private void ComputeTaxPrice(AdditionalBooking entity) { if (entity.Tax != null) { Tax associatedTax = entity.Tax; entity.PriceTTC = ComputePrice.ComputePriceFromPercentOrAmount((Decimal)entity.PriceHT, (EValueType)associatedTax.ValueType, (Decimal)associatedTax.Price); } }
private void ComputeTaxPrice(RoomSupplement entity) { if (entity.Tax != null) { Tax associatedTax = entity.Tax; orig.PriceTTC = ComputePrice.ComputePriceFromPercentOrAmount((Decimal)entity.PriceHT, (EValueType)associatedTax.ValueType, (Decimal)associatedTax.Price); } }
private void ComputePriceAndDuration(ProductBooking entity) { Product associatedProduct = entity.Product; Tax associatedTax = associatedProduct.Tax == null ? null : associatedProduct.Tax; entity.PriceHT = associatedProduct.PriceHT * entity.Quantity; if (associatedTax != null) { entity.PriceTTC = ComputePrice.ComputePriceFromPercentOrAmount((decimal)entity.PriceHT, (EValueType)associatedTax.ValueType, (EValueType)associatedTax.ValueType == EValueType.AMOUNT ? Decimal.Multiply((decimal)associatedTax.Price, (decimal)entity.Quantity) : (decimal)associatedTax.Price); } else { entity.PriceTTC = entity.PriceHT; } if (associatedProduct.Duration != null) { entity.Duration = entity.Quantity * associatedProduct.Duration; } }
public virtual DinnerBookingDTO Compute(Client currentClient, int id, object param) { Decimal priceHT = 0; Decimal priceTTC = 0; IEnumerable <MealBooking> mealBookings = null; ProcessDTOPostPut(null, id, currentClient); ValidateOrig(); repo.includes.Add("PeopleCategory"); repo.includes.Add("Meal"); mealBookings = repo.GetAllMealByDinnerBooking(id, currentClient.Id); foreach (MealBooking cur in mealBookings) { repo.includes.Add("Tax"); MealPrice priceForMeal = repo.GetMealPriceByPeopleCategoryId(cur.PeopleCategory.Id, (int)cur.Meal.Id, currentClient.Id); if (priceForMeal == null) { validationDictionnary.AddModelError(String.Format(GenericNames.MODEL_STATE_FORMAT, TypeOfName.GetNameFromType <DinnerBooking>(), "MealPrice"), GenericError.CANNOT_BE_NULL_OR_EMPTY); throw new ManahostValidationException(validationDictionnary); } Decimal tmpPrice = (Decimal)priceForMeal.PriceHT * (int)cur.NumberOfPeople; priceHT += tmpPrice; if (priceForMeal.Tax != null) { priceTTC += ComputePrice.ComputePriceFromPercentOrAmount(tmpPrice, (EValueType)priceForMeal.Tax.ValueType, (EValueType)priceForMeal.Tax.ValueType == EValueType.AMOUNT ? (Decimal)priceForMeal.Tax.Price * (int)cur.NumberOfPeople : (Decimal)priceForMeal.Tax.Price); } else { priceTTC += tmpPrice; } } orig.PriceHT = priceHT; orig.PriceTTC = priceTTC; repo.Update(orig); repo.Save(); return(GetMapper.Map <DinnerBooking, DinnerBookingDTO>(orig)); }
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; } }