Esempio n. 1
0
 internal static void RegistData(BlueViewModel model)
 {
     mBlueViewModel = model;
 }
Esempio n. 2
0
        /// <summary>
        /// 开具电子蓝票
        /// </summary>
        /// <param name="viewModel"></param>
        internal static void DrawElectronicBlue(BlueViewModel viewModel)
        {
            string url = ConfigurationManager.AppSettings["ElectronicBlue"];

            postBlueJson(viewModel, url, "电子");
        }
Esempio n. 3
0
        internal static void DrawPaperSpecial(BlueViewModel viewModel)
        {
            string url = ConfigurationManager.AppSettings["PaperSpecial"];

            postBlueJson(viewModel, url, "纸质");
        }
Esempio n. 4
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);
                }
            });
        }