protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { var providerPeriod = (ProviderEarnedPeriodValue)period; var specPeriod = providerPeriod.PeriodName.ToPeriodDateTime().AddMonths(-1).ToPeriodName(); return($"Expected {providerPeriod.ProviderId} to be paid {period.Value} in {specPeriod} for completion framework uplift but was actually paid {actualPaymentInPeriod}"); }
protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { var employerPeriod = (EmployerAccountPeriodValue)period; var specPeriod = period.PeriodName.ToPeriodDateTime().AddMonths(1).ToPeriodName(); return($"Expected provider to be paid {period.Value} by employer {employerPeriod.EmployerAccountId} in {specPeriod} but actually paid {actualPaymentInPeriod}"); }
protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { var employerPeriod = (EmployerAccountPeriodValue)period; var specPeriod = period.PeriodName.ToPeriodDateTime().AddMonths(1).ToPeriodName(); return($"Expected Employer transactions net for {employerPeriod.EmployerAccountId} expected to be {period.Value} in {specPeriod} but was actually {actualPaymentInPeriod}"); }
protected void AssertResultsForPeriod(PeriodValue period, PaymentResult[] allPayments) { var paidInPeriod = allPayments.Where(p => p.CalculationPeriod == period.PeriodName).Sum(p => p.Amount); if (!AreValuesEqual(period.Value, paidInPeriod)) { throw new Exception(FormatAssertionFailureMessage(period, paidInPeriod)); } }
public static Int64 schedule(Object callback, DateTimeOffset executeAt, PeriodValue repeatEvery, String jobName) { if (callback is ClosureValue) { return(schedule((ClosureValue)callback, executeAt, repeatEvery, jobName)); } else { throw new Exception("Should never get there!"); } }
protected override IEnumerable <PaymentResult> FilterPayments(PeriodValue period, IEnumerable <LearnerResults> submissionResults, EmployerAccountContext employerAccountContext) { var employerPeriod = (EmployerAccountProviderPeriodValue)period; var employer = employerAccountContext.EmployerAccounts.SingleOrDefault(a => a.Id == employerPeriod.EmployerAccountId); var isDasEmployer = employer?.IsDasEmployer ?? false; var earningPeriod = employerPeriod.PeriodName.ToPeriodDateTime().AddMonths(-1).ToPeriodName(); return(submissionResults.Where(l => l.ProviderId.Equals(employerPeriod.ProviderId, System.StringComparison.CurrentCultureIgnoreCase)) .SelectMany(r => r.Payments).Where(p => (p.EmployerAccountId == employerPeriod.EmployerAccountId || !isDasEmployer && p.EmployerAccountId == 0) && p.DeliveryPeriod == earningPeriod && (p.TransactionType == TransactionType.First16To18EmployerIncentive || p.TransactionType == TransactionType.Second16To18EmployerIncentive))); }
protected override IEnumerable <PaymentResult> FilterPayments(PeriodValue period, IEnumerable <LearnerResults> submissionResults, EmployerAccountContext employerAccountContext) { var providerPeriod = (ProviderEarnedPeriodValue)period; var earnedPeriod = GetPaymentFilterPeriodName(providerPeriod); var providerPaymentsInPeriod = submissionResults.Where(r => r.ProviderId.Equals(providerPeriod.ProviderId, StringComparison.CurrentCultureIgnoreCase)) .SelectMany(r => r.Payments) .Where(p => p.DeliveryPeriod == earnedPeriod && p.FundingSource != FundingSource.CoInvestedEmployer); return(FilterPeriodPayments(providerPaymentsInPeriod)); }
private void AssertResultsForPeriod(PeriodValue period, LearnerEarningsResult[] allEarnings) { var earnedInPeriod = (from e in allEarnings where e.DeliveryPeriod == period.PeriodName group e by e.LearnerId into g select g.First()).Sum(x => x.Value); if (!AreValuesEqual(period.Value, earnedInPeriod)) { throw new Exception($"Expected provider to earn {period.Value} in {period.PeriodName} but actually earned {earnedInPeriod}"); } }
private void AssertResultsForPeriod(PeriodValue period, LearnerEarningsResult[] allEarnings) { // This is not picking correct earning when price changed mid-year and the change period it the one we care about. var earnedInPeriod = (from e in allEarnings where e.DeliveryPeriod == period.PeriodName && ComparePeriods(e.CalculationPeriod, period.PeriodName) >= 0 group e by e.LearnerReferenceNumber into g select g.First()).Sum(x => x.Value); if (!AreValuesEqual(period.Value, earnedInPeriod)) { throw new Exception($"Expected provider to earn {Math.Round(period.Value, 2)} in {period.PeriodName} but actually earned {Math.Round(earnedInPeriod, 2)}"); } }
public override void AssertBreakdown(EarningsAndPaymentsBreakdown breakdown, IEnumerable <LearnerResults> submissionResults, EmployerAccountContext employerAccountContext) { var allPayments = GetPaymentsForBreakdown(breakdown, submissionResults) .Where(p => p.FundingSource != FundingSource.CoInvestedEmployer && p.Amount > 0) .ToArray(); foreach (var period in breakdown.ProviderPaidBySfa) { var prevPeriod = new PeriodValue { PeriodName = period.PeriodName.ToPeriodDateTime().AddMonths(-1).ToPeriodName(), Value = period.Value }; AssertResultsForPeriod(prevPeriod, allPayments); } }
public override IValue interpret(Context context) { IValue val = expression.interpret(context); if (val is IntegerValue) { return(new IntegerValue(-((IntegerValue)val).LongValue)); } else if (val is DecimalValue) { return(new DecimalValue(-((DecimalValue)val).DoubleValue)); } else if (val is PeriodValue) { PeriodValue p = (PeriodValue)val; return(new PeriodValue(-p.Years, -p.Months, -p.Weeks, -p.Days, -p.Hours, -p.Minutes, -p.Seconds, -p.Millis)); } else { throw new SyntaxError("Illegal: - " + val.GetType().Name); } }
protected abstract IEnumerable <PaymentResult> FilterPayments(PeriodValue period, IEnumerable <LearnerResults> submissionResults, EmployerAccountContext employerAccountContext);
protected abstract string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod);
public static Int64 schedule(ClosureValue callback, DateTimeOffset executeAt, PeriodValue repeatEvery, String jobName) { long delayInMillis = (executeAt.Ticks - DateTime.Now.Ticks) / 10000; // 1 tick = 100 nanosecond if (delayInMillis < 0) { delayInMillis = 0; } long periodInMillis = repeatEvery == null ? -1L : repeatEvery.TotalMilliseconds(); Int64 jobId = Interlocked.Increment(ref JOB_COUNTER); TimerCallback timer = state => HandleCallback(callback, repeatEvery == null ? jobId : (Int64?)null); JOB_TIMERS[jobId] = new Timer(timer, null, delayInMillis, periodInMillis); return(jobId); }
protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { var employerPeriod = (ProviderEarnedPeriodValue)period; return($"Expected provider {employerPeriod.ProviderId} to earn {period.Value} in {period.PeriodName} for completion but was actually earned {actualPaymentInPeriod}"); }
protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { return($"Expected SFA Levy co funded budget to be debited {period.Value} in {period.PeriodName} but was actually debited {actualPaymentInPeriod}"); }
private void TestOne(String s) { PeriodValue period = PeriodValue.Parse(s); Assert.AreEqual(s, period.ToString()); }
protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { var specPeriod = period.PeriodName.ToPeriodDateTime().AddMonths(1).ToPeriodName(); return($"Expected provider to refund taken {period.Value} by SFA in {specPeriod} but actually refunded {actualPaymentInPeriod}"); }
protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { return($"Expected SFA non Levy additional payment of {period.Value} in {period.PeriodName} but was actually {actualPaymentInPeriod}"); }
protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { var employerPeriod = (EmployerAccountPeriodValue)period; return($"Expected Employer {employerPeriod.EmployerAccountId} to be paid {period.Value} in {period.PeriodName} for 16-18 incentive but was actually paid {actualPaymentInPeriod}"); }
protected override string FormatAssertionFailureMessage(PeriodValue period, decimal actualPaymentInPeriod) { var providerPeriod = (ProviderEarnedPeriodValue)period; return($"Expected {providerPeriod.ProviderId} to be paid {period.Value} in {period.PeriodName} for learning support but was actually paid {actualPaymentInPeriod}"); }