From e114ea98c311f17b0fa1e1e17a7b1e891577ea3e Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Tue, 24 Oct 2023 10:16:36 +0530 Subject: [PATCH] test: add bill of entry test case --- .../doctype/bill_of_entry/bill_of_entry.js | 9 ++- .../overrides/test_ineligible_itc.py | 57 ++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js b/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js index 85397837a6..42fc80e43a 100644 --- a/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js +++ b/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js @@ -26,7 +26,14 @@ frappe.ui.form.on("Bill of Entry", { ); } - if (frm.doc.docstatus === 1 && frm.doc.total_customs_duty > 0) { + const has_ineligible_items = frm.doc.items.some( + item => item.is_ineligible_for_itc + ); + + if ( + (frm.doc.docstatus === 1 && frm.doc.total_customs_duty > 0) || + has_ineligible_items + ) { frm.add_custom_button( __("Landed Cost Voucher"), () => { diff --git a/india_compliance/gst_india/overrides/test_ineligible_itc.py b/india_compliance/gst_india/overrides/test_ineligible_itc.py index dd21b5438a..96995c337e 100644 --- a/india_compliance/gst_india/overrides/test_ineligible_itc.py +++ b/india_compliance/gst_india/overrides/test_ineligible_itc.py @@ -2,12 +2,17 @@ from contextlib import contextmanager import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.utils import today from erpnext.controllers.sales_and_purchase_return import make_return_doc from erpnext.stock.doctype.purchase_receipt.purchase_receipt import ( make_purchase_invoice, ) +from india_compliance.gst_india.doctype.bill_of_entry.bill_of_entry import ( + make_bill_of_entry, + make_landed_cost_voucher, +) from india_compliance.gst_india.utils.tests import create_transaction SAMPLE_ITEM_LIST = [ @@ -651,8 +656,56 @@ def test_purchase_receipt_and_then_purchase_invoice_for_provisional_expense(self ], ) + @change_settings("GST Settings", {"enable_overseas_transactions": 1}) def test_purchase_invoice_with_bill_of_entry(self): - pass + transaction_details = { + "doctype": "Purchase Invoice", + "supplier": "_Test Foreign Supplier", + "bill_no": "BILL-08", + "update_stock": 1, + "items": SAMPLE_ITEM_LIST, + } + doc = create_transaction(**transaction_details) + boe = make_bill_of_entry(doc.name) + boe.bill_of_entry_no = "BILL-09" + boe.bill_of_entry_date = today() + boe.submit() + + self.assertGLEntry( + boe.name, + [ + { + "account": "Administrative Expenses - _TIRC", + "debit": 179.64, + "credit": 0.0, + }, + { + "account": "Customs Duty Payable - _TIRC", + "debit": 0.0, + "credit": 855.72, + }, + {"account": "GST Expense - _TIRC", "debit": 369.72, "credit": 179.64}, + {"account": "Input Tax IGST - _TIRC", "debit": 0.0, "credit": 369.72}, + {"account": "Input Tax IGST - _TIRC", "debit": 855.72, "credit": 0.0}, + ], + ) + + lcv = make_landed_cost_voucher(boe.name) + lcv.save() + + for item in lcv.items: + if item.item_code == "Test Ineligible Stock Item": + self.assertEqual(item.applicable_charges, 3.42) # 10.26 / 3 Nos + elif item.item_code == "Test Ineligible Fixed Asset": + self.assertEqual(item.applicable_charges, 179.82) + else: + self.assertEqual(item.applicable_charges, 0.0) + + for row in lcv.taxes: + if row.expense_account == "GST Expense - _TIRC": + self.assertEqual(row.amount, 190.08) + else: + self.assertEqual(row.amount, 0.0) def assertGLEntry(self, docname, expected_gl_entry): gl_entries = frappe.get_all(