2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 14:50:56 +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( async _applyFormula(
changedFieldname?: string, changedFieldname?: string,
retriggerChildDocApplyChange?: boolean retriggerChildDocApplyChange?: boolean

View File

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

View File

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