mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 14:39:19 +00:00
Merge pull request #53895 from frappe/mergify/bp/version-15-hotfix/pr-53799
fix(stock): update company validation for expense account in lcv (backport #53799)
This commit is contained in:
@@ -10,6 +10,7 @@ from frappe.query_builder.custom import ConstantColumn
|
|||||||
from frappe.utils import cint, flt
|
from frappe.utils import cint, flt
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
|
from erpnext import is_perpetual_inventory_enabled
|
||||||
from erpnext.controllers.taxes_and_totals import init_landed_taxes_and_totals
|
from erpnext.controllers.taxes_and_totals import init_landed_taxes_and_totals
|
||||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
||||||
|
|
||||||
@@ -160,6 +161,9 @@ class LandedCostVoucher(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def validate_expense_accounts(self):
|
def validate_expense_accounts(self):
|
||||||
|
if not is_perpetual_inventory_enabled(self.company):
|
||||||
|
return
|
||||||
|
|
||||||
for t in self.taxes:
|
for t in self.taxes:
|
||||||
company = frappe.get_cached_value("Account", t.expense_account, "company")
|
company = frappe.get_cached_value("Account", t.expense_account, "company")
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ class TestLandedCostVoucher(FrappeTestCase):
|
|||||||
self.assertEqual(last_sle_after_landed_cost.stock_value - last_sle.stock_value, 50.0)
|
self.assertEqual(last_sle_after_landed_cost.stock_value - last_sle.stock_value, 50.0)
|
||||||
|
|
||||||
def test_lcv_validates_company(self):
|
def test_lcv_validates_company(self):
|
||||||
|
from erpnext import is_perpetual_inventory_enabled
|
||||||
|
from erpnext.accounts.doctype.account.test_account import create_account
|
||||||
from erpnext.stock.doctype.landed_cost_voucher.landed_cost_voucher import (
|
from erpnext.stock.doctype.landed_cost_voucher.landed_cost_voucher import (
|
||||||
IncorrectCompanyValidationError,
|
IncorrectCompanyValidationError,
|
||||||
)
|
)
|
||||||
@@ -182,6 +184,20 @@ class TestLandedCostVoucher(FrappeTestCase):
|
|||||||
company_a = "_Test Company"
|
company_a = "_Test Company"
|
||||||
company_b = "_Test Company with perpetual inventory"
|
company_b = "_Test Company with perpetual inventory"
|
||||||
|
|
||||||
|
srbnb = create_account(
|
||||||
|
account_name="Stock Received But Not Billed",
|
||||||
|
account_type="Stock Received But Not Billed",
|
||||||
|
parent_account="Stock Liabilities - _TC",
|
||||||
|
company=company_a,
|
||||||
|
account_currency="INR",
|
||||||
|
)
|
||||||
|
|
||||||
|
epi = is_perpetual_inventory_enabled(company_a)
|
||||||
|
company_doc = frappe.get_doc("Company", company_a)
|
||||||
|
company_doc.enable_perpetual_inventory = 1
|
||||||
|
company_doc.stock_received_but_not_billed = srbnb
|
||||||
|
company_doc.save()
|
||||||
|
|
||||||
pr = make_purchase_receipt(
|
pr = make_purchase_receipt(
|
||||||
company=company_a,
|
company=company_a,
|
||||||
warehouse="Stores - _TC",
|
warehouse="Stores - _TC",
|
||||||
@@ -207,6 +223,9 @@ class TestLandedCostVoucher(FrappeTestCase):
|
|||||||
distribute_landed_cost_on_items(lcv)
|
distribute_landed_cost_on_items(lcv)
|
||||||
lcv.submit()
|
lcv.submit()
|
||||||
|
|
||||||
|
frappe.db.set_value("Company", company_a, "enable_perpetual_inventory", epi)
|
||||||
|
frappe.local.enable_perpetual_inventory = {}
|
||||||
|
|
||||||
def test_landed_cost_voucher_for_zero_purchase_rate(self):
|
def test_landed_cost_voucher_for_zero_purchase_rate(self):
|
||||||
"Test impact of LCV on future stock balances."
|
"Test impact of LCV on future stock balances."
|
||||||
from erpnext.stock.doctype.item.test_item import make_item
|
from erpnext.stock.doctype.item.test_item import make_item
|
||||||
|
|||||||
Reference in New Issue
Block a user