コード例 #1
0
ファイル: InvoiceService.cs プロジェクト: tczhd/SMLYS
        private InvoiceSpecification GetInvoiceSpecification(InvoiceSearchDataModel searchModel, bool IsCount)
        {
            var invoiceSpecification = new InvoiceSpecification(_clinicId);
            if (searchModel.DisplayId != null && searchModel.DisplayId > 0)
            {
                invoiceSpecification.AddDisplayId((int)searchModel.DisplayId);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.FirstName))
            {
                invoiceSpecification.AddFirstName(searchModel.FirstName);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.LastName))
            {
                invoiceSpecification.AddFirstName(searchModel.LastName);
            }
            if (searchModel.InvoiceFromDate != null)
            {
                invoiceSpecification.AddFromDate((DateTime)searchModel.InvoiceFromDate);
            }
            if (searchModel.InvoiceToDate != null)
            {
                invoiceSpecification.AddToDate((DateTime)searchModel.InvoiceToDate);
            }

            if (!IsCount)
            {
                invoiceSpecification.AddPagination(searchModel.CurrentPage, searchModel.PageSize);
            }

            return invoiceSpecification;
        }
コード例 #2
0
ファイル: InvoiceService.cs プロジェクト: tczhd/SMLYS
        public InvoiceModel SearchInvoice(int invoiceId)
        {
            var invoiceDetailSpecification = new InvoiceSpecification(_clinicId);
            invoiceDetailSpecification.AddDisplayId(invoiceId);
            var data = _invoiceRepository.GetSingleBySpec(invoiceDetailSpecification);

            return data !=null?data:null;
        }
コード例 #3
0
        public IEnumerable <InvoiceDto> GetInvoices(string staff, string supplier, int costFrom, int costTo, int pageIndex, int pageSize, out int count)
        {
            InvoiceSpecification spec  = new InvoiceSpecification(staff, supplier, costFrom, costTo, pageIndex, pageSize);
            InvoiceSpecification spec1 = new InvoiceSpecification(staff, supplier, costFrom, costTo);

            var product = _unitOfWork.Invoices.Find(spec);

            count = _unitOfWork.Invoices.Count(spec1);
            return(_mapper.Map <IEnumerable <Invoice>, IEnumerable <InvoiceDto> >(product));
        }
コード例 #4
0
        public async Task GetInvoices_Should_GetInvoices(InvoiceSpecification invoiceSpecification, int index, int pageSize, int count)
        {
            _repository.Setup(s => s.GetListAsync(It.IsAny <Expression <Func <Invoice, bool> > >(), It.IsAny <Func <IQueryable <Invoice>, IOrderedQueryable <Invoice> > >(), It.IsAny <Expression <Func <Invoice, object> > >()))
            .ReturnsAsync(DataSeed.Invoices.AsQueryable().Where(invoiceSpecification));
            IPageResult <Invoice> invoices = await _invoiceService.GetInvoices(invoiceSpecification, index, pageSize);

            Assert.NotNull(invoices);
            Assert.Equal(count, invoices.Total);
            int pageCount = count - pageSize * index;

            Assert.Equal(pageCount >= pageSize ? pageSize : (pageCount > 0 ? count : 0), invoices.Data.Count());
        }
コード例 #5
0
        public async Task <IPageResult <Invoice> > GetInvoices(InvoiceSpecification invoiceSpecification, int index, int pageSize)
        {
            var list = await _invoiceRepository.GetListAsync(invoiceSpecification, null, i => i.InvoiceItems);

            return(new PageResult <Invoice>(list, index, pageSize));
        }
コード例 #6
0
 public IQueryable <Invoice> BuildQuery(InvoiceSpecification specification, IQueryable <Creditor> query)
 {
     // method logic here
 }
コード例 #7
0
        public PaymentResultModel ApplyPayment(PaymentDataModel requestMdoel)
        {
            var result = new PaymentResultModel();

            var userContext = _userHandler.GetUserContext();
            var invoiceDetailSpecification = new InvoiceSpecification(_clinicId);

            invoiceDetailSpecification.AddInvoiceId(requestMdoel.InvoiceId);
            var invoice = _invoiceRepository.GetSingleBySpec(invoiceDetailSpecification);

            if (invoice != null)
            {
                var payementResult = _stripePaymentService.ProcessPayment((StripeBasicRequestModel)requestMdoel);
                result = payementResult;
                var cardLast4 = requestMdoel.CreditCard.GetCardF4L4();
                result.CardLast4 = cardLast4;

                if (payementResult.Success && payementResult.Approved)
                {
                    var payment = new Payment
                    {
                        ClinicId            = _clinicId,
                        Description         = requestMdoel.Note,
                        PaymentDate         = DateTime.UtcNow,
                        PaymentMethodTypeId = (int)PaymentMethodType.Visa,
                        PaymentStatusTypeId = (int)requestMdoel.PaymentStatusType,
                        PaymentTypeId       = (int)requestMdoel.PaymentType,
                        UpdatedBy           = userContext.SiteUserId,
                        UpdatedDateUtc      = DateTime.UtcNow,
                        Amount            = requestMdoel.PaymentAmount,
                        TransactionId     = payementResult.TransactionId,
                        AuthorizationCode = payementResult.AuthCode,
                        CardToken         = payementResult.CardToken,
                        CardF4L4          = cardLast4
                    };

                    var invoicePayment = new InvoicePayment
                    {
                        AmountPaid = requestMdoel.PaymentAmount,
                        InvoiceId  = requestMdoel.InvoiceId,
                        Payment    = payment,
                        Note       = requestMdoel.Note
                    };

                    _invoicePaymentRepository.AddOnly(invoicePayment);

                    var patientCardOnFile = new PatientCardOnFile {
                        Active         = true,
                        CardF4L4       = requestMdoel.CreditCard.GetCardF4L4(),
                        CardToken      = payementResult.CardToken,
                        UpdatedDateUtc = DateTime.UtcNow,
                        PatientId      = invoice.PatientId,
                        UpdatedBy      = userContext.SiteUserId
                    };

                    _patientCardOnFileRepository.AddOnly(patientCardOnFile);

                    invoice.AmountPaid += requestMdoel.PaymentAmount;

                    _invoicePaymentRepository.SaveAll();

                    result.AmountPaidTotal = invoice.AmountPaid;
                }
                else
                {
                    result.Message = "Process payment failed. ";
                }
            }
            else
            {
                result.Message = "Invalid invoice Id, Please choose right one and try again. ";
            }

            return(result);
        }