Skip to content

Commit

Permalink
fix(ux): disable Pay, Submit buttons on conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayitzme committed Dec 4, 2023
1 parent 97f9fbb commit a769537
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions schemas/app/inventory/Point of Sale/POSSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"label": "Counter Cash Account",
"fieldtype": "Link",
"target": "Account",
"default": "Cash In Hand",
"required": true,
"create": true,
"section": "Default"
Expand Down
12 changes: 11 additions & 1 deletion src/pages/POS/POS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@

<Button
class="mt-4 w-full bg-green-500 py-6"
:disabled="!sinvDoc.items?.length"
:disabled="disablePayButton"
@click="toggleModal('Payment', true)"
>
<slot>
Expand Down Expand Up @@ -273,6 +273,16 @@ export default defineComponent({
}
return true;
},
disablePayButton(): boolean {
if (!this.sinvDoc.items?.length) {
return true;
}
if (!this.sinvDoc.party) {
return true;
}
return false;
},
},
watch: {
sinvDoc: {
Expand Down
7 changes: 7 additions & 0 deletions src/pages/POS/PaymentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ export default defineComponent({
) {
return true;
}
if (
this.cashAmount.isZero() &&
(!this.transferRefNo || !this.transferClearanceDate)
) {
return true;
}
return false;
},
},
Expand Down
12 changes: 8 additions & 4 deletions src/utils/pos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ export async function transferPOSCashAndWriteOff(
fyo: Fyo,
posShiftDoc: POSShift
) {
const differenceAmount = posShiftDoc?.closingAmounts?.find(
(row) => row.paymentMethod === 'Cash'
)?.differenceAmount as Money;

if (differenceAmount.isZero()) {
return;
}

const closingCashAmount = posShiftDoc.closingAmounts?.find(
(row) => row.paymentMethod === 'Cash'
)?.closingAmount as Money;
Expand All @@ -229,10 +237,6 @@ export async function transferPOSCashAndWriteOff(
credit: closingCashAmount,
});

const differenceAmount = posShiftDoc?.closingAmounts?.find(
(row) => row.paymentMethod === 'Cash'
)?.differenceAmount as Money;

if (differenceAmount.isNegative()) {
await jvDoc.append('accounts', {
account: AccountTypeEnum.Cash,
Expand Down

0 comments on commit a769537

Please sign in to comment.