Exemplo n.º 1
0
        public async Task DeleteReclaimsForPackage(Guid packageId, ReclaimType reclaimType)
        {
            var reclaims = await _dbContext.CarePackageReclaims
                           .Where(pr => pr.CarePackageId.Equals(packageId) && pr.Type.Equals(reclaimType)).ToListAsync();

            _dbContext.CarePackageReclaims.RemoveRange(reclaims);
        }
        private void AddReclaim(decimal cost, ReclaimType type, ClaimCollector collector)
        {
            var reclaim = new CarePackageReclaim
            {
                Cost    = cost,
                Type    = type,
                SubType = type is ReclaimType.Fnc
                    ? ReclaimSubType.FncPayment
                    : ReclaimSubType.CareChargeProvisional,
                ClaimCollector = collector,
                StartDate      = _startDate,
                EndDate        = _endDate,
                Status         = ReclaimStatus.Active
            };

            _package.Reclaims.Add(reclaim);

            if (type is ReclaimType.Fnc)
            {
                var fncReclaim = reclaim.DeepCopy();

                fncReclaim.Cost    = Decimal.Negate(reclaim.Cost);
                fncReclaim.SubType = ReclaimSubType.FncReclaim;

                _package.Reclaims.Add(fncReclaim);
            }
        }
Exemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            ReclaimType reclaimType = db.ReclaimType.Find(id);

            db.ReclaimType.Remove(reclaimType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task ShouldConsiderReclaimCollector(ReclaimType reclaimType, ClaimCollector collector, decimal totalWeeklyCost)
        {
            AddCoreCost(100);
            AddReclaim(20, reclaimType, collector);

            var summary = await _useCase.ExecuteAsync(_package.Id);

            summary.TotalWeeklyCost.Should().Be(totalWeeklyCost);
        }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "IdReclaimType,Name")] ReclaimType reclaimType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reclaimType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(reclaimType));
 }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "IdReclaimType,Name")] ReclaimType reclaimType)
        {
            if (ModelState.IsValid)
            {
                db.ReclaimType.Add(reclaimType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(reclaimType));
        }
        public CarePackageReclaim CreateCarePackageReclaim(
            CarePackage package, ClaimCollector collector,
            ReclaimType type, ReclaimSubType subType = ReclaimSubType.CareCharge13PlusWeeks)
        {
            var reclaim = TestDataHelper.CreateCarePackageReclaim(package.Id, collector, type, subType);

            _context.CarePackageReclaims.Add(reclaim);
            _context.SaveChanges();

            return(reclaim);
        }
Exemplo n.º 8
0
        // GET: ReclaimTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReclaimType reclaimType = db.ReclaimType.Find(id);

            if (reclaimType == null)
            {
                return(HttpNotFound());
            }
            return(View(reclaimType));
        }
Exemplo n.º 9
0
 public static CarePackageReclaim CreateCarePackageReclaim(Guid packageId, ClaimCollector collector,
                                                           ReclaimType type, ReclaimSubType subType)
 {
     return(new Faker <CarePackageReclaim>()
            .RuleFor(r => r.CarePackageId, packageId)
            .RuleFor(r => r.Cost,
                     f => Math.Round(f.Random.Decimal(0m, 1000m), 2)) // Workaround to avoid precision loss in SQLite)
            .RuleFor(r => r.StartDate, f => f.Date.Past().Date)
            .RuleFor(r => r.EndDate, f => f.Date.Future().Date)
            .RuleFor(r => r.Description, f => f.Lorem.Paragraph())
            .RuleFor(r => r.ClaimCollector, collector)
            .RuleFor(r => r.Type, type)
            .RuleFor(r => r.Status, ReclaimStatus.Active)
            .RuleFor(r => r.SubType, subType));
 }
Exemplo n.º 10
0
 public static CarePackageReclaim CreateCarePackageReclaim(
     Guid packageId, ReclaimType type, ReclaimSubType subType, ClaimCollector?collector,
     decimal?cost, DateTimeOffset?startDate, DateTimeOffset?endDate)
 {
     return(new Faker <CarePackageReclaim>()
            .RuleFor(r => r.Id, Guid.NewGuid)
            .RuleFor(r => r.CarePackageId, packageId)
            .RuleFor(r => r.Cost, f => cost ?? f.Random.Decimal(0m, 1000m).Round(2))
            .RuleFor(r => r.StartDate, f => startDate ?? f.Date.Past(1, DateTime.Now.AddDays(-1)).Date)
            .RuleFor(d => d.EndDate,
                     f => endDate != DateTimeOffset.MaxValue // use DateTimeOffset.MaxValue to create an ongoing reclaim
                 ? endDate ?? f.Date.Future(1, DateTime.Now.AddDays(1)).Date
                 : null as DateTimeOffset?)
            .RuleFor(r => r.Description, f => f.Lorem.Paragraph())
            .RuleFor(r => r.ClaimCollector, f => collector ?? f.PickRandom <ClaimCollector>())
            .RuleFor(r => r.Type, type)
            .RuleFor(r => r.Status, ReclaimStatus.Active)
            .RuleFor(r => r.SubType, subType));
 }
        public async Task <CarePackageReclaimDomain> GetSingleAsync(Guid carePackageId, ReclaimType reclaimType, ReclaimSubType?reclaimSubType)
        {
            var carePackageReclaim = await _dbContext.CarePackageReclaims
                                     .Where(reclaim =>
                                            reclaim.CarePackageId.Equals(carePackageId) &&
                                            reclaim.Type.Equals(reclaimType) &&
                                            (reclaimSubType == null || reclaim.SubType == reclaimSubType))
                                     .FirstOrDefaultAsync();

            return(carePackageReclaim?.ToDomain());
        }
Exemplo n.º 12
0
        public ExcelPackageModel(string elementType)
        {
            _costPeriod = PaymentPeriod.Weekly;

            if (_corePackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType  = ExcelPackageType.Detail;
                _packageDetailType = PackageDetailType.CoreCost;
            }
            else if (_anpPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType  = ExcelPackageType.Detail;
                _packageDetailType = PackageDetailType.AdditionalNeed;
            }
            else if (_careChargeProvisionalNetPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType = ExcelPackageType.Reclaim;
                _reclaimSubType   = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.CareChargeProvisional;
                _reclaimType      = ReclaimType.CareCharge;
                _claimCollector   = ClaimCollector.Supplier;
            }
            else if (_careChargeProvisionalGrossPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType = ExcelPackageType.Reclaim;
                _reclaimSubType   = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.CareChargeProvisional;
                _reclaimType      = ReclaimType.CareCharge;
                _claimCollector   = ClaimCollector.Hackney;
            }
            else if (_careCharge13PlusNetPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType = ExcelPackageType.Reclaim;
                _reclaimSubType   = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.CareCharge13PlusWeeks;
                _reclaimType      = ReclaimType.CareCharge;
                _claimCollector   = ClaimCollector.Supplier;
            }
            else if (_careCharge13PlusGrossPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType = ExcelPackageType.Reclaim;
                _reclaimSubType   = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.CareCharge13PlusWeeks;
                _reclaimType      = ReclaimType.CareCharge;
                _claimCollector   = ClaimCollector.Hackney;
            }
            else if (_anpOneOffPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType  = ExcelPackageType.Detail;
                _packageDetailType = PackageDetailType.AdditionalNeed;
                _costPeriod        = PaymentPeriod.OneOff;
            }
            else if (_fncGrossPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType = ExcelPackageType.Reclaim;
                _reclaimSubType   = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.FncReclaim;
                _reclaimType      = ReclaimType.Fnc;
                _claimCollector   = ClaimCollector.Hackney;
            }
            else if (_fncNetPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase))
            {
                _excelPackageType = ExcelPackageType.Reclaim;
                _reclaimSubType   = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.FncPayment;
                _reclaimType      = ReclaimType.Fnc;
                _claimCollector   = ClaimCollector.Supplier;
            }
            else
            {
                throw new Exception($"Undefined element type: {elementType}");
            }
        }
        public async Task <CarePackageReclaimResponse> CreateProvisionalCareCharge(CarePackageReclaimCreationDomain reclaimCreationDomain, ReclaimType reclaimType)
        {
            var carePackage = await _carePackageGateway
                              .GetPackageAsync(reclaimCreationDomain.CarePackageId, PackageFields.Details | PackageFields.Reclaims, true)
                              .EnsureExistsAsync($"Care package with id {reclaimCreationDomain.CarePackageId} not found");

            if (carePackage.Status.In(PackageStatus.Cancelled, PackageStatus.Ended))
            {
                throw new ApiException($"Can not create {reclaimType.GetDisplayName()} for care package status {carePackage.Status.GetDisplayName()}",
                                       HttpStatusCode.BadRequest);
            }

            var coreCostDetail = carePackage.Details
                                 .FirstOrDefault(d => d.Type is PackageDetailType.CoreCost)
                                 .EnsureExists($"Core cost for package with id {reclaimCreationDomain.CarePackageId} not found", HttpStatusCode.InternalServerError);

            ValidateProvisionalCareChargeAsync(reclaimCreationDomain, carePackage, coreCostDetail);

            //todo FK: ?
            reclaimCreationDomain.SubType = ReclaimSubType.CareChargeProvisional;
            var newReclaim = reclaimCreationDomain.ToEntity();

            //todo FK: ?
            newReclaim.Type       = ReclaimType.CareCharge;
            newReclaim.Status     = ReclaimStatus.Active;
            newReclaim.Subjective = SubjectiveConstants.CareChargeReclaimSubjectiveCode;

            carePackage.Reclaims.Add(newReclaim);

            carePackage.Histories.Add(new CarePackageHistory
            {
                Description = $"{reclaimType.GetDisplayName()} {reclaimCreationDomain.SubType.GetDisplayName()} Created",
            });

            // Change status of package to submitted for approval
            if (carePackage.Status == PackageStatus.Approved)
            {
                carePackage.Status = PackageStatus.SubmittedForApproval;
            }

            await _dbManager.SaveAsync("Could not save care package reclaim to database");

            return(newReclaim.ToDomain().ToResponse());
        }
Exemplo n.º 14
0
 public async Task <List <CarePackageReclaim> > GetCarePackageReclaimsAsync(Guid packageId, ReclaimType type, ReclaimSubType?subType = null,
                                                                            bool trackChanges = false)
 {
     return(await _dbContext.CarePackageReclaims
            .Where(pr => pr.CarePackageId.Equals(packageId) && pr.Type.Equals(type) &&
                   (subType == null || pr.SubType.Equals(subType))).TrackChanges(trackChanges)
            .ToListAsync());
 }