mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
feat: Add net_total to Taxes And Charges doctypes and modify relevant controllers
This commit is contained in:
@@ -20,11 +20,13 @@
|
|||||||
"rate",
|
"rate",
|
||||||
"section_break_9",
|
"section_break_9",
|
||||||
"currency",
|
"currency",
|
||||||
|
"net_amount",
|
||||||
"tax_amount",
|
"tax_amount",
|
||||||
"total",
|
"total",
|
||||||
"allocated_amount",
|
"allocated_amount",
|
||||||
"column_break_13",
|
"column_break_13",
|
||||||
"base_tax_amount",
|
"base_tax_amount",
|
||||||
|
"base_net_amount",
|
||||||
"base_total"
|
"base_total"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
@@ -174,12 +176,29 @@
|
|||||||
"label": "Account Currency",
|
"label": "Account Currency",
|
||||||
"options": "Currency",
|
"options": "Currency",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 2,
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"oldfieldname": "tax_amount",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:05:58.437605",
|
"modified": "2024-09-24 06:51:07.417348",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Advance Taxes and Charges",
|
"name": "Advance Taxes and Charges",
|
||||||
@@ -188,4 +207,4 @@
|
|||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "ASC",
|
"sort_order": "ASC",
|
||||||
"states": []
|
"states": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class AdvanceTaxesandCharges(Document):
|
|||||||
account_head: DF.Link
|
account_head: DF.Link
|
||||||
add_deduct_tax: DF.Literal["Add", "Deduct"]
|
add_deduct_tax: DF.Literal["Add", "Deduct"]
|
||||||
allocated_amount: DF.Currency
|
allocated_amount: DF.Currency
|
||||||
|
base_net_amount: DF.Currency
|
||||||
base_tax_amount: DF.Currency
|
base_tax_amount: DF.Currency
|
||||||
base_total: DF.Currency
|
base_total: DF.Currency
|
||||||
charge_type: DF.Literal[
|
charge_type: DF.Literal[
|
||||||
@@ -27,6 +28,7 @@ class AdvanceTaxesandCharges(Document):
|
|||||||
currency: DF.Link | None
|
currency: DF.Link | None
|
||||||
description: DF.SmallText
|
description: DF.SmallText
|
||||||
included_in_paid_amount: DF.Check
|
included_in_paid_amount: DF.Check
|
||||||
|
net_amount: DF.Currency
|
||||||
parent: DF.Data
|
parent: DF.Data
|
||||||
parentfield: DF.Data
|
parentfield: DF.Data
|
||||||
parenttype: DF.Data
|
parenttype: DF.Data
|
||||||
|
|||||||
@@ -24,10 +24,12 @@
|
|||||||
"dimension_col_break",
|
"dimension_col_break",
|
||||||
"section_break_9",
|
"section_break_9",
|
||||||
"account_currency",
|
"account_currency",
|
||||||
|
"net_amount",
|
||||||
"tax_amount",
|
"tax_amount",
|
||||||
"tax_amount_after_discount_amount",
|
"tax_amount_after_discount_amount",
|
||||||
"total",
|
"total",
|
||||||
"column_break_14",
|
"column_break_14",
|
||||||
|
"base_net_amount",
|
||||||
"base_tax_amount",
|
"base_tax_amount",
|
||||||
"base_total",
|
"base_total",
|
||||||
"base_tax_amount_after_discount_amount",
|
"base_tax_amount_after_discount_amount",
|
||||||
@@ -233,12 +235,30 @@
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Is Tax Withholding Account",
|
"label": "Is Tax Withholding Account",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 2,
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Net Amount",
|
||||||
|
"oldfieldname": "tax_amount",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "currency"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-04-08 19:51:36.678551",
|
"modified": "2024-09-24 06:47:25.129901",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Taxes and Charges",
|
"name": "Purchase Taxes and Charges",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class PurchaseTaxesandCharges(Document):
|
|||||||
account_currency: DF.Link | None
|
account_currency: DF.Link | None
|
||||||
account_head: DF.Link
|
account_head: DF.Link
|
||||||
add_deduct_tax: DF.Literal["Add", "Deduct"]
|
add_deduct_tax: DF.Literal["Add", "Deduct"]
|
||||||
|
base_net_amount: DF.Currency
|
||||||
base_tax_amount: DF.Currency
|
base_tax_amount: DF.Currency
|
||||||
base_tax_amount_after_discount_amount: DF.Currency
|
base_tax_amount_after_discount_amount: DF.Currency
|
||||||
base_total: DF.Currency
|
base_total: DF.Currency
|
||||||
@@ -35,6 +36,7 @@ class PurchaseTaxesandCharges(Document):
|
|||||||
included_in_print_rate: DF.Check
|
included_in_print_rate: DF.Check
|
||||||
is_tax_withholding_account: DF.Check
|
is_tax_withholding_account: DF.Check
|
||||||
item_wise_tax_detail: DF.Code | None
|
item_wise_tax_detail: DF.Code | None
|
||||||
|
net_amount: DF.Currency
|
||||||
parent: DF.Data
|
parent: DF.Data
|
||||||
parentfield: DF.Data
|
parentfield: DF.Data
|
||||||
parenttype: DF.Data
|
parenttype: DF.Data
|
||||||
|
|||||||
@@ -20,10 +20,12 @@
|
|||||||
"rate",
|
"rate",
|
||||||
"section_break_9",
|
"section_break_9",
|
||||||
"account_currency",
|
"account_currency",
|
||||||
|
"net_amount",
|
||||||
"tax_amount",
|
"tax_amount",
|
||||||
"total",
|
"total",
|
||||||
"tax_amount_after_discount_amount",
|
"tax_amount_after_discount_amount",
|
||||||
"column_break_13",
|
"column_break_13",
|
||||||
|
"base_net_amount",
|
||||||
"base_tax_amount",
|
"base_tax_amount",
|
||||||
"base_total",
|
"base_total",
|
||||||
"base_tax_amount_after_discount_amount",
|
"base_tax_amount_after_discount_amount",
|
||||||
@@ -212,13 +214,30 @@
|
|||||||
"label": "Account Currency",
|
"label": "Account Currency",
|
||||||
"options": "Currency",
|
"options": "Currency",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 2,
|
||||||
|
"fieldname": "net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Net Amount",
|
||||||
|
"options": "currency"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "base_net_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Net Amount (Company Currency)",
|
||||||
|
"oldfieldname": "tax_amount",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:10:38.190993",
|
"modified": "2024-09-24 06:49:32.034074",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Taxes and Charges",
|
"name": "Sales Taxes and Charges",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class SalesTaxesandCharges(Document):
|
|||||||
|
|
||||||
account_currency: DF.Link | None
|
account_currency: DF.Link | None
|
||||||
account_head: DF.Link
|
account_head: DF.Link
|
||||||
|
base_net_amount: DF.Currency
|
||||||
base_tax_amount: DF.Currency
|
base_tax_amount: DF.Currency
|
||||||
base_tax_amount_after_discount_amount: DF.Currency
|
base_tax_amount_after_discount_amount: DF.Currency
|
||||||
base_total: DF.Currency
|
base_total: DF.Currency
|
||||||
@@ -33,6 +34,7 @@ class SalesTaxesandCharges(Document):
|
|||||||
included_in_paid_amount: DF.Check
|
included_in_paid_amount: DF.Check
|
||||||
included_in_print_rate: DF.Check
|
included_in_print_rate: DF.Check
|
||||||
item_wise_tax_detail: DF.Code | None
|
item_wise_tax_detail: DF.Code | None
|
||||||
|
net_amount: DF.Currency
|
||||||
parent: DF.Data
|
parent: DF.Data
|
||||||
parentfield: DF.Data
|
parentfield: DF.Data
|
||||||
parenttype: DF.Data
|
parenttype: DF.Data
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ class calculate_taxes_and_totals:
|
|||||||
tax.item_wise_tax_detail = {}
|
tax.item_wise_tax_detail = {}
|
||||||
|
|
||||||
tax_fields = [
|
tax_fields = [
|
||||||
|
"net_amount",
|
||||||
"total",
|
"total",
|
||||||
"tax_amount_after_discount_amount",
|
"tax_amount_after_discount_amount",
|
||||||
"tax_amount_for_current_item",
|
"tax_amount_for_current_item",
|
||||||
@@ -380,9 +381,12 @@ class calculate_taxes_and_totals:
|
|||||||
item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
|
item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
|
||||||
for i, tax in enumerate(self.doc.get("taxes")):
|
for i, tax in enumerate(self.doc.get("taxes")):
|
||||||
# tax_amount represents the amount of tax for the current step
|
# tax_amount represents the amount of tax for the current step
|
||||||
current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
|
current_net_amount, current_tax_amount = self.get_current_tax_and_net_amount(
|
||||||
|
item, tax, item_tax_map
|
||||||
|
)
|
||||||
if frappe.flags.round_row_wise_tax:
|
if frappe.flags.round_row_wise_tax:
|
||||||
current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount"))
|
current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount"))
|
||||||
|
current_net_amount = flt(current_net_amount, tax.precision("net_amount"))
|
||||||
|
|
||||||
# Adjust divisional loss to the last item
|
# Adjust divisional loss to the last item
|
||||||
if tax.charge_type == "Actual":
|
if tax.charge_type == "Actual":
|
||||||
@@ -395,6 +399,7 @@ class calculate_taxes_and_totals:
|
|||||||
self.discount_amount_applied and self.doc.apply_discount_on == "Grand Total"
|
self.discount_amount_applied and self.doc.apply_discount_on == "Grand Total"
|
||||||
):
|
):
|
||||||
tax.tax_amount += current_tax_amount
|
tax.tax_amount += current_tax_amount
|
||||||
|
tax.net_amount += current_net_amount
|
||||||
|
|
||||||
# store tax_amount for current item as it will be used for
|
# store tax_amount for current item as it will be used for
|
||||||
# charge type = 'On Previous Row Amount'
|
# charge type = 'On Previous Row Amount'
|
||||||
@@ -419,7 +424,9 @@ class calculate_taxes_and_totals:
|
|||||||
# set precision in the last item iteration
|
# set precision in the last item iteration
|
||||||
if n == len(self._items) - 1:
|
if n == len(self._items) - 1:
|
||||||
self.round_off_totals(tax)
|
self.round_off_totals(tax)
|
||||||
self._set_in_company_currency(tax, ["tax_amount", "tax_amount_after_discount_amount"])
|
self._set_in_company_currency(
|
||||||
|
tax, ["tax_amount", "tax_amount_after_discount_amount", "net_amount"]
|
||||||
|
)
|
||||||
|
|
||||||
self.round_off_base_values(tax)
|
self.round_off_base_values(tax)
|
||||||
self.set_cumulative_total(i, tax)
|
self.set_cumulative_total(i, tax)
|
||||||
@@ -462,9 +469,10 @@ class calculate_taxes_and_totals:
|
|||||||
else:
|
else:
|
||||||
tax.total = flt(self.doc.get("taxes")[row_idx - 1].total + tax_amount, tax.precision("total"))
|
tax.total = flt(self.doc.get("taxes")[row_idx - 1].total + tax_amount, tax.precision("total"))
|
||||||
|
|
||||||
def get_current_tax_amount(self, item, tax, item_tax_map):
|
def get_current_tax_and_net_amount(self, item, tax, item_tax_map):
|
||||||
tax_rate = self._get_tax_rate(tax, item_tax_map)
|
tax_rate = self._get_tax_rate(tax, item_tax_map)
|
||||||
current_tax_amount = 0.0
|
current_tax_amount = 0.0
|
||||||
|
current_net_amount = 0.0
|
||||||
|
|
||||||
if tax.charge_type == "Actual":
|
if tax.charge_type == "Actual":
|
||||||
# distribute the tax amount proportionally to each item row
|
# distribute the tax amount proportionally to each item row
|
||||||
@@ -473,48 +481,59 @@ class calculate_taxes_and_totals:
|
|||||||
if tax.get("is_tax_withholding_account") and item.meta.get_field("apply_tds"):
|
if tax.get("is_tax_withholding_account") and item.meta.get_field("apply_tds"):
|
||||||
if not item.get("apply_tds") or not self.doc.tax_withholding_net_total:
|
if not item.get("apply_tds") or not self.doc.tax_withholding_net_total:
|
||||||
current_tax_amount = 0.0
|
current_tax_amount = 0.0
|
||||||
|
current_net_amount = 0.0
|
||||||
else:
|
else:
|
||||||
current_tax_amount = item.net_amount * actual / self.doc.tax_withholding_net_total
|
current_net_amount = item.net_amount
|
||||||
|
current_tax_amount = current_net_amount * actual / self.doc.tax_withholding_net_total
|
||||||
else:
|
else:
|
||||||
|
current_net_amount = item.net_amount
|
||||||
current_tax_amount = (
|
current_tax_amount = (
|
||||||
item.net_amount * actual / self.doc.net_total if self.doc.net_total else 0.0
|
current_net_amount * actual / self.doc.net_total if self.doc.net_total else 0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
elif tax.charge_type == "On Net Total":
|
elif tax.charge_type == "On Net Total":
|
||||||
current_tax_amount = (tax_rate / 100.0) * item.net_amount
|
current_net_amount = item.net_amount
|
||||||
|
current_tax_amount = (tax_rate / 100.0) * current_net_amount
|
||||||
elif tax.charge_type == "On Previous Row Amount":
|
elif tax.charge_type == "On Previous Row Amount":
|
||||||
current_tax_amount = (tax_rate / 100.0) * self.doc.get("taxes")[
|
current_net_amount = self.doc.get("taxes")[cint(tax.row_id) - 1].tax_amount_for_current_item
|
||||||
cint(tax.row_id) - 1
|
current_tax_amount = (tax_rate / 100.0) * current_net_amount
|
||||||
].tax_amount_for_current_item
|
|
||||||
elif tax.charge_type == "On Previous Row Total":
|
elif tax.charge_type == "On Previous Row Total":
|
||||||
current_tax_amount = (tax_rate / 100.0) * self.doc.get("taxes")[
|
current_net_amount = self.doc.get("taxes")[cint(tax.row_id) - 1].grand_total_for_current_item
|
||||||
cint(tax.row_id) - 1
|
current_tax_amount = (tax_rate / 100.0) * current_net_amount
|
||||||
].grand_total_for_current_item
|
|
||||||
elif tax.charge_type == "On Item Quantity":
|
elif tax.charge_type == "On Item Quantity":
|
||||||
|
# don't sum current net amount due to the field being a currency field
|
||||||
current_tax_amount = tax_rate * item.qty
|
current_tax_amount = tax_rate * item.qty
|
||||||
|
|
||||||
if not (self.doc.get("is_consolidated") or tax.get("dont_recompute_tax")):
|
if not (self.doc.get("is_consolidated") or tax.get("dont_recompute_tax")):
|
||||||
self.set_item_wise_tax(item, tax, tax_rate, current_tax_amount)
|
self.set_item_wise_tax(item, tax, tax_rate, current_tax_amount, current_net_amount)
|
||||||
|
|
||||||
return current_tax_amount
|
return current_net_amount, current_tax_amount
|
||||||
|
|
||||||
def set_item_wise_tax(self, item, tax, tax_rate, current_tax_amount):
|
def set_item_wise_tax(self, item, tax, tax_rate, current_tax_amount, current_net_amount):
|
||||||
# store tax breakup for each item
|
# store tax breakup for each item
|
||||||
key = item.item_code or item.item_name
|
key = item.item_code or item.item_name
|
||||||
item_wise_tax_amount = current_tax_amount * self.doc.conversion_rate
|
item_wise_tax_amount = current_tax_amount * self.doc.conversion_rate
|
||||||
|
if tax.charge_type != "On Item Quantity":
|
||||||
|
item_wise_net_amount = current_net_amount * self.doc.conversion_rate
|
||||||
|
else:
|
||||||
|
item_wise_net_amount = 0.0
|
||||||
if frappe.flags.round_row_wise_tax:
|
if frappe.flags.round_row_wise_tax:
|
||||||
item_wise_tax_amount = flt(item_wise_tax_amount, tax.precision("tax_amount"))
|
item_wise_tax_amount = flt(item_wise_tax_amount, tax.precision("tax_amount"))
|
||||||
|
item_wise_net_amount = flt(item_wise_net_amount, tax.precision("net_amount"))
|
||||||
if tax.item_wise_tax_detail.get(key):
|
if tax.item_wise_tax_detail.get(key):
|
||||||
item_wise_tax_amount += flt(tax.item_wise_tax_detail[key][1], tax.precision("tax_amount"))
|
item_wise_tax_amount += flt(tax.item_wise_tax_detail[key][1], tax.precision("tax_amount"))
|
||||||
|
item_wise_net_amount += flt(tax.item_wise_tax_detail[key][2], tax.precision("net_amount"))
|
||||||
tax.item_wise_tax_detail[key] = [
|
tax.item_wise_tax_detail[key] = [
|
||||||
tax_rate,
|
tax_rate,
|
||||||
flt(item_wise_tax_amount, tax.precision("tax_amount")),
|
flt(item_wise_tax_amount, tax.precision("tax_amount")),
|
||||||
|
flt(item_wise_net_amount, tax.precision("net_amount")),
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
if tax.item_wise_tax_detail.get(key):
|
if tax.item_wise_tax_detail.get(key):
|
||||||
item_wise_tax_amount += tax.item_wise_tax_detail[key][1]
|
item_wise_tax_amount += tax.item_wise_tax_detail[key][1]
|
||||||
|
item_wise_net_amount += tax.item_wise_tax_detail[key][2]
|
||||||
|
|
||||||
tax.item_wise_tax_detail[key] = [tax_rate, item_wise_tax_amount]
|
tax.item_wise_tax_detail[key] = [tax_rate, item_wise_tax_amount, item_wise_net_amount]
|
||||||
|
|
||||||
def round_off_totals(self, tax):
|
def round_off_totals(self, tax):
|
||||||
if tax.account_head in frappe.flags.round_off_applicable_accounts:
|
if tax.account_head in frappe.flags.round_off_applicable_accounts:
|
||||||
@@ -522,6 +541,7 @@ class calculate_taxes_and_totals:
|
|||||||
tax.tax_amount_after_discount_amount = round(tax.tax_amount_after_discount_amount, 0)
|
tax.tax_amount_after_discount_amount = round(tax.tax_amount_after_discount_amount, 0)
|
||||||
|
|
||||||
tax.tax_amount = flt(tax.tax_amount, tax.precision("tax_amount"))
|
tax.tax_amount = flt(tax.tax_amount, tax.precision("tax_amount"))
|
||||||
|
tax.net_amount = flt(tax.net_amount, tax.precision("net_amount"))
|
||||||
tax.tax_amount_after_discount_amount = flt(
|
tax.tax_amount_after_discount_amount = flt(
|
||||||
tax.tax_amount_after_discount_amount, tax.precision("tax_amount")
|
tax.tax_amount_after_discount_amount, tax.precision("tax_amount")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -461,16 +461,20 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
if(tax.charge_type == "Actual") {
|
if(tax.charge_type == "Actual") {
|
||||||
// distribute the tax amount proportionally to each item row
|
// distribute the tax amount proportionally to each item row
|
||||||
var actual = flt(tax.tax_amount, precision("tax_amount", tax));
|
var actual = flt(tax.tax_amount, precision("tax_amount", tax));
|
||||||
|
current_net_amount = item.net_amount
|
||||||
current_tax_amount = this.frm.doc.net_total ?
|
current_tax_amount = this.frm.doc.net_total ?
|
||||||
((item.net_amount / this.frm.doc.net_total) * actual) : 0.0;
|
((item.net_amount / this.frm.doc.net_total) * actual) : 0.0;
|
||||||
|
|
||||||
} else if(tax.charge_type == "On Net Total") {
|
} else if(tax.charge_type == "On Net Total") {
|
||||||
|
current_net_amount = item.net_amount
|
||||||
current_tax_amount = (tax_rate / 100.0) * item.net_amount;
|
current_tax_amount = (tax_rate / 100.0) * item.net_amount;
|
||||||
} else if(tax.charge_type == "On Previous Row Amount") {
|
} else if(tax.charge_type == "On Previous Row Amount") {
|
||||||
|
current_net_amount = this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount_for_current_item
|
||||||
current_tax_amount = (tax_rate / 100.0) *
|
current_tax_amount = (tax_rate / 100.0) *
|
||||||
this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount_for_current_item;
|
this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount_for_current_item;
|
||||||
|
|
||||||
} else if(tax.charge_type == "On Previous Row Total") {
|
} else if(tax.charge_type == "On Previous Row Total") {
|
||||||
|
current_net_amount = this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item
|
||||||
current_tax_amount = (tax_rate / 100.0) *
|
current_tax_amount = (tax_rate / 100.0) *
|
||||||
this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item;
|
this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item;
|
||||||
} else if (tax.charge_type == "On Item Quantity") {
|
} else if (tax.charge_type == "On Item Quantity") {
|
||||||
@@ -478,13 +482,13 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!tax.dont_recompute_tax) {
|
if (!tax.dont_recompute_tax) {
|
||||||
this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount);
|
this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount, current_net_amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return current_tax_amount;
|
return current_tax_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_item_wise_tax(item, tax, tax_rate, current_tax_amount) {
|
set_item_wise_tax(item, tax, tax_rate, current_tax_amount, current_net_amount) {
|
||||||
// store tax breakup for each item
|
// store tax breakup for each item
|
||||||
let tax_detail = tax.item_wise_tax_detail;
|
let tax_detail = tax.item_wise_tax_detail;
|
||||||
let key = item.item_code || item.item_name;
|
let key = item.item_code || item.item_name;
|
||||||
@@ -495,17 +499,20 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate;
|
let item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate;
|
||||||
|
let item_wise_net_amount = current_net_amount * this.frm.doc.conversion_rate;
|
||||||
if (frappe.flags.round_row_wise_tax) {
|
if (frappe.flags.round_row_wise_tax) {
|
||||||
item_wise_tax_amount = flt(item_wise_tax_amount, precision("tax_amount", tax));
|
item_wise_tax_amount = flt(item_wise_tax_amount, precision("tax_amount", tax));
|
||||||
|
item_wise_net_amount = flt(item_wise_net_amount, precision("net_amount", tax));
|
||||||
if (tax_detail && tax_detail[key]) {
|
if (tax_detail && tax_detail[key]) {
|
||||||
item_wise_tax_amount += flt(tax_detail[key][1], precision("tax_amount", tax));
|
item_wise_tax_amount += flt(tax_detail[key][1], precision("tax_amount", tax));
|
||||||
|
item_wise_net_amount += flt(tax_detail[key][2], precision("net_amount", tax));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tax_detail && tax_detail[key])
|
if (tax_detail && tax_detail[key])
|
||||||
item_wise_tax_amount += tax_detail[key][1];
|
item_wise_tax_amount += tax_detail[key][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
tax_detail[key] = [tax_rate, flt(item_wise_tax_amount, precision("base_tax_amount", tax))];
|
tax_detail[key] = [tax_rate, flt(item_wise_tax_amount, precision("base_tax_amount", tax)), flt(item_wise_net_amount, precision("base_net_amount", tax))];
|
||||||
}
|
}
|
||||||
|
|
||||||
round_off_totals(tax) {
|
round_off_totals(tax) {
|
||||||
|
|||||||
Reference in New Issue
Block a user