private LSDecimal Calculate_PointOfSale(Basket basket, Dictionary <string, string> existingTransactions) { WebTrace.Write("CertiTAX: Begin Calculate POS"); CertiTAX.Order taxOrder = new CertiTAX.Order(); //SET THE TAXORDER ADDRESS BuildTaxOrderAddress(taxOrder, StoreDataSource.Load().DefaultWarehouse); //BUILD THE TAXORDER OBJECT BuildTaxOrder(taxOrder, basket, 0, existingTransactions); taxOrder.Nexus = "POS"; //EXECUTE THE TRANSACTION CertiTAX.TaxTransaction taxTransaction = null; try { taxTransaction = (new CertiTAX.CertiCalc()).Calculate(taxOrder); } catch (Exception ex) { WebTrace.Write("CertiTax could not calculate tax. The error was: " + ex.Message); if (!this.IgnoreFailedConfirm) { throw; } } //PARSE THE RESULTS LSDecimal totalTax = ParseTaxTransaction(taxTransaction, basket, 0); WebTrace.Write("CertiTAX: End Calculate POS"); return(totalTax); }
private LSDecimal Calculate_PointOfDelivery(Basket basket, Dictionary <string, string> existingTransactions) { WebTrace.Write("CertiTAX: Begin Calculate POD"); LSDecimal totalTax = 0; foreach (BasketShipment shipment in basket.Shipments) { CertiTAX.Order taxOrder = new CertiTAX.Order(); //SET THE TAXORDER ADDRESS BuildTaxOrderAddress(taxOrder, shipment.Address); //BUILD THE TAXORDER OBJECT BuildTaxOrder(taxOrder, basket, shipment.BasketShipmentId, existingTransactions); taxOrder.Nexus = "POD"; //EXECUTE THE TRANSACTION CertiTAX.TaxTransaction taxTransaction = null; try { taxTransaction = (new CertiTAX.CertiCalc()).Calculate(taxOrder); } catch (Exception ex) { WebTrace.Write("CertiTax could not calculate tax. The error was: " + ex.Message); if (!this.IgnoreFailedConfirm) { throw; } } //PARSE THE RESULTS totalTax += ParseTaxTransaction(taxTransaction, basket, shipment.BasketShipmentId); } WebTrace.Write("CertiTAX: End Calculate POD"); //RETURN THE TOTAL TAX return(totalTax); }
private void BuildTaxOrderAddress(CertiTAX.Order taxOrder, Warehouse address) { taxOrder.Address = new CommerceBuilder.Taxes.Providers.CCH.CertiTAX.Address(); taxOrder.Address.Name = address.Name; taxOrder.Address.Street1 = address.Address1; taxOrder.Address.Street2 = address.Address2; taxOrder.Address.City = address.City; taxOrder.Address.State = address.Province; taxOrder.Address.PostalCode = address.PostalCode; taxOrder.Address.Nation = address.CountryCode; }
private void BuildTaxOrderItems(CertiTAX.Order taxOrder, Basket basket, int shipmentId) { if (this.UseLineItems) { WebTrace.Write("Process Tax Items -- Line Items Mode"); LSDecimal productTotal = 0; List <CertiTAX.OrderLineItem> taxLineItems = new List <CertiTAX.OrderLineItem>(); foreach (BasketItem item in basket.Items) { if (item.OrderItemType == OrderItemType.Product) { CertiTAX.OrderLineItem taxLineItem = new CertiTAX.OrderLineItem(); taxLineItem.ItemId = item.ProductId.ToString(); taxLineItem.StockingUnit = item.Sku; taxLineItem.Quantity = item.Quantity; taxLineItem.ExtendedPrice = (Decimal)item.ExtendedPrice; productTotal += item.ExtendedPrice; taxLineItems.Add(taxLineItem); } } taxOrder.LineItems = taxLineItems.ToArray(); taxOrder.Total = (Decimal)productTotal; } else { WebTrace.Write("Process Tax Items -- Order Total Mode"); OrderItemType[] productTypes = { OrderItemType.Product, OrderItemType.Coupon, OrderItemType.Discount }; if (shipmentId == 0) { //SET TOTAL FOR THE BASKET taxOrder.Total = (Decimal)basket.Items.TotalPrice(productTypes); } else { //SET TOTAL FOR THE SHIPMENT BasketShipment shipment = this.GetShipment(basket, shipmentId); if (shipment != null) { taxOrder.Total = (Decimal)shipment.GetItems().TotalPrice(productTypes); } else { taxOrder.Total = 0; } } } }
private void BuildTaxOrder(CertiTAX.Order taxOrder, Basket basket, int shipmentId, Dictionary <string, string> existingTransactions) { if (existingTransactions.ContainsKey(shipmentId.ToString())) { taxOrder.CertiTAXTransactionId = existingTransactions[shipmentId.ToString()]; } LSDecimal shippingCharge = 0; LSDecimal handlingCharge = 0; GetShipCharges(basket, shipmentId, out shippingCharge, out handlingCharge); taxOrder.SerialNumber = CT_SERIAL_NUMBER; taxOrder.ReferredId = ReferredID; taxOrder.CalculateTax = true; taxOrder.ConfirmAddress = this.ConfirmAddresses; taxOrder.DefaultProductCode = 0; taxOrder.HandlingCharge = (Decimal)handlingCharge; taxOrder.ShippingCharge = (Decimal)shippingCharge; taxOrder.Location = Location; taxOrder.MerchantTransactionId = basket.BasketId.ToString(); WebTrace.Write("Processing Items"); BuildTaxOrderItems(taxOrder, basket, shipmentId); }