Example #1
0
        //存在的增值税申请 赋值增值税发票
        public void BindVATInvoiceVM(VATInvoiceRequest vatInvoiceRequset)
        {
            if (vatInvoiceRequset != null)
            {
                BPId = vatInvoiceRequset.BPId;
                InternalBPId = vatInvoiceRequset.InternalBPId;
                VATInvoiceRequestId = vatInvoiceRequset.Id;
                BusinessPartner bp;
                using (
                    var businessPartnerService =
                        SvcClientManager.GetSvcClient<BusinessPartnerServiceClient>(SvcType.BusinessPartnerSvc))
                {
                    bp = businessPartnerService.GetById(BPId);
                }
                if (bp != null)
                {
                    BPName = bp.ShortName;
                }

                VATRate vatRate;
                using (
                    var vatRateService =
                        SvcClientManager.GetSvcClient<VATRateServiceReference.VATRateServiceClient>(SvcType.VATRateSvc))
                {
                    //it.Type=2 为销项税
                    vatRate = vatRateService.Select("it.IsDeleted=false and it.Type=2 order by it.Created", null, null).FirstOrDefault();
                }


                var vatInvoiceLines = new List<VATInvoiceLine>();
                foreach (VATInvoiceRequestLine item in vatInvoiceRequset.VATInvoiceRequestLines)
                {
                    var line = new VATInvoiceLine();
                    int id = GetLineId();
                    line.Id = -id;
                    line.QuotaId = item.QuotaId;
                    line.VATInvoiceQuantity = item.RequestQuantity - item.VATInvoicedQuantity;
                    line.UnOpenedQuantity = item.RequestQuantity - item.VATInvoicedQuantity;
                    line.VATAmount = item.RequestAmount;
                    line.VATPrice = item.RequestPrice;
                    line.VATInvoiceRequestLineId = item.Id;
                    if (vatRate != null)
                    {
                        line.VATRateId = vatRate.Id;
                        line.VATRate = vatRate;
                    }
                    if (DetailVM == null)
                    {
                        DetailVM = new VATInvoiceLineDetailVM(VATInvoiceType);
                    }

                    using (var quotaService = SvcClientManager.GetSvcClient<QuotaServiceClient>(SvcType.QuotaSvc))
                    {
                        Quota qt = quotaService.GetById(item.QuotaId);
                        if (qt != null)
                        {
                            line.Quota = qt;
                            line.Quota.VATStatus = qt.VATStatus;
                        }
                    }
                    vatInvoiceLines.Add(line);
                    if (ShowVATInvoiceLines == null)
                    {
                        ShowVATInvoiceLines = new List<VATInvoiceLine>();
                    }
                    ShowVATInvoiceLines.Add(line);
                    if (AddVATInvoiceLines == null)
                    {
                        AddVATInvoiceLines = new List<VATInvoiceLine>();
                    }
                    AddVATInvoiceLines.Add(line);
                }
            }
        }
Example #2
0
 public VATInvoiceDetailVM(int id)
 {
     ObjectId = id;
     if (DetailVM == null)
         DetailVM = new VATInvoiceLineDetailVM(VATInvoiceType);
     Initialize();
 }