fix: capture advance payments in payment order

This commit is contained in:
Mangesh-Khairnar 2020-09-04 12:17:56 +05:30
parent 2badd93d8f
commit 8d8af94182
2 changed files with 15 additions and 27 deletions

View File

@ -1172,30 +1172,23 @@ def make_payment_order(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
target.payment_order_type = "Payment Entry"
target.append('references', dict(
reference_doctype="Payment Entry",
reference_name=source.name,
bank_account=source.party_bank_account,
amount=source.paid_amount,
account=source.paid_to,
supplier=source.party,
mode_of_payment=source.mode_of_payment,
))
def update_item(source_doc, target_doc, source_parent):
target_doc.bank_account = source_parent.party_bank_account
target_doc.amount = source_doc.allocated_amount
target_doc.account = source_parent.paid_to
target_doc.payment_entry = source_parent.name
target_doc.supplier = source_parent.party
target_doc.mode_of_payment = source_parent.mode_of_payment
doclist = get_mapped_doc("Payment Entry", source_name, {
doclist = get_mapped_doc("Payment Entry", source_name, {
"Payment Entry": {
"doctype": "Payment Order",
"validation": {
"docstatus": ["=", 1]
}
},
"Payment Entry Reference": {
"doctype": "Payment Order Reference",
"validation": {
"docstatus": ["=", 1]
},
"postprocess": update_item
},
}
}, target_doc, set_missing_values)

View File

@ -1,4 +1,5 @@
{
"actions": [],
"creation": "2018-07-20 16:38:06.630813",
"doctype": "DocType",
"editable_grid": 1,
@ -10,7 +11,6 @@
"column_break_4",
"supplier",
"payment_request",
"payment_entry",
"mode_of_payment",
"bank_account_details",
"bank_account",
@ -103,17 +103,12 @@
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "payment_entry",
"fieldtype": "Link",
"label": "Payment Entry",
"options": "Payment Entry",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"modified": "2019-05-08 13:56:25.724557",
"links": [],
"modified": "2020-09-04 08:29:51.014390",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Order Reference",