Skip to content

Commit

Permalink
Merge pull request #1356 from Bloomstack/bs-may-sprint-2
Browse files Browse the repository at this point in the history
Merge branch bs-may-sprint-2 into pre-release
  • Loading branch information
sahil28297 authored Jun 4, 2021
2 parents acedc42 + cded519 commit 3257650
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -720,4 +720,5 @@ erpnext.patches.v13_0.make_mobile_application_access_roles #2021-04-08
erpnext.patches.v13_0.delete_company_custom_fields
execute:frappe.reload_doc('setup', 'doctype', 'company', force=True)
erpnext.patches.v13_0.set_is_used #01-04-2021
erpnext.patches.v13_0.set_coa_batch_in_batch
erpnext.patches.v13_0.set_coa_batch_in_batch
erpnext.patches.v13_0.recalculate_outstanding_amount
27 changes: 27 additions & 0 deletions erpnext/patches/v13_0/recalculate_outstanding_amount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import frappe

def execute():
payment_references = frappe.get_all("Payment Entry Reference", filters={"docstatus": 1}, fields=["*"])
reference_documents = {}

for payment_reference in payment_references:
if payment_reference.reference_name in reference_documents:
reference_documents[payment_reference.reference_name] += [payment_reference]
else:
reference_documents[payment_reference.reference_name] = [payment_reference]

for key in reference_documents:
if len(reference_documents[key]) > 1:
reference_documents[key].sort(key=sort)

set_outstanding(reference_documents[key])

def sort(e):
return e["modified"]

def set_outstanding(documents):
total_amount = documents[0].total_amount

for document in documents:
total_amount -= document.allocated_amount
frappe.db.set_value("Payment Entry Reference", document.name, "outstanding_amount", total_amount, update_modified=False)

0 comments on commit 3257650

Please sign in to comment.