Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ILogger        logger         = new XmlLogger();
            TaxCalculation taxCalculation = new TaxCalculation(logger);

            Console.WriteLine(taxCalculation.Calculation(10, 0));
        }
        /// <summary>
        /// 签名失败处理数据
        /// </summary>
        private void SignFilureData()
        {
            //签名失败,客户端处理税款明细
            if (Credit != null && Credit.Productes != null)
            {
                TaxList = Credit.Productes.GroupBy(a => a.TaxType.Id).Select(g => new InvoiceTax
                {
                    TaxItemCode = g.First().TaxType.Label,
                    TaxItemDesc = g.First().TaxType.Name,
                    TaxRate     = g.First().TaxType.Rate,

                    TaxAmount = g.Sum(b =>
                    {
                        return(TaxCalculation.Calculation(b.TaxInclusive, b.TaxType.CalculationMode, b.Price, b.Count, b.TaxType.Rate, b.TaxType.FixTaxAmount));
                    })
                }).ToList();
                if (TaxList != null && TaxList.Count > 0)
                {
                    TotalTaxAmount = Math.Round(TaxList.Sum(a => a.TaxAmount), 2);
                }
            }
        }
        private void Save(SignRequest request, SignResponse signResponse)
        {
            //保存销售订单主表
            InvoiceAbbreviation invoiceAbbreviation = new InvoiceAbbreviation
            {
                CashierId      = Const.CashierId,
                TaxpayerTin    = TaxPayerInfo.Tin,
                TotalTaxAmount = TotalTaxAmount,
                TenderAmount   = ActualPay,
                Change         = Change,
                QrcodePath     = "",
            };

            if (Credit != null)
            {
                invoiceAbbreviation.SalesorderNum = Credit.OrderNumber;
                if (Credit.SelectedPaymentType != null)
                {
                    invoiceAbbreviation.PaymentType = Credit.SelectedPaymentType.Code;
                }
                invoiceAbbreviation.BuyerTin    = Credit.Buyer.Tin;
                invoiceAbbreviation.BuyerName   = Credit.Buyer.Name;
                invoiceAbbreviation.TotalAmount = Credit.GrandTotal;
            }
            //if (request != null)
            //{
            //    invoiceAbbreviation.HashCode = request.Hash;
            //}
            ///sdc取值
            if (signResponse != null)
            {
                invoiceAbbreviation.TaxpayerName = signResponse.TaxpayerName;     //sdc取值
                //invoiceAbbreviation.TaxpayerLocation = signResponse.LocationName;//sdc取值
                invoiceAbbreviation.TaxpayerAddress = signResponse.Addreess;      //sdc取值
                //invoiceAbbreviation.TaxpayerDistrit = signResponse.District;//sdc取值
                invoiceAbbreviation.InvoiceNumber   = signResponse.InvoiceNumber; //sdc取值
                invoiceAbbreviation.IssueDate       = request.IssueTime;          //sdc取值
                invoiceAbbreviation.VerificationUrl = signResponse.VerificationUrl;
            }
            Const.dB.Insert <InvoiceAbbreviation>(invoiceAbbreviation);
            //保存订单销售子表
            InvoiceItems invoiceItem = null;

            if (Credit != null && Credit.Productes != null)
            {
                foreach (var item in Credit.Productes)
                {
                    invoiceItem    = new InvoiceItems();
                    invoiceItem.Sn = null;

                    invoiceItem.TaxtypeId     = item.TaxType.Id;
                    invoiceItem.SalesorderNum = Credit.OrderNumber;
                    invoiceItem.GoodsId       = item.No;
                    invoiceItem.GoodsGin      = item.BarCode;
                    invoiceItem.GoodsDesc     = item.Name;
                    invoiceItem.GoodsPrice    = item.Price;
                    invoiceItem.GoodsQty      = item.Count;
                    invoiceItem.TotalAmount   = item.Price * item.Count;

                    invoiceItem.TaxtypeId = item.TaxType.Id;
                    invoiceItem.TaxItem   = item.TaxType.Name;
                    invoiceItem.TaxRate   = item.TaxType.Rate;
                    invoiceItem.TaxAmount = TaxCalculation.Calculation(item.TaxInclusive, item.TaxType.CalculationMode, item.Price, item.Count, item.TaxType.Rate, item.TaxType.FixTaxAmount);

                    Const.dB.Insert <InvoiceItems>(invoiceItem);
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            TaxCalculation taxCalculation = new TaxCalculation(LogType.TXT);

            Console.WriteLine(taxCalculation.Calculation(5, 0));
        }