fix: item wise sales register taxes and charges
I have added a separate column for other charges. Instead of adding all values to tax_total, it checks if account_type is tax, and then only it adds to total_tax otherwise it adds to the total_other_charges.
This commit is contained in:
@@ -97,6 +97,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
|
|||||||
row.update({"rate": d.base_net_rate, "amount": d.base_net_amount})
|
row.update({"rate": d.base_net_rate, "amount": d.base_net_amount})
|
||||||
|
|
||||||
total_tax = 0
|
total_tax = 0
|
||||||
|
total_other_charges = 0
|
||||||
for tax in tax_columns:
|
for tax in tax_columns:
|
||||||
item_tax = itemised_tax.get(d.name, {}).get(tax, {})
|
item_tax = itemised_tax.get(d.name, {}).get(tax, {})
|
||||||
row.update(
|
row.update(
|
||||||
@@ -105,10 +106,18 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
|
|||||||
frappe.scrub(tax + " Amount"): item_tax.get("tax_amount", 0),
|
frappe.scrub(tax + " Amount"): item_tax.get("tax_amount", 0),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
total_tax += flt(item_tax.get("tax_amount"))
|
if item_tax.get("is_other_charges"):
|
||||||
|
total_other_charges += flt(item_tax.get("tax_amount"))
|
||||||
|
else:
|
||||||
|
total_tax += flt(item_tax.get("tax_amount"))
|
||||||
|
|
||||||
row.update(
|
row.update(
|
||||||
{"total_tax": total_tax, "total": d.base_net_amount + total_tax, "currency": company_currency}
|
{
|
||||||
|
"total_tax": total_tax,
|
||||||
|
"total_other_charges": total_other_charges,
|
||||||
|
"total": d.base_net_amount + total_tax,
|
||||||
|
"currency": company_currency,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if filters.get("group_by"):
|
if filters.get("group_by"):
|
||||||
@@ -477,7 +486,7 @@ def get_tax_accounts(
|
|||||||
tax_details = frappe.db.sql(
|
tax_details = frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
select
|
select
|
||||||
name, parent, description, item_wise_tax_detail,
|
name, parent, description, item_wise_tax_detail, account_head,
|
||||||
charge_type, {add_deduct_tax}, base_tax_amount_after_discount_amount
|
charge_type, {add_deduct_tax}, base_tax_amount_after_discount_amount
|
||||||
from `tab%s`
|
from `tab%s`
|
||||||
where
|
where
|
||||||
@@ -493,11 +502,22 @@ def get_tax_accounts(
|
|||||||
tuple([doctype] + list(invoice_item_row)),
|
tuple([doctype] + list(invoice_item_row)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
account_doctype = frappe.qb.DocType("Account")
|
||||||
|
|
||||||
|
query = (
|
||||||
|
frappe.qb.from_(account_doctype)
|
||||||
|
.select(account_doctype.name)
|
||||||
|
.where((account_doctype.account_type == "Tax"))
|
||||||
|
)
|
||||||
|
|
||||||
|
tax_accounts = query.run()
|
||||||
|
|
||||||
for (
|
for (
|
||||||
name,
|
name,
|
||||||
parent,
|
parent,
|
||||||
description,
|
description,
|
||||||
item_wise_tax_detail,
|
item_wise_tax_detail,
|
||||||
|
account_head,
|
||||||
charge_type,
|
charge_type,
|
||||||
add_deduct_tax,
|
add_deduct_tax,
|
||||||
tax_amount,
|
tax_amount,
|
||||||
@@ -540,7 +560,11 @@ def get_tax_accounts(
|
|||||||
)
|
)
|
||||||
|
|
||||||
itemised_tax.setdefault(d.name, {})[description] = frappe._dict(
|
itemised_tax.setdefault(d.name, {})[description] = frappe._dict(
|
||||||
{"tax_rate": tax_rate, "tax_amount": tax_value}
|
{
|
||||||
|
"tax_rate": tax_rate,
|
||||||
|
"tax_amount": tax_value,
|
||||||
|
"is_other_charges": 0 if tuple([account_head]) in tax_accounts else 1,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@@ -583,6 +607,13 @@ def get_tax_accounts(
|
|||||||
"options": "currency",
|
"options": "currency",
|
||||||
"width": 100,
|
"width": 100,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": _("Total Other Charges"),
|
||||||
|
"fieldname": "total_other_charges",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"width": 100,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": _("Total"),
|
"label": _("Total"),
|
||||||
"fieldname": "total",
|
"fieldname": "total",
|
||||||
|
|||||||
Reference in New Issue
Block a user