mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 22:19:18 +00:00
Merge pull request #45972 from Ninad1306/update_taxes
fix: Set Taxes Before Calculating Taxes and Totals
This commit is contained in:
@@ -197,6 +197,14 @@ class AccountsController(TransactionBase):
|
|||||||
self.set_incoming_rate()
|
self.set_incoming_rate()
|
||||||
self.init_internal_values()
|
self.init_internal_values()
|
||||||
|
|
||||||
|
# Need to set taxes based on taxes_and_charges template
|
||||||
|
# before calculating taxes and totals
|
||||||
|
if self.meta.get_field("taxes_and_charges"):
|
||||||
|
self.validate_enabled_taxes_and_charges()
|
||||||
|
self.validate_tax_account_company()
|
||||||
|
|
||||||
|
self.set_taxes_and_charges()
|
||||||
|
|
||||||
if self.meta.get_field("currency"):
|
if self.meta.get_field("currency"):
|
||||||
self.calculate_taxes_and_totals()
|
self.calculate_taxes_and_totals()
|
||||||
|
|
||||||
@@ -207,10 +215,6 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
self.validate_all_documents_schedule()
|
self.validate_all_documents_schedule()
|
||||||
|
|
||||||
if self.meta.get_field("taxes_and_charges"):
|
|
||||||
self.validate_enabled_taxes_and_charges()
|
|
||||||
self.validate_tax_account_company()
|
|
||||||
|
|
||||||
self.validate_party()
|
self.validate_party()
|
||||||
self.validate_currency()
|
self.validate_currency()
|
||||||
self.validate_party_account_currency()
|
self.validate_party_account_currency()
|
||||||
@@ -255,8 +259,6 @@ class AccountsController(TransactionBase):
|
|||||||
self.validate_deferred_income_expense_account()
|
self.validate_deferred_income_expense_account()
|
||||||
self.set_inter_company_account()
|
self.set_inter_company_account()
|
||||||
|
|
||||||
self.set_taxes_and_charges()
|
|
||||||
|
|
||||||
if self.doctype == "Purchase Invoice":
|
if self.doctype == "Purchase Invoice":
|
||||||
self.calculate_paid_amount()
|
self.calculate_paid_amount()
|
||||||
# apply tax withholding only if checked and applicable
|
# apply tax withholding only if checked and applicable
|
||||||
|
|||||||
@@ -935,6 +935,35 @@ class TestAccountsController(IntegrationTestCase):
|
|||||||
self.assertEqual(exc_je_for_si, [])
|
self.assertEqual(exc_je_for_si, [])
|
||||||
self.assertEqual(exc_je_for_pe, [])
|
self.assertEqual(exc_je_for_pe, [])
|
||||||
|
|
||||||
|
@IntegrationTestCase.change_settings("Accounts Settings", {"add_taxes_from_item_tax_template": 1})
|
||||||
|
def test_18_fetch_taxes_based_on_taxes_and_charges_template(self):
|
||||||
|
# Create a Sales Taxes and Charges Template
|
||||||
|
if not frappe.db.exists("Sales Taxes and Charges Template", "_Test Tax - _TC"):
|
||||||
|
doc = frappe.new_doc("Sales Taxes and Charges Template")
|
||||||
|
doc.company = self.company
|
||||||
|
doc.title = "_Test Tax"
|
||||||
|
doc.append(
|
||||||
|
"taxes",
|
||||||
|
{
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"account_head": "Sales Expenses - _TC",
|
||||||
|
"description": "Test taxes",
|
||||||
|
"rate": 9,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
doc.insert()
|
||||||
|
|
||||||
|
# Create a Sales Invoice
|
||||||
|
sinv = frappe.new_doc("Sales Invoice")
|
||||||
|
sinv.customer = self.customer
|
||||||
|
sinv.company = self.company
|
||||||
|
sinv.currency = "INR"
|
||||||
|
sinv.taxes_and_charges = "_Test Tax - _TC"
|
||||||
|
sinv.append("items", {"item_code": "_Test Item", "qty": 1, "rate": 50})
|
||||||
|
sinv.insert()
|
||||||
|
|
||||||
|
self.assertEqual(sinv.total_taxes_and_charges, 4.5)
|
||||||
|
|
||||||
def test_20_journal_against_sales_invoice(self):
|
def test_20_journal_against_sales_invoice(self):
|
||||||
# Invoice in Foreign Currency
|
# Invoice in Foreign Currency
|
||||||
si = self.create_sales_invoice(qty=1, conversion_rate=80, rate=1)
|
si = self.create_sales_invoice(qty=1, conversion_rate=80, rate=1)
|
||||||
|
|||||||
Reference in New Issue
Block a user