fix: Tax withholding net total for PI in reports
This commit is contained in:
parent
bfd7a97ea9
commit
3eb1ed19a1
@ -40,7 +40,6 @@
|
|||||||
"discount_amount",
|
"discount_amount",
|
||||||
"base_rate_with_margin",
|
"base_rate_with_margin",
|
||||||
"sec_break2",
|
"sec_break2",
|
||||||
"apply_tds",
|
|
||||||
"rate",
|
"rate",
|
||||||
"amount",
|
"amount",
|
||||||
"item_tax_template",
|
"item_tax_template",
|
||||||
@ -50,6 +49,7 @@
|
|||||||
"pricing_rules",
|
"pricing_rules",
|
||||||
"stock_uom_rate",
|
"stock_uom_rate",
|
||||||
"is_free_item",
|
"is_free_item",
|
||||||
|
"apply_tds",
|
||||||
"section_break_22",
|
"section_break_22",
|
||||||
"net_rate",
|
"net_rate",
|
||||||
"net_amount",
|
"net_amount",
|
||||||
@ -871,16 +871,16 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "1",
|
"default": "1",
|
||||||
"fieldname": "apply_tds",
|
"fieldname": "apply_tds",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Apply TDS"
|
"label": "Apply TDS"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-10-26 16:05:37.304788",
|
"modified": "2022-11-29 13:01:20.438217",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice Item",
|
"name": "Purchase Invoice Item",
|
||||||
|
@ -14,9 +14,17 @@ def execute(filters=None):
|
|||||||
filters.naming_series = frappe.db.get_single_value("Buying Settings", "supp_master_name")
|
filters.naming_series = frappe.db.get_single_value("Buying Settings", "supp_master_name")
|
||||||
|
|
||||||
columns = get_columns(filters)
|
columns = get_columns(filters)
|
||||||
tds_docs, tds_accounts, tax_category_map, journal_entry_party_map = get_tds_docs(filters)
|
(
|
||||||
|
tds_docs,
|
||||||
|
tds_accounts,
|
||||||
|
tax_category_map,
|
||||||
|
journal_entry_party_map,
|
||||||
|
invoice_total_map,
|
||||||
|
) = get_tds_docs(filters)
|
||||||
|
|
||||||
res = get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_party_map)
|
res = get_result(
|
||||||
|
filters, tds_docs, tds_accounts, tax_category_map, journal_entry_party_map, invoice_total_map
|
||||||
|
)
|
||||||
final_result = group_by_supplier_and_category(res)
|
final_result = group_by_supplier_and_category(res)
|
||||||
|
|
||||||
return columns, final_result
|
return columns, final_result
|
||||||
|
@ -8,11 +8,19 @@ from frappe import _
|
|||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
validate_filters(filters)
|
validate_filters(filters)
|
||||||
tds_docs, tds_accounts, tax_category_map, journal_entry_party_map = get_tds_docs(filters)
|
(
|
||||||
|
tds_docs,
|
||||||
|
tds_accounts,
|
||||||
|
tax_category_map,
|
||||||
|
journal_entry_party_map,
|
||||||
|
invoice_net_total_map,
|
||||||
|
) = get_tds_docs(filters)
|
||||||
|
|
||||||
columns = get_columns(filters)
|
columns = get_columns(filters)
|
||||||
|
|
||||||
res = get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_party_map)
|
res = get_result(
|
||||||
|
filters, tds_docs, tds_accounts, tax_category_map, journal_entry_party_map, invoice_net_total_map
|
||||||
|
)
|
||||||
return columns, res
|
return columns, res
|
||||||
|
|
||||||
|
|
||||||
@ -22,7 +30,9 @@ def validate_filters(filters):
|
|||||||
frappe.throw(_("From Date must be before To Date"))
|
frappe.throw(_("From Date must be before To Date"))
|
||||||
|
|
||||||
|
|
||||||
def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_party_map):
|
def get_result(
|
||||||
|
filters, tds_docs, tds_accounts, tax_category_map, journal_entry_party_map, invoice_net_total_map
|
||||||
|
):
|
||||||
supplier_map = get_supplier_pan_map()
|
supplier_map = get_supplier_pan_map()
|
||||||
tax_rate_map = get_tax_rate_map(filters)
|
tax_rate_map = get_tax_rate_map(filters)
|
||||||
gle_map = get_gle_map(tds_docs)
|
gle_map = get_gle_map(tds_docs)
|
||||||
@ -50,7 +60,10 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_
|
|||||||
if entry.account in tds_accounts:
|
if entry.account in tds_accounts:
|
||||||
tds_deducted += entry.credit - entry.debit
|
tds_deducted += entry.credit - entry.debit
|
||||||
|
|
||||||
total_amount_credited += entry.credit
|
if invoice_net_total_map.get(name):
|
||||||
|
total_amount_credited = invoice_net_total_map.get(name)
|
||||||
|
else:
|
||||||
|
total_amount_credited += entry.credit
|
||||||
|
|
||||||
if tds_deducted:
|
if tds_deducted:
|
||||||
row = {
|
row = {
|
||||||
@ -179,9 +192,10 @@ def get_tds_docs(filters):
|
|||||||
purchase_invoices = []
|
purchase_invoices = []
|
||||||
payment_entries = []
|
payment_entries = []
|
||||||
journal_entries = []
|
journal_entries = []
|
||||||
tax_category_map = {}
|
tax_category_map = frappe._dict()
|
||||||
or_filters = {}
|
invoice_net_total_map = frappe._dict()
|
||||||
journal_entry_party_map = {}
|
or_filters = frappe._dict()
|
||||||
|
journal_entry_party_map = frappe._dict()
|
||||||
bank_accounts = frappe.get_all("Account", {"is_group": 0, "account_type": "Bank"}, pluck="name")
|
bank_accounts = frappe.get_all("Account", {"is_group": 0, "account_type": "Bank"}, pluck="name")
|
||||||
|
|
||||||
tds_accounts = frappe.get_all(
|
tds_accounts = frappe.get_all(
|
||||||
@ -218,16 +232,22 @@ def get_tds_docs(filters):
|
|||||||
tds_documents.append(d.voucher_no)
|
tds_documents.append(d.voucher_no)
|
||||||
|
|
||||||
if purchase_invoices:
|
if purchase_invoices:
|
||||||
get_tax_category_map(purchase_invoices, "Purchase Invoice", tax_category_map)
|
get_doc_info(purchase_invoices, "Purchase Invoice", tax_category_map, invoice_net_total_map)
|
||||||
|
|
||||||
if payment_entries:
|
if payment_entries:
|
||||||
get_tax_category_map(payment_entries, "Payment Entry", tax_category_map)
|
get_doc_info(payment_entries, "Payment Entry", tax_category_map)
|
||||||
|
|
||||||
if journal_entries:
|
if journal_entries:
|
||||||
journal_entry_party_map = get_journal_entry_party_map(journal_entries)
|
journal_entry_party_map = get_journal_entry_party_map(journal_entries)
|
||||||
get_tax_category_map(journal_entries, "Journal Entry", tax_category_map)
|
get_doc_info(journal_entries, "Journal Entry", tax_category_map)
|
||||||
|
|
||||||
return tds_documents, tds_accounts, tax_category_map, journal_entry_party_map
|
return (
|
||||||
|
tds_documents,
|
||||||
|
tds_accounts,
|
||||||
|
tax_category_map,
|
||||||
|
journal_entry_party_map,
|
||||||
|
invoice_net_total_map,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_journal_entry_party_map(journal_entries):
|
def get_journal_entry_party_map(journal_entries):
|
||||||
@ -244,17 +264,18 @@ def get_journal_entry_party_map(journal_entries):
|
|||||||
return journal_entry_party_map
|
return journal_entry_party_map
|
||||||
|
|
||||||
|
|
||||||
def get_tax_category_map(vouchers, doctype, tax_category_map):
|
def get_doc_info(vouchers, doctype, tax_category_map, invoice_net_total_map=None):
|
||||||
tax_category_map.update(
|
if doctype == "Purchase Invoice":
|
||||||
frappe._dict(
|
fields = ["name", "tax_withholding_category", "base_tax_withholding_net_total"]
|
||||||
frappe.get_all(
|
else:
|
||||||
doctype,
|
fields = ["name", "tax_withholding_category"]
|
||||||
filters={"name": ("in", vouchers)},
|
|
||||||
fields=["name", "tax_withholding_category"],
|
entries = frappe.get_all(doctype, filters={"name": ("in", vouchers)}, fields=fields)
|
||||||
as_list=1,
|
|
||||||
)
|
for entry in entries:
|
||||||
)
|
tax_category_map.update({entry.name: entry.tax_withholding_category})
|
||||||
)
|
if doctype == "Purchase Invoice":
|
||||||
|
invoice_net_total_map.update({entry.name: entry.base_tax_withholding_net_total})
|
||||||
|
|
||||||
|
|
||||||
def get_tax_rate_map(filters):
|
def get_tax_rate_map(filters):
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
"discount_amount",
|
"discount_amount",
|
||||||
"base_rate_with_margin",
|
"base_rate_with_margin",
|
||||||
"sec_break2",
|
"sec_break2",
|
||||||
"apply_tds",
|
|
||||||
"rate",
|
"rate",
|
||||||
"amount",
|
"amount",
|
||||||
"item_tax_template",
|
"item_tax_template",
|
||||||
@ -54,6 +53,7 @@
|
|||||||
"pricing_rules",
|
"pricing_rules",
|
||||||
"stock_uom_rate",
|
"stock_uom_rate",
|
||||||
"is_free_item",
|
"is_free_item",
|
||||||
|
"apply_tds",
|
||||||
"section_break_29",
|
"section_break_29",
|
||||||
"net_rate",
|
"net_rate",
|
||||||
"net_amount",
|
"net_amount",
|
||||||
@ -902,7 +902,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-10-26 16:47:41.364387",
|
"modified": "2022-11-29 16:47:41.364387",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order Item",
|
"name": "Purchase Order Item",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user