Exemple #1
0
        static void postRedJson(RedViewModel viewModel, string url, string type)
        {
            InvoiceRed invoice = new InvoiceRed();

            invoice.taxpayerNum        = viewModel.TaxpayerNum;
            invoice.invoiceReqSerialNo = SerialNoHelper.GetInvoiceReqSerialNo(mcPrefix);
            invoice.amount             = viewModel.Amount;
            invoice.invoiceCode        = viewModel.InvoiceCode;
            invoice.invoiceNo          = viewModel.InvoiceNo;
            invoice.redReason          = viewModel.RedReason;

            string content = JsonHelper.Object2String <InvoiceRed>(invoice).Replace("\\", "");

            mLogger.Info("红票业务内容JSON串");

            Task.Factory.StartNew(() =>
            {
                MsgResponse rsp = mApi.PostJson(url, content);
                if (OnHttpPost != null)
                {
                    OnHttpPost(type + "红票开票" + rsp.msg);
                }
            });
        }
Exemple #2
0
        static void postBlueJson(BlueViewModel viewModel, string url, string type)
        {
            InvoiceBlue invoice = new InvoiceBlue();

            // 纳税人识别号
            invoice.taxpayerNum = viewModel.TaxPayerNum;
            // 发票请求流水号
            invoice.invoiceReqSerialNo = SerialNoHelper.GetInvoiceReqSerialNo(mcPrefix);

            invoice.buyerName        = viewModel.BuyerName;
            invoice.buyerAddress     = viewModel.BuyerAddress;
            invoice.buyerTel         = viewModel.BuyerTel;
            invoice.buyerBankName    = viewModel.BuyerBankName;
            invoice.buyerBankAccount = viewModel.BuyerBankAccount;
            invoice.buyerTaxpayerNum = viewModel.TaxPayerNum;

            invoice.sellerAddress     = viewModel.SellerAddress;
            invoice.sellerBankAccount = viewModel.SellerBankAccount;
            invoice.sellerBankName    = viewModel.SellerBankName;
            invoice.sellerTel         = viewModel.SellerTel;

            // 纸质蓝票的分机号时必填项
            if (type == "纸质")
            {
                invoice.extensionNum = "1";
            }

            List <Goods> goodsList = new List <Goods>();

            foreach (BlueGoods item in viewModel.BlueGoodses)
            {
                // 只添加被选中的项目
                if (!item.IsSelected)
                {
                    continue;
                }
                goodsList.Add(new Goods()
                {
                    goodsName = item.Description,
                    quantity  = item.Quantity.ToString(),
                    //quantity ="1.00",
                    unitPrice = item.Price.ToString(),
                    //unitPrice ="56.64",
                    invoiceAmount = item.TransactionAmount.ToString(),
                    // invoiceAmount ="56.64",
                    includeTaxFlag = item.IsIncludeTax?"1":"0",
                    taxRateValue   = item.TaxRate.ToString(),
                    // 0税率处理
                    zeroTaxFlag = item.TaxRate == 0?"1":null,
                    // 税额的计算
                    taxRateAmount = Convert.ToDouble((item.TaxRateAmount == 0?
                                                      TaxHelper.GetTaxAmount(item.Quantity, item.Price, item.TaxRate):item.TaxRateAmount)).ToString(),

                    taxClassificationCode = item.TaxClassificationCode,
                });
            }
            // 项目列表
            invoice.itemList = JsonHelper.Object2String <List <Goods> >(goodsList);
            // 过滤业务内容串
            string content = JsonHelper.Object2String <InvoiceBlue>(invoice).
                             Replace("\\", "").Replace("\"[", "[").Replace("]\"", "]");

            // 记录业务报文json串到日志中
            mLogger.Info("蓝票业务内容JSON串:" + content);

            Task.Factory.StartNew(() =>
            {
                MsgResponse rsp = mApi.PostJson(url, content);
                if (OnHttpPost != null)
                {
                    OnHttpPost(type + "蓝票开票" + rsp.msg);
                }
            });
        }