My store is pretty simple and I run it without Quick Books, etc. Is there a way to see the previous quarter's orders that have collected sales tax (for govm't reporting)?
Failing that, is there a note that can be added to the order that can be searched for so they all show up in a list in the admin?
Can I poll for orders with Sales Tax?
Re: Can I poll for orders with Sales Tax?
I use something similar to this.
Hope it helps.
Scott
Code: Select all
<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" Inherits="CommerceBuilder.Web.UI.AbleCommerceAdminPage" Title="Sales With Tax" %>
<%@ Register Src="~/Admin/UserControls/PickerAndCalendar.ascx" TagName="PickerAndCalendar" TagPrefix="uc1" %>
<%@ Register Assembly="CommerceBuilder.Web" Namespace="CommerceBuilder.Web.UI.WebControls" TagPrefix="cb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BreadCrumbsPanel" runat="Server">
</asp:Content>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ProcessButton_Click(object sender, EventArgs e)
{
BindGrid();
}
protected void BindGrid()
{
int count = 0;
LSDecimal ProductTotal = 0;
LSDecimal TaxTotal = 0;
DataTable dt = new DataTable();
dt.Columns.Add("OrderId", typeof(String));
dt.Columns.Add("OrderNumber", typeof(String));
dt.Columns.Add("ProductSubTotal", typeof(LSDecimal));
dt.Columns.Add("Tax", typeof(LSDecimal));
dt.Columns.Add("Status", typeof(String));
List<int> pc = new List<int>();
DateTime fromDate = PickerAndCalendar1.SelectedDate;
DateTime toDate = PickerAndCalendar2.SelectedDate.AddDays(1);
OrderCollection oc = OrderDataSource.LoadForCriteria("OrderDate > '" + fromDate + "' AND OrderDate < '" + toDate + "'");
foreach (Order o in oc)
{
LSDecimal tax = GetTax(o);
if (tax > 0 && o.OrderStatusId != 4 && o.OrderStatusId != 5)
{
dt.Rows.Add(new object [] {o.OrderId.ToString() , o.OrderNumber.ToString(), o.ProductSubtotal, tax});
count ++;
ProductTotal += o.ProductSubtotal;
TaxTotal += tax;
}
}
dt.Rows.Add(new object [] { "ALL ORDERS", "ALL ORDERS", ProductTotal, TaxTotal});
ProductBreakdownGrid.DataSource = dt;
ProductBreakdownGrid.DataBind();
}
public void DoSort(object sender, GridViewSortEventArgs e)
{
e.SortDirection = SortDirection.Ascending;
this.BindGrid();
}
protected LSDecimal GetTax(Order o)
{
LSDecimal tax = 0;
foreach (OrderItem oi in o.Items)
{
if (oi.OrderItemType.Equals(OrderItemType.Tax))
tax += oi.Price;
}
return tax;
}
protected String GetOrderUrl(string _OrderId)
{
return Token.Instance.Store.StoreUrl + "Admin/Orders/ViewOrder.aspx?OrderId=" + _OrderId;
}
</script>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<ajax:UpdatePanel ID="ReportAjax" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="pageHeader">
<div class="caption">
<h1>
<asp:Localize ID="Caption" runat="server" Text="Sales with Tax"></asp:Localize><asp:Localize
ID="ReportCaption" runat="server" Visible="false" EnableViewState="false"></asp:Localize>
</h1>
</div>
</div>
<table align="center" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<th class="sectionHeader" colspan="4">
<div style="text-align: left">
Report Period</div>
</th>
</tr>
<tr>
<td>
<div style="text-align: right; vertical-align: middle">
<asp:Label ID="Label1" runat="server" Text="From: " SkinID="FieldHeader"></asp:Label>
</div>
</td>
<td style="text-align: left">
<uc1:PickerAndCalendar ID="PickerAndCalendar1" runat="server" />
</td>
<td>
<div style="text-align: right; vertical-align: middle">
<asp:Label ID="Label4" runat="server" Text="To: " SkinID="FieldHeader"></asp:Label>
</div>
</td>
<td style="text-align: left">
<uc1:PickerAndCalendar ID="PickerAndCalendar2" runat="server" />
</td>
</tr>
<tr>
<td colspan="4">
<div style="text-align: center; vertical-align: middle">
<asp:Button ID="ProcessButton" runat="server" Text="GO.." OnClick="ProcessButton_Click" />
</div>
</td>
</tr>
<tr>
<td class="dataSheet" colspan="4" style="text-align:center">
<asp:GridView ID="ProductBreakdownGrid" runat="server" AutoGenerateColumns="False"
Width="30%" SkinID="PagedList" AllowSorting="true" OnSorting="DoSort">
<Columns>
<asp:TemplateField HeaderText="OrderId">
<HeaderStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:HyperLink ID="OrderIdLabel" runat="server" Target="_blank" NavigateUrl='<%# GetOrderUrl((string)Eval("OrderId")) %>' Text='<%# Eval("OrderNumber") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Sales">
<HeaderStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="ProductSalesLabel" runat="server" Text='<%# string.Format("{0:lc}",Eval("ProductSubTotal")) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tax">
<HeaderStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="TaxLabel" runat="server" Text='<%# string.Format("{0:lc}", Eval("Tax")) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div class="emptyResult">
<asp:Label ID="EmptyResultsMessage" runat="server" Text="There are no products to report for the selected dates."></asp:Label>
</div>
</EmptyDataTemplate>
</asp:GridView>
<br />
<asp:Label ID="EmptyText" runat="server"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</ajax:UpdatePanel>
</asp:Content>
Scott