Skip to content

Commit

Permalink
fix(ux): overbiling message in SO->SI, PO->PI (#28088)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush authored Oct 27, 2021
1 parent a87c201 commit 6ec047c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):

if role_allowed_to_over_bill in user_roles and total_overbilled_amt > 0.1:
frappe.msgprint(_("Overbilling of {} ignored because you have {} role.")
.format(total_overbilled_amt, role_allowed_to_over_bill), title=_("Warning"), indicator="orange")
.format(total_overbilled_amt, role_allowed_to_over_bill), indicator="orange", alert=True)

def throw_overbill_exception(self, item, max_allowed_amt):
frappe.throw(_("Cannot overbill for Item {0} in row {1} more than {2}. To allow over-billing, please set allowance in Accounts Settings")
Expand Down
20 changes: 18 additions & 2 deletions erpnext/controllers/status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,14 @@ def check_overflow_with_allowance(self, item, args):
overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) /
item[args['target_ref_field']]) * 100

if overflow_percent - allowance > 0.01 and role not in frappe.get_roles():
if overflow_percent - allowance > 0.01:
item['max_allowed'] = flt(item[args['target_ref_field']] * (100+allowance)/100)
item['reduce_by'] = item[args['target_field']] - item['max_allowed']

self.limits_crossed_error(args, item, qty_or_amount)
if role not in frappe.get_roles():
self.limits_crossed_error(args, item, qty_or_amount)
else:
self.warn_about_bypassing_with_role(item, qty_or_amount, role)

def limits_crossed_error(self, args, item, qty_or_amount):
'''Raise exception for limits crossed'''
Expand All @@ -238,6 +241,19 @@ def limits_crossed_error(self, args, item, qty_or_amount):
frappe.bold(item.get('item_code'))
) + '<br><br>' + action_msg, OverAllowanceError, title = _('Limit Crossed'))

def warn_about_bypassing_with_role(self, item, qty_or_amount, role):
action = _("Over Receipt/Delivery") if qty_or_amount == "qty" else _("Overbilling")

msg = (_("{} of {} {} ignored for item {} because you have {} role.")
.format(
action,
_(item["target_ref_field"].title()),
frappe.bold(item["reduce_by"]),
frappe.bold(item.get('item_code')),
role)
)
frappe.msgprint(msg, indicator="orange", alert=True)

def update_qty(self, update_modified=True):
"""Updates qty or amount at row level
Expand Down

0 comments on commit 6ec047c

Please sign in to comment.