2
0
mirror of https://github.com/frappe/books.git synced 2024-09-19 19:19:02 +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", "label": "Counter Cash Account",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Account", "target": "Account",
"default": "Cash In Hand",
"required": true, "required": true,
"create": true, "create": true,
"section": "Default" "section": "Default"

View File

@ -142,7 +142,7 @@
<Button <Button
class="mt-4 w-full bg-green-500 py-6" class="mt-4 w-full bg-green-500 py-6"
:disabled="!sinvDoc.items?.length" :disabled="disablePayButton"
@click="toggleModal('Payment', true)" @click="toggleModal('Payment', true)"
> >
<slot> <slot>
@ -273,6 +273,16 @@ export default defineComponent({
} }
return true; return true;
}, },
disablePayButton(): boolean {
if (!this.sinvDoc.items?.length) {
return true;
}
if (!this.sinvDoc.party) {
return true;
}
return false;
},
}, },
watch: { watch: {
sinvDoc: { sinvDoc: {

View File

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

View File

@ -211,6 +211,14 @@ export async function transferPOSCashAndWriteOff(
fyo: Fyo, fyo: Fyo,
posShiftDoc: POSShift posShiftDoc: POSShift
) { ) {
const differenceAmount = posShiftDoc?.closingAmounts?.find(
(row) => row.paymentMethod === 'Cash'
)?.differenceAmount as Money;
if (differenceAmount.isZero()) {
return;
}
const closingCashAmount = posShiftDoc.closingAmounts?.find( const closingCashAmount = posShiftDoc.closingAmounts?.find(
(row) => row.paymentMethod === 'Cash' (row) => row.paymentMethod === 'Cash'
)?.closingAmount as Money; )?.closingAmount as Money;
@ -229,10 +237,6 @@ export async function transferPOSCashAndWriteOff(
credit: closingCashAmount, credit: closingCashAmount,
}); });
const differenceAmount = posShiftDoc?.closingAmounts?.find(
(row) => row.paymentMethod === 'Cash'
)?.differenceAmount as Money;
if (differenceAmount.isNegative()) { if (differenceAmount.isNegative()) {
await jvDoc.append('accounts', { await jvDoc.append('accounts', {
account: AccountTypeEnum.Cash, account: AccountTypeEnum.Cash,