Skip to content

Commit

Permalink
Merge pull request #97 from ketangarala/Issues/Issue-91
Browse files Browse the repository at this point in the history
Tax Calculation after discount get deducted to resolved issue #91
  • Loading branch information
Will Strohl authored Mar 29, 2018
2 parents 9780463 + 89b9d68 commit 78f8964
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ Desktop.ini
[Ww]ebsite/[Bb]in
[Ww]ebsite/[Bb]in/[Hh]otcakes.*
[Ww]ebsite/[Dd]esktop[Mm]odules/[Hh]otcakes/[Bb]in
[Ww]bsite/[Ii]nstall/[Tt]emp/
[Ww]ebsite/[Ii]nstall/[Tt]emp/
[Ww]ebsite/[Ii]nstall/*/*.zip
[Ww]ebsite/[Ii]nstall/*/*.resources
[Ww]ebsite/[Ii]nstall/[Cc]leanup
[Ww]ebsite/[Ii]nstall/[Cc]onfig
[Ww]ebsite/[Ii]nstall/installstat.log.resources.txt
[Ww]ebsite/[Ii]nstall/upgradestat.log.resources.txt
[Ww]ebsite/[Pp]roviders/[Hh]tml[Ee]ditor[Pp]roviders/
[Ww]ebsite/[Pp]ortals/**/[Cc]ache
[Ww]ebsite/[Pp]ortals/_default/CK*.xml
[Ww]ebsite/[Pp]ortals/_default/[Ii]nstall/CK*.xml
[Ww]ebsite/[Pp]ortals/_default/[Ll]ogs
Expand Down
13 changes: 10 additions & 3 deletions Libraries/Hotcakes.Commerce/Orders/OrderCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private void CalculateTaxes(Order order)

private void TaxOrder(Order order)
{
TaxItems(order.ItemsAsITaxable(), order.BillingAddress, order.ShippingAddress);
TaxItems(order.ItemsAsITaxable(), order.BillingAddress, order.ShippingAddress, order.TotalOrderDiscounts);

var isTaxRateSame = true;
decimal taxRate = -1;
Expand Down Expand Up @@ -586,9 +586,15 @@ private void TaxOrder(Order order)
order.TotalTax = order.ItemsTax + order.ShippingTax;
}

private void TaxItems(List<ITaxable> items, IAddress billingAddress, IAddress shippingAddress)
private void TaxItems(List<ITaxable> items, IAddress billingAddress, IAddress shippingAddress,decimal totalOrderDiscounts)
{
var applyVATRules = _app.CurrentStore.Settings.ApplyVATRules;
decimal discount = 0;
if (totalOrderDiscounts != 0)
{
var qty = items.Where(i => i.IsTaxExempt == false && i.TaxSchedule != -1 && _app.OrderServices.TaxSchedules.FindForThisStore(i.TaxSchedule) != null).Sum(i => i.Quantity);
discount = totalOrderDiscounts / qty;
}

foreach (var item in items)
{
Expand Down Expand Up @@ -630,6 +636,7 @@ private void TaxItems(List<ITaxable> items, IAddress billingAddress, IAddress sh
item.SetTaxRate(rate);

item.SetShippingTaxRate(shippingRate);
var lineItemTotalDiscount = item.Quantity * discount;

if (tax != null)
{
Expand Down Expand Up @@ -678,7 +685,7 @@ private void TaxItems(List<ITaxable> items, IAddress billingAddress, IAddress sh
}
else
{
var lineTotalTax = Money.RoundCurrency(item.LineTotal*rate);
var lineTotalTax = Money.RoundCurrency((item.LineTotal + lineItemTotalDiscount) * rate);

item.TaxPortion = lineTotalTax;

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Hotcakes.Commerce/WebAppSettings.System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Version AppVersion

public static string SKU
{
get { return "PRO"; }
get { return string.Empty; }
}

public static string FriendlyAppVersion
Expand All @@ -56,7 +56,7 @@ public static string FriendlyAppVersion

public static string FriendlySKU
{
get { return "Pro"; }
get { return string.Empty; }
}

public static string CookieNameCartIdPaymentPending(long storeId)
Expand Down
5 changes: 3 additions & 2 deletions Website/web.config
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</configSections>
<connectionStrings>
<!-- Connection String for SQL Server 2008/2012 Express -->
<add name="SiteSqlServer" connectionString="Data Source=localhost\mssqlserver2014;Initial Catalog=Hotcakes_Dev;User ID=dnn;Password=dnn" providerName="System.Data.SqlClient" />
<add name="SiteSqlServer" connectionString="Data Source=.\MSSQL2016;Initial Catalog=HotcakesDev;User ID=uvuser;Password=uvpwd" providerName="System.Data.SqlClient" />
<!-- Connection String for SQL Server 2008/2012
<add name="SiteSqlServer" connectionString="Server=(local);Database=DotNetNuke;uid=;pwd=;" providerName="System.Data.SqlClient" />
-->
Expand Down Expand Up @@ -87,12 +87,13 @@
<add name="Personalization" type="DotNetNuke.HttpModules.Personalization.PersonalizationModule, DotNetNuke.HttpModules" preCondition="managedHandler" />
<add name="Analytics" type="DotNetNuke.HttpModules.Analytics.AnalyticsModule, DotNetNuke.HttpModules" preCondition="managedHandler" />
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="managedHandler" />
<!--add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="managedHandler" /-->
<add name="ClientDependencyModule" type="ClientDependency.Core.Module.ClientDependencyModule, ClientDependency.Core" preCondition="managedHandler" />
<add name="Services" type="DotNetNuke.HttpModules.Services.ServicesModule, DotNetNuke.HttpModules" preCondition="managedHandler" />
<add name="OutputCaching" type="DotNetNuke.HttpModules.OutputCaching.OutputCacheModule, DotNetNuke.HttpModules" preCondition="managedHandler" />
<add name="Compression" type="DotNetNuke.HttpModules.Compression.CompressionModule, DotNetNuke.HttpModules" preCondition="managedHandler" />
<add name="MVCModules" type="DotNetNuke.Web.Mvc.MvcHttpModule, DotNetNuke.Web.Mvc" preCondition="managedHandler" />
<add name="UrlRoutingModule-4.0" type="Hotcakes.Commerce.Dnn.Providers.HccUrlRoutingModule, Hotcakes.Commerce.Dnn" preCondition="managedHandler,runtimeVersionv4.0" />
<add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" preCondition="managedHandler" />
<add name="Detector" type="FiftyOne.Foundation.Mobile.Detection.DetectorModule, FiftyOne.Foundation" preCondition="managedHandler" />
</modules>
Expand Down

0 comments on commit 78f8964

Please sign in to comment.