예제 #1
0
        private CalcResult SalesOrderTax(CalcRequestContext context)
        {
            var repository = new BqlRepository(new PXGraph(), _logger);

            var transfer = repository.RetrieveTaxTransfer(context.OrderType, context.OrderNbr);
            var result   = new CalcResult();

            result.AddTaxLine("Sales Order Tax", 0m, transfer.NetTaxableAmount, transfer.NetTotalTax);
            return(result);
        }
예제 #2
0
        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);
        }
예제 #3
0
        private GetTaxResult ProcessResults(CalcResult result)
        {
            if (result.Failed)
            {
                var log = $"TaxCalcService {CalcVersion} -> Calculate failed:" + Environment.NewLine;
                result.ErrorMessages.ForEach(x => log += x + Environment.NewLine);

                _logger.Info(log);

                throw new Exception($"TaxCalcService {CalcVersion} -> Calculate failed");
            }
            else
            {
                var acumaticaTaxId = _settings.Setting(ProviderSettings.SETTING_EXTERNALTAXID).Value;
                var json           = JsonConvert.SerializeObject(result);
                _logger.Info($"TaxCalcService {CalcVersion} -> Calculate (Result) - {json}");

                var output = result.ToGetTaxResult(acumaticaTaxId);
                return(output);
            }
        }
예제 #4
0
        // 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);
        }