mirror of
https://github.com/frappe/books.git
synced 2025-02-11 08:28:47 +00:00
Submit payment on a fresh doc
This commit is contained in:
parent
db207f2502
commit
89e0436c35
@ -89,6 +89,12 @@ module.exports = {
|
|||||||
disabled: true,
|
disabled: true,
|
||||||
readOnly: 1
|
readOnly: 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname: 'outstandingAmount',
|
||||||
|
label: 'Outstanding Amount',
|
||||||
|
fieldtype: 'Currency',
|
||||||
|
hidden: 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'terms',
|
fieldname: 'terms',
|
||||||
label: 'Terms',
|
label: 'Terms',
|
||||||
@ -131,15 +137,17 @@ module.exports = {
|
|||||||
utils.ledgerLink,
|
utils.ledgerLink,
|
||||||
{
|
{
|
||||||
label: 'Make Payment',
|
label: 'Make Payment',
|
||||||
condition: form => form.doc.submitted,
|
condition: form => form.doc.submitted && form.doc.outstandingAmount !== 0.0,
|
||||||
action: async form => {
|
action: async form => {
|
||||||
const payment = await frappe.getNewDoc('Payment');
|
const payment = await frappe.getNewDoc('Payment');
|
||||||
payment.party = form.doc.customer;
|
payment.party = form.doc.customer;
|
||||||
payment.account = form.doc.account;
|
payment.account = form.doc.account;
|
||||||
payment.for = [{ referenceType: form.doc.doctype, referenceName: form.doc.name, amount: form.doc.grandTotal }];
|
payment.for = [{ referenceType: form.doc.doctype, referenceName: form.doc.name, amount: form.doc.grandTotal }];
|
||||||
payment.on('afterInsert', () => {
|
payment.on('afterInsert', async () => {
|
||||||
form.$formModal.close();
|
form.$formModal.close();
|
||||||
payment.submit();
|
|
||||||
|
const _payment = await frappe.getDoc('Payment', payment.name);
|
||||||
|
await _payment.submit();
|
||||||
})
|
})
|
||||||
await form.$formModal.open(payment);
|
await form.$formModal.open(payment);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user