2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 19:09:01 +00:00

fix: make payment flow

This commit is contained in:
18alantom 2023-04-19 13:13:46 +05:30
parent a829e23bda
commit ef3f23bf2b
3 changed files with 18 additions and 2 deletions

View File

@ -758,6 +758,10 @@ export class Doc extends Observable<DocValue | Doc[]> {
}
}
async runFormulas() {
await this._applyFormula();
}
async _applyFormula(
changedFieldname?: string,
retriggerChildDocApplyChange?: boolean

View File

@ -61,20 +61,31 @@ export function getMakePaymentAction(fyo: Fyo): Action {
group: fyo.t`Create`,
condition: (doc: Doc) =>
doc.isSubmitted && !(doc.outstandingAmount as Money).isZero(),
action: async (doc: Doc) => {
action: async (doc, router) => {
const payment = (doc as Invoice).getPayment();
if (!payment) {
return;
}
const currentRoute = router.currentRoute.value.fullPath;
payment.once('afterSync', async () => {
await payment.submit();
await doc.load();
await router.push(currentRoute);
});
const hideFields = ['party', 'paymentType', 'for'];
if (doc.schemaName === ModelNameEnum.SalesInvoice) {
hideFields.push('account');
} else {
hideFields.push('paymentAccount');
}
await payment.runFormulas();
const { openQuickEdit } = await import('src/utils/ui');
await openQuickEdit({
doc: payment,
hideFields: ['party', 'paymentType', 'for'],
hideFields,
});
},
};

View File

@ -27,6 +27,7 @@
overflow-auto
mb-4
bg-white
mx-4
"
>
<slot name="body" />