mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-16 16:08:39 +00:00
chore: resolve conflicts
This commit is contained in:
@@ -323,12 +323,7 @@ class calculate_taxes_and_totals:
|
||||
if not self.discount_amount_applied and item.qty and (total_tax_slope or total_tax_intercept):
|
||||
amount = flt(item.amount) - total_tax_intercept
|
||||
|
||||
<<<<<<< HEAD
|
||||
item.net_amount = flt(amount / (1 + cumulated_tax_fraction), item.precision("net_amount"))
|
||||
=======
|
||||
item._unrounded_net_amount = amount / (1 + total_tax_slope)
|
||||
item.net_amount = flt(item._unrounded_net_amount, item.precision("net_amount"))
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
item.net_amount = flt(amount / (1 + total_tax_slope), item.precision("net_amount"))
|
||||
item.net_rate = flt(item.net_amount / item.qty, item.precision("net_rate"))
|
||||
item.discount_percentage = flt(
|
||||
item.discount_percentage, item.precision("discount_percentage")
|
||||
@@ -350,12 +345,6 @@ class calculate_taxes_and_totals:
|
||||
if cint(tax.included_in_print_rate):
|
||||
tax_rate = self._get_tax_rate(tax, item_tax_map)
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
if tax_rate == NOT_APPLICABLE_TAX:
|
||||
return tax_slope, tax_intercept
|
||||
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
if tax.charge_type == "On Net Total":
|
||||
tax_slope = tax_rate / 100.0
|
||||
|
||||
@@ -546,21 +535,7 @@ class calculate_taxes_and_totals:
|
||||
)
|
||||
|
||||
elif tax.charge_type == "On Net Total":
|
||||
<<<<<<< HEAD
|
||||
current_tax_amount = (tax_rate / 100.0) * item.net_amount
|
||||
=======
|
||||
if tax.account_head in item_tax_map:
|
||||
current_net_amount = item.net_amount
|
||||
# Use unrounded net for inclusive taxes to avoid double rounding
|
||||
if (
|
||||
cint(tax.included_in_print_rate)
|
||||
and not self.discount_amount_applied
|
||||
and item._unrounded_net_amount is not None
|
||||
):
|
||||
current_tax_amount = (tax_rate / 100.0) * item._unrounded_net_amount
|
||||
else:
|
||||
current_tax_amount = (tax_rate / 100.0) * item.net_amount
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
elif tax.charge_type == "On Previous Row Amount":
|
||||
current_tax_amount = (tax_rate / 100.0) * self.doc.get("taxes")[
|
||||
cint(tax.row_id) - 1
|
||||
@@ -573,18 +548,13 @@ class calculate_taxes_and_totals:
|
||||
current_tax_amount = tax_rate * item.qty
|
||||
else:
|
||||
# Custom charge_type: rate applies to the resolver-provided base.
|
||||
base = self.get_item_taxable_base(item, tax)
|
||||
current_net_amount = base
|
||||
current_tax_amount = (tax_rate / 100.0) * base
|
||||
current_tax_amount = (tax_rate / 100.0) * self.get_item_taxable_base(item, 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)
|
||||
|
||||
return current_tax_amount
|
||||
|
||||
<<<<<<< HEAD
|
||||
def set_item_wise_tax(self, item, tax, tax_rate, current_tax_amount):
|
||||
=======
|
||||
def get_item_taxable_base(self, item, tax):
|
||||
"""Per-item base a custom charge_type's rate is applied to.
|
||||
|
||||
@@ -614,8 +584,7 @@ class calculate_taxes_and_totals:
|
||||
# fallback
|
||||
return flt(item.net_amount)
|
||||
|
||||
def set_item_wise_tax(self, item, tax, tax_rate, current_tax_amount, current_net_amount):
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
def set_item_wise_tax(self, item, tax, tax_rate, current_tax_amount):
|
||||
# store tax breakup for each item
|
||||
key = item.item_code or item.item_name
|
||||
item_wise_tax_amount = current_tax_amount * self.doc.conversion_rate
|
||||
|
||||
@@ -2,19 +2,13 @@ from unittest import mock
|
||||
from unittest.mock import patch
|
||||
|
||||
import frappe
|
||||
<<<<<<< HEAD
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
=======
|
||||
from frappe.utils import flt
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
|
||||
from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
class TestTaxesAndTotals(FrappeTestCase):
|
||||
=======
|
||||
def resolve_on_gross(calc, item, tax):
|
||||
# base = gross printed line amount
|
||||
return flt(item.amount)
|
||||
@@ -25,8 +19,7 @@ def resolve_on_mrp(calc, item, tax):
|
||||
return flt(item.price_list_rate) * flt(item.qty)
|
||||
|
||||
|
||||
class TestTaxesAndTotals(ERPNextTestSuite):
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
class TestTaxesAndTotals(FrappeTestCase):
|
||||
def test_regional_round_off_accounts(self):
|
||||
"""
|
||||
Regional overrides cannot extend the list in-place — the return
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
const NOT_APPLICABLE_TAX = "N/A";
|
||||
|
||||
// Per-charge_type base resolvers, mirror of the `erpnext_taxable_base_resolvers`
|
||||
// server hook. A localization registers `fn(calc, item, tax)` returning the per-item
|
||||
// base, so the client preview matches the server for custom charge types.
|
||||
erpnext.taxable_base_resolvers = erpnext.taxable_base_resolvers || {};
|
||||
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
setup() {
|
||||
this.fetch_round_off_accounts();
|
||||
@@ -262,22 +257,13 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
|
||||
$.each(this.frm.doc.items || [], function(n, item) {
|
||||
var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
|
||||
<<<<<<< HEAD
|
||||
var cumulated_tax_fraction = 0.0;
|
||||
var total_inclusive_tax_amount_per_qty = 0;
|
||||
$.each(me.frm.doc["taxes"] || [], function(i, tax) {
|
||||
var current_tax_fraction = me.get_current_tax_fraction(tax, item_tax_map);
|
||||
tax.tax_fraction_for_current_item = current_tax_fraction[0];
|
||||
var inclusive_tax_amount_per_qty = current_tax_fraction[1];
|
||||
=======
|
||||
var total_tax_slope = 0.0;
|
||||
var total_tax_intercept = 0;
|
||||
$.each(me.frm.doc["taxes"] || [], function (i, tax) {
|
||||
$.each(me.frm.doc["taxes"] || [], function(i, tax) {
|
||||
var tax_contribution = me.get_current_tax_fraction(tax, item_tax_map, item);
|
||||
tax.tax_fraction_for_current_item = tax_contribution[0];
|
||||
var tax_intercept_per_qty = tax_contribution[1];
|
||||
tax.inclusive_amount_per_qty = tax_intercept_per_qty;
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
|
||||
if(i==0) {
|
||||
tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item;
|
||||
@@ -285,30 +271,19 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
} else {
|
||||
var prev = me.frm.doc["taxes"][i - 1];
|
||||
tax.grand_total_fraction_for_current_item =
|
||||
<<<<<<< HEAD
|
||||
me.frm.doc["taxes"][i-1].grand_total_fraction_for_current_item +
|
||||
prev.grand_total_fraction_for_current_item +
|
||||
tax.tax_fraction_for_current_item;
|
||||
=======
|
||||
prev.grand_total_fraction_for_current_item + tax.tax_fraction_for_current_item;
|
||||
tax.grand_total_amount_per_qty =
|
||||
flt(prev.grand_total_amount_per_qty) + tax_intercept_per_qty;
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
}
|
||||
|
||||
total_tax_slope += tax.tax_fraction_for_current_item;
|
||||
total_tax_intercept += tax_intercept_per_qty * flt(item.qty);
|
||||
});
|
||||
|
||||
<<<<<<< HEAD
|
||||
if(!me.discount_amount_applied && item.qty && (total_inclusive_tax_amount_per_qty || cumulated_tax_fraction)) {
|
||||
var amount = flt(item.amount) - total_inclusive_tax_amount_per_qty;
|
||||
item.net_amount = flt(amount / (1 + cumulated_tax_fraction), precision("net_amount", item));
|
||||
=======
|
||||
if (!me.discount_amount_applied && item.qty && (total_tax_intercept || total_tax_slope)) {
|
||||
if(!me.discount_amount_applied && item.qty && (total_tax_intercept || total_tax_slope)) {
|
||||
var amount = flt(item.amount) - total_tax_intercept;
|
||||
item._unrounded_net_amount = amount / (1 + total_tax_slope);
|
||||
item.net_amount = flt(item._unrounded_net_amount, precision("net_amount", item));
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
item.net_amount = flt(amount / (1 + total_tax_slope), precision("net_amount", item));
|
||||
item.net_rate = item.qty ? flt(item.net_amount / item.qty, precision("net_rate", item)) : 0;
|
||||
|
||||
me.set_in_company_currency(item, ["net_rate", "net_amount"]);
|
||||
@@ -325,33 +300,18 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
if(cint(tax.included_in_print_rate)) {
|
||||
var tax_rate = this._get_tax_rate(tax, item_tax_map);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if(tax.charge_type == "On Net Total") {
|
||||
current_tax_fraction = (tax_rate / 100.0);
|
||||
tax_slope = (tax_rate / 100.0);
|
||||
|
||||
} else if(tax.charge_type == "On Previous Row Amount") {
|
||||
current_tax_fraction = (tax_rate / 100.0) *
|
||||
this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_fraction_for_current_item;
|
||||
|
||||
} else if(tax.charge_type == "On Previous Row Total") {
|
||||
current_tax_fraction = (tax_rate / 100.0) *
|
||||
this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_fraction_for_current_item;
|
||||
=======
|
||||
if (tax_rate === NOT_APPLICABLE_TAX) {
|
||||
return [tax_slope, tax_intercept];
|
||||
}
|
||||
|
||||
if (tax.charge_type == "On Net Total") {
|
||||
tax_slope = tax_rate / 100.0;
|
||||
} else if (tax.charge_type == "On Previous Row Amount") {
|
||||
const row = this.frm.doc["taxes"][cint(tax.row_id) - 1];
|
||||
tax_slope = (tax_rate / 100.0) * row.tax_fraction_for_current_item;
|
||||
tax_intercept = (tax_rate / 100.0) * flt(row.inclusive_amount_per_qty);
|
||||
} else if (tax.charge_type == "On Previous Row Total") {
|
||||
|
||||
} else if(tax.charge_type == "On Previous Row Total") {
|
||||
const row = this.frm.doc["taxes"][cint(tax.row_id) - 1];
|
||||
tax_slope = (tax_rate / 100.0) * row.grand_total_fraction_for_current_item;
|
||||
tax_intercept = (tax_rate / 100.0) * flt(row.grand_total_amount_per_qty);
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
} else if (tax.charge_type == "On Item Quantity") {
|
||||
tax_intercept = flt(tax_rate);
|
||||
} else {
|
||||
@@ -363,15 +323,9 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
if(tax.add_deduct_tax && tax.add_deduct_tax == "Deduct") {
|
||||
current_tax_fraction *= -1;
|
||||
inclusive_tax_amount_per_qty *= -1;
|
||||
=======
|
||||
if (tax.add_deduct_tax && tax.add_deduct_tax == "Deduct") {
|
||||
tax_slope *= -1;
|
||||
tax_intercept *= -1;
|
||||
>>>>>>> 986cea2331 (feat: taxable-base resolver hook for custom charge types (#56175))
|
||||
}
|
||||
return [tax_slope, tax_intercept];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user