[minor] [fix] apply float precision on over-billing validation
This commit is contained in:
parent
dce9fdfe26
commit
19d945a4e7
@ -71,7 +71,8 @@ class DocType(BuyingController):
|
|||||||
self.validate_write_off_account()
|
self.validate_write_off_account()
|
||||||
self.update_raw_material_cost()
|
self.update_raw_material_cost()
|
||||||
self.update_valuation_rate("entries")
|
self.update_valuation_rate("entries")
|
||||||
self.validate_multiple_billing("Purchase Receipt", "pr_detail", "import_amount")
|
self.validate_multiple_billing("Purchase Receipt", "pr_detail", "import_amount",
|
||||||
|
"purchase_receipt_details")
|
||||||
|
|
||||||
def get_credit_to(self):
|
def get_credit_to(self):
|
||||||
acc_head = sql("""select name, credit_days from `tabAccount`
|
acc_head = sql("""select name, credit_days from `tabAccount`
|
||||||
|
@ -93,7 +93,8 @@ class DocType(SellingController):
|
|||||||
self.validate_c_form()
|
self.validate_c_form()
|
||||||
self.validate_time_logs_are_submitted()
|
self.validate_time_logs_are_submitted()
|
||||||
self.validate_recurring_invoice()
|
self.validate_recurring_invoice()
|
||||||
self.validate_multiple_billing("Delivery Note", "dn_detail", "export_amount")
|
self.validate_multiple_billing("Delivery Note", "dn_detail", "export_amount",
|
||||||
|
"delivery_note_details")
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if cint(self.doc.update_stock) == 1:
|
if cint(self.doc.update_stock) == 1:
|
||||||
|
@ -382,7 +382,7 @@ class AccountsController(TransactionBase):
|
|||||||
"allocate_amount": 0
|
"allocate_amount": 0
|
||||||
})
|
})
|
||||||
|
|
||||||
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on):
|
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
|
||||||
for item in self.doclist.get({"parentfield": "entries"}):
|
for item in self.doclist.get({"parentfield": "entries"}):
|
||||||
if item.fields.get(item_ref_dn):
|
if item.fields.get(item_ref_dn):
|
||||||
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
|
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
|
||||||
@ -390,10 +390,13 @@ class AccountsController(TransactionBase):
|
|||||||
item.fields[item_ref_dn])[0][0]
|
item.fields[item_ref_dn])[0][0]
|
||||||
|
|
||||||
max_allowed_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
|
max_allowed_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
|
||||||
item.fields[item_ref_dn], based_on))
|
item.fields[item_ref_dn], based_on), self.precision(based_on, item))
|
||||||
|
|
||||||
if max_allowed_amt and \
|
total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
|
||||||
flt(already_billed) + flt(item.fields[based_on]) > max_allowed_amt:
|
self.precision(based_on, item))
|
||||||
|
webnotes.errprint([max_allowed_amt, total_billed_amt])
|
||||||
|
|
||||||
|
if max_allowed_amt and total_billed_amt > max_allowed_amt:
|
||||||
webnotes.msgprint(_("Row ")+ cstr(item.idx) + ": " + cstr(item.item_code) +
|
webnotes.msgprint(_("Row ")+ cstr(item.idx) + ": " + cstr(item.item_code) +
|
||||||
_(" will be over-billed against mentioned ") + cstr(ref_dt) +
|
_(" will be over-billed against mentioned ") + cstr(ref_dt) +
|
||||||
_(". Max allowed " + cstr(based_on) + ": " + cstr(max_allowed_amt)),
|
_(". Max allowed " + cstr(based_on) + ": " + cstr(max_allowed_amt)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user