diff --git a/src/components/POS/Classic/SelectedItemRow.vue b/src/components/POS/Classic/SelectedItemRow.vue index cc579f49..dd48f416 100644 --- a/src/components/POS/Classic/SelectedItemRow.vue +++ b/src/components/POS/Classic/SelectedItemRow.vue @@ -27,19 +27,34 @@

- +
+ +
+ + +
+
@@ -274,7 +273,6 @@ fyo.singles.Defaults?.cancelButtonColour, }" :class="`${isReturnInvoiceEnabledReturn ? 'py-5' : 'py-6'}`" - :disabled="!sinvDoc?.items?.length" @click="() => $emit('clearValues')" > @@ -332,8 +330,7 @@ fyo.singles.Defaults?.payButtonColour, }" :class="`${isReturnInvoiceEnabledReturn ? 'py-5' : 'py-6'}`" - :disabled="disablePayButton" - @click="emitEvent('toggleModal', 'Payment', true)" + @click="emitEvent('handlePaymentAction')" >

@@ -350,8 +347,7 @@ profile?.payButtonColour || fyo.singles.Defaults?.payButtonColour, }" - :disabled="disablePayButton" - @click="emitEvent('toggleModal', 'Payment', true)" + @click="emitEvent('handlePaymentAction')" >

@@ -506,6 +502,7 @@ export default defineComponent({ 'selectedReturnInvoice', 'setTransferClearanceDate', 'saveAndContinue', + 'handlePaymentAction', ], data() { return { diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index 9e19cbf1..fc4a5b74 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -62,6 +62,7 @@ @selected-return-invoice="selectedReturnInvoice" @set-transfer-clearance-date="setTransferClearanceDate" @save-and-continue="handleSaveAndContinue" + @handle-payment-action="handlePaymentAction" /> -

+

{{ t`Submit` }}

@@ -170,7 +166,7 @@ backgroundColor: fyo.singles.Defaults?.cancelButtonColour, }" style="padding: 1.35rem" - @click="cancelTransaction()" + @click="cancelTransaction" >

@@ -185,8 +181,7 @@ class="w-full" :style="{ backgroundColor: fyo.singles.Defaults?.payButtonColour }" style="padding: 1.35rem" - :disabled="disablePayButton" - @click="payTransaction()" + @click="payTransaction" >

@@ -203,8 +198,7 @@ backgroundColor: fyo.singles.Defaults?.payAndPrintButtonColour, }" style="padding: 1.35rem" - :disabled="disablePayButton" - @click="$emit('createTransaction', true, true)" + @click="payAndPrintTransaction" >

@@ -230,6 +224,7 @@ import { defineComponent, inject } from 'vue'; import { fyo } from 'src/initFyo'; import { isPesa } from 'fyo/utils'; import { ModelNameEnum } from 'models/types'; +import { showToast } from 'src/utils/interactive'; export default defineComponent({ name: 'PaymentModal', @@ -331,45 +326,6 @@ export default defineComponent({ return true; } - return false; - }, - disableSubmitButton(): boolean { - if (this.sinvDoc.submitted) { - return true; - } - - if ( - (this.sinvDoc.grandTotal?.float as number) < 1 && - this.fyo.pesa(this.paidAmount.float).isZero() && - !this.sinvDoc.returnAgainst - ) { - return true; - } - - if ( - !this.paymentMethod && - (!this.transferRefNo || !this.transferClearanceDate) - ) { - return true; - } - return false; - }, - disablePayButton(): boolean { - if ( - (this.sinvDoc.grandTotal?.float as number) < 1 && - this.fyo.pesa(this.paidAmount.float).isZero() && - !this.sinvDoc.returnAgainst - ) { - return true; - } - - if ( - !this.paymentMethod && - (!this.transferRefNo || !this.transferClearanceDate) - ) { - return true; - } - return false; }, }, @@ -394,11 +350,39 @@ export default defineComponent({ ).map((d) => d.name); }, submitTransaction() { + if (!this.paymentMethod) { + return showToast({ + type: 'error', + message: this.fyo + .t`Please select a payment method before submitting.`, + }); + return; + } this.$emit('createTransaction'); }, payTransaction() { + if (!this.paymentMethod) { + return showToast({ + type: 'error', + message: this.fyo + .t`Please select a payment method before proceeding with payment.`, + }); + return; + } this.$emit('createTransaction', false, true); }, + payAndPrintTransaction() { + if (!this.paymentMethod) { + return showToast({ + type: 'error', + message: this.fyo + .t`Please select a payment method before proceeding with payment.`, + }); + return; + } + + this.$emit('createTransaction', true, true); + }, cancelTransaction() { this.$emit('setPaidAmount', fyo.pesa(0)); this.$emit('toggleModal', 'Payment');