feat: item wise tds calculation for purchase order.
This commit is contained in:
parent
b9d0b4e2d3
commit
46e8cdf31a
@ -226,6 +226,42 @@ class TestTaxWithholdingCategory(unittest.TestCase):
|
|||||||
for d in reversed(invoices):
|
for d in reversed(invoices):
|
||||||
d.cancel()
|
d.cancel()
|
||||||
|
|
||||||
|
orders = []
|
||||||
|
|
||||||
|
po = create_purchase_order(supplier="Test TDS Supplier4", rate=20000, do_not_save=True)
|
||||||
|
po.extend(
|
||||||
|
"items",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"doctype": "Purchase Order Item",
|
||||||
|
"item_code": frappe.db.get_value("Item", {"item_name": "TDS Item"}, "name"),
|
||||||
|
"qty": 1,
|
||||||
|
"rate": 20000,
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"expense_account": "Stock Received But Not Billed - _TC",
|
||||||
|
"apply_tds": 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Purchase Order Item",
|
||||||
|
"item_code": frappe.db.get_value("Item", {"item_name": "TDS Item"}, "name"),
|
||||||
|
"qty": 1,
|
||||||
|
"rate": 35000,
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"expense_account": "Stock Received But Not Billed - _TC",
|
||||||
|
"apply_tds": 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
po.save()
|
||||||
|
po.submit()
|
||||||
|
orders.append(po)
|
||||||
|
|
||||||
|
self.assertEqual(po.taxes[0].tax_amount, 5500)
|
||||||
|
|
||||||
|
# cancel orders to avoid clashing
|
||||||
|
for d in reversed(orders):
|
||||||
|
d.cancel()
|
||||||
|
|
||||||
def test_multi_category_single_supplier(self):
|
def test_multi_category_single_supplier(self):
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Supplier", "Test TDS Supplier5", "tax_withholding_category", "Test Service Category"
|
"Supplier", "Test TDS Supplier5", "tax_withholding_category", "Test Service Category"
|
||||||
@ -348,6 +384,39 @@ def create_purchase_invoice(**args):
|
|||||||
return pi
|
return pi
|
||||||
|
|
||||||
|
|
||||||
|
def create_purchase_order(**args):
|
||||||
|
# return purchase order doc object
|
||||||
|
item = frappe.db.get_value("Item", {"item_name": "TDS Item"}, "name")
|
||||||
|
|
||||||
|
args = frappe._dict(args)
|
||||||
|
po = frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Purchase Order",
|
||||||
|
"transaction_date": today(),
|
||||||
|
"schedule_date": today(),
|
||||||
|
"apply_tds": 0 if args.do_not_apply_tds else 1,
|
||||||
|
"supplier": args.supplier,
|
||||||
|
"company": "_Test Company",
|
||||||
|
"taxes_and_charges": "",
|
||||||
|
"currency": "INR",
|
||||||
|
"taxes": [],
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"doctype": "Purchase Order Item",
|
||||||
|
"item_code": item,
|
||||||
|
"qty": args.qty or 1,
|
||||||
|
"rate": args.rate or 10000,
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"expense_account": "Stock Received But Not Billed - _TC",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
po.save()
|
||||||
|
return po
|
||||||
|
|
||||||
|
|
||||||
def create_sales_invoice(**args):
|
def create_sales_invoice(**args):
|
||||||
# return sales invoice doc object
|
# return sales invoice doc object
|
||||||
item = frappe.db.get_value("Item", {"item_name": "TCS Item"}, "name")
|
item = frappe.db.get_value("Item", {"item_name": "TCS Item"}, "name")
|
||||||
|
@ -25,5 +25,21 @@ def execute():
|
|||||||
).where(
|
).where(
|
||||||
purchase_invoice.docstatus == 1
|
purchase_invoice.docstatus == 1
|
||||||
).run()
|
).run()
|
||||||
|
|
||||||
|
purchase_order = frappe.qb.DocType("Purchase Order")
|
||||||
|
|
||||||
|
frappe.qb.update(purchase_order).set(
|
||||||
|
purchase_order.tax_withholding_net_total, purchase_order.net_total
|
||||||
|
).set(
|
||||||
|
purchase_order.base_tax_withholding_net_total, purchase_order.base_net_total
|
||||||
|
).where(
|
||||||
|
purchase_order.company == company.name
|
||||||
|
).where(
|
||||||
|
purchase_order.apply_tds == 1
|
||||||
|
).where(
|
||||||
|
purchase_order.transaction_date >= fiscal_year_details.year_start_date
|
||||||
|
).where(
|
||||||
|
purchase_order.docstatus == 1
|
||||||
|
).run()
|
||||||
except FiscalYearError:
|
except FiscalYearError:
|
||||||
pass
|
pass
|
Loading…
x
Reference in New Issue
Block a user