Skip to content

Commit

Permalink
fix(pos): error while consolidating pos invoices
Browse files Browse the repository at this point in the history
(cherry picked from commit 33762db)
  • Loading branch information
nextchamp-saqib authored and mergify[bot] committed Sep 4, 2022
1 parent 741d6fc commit 0527393
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion erpnext/accounts/doctype/pos_profile/pos_profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"currency",
"write_off_account",
"write_off_cost_center",
"write_off_limit",
"account_for_change_amount",
"disable_rounded_total",
"column_break_23",
Expand Down Expand Up @@ -360,6 +361,14 @@
"fieldtype": "Check",
"label": "Validate Stock on Save"
},
{
"default": "1",
"description": "Auto write off precision loss while consolidation",
"fieldname": "write_off_limit",
"fieldtype": "Currency",
"label": "Write Off Limit",
"reqd": 1
},
{
"default": "0",
"description": "If enabled, the consolidated invoices will have rounded total disabled",
Expand Down Expand Up @@ -393,7 +402,7 @@
"link_fieldname": "pos_profile"
}
],
"modified": "2022-07-21 11:16:46.911173",
"modified": "2022-08-10 12:57:06.241439",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Profile",
Expand Down
12 changes: 12 additions & 0 deletions erpnext/controllers/taxes_and_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,18 @@ def calculate_outstanding_amount(self):
self.doc.precision("outstanding_amount"),
)

if (
self.doc.doctype == "Sales Invoice"
and self.doc.get("is_pos")
and self.doc.get("pos_profile")
and self.doc.get("is_consolidated")
):
write_off_limit = flt(
frappe.db.get_value("POS Profile", self.doc.pos_profile, "write_off_limit")
)
if write_off_limit and abs(self.doc.outstanding_amount) <= write_off_limit:
self.doc.write_off_outstanding_amount_automatically = 1

if (
self.doc.doctype == "Sales Invoice"
and self.doc.get("is_pos")
Expand Down

0 comments on commit 0527393

Please sign in to comment.