fix: Multiple fixes related to landed cost accounting (#19656)
This commit is contained in:
parent
150c44b350
commit
7af153da50
@ -452,6 +452,10 @@ class PurchaseInvoice(BuyingController):
|
|||||||
fields = ["voucher_detail_no", "stock_value_difference"], filters={'voucher_no': self.name}):
|
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)
|
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"):
|
for item in self.get("items"):
|
||||||
if flt(item.base_net_amount):
|
if flt(item.base_net_amount):
|
||||||
account_currency = get_account_currency(item.expense_account)
|
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 \
|
if self.auto_accounting_for_stock and self.is_opening == "No" and \
|
||||||
item.item_code in stock_items and item.item_tax_amount:
|
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
|
# 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`
|
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""",
|
where voucher_type='Purchase Receipt' and voucher_no=%s and account in %s""",
|
||||||
(item.purchase_receipt, self.expenses_included_in_valuation))
|
(item.purchase_receipt, valuation_tax_accounts))
|
||||||
|
|
||||||
if not negative_expense_booked_in_pr:
|
if not negative_expense_booked_in_pr:
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
|
@ -204,7 +204,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
pi.insert()
|
pi.insert()
|
||||||
pi.submit()
|
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):
|
def check_gle_for_pi(self, pi):
|
||||||
gl_entries = frappe.db.sql("""select account, sum(debit) as debit, sum(credit) as credit
|
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][1], gle.debit)
|
||||||
self.assertEqual(expected_values[gle.account][2], gle.credit)
|
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):
|
def test_purchase_invoice_change_naming_series(self):
|
||||||
pi = frappe.copy_doc(test_records[1])
|
pi = frappe.copy_doc(test_records[1])
|
||||||
pi.insert()
|
pi.insert()
|
||||||
|
@ -117,6 +117,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fetch_from": "item_code.item_name",
|
"fetch_from": "item_code.item_name",
|
||||||
|
"fetch_if_empty": 1,
|
||||||
"fieldname": "item_name",
|
"fieldname": "item_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"in_global_search": 1,
|
"in_global_search": 1,
|
||||||
@ -192,7 +193,6 @@
|
|||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fetch_from": "item_code.stock_uom",
|
|
||||||
"fieldname": "uom",
|
"fieldname": "uom",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "UOM",
|
"label": "UOM",
|
||||||
@ -766,7 +766,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2019-11-03 13:43:23.782877",
|
"modified": "2019-11-21 16:27:52.043744",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice Item",
|
"name": "Purchase Invoice Item",
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
"naming_series",
|
"naming_series",
|
||||||
"company",
|
"company",
|
||||||
"purchase_receipts",
|
"purchase_receipts",
|
||||||
"sec_break1",
|
|
||||||
"taxes",
|
|
||||||
"purchase_receipt_items",
|
"purchase_receipt_items",
|
||||||
"get_items_from_purchase_receipts",
|
"get_items_from_purchase_receipts",
|
||||||
"items",
|
"items",
|
||||||
|
"sec_break1",
|
||||||
|
"taxes",
|
||||||
"section_break_9",
|
"section_break_9",
|
||||||
"total_taxes_and_charges",
|
"total_taxes_and_charges",
|
||||||
"col_break1",
|
"col_break1",
|
||||||
@ -123,7 +123,7 @@
|
|||||||
],
|
],
|
||||||
"icon": "icon-usd",
|
"icon": "icon-usd",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2019-10-09 13:39:36.082777",
|
"modified": "2019-11-21 15:34:10.846093",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Landed Cost Voucher",
|
"name": "Landed Cost Voucher",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user