fix: debit credit mismatch in multi-currecy asset purchase receipt (#38342)
* fix: Debit credit mimatch in multicurrecy asset purchase receipt * test: multi currency purchase receipt * chore: update init files * test: roolback
This commit is contained in:
parent
ad3634be7c
commit
add238c892
@ -149,12 +149,7 @@ class TestAsset(AssetSetup):
|
|||||||
("Creditors - _TC", 0.0, 100000.0),
|
("Creditors - _TC", 0.0, 100000.0),
|
||||||
)
|
)
|
||||||
|
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Purchase Invoice", pi.name)
|
||||||
"""select account, debit, credit from `tabGL Entry`
|
|
||||||
where voucher_type='Purchase Invoice' and voucher_no = %s
|
|
||||||
order by account""",
|
|
||||||
pi.name,
|
|
||||||
)
|
|
||||||
self.assertSequenceEqual(gle, expected_gle)
|
self.assertSequenceEqual(gle, expected_gle)
|
||||||
|
|
||||||
pi.cancel()
|
pi.cancel()
|
||||||
@ -264,12 +259,7 @@ class TestAsset(AssetSetup):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Journal Entry", asset.journal_entry_for_scrap)
|
||||||
"""select account, debit, credit from `tabGL Entry`
|
|
||||||
where voucher_type='Journal Entry' and voucher_no = %s
|
|
||||||
order by account""",
|
|
||||||
asset.journal_entry_for_scrap,
|
|
||||||
)
|
|
||||||
self.assertSequenceEqual(gle, expected_gle)
|
self.assertSequenceEqual(gle, expected_gle)
|
||||||
|
|
||||||
restore_asset(asset.name)
|
restore_asset(asset.name)
|
||||||
@ -345,13 +335,7 @@ class TestAsset(AssetSetup):
|
|||||||
("Debtors - _TC", 25000.0, 0.0),
|
("Debtors - _TC", 25000.0, 0.0),
|
||||||
)
|
)
|
||||||
|
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Sales Invoice", si.name)
|
||||||
"""select account, debit, credit from `tabGL Entry`
|
|
||||||
where voucher_type='Sales Invoice' and voucher_no = %s
|
|
||||||
order by account""",
|
|
||||||
si.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertSequenceEqual(gle, expected_gle)
|
self.assertSequenceEqual(gle, expected_gle)
|
||||||
|
|
||||||
si.cancel()
|
si.cancel()
|
||||||
@ -425,13 +409,7 @@ class TestAsset(AssetSetup):
|
|||||||
("Debtors - _TC", 40000.0, 0.0),
|
("Debtors - _TC", 40000.0, 0.0),
|
||||||
)
|
)
|
||||||
|
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Sales Invoice", si.name)
|
||||||
"""select account, debit, credit from `tabGL Entry`
|
|
||||||
where voucher_type='Sales Invoice' and voucher_no = %s
|
|
||||||
order by account""",
|
|
||||||
si.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertSequenceEqual(gle, expected_gle)
|
self.assertSequenceEqual(gle, expected_gle)
|
||||||
|
|
||||||
def test_asset_with_maintenance_required_status_after_sale(self):
|
def test_asset_with_maintenance_required_status_after_sale(self):
|
||||||
@ -572,13 +550,7 @@ class TestAsset(AssetSetup):
|
|||||||
("CWIP Account - _TC", 5250.0, 0.0),
|
("CWIP Account - _TC", 5250.0, 0.0),
|
||||||
)
|
)
|
||||||
|
|
||||||
pr_gle = frappe.db.sql(
|
pr_gle = get_gl_entries("Purchase Receipt", pr.name)
|
||||||
"""select account, debit, credit from `tabGL Entry`
|
|
||||||
where voucher_type='Purchase Receipt' and voucher_no = %s
|
|
||||||
order by account""",
|
|
||||||
pr.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertSequenceEqual(pr_gle, expected_gle)
|
self.assertSequenceEqual(pr_gle, expected_gle)
|
||||||
|
|
||||||
pi = make_invoice(pr.name)
|
pi = make_invoice(pr.name)
|
||||||
@ -591,13 +563,7 @@ class TestAsset(AssetSetup):
|
|||||||
("Creditors - _TC", 0.0, 5500.0),
|
("Creditors - _TC", 0.0, 5500.0),
|
||||||
)
|
)
|
||||||
|
|
||||||
pi_gle = frappe.db.sql(
|
pi_gle = get_gl_entries("Purchase Invoice", pi.name)
|
||||||
"""select account, debit, credit from `tabGL Entry`
|
|
||||||
where voucher_type='Purchase Invoice' and voucher_no = %s
|
|
||||||
order by account""",
|
|
||||||
pi.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertSequenceEqual(pi_gle, expected_gle)
|
self.assertSequenceEqual(pi_gle, expected_gle)
|
||||||
|
|
||||||
asset = frappe.db.get_value("Asset", {"purchase_receipt": pr.name, "docstatus": 0}, "name")
|
asset = frappe.db.get_value("Asset", {"purchase_receipt": pr.name, "docstatus": 0}, "name")
|
||||||
@ -624,13 +590,7 @@ class TestAsset(AssetSetup):
|
|||||||
|
|
||||||
expected_gle = (("_Test Fixed Asset - _TC", 5250.0, 0.0), ("CWIP Account - _TC", 0.0, 5250.0))
|
expected_gle = (("_Test Fixed Asset - _TC", 5250.0, 0.0), ("CWIP Account - _TC", 0.0, 5250.0))
|
||||||
|
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Asset", asset_doc.name)
|
||||||
"""select account, debit, credit from `tabGL Entry`
|
|
||||||
where voucher_type='Asset' and voucher_no = %s
|
|
||||||
order by account""",
|
|
||||||
asset_doc.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertSequenceEqual(gle, expected_gle)
|
self.assertSequenceEqual(gle, expected_gle)
|
||||||
|
|
||||||
def test_asset_cwip_toggling_cases(self):
|
def test_asset_cwip_toggling_cases(self):
|
||||||
@ -653,10 +613,7 @@ class TestAsset(AssetSetup):
|
|||||||
asset_doc.available_for_use_date = nowdate()
|
asset_doc.available_for_use_date = nowdate()
|
||||||
asset_doc.calculate_depreciation = 0
|
asset_doc.calculate_depreciation = 0
|
||||||
asset_doc.submit()
|
asset_doc.submit()
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Asset", asset_doc.name)
|
||||||
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
|
|
||||||
asset_doc.name,
|
|
||||||
)
|
|
||||||
self.assertFalse(gle)
|
self.assertFalse(gle)
|
||||||
|
|
||||||
# case 1 -- PR with cwip disabled, Asset with cwip enabled
|
# case 1 -- PR with cwip disabled, Asset with cwip enabled
|
||||||
@ -670,10 +627,7 @@ class TestAsset(AssetSetup):
|
|||||||
asset_doc.available_for_use_date = nowdate()
|
asset_doc.available_for_use_date = nowdate()
|
||||||
asset_doc.calculate_depreciation = 0
|
asset_doc.calculate_depreciation = 0
|
||||||
asset_doc.submit()
|
asset_doc.submit()
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Asset", asset_doc.name)
|
||||||
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
|
|
||||||
asset_doc.name,
|
|
||||||
)
|
|
||||||
self.assertFalse(gle)
|
self.assertFalse(gle)
|
||||||
|
|
||||||
# case 2 -- PR with cwip enabled, Asset with cwip disabled
|
# case 2 -- PR with cwip enabled, Asset with cwip disabled
|
||||||
@ -686,10 +640,7 @@ class TestAsset(AssetSetup):
|
|||||||
asset_doc.available_for_use_date = nowdate()
|
asset_doc.available_for_use_date = nowdate()
|
||||||
asset_doc.calculate_depreciation = 0
|
asset_doc.calculate_depreciation = 0
|
||||||
asset_doc.submit()
|
asset_doc.submit()
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Asset", asset_doc.name)
|
||||||
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
|
|
||||||
asset_doc.name,
|
|
||||||
)
|
|
||||||
self.assertTrue(gle)
|
self.assertTrue(gle)
|
||||||
|
|
||||||
# case 3 -- PI with cwip disabled, Asset with cwip enabled
|
# case 3 -- PI with cwip disabled, Asset with cwip enabled
|
||||||
@ -702,10 +653,7 @@ class TestAsset(AssetSetup):
|
|||||||
asset_doc.available_for_use_date = nowdate()
|
asset_doc.available_for_use_date = nowdate()
|
||||||
asset_doc.calculate_depreciation = 0
|
asset_doc.calculate_depreciation = 0
|
||||||
asset_doc.submit()
|
asset_doc.submit()
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Asset", asset_doc.name)
|
||||||
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
|
|
||||||
asset_doc.name,
|
|
||||||
)
|
|
||||||
self.assertFalse(gle)
|
self.assertFalse(gle)
|
||||||
|
|
||||||
# case 4 -- PI with cwip enabled, Asset with cwip disabled
|
# case 4 -- PI with cwip enabled, Asset with cwip disabled
|
||||||
@ -718,10 +666,7 @@ class TestAsset(AssetSetup):
|
|||||||
asset_doc.available_for_use_date = nowdate()
|
asset_doc.available_for_use_date = nowdate()
|
||||||
asset_doc.calculate_depreciation = 0
|
asset_doc.calculate_depreciation = 0
|
||||||
asset_doc.submit()
|
asset_doc.submit()
|
||||||
gle = frappe.db.sql(
|
gle = get_gl_entries("Asset", asset_doc.name)
|
||||||
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
|
|
||||||
asset_doc.name,
|
|
||||||
)
|
|
||||||
self.assertTrue(gle)
|
self.assertTrue(gle)
|
||||||
|
|
||||||
frappe.db.set_value("Asset Category", "Computers", "enable_cwip_accounting", cwip)
|
frappe.db.set_value("Asset Category", "Computers", "enable_cwip_accounting", cwip)
|
||||||
@ -1701,6 +1646,30 @@ class TestDepreciationBasics(AssetSetup):
|
|||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, jv.insert)
|
self.assertRaises(frappe.ValidationError, jv.insert)
|
||||||
|
|
||||||
|
def test_multi_currency_asset_pr_creation(self):
|
||||||
|
pr = make_purchase_receipt(
|
||||||
|
item_code="Macbook Pro",
|
||||||
|
qty=1,
|
||||||
|
rate=100.0,
|
||||||
|
location="Test Location",
|
||||||
|
supplier="_Test Supplier USD",
|
||||||
|
currency="USD",
|
||||||
|
)
|
||||||
|
|
||||||
|
pr.submit()
|
||||||
|
self.assertTrue(get_gl_entries("Purchase Receipt", pr.name))
|
||||||
|
|
||||||
|
|
||||||
|
def get_gl_entries(doctype, docname):
|
||||||
|
gl_entry = frappe.qb.DocType("GL Entry")
|
||||||
|
return (
|
||||||
|
frappe.qb.from_(gl_entry)
|
||||||
|
.select(gl_entry.account, gl_entry.debit, gl_entry.credit)
|
||||||
|
.where((gl_entry.voucher_type == doctype) & (gl_entry.voucher_no == docname))
|
||||||
|
.orderby(gl_entry.account)
|
||||||
|
.run()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_asset_data():
|
def create_asset_data():
|
||||||
if not frappe.db.exists("Asset Category", "Computers"):
|
if not frappe.db.exists("Asset Category", "Computers"):
|
||||||
|
@ -571,7 +571,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
stock_value_diff = (
|
stock_value_diff = (
|
||||||
flt(d.net_amount)
|
flt(d.base_net_amount)
|
||||||
+ flt(d.item_tax_amount / self.conversion_rate)
|
+ flt(d.item_tax_amount / self.conversion_rate)
|
||||||
+ flt(d.landed_cost_voucher_amount)
|
+ flt(d.landed_cost_voucher_amount)
|
||||||
)
|
)
|
||||||
|
0
erpnext/www/all-products/__init__.py
Normal file
0
erpnext/www/all-products/__init__.py
Normal file
0
erpnext/www/shop-by-category/__init__.py
Normal file
0
erpnext/www/shop-by-category/__init__.py
Normal file
Loading…
x
Reference in New Issue
Block a user