From b8ce9673d4fc242da87afd23d4c1d9a25a02e9d5 Mon Sep 17 00:00:00 2001 From: AbleKSaju <126228406+AbleKSaju@users.noreply.github.com> Date: Sat, 28 Dec 2024 11:58:31 +0530 Subject: [PATCH] feat: submit and print functionality from POS --- src/pages/POS/POS.vue | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index 6bd2c8eb..3a66fdf6 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -575,8 +575,8 @@ export default defineComponent({ async createTransaction(shouldPrint = false) { try { await this.validate(); - await this.submitSinvDoc(shouldPrint); - await this.makePayment(); + await this.submitSinvDoc(); + await this.makePayment(shouldPrint); await this.makeStockTransfer(); await this.afterTransaction(); await this.setItems(); @@ -587,7 +587,7 @@ export default defineComponent({ }); } }, - async makePayment() { + async makePayment(shouldPrint: boolean) { this.paymentDoc = this.sinvDoc.getPayment() as Payment; const paymentMethod = this.paymentMethod; @@ -623,6 +623,13 @@ export default defineComponent({ try { await this.paymentDoc?.sync(); await this.paymentDoc?.submit(); + + if (shouldPrint) { + await routeTo( + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `/print/${this.sinvDoc.schemaName}/${this.sinvDoc.name}` + ); + } } catch (error) { return showToast({ type: 'error', @@ -660,20 +667,13 @@ export default defineComponent({ }); } }, - async submitSinvDoc(shouldPrint: boolean) { - this.sinvDoc.once('afterSubmit', async () => { + async submitSinvDoc() { + this.sinvDoc.once('afterSubmit', () => { showToast({ type: 'success', message: t`Sales Invoice ${this.sinvDoc.name as string} is Submitted`, duration: 'short', }); - - if (shouldPrint) { - await routeTo( - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - `/print/${this.sinvDoc.schemaName}/${this.sinvDoc.name}` - ); - } }); try {