Taxes in email
Posted: Wed Aug 05, 2009 10:34 pm
Hi,
I'm trying to display Canadian taxes on my email invoice. All 3 taxes, PST,GST & HST. Whoever buys from which province, that province's taxation rules applys.
I managed to do it on the screen and printable version because I modify OrderTotalSummary.ascx.cs to look lile this.
protected void Page_Init(object sender, EventArgs e)
{
_OrderId = AlwaysConvert.ToInt(Request.QueryString["OrderId"]);
_Order = OrderDataSource.Load(_OrderId);
LSDecimal subtotal = 0;
LSDecimal shipping = 0;
LSDecimal taxes = 0;
LSDecimal taxesPST = 0;
LSDecimal taxesGST = 0;
LSDecimal taxesHST = 0;
LSDecimal coupons = 0;
LSDecimal total = 0;
LSDecimal giftwrap = 0;
LSDecimal adjustments = 0;
foreach (OrderItem item in _Order.Items)
{
LSDecimal extendedPrice = item.ExtendedPrice;
switch (item.OrderItemType)
{
case OrderItemType.Shipping:
case OrderItemType.Handling:
shipping += extendedPrice;
break;
case OrderItemType.Tax:
// taxes += extendedPrice;
if (item.Name == "PST") {
taxesPST += extendedPrice;
}
if (item.Name == "GST") {
taxesGST += extendedPrice;
}
if (item.Name == "HST") {
taxesHST += extendedPrice;
}
break;
case OrderItemType.Coupon:
coupons += extendedPrice;
break;
case OrderItemType.GiftWrap:
giftwrap += extendedPrice;
break;
case OrderItemType.Charge:
case OrderItemType.Credit:
adjustments += extendedPrice;
break;
default:
subtotal += extendedPrice;
break;
}
total += item.ExtendedPrice;
}
Subtotal.Text = subtotal.ToString("ulc");
Shipping.Text = shipping.ToString("ulc");
// Taxes.Text = taxes.ToString("ulc");
TaxesPST.Text = taxesPST.ToString("ulc");
TaxesGST.Text = taxesGST.ToString("ulc");
TaxesHST.Text = taxesHST.ToString("ulc");
Total.Text = total.ToString("ulc");
if (giftwrap != 0)
{
trGiftWrap.Visible = true;
GiftWrap.Text = giftwrap.ToString("ulc");
}
else trGiftWrap.Visible = false;
if (coupons != 0)
{
trCoupon.Visible = true;
Coupons.Text = coupons.ToString("ulc");
}
else trCoupon.Visible = false;
if (adjustments != 0)
{
trAdjustments.Visible = true;
Adjustments.Text = adjustments.ToString("ulc");
}
else trAdjustments.Visible = false;
}
The resultant display on the screen invoice looks like this: (e.g. the billing address is from BC)
PAYMENT INFORMATION
Order Summary
Item Subtotal: CAD $40.00
Shipping: CAD $12.39
PST: CAD $2.80
GST: CAD $2.00
HST: CAD $0.00
--------------------------------------------------------------------------------
Total: CAD $57.19
However, I had a hard time doing the same with the email version because nvelocity dynamic variables cannot do decimal maths. I have to sum up in group all 3 different taxes applicable to one line item and there are more than one line items per invoice. nvelocity would not add decimal number.
Google on the net does not give me a satisfactory answer with nvelocity solution.
Does anybody has any idea how best to approach this problem? If there is a cs file I can modify like the above, which one can I change?
Many thanks,
Joe
I'm trying to display Canadian taxes on my email invoice. All 3 taxes, PST,GST & HST. Whoever buys from which province, that province's taxation rules applys.
I managed to do it on the screen and printable version because I modify OrderTotalSummary.ascx.cs to look lile this.
protected void Page_Init(object sender, EventArgs e)
{
_OrderId = AlwaysConvert.ToInt(Request.QueryString["OrderId"]);
_Order = OrderDataSource.Load(_OrderId);
LSDecimal subtotal = 0;
LSDecimal shipping = 0;
LSDecimal taxes = 0;
LSDecimal taxesPST = 0;
LSDecimal taxesGST = 0;
LSDecimal taxesHST = 0;
LSDecimal coupons = 0;
LSDecimal total = 0;
LSDecimal giftwrap = 0;
LSDecimal adjustments = 0;
foreach (OrderItem item in _Order.Items)
{
LSDecimal extendedPrice = item.ExtendedPrice;
switch (item.OrderItemType)
{
case OrderItemType.Shipping:
case OrderItemType.Handling:
shipping += extendedPrice;
break;
case OrderItemType.Tax:
// taxes += extendedPrice;
if (item.Name == "PST") {
taxesPST += extendedPrice;
}
if (item.Name == "GST") {
taxesGST += extendedPrice;
}
if (item.Name == "HST") {
taxesHST += extendedPrice;
}
break;
case OrderItemType.Coupon:
coupons += extendedPrice;
break;
case OrderItemType.GiftWrap:
giftwrap += extendedPrice;
break;
case OrderItemType.Charge:
case OrderItemType.Credit:
adjustments += extendedPrice;
break;
default:
subtotal += extendedPrice;
break;
}
total += item.ExtendedPrice;
}
Subtotal.Text = subtotal.ToString("ulc");
Shipping.Text = shipping.ToString("ulc");
// Taxes.Text = taxes.ToString("ulc");
TaxesPST.Text = taxesPST.ToString("ulc");
TaxesGST.Text = taxesGST.ToString("ulc");
TaxesHST.Text = taxesHST.ToString("ulc");
Total.Text = total.ToString("ulc");
if (giftwrap != 0)
{
trGiftWrap.Visible = true;
GiftWrap.Text = giftwrap.ToString("ulc");
}
else trGiftWrap.Visible = false;
if (coupons != 0)
{
trCoupon.Visible = true;
Coupons.Text = coupons.ToString("ulc");
}
else trCoupon.Visible = false;
if (adjustments != 0)
{
trAdjustments.Visible = true;
Adjustments.Text = adjustments.ToString("ulc");
}
else trAdjustments.Visible = false;
}
The resultant display on the screen invoice looks like this: (e.g. the billing address is from BC)
PAYMENT INFORMATION
Order Summary
Item Subtotal: CAD $40.00
Shipping: CAD $12.39
PST: CAD $2.80
GST: CAD $2.00
HST: CAD $0.00
--------------------------------------------------------------------------------
Total: CAD $57.19
However, I had a hard time doing the same with the email version because nvelocity dynamic variables cannot do decimal maths. I have to sum up in group all 3 different taxes applicable to one line item and there are more than one line items per invoice. nvelocity would not add decimal number.
Google on the net does not give me a satisfactory answer with nvelocity solution.
Does anybody has any idea how best to approach this problem? If there is a cs file I can modify like the above, which one can I change?
Many thanks,
Joe