mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-23 00:28:30 +00:00
fix: update item_tax_rate in backend
(cherry picked from commit de54c0b41f)
# Conflicts:
# erpnext/controllers/taxes_and_totals.py
This commit is contained in:
@@ -43,6 +43,7 @@ from erpnext.stock.doctype.stock_entry.test_stock_entry import (
|
|||||||
from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import (
|
from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import (
|
||||||
create_stock_reconciliation,
|
create_stock_reconciliation,
|
||||||
)
|
)
|
||||||
|
from erpnext.stock.get_item_details import get_item_tax_map
|
||||||
from erpnext.stock.utils import get_incoming_rate, get_stock_balance
|
from erpnext.stock.utils import get_incoming_rate, get_stock_balance
|
||||||
|
|
||||||
|
|
||||||
@@ -2873,13 +2874,26 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
item.save()
|
item.save()
|
||||||
|
|
||||||
sales_invoice = create_sales_invoice(item="T Shirt", rate=700, do_not_submit=True)
|
sales_invoice = create_sales_invoice(item="T Shirt", rate=700, do_not_submit=True)
|
||||||
|
item_tax_map = get_item_tax_map(
|
||||||
|
doc=sales_invoice,
|
||||||
|
tax_template=sales_invoice.items[0].item_tax_template,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 12 - _TC")
|
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 12 - _TC")
|
||||||
|
self.assertEqual(sales_invoice.items[0].item_tax_rate, item_tax_map)
|
||||||
|
|
||||||
# Apply discount
|
# Apply discount
|
||||||
sales_invoice.apply_discount_on = "Net Total"
|
sales_invoice.apply_discount_on = "Net Total"
|
||||||
sales_invoice.discount_amount = 300
|
sales_invoice.discount_amount = 300
|
||||||
sales_invoice.save()
|
sales_invoice.save()
|
||||||
|
|
||||||
|
item_tax_map = get_item_tax_map(
|
||||||
|
doc=sales_invoice,
|
||||||
|
tax_template=sales_invoice.items[0].item_tax_template,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")
|
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")
|
||||||
|
self.assertEqual(sales_invoice.items[0].item_tax_rate, item_tax_map)
|
||||||
|
|
||||||
@change_settings("Selling Settings", {"enable_discount_accounting": 1})
|
@change_settings("Selling Settings", {"enable_discount_accounting": 1})
|
||||||
def test_sales_invoice_with_discount_accounting_enabled(self):
|
def test_sales_invoice_with_discount_accounting_enabled(self):
|
||||||
|
|||||||
@@ -18,7 +18,12 @@ from erpnext.controllers.accounts_controller import (
|
|||||||
validate_inclusive_tax,
|
validate_inclusive_tax,
|
||||||
validate_taxes_and_charges,
|
validate_taxes_and_charges,
|
||||||
)
|
)
|
||||||
|
<<<<<<< HEAD
|
||||||
from erpnext.stock.get_item_details import _get_item_tax_template
|
from erpnext.stock.get_item_details import _get_item_tax_template
|
||||||
|
=======
|
||||||
|
from erpnext.deprecation_dumpster import deprecated
|
||||||
|
from erpnext.stock.get_item_details import ItemDetailsCtx, _get_item_tax_template, get_item_tax_map
|
||||||
|
>>>>>>> de54c0b41f (fix: update item_tax_rate in backend)
|
||||||
from erpnext.utilities.regional import temporary_flag
|
from erpnext.utilities.regional import temporary_flag
|
||||||
|
|
||||||
|
|
||||||
@@ -70,6 +75,7 @@ class calculate_taxes_and_totals:
|
|||||||
self.validate_conversion_rate()
|
self.validate_conversion_rate()
|
||||||
self.calculate_item_values()
|
self.calculate_item_values()
|
||||||
self.validate_item_tax_template()
|
self.validate_item_tax_template()
|
||||||
|
self.update_item_tax_map()
|
||||||
self.initialize_taxes()
|
self.initialize_taxes()
|
||||||
self.determine_exclusive_rate()
|
self.determine_exclusive_rate()
|
||||||
self.calculate_net_total()
|
self.calculate_net_total()
|
||||||
@@ -134,6 +140,14 @@ class calculate_taxes_and_totals:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_item_tax_map(self):
|
||||||
|
for item in self.doc.items:
|
||||||
|
item.item_tax_rate = get_item_tax_map(
|
||||||
|
doc=self.doc,
|
||||||
|
tax_template=item.item_tax_template,
|
||||||
|
as_json=True,
|
||||||
|
)
|
||||||
|
|
||||||
def validate_conversion_rate(self):
|
def validate_conversion_rate(self):
|
||||||
# validate conversion rate
|
# validate conversion rate
|
||||||
company_currency = erpnext.get_company_currency(self.doc.company)
|
company_currency = erpnext.get_company_currency(self.doc.company)
|
||||||
|
|||||||
Reference in New Issue
Block a user