private DateTime CalculateToDate(TenantEntity tenant, DateTime today) { var toDate = UseFullPeriod ? GetPeriodEndDate(tenant, today) : today; if (tenant.VacatingBefore(toDate)) { toDate = tenant.VacatingDate.AsDateOnly(); } return toDate; }
public int CalculateDays(TenantEntity tenant) { DateTime today = Today(); DateTime fromDate = CalculateFromDate(tenant, today); DateTime toDate = CalculateToDate(tenant, today); var days = (toDate - fromDate).Days; return days - tenant.CreditedDays; }
private static DateTime GetPeriodEndDate(TenantEntity tenant, DateTime today) { var rentalPeriod = tenant.GetRentalPeriod(); return rentalPeriod.CalculateNextPeriodEndDateFrom(today); }
private static DateTime CalculateFromDate(TenantEntity tenant, DateTime today) { return tenant.PaidTo == null ? today : tenant.PaidTo.AsDateOnly(); }