fix: Multiple fixes related to landed cost accounting (#19657)
This commit is contained in:
parent
1a92eb14ed
commit
046137caa2
@ -452,6 +452,10 @@ class PurchaseInvoice(BuyingController):
|
||||
fields = ["voucher_detail_no", "stock_value_difference"], filters={'voucher_no': self.name}):
|
||||
voucher_wise_stock_value.setdefault(d.voucher_detail_no, d.stock_value_difference)
|
||||
|
||||
valuation_tax_accounts = [d.account_head for d in self.get("taxes")
|
||||
if d.category in ('Valuation', 'Total and Valuation')
|
||||
and flt(d.base_tax_amount_after_discount_amount)]
|
||||
|
||||
for item in self.get("items"):
|
||||
if flt(item.base_net_amount):
|
||||
account_currency = get_account_currency(item.expense_account)
|
||||
@ -551,10 +555,10 @@ class PurchaseInvoice(BuyingController):
|
||||
if self.auto_accounting_for_stock and self.is_opening == "No" and \
|
||||
item.item_code in stock_items and item.item_tax_amount:
|
||||
# Post reverse entry for Stock-Received-But-Not-Billed if it is booked in Purchase Receipt
|
||||
if item.purchase_receipt:
|
||||
if item.purchase_receipt and valuation_tax_accounts:
|
||||
negative_expense_booked_in_pr = frappe.db.sql("""select name from `tabGL Entry`
|
||||
where voucher_type='Purchase Receipt' and voucher_no=%s and account=%s""",
|
||||
(item.purchase_receipt, self.expenses_included_in_valuation))
|
||||
where voucher_type='Purchase Receipt' and voucher_no=%s and account in %s""",
|
||||
(item.purchase_receipt, valuation_tax_accounts))
|
||||
|
||||
if not negative_expense_booked_in_pr:
|
||||
gl_entries.append(
|
||||
|
@ -204,7 +204,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
pi.insert()
|
||||
pi.submit()
|
||||
|
||||
self.check_gle_for_pi_against_pr(pi.name)
|
||||
self.check_gle_for_pi(pi.name)
|
||||
|
||||
def check_gle_for_pi(self, pi):
|
||||
gl_entries = frappe.db.sql("""select account, sum(debit) as debit, sum(credit) as credit
|
||||
@ -225,26 +225,6 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEqual(expected_values[gle.account][1], gle.debit)
|
||||
self.assertEqual(expected_values[gle.account][2], gle.credit)
|
||||
|
||||
def check_gle_for_pi_against_pr(self, pi):
|
||||
gl_entries = frappe.db.sql("""select account, sum(debit) as debit, sum(credit) as credit
|
||||
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||
group by account""", pi, as_dict=1)
|
||||
|
||||
self.assertTrue(gl_entries)
|
||||
|
||||
expected_values = dict((d[0], d) for d in [
|
||||
["Creditors - TCP1", 0, 720],
|
||||
["Stock Received But Not Billed - TCP1", 750.0, 0],
|
||||
["_Test Account Shipping Charges - TCP1", 100.0, 100.0],
|
||||
["_Test Account VAT - TCP1", 120.0, 0],
|
||||
["_Test Account Customs Duty - TCP1", 0, 150]
|
||||
])
|
||||
|
||||
for i, gle in enumerate(gl_entries):
|
||||
self.assertEqual(expected_values[gle.account][0], gle.account)
|
||||
self.assertEqual(expected_values[gle.account][1], gle.debit)
|
||||
self.assertEqual(expected_values[gle.account][2], gle.credit)
|
||||
|
||||
def test_purchase_invoice_change_naming_series(self):
|
||||
pi = frappe.copy_doc(test_records[1])
|
||||
pi.insert()
|
||||
|
@ -117,6 +117,7 @@
|
||||
},
|
||||
{
|
||||
"fetch_from": "item_code.item_name",
|
||||
"fetch_if_empty": 1,
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Data",
|
||||
"in_global_search": 1,
|
||||
@ -192,7 +193,6 @@
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fetch_from": "item_code.stock_uom",
|
||||
"fieldname": "uom",
|
||||
"fieldtype": "Link",
|
||||
"label": "UOM",
|
||||
@ -766,7 +766,7 @@
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2019-11-03 13:43:23.782877",
|
||||
"modified": "2019-11-21 16:27:52.043744",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Purchase Invoice Item",
|
||||
|
@ -135,7 +135,7 @@ class SalesInvoice(SellingController):
|
||||
|
||||
if self.redeem_loyalty_points and self.loyalty_program and self.loyalty_points:
|
||||
validate_loyalty_points(self, self.loyalty_points)
|
||||
|
||||
|
||||
def validate_fixed_asset(self):
|
||||
for d in self.get("items"):
|
||||
if d.is_fixed_asset and d.meta.get_field("asset") and d.asset:
|
||||
|
@ -8,11 +8,11 @@
|
||||
"naming_series",
|
||||
"company",
|
||||
"purchase_receipts",
|
||||
"sec_break1",
|
||||
"taxes",
|
||||
"purchase_receipt_items",
|
||||
"get_items_from_purchase_receipts",
|
||||
"items",
|
||||
"sec_break1",
|
||||
"taxes",
|
||||
"section_break_9",
|
||||
"total_taxes_and_charges",
|
||||
"col_break1",
|
||||
@ -123,7 +123,7 @@
|
||||
],
|
||||
"icon": "icon-usd",
|
||||
"is_submittable": 1,
|
||||
"modified": "2019-10-09 13:39:36.082777",
|
||||
"modified": "2019-11-21 15:34:10.846093",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Landed Cost Voucher",
|
||||
|
Loading…
x
Reference in New Issue
Block a user