diff --git a/fyo/model/doc.ts b/fyo/model/doc.ts index 5d89ae91..e52b81b6 100644 --- a/fyo/model/doc.ts +++ b/fyo/model/doc.ts @@ -758,6 +758,10 @@ export class Doc extends Observable { } } + async runFormulas() { + await this._applyFormula(); + } + async _applyFormula( changedFieldname?: string, retriggerChildDocApplyChange?: boolean diff --git a/models/helpers.ts b/models/helpers.ts index 5ad20abc..a992db42 100644 --- a/models/helpers.ts +++ b/models/helpers.ts @@ -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, }); }, }; diff --git a/src/components/FormContainer.vue b/src/components/FormContainer.vue index 95e26426..0bcf5981 100644 --- a/src/components/FormContainer.vue +++ b/src/components/FormContainer.vue @@ -27,6 +27,7 @@ overflow-auto mb-4 bg-white + mx-4 " >