2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

fix(ux): disable Pay, Submit buttons on conditions

This commit is contained in:
akshayitzme 2023-12-02 19:53:55 +05:30
parent 97f9fbb80b
commit a76953776b
4 changed files with 27 additions and 5 deletions

View File

@ -18,6 +18,7 @@
"label": "Counter Cash Account",
"fieldtype": "Link",
"target": "Account",
"default": "Cash In Hand",
"required": true,
"create": true,
"section": "Default"

View File

@ -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>
@ -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: {

View File

@ -300,6 +300,13 @@ export default defineComponent({
) {
return true;
}
if (
this.cashAmount.isZero() &&
(!this.transferRefNo || !this.transferClearanceDate)
) {
return true;
}
return false;
},
},

View File

@ -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;
@ -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,