test: Add tests
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 1d59651..1eeaf13 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -83,6 +83,8 @@
"section_break_51",
"taxes_and_charges",
"taxes",
+ "tax_withheld_vouchers_section",
+ "tax_withheld_vouchers",
"sec_tax_breakup",
"other_charges_calculation",
"totals",
@@ -93,8 +95,6 @@
"taxes_and_charges_added",
"taxes_and_charges_deducted",
"total_taxes_and_charges",
- "tax_withheld_vouchers_section",
- "tax_withheld_vouchers",
"section_break_44",
"apply_discount_on",
"base_discount_amount",
@@ -1446,7 +1446,7 @@
"idx": 204,
"is_submittable": 1,
"links": [],
- "modified": "2022-09-13 16:22:04.103982",
+ "modified": "2022-09-13 23:39:54.525037",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",
diff --git a/erpnext/accounts/doctype/tax_withheld_vouchers/tax_withheld_vouchers.json b/erpnext/accounts/doctype/tax_withheld_vouchers/tax_withheld_vouchers.json
index cecc6fb..ce8c0c3 100644
--- a/erpnext/accounts/doctype/tax_withheld_vouchers/tax_withheld_vouchers.json
+++ b/erpnext/accounts/doctype/tax_withheld_vouchers/tax_withheld_vouchers.json
@@ -29,13 +29,14 @@
"fieldname": "taxable_amount",
"fieldtype": "Currency",
"in_list_view": 1,
- "label": "Taxable Amount"
+ "label": "Taxable Amount",
+ "options": "Company:company:default_currency"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2022-09-13 17:31:52.321034",
+ "modified": "2022-09-13 23:40:41.479208",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Tax Withheld Vouchers",
diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
index f2fa770..15f75d1 100644
--- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
+++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
@@ -285,9 +285,7 @@
{"apply_tds": 1, "tax_withholding_category": tax_details.get("tax_withholding_category")}
)
- invoices_details = frappe.get_all(
- doctype, filters=filters, fields=["name", "base_net_total"]
- ) or [""]
+ invoices_details = frappe.get_all(doctype, filters=filters, fields=["name", "base_net_total"])
for d in invoices_details:
vouchers.append(d.name)
diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
index 3059f8d..5c031a9 100644
--- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
+++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
@@ -148,7 +148,7 @@
self.assertEqual(tcs_charged, 500)
invoices.append(si)
- # delete invoices to avoid clashing
+ # cancel invoices to avoid clashing
for d in invoices:
d.cancel()
@@ -182,7 +182,7 @@
self.assertEqual(pi1.taxes[0].tax_amount, 4000)
- # delete invoices to avoid clashing
+ # cancel invoices to avoid clashing
for d in invoices:
d.cancel()
@@ -207,10 +207,52 @@
self.assertEqual(pi1.taxes[0].tax_amount, 250)
- # delete invoices to avoid clashing
+ # cancel invoices to avoid clashing
for d in invoices:
d.cancel()
+ def test_tax_withholding_category_voucher_display(self):
+ frappe.db.set_value(
+ "Supplier", "Test TDS Supplier6", "tax_withholding_category", "Test Multi Invoice Category"
+ )
+ invoices = []
+
+ pi = create_purchase_invoice(supplier="Test TDS Supplier6", rate=4000, do_not_save=True)
+ pi.apply_tds = 1
+ pi.tax_withholding_category = "Test Multi Invoice Category"
+ pi.save()
+ pi.submit()
+ invoices.append(pi)
+
+ pi1 = create_purchase_invoice(supplier="Test TDS Supplier6", rate=2000, do_not_save=True)
+ pi1.apply_tds = 1
+ pi1.is_return = 1
+ pi1.items[0].qty = -1
+ pi1.tax_withholding_category = "Test Multi Invoice Category"
+ pi1.save()
+ pi1.submit()
+ invoices.append(pi1)
+
+ pi2 = create_purchase_invoice(supplier="Test TDS Supplier6", rate=9000, do_not_save=True)
+ pi2.apply_tds = 1
+ pi2.tax_withholding_category = "Test Multi Invoice Category"
+ pi2.save()
+ pi2.submit()
+ invoices.append(pi2)
+
+ pi2.load_from_db()
+
+ self.assertTrue(pi2.taxes[0].tax_amount, 1100)
+
+ self.assertTrue(pi2.tax_withheld_vouchers[0].voucher_name == pi1.name)
+ self.assertTrue(pi2.tax_withheld_vouchers[0].taxable_amount == pi1.net_total)
+ self.assertTrue(pi2.tax_withheld_vouchers[1].voucher_name == pi.name)
+ self.assertTrue(pi2.tax_withheld_vouchers[1].taxable_amount == pi.net_total)
+
+ # cancel invoices to avoid clashing
+ for d in reversed(invoices):
+ d.cancel()
+
def cancel_invoices():
purchase_invoices = frappe.get_all(
@@ -308,6 +350,7 @@
"Test TDS Supplier3",
"Test TDS Supplier4",
"Test TDS Supplier5",
+ "Test TDS Supplier6",
]:
if frappe.db.exists("Supplier", name):
continue
@@ -498,3 +541,22 @@
"accounts": [{"company": "_Test Company", "account": "TDS - _TC"}],
}
).insert()
+
+ if not frappe.db.exists("Tax Withholding Category", "Test Multi Invoice Category"):
+ frappe.get_doc(
+ {
+ "doctype": "Tax Withholding Category",
+ "name": "Test Multi Invoice Category",
+ "category_name": "Test Multi Invoice Category",
+ "rates": [
+ {
+ "from_date": fiscal_year[1],
+ "to_date": fiscal_year[2],
+ "tax_withholding_rate": 10,
+ "single_threshold": 5000,
+ "cumulative_threshold": 10000,
+ }
+ ],
+ "accounts": [{"company": "_Test Company", "account": "TDS - _TC"}],
+ }
+ ).insert()
diff --git a/erpnext/www/lms/__init__.py b/erpnext/www/lms/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/www/lms/__init__.py