public PatientBillPaymentReportResponeModel GetPatientBillPaymentReport(PatientBillPaymentReportResponeModel model)
        {
            if (model.FromDate == null || model.ToDate == null)
            {
                throw new Exception("Please enter proper date range");
            }

            model.Users        = usersRepository.GetAll().ToList();
            model.PaymentTypes = fieldOptionsRepository.GetAll().ToList()?.FindAll(x => x.FieldId == 4);

            var billPayments = billPaymentRepository.GetAll().ToList()?.FindAll(x => x.PaymentDate >= model.FromDate && x.PaymentDate <= model.ToDate);

            if (billPayments != null)
            {
                model.BillPayments = new List <PatientBillPaymentReportDto>();
                foreach (var billPayment in billPayments)
                {
                    var item = new PatientBillPaymentReportDto();
                    item.BillPaymentId   = billPayment.Id;
                    item.ReceiptNo       = (int)billPayment.ReceiptNo;
                    item.CardMode        = (bool)billPayment.CardMode;
                    item.ChequeMode      = (bool)billPayment.ChequeMode;
                    item.CashMode        = (bool)billPayment.CashMode;
                    item.PaymentDate     = billPayment.PaymentDate.Value;
                    item.PaymentTypeId   = billPayment.PaymentType;
                    item.BillPaymentType = fieldOptionsRepository.Get(billPayment.PaymentType);
                    item.Amount          = (float)billPayment.PaymentAmount;
                    item.PaidBy          = billPayment.BillPaidBy;
                    item.EntryDoneBy     = billPayment.ModifiedBy;

                    var bill    = patientBillRepository.Get(billPayment.BillId);
                    var patient = patientRepository.Get(bill.PatientId);
                    if (patient != null)
                    {
                        item.PatientCode = patient.PatientCode;
                        item.PatientName = patient.FirstName + " " + patient.LastName;
                        item.PatientId   = patient.Id;
                    }
                    model.BillPayments.Add(item);
                }
            }

            return(model);
        }
        public ActionResult GetPatientBillPaymentReport(PatientBillPaymentReportResponeModel requestModel)
        {
            try
            {
                var resposeModel = financeService.GetPatientBillPaymentReport(requestModel);

                if (resposeModel != null)
                {
                    return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, resposeModel)));
                }
                else
                {
                    return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No bills found", "Something went wrong!"))));
                }
            }
            catch (Exception e)
            {
                Program.Logger.Error(e);
                return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", e.Message))));
            }
        }
        public async Task <PatientBillPaymentReportResponeModel> GetPatientBillPaymentReport(PatientBillPaymentReportResponeModel model)
        {
            var url = URLBuilder.GetURL(Controllers.FINANCE, EndPoint.FINANCE_PATIENT_BILL_PAYMENT_REPORT);

            return(await requestProvider.PostAsync(url, model));
        }