[patch] Fix outstanding amount for original invoice for return entry
This commit is contained in:
parent
ad44b00f33
commit
5bbe823106
@ -554,17 +554,17 @@ def get_outstanding(args):
|
||||
|
||||
against_jv_amount = flt(against_jv_amount[0][0]) if against_jv_amount else 0
|
||||
return {
|
||||
"credit" if against_jv_amount > 0 else "debit": abs(against_jv_amount)
|
||||
("credit" if against_jv_amount > 0 else "debit"): abs(against_jv_amount)
|
||||
}
|
||||
elif args.get("doctype") == "Sales Invoice":
|
||||
outstanding_amount = flt(frappe.db.get_value("Sales Invoice", args["docname"], "outstanding_amount"))
|
||||
return {
|
||||
"credit" if outstanding_amount > 0 else "debit": abs(outstanding_amount)
|
||||
("credit" if outstanding_amount > 0 else "debit"): abs(outstanding_amount)
|
||||
}
|
||||
elif args.get("doctype") == "Purchase Invoice":
|
||||
outstanding_amount = flt(frappe.db.get_value("Purchase Invoice", args["docname"], "outstanding_amount"))
|
||||
return {
|
||||
"debit" if outstanding_amount > 0 else "credit": abs(outstanding_amount)
|
||||
("debit" if outstanding_amount > 0 else "credit"): abs(outstanding_amount)
|
||||
}
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -136,7 +136,9 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
||||
"doctype": doctype + " Item",
|
||||
"fields": {
|
||||
"purchase_order": "purchase_order",
|
||||
"purchase_receipt": "purchase_receipt"
|
||||
"purchase_receipt": "purchase_receipt",
|
||||
"serial_no": "serial_no",
|
||||
"batch_no": "batch_no"
|
||||
},
|
||||
"postprocess": update_item
|
||||
},
|
||||
|
12
erpnext/patches/v5_4/fix_invoice_outstanding.py
Normal file
12
erpnext/patches/v5_4/fix_invoice_outstanding.py
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
|
||||
|
||||
def execute():
|
||||
return_entries = frappe.get_list("Sales Invoice", filters={"is_return": 1, "docstatus": 1},
|
||||
fields=["debit_to", "customer", "return_against"])
|
||||
for d in return_entries:
|
||||
update_outstanding_amt(d.debit_to, "Customer", d.customer, "Sales Invoice", d.return_against)
|
Loading…
x
Reference in New Issue
Block a user