using uCommerce 3.6.0.13142 and the demo Razor Store 1.0.3.13124
I seem to be having a few issues with balancing order figures on the front end of the cart and preview pages with discounts; essentially I'm having difficulty in recreating the Sub Total and VAT figures pre discounts being applied. They're currently in this format:
Sub Total,
Vat,
Shipping,
Discount,
Total
Without discounts applied, I can easily access the above using the current client's basket / PurchaseOrder object, but with discounts applied, I have to start resorting to manually calculating the above because of how discounts affect the properties contained on the PurchaseOrder object. For example:
The SubTotal property is now discounted - there's no property which exposes the SubTotal before discounts are applied, so I have to work this out manually like so:
var subTotal = new Money(basket.OrderLines.Sum(p => p.Price * p.Quantity), currency);
I can't just take away the discounts from the SubTotal property, as this may includes discounts that apply to shipping.
The Vat is now discounted - there's no property which exposes the Vat before discounts are applied, so I have to work this out manually again, both to grab the VAT inclusive and exclusive of discounts.
var taxExDiscount = new Money(subTotal.Value * vatRate, currency);
var taxIncDiscount = new Money(basket.TaxTotal.Value, currency);
and finally to work out discounts (not including shipping discounts) I do the following:
if (basket.DiscountTotal.HasValue)
{
var shippingDiscount = basket.Shipments.Sum(s => s.ShipmentDiscount ?? 0.00m);
discountTotal = new Money((basket.DiscountTotal.Value - shippingDiscount) * -1, currency);
}
I'm having issues with this approach as well with the various types of discounts (order line and order).
I hope this makes sense; it just seems to be really workman-like and prone to error (being terrible at maths doesn't help!) - unless I'm completely missing something? Any help would be greatly appreciated!
Unfortunately it is pretty complicated to do this when you want to aggregate the before and after prices.
We have made it easy to display list unit prices and discounted unit prices, but haven't seen a lot of need to do this on the totals. Usually the customer just needs to see the grand total, not the total savings.
It might be a candidate for extending the pre-calculated prices available at the order level.
You might find DiscountTotal useful as that contains all the discounts applied to the entire order including shipment level discounts.
Working out prices after discounts
Hi guys
using uCommerce 3.6.0.13142 and the demo Razor Store 1.0.3.13124
I seem to be having a few issues with balancing order figures on the front end of the cart and preview pages with discounts; essentially I'm having difficulty in recreating the Sub Total and VAT figures pre discounts being applied. They're currently in this format:
Sub Total, Vat, Shipping, Discount, Total
Without discounts applied, I can easily access the above using the current client's basket / PurchaseOrder object, but with discounts applied, I have to start resorting to manually calculating the above because of how discounts affect the properties contained on the PurchaseOrder object. For example:
The SubTotal property is now discounted - there's no property which exposes the SubTotal before discounts are applied, so I have to work this out manually like so:
I can't just take away the discounts from the SubTotal property, as this may includes discounts that apply to shipping.
The Vat is now discounted - there's no property which exposes the Vat before discounts are applied, so I have to work this out manually again, both to grab the VAT inclusive and exclusive of discounts.
and finally to work out discounts (not including shipping discounts) I do the following:
I'm having issues with this approach as well with the various types of discounts (order line and order).
I hope this makes sense; it just seems to be really workman-like and prone to error (being terrible at maths doesn't help!) - unless I'm completely missing something? Any help would be greatly appreciated!
Hi Mike,
Unfortunately it is pretty complicated to do this when you want to aggregate the before and after prices.
We have made it easy to display list unit prices and discounted unit prices, but haven't seen a lot of need to do this on the totals. Usually the customer just needs to see the grand total, not the total savings.
It might be a candidate for extending the pre-calculated prices available at the order level.
You might find DiscountTotal useful as that contains all the discounts applied to the entire order including shipment level discounts.
Hope this helps.
is working on a reply...