Skip to content

Commit

Permalink
fix: Disable tax included prices for internal transfers (#32794)
Browse files Browse the repository at this point in the history
* fix: Disable tax-included prices for internal transfers

(cherry picked from commit 8d30ebb)
  • Loading branch information
deepeshgarg007 authored and mergify[bot] committed Nov 5, 2022
1 parent afe86d8 commit 84ee1b8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions erpnext/controllers/accounts_controller.py
Expand Up @@ -152,6 +152,7 @@ def validate(self):
self.validate_inter_company_reference()

self.disable_pricing_rule_on_internal_transfer()
self.disable_tax_included_prices_for_internal_transfer()
self.set_incoming_rate()

if self.meta.get_field("currency"):
Expand Down Expand Up @@ -395,6 +396,20 @@ def disable_pricing_rule_on_internal_transfer(self):
alert=1,
)

def disable_tax_included_prices_for_internal_transfer(self):
if self.is_internal_transfer():
tax_updated = False
for tax in self.get("taxes"):
if tax.get("included_in_print_rate"):
tax.included_in_print_rate = 0
tax_updated = True

if tax_updated:
frappe.msgprint(
_("Disabled tax included prices since this {} is an internal transfer").format(self.doctype),
alert=1,
)

def validate_due_date(self):
if self.get("is_pos"):
return
Expand Down
14 changes: 14 additions & 0 deletions erpnext/stock/doctype/delivery_note/test_delivery_note.py
Expand Up @@ -1050,9 +1050,22 @@ def test_internal_transfer_with_valuation_only(self):
do_not_submit=True,
)

dn.append(
"taxes",
{
"charge_type": "On Net Total",
"account_head": "_Test Account Service Tax - _TC",
"description": "Tax 1",
"rate": 14,
"cost_center": "_Test Cost Center - _TC",
"included_in_print_rate": 1,
},
)

self.assertEqual(dn.items[0].rate, 500) # haven't saved yet
dn.save()
self.assertEqual(dn.ignore_pricing_rule, 1)
self.assertEqual(dn.taxes[0].included_in_print_rate, 0)

# rate should reset to incoming rate
self.assertEqual(dn.items[0].rate, rate)
Expand All @@ -1063,6 +1076,7 @@ def test_internal_transfer_with_valuation_only(self):
dn.save()

self.assertEqual(dn.items[0].rate, rate)
self.assertEqual(dn.items[0].net_rate, rate)

def test_internal_transfer_precision_gle(self):
from erpnext.selling.doctype.customer.test_customer import create_internal_customer
Expand Down

0 comments on commit 84ee1b8

Please sign in to comment.