private void AddRandomExpenseItem(Claim claim)
        {
            AbstractExpenseItem item = claim.CreateNewExpenseItem(expenseTypes[random.Next(8)]);

            Populate(item);
            Container.Persist(ref item);
        }
示例#2
0
            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);
            }
        }
示例#4
0
 public virtual string ValidateCopyFrom(AbstractExpenseItem otherItem)
 {
     if (BelongsToSameClaim(otherItem) || (GetType().IsInstanceOfType(otherItem)))
     {
         return(null);
     }
     return(COPY_WARN);
 }
示例#5
0
 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);
        }
示例#8
0
 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);
     }
 }
示例#9
0
 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);
         }
     }
 }
示例#10
0
 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);
         }
     }
 }
示例#11
0
 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();
         }
     }
 }
示例#12
0
            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);
            }
示例#13
0
            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;
            }
示例#14
0
            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());
            }
示例#15
0
 public virtual void CopyFrom(AbstractExpenseItem otherItem)
 {
     if (BelongsToSameClaim(otherItem))
     {
         if (DateIncurred == null)
         {
             ModifyDateIncurred(otherItem.DateIncurred);
         }
     }
     else if (GetType().IsInstanceOfType(otherItem))
     {
         CopyAllSameClassFields(otherItem);
     }
 }
示例#16
0
 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);
 }
示例#17
0
            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);
            }
        }
示例#19
0
 protected internal abstract void CopyAnyEmptyFieldsSpecificToSubclassOfJourney(AbstractExpenseItem otherItem);
示例#20
0
 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);
 }
示例#21
0
            protected internal override void CopyAllSameClassFields(AbstractExpenseItem otherItem) {
                base.CopyAllSameClassFields(otherItem);

                if (otherItem is Hotel) {}
            }
示例#22
0
 protected internal virtual bool BelongsToSameClaim(AbstractExpenseItem otherItem)
 {
     return(m_claim.Equals(otherItem.Claim));
 }
示例#23
0
 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);
         }
     }
 }
示例#24
0
 protected internal virtual void CopyAllSameClassFields(AbstractExpenseItem otherItem)
 {
     CopyAllFieldsFromAbstractExpenseItem(otherItem);
     CopyAnyEmptyFieldsSpecificToSubclassOfAbstractExpenseItem(otherItem);
 }
示例#25
0
 protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfJourney(AbstractExpenseItem otherItem) {
     // No extra fields to copy.
 }
示例#26
0
 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);
                    }
                }
            }
示例#28
0
 protected internal override void CopyAnyEmptyFieldsSpecificToSubclassOfJourney(AbstractExpenseItem otherItem) {
     if (otherItem is Airfare) {
         var airfare = (Airfare) otherItem;
         if (string.IsNullOrEmpty(m_airlineAndFlight)) {
             ModifyAirlineAndFlight(airfare.AirlineAndFlight);
         }
     }
 }
示例#29
0
 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);
     }
 }
示例#34
0
 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);
 }
示例#37
0
 public virtual void RemoveFromExpenseItems(AbstractExpenseItem item)
 {
     ExpenseItems.Remove(item);
     RecalculateTotal();
 }
示例#38
0
            protected internal override void CopyAllSameClassFields(AbstractExpenseItem otherItem) {
                base.CopyAllSameClassFields(otherItem);

                if (otherItem is Hotel) { }
            }
示例#39
0
 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);
         }
     }
 }
示例#40
0
 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));
 }
示例#42
0
 public virtual AbstractExpenseItem CopyAnExistingExpenseItem(AbstractExpenseItem otherItem) {
     AbstractExpenseItem newItem = m_claimRepository.CreateNewExpenseItem(this, otherItem.ExpenseType);
     newItem.CopyFrom(otherItem);
     return newItem;
 }
示例#43
0
 public virtual void AddToExpenseItems(AbstractExpenseItem item)
 {
     ExpenseItems.Add(item);
     RecalculateTotal();
 }