private void AddRandomExpenseItem(Claim claim) { AbstractExpenseItem item = claim.CreateNewExpenseItem(expenseTypes[random.Next(8)]); Populate(item); Container.Persist(ref item); }
public virtual AbstractExpenseItem CopyAnExistingExpenseItem(AbstractExpenseItem otherItem) { AbstractExpenseItem newItem = m_claimRepository.CreateNewExpenseItem(this, otherItem.ExpenseType); newItem.CopyFrom(otherItem); return(newItem); }
private void Populate(AbstractExpenseItem item) { PopulateGeneral(item); if (item is Journey) { PopulateJourney((Journey)item); } if (item is Airfare) { PopulateAirfare((Airfare)item); } if (item is CarRental) { PopulateCarRental((CarRental)item); } if (item is PrivateCarJourney) { PopulatePrivateCarJourney((PrivateCarJourney)item); } if (item is Hotel) { PopulateHotel((Hotel)item); } }
public virtual string ValidateCopyFrom(AbstractExpenseItem otherItem) { if (BelongsToSameClaim(otherItem) || (GetType().IsInstanceOfType(otherItem))) { return(null); } return(COPY_WARN); }
public virtual void ModifyProjectCode(ProjectCode newCode) { ProjectCode = newCode; for (int i = 0; i < ExpenseItems.Count; i++) { AbstractExpenseItem item = (ExpenseItems[i]); item.ModifyProjectCode(m_projectCode); } }
private void PopulateGeneral(AbstractExpenseItem item) { var rDate = new DateTime(random.Next(7) + 2000, random.Next(12) + 1, random.Next(28) + 1); item.ModifyAmount(RandomAmount); //item.modifyDescription(item.[GetType()]().FullName + " " + rDate.ToString()) item.ModifyDateIncurred(rDate); item.ModifyProjectCode(RandomProjectCode); }
private AbstractExpenseItem CreateExpenseItem(Claim claim, ExpenseType type, DateTime dateIncurred, string description, decimal amount) { AbstractExpenseItem item = (claim.CreateNewExpenseItem(type)); item.ModifyDateIncurred(dateIncurred); item.ModifyDescription(description); item.ModifyAmount(Money(amount, claim)); return(item); }
public virtual void CopyAllExpenseItemsFromAnotherClaim([Named("Claim or Template")] Claim otherClaim, [Optionally, Named("New date to apply to all items"), Mask("d")] DateTime newDate) { for (int i = 0; i < otherClaim.ExpenseItems.Count; i++) { AbstractExpenseItem otherItem = (otherClaim.ExpenseItems[i]); AbstractExpenseItem newItem = CopyAnExistingExpenseItem(otherItem); newItem.ModifyDateIncurred(newDate); Container.Persist(ref newItem); } }
public virtual void QueryItems(string reason, bool newOnly) { for (int i = 0; i < ExpenseItems.Count; i++) { AbstractExpenseItem item = (ExpenseItems[i]); if ((!newOnly) || (item.NewComplete())) { item.Query(reason); } } }
public virtual void RejectItems(string reason, [Optionally] bool newItemsOnly) { for (int i = 0; i < ExpenseItems.Count; i++) { AbstractExpenseItem item = (ExpenseItems[i]); if ((!newItemsOnly) || (item.NewComplete())) { item.Reject(reason); } } }
public virtual void ApproveItems([Optionally] bool approveNewItemsOnly) { for (int i = 0; i < ExpenseItems.Count; i++) { AbstractExpenseItem item = (ExpenseItems[i]); if ((!approveNewItemsOnly) || (item.NewComplete())) { item.Approve(); } } }
public virtual void ReturnToClaimant(string message, bool sendEmail) { ChangeStatusToReturned(); for (int i = 0; i < ExpenseItems.Count; i++) { AbstractExpenseItem item = (ExpenseItems[i]); item.IsLocked = (false); } m_recordActionService.RecordMenuAction(this, "Return To Claimant", message); string fullMessage = ("Your Expenses Claim: " + Title() + " has been returned to you with the message " + message); SendEmailIfPossible(sendEmail, Claimant.EmailAddress, fullMessage); }
public virtual void RecalculateTotal() { decimal runningTotal = 0M; for (int i = 0; i < ExpenseItems.Count; i++) { AbstractExpenseItem item = ExpenseItems[i]; decimal itemAmount = item.RequestedOrApprovedAmount(); runningTotal = runningTotal + itemAmount; } Total = runningTotal; }
public virtual void Submit(Employee approver, [Named("Advise approver by email")] bool sendEmail) { ChangeStatusToSubmitted(); for (int i = 0; i < ExpenseItems.Count; i++) { AbstractExpenseItem item = (ExpenseItems[i]); item.IsLocked = (true); } string message = Claimant.Name + CLAIM_AWAITING_YOUR_APPROVAL; SendEmailIfPossible(sendEmail, approver.EmailAddress, message); m_recordActionService.RecordMenuAction(this, "Submit", "to " + approver.Title()); }
public virtual void CopyFrom(AbstractExpenseItem otherItem) { if (BelongsToSameClaim(otherItem)) { if (DateIncurred == null) { ModifyDateIncurred(otherItem.DateIncurred); } } else if (GetType().IsInstanceOfType(otherItem)) { CopyAllSameClassFields(otherItem); } }
private bool AllItemsComplete() { if (ExpenseItems.Count == 0) { return(false); } for (int i = 0; i < ExpenseItems.Count; i++) { AbstractExpenseItem item = (ExpenseItems[i]); if (!(item.NewComplete())) { return(false); } } return(true); }
protected internal virtual void CopyAllFieldsFromAbstractExpenseItem(AbstractExpenseItem otherItem) { if (Amount == 0M) { // Guard against different currency ModifyAmount(otherItem.Amount); } if (Description == null || Description.Equals("")) { ModifyDescription(otherItem.Description); } if (ProjectCode == null) { ModifyProjectCode(otherItem.ProjectCode); } }
private void Populate(AbstractExpenseItem item) { PopulateGeneral(item); if (item is Journey) { PopulateJourney((Journey) item); } if (item is Airfare) { PopulateAirfare((Airfare) item); } if (item is CarRental) { PopulateCarRental((CarRental) item); } if (item is PrivateCarJourney) { PopulatePrivateCarJourney((PrivateCarJourney) item); } if (item is Hotel) { PopulateHotel((Hotel) item); } }
protected internal abstract void CopyAnyEmptyFieldsSpecificToSubclassOfJourney(AbstractExpenseItem otherItem);
protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfAbstractExpenseItem(AbstractExpenseItem otherItem) { if (otherItem is Journey) { var journey = (Journey) otherItem; if (string.IsNullOrEmpty(m_origin)) { ModifyOrigin(journey.Origin); } if (string.IsNullOrEmpty(m_destination)) { ModifyDestination(journey.Destination); } } CopyAnyEmptyFieldsSpecificToSubclassOfJourney(otherItem); }
protected internal override void CopyAllSameClassFields(AbstractExpenseItem otherItem) { base.CopyAllSameClassFields(otherItem); if (otherItem is Hotel) {} }
protected internal virtual bool BelongsToSameClaim(AbstractExpenseItem otherItem) { return(m_claim.Equals(otherItem.Claim)); }
protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfAbstractExpenseItem(AbstractExpenseItem otherItem) { if (otherItem is Hotel) { var otherHotel = (Hotel) otherItem; if (string.IsNullOrEmpty(m_hotelURL)) { ModifyHotelURL(otherHotel.HotelURL); } if (m_numberOfNights == 0) { ModifyNumberOfNights(otherHotel.NumberOfNights); } if (m_accommodation == 0) { ModifyAccommodation(otherHotel.Accommodation); } if (m_food == 0) { ModifyFood(otherHotel.Food); } if (m_other == 0) { ModifyOther(otherHotel.Other); } } }
protected internal virtual void CopyAllSameClassFields(AbstractExpenseItem otherItem) { CopyAllFieldsFromAbstractExpenseItem(otherItem); CopyAnyEmptyFieldsSpecificToSubclassOfAbstractExpenseItem(otherItem); }
protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfJourney(AbstractExpenseItem otherItem) { // No extra fields to copy. }
public IList<AbstractExpenseItem> FindExpenseItemsLike(AbstractExpenseItem item) { // Simple implementation: could be extended to compare any fields that have already been set on the // item provided. return findExpenseItemsOfType(item.Claim.Claimant, item.ExpenseType); }
protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfAbstractExpenseItem(AbstractExpenseItem otherItem) { if (otherItem is CarRental) { var carRental = (CarRental) otherItem; if (string.IsNullOrEmpty(m_rentalCompany)) { ModifyRentalCompany(carRental.RentalCompany); } if (m_numberOfDays == 0) { ModifyNumberOfDays(carRental.NumberOfDays); } } }
protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfJourney(AbstractExpenseItem otherItem) { if (otherItem is Airfare) { var airfare = (Airfare) otherItem; if (string.IsNullOrEmpty(m_airlineAndFlight)) { ModifyAirlineAndFlight(airfare.AirlineAndFlight); } } }
protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfJourney(AbstractExpenseItem otherItem) { if (otherItem is PrivateCarJourney) { var carJourney = (PrivateCarJourney) otherItem; if (m_totalMiles == 0) { ModifyTotalMiles(carJourney.TotalMiles); } if (m_mileageRate == 0) { ModifyMileageRate(carJourney.MileageRate); } } }
public virtual string ValidateCopyFrom(AbstractExpenseItem otherItem) { if (BelongsToSameClaim(otherItem) || (GetType().IsInstanceOfType(otherItem))) { return null; } return COPY_WARN; }
protected internal virtual void CopyAllSameClassFields(AbstractExpenseItem otherItem) { CopyAllFieldsFromAbstractExpenseItem(otherItem); CopyAnyEmptyFieldsSpecificToSubclassOfAbstractExpenseItem(otherItem); }
private void PopulateGeneral(AbstractExpenseItem item) { var rDate = new DateTime(random.Next(7) + 2000, random.Next(12) + 1, random.Next(28) + 1); item.ModifyAmount(RandomAmount); //item.modifyDescription(item.[GetType()]().FullName + " " + rDate.ToString()) item.ModifyDateIncurred(rDate); item.ModifyProjectCode(RandomProjectCode); }
public virtual void CopyFrom(AbstractExpenseItem otherItem) { if (BelongsToSameClaim(otherItem)) { if (DateIncurred == null) { ModifyDateIncurred(otherItem.DateIncurred); } } else if (GetType().IsInstanceOfType(otherItem)) { CopyAllSameClassFields(otherItem); } }
public virtual void RemoveFromExpenseItems(AbstractExpenseItem item) { ExpenseItems.Remove(item); RecalculateTotal(); }
protected internal virtual void CopyAllFieldsFromAbstractExpenseItem(AbstractExpenseItem otherItem) { if (Amount == 0M) { // Guard against different currency ModifyAmount(otherItem.Amount); } if (Description == null || Description.Equals("")) { ModifyDescription(otherItem.Description); } if (ProjectCode == null) { ModifyProjectCode(otherItem.ProjectCode); } }
protected internal virtual bool BelongsToSameClaim(AbstractExpenseItem otherItem) { return m_claim.Equals(otherItem.Claim); }
public virtual void RemoveFromExpenseItems(AbstractExpenseItem item) { ExpenseItems.Remove(item); RecalculateTotal(); }
protected internal override void CopyAllSameClassFields(AbstractExpenseItem otherItem) { base.CopyAllSameClassFields(otherItem); if (otherItem is Hotel) { } }
protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfAbstractExpenseItem(AbstractExpenseItem otherItem) { if (otherItem is Hotel) { var otherHotel = (Hotel) otherItem; if (string.IsNullOrEmpty(m_hotelURL)) { ModifyHotelURL(otherHotel.HotelURL); } if (m_numberOfNights == 0) { ModifyNumberOfNights(otherHotel.NumberOfNights); } if (m_accommodation == 0) { ModifyAccommodation(otherHotel.Accommodation); } if (m_food == 0) { ModifyFood(otherHotel.Food); } if (m_other == 0) { ModifyOther(otherHotel.Other); } } }
public virtual void AddToExpenseItems(AbstractExpenseItem item) { ExpenseItems.Add(item); RecalculateTotal(); }
public IList <AbstractExpenseItem> FindExpenseItemsLike(AbstractExpenseItem item) { // Simple implementation: could be extended to compare any fields that have already been set on the // item provided. return(FindExpenseItemsOfType(item.Claim.Claimant, item.ExpenseType)); }
public virtual AbstractExpenseItem CopyAnExistingExpenseItem(AbstractExpenseItem otherItem) { AbstractExpenseItem newItem = m_claimRepository.CreateNewExpenseItem(this, otherItem.ExpenseType); newItem.CopyFrom(otherItem); return newItem; }
public virtual void AddToExpenseItems(AbstractExpenseItem item) { ExpenseItems.Add(item); RecalculateTotal(); }