Page 1 of 1
How to modify Tax Report
Posted: Thu Dec 10, 2009 1:17 pm
by bigbangtech
The TaxDetail.aspx report currently only lists Order#, Date and Amount collected.
To help us calculate sales tax for New York, a few modifications would be helpful.
We need to also display a column for the Shipto City and the Total Order Amount minus the actual collected tax.
After looking at the code for the page, I don't understand how the page works at all in generating this report, new to 7.03 coding.
Re: How to modify Tax Report
Posted: Fri Dec 11, 2009 7:03 am
by mazhar
This will be an easy job. Go to your
Website/Admin/Reports/TaxDetail.aspx and locate following code block
Code: Select all
<asp:TemplateField HeaderText="Total Collected" SortExpression="TaxAmount">
<headerstyle horizontalalign="right" />
<itemstyle horizontalalign="Right" />
<itemtemplate>
<%# Eval("TaxAmount", "{0:lc}") %>
</itemtemplate>
</asp:TemplateField>
and then put following code block just under the above one
Code: Select all
<asp:TemplateField HeaderText="Ship To City">
<headerstyle horizontalalign="Center" />
<itemstyle horizontalalign="Center" />
<itemtemplate>
<%# GetShipToCityList(Container.DataItem)%>
</itemtemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Order Total - Tax Amount" SortExpression="TaxAmount">
<headerstyle horizontalalign="Center" />
<itemstyle horizontalalign="Center" />
<itemtemplate>
<%# DoCustomCalculation(Container.DataItem).ToString("lc")%>
</itemtemplate>
</asp:TemplateField>
save the file. Now edit
Website/Admin/Reports/TaxDetail.aspx.cs file put follwoing code block just above the very last curly brace.
Code: Select all
protected string GetShipToCityList(Object dataItem)
{
TaxReportDetailItem detail = (TaxReportDetailItem)dataItem;
string shipToCityList = string.Empty;
if (detail.Order.Shipments.Count > 0)
{
foreach (OrderShipment shipment in detail.Order.Shipments)
shipToCityList += shipment.ShipToCity+",";
}
if (!String.IsNullOrEmpty(shipToCityList))
shipToCityList = shipToCityList.Remove((shipToCityList.Length - 1), 1);
return shipToCityList;
}
protected LSDecimal DoCustomCalculation(Object dataItem)
{
TaxReportDetailItem detail = (TaxReportDetailItem)dataItem;
LSDecimal value = detail.Order.TotalCharges - detail.TaxAmount;
return value;
}
save this one as well and retest your details report.
Re: How to modify Tax Report
Posted: Thu Dec 17, 2009 3:14 pm
by bigbangtech
Thanks, the code worked great. Additionally, we would like to be able to sort the output by the ship to city?
Re: How to modify Tax Report
Posted: Fri Dec 18, 2009 2:50 am
by mazhar
I don't think so currently there is any simple workaround for sort by shiptocity. For this you need to do some custom comparer like stuff something like this
viewtopic.php?f=42&t=12443&p=53577