2
0
mirror of https://github.com/frappe/books.git synced 2025-02-10 07:59:03 +00:00

Submit payment on a fresh doc

This commit is contained in:
Faris Ansari 2018-10-26 02:25:47 +05:30
parent db207f2502
commit 89e0436c35

View File

@ -89,6 +89,12 @@ module.exports = {
disabled: true,
readOnly: 1
},
{
fieldname: 'outstandingAmount',
label: 'Outstanding Amount',
fieldtype: 'Currency',
hidden: 1
},
{
fieldname: 'terms',
label: 'Terms',
@ -131,15 +137,17 @@ module.exports = {
utils.ledgerLink,
{
label: 'Make Payment',
condition: form => form.doc.submitted,
condition: form => form.doc.submitted && form.doc.outstandingAmount !== 0.0,
action: async form => {
const payment = await frappe.getNewDoc('Payment');
payment.party = form.doc.customer;
payment.account = form.doc.account;
payment.for = [{ referenceType: form.doc.doctype, referenceName: form.doc.name, amount: form.doc.grandTotal }];
payment.on('afterInsert', () => {
payment.on('afterInsert', async () => {
form.$formModal.close();
payment.submit();
const _payment = await frappe.getDoc('Payment', payment.name);
await _payment.submit();
})
await form.$formModal.open(payment);
}