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.
How to modify Tax Report
-
- Commander (CMDR)
- Posts: 182
- Joined: Mon Oct 10, 2005 6:27 pm
Re: How to modify Tax Report
This will be an easy job. Go to your Website/Admin/Reports/TaxDetail.aspx and locate following code block
and then put following code block just under the above one
save the file. Now edit Website/Admin/Reports/TaxDetail.aspx.cs file put follwoing code block just above the very last curly brace.
save this one as well and retest your details report.
Code: Select all
<asp:TemplateField HeaderText="Total Collected" SortExpression="TaxAmount">
<headerstyle horizontalalign="right" />
<itemstyle horizontalalign="Right" />
<itemtemplate>
<%# Eval("TaxAmount", "{0:lc}") %>
</itemtemplate>
</asp:TemplateField>
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>
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.
-
- Commander (CMDR)
- Posts: 182
- Joined: Mon Oct 10, 2005 6:27 pm
Re: How to modify Tax Report
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
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
viewtopic.php?f=42&t=12443&p=53577