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);
            }
        }
        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);
        }
        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);
        }
 public static decimal GetFncReclaimCost(this CarePackage package, ClaimCollector collector, DateTimeOffset?targetDate = null)
 {
     return(package.Reclaims
            .FirstOrDefault(reclaim =>
                            reclaim.Type is ReclaimType.Fnc &&
                            reclaim.SubType is ReclaimSubType.FncReclaim &&
                            reclaim.ClaimCollector == collector &&
                            reclaim.Status != ReclaimStatus.Cancelled &&
                            (targetDate is null || targetDate.Value.IsInRange(reclaim.StartDate, reclaim.EndDate ?? DateTimeOffset.MaxValue)))?
            .Cost ?? 0.0m);
 }
        public async Task ShouldFillReclaimsSubTotals(
            ClaimCollector fncCollector, ClaimCollector careChargesCollector, decimal hackneySubTotal, decimal supplierSubTotal)
        {
            AddCoreCost(100.0m);
            AddReclaim(10.0m, ReclaimType.Fnc, fncCollector);
            AddReclaim(30.0m, ReclaimType.CareCharge, careChargesCollector);
            AddReclaim(50.0m, ReclaimType.CareCharge, careChargesCollector);

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

            summary.HackneyReclaims?.SubTotal.Should().Be(hackneySubTotal);
            summary.SupplierReclaims?.SubTotal.Should().Be(supplierSubTotal);
        }
예제 #6
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));
 }
예제 #7
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}");
            }
        }
예제 #8
0
        private void FillReclaimsForCollector(CarePackageSummaryReclaimsDomain reclaimTotals, ClaimCollector collector)
        {
            reclaimTotals.Fnc        = Math.Abs(_package.GetFncReclaimCost(collector, DateTimeOffset.UtcNow));
            reclaimTotals.CareCharge = _package.GetCareChargesCost(collector, DateTimeOffset.UtcNow);

            reclaimTotals.SubTotal = reclaimTotals.Fnc + reclaimTotals.CareCharge;
        }
예제 #9
0
 public static InvoiceItem CreateInvoiceItem(Invoice invoice, DateTimeOffset fromDate, DateTimeOffset toDate,
                                             decimal weeklyCost      = 2m, decimal quantity = 1m, ClaimCollector claimCollector = ClaimCollector.Hackney,
                                             PriceEffect priceEffect = PriceEffect.Add)
 {
     return(new Faker <InvoiceItem>()
            .RuleFor(invItem => invItem.Id, f => f.Random.Uuid())
            .RuleFor(invItem => invItem.Name, f => f.Random.Words(3))
            .RuleFor(invItem => invItem.InvoiceId, invoice.Id)
            .RuleFor(invItem => invItem.WeeklyCost, weeklyCost)
            .RuleFor(invItem => invItem.Quantity, quantity)
            .RuleFor(invItem => invItem.FromDate, fromDate)
            .RuleFor(invItem => invItem.ToDate, toDate)
            .RuleFor(invItem => invItem.ClaimCollector, claimCollector)
            .RuleFor(invItem => invItem.PriceEffect, priceEffect));
 }