mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 14:09:19 +00:00
@@ -3010,16 +3010,11 @@ class AccountsController(TransactionBase):
|
|||||||
# returns have negative discount
|
# returns have negative discount
|
||||||
discount_already_applied *= -1
|
discount_already_applied *= -1
|
||||||
|
|
||||||
if (source_doc.discount_amount * (discount_already_applied - source_doc.discount_amount)) >= 0:
|
discount_amount = max(source_doc.discount_amount - discount_already_applied, 0)
|
||||||
# full discount already applied or exceeded
|
if discount_amount and is_return:
|
||||||
self.discount_amount = 0
|
discount_amount *= -1
|
||||||
else:
|
|
||||||
discount_amount = source_doc.discount_amount - discount_already_applied
|
|
||||||
if is_return:
|
|
||||||
# returns have negative discount
|
|
||||||
discount_amount *= -1
|
|
||||||
|
|
||||||
self.discount_amount = flt(discount_amount, self.precision("discount_amount"))
|
self.discount_amount = flt(discount_amount, self.precision("discount_amount"))
|
||||||
|
|
||||||
self.calculate_taxes_and_totals()
|
self.calculate_taxes_and_totals()
|
||||||
|
|
||||||
|
|||||||
@@ -690,7 +690,10 @@ class calculate_taxes_and_totals:
|
|||||||
grand_total = self.doc.grand_total
|
grand_total = self.doc.grand_total
|
||||||
|
|
||||||
# validate that discount amount cannot exceed the total before discount
|
# validate that discount amount cannot exceed the total before discount
|
||||||
if grand_total * (discount_amount - grand_total) > 0:
|
if (
|
||||||
|
(grand_total >= 0 and discount_amount > grand_total)
|
||||||
|
or (grand_total < 0 and discount_amount < grand_total) # returns
|
||||||
|
):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"Additional Discount Amount ({discount_amount}) cannot exceed "
|
"Additional Discount Amount ({discount_amount}) cannot exceed "
|
||||||
|
|||||||
Reference in New Issue
Block a user