コード例 #1
0
        public ActionResult download()
        {
            PaymentInvoice tempinvoice = new PaymentInvoice().GetInvoice(Request.QueryString["tid"].ToString(), Session["companyid"].ToString(), Session["userid"].ToString());
            string         data        = tempinvoice.invoicedata;
            XDocument      invoicedoc  = new XDocument();

            try
            {
                invoicedoc = XDocument.Parse(data);
            }
            catch
            {
            }



            var pdf = new PdfResult(tempinvoice, "download");

            string filename = "attachment; filename=" + invoicedoc.Descendants("client").First().Descendants("compname").First().Value.ToString() + "-" + invoicedoc.Descendants("metadata").First().Descendants("id").First().Value.ToString() + ".pdf";

            pdf.ViewBag.Title    = "Invoice";
            Response.ContentType = "application/pdf";
            Response.AddHeader("Content-Disposition", filename);



            return(pdf);

            // return View();
        }
コード例 #2
0
ファイル: Delete.cshtml.cs プロジェクト: shasans/0g-hrms
        public async Task <IActionResult> OnPostAsync(int id)
        {
            // PaymentInvoice = await Context.PaymentInvoice.FindAsync(id);
            PaymentInvoice = await Context.PaymentInvoice.AsNoTracking()
                             .FirstOrDefaultAsync(m => m.PaymentInvoiceID == id);

            var paymentInvoice = await Context
                                 .PaymentInvoice.AsNoTracking()
                                 .FirstOrDefaultAsync(m => m.PaymentInvoiceID == id);

            if (paymentInvoice == null)
            {
                return(NotFound());
            }

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, paymentInvoice,
                EmployeeOperations.Delete);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            Context.PaymentInvoice.Remove(PaymentInvoice);
            await Context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #3
0
        public async Task <IActionResult> Post(Owner.Type ownerType, bool force, [FromBody] PaymentUseDto useDto)
        {
            var paymentUse = _mapper.Map <PaymentUseDto, PaymentUse>(useDto);

            _executor.GetCommand <CreatePaymentUseHandler>().Process(c => c.Execute(ownerType, paymentUse, force));
            PaymentInvoice paymentInvoice = null;

            if (paymentUse.PaymentInvoiceId.HasValue)
            {
                paymentInvoice = await _executor.GetQuery <GetPaymentInvoiceByIdQuery>()
                                 .Process(q => q.ExecuteAsync(paymentUse.PaymentInvoiceId.Value));
            }

            switch (ownerType)
            {
            case Owner.Type.Request:
                var requestId = paymentInvoice?.RequestId;
                NiisWorkflowAmbientContext.Current.RequestWorkflowService.Process(new RequestWorkFlowRequest
                {
                    RequestId        = requestId ?? 0,
                    PaymentInvoiceId = paymentInvoice?.Id,
                    IsAuto           = true
                });

                await Executor.GetHandler <UnsetRequestFormalExamNotPaidHandler>().Process(h => h.ExecuteAsync(requestId ?? 0, paymentInvoice));

                //await Executor.GetHandler<GenerateAutoNotificationHandler>().Process(h => h.Execute(requestId ?? 0));
                break;

            case Owner.Type.ProtectionDoc:
                if (DicTariff.Codes.GetProtectionDocSupportCodes().Contains(paymentInvoice?.Tariff?.Code) ||
                    paymentInvoice?.Tariff?.Code == DicTariff.Codes.ProtectionDocRestore)
                {
                    var protectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>().Process(q => q.ExecuteAsync(paymentInvoice?.ProtectionDocId ?? 0));

                    if (protectionDoc != null)
                    {
                        protectionDoc.MaintainDate = protectionDoc.MaintainDate?.AddYears(paymentInvoice?.TariffCount ?? 1)
                                                     ?? DateTimeOffset.Now.AddYears(paymentInvoice?.TariffCount ?? 1);
                        await Executor.GetCommand <UpdateProtectionDocCommand>().Process(c => c.ExecuteAsync(protectionDoc.Id, protectionDoc));
                    }
                }
                NiisWorkflowAmbientContext.Current.ProtectionDocumentWorkflowService.Process(new ProtectionDocumentWorkFlowRequest
                {
                    ProtectionDocId = paymentInvoice?.ProtectionDocId ?? 0,
                    IsAuto          = true
                });
                break;

            case Owner.Type.Contract:
                NiisWorkflowAmbientContext.Current.ContractWorkflowService.Process(new ContractWorkFlowRequest
                {
                    ContractId = paymentInvoice?.ContractId ?? 0,
                    IsAuto     = true
                });
                break;
            }

            return(Ok(_mapper.Map <PaymentUse, PaymentUseDto>(paymentUse)));
        }
コード例 #4
0
ファイル: PaymentDtoProfile.cs プロジェクト: Hugoberry/WEB
        private static decimal?GetPaymentInvoiceSum(PaymentInvoice pi, List <DicCustomer> customers)
        {
            var tariffPrice = GetTariffPrice(pi, customers);

            return(tariffPrice * pi.Coefficient * pi.TariffCount +
                   tariffPrice * pi.Coefficient * pi.TariffCount * pi.PenaltyPercent);
        }
コード例 #5
0
        public void Execute(PaymentInvoice paymentInvoice)
        {
            var paymentInvoiceRepository = Uow.GetRepository <PaymentInvoice>();

            paymentInvoiceRepository.Delete(paymentInvoice);
            Uow.SaveChanges();
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op  = RequestData.Get <string>("op");
            id  = RequestData.Get <string>("id");
            CId = RequestData.Get <string>("CId");
            switch (RequestActionString)
            {
            case "update":
                ent = this.GetMergedData <PaymentInvoice>();
                ent.DoUpdate();
                break;

            case "create":
                ent                 = this.GetPostedData <PaymentInvoice>();
                ent.BillType        = "收据";
                ent.CreateId        = UserInfo.UserID;
                ent.CreateName      = UserInfo.Name;
                ent.CreateTime      = DateTime.Now;
                ent.Name            = "自动销账";
                ent.CorrespondState = "已对应";
                ent.DoCreate();
                ent.CorrespondInvoice = ent.CorrespondInvoice + "_" + ent.Money;
                ent.DoUpdate();
                break;

            default:
                DoSelect();
                break;
            }
        }
コード例 #7
0
        public string GetInvoice(string invid)
        {
            PaymentInvoice tempinvoice = new PaymentInvoice().GetInvoice(invid, Session["companyid"].ToString(), Session["userid"].ToString());
            string         data        = tempinvoice.invoicedata;

            return(data);
        }
コード例 #8
0
ファイル: PaymentDtoProfile.cs プロジェクト: Hugoberry/WEB
        private static decimal?GetTariffPrice(PaymentInvoice pi, List <DicCustomer> customers)
        {
            List <decimal?> invoiceSums = new List <decimal?>();

            // Workaround для миграции. Старые тарифы
            if (customers == null || customers.Count == 0)
            {
                return(pi.Tariff?.Price ?? 0);
            }

            foreach (var customer in customers)
            {
                // Workaround для миграции. Старые тарифы
                if (pi.Tariff.Price != null)
                {
                    invoiceSums.Add(pi.Tariff.Price);
                }

                //не зависит от типа заявителя
                //if (new[] { DicProtectionDocType.Codes.Trademark, DicProtectionDocType.Codes.InternationalTrademark }
                //    .Contains(GetOwnerProtectionDocType(pi)))
                //{
                //    invoiceSums.Add(pi.Tariff.Price);
                //    continue;
                //}

                //var isBeneficiary = customer?.IsBeneficiary ?? false;
                //if (isBeneficiary && customer?.BeneficiaryType?.Code != "SMB") // Субъекты малого и среднего бизнеса
                //{
                //    invoiceSums.Add(pi.Tariff.Price);
                //    continue;
                //}

                //if (customer?.BeneficiaryType?.Code == "SMB")
                //{
                //    invoiceSums.Add(pi.Tariff.Price);
                //    continue;
                //}

                //switch (customer?.Type?.Code)
                //{
                //    case DicCustomerTypeCodes.Physical:
                //        invoiceSums.Add(pi.Tariff.PriceFl);
                //        break;
                //    case DicCustomerTypeCodes.Juridical:
                //        invoiceSums.Add(pi.Tariff.PriceUl);
                //        break;
                //    case DicCustomerTypeCodes.SoloEntrepreneur:
                //    case DicCustomerTypeCodes.LimitedPartnership:
                //        invoiceSums.Add(pi.Tariff.PriceBusiness);
                //        break;
                //    default: return null;
                //}
            }

            return(invoiceSums.Max());
        }
コード例 #9
0
        public async Task <int> ExecuteAsync(PaymentInvoice paymentInvoice)
        {
            var paymentInvoiceRepository = Uow.GetRepository <PaymentInvoice>();
            await paymentInvoiceRepository.CreateAsync(paymentInvoice);

            await Uow.SaveChangesAsync();

            return(paymentInvoice.Id);
        }
コード例 #10
0
        private void MakePaymentInvoiceNotpaid(PaymentInvoice paymentInvoice)
        {
            paymentInvoice.Status = Uow.GetRepository <DicPaymentStatus>()
                                    .AsQueryable()
                                    .FirstOrDefault(q => q.Code == DicPaymentStatusCodes.Notpaid);

            paymentInvoice.DateFact       = null;
            paymentInvoice.WhoBoundUserId = null;
        }
コード例 #11
0
        private void MakePaymentInvoiceCredited(PaymentInvoice paymentInvoice)
        {
            paymentInvoice.Status = Uow.GetRepository <DicPaymentStatus>()
                                    .AsQueryable()
                                    .FirstOrDefault(q => q.Code == DicPaymentStatusCodes.Credited);

            paymentInvoice.DateFact       = DateTimeOffset.Now;
            paymentInvoice.WhoBoundUserId = NiisAmbientContext.Current.User.Identity.UserId;
        }
コード例 #12
0
        public int Execute(PaymentInvoice invoice)
        {
            var repo = Uow.GetRepository <PaymentInvoice>();

            repo.Create(invoice);

            Uow.SaveChanges();
            return(invoice.Id);
        }
コード例 #13
0
ファイル: PaymentForm.cs プロジェクト: anoozz/nbooks
 void EnterPaymentToolStripMenuItemClick(object sender, EventArgs e)
 {
     if (listViewInvoices.SelectedItems.Count > 0)
     {
         PaymentInvoice invoice = payment.Invoices[listViewInvoices.SelectedItems[0].Index];
         using (var f = new PaymentInvoiceForm(invoice)) {
             if (WorkbenchSingleton.AddDialog(f) == DialogResult.OK)
             {
             }
         }
     }
 }
コード例 #14
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            PaymentInvoice.UploadDT = DateTime.Now;



            PaymentInvoice.OwnerID = UserManager.GetUserId(User);

            // requires using ContactManager.Authorization;
            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, PaymentInvoice,
                EmployeeOperations.Create);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }


            var emptyPaymentInvoice = new PaymentInvoice();

            if (await TryUpdateModelAsync <PaymentInvoice>(
                    emptyPaymentInvoice,
                    "paymentinvoice", // Prefix for form value.
                    s => s.PaymentInvoiceID, s => s.RecieverType, s => s.ClientID, s => s.VendorID, s => s.BankAccount, s => s.Amount, s => s.ImageName))
            {
                if (Image != null)
                {
                    var fileName = GetUniqueName(Image.FileName);
                    PaymentInvoice.ImageName = fileName;
                    var uploaded = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/uploads");
                    var filePath = Path.Combine(uploaded, fileName);
                    var memory   = new MemoryStream();
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        await Image.CopyToAsync(stream);
                    }
                }
                Context.PaymentInvoice.Add(PaymentInvoice);
                await Context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            // Select DepartmentID if TryUpdateModelAsync fails.
            PopulateRecieverDropDownList(Context, emptyPaymentInvoice.ClientID);
            PopulateReciever2DropDownList(Context, emptyPaymentInvoice.VendorID);
            return(Page());
        }
コード例 #15
0
 private void DoSelect()
 {
     if (op != "c" && op != "cs")
     {
         if (!String.IsNullOrEmpty(id))
         {
             ent = PaymentInvoice.Find(id);
         }
     }
     else
     {
         ent = new PaymentInvoice();
     }
     SetFormData(ent);
     PageState.Add("PayType", SysEnumeration.GetEnumDict("PayType"));
 }
コード例 #16
0
        public int Execute(Owner.Type ownerType, int ownerId, string tariffCode, string paymentStatusCode, int?userId, int?tariffCount = null)
        {
            var tariffId = Executor.GetQuery <GetDictionaryIdByEntityNameAndCodeQuery>().Process(q => q.Execute(nameof(DicTariff), tariffCode));

            if (tariffId.HasValue == false)
            {
                throw new DataNotFoundException(nameof(DicTariff),
                                                DataNotFoundException.OperationType.Read, $"Parameters: {nameof(tariffCode)}");
            }
            var paymentStatusId = Executor.GetQuery <GetDictionaryIdByEntityNameAndCodeQuery>().Process(q => q.Execute(nameof(DicPaymentStatus), paymentStatusCode));

            if (paymentStatusId.HasValue == false)
            {
                throw new DataNotFoundException(nameof(DicPaymentStatus),
                                                DataNotFoundException.OperationType.Read, $"Parameters: {nameof(paymentStatusCode)}");
            }
            PaymentInvoice paymentInvoice = new PaymentInvoice
            {
                Coefficient    = defaultCoefficient,
                Nds            = defaultNds,
                TariffCount    = tariffCount ?? defaultTariffCount,
                PenaltyPercent = defaultPenaltyPercent,
                TariffId       = tariffId.Value,
                StatusId       = paymentStatusId.Value,
                CreateUserId   = userId
            };

            switch (ownerType)
            {
            case Owner.Type.Request:
                paymentInvoice.RequestId = ownerId;
                break;

            case Owner.Type.Contract:
                paymentInvoice.ContractId = ownerId;
                break;

            case Owner.Type.ProtectionDoc:
                paymentInvoice.ProtectionDocId = ownerId;
                break;
            }

            Executor.GetCommand <CreatePaymentInvoiceCommand>().Process(c => c.Execute(paymentInvoice));
            return(paymentInvoice.Id);
        }
コード例 #17
0
ファイル: PaymentDtoProfile.cs プロジェクト: Hugoberry/WEB
        private static string GetOwnerProtectionDocType(PaymentInvoice pi)
        {
            if (pi.RequestId != null)
            {
                return(pi.Request.ProtectionDocType.Code);
            }

            if (pi.ProtectionDocId != null)
            {
                return(pi.ProtectionDoc.Type.Code);
            }

            if (pi.ContractId != null)
            {
                return(pi.Contract.ProtectionDocType.Code);
            }

            return(string.Empty);
        }
コード例 #18
0
        string type = String.Empty; // 对象类型

        #endregion

        #region ASP.NET 事件

        protected void Page_Load(object sender, EventArgs e)
        {
            op   = RequestData.Get <string>("op");
            id   = RequestData.Get <string>("id");
            type = RequestData.Get <string>("type");

            PaymentInvoice ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <PaymentInvoice>();
                ent.DoUpdate();
                this.SetMessage("修改成功!");
                break;

            case RequestActionEnum.Insert:
            case RequestActionEnum.Create:
                ent     = this.GetPostedData <PaymentInvoice>();
                ent.CId = RequestData.Get <string>("CId");
                ent.DoCreate();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <PaymentInvoice>();
                ent.DoDelete();
                this.SetMessage("删除成功!");
                return;
            }

            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent = PaymentInvoice.Find(id);
                }

                this.SetFormData(ent);
            }

            PageState.Add("PayType", SysEnumeration.GetEnumDict("PayType"));
        }
コード例 #19
0
        public async Task Execute(Owner.Type ownerType, int ownerId, string[] tariffCodes, string paymentStatusCode, int?userId, int?tariffCount = null)
        {
            foreach (var tariffCode in tariffCodes)
            {
                var tariffId = Executor.GetQuery <GetDictionaryIdByEntityNameAndCodeQuery>().Process(q => q.Execute(nameof(DicTariff), tariffCode));
                if (tariffId.HasValue == false)
                {
                    continue;
                }
                var paymentStatusId = Executor.GetQuery <GetDictionaryIdByEntityNameAndCodeQuery>().Process(q => q.Execute(nameof(DicPaymentStatus), paymentStatusCode));
                if (paymentStatusId.HasValue == false)
                {
                    continue;
                }
                PaymentInvoice paymentInvoice = new PaymentInvoice
                {
                    Coefficient    = defaultCoefficient,
                    Nds            = defaultNds,
                    TariffCount    = tariffCount ?? defaultTariffCount,
                    PenaltyPercent = defaultPenaltyPercent,
                    TariffId       = tariffId.Value,
                    StatusId       = paymentStatusId.Value,
                    CreateUserId   = userId
                };
                switch (ownerType)
                {
                case Owner.Type.Request:
                    paymentInvoice.RequestId = ownerId;
                    break;

                case Owner.Type.Contract:
                    paymentInvoice.ContractId = ownerId;
                    break;

                case Owner.Type.ProtectionDoc:
                    paymentInvoice.ProtectionDocId = ownerId;
                    break;
                }

                await Executor.GetCommand <CreatePaymentInvoiceCommand>().Process(c => c.ExecuteAsync(paymentInvoice));
            }
        }
コード例 #20
0
ファイル: Delete.cshtml.cs プロジェクト: shasans/0g-hrms
        public async Task <IActionResult> OnGetAsync(int id)
        {
            PaymentInvoice = await Context.PaymentInvoice.AsNoTracking().Include(c => c.Client).Include(v => v.Vendor).FirstOrDefaultAsync(m => m.PaymentInvoiceID == id);

            if (PaymentInvoice == null)
            {
                return(NotFound());
            }

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, PaymentInvoice,
                EmployeeOperations.Delete);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            return(Page());
        }
コード例 #21
0
        public static PaymentInvoice ToPaymentInvoice(this StripeInvoice stripeInvoice)
        {
            var invoice = new PaymentInvoice
            {
                Id              = stripeInvoice.Id,
                InvoiceNumber   = stripeInvoice.Number,
                ReceiptNumber   = stripeInvoice.ReceiptNumber,
                AmountDue       = stripeInvoice.AmountDue.ToDecimalAmount(),
                AmountPaid      = stripeInvoice.AmountPaid.ToDecimalAmount(),
                AmountRemaining = stripeInvoice.AmountRemaining.ToDecimalAmount(),
                AttemptCount    = stripeInvoice.AttemptCount,
                Attempted       = stripeInvoice.Attempted,
                CustomerId      = stripeInvoice.CustomerId,
                ChargeId        = stripeInvoice.ChargeId,
                Description     = stripeInvoice.Description,
                //Todo: Discount
                DueDate          = stripeInvoice.DueDate,
                HostedInvoiceUrl = stripeInvoice.HostedInvoiceUrl,
                HostedPdf        = stripeInvoice.InvoicePdf,
                Subtotal         = stripeInvoice.Subtotal.ToDecimalAmount(),
                Total            = stripeInvoice.Total.ToDecimalAmount(),
                periodStartDate  = stripeInvoice.PeriodStart,
                periodEndDate    = stripeInvoice.PeriodEnd,
                Tax        = stripeInvoice.Tax == null ? null : (decimal?)((int)stripeInvoice.Tax).ToDecimalAmount(),
                TaxPercent = stripeInvoice.TaxPercent
            };

            //Items
            if (stripeInvoice.StripeInvoiceLineItems != null && stripeInvoice.StripeInvoiceLineItems.TotalCount > 0)
            {
                invoice.Items = new List <InvoiceItem>();
                foreach (var lineItem in stripeInvoice.StripeInvoiceLineItems)
                {
                    if (lineItem != null)
                    {
                        invoice.Items.Add(lineItem.ToInvoiceItem());
                    }
                }
            }
            return(invoice);
        }
コード例 #22
0
        public async Task ExecuteAsync(int requestId, PaymentInvoice paymentInvoice)
        {
            //коды тарифов оплаты за предварительную экспертизу
            var formalExamTariffCodes = new[]
            {
                DicTariffCodes.CollectiveTmFormalExpertizeDigital,
                DicTariffCodes.CollectiveTmFormalExpertizePaper,
                DicTariffCodes.TmNmptFormalExpertizeDigital,
                DicTariffCodes.TmNmptFormalExpertizePaper
            };

            if (formalExamTariffCodes.Contains(paymentInvoice?.Tariff?.Code) && paymentInvoice?.Status.Code == DicPaymentStatusCodes.Credited)
            {
                //снятие флага с заявки
                var request = await Executor.GetQuery <GetRequestByIdQuery>()
                              .Process(q => q.ExecuteAsync(requestId));

                request.IsFormalExamFeeNotPaidInTime = false;
                Executor.GetCommand <WorkflowBusinessLogic.Requests.UpdateRequestCommand>().Process(c => c.Execute(request));
            }
        }
コード例 #23
0
ファイル: ImportPaymentsHelper.cs プロジェクト: Hugoberry/WEB
        protected PaymentInvoice CreatePaymentInvoice(WtPlFixpayment oldPaymentInvoice, int requestId)
        {
            try
            {
                var tariffId = GetObjectId <DicTariff>(oldPaymentInvoice.TariffId);

                if (tariffId == null || tariffId == 0)
                {
                    return(null);
                }

                var paymentInvoice = new PaymentInvoice
                {
                    Coefficient    = oldPaymentInvoice.FinePercent,
                    CreateUserId   = GetUserId(oldPaymentInvoice.FlCreateUserId),
                    DateComplete   = GetNullableDate(oldPaymentInvoice.DateComplete),
                    DateCreate     = new DateTimeOffset(oldPaymentInvoice.DateCreate.GetValueOrDefault(DateTime.Now)),
                    DateUpdate     = new DateTimeOffset(oldPaymentInvoice.Stamp.GetValueOrDefault(DateTime.Now)),
                    DateFact       = GetNullableDate(oldPaymentInvoice.DateFact),
                    ExternalId     = oldPaymentInvoice.Id,
                    IsComplete     = GenerateHelper.StringToNullableBool(oldPaymentInvoice.IsComplete),
                    Nds            = oldPaymentInvoice.VatPercent,
                    OverdueDate    = GetNullableDate(oldPaymentInvoice.DateLimit),
                    PenaltyPercent = oldPaymentInvoice.PeniPercent,
                    RequestId      = requestId,
                    StatusId       = GetStatusId(oldPaymentInvoice),
                    TariffCount    = oldPaymentInvoice.TariffCount,
                    TariffId       = tariffId.Value,
                    Timestamp      = BitConverter.GetBytes(DateTime.Now.Ticks),
                    IsDeleted      = false
                };

                return(paymentInvoice);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string         action = Request["action"];
            string         sql    = "";
            DataTable      dt     = null;
            PaymentInvoice piEnt  = null;
            SaleOrder      soEnt  = null;

            switch (action)
            {
            case "loadpaytype":
                sql = @"select name from SysEnumeration where parentid=(select TOP 1 EnumerationID from SysEnumeration WHERE Code = 'PayType') order by sortindex asc ";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "loadbyorderid":
                soEnt = SaleOrder.Find(Request["orderid"]);
                Response.Write("{data:" + JsonHelper.GetJsonString(soEnt) + "}");
                Response.End();
                break;

            case "create":
                soEnt                   = SaleOrder.Find(Request["orderid"]);
                piEnt                   = JsonHelper.GetObject <PaymentInvoice>(Request["formdata"]);
                piEnt.BillType          = "订单";
                piEnt.CorrespondState   = "已对应";
                piEnt.CollectionType    = "销售收款";
                piEnt.Name              = "手动销账";
                piEnt.CorrespondInvoice = soEnt.Number + "_" + soEnt.TotalMoney;
                piEnt.DoCreate();
                //创建完付款单后,更新订单状态
                soEnt.PayState = "已付款";
                soEnt.DoUpdate();
                break;
            }
        }
コード例 #25
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            PaymentInvoice = await Context.PaymentInvoice.Include(c => c.Client).Include(v => v.Vendor).FirstOrDefaultAsync(m => m.PaymentInvoiceID == id);

            if (PaymentInvoice == null)
            {
                return(NotFound());
            }

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, PaymentInvoice,
                EmployeeOperations.Update);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            PopulateRecieverDropDownList(Context, PaymentInvoice.ClientID);
            PopulateReciever2DropDownList(Context, PaymentInvoice.VendorID);

            return(Page());
        }
コード例 #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op  = RequestData.Get <string>("op");
            id  = RequestData.Get <string>("id");
            CId = RequestData.Get <string>("CId");
            switch (RequestActionString)
            {
            case "create":
                ent                = this.GetPostedData <PaymentInvoice>();
                ent.BillType       = "发票";
                ent.CreateId       = UserInfo.UserID;
                ent.CreateName     = UserInfo.Name;
                ent.CreateTime     = DateTime.Now;
                ent.CollectionType = "销售收款";
                ent.DoCreate();
                UpdateOrderInvoice();
                break;

            default:
                DoSelect();
                break;
            }
        }
コード例 #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op  = RequestData.Get <string>("op");
            id  = RequestData.Get <string>("id");
            CId = RequestData.Get <string>("CId");
            switch (RequestActionString)
            {
            case "create":
                ent            = this.GetPostedData <PaymentInvoice>();
                ent.BillType   = "收据";
                ent.CreateId   = UserInfo.UserID;
                ent.CreateName = UserInfo.Name;
                ent.CreateTime = DateTime.Now;
                ent.DoCreate();
                UpdateSaleOrder();
                break;

            case "AutoCorrespond":
                sql = @"select sum(TotalMoney-isnull(DiscountAmount,0)-isnull(ReturnAmount,0)-isnull(ReceiptAmount,0)) 
                    from SHHG_AimExamine..SaleOrders where  CId='" + CId + "' and State is null and InvoiceType='收据' and (PayState is null or PayState='部分付款')";
                decimal TotalArrearage = DataHelper.QueryValue <decimal>(sql);
                if (TotalArrearage >= RequestData.Get <decimal>("PayAmount"))
                {
                    PageState.Add("Result", "T");
                }
                else
                {
                    PageState.Add("Result", "F");
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
コード例 #28
0
        private static Object PaymentInvoiceObj(int customer_id, int type, int pay_method, int invoice_id)
        {
            PaymentInvoice pay_invoice = new PaymentInvoice();

            pay_invoice.customer_id = customer_id;

            if (type == 0)
            {
                pay_invoice.paymethods = (new List <paymethods>()
                {
                    new CreditCard()
                    {
                        creditcard_id = pay_method
                    }
                });
            }
            else if (type == 1)
            {
                pay_invoice.paymethods = (new List <paymethods>()
                {
                    new ACH {
                        ach_id = pay_method
                    }
                });
            }

            pay_invoice.applied_to = (new List <Applied_to>()
            {
                new Applied_to()
                {
                    invoice_id = invoice_id
                }
            });

            return(pay_invoice);
        }
コード例 #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CC = RequestData.Get <string>("CC");
            string ids = RequestData.Get <string>("ids");

            string[] idArray = null;
            if (!string.IsNullOrEmpty(ids))
            {
                idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            }
            switch (RequestActionString)
            {
            case "CancelCorrespond":
                foreach (string str in idArray)    //可以同时对多个付款进行撤销对应
                {
                    piEnt = PaymentInvoice.Find(str);
                    string[] invoiceArray = piEnt.CorrespondInvoice.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < invoiceArray.Length; i++)
                    {
                        int          index  = invoiceArray[i].IndexOf("_");
                        string       number = invoiceArray[i].Substring(0, index); //找到对应的发票号和销账金额 对发票进行回滚
                        decimal      amount = Convert.ToDecimal(invoiceArray[i].Substring(index + 1));
                        OrderInvoice oiEnt  = OrderInvoice.FindAllByProperty(OrderInvoice.Prop_Number, number).FirstOrDefault <OrderInvoice>();
                        oiEnt.PayAmount = oiEnt.PayAmount - amount;
                        oiEnt.PayState  = oiEnt.PayAmount > 0 ? "部分付款" : "";
                        oiEnt.DoUpdate();
                    }
                    piEnt.CorrespondAmount  = 0;
                    piEnt.CorrespondInvoice = "";
                    piEnt.CorrespondState   = "";
                    piEnt.Name = "暂不销账";
                    piEnt.DoUpdate();
                }
                break;

            case "AutoCorrespond":
                foreach (string id in idArray)
                {
                    piEnt = PaymentInvoice.Find(id);
                    sql   = @"select sum(Amount-isnull(PayAmount,0)) from SHHG_AimExamine..OrderInvoice where (PayState is null or PayState<>'已全部付款') and CId='" + piEnt.CId + "'";
                    decimal shouldpayAmount = DataHelper.QueryValue <decimal>(sql);   //合计应付金额
                    if (shouldpayAmount > 0)
                    {
                        decimal validAmount = piEnt.Money.Value - (piEnt.CorrespondAmount.HasValue ? piEnt.CorrespondAmount.Value : 0); //有效金额
                        if (shouldpayAmount >= validAmount)                                                                             //如果 付款金额小于等于应付款总额
                        {
                            sql = @"select * from SHHG_AimExamine..OrderInvoice where (PayState is null or PayState<>'已全部付款') and CId='" + piEnt.CId + "' order by InvoiceDate asc";
                            IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
                            //decimal payamount = piEnt.Money.Value;
                            foreach (EasyDictionary dic in dics)
                            {
                                if (validAmount > 0)
                                {
                                    OrderInvoice oiEnt = OrderInvoice.Find(dic.Get <string>("Id"));
                                    if (validAmount >= (oiEnt.Amount.Value - (oiEnt.PayAmount.HasValue ? oiEnt.PayAmount.Value : 0)))    //大于等于该发票的未付金额
                                    {
                                        validAmount              = validAmount - (oiEnt.Amount.Value - (oiEnt.PayAmount.HasValue ? oiEnt.PayAmount.Value : 0));
                                        oiEnt.PayState           = "已全部付款";
                                        piEnt.CorrespondInvoice += (string.IsNullOrEmpty(piEnt.CorrespondInvoice) ? "" : ",") + oiEnt.Number + "_" + (oiEnt.Amount - (oiEnt.PayAmount.HasValue ? oiEnt.PayAmount.Value : 0));
                                        oiEnt.PayAmount          = oiEnt.Amount;
                                    }
                                    else
                                    {
                                        oiEnt.PayAmount          = (oiEnt.PayAmount.HasValue ? oiEnt.PayAmount.Value : 0) + validAmount;
                                        oiEnt.PayState           = "部分付款";
                                        piEnt.CorrespondInvoice += (string.IsNullOrEmpty(piEnt.CorrespondInvoice) ? "" : ",") + oiEnt.Number + "_" + validAmount;
                                        validAmount              = 0;
                                    }
                                    oiEnt.DoUpdate();
                                }
                            }
                            piEnt.CorrespondAmount = piEnt.Money;
                            piEnt.CorrespondState  = "已对应";
                            piEnt.Name             = "自动销账";
                            piEnt.DoUpdate();
                        }
                        else     //如果付款金额大于应付款总金额
                        {
                            sql = @"select * from SHHG_AimExamine..OrderInvoice where (PayState is null or PayState<>'已全部付款') and CId='" + piEnt.CId + "' order by InvoiceDate asc";
                            IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
                            foreach (EasyDictionary dic in dics)
                            {
                                OrderInvoice oiEnt = OrderInvoice.Find(dic.Get <string>("Id"));
                                piEnt.CorrespondInvoice += (string.IsNullOrEmpty(piEnt.CorrespondInvoice) ? "" : ",") + oiEnt.Number + "_" + (oiEnt.Amount - (oiEnt.PayAmount.HasValue ? oiEnt.PayAmount.Value : 0));
                                piEnt.CorrespondState    = "部分对应";
                                piEnt.CorrespondAmount   = (piEnt.CorrespondAmount.HasValue ? piEnt.CorrespondAmount.Value : 0) + shouldpayAmount;
                                piEnt.DoUpdate();
                                oiEnt.PayState  = "已全部付款";
                                oiEnt.PayAmount = oiEnt.Amount;
                                oiEnt.DoUpdate();
                            }
                        }
                    }
                }
                break;

            case "delete":
                foreach (string str in idArray)
                {
                    piEnt = PaymentInvoice.Find(str);
                    piEnt.DoDelete();
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
コード例 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ids = RequestData.Get <string>("ids");

            string[] idArray = null;
            if (!string.IsNullOrEmpty(ids))
            {
                idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            }
            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                piEnt = PaymentInvoice.Find(id);
            }
            switch (RequestActionString)
            {
            case "CancelCorrespond":
                foreach (string str in idArray)    //可以同时对多个付款进行撤销对应
                {
                    piEnt = PaymentInvoice.Find(str);
                    string[] invoiceArray = piEnt.CorrespondInvoice.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < invoiceArray.Length; i++)
                    {
                        int       index  = invoiceArray[i].IndexOf("_");
                        string    number = invoiceArray[i].Substring(0, index);  //找到对应的发票号和销账金额 对发票进行回滚
                        decimal   amount = Convert.ToDecimal(invoiceArray[i].Substring(index + 1));
                        SaleOrder oiEnt  = SaleOrder.FindAllByProperty(SaleOrder.Prop_Number, number).FirstOrDefault <SaleOrder>();
                        oiEnt.ReceiptAmount = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) - amount;
                        oiEnt.PayState      = oiEnt.ReceiptAmount > 0 ? "部分付款" : null;
                        oiEnt.DoUpdate();
                    }
                    piEnt.CorrespondInvoice = "";
                    piEnt.CorrespondState   = "";
                    piEnt.Name = "暂不销账";
                    piEnt.DoUpdate();
                }
                break;

            case "AutoCorrespond":
                sql = @"select sum(TotalMoney-isnull(DiscountAmount,0)-isnull(ReturnAmount,0)-isnull(ReceiptAmount,0)) 
                    from SHHG_AimExamine..SaleOrders where  CId='" + piEnt.CId + "' and State is null and InvoiceType='收据' and (PayState is null or PayState='部分付款')";
                decimal TotalArrearage = DataHelper.QueryValue <decimal>(sql);
                if (TotalArrearage >= piEnt.Money)
                {
                    sql = @"select * from SHHG_AimExamine..SaleOrders  where InvoiceType='收据' and 
                          CId='" + piEnt.CId + "' and State is null and (PayState is null or PayState='部分付款') order by CreateTime asc";
                    IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
                    decimal payamount           = piEnt.Money.Value;
                    piEnt.CorrespondInvoice = "";
                    foreach (EasyDictionary dic in dics)
                    {
                        if (payamount > 0)
                        {
                            SaleOrder oiEnt       = SaleOrder.Find(dic.Get <string>("Id"));
                            decimal   unpayAmount = oiEnt.TotalMoney.Value - (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) -
                                                    (oiEnt.DiscountAmount.HasValue ? oiEnt.DiscountAmount.Value : 0) - (oiEnt.ReturnAmount.HasValue ? oiEnt.ReturnAmount.Value : 0);
                            if (payamount >= unpayAmount)
                            {
                                payamount                = payamount - unpayAmount;
                                oiEnt.ReceiptAmount      = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + unpayAmount;
                                oiEnt.PayState           = "已全部付款";
                                piEnt.CorrespondInvoice += oiEnt.Number + "_" + unpayAmount + ",";
                            }
                            else
                            {
                                oiEnt.ReceiptAmount      = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + payamount;
                                piEnt.CorrespondInvoice += oiEnt.Number + "_" + payamount + ",";
                                payamount = 0;
                            }
                            oiEnt.DoUpdate();
                        }
                    }
                    piEnt.CorrespondState = "已对应";
                    piEnt.Name            = "自动销账";
                    piEnt.DoUpdate();
                    PageState.Add("Result", "T");
                }
                else
                {
                    PageState.Add("Result", "F");
                }
                break;

            case "delete":
                foreach (string str in idArray)
                {
                    piEnt = PaymentInvoice.Find(str);
                    piEnt.DoDelete();
                }
                break;

            default:
                DoSelect();
                break;
            }
        }