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
+13 -2
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,
});
},
};