diff --git a/schemas/app/inventory/Point of Sale/POSSettings.json b/schemas/app/inventory/Point of Sale/POSSettings.json index efb8d70a0..a51ec0ccf 100644 --- a/schemas/app/inventory/Point of Sale/POSSettings.json +++ b/schemas/app/inventory/Point of Sale/POSSettings.json @@ -51,7 +51,7 @@ "section": "Default" }, { - "fieldname": " ", + "fieldname": "submitInvoice", "label": "Post Payment", "fieldtype": "Check", "default": false, diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index 7e78859e2..81584f51c 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -138,6 +138,7 @@ import { ItemQtyMap, ItemSerialNumbers, } from 'src/components/POS/types'; +import { ValidationError } from 'fyo/utils/errors'; const COMPONENT_NAME = 'POS'; @@ -477,19 +478,25 @@ export default defineComponent({ }, async addItem(item: POSItem | Item | undefined) { - await this.sinvDoc.runFormulas(); + try { + if (this.sinvDoc.isSubmitted) { + throw new ValidationError( + t`Cannot add an item to a submitted invoice.` + ); + } - if (!item) { - return; - } + await this.sinvDoc.runFormulas(); - const existingItems = - this.sinvDoc.items?.filter( - (invoiceItem) => - invoiceItem.item === item.name && !invoiceItem.isFreeItem - ) ?? []; + if (!item) { + return; + } + + const existingItems = + this.sinvDoc.items?.filter( + (invoiceItem) => + invoiceItem.item === item.name && !invoiceItem.isFreeItem + ) ?? []; - try { if (item.hasBatch) { for (const invItem of existingItems) { const itemQty = invItem.quantity ?? 0; diff --git a/src/pages/POS/SavedInvoiceModal.vue b/src/pages/POS/SavedInvoiceModal.vue index 5cf573eab..3db5f3f99 100644 --- a/src/pages/POS/SavedInvoiceModal.vue +++ b/src/pages/POS/SavedInvoiceModal.vue @@ -8,7 +8,7 @@ @@ -16,7 +16,7 @@