mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
Merged develop into v5
This commit is contained in:
@@ -119,6 +119,8 @@ class AccountsController(TransactionBase):
|
||||
if item.get("item_code"):
|
||||
args = parent_dict.copy()
|
||||
args.update(item.as_dict())
|
||||
if not args.get("transaction_date"):
|
||||
args["transaction_date"] = args.get("posting_date")
|
||||
ret = get_item_details(args)
|
||||
|
||||
for fieldname, value in ret.items():
|
||||
@@ -165,7 +167,6 @@ class AccountsController(TransactionBase):
|
||||
if frappe.db.get_value(taxes_and_charges_doctype, self.taxes_and_charges, "disabled"):
|
||||
frappe.throw(_("{0} '{1}' is disabled").format(taxes_and_charges_doctype, self.taxes_and_charges))
|
||||
|
||||
|
||||
def get_gl_dict(self, args):
|
||||
"""this method populates the common properties of a gl entry record"""
|
||||
gl_dict = frappe._dict({
|
||||
|
||||
@@ -31,6 +31,7 @@ class calculate_taxes_and_totals(object):
|
||||
self.determine_exclusive_rate()
|
||||
self.calculate_net_total()
|
||||
self.calculate_taxes()
|
||||
self.manipulate_grand_total_for_inclusive_tax()
|
||||
self.calculate_totals()
|
||||
self._cleanup()
|
||||
|
||||
@@ -281,6 +282,21 @@ class calculate_taxes_and_totals(object):
|
||||
tax.total = flt(tax.total + discount_amount_loss, tax.precision("total"))
|
||||
|
||||
self._set_in_company_currency(tax, ["total", "tax_amount_after_discount_amount"])
|
||||
|
||||
def manipulate_grand_total_for_inclusive_tax(self):
|
||||
# if fully inclusive taxes and diff
|
||||
if self.doc.get("taxes") and all(cint(t.included_in_print_rate) for t in self.doc.get("taxes")):
|
||||
|
||||
last_tax = self.doc.get("taxes")[-1]
|
||||
|
||||
diff = self.doc.net_total - flt(last_tax.total / self.doc.conversion_rate,
|
||||
self.precision("grand_total_export"))
|
||||
|
||||
if diff and abs(diff) <= (2.0 / 10**last_tax.precision("tax_amount")):
|
||||
adjustment_amount = flt(diff * self.doc.conversion_rate, last_tax.precision("tax_amount"))
|
||||
last_tax.tax_amount += adjustment_amount
|
||||
last_tax.tax_amount_after_discount_amount += adjustment_amount
|
||||
last_tax.total += adjustment_amount
|
||||
|
||||
def calculate_totals(self):
|
||||
self.doc.grand_total = flt(self.doc.get("taxes")[-1].total
|
||||
|
||||
Reference in New Issue
Block a user