diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index 67a011de..b830b555 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -9,6 +9,7 @@ @@ -57,18 +58,12 @@
+ @@ -217,7 +212,9 @@ export default defineComponent({ }, provide() { return { + doc: computed(() => this.sinvDoc), cashAmount: computed(() => this.cashAmount), + isDiscountingEnabled: computed(() => this.isDiscountingEnabled), itemDiscounts: computed(() => this.itemDiscounts), itemQtyMap: computed(() => this.itemQtyMap), itemSerialNumbers: computed(() => this.itemSerialNumbers), @@ -255,6 +252,11 @@ export default defineComponent({ }; }, computed: { + defaultPOSCashAccount: () => + fyo.singles.POSSettings?.cashAccount ?? undefined, + isDiscountingEnabled(): boolean { + return !!fyo.singles.AccountingSettings?.enableDiscounting; + }, isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, }, watch: { @@ -294,6 +296,7 @@ export default defineComponent({ this.sinvDoc = this.fyo.doc.getNewDoc(ModelNameEnum.SalesInvoice, { account: 'Debtors', party: this.sinvDoc.party ?? this.defaultCustomer, + isPOS: true, }) as SalesInvoice; }, setTotalQuantity() { @@ -404,7 +407,6 @@ export default defineComponent({ } }, async makePayment() { - await validateShipment(this.itemSerialNumbers); const paymentMethod = this.cashAmount.isZero() ? 'Transfer' : 'Cash'; await this.paymentDoc.set('paymentMethod', paymentMethod); @@ -417,35 +419,39 @@ export default defineComponent({ } if (paymentMethod === 'Cash') { - await this.paymentDoc.set('amount', this.cashAmount as Money); + await this.paymentDoc.setMultiple({ + paymentAccount: this.defaultPOSCashAccount, + amount: this.cashAmount as Money, + }); } try { await this.paymentDoc?.sync(); await this.paymentDoc?.submit(); } catch (error) { - showToast({ + return showToast({ type: 'error', message: t`${error as string}`, }); } }, async makeStockTransfer() { - const shipment = (await this.sinvDoc.getStockTransfer()) as Shipment; - if (!shipment.items) { + const shipmentDoc = (await this.sinvDoc.getStockTransfer()) as Shipment; + if (!shipmentDoc.items) { return; } - for (const item of shipment.items) { + for (const item of shipmentDoc.items) { + item.location = fyo.singles.POSSettings?.inventory; item.serialNumber = this.itemSerialNumbers[item.item as string] ?? undefined; } try { - await shipment.sync(); - await shipment.submit(); + await shipmentDoc.sync(); + await shipmentDoc.submit(); } catch (error) { - showToast({ + return showToast({ type: 'error', message: t`${error as string}`, }); @@ -455,12 +461,11 @@ export default defineComponent({ try { await this.validate(); await this.sinvDoc.runFormulas(); - await this.sinvDoc._callAllTableFieldsApplyFormula(); await this.sinvDoc.sync(); await this.sinvDoc.submit(); this.paymentDoc = this.sinvDoc.getPayment() as Payment; } catch (error) { - showToast({ + return showToast({ type: 'error', message: t`${error as string}`, }); diff --git a/src/router.ts b/src/router.ts index 53b19750..4e7b7932 100644 --- a/src/router.ts +++ b/src/router.ts @@ -128,8 +128,14 @@ const routes: RouteRecordRaw[] = [ { path: '/pos', name: 'Point of Sale', - component: POS, - props: {}, + components: { + default: POS, + edit: QuickEditForm, + }, + props: { + default: true, + edit: (route) => route.query, + }, }, ];