Skip to content

Commit

Permalink
fix: check so_detail before dn_detail
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r authored and KrithiRamani committed Mar 12, 2022
1 parent ba0086d commit cedbf9b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,14 +1247,14 @@ def make_gle_for_rounding_adjustment(self, gl_entries):
def update_billing_status_in_dn(self, update_modified=True):
updated_delivery_notes = []
for d in self.get("items"):
if d.dn_detail:
if d.so_detail:
updated_delivery_notes += update_billed_amount_based_on_so(d.so_detail, update_modified)
elif d.dn_detail:
billed_amt = frappe.db.sql("""select sum(amount) from `tabSales Invoice Item`
where dn_detail=%s and docstatus=1""", d.dn_detail)
billed_amt = billed_amt and billed_amt[0][0] or 0
frappe.db.set_value("Delivery Note Item", d.dn_detail, "billed_amt", billed_amt, update_modified=update_modified)
updated_delivery_notes.append(d.delivery_note)
elif d.so_detail:
updated_delivery_notes += update_billed_amount_based_on_so(d.so_detail, update_modified)

for dn in set(updated_delivery_notes):
frappe.get_doc("Delivery Note", dn).update_billing_percentage(update_modified=update_modified)
Expand Down

0 comments on commit cedbf9b

Please sign in to comment.