private static void AdjustPriceAndTaxes(Currency currency, ILineItem lineItem, DinteroOrderLine dinteroItem, IOrderAddress orderAddress) { var amount = lineItem.GetExtendedPrice(currency).Amount; double vat = 0; var entryDto = CatalogContext.Current.GetCatalogEntryDto(lineItem.Code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)); if (entryDto.CatalogEntry.Count > 0) { CatalogEntryDto.VariationRow[] variationRows = entryDto.CatalogEntry[0].GetVariationRows(); if (variationRows.Length > 0) { var taxCategory = CatalogTaxManager.GetTaxCategoryNameById(variationRows[0].TaxCategoryId); var taxes = OrderContext.Current.GetTaxes(Guid.Empty, taxCategory, Thread.CurrentThread.CurrentCulture.Name, orderAddress).ToList(); foreach (var tax in taxes) { if (tax.TaxType == TaxType.SalesTax) { vat = tax.Percentage; } } } } dinteroItem.Amount = CurrencyHelper.CurrencyToInt(amount, currency.CurrencyCode); dinteroItem.Vat = Convert.ToInt32(vat); dinteroItem.VatAmount = GetVatAmount(amount, vat, currency.CurrencyCode); }
private static DinteroOrderLine TransformLineItem(Currency currency, ILineItem lineItem, IOrderAddress orderAddress, int index) { var dinteroItem = new DinteroOrderLine { Id = lineItem.Code, Groups = new List<DinteroOrderLineGroup>(), LineId = index.ToString(), Description = lineItem.DisplayName, Quantity = lineItem.Quantity }; AdjustPriceAndTaxes(currency, lineItem, dinteroItem, orderAddress); return dinteroItem; }