How to modify Tax Report

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
bigbangtech
Commander (CMDR)
Commander (CMDR)
Posts: 182
Joined: Mon Oct 10, 2005 6:27 pm

How to modify Tax Report

Post by bigbangtech » Thu Dec 10, 2009 1:17 pm

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.
AC7.3

Need A Bulb? - Light bulbs for the building maintenance and construction industries

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to modify Tax Report

Post by mazhar » Fri Dec 11, 2009 7:03 am

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.

bigbangtech
Commander (CMDR)
Commander (CMDR)
Posts: 182
Joined: Mon Oct 10, 2005 6:27 pm

Re: How to modify Tax Report

Post by bigbangtech » Thu Dec 17, 2009 3:14 pm

Thanks, the code worked great. Additionally, we would like to be able to sort the output by the ship to city?
AC7.3

Need A Bulb? - Light bulbs for the building maintenance and construction industries

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to modify Tax Report

Post by mazhar » Fri Dec 18, 2009 2:50 am

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

Post Reply