Beispiel #1
0
        public void DeletePricePerPerson()
        {
            PricePerPerson toDelete = repo.GetUniq(p => p.Title == "Prix adulte room1 haute saison");

            Assert.IsNotNull(repo.GetUniq(p => p.Title == "Prix adulte room1 haute saison"));

            repo.Delete(toDelete);
            repo.Save();

            Assert.IsNull(repo.GetUniq(p => p.Title == "Prix adulte room1 haute saison"));
        }
Beispiel #2
0
        private void UpdatePrices(List <Period> listPeriod, DateTime begin, DateTime end, Client currentClient, int coeff, int?peopleCategoryId = null)
        {
            DateTime       dateNights = begin;
            PricePerPerson ppp        = null;

            for (; dateNights.Date < end.Date; dateNights = dateNights.AddDays(1))
            {
                Period currentPeriod = PeriodUtils.GetCorrecPeriod(listPeriod.Where(p => dateNights >= p.Begin && dateNights <= p.End).ToList(), dateNights);
                if (currentPeriod == null)
                {
                    validationDictionnary.AddModelError(String.Format(GenericNames.MODEL_STATE_FORMAT, TypeOfName.GetNameFromType <RoomBooking>(), "Period"), GenericError.CANNOT_BE_NULL_OR_EMPTY);
                    return;
                }
                repo.includes.Add("Tax");
                if (peopleCategoryId == null)
                {
                    ppp = repo.GetPricePerPersonForGivenPeriodAndRoom(currentPeriod.Id, orig.Room.Id, currentClient.Id);
                }
                else
                {
                    ppp = repo.GetPricePerPersonForGivenPeriodPeopleCategoryAndRoom(currentPeriod.Id, (int)peopleCategoryId, orig.Room.Id, currentClient.Id);
                }
                if (ppp == null)
                {
                    validationDictionnary.AddModelError(String.Format(GenericNames.MODEL_STATE_FORMAT, TypeOfName.GetNameFromType <RoomBooking>(), "PricePerPerson"), GenericError.CANNOT_BE_NULL_OR_EMPTY);
                    return;
                }
                Decimal tmpTTC = (Decimal)(ppp.PriceHT) * coeff;
                if (ppp.Tax != null)
                {
                    tmpTTC = ComputePrice.ComputePriceFromPercentOrAmount(tmpTTC, (EValueType)ppp.Tax.ValueType,
                                                                          (EValueType)ppp.Tax.ValueType == EValueType.AMOUNT ? (Decimal)ppp.Tax.Price * coeff : (Decimal)ppp.Tax.Price);
                }
                finalPriceHT  += (Decimal)(ppp.PriceHT) * coeff;
                finalPriceTTC += tmpTTC;
            }
        }