From 0faf9f5f8c1fca976fc91aaa9ca78c451c2ca3f4 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Fri, 3 May 2019 21:18:24 +0530 Subject: [PATCH] feat: add mapping logic for creating payment order --- .../doctype/payment_entry/payment_entry.py | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 928d9a02dc..2c56dc40ed 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -970,20 +970,28 @@ def get_party_and_account_balance(company, date, paid_from=None, paid_to=None, p @frappe.whitelist() def make_payment_order(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc def set_missing_values(source, target): - target.append('references', { - 'amount': source.base_paid_amount, - 'supplier': source.party, - 'payment_request': source_name, - 'mode_of_payment': source.mode_of_payment, - 'bank_account': source.bank_account, - 'account': source.account - }) + pass - doclist = get_mapped_doc("Payment Request", source_name, { - "Payment Request": { + def update_item(source_doc, target_doc, source_parent): + target_doc.bank_account = source_parent.bank_account + target_doc.amount = source_parent.base_paid_amount + target_doc.account = source_parent.paid_to or source_parent.paid_from + target_doc.payment_entry = source_doc.name + target_doc.supplier = source_doc.party + target_doc.mode_of_payment = source_doc.mode_of_payment + + + doclist = get_mapped_doc("Payment Entry", source_name, { + "Payment Entry": { "doctype": "Payment Order", - } + }, + "Payment Entry Reference": { + "doctype": "Payment Order Reference", + "postprocess": update_item + }, + }, target_doc, set_missing_values) return doclist