Last active
August 29, 2015 14:05
-
-
Save ArveSystad/3bd1c3e939c72cf190d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foreach (LineItem item in items) | |
| { | |
| OrderAddress address = GetAddressByName(form, shipment.ShippingAddressId); | |
| if (address != null) // no taxes if there is no address | |
| { | |
| CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(item.CatalogEntryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)); | |
| if (entryDto.CatalogEntry.Count > 0) // no entry, no tax category, no tax | |
| { | |
| CatalogEntryDto.VariationRow[] variationRows = entryDto.CatalogEntry[0].GetVariationRows(); | |
| if (variationRows.Length > 0) | |
| { | |
| string taxCategory = CatalogTaxManager.GetTaxCategoryNameById(variationRows[0].TaxCategoryId); | |
| IMarket market = ServiceLocator.Current.GetInstance<IMarketService>().GetMarket(order.MarketId); | |
| TaxValue[] taxes = OrderContext.Current.GetTaxes(myAppGuid, taxCategory, market.DefaultLanguage.Name, address.CountryCode, address.State, address.PostalCode, address.RegionCode, String.Empty, address.City); | |
| if (taxes.Length > 0) | |
| { | |
| int itemTax = 0; | |
| foreach (TaxValue tax in taxes) | |
| { | |
| if (tax.TaxType == TaxType.SalesTax) { | |
| itemTax = (int)((double)item.ExtendedPrice * (tax.Percentage / 100)); | |
| totalTaxes += itemTax; | |
| } | |
| } | |
| item[Constants.Metadata.LineItem.VatAmount] = itemTax; | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment