private CalcResult InvoiceFinalTax(TaxTransfer.v2.TaxTransfer transfer, OtherInvoiceTaxContext otherInvoiceTaxes) { var taxableTotal = transfer.NetTaxableAmount - otherInvoiceTaxes.TotalTaxableAmount; var taxTotal = transfer.NetTotalTax - otherInvoiceTaxes.TotalTaxAmount; // *** Add Payment Discrepancy // var result = new CalcResult(); result.AddTaxLine("Final Invoice Tax", 0m, taxableTotal, taxTotal); return(result); }
// Recreate Tax Calculation using the Tax Transfer // private CalcResult InvoiceSplitShipmentTax(GetTaxRequest request, TaxTransfer.v2.TaxTransfer snapshot) { var result = new CalcResult(); foreach (var lineItem in request.CartItems) { // NULL ItemCode signals that this line item is freight // if (lineItem.ItemCode == null) { if (lineItem.Amount > 0.00m) { result.AddTaxLine(lineItem.Description, 0m, lineItem.Amount, snapshot.NetFreightTax); } continue; } var correctedItemCode = lineItem.ItemCode.Trim(); if (snapshot.LineItems.Any(x => x.ItemID == correctedItemCode) == false) { result.AddError($"Unable to locate Inventory ID {correctedItemCode} in Tax Transfer"); continue; } // Compute Line Item Tax using Tax Lines from Transfer // var lineItemTaxCalc = snapshot.CalculateTax(correctedItemCode, (decimal)lineItem.Amount, (int)lineItem.Quantity); result.AddTaxLine(lineItemTaxCalc.Name, 0m, lineItemTaxCalc.TaxableAmount, lineItemTaxCalc.TaxAmount); } return(result); }
public static TaxTransfer.v2.TaxTransfer ToTaxTransfer(this Order shopifyOrder) { var snapshot = new TaxTransfer.v2.TaxTransfer(); snapshot.ShopifyOrderId = shopifyOrder.id; snapshot.ShopifyRefundIds = shopifyOrder.refunds.Select(x => x.id).OrderBy(x => x).ToList(); snapshot.NetTaxableFreight = shopifyOrder.NetShippingTaxablePrice; snapshot.NetFreightTax = shopifyOrder.NetShippingTax; // *** Includes Shipping // snapshot.NetTaxableAmount = shopifyOrder.line_items.Sum(x => x.TaxableAmount) + shopifyOrder.ShippingTaxableTotal - shopifyOrder.refunds.Sum(x => x.TotalTaxableLineAndShippingAmount); snapshot.NetTotalTax = shopifyOrder.NetLineItemTax + shopifyOrder.NetShippingTax; snapshot.LineItems = new List <TaxTransferLineItem>(); foreach (var line_item in shopifyOrder.line_items) { var snapshot_line = new TaxTransferLineItem(); snapshot_line.ItemID = line_item.sku; snapshot_line.TaxLines = line_item.tax_lines.ToSnapshotTaxLines(); snapshot.LineItems.Add(snapshot_line); } snapshot.FreightTaxLines = shopifyOrder .shipping_lines .SelectMany(x => x.tax_lines) .ToSnapshotTaxLines(); return(snapshot); }