Thank you, this was a great help for me.
Kind Regards,
Ludo
These are the changes in case someone is interested:
NopCommerceStore\Modules\OrderTotals.ascx.cs
BindData()
…
// **LV**100329**START
// Take into account a possible Order % Discount when calculating the Tax.
// decimal shoppingCartTaxBase = TaxManager.GetTaxTotal(Cart, paymentMethodID, NopContext.Current.User, ref TaxError);
decimal shoppingCartTaxBase = TaxManager.GetTaxTotal(Cart, paymentMethodID, NopContext.Current.User, ref TaxError, appliedDiscount);
// **LV**100329**END
…
Libraries\Nop.BusinessLogic\Tax\TaxManager.cs
using NopSolutions.NopCommerce.BusinessLogic.Promo.Discounts; // **LV**100329
// **LV**100329**START
//public static decimal GetTaxTotal(ShoppingCart Cart, Customer customer, ref string Error)
public static decimal GetTaxTotal(ShoppingCart Cart, Customer customer, ref string Error, Discount orderDiscount)
// **LV**100329**END
{
// **LV**100329**START
// return GetTaxTotal(Cart, 0, customer, ref Error);
return GetTaxTotal(Cart, 0, customer, ref Error, orderDiscount);
// **LV**100329**END
}
// **LV**100329**START
//public static decimal GetTaxTotal(ShoppingCart Cart, int PaymentMethodID,
// Customer customer, ref string Error)
public static decimal GetTaxTotal(ShoppingCart Cart, int PaymentMethodID,
Customer customer, ref string Error, Discount orderDiscount)
// **LV**100329**END
{
decimal taxTotal = decimal.Zero;
// **LV**100329**START
// Check if there was a % percentage discount for the order.
decimal orderDiscountPercentage;
if (orderDiscount != null && orderDiscount.UsePercentage && orderDiscount.DiscountPercentage > 0)
orderDiscountPercentage = orderDiscount.DiscountPercentage;
else
orderDiscountPercentage = 0;
// **LV**100329**END
//items
decimal itemsTaxTotal = decimal.Zero;
foreach (var shoppingCartItem in Cart)
{
decimal subTotalWithoutDiscountExclTax = decimal.Zero;
decimal subTotalWithoutDiscountInclTax = decimal.Zero;
string Error1 = string.Empty;
string Error2 = string.Empty;
// **LV**100329**START
//subTotalWithoutDiscountExclTax = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, customer, true), false, customer, ref Error1);
//subTotalWithoutDiscountInclTax = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, customer, true), true, customer, ref Error2);
decimal itemPrice = PriceHelper.GetSubTotal(shoppingCartItem, customer, true);
if (orderDiscountPercentage > 0)
itemPrice = itemPrice * ((100 - orderDiscountPercentage) / 100);
subTotalWithoutDiscountExclTax = TaxManager.GetPrice(shoppingCartItem.ProductVariant, itemPrice, false, customer, ref Error1);
subTotalWithoutDiscountInclTax = TaxManager.GetPrice(shoppingCartItem.ProductVariant, itemPrice, true, customer, ref Error2);
// **LV**100329**END
…
Libraries\Nop.BusinessLogic\Orders\OrderManager.cs
public static string PlaceOrder(PaymentInfo paymentInfo, Customer customer,
Guid OrderGuid, out int OrderID)
{
…
//tax total
decimal orderTaxTotal = decimal.Zero;
decimal orderTaxInCustomerCurrency = decimal.Zero;
if (!paymentInfo.IsRecurringPayment)
{
string TaxError = string.Empty;
// **LV**100329**START
// Take into account a possible Order % Discount when calculating the Tax.
//orderTaxTotal = TaxManager.GetTaxTotal(cart, paymentInfo.PaymentMethodID, customer, ref TaxError);
Discount orderDiscount = appliedDiscounts.Count > 0 ? appliedDiscounts[0] : null;
orderTaxTotal = TaxManager.GetTaxTotal(cart, paymentInfo.PaymentMethodID, customer, ref TaxError, orderDiscount);
// **LV**100329**END
if (!String.IsNullOrEmpty(TaxError))
throw new NopException("Tax total couldn't be calculated");
…
Libraries\Nop.BusinessLogic\Orders\ShoppingCartManager.cs
public static decimal? GetShoppingCartTotal(ShoppingCart Cart, int PaymentMethodID, Customer customer)
…
//tax
// **LV**100329**START
// Take into account a possible Order % Discount when calculating the Tax.
// decimal shoppingCartTax = TaxManager.GetTaxTotal(Cart, PaymentMethodID, customer, ref TaxError);
decimal shoppingCartTax = TaxManager.GetTaxTotal(Cart, PaymentMethodID, customer, ref TaxError, appliedDiscount);
// **LV**100329**START
if (!String.IsNullOrEmpty(TaxError))
return null;
…
public static string GetShoppingCartSubTotal(ShoppingCart Cart, Customer customer,
out decimal discountAmount, out Discount appliedDiscount,
out List<AppliedGiftCard> appliedGiftCards, bool includingTax,
out decimal subtotalWithoutPromo, out decimal subtotalWithPromo)
…
#region Discounts
//Discount amount (excl tax)
//We calculate discount amount on subtotal excl tax
//This type of discounts [Assigned to whole order] is not taxable
// **LV**100329**START
// Calculate the Order Discount on the Order Total including the Tax.
if (includingTax) {
discountAmount = GetOrderDiscount(customer, subTotalInclTaxWithoutDiscount, out appliedDiscount);
// If the appliedDiscount is not a percentage then recalc it without tax.
if (appliedDiscount != null && !appliedDiscount.UsePercentage)
discountAmount = GetOrderDiscount(customer, subTotalExclTaxWithoutDiscount, out appliedDiscount);
}
else
// **LV**100329**END
discountAmount = GetOrderDiscount(customer, subTotalExclTaxWithoutDiscount, out appliedDiscount);
//sub totals with discount
decimal subTotalWithDiscount = decimal.Zero;