Skip to content

Commit

Permalink
fix: Conversion factor error for invoices without item code (petty ex…
Browse files Browse the repository at this point in the history
…penses) (frappe#32714)

fix: Conversion factor error for invoices without item code (petty expenses) (frappe#32714)

* fix: Set default uom conversion factor to 1 for invoices

* chore: set default conversion_factor as 1

* chore: remove print statements

(cherry picked from commit 6175183)

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
  • Loading branch information
mergify[bot] and deepeshgarg007 authored Dec 30, 2022
1 parent 83a2c9b commit ba5a149
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@
"idx": 1,
"istable": 1,
"links": [],
"modified": "2022-11-02 12:53:12.693217",
"modified": "2022-12-28 16:17:33.484531",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Item",
Expand Down
7 changes: 6 additions & 1 deletion erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,12 @@ def set_missing_item_details(self, for_validate=False):
if bool(uom) != bool(stock_uom): # xor
item.stock_uom = item.uom = uom or stock_uom

item.conversion_factor = get_uom_conv_factor(item.get("uom"), item.get("stock_uom"))
# UOM cannot be zero so substitute as 1
item.conversion_factor = (
get_uom_conv_factor(item.get("uom"), item.get("stock_uom"))
or item.get("conversion_factor")
or 1
)

if self.doctype == "Purchase Invoice":
self.set_expense_account(for_validate)
Expand Down

0 comments on commit ba5a149

Please sign in to comment.