2
0
mirror of https://github.com/frappe/books.git synced 2025-02-06 22:18:34 +00:00

chore: rename Quick Payment to Auto Payment

- ∵ more semantically correct
This commit is contained in:
18alantom 2023-04-20 13:12:20 +05:30
parent 759bedf764
commit 19aa0d949a
5 changed files with 21 additions and 21 deletions

View File

@ -3,7 +3,7 @@ import { FiltersMap, HiddenMap } from 'fyo/model/types';
import { ModelNameEnum } from 'models/types';
export class Defaults extends Doc {
// Quick Payments
// Auto Payments
salesPaymentAccount?: string;
purchasePaymentAccount?: string;
@ -32,7 +32,7 @@ export class Defaults extends Doc {
stockMovementPrintTemplate?: string;
static commonFilters = {
// Quick Payments
// Auto Payments
salesPaymentAccount: () => ({ isGroup: false, accountType: 'Cash' }),
purchasePaymentAccount: () => ({ isGroup: false, accountType: 'Cash' }),
// Number Series

View File

@ -47,7 +47,7 @@ export abstract class Invoice extends Transactional {
submitted?: boolean;
cancelled?: boolean;
makeQuickPayment?: boolean;
makeAutoPayment?: boolean;
get isSales() {
return this.schemaName === 'SalesInvoice';
@ -91,7 +91,7 @@ export abstract class Invoice extends Transactional {
return !this.baseGrandTotal?.eq(this.outstandingAmount!);
}
get quickPaymentAccount(): string | null {
get autoPaymentAccount(): string | null {
const fieldname = this.isSales
? 'salesPaymentAccount'
: 'purchasePaymentAccount';
@ -130,7 +130,7 @@ export abstract class Invoice extends Transactional {
const party = (await this.fyo.doc.getDoc('Party', this.party!)) as Party;
await party.updateOutstandingAmount();
if (this.makeQuickPayment && this.quickPaymentAccount) {
if (this.makeAutoPayment && this.autoPaymentAccount) {
const payment = this.getPayment();
await payment?.sync();
await payment?.submit();
@ -409,8 +409,8 @@ export abstract class Invoice extends Transactional {
},
dependsOn: ['items'],
},
makeQuickPayment: {
formula: () => !!this.quickPaymentAccount,
makeAutoPayment: {
formula: () => !!this.autoPaymentAccount,
dependsOn: [],
},
};
@ -448,12 +448,12 @@ export abstract class Invoice extends Transactional {
}
hidden: HiddenMap = {
makeQuickPayment: () => {
makeAutoPayment: () => {
if (this.submitted) {
return true;
}
if (!this.quickPaymentAccount) {
if (!this.autoPaymentAccount) {
return true;
}
@ -481,8 +481,8 @@ export abstract class Invoice extends Transactional {
};
static defaults: DefaultMap = {
makeQuickPayment: (doc) =>
doc instanceof Invoice && !!doc.quickPaymentAccount,
makeAutoPayment: (doc) =>
doc instanceof Invoice && !!doc.autoPaymentAccount,
numberSeries: (doc) => getNumberSeries(doc.schemaName, doc.fyo),
terms: (doc) => {
const defaults = doc.fyo.singles.Defaults as Defaults | undefined;
@ -563,9 +563,9 @@ export abstract class Invoice extends Transactional {
],
};
if (this.makeQuickPayment && this.quickPaymentAccount) {
const quickPaymentAccount = this.isSales ? 'paymentAccount' : 'account';
data[quickPaymentAccount] = this.quickPaymentAccount;
if (this.makeAutoPayment && this.autoPaymentAccount) {
const autoPaymentAccount = this.isSales ? 'paymentAccount' : 'account';
data[autoPaymentAccount] = this.autoPaymentAccount;
}
return this.fyo.doc.getNewDoc(ModelNameEnum.Payment, data) as Payment;

View File

@ -10,7 +10,7 @@
"fieldtype": "Link",
"target": "Account",
"create": true,
"section": "Quick Payments"
"section": "Auto Payments"
},
{
"fieldname": "purchasePaymentAccount",
@ -18,7 +18,7 @@
"fieldtype": "Link",
"target": "Account",
"create": true,
"section": "Quick Payments"
"section": "Auto Payments"
},
{
"fieldname": "salesInvoiceNumberSeries",

View File

@ -140,7 +140,7 @@
"tab": "Settings"
},
{
"fieldname": "makeQuickPayment",
"fieldname": "makeAutoPayment",
"label": "Make Payment On Submit",
"fieldtype": "Check",
"computed": true,

View File

@ -589,16 +589,16 @@ async function showSubmitOrSyncDialog(doc: Doc, type: 'submit' | 'sync') {
function getDocSubmitMessage(doc: Doc): string {
const details = [t`Mark ${doc.schema.label} as submitted?`];
if (doc instanceof SalesInvoice && doc.makeQuickPayment) {
const toAccount = doc.quickPaymentAccount!;
if (doc instanceof SalesInvoice && doc.makeAutoPayment) {
const toAccount = doc.autoPaymentAccount!;
const fromAccount = doc.account!;
const amount = fyo.format(doc.outstandingAmount, 'Currency');
details.push(
t`Payment of ${amount} will be made from account "${fromAccount}" to account "${toAccount}" on Submit.`
);
} else if (doc instanceof PurchaseInvoice && doc.makeQuickPayment) {
const fromAccount = doc.quickPaymentAccount!;
} else if (doc instanceof PurchaseInvoice && doc.makeAutoPayment) {
const fromAccount = doc.autoPaymentAccount!;
const toAccount = doc.account!;
const amount = fyo.format(doc.outstandingAmount, 'Currency');