mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-30 20:18:27 +00:00
Merge pull request #53931 from frappe/mergify/bp/version-15-hotfix/pr-53406
fix: correct item valuation when "Deduct" is used in Purchase Invoice and Receipt. (backport #53406)
This commit is contained in:
@@ -327,7 +327,7 @@ class BuyingController(SubcontractingController):
|
||||
last_item_idx = d.idx
|
||||
|
||||
total_valuation_amount = sum(
|
||||
flt(d.base_tax_amount_after_discount_amount)
|
||||
flt(d.base_tax_amount_after_discount_amount) * (-1 if d.get("add_deduct_tax") == "Deduct" else 1)
|
||||
for d in self.get("taxes")
|
||||
if d.category in ["Valuation", "Valuation and Total"]
|
||||
)
|
||||
|
||||
@@ -1217,6 +1217,65 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
|
||||
pr.cancel()
|
||||
|
||||
def test_item_valuation_with_deduct_valuation_and_total_tax(self):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
qty=5,
|
||||
rate=100,
|
||||
do_not_save=1,
|
||||
)
|
||||
|
||||
pr.append(
|
||||
"taxes",
|
||||
{
|
||||
"charge_type": "Actual",
|
||||
"add_deduct_tax": "Deduct",
|
||||
"account_head": "_Test Account Shipping Charges - TCP1",
|
||||
"category": "Valuation and Total",
|
||||
"cost_center": "Main - TCP1",
|
||||
"description": "Valuation Discount",
|
||||
"tax_amount": 20,
|
||||
},
|
||||
)
|
||||
|
||||
pr.insert()
|
||||
|
||||
self.assertAlmostEqual(pr.items[0].item_tax_amount, -20.0, places=2)
|
||||
self.assertAlmostEqual(pr.items[0].valuation_rate, 96.0, places=2)
|
||||
|
||||
pr.delete()
|
||||
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
qty=5,
|
||||
rate=100,
|
||||
do_not_save=1,
|
||||
)
|
||||
|
||||
pr.append(
|
||||
"taxes",
|
||||
{
|
||||
"charge_type": "On Net Total",
|
||||
"add_deduct_tax": "Deduct",
|
||||
"account_head": "_Test Account Shipping Charges - TCP1",
|
||||
"category": "Valuation and Total",
|
||||
"cost_center": "Main - TCP1",
|
||||
"description": "Valuation Discount",
|
||||
"rate": 10,
|
||||
},
|
||||
)
|
||||
|
||||
pr.insert()
|
||||
|
||||
self.assertAlmostEqual(pr.items[0].item_tax_amount, -50.0, places=2)
|
||||
self.assertAlmostEqual(pr.items[0].valuation_rate, 90.0, places=2)
|
||||
|
||||
pr.delete()
|
||||
|
||||
def test_po_to_pi_and_po_to_pr_worflow_full(self):
|
||||
"""Test following behaviour:
|
||||
- Create PO
|
||||
|
||||
Reference in New Issue
Block a user