Skip to content

Commit

Permalink
fix: incorrect percentage received in purchase invoice
Browse files Browse the repository at this point in the history
(cherry picked from commit 8d2c788)
  • Loading branch information
rohitwaghchaure authored and mergify[bot] committed Jan 11, 2024
1 parent dc7c9e7 commit 453700d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ def validate(self):
self.reset_default_field_value("set_warehouse", "items", "warehouse")
self.reset_default_field_value("rejected_warehouse", "items", "rejected_warehouse")
self.reset_default_field_value("set_from_warehouse", "items", "from_warehouse")
self.set_percentage_received()

def set_percentage_received(self):
total_billed_qty = 0.0
total_received_qty = 0.0
for row in self.items:
if row.purchase_receipt and row.pr_detail and row.received_qty:
total_billed_qty += row.qty
total_received_qty += row.received_qty

if total_billed_qty and total_received_qty:
self.per_received = total_received_qty / total_billed_qty * 100

def validate_release_date(self):
if self.release_date and getdate(nowdate()) >= getdate(self.release_date):
Expand Down
1 change: 1 addition & 0 deletions erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ def get_pending_qty(item_row):
"field_map": {
"name": "pr_detail",
"parent": "purchase_receipt",
"qty": "received_qty",
"purchase_order_item": "po_detail",
"purchase_order": "purchase_order",
"is_fixed_asset": "is_fixed_asset",
Expand Down

0 comments on commit 453700d

Please sign in to comment.