Skip to content

Commit

Permalink
fix: Add company field to lower deduction certificate (#34914)
Browse files Browse the repository at this point in the history
* fix: Add company field to lower deduction certificate (#34914)

(cherry picked from commit b545e3d)

# Conflicts:
#	erpnext/patches.txt

* chore: resolve conflicts

---------

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
  • Loading branch information
mergify[bot] and deepeshgarg007 committed Apr 25, 2023
1 parent 693007a commit d732083
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,15 @@ def get_tax_row_for_tds(tax_details, tax_amount):
}


def get_lower_deduction_certificate(tax_details, pan_no):
def get_lower_deduction_certificate(company, tax_details, pan_no):
ldc_name = frappe.db.get_value(
"Lower Deduction Certificate",
{
"pan_no": pan_no,
"tax_withholding_category": tax_details.tax_withholding_category,
"valid_from": (">=", tax_details.from_date),
"valid_upto": ("<=", tax_details.to_date),
"company": company,
},
"name",
)
Expand Down Expand Up @@ -255,7 +256,7 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N
tax_amount = 0

if party_type == "Supplier":
ldc = get_lower_deduction_certificate(tax_details, pan_no)
ldc = get_lower_deduction_certificate(inv.company, tax_details, pan_no)
if tax_deducted:
net_total = inv.tax_withholding_net_total
if ldc:
Expand Down
1 change: 1 addition & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,4 @@ erpnext.patches.v13_0.update_docs_link
execute:frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0)
# below migration patches should always run last
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
erpnext.patches.v14_0.update_company_in_ldc
14 changes: 14 additions & 0 deletions erpnext/patches/v14_0/update_company_in_ldc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE


import frappe

from erpnext import get_default_company


def execute():
company = get_default_company()
if company:
for d in frappe.get_all("Lower Deduction Certificate", pluck="name"):
frappe.db.set_value("Lower Deduction Certificate", d, "company", company, update_modified=False)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"tax_withholding_category",
"fiscal_year",
"column_break_3",
"company",
"certificate_no",
"section_break_3",
"supplier",
Expand Down Expand Up @@ -123,11 +124,18 @@
"label": "Tax Withholding Category",
"options": "Tax Withholding Category",
"reqd": 1
},
{
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"reqd": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-10-23 18:33:38.962622",
"modified": "2023-04-18 08:25:35.302081",
"modified_by": "Administrator",
"module": "Regional",
"name": "Lower Deduction Certificate",
Expand All @@ -136,5 +144,6 @@
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}

0 comments on commit d732083

Please sign in to comment.