public static (FeeStatus FeeStatus, Fee Fee) GetTrainingFee(this MemberUser user) { if (user.HasPayedTrainingFeeThisSemester()) { return(FeeStatus.Paid, null); } if (user.ExemptFromTrainingFee) { return(FeeStatus.Unpayable, null); } if (user.HasPayedMembershipThisYear()) { return( FeeStatus.Unpaid, new Fee("Treningsavgift", TrainingFee, includesTraining: true) ); } return( FeeStatus.Unpaid, new Fee("Medlemskap og treningsavgift", MembershipFee + TrainingFee, includesMembership: true, includesTraining: true) ); }
public void TestNoPayments() { var user = new MemberUser(); user.HasPayedMembershipThisYear().ShouldBeFalse(); user.HasPayedTrainingFeeThisSemester().ShouldBeFalse(); user.HasPayedClassesFeeThisSemester().ShouldBeFalse(); }
public void TestPaidLastYear() { var user = new MemberUser { Payments = { Payment(paidAt: TimeProvider.UtcNow.AddYears(-1), membership: true, training: true, classes: true) } }; user.HasPayedMembershipThisYear().ShouldBeFalse(); user.HasPayedTrainingFeeThisSemester().ShouldBeFalse(); user.HasPayedClassesFeeThisSemester().ShouldBeFalse(); }
public void TestPaidExemptFromFees() { using (TemporaryTime.Is(new DateTime(2019, 10, 2))) { var user = new MemberUser { ExemptFromClassesFee = true, ExemptFromTrainingFee = true }; user.HasPayedMembershipThisYear().ShouldBeFalse(); user.HasPayedTrainingFeeThisSemester().ShouldBeFalse(); user.HasPayedClassesFeeThisSemester().ShouldBeFalse(); } }
public void TestPaidMembershipThisFallSemester() { using (TemporaryTime.Is(new DateTime(2019, 10, 2))) { var user = new MemberUser { Payments = { Payment(paidAt: TimeProvider.UtcNow.AddMonths(-1), membership: true, training: false, classes: false) } }; user.HasPayedMembershipThisYear().ShouldBeTrue(); user.HasPayedTrainingFeeThisSemester().ShouldBeFalse(); user.HasPayedClassesFeeThisSemester().ShouldBeFalse(); } }
public static bool MustPayTrainingFee(this MemberUser user, EventSignupOptions options) => options.RequiresTrainingFee && !user.HasPayedTrainingFeeThisSemester() && !user.ExemptFromTrainingFee;