mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
fix(ux): disable Pay, Submit buttons on conditions
This commit is contained in:
parent
97f9fbb80b
commit
a76953776b
@ -18,6 +18,7 @@
|
||||
"label": "Counter Cash Account",
|
||||
"fieldtype": "Link",
|
||||
"target": "Account",
|
||||
"default": "Cash In Hand",
|
||||
"required": true,
|
||||
"create": true,
|
||||
"section": "Default"
|
||||
|
@ -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: {
|
||||
|
@ -300,6 +300,13 @@ export default defineComponent({
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
this.cashAmount.isZero() &&
|
||||
(!this.transferRefNo || !this.transferClearanceDate)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user