public static ContractStatus CreateContractStatus(ContractStatuses contractStatuses) { ContractStatus con; var statusVal = (int)contractStatuses; if (!_statuses.TryGetValue(statusVal, out con)) { con = new ContractStatus(contractStatuses); _statuses.Add(statusVal, con); } return(con); }
//TODO Review. Should transfer to service //public void ChangePaymentPeriod(PaymentPeriod newPaymentPeriod) //{ // if ( PaymentPeriodId != newPaymentPeriod.PaymentPeriodId) // { // if (LastBilled.Date != ConstantValues.MinDate) // { // //expire the contract at the end of the current term // var nxtbillCycle = LastBilled.AddCycles(PaymentPeriod.PeriodInMonths); // var expireDate = nxtbillCycle.Date.AddDays(-1); // ExpiryDate = expireDate; // //start new contract as from end of previous contract // var newCont = CreateNewContractForPaymentPeriod(nxtbillCycle.Date, newPaymentPeriod); // CustomerAccount.AddContract(newCont); // } // else // { // PaymentPeriod = newPaymentPeriod; // } // } //} //public abstract void ExpireContract(); //protected abstract Contract CreateNewContractForPaymentPeriod(DateTime startDate,PaymentPeriod paymentPeriod); public ContractStatus GetContractStatusOn(DateTime dateTime) { if (ExpiryDate <= dateTime || ExpiryDate == StartDate) { return(ContractStatus.CreateContractStatus(ContractStatus.ContractStatuses.Expired)); } if (StartDate > dateTime) { return(ContractStatus.CreateContractStatus(ContractStatus.ContractStatuses.Scheduled)); } return(ContractStatus.CreateContractStatus(ContractStatus.ContractStatuses.Active)); }