diff --git a/src/components/POS/types.ts b/src/components/POS/types.ts index 31102b68..e80cc89b 100644 --- a/src/components/POS/types.ts +++ b/src/components/POS/types.ts @@ -8,7 +8,7 @@ export type ItemSerialNumbers = { [item: string]: string }; export type DiscountType = "percent" | "amount"; -export type ModalName = 'ShiftOpen' | 'ShiftClose' | 'Payment' | 'LoyaltyProgram' | 'RouteToInvoiceList' +export type ModalName = 'ShiftOpen' | 'ShiftClose' | 'Payment' | 'LoyaltyProgram' | 'SavedInvoice' | 'RouteToInvoiceList' export interface POSItem { image?:string, diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index 9e1cf014..7281dfb8 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -29,6 +29,12 @@ @set-loyalty-points="setLoyaltyPoints" @toggle-modal="toggleModal" /> + +
+
+ + +
+
+ -
- - - + +
@@ -403,6 +433,7 @@ import Barcode from 'src/components/Controls/Barcode.vue'; import { getAddedLPWithGrandTotal, getPricingRule } from 'models/helpers'; import LoyaltyProgramModal from './LoyaltyprogramModal.vue'; import AlertModal from './AlertModal.vue'; +import SavedInvoiceModal from './SavedInvoiceModal.vue'; export default defineComponent({ name: 'POS', @@ -419,6 +450,7 @@ export default defineComponent({ PageHeader, PaymentModal, LoyaltyProgramModal, + SavedInvoiceModal, SelectedItemTable, Barcode, }, @@ -446,6 +478,7 @@ export default defineComponent({ isItemsSeeded: false, openPaymentModal: false, openLoyaltyProgramModal: false, + openSavedInvoiceModal: false, openShiftCloseModal: false, openShiftOpenModal: false, openRouteToInvoiceListModal: false, @@ -541,6 +574,26 @@ export default defineComponent({ this.loyaltyProgram = party[0]?.loyaltyProgram as string; this.loyaltyPoints = party[0].loyaltyPoints as number; }, + async saveOrder() { + try { + await this.validate(); + await this.sinvDoc.runFormulas(); + await this.sinvDoc.sync(); + } catch (error) { + return showToast({ + type: 'error', + message: t`${error as string}`, + }); + } + + showToast({ + type: 'success', + message: t`Sales Invoice ${this.sinvDoc.name as string} is Saved`, + duration: 'short', + }); + + await this.afterSync(); + }, async setItems() { const items = (await fyo.db.getAll(ModelNameEnum.Item, { fields: [], @@ -620,6 +673,15 @@ export default defineComponent({ this.sinvDoc.grandTotal = total; }, + async selectedInvoiceName(doc: SalesInvoice) { + const salesInvoiceDoc = (await this.fyo.doc.getDoc( + ModelNameEnum.SalesInvoice, + doc.name + )) as SalesInvoice; + + this.sinvDoc = salesInvoiceDoc; + this.toggleModal('SavedInvoice', false); + }, setTransferAmount(amount: Money = fyo.pesa(0)) { this.transferAmount = amount; }, @@ -832,7 +894,10 @@ export default defineComponent({ }); } }, - + async afterSync() { + await this.clearValues(); + this.setSinvDoc(); + }, async afterTransaction() { await this.setItemQtyMap(); await this.clearValues(); @@ -890,12 +955,18 @@ export default defineComponent({ }, 1); }, async routeToSinvList() { - if (!this.sinvDoc.items.length) { + if (!this.sinvDoc.items?.length) { return await routeTo('/list/SalesInvoice'); } this.openRouteToInvoiceListModal = true; }, + async handleSaveInvoiceAction() { + if (!this.sinvDoc.party && !this.sinvDoc.items?.length) { + return; + } + await this.saveOrder(); + }, routeTo, getItem, }, diff --git a/src/pages/POS/SavedInvoiceModal.vue b/src/pages/POS/SavedInvoiceModal.vue new file mode 100644 index 00000000..c12b66f5 --- /dev/null +++ b/src/pages/POS/SavedInvoiceModal.vue @@ -0,0 +1,186 @@ + + +