public IntSync.Price GetPrice(QTouristik.Interface.Sync.PriceArg arg, IntOffice.PriceList priceList)
        {
            MasterDataManager mda = new MasterDataManager();
            var unit = mda.GetTouristUnit(arg.TouristSiteCode, arg.OfferCode);

            var offer = mda.GetUnitOffer(arg.TourOperatorCode, arg.TouristSiteCode, arg.OfferCode);

            Utility.PriceCalculator.CalculatorPriceList cpl = ConvertToCalculatorPriceList(priceList, unit.UnitStopBooking);
            var calcArg = new QTouristik.Utility.PriceCalculator.PriceArg();

            calcArg.CheckIn              = arg.CheckIn.Date;
            calcArg.CheckOut             = arg.CheckOut.Date;
            calcArg.OfferCode            = arg.OfferCode;
            calcArg.Pets                 = arg.Pets;
            calcArg.TouristSiteId        = arg.TouristSiteCode;
            calcArg.TourOperatorCode     = arg.TourOperatorCode;
            calcArg.Traveler             = arg.Birthdays;
            calcArg.PaymentOfferOptionId = arg.PaymentOfferOptionId;


            var calculatorPrice = new QTouristik.Utility.PriceCalculator.PriceCalculateUtility(cpl).GetPrice(calcArg);
            var price           = ConvertToPrice(calculatorPrice);

            price.OfferCode    = priceList.OfferCode;
            price.OfferName    = offer.OfferTitel;
            price.PlaceName    = unit.PlaceName;
            price.RegionName   = unit.RegionName;
            price.SiteCode     = unit.SiteCode;
            price.FacilityName = unit.SiteName;


            return(price);
        }
Exemple #2
0
        public static void ReplacePriceList(IdomOffice.Interface.BackOffice.PriceLists.PriceList priceList, string targetPriceListId, decimal factor)
        {
            var manager         = PlugInManager.GetPriceListManager();
            var targetPriceList = manager.GetPriceList(targetPriceListId);

            targetPriceList.ActionsList      = priceList.ActionsList;
            targetPriceList.AvailabilityList = priceList.AvailabilityList;
            targetPriceList.ConditionsList   = priceList.ConditionsList;
            targetPriceList.PaymentModeList  = priceList.PaymentModeList;
            targetPriceList.ServicesList     = priceList.ServicesList;
            targetPriceList.SeasonPriceList  = priceList.SeasonPriceList;

            if (factor > 0)
            {
                foreach (var pr in targetPriceList.SeasonPriceList)
                {
                    pr.Eur = pr.Eur * factor;
                }
            }
            manager.UpdatePriceList(targetPriceList);
        }
Exemple #3
0
        public static PriceListModel GetModel(string tourOperatorCode, string siteCode, string offerCode, PriceListType priceTyp)
        {
            PriceListModel model = new PriceListModel();

            var manager   = PlugInManager.GetPriceListManager();
            var priceList = manager.GetPriceList(tourOperatorCode, siteCode, offerCode, priceTyp);

            if (priceList == null)
            {
                priceList    = new IdomOffice.Interface.BackOffice.PriceLists.PriceList();
                priceList.id = Guid.NewGuid().ToString();
                priceList.TourOperatorCode = tourOperatorCode;
                priceList.SiteCode         = siteCode;
                priceList.OfferCode        = offerCode;
                priceList.PriceListType    = priceTyp;
                manager.AddPriceList(priceList);
            }

            // sada kreiramo model
            model           = new PriceListModel();
            model.id        = priceList.id;
            model.SiteCode  = priceList.SiteCode;
            model.OfferCode = priceList.OfferCode;
            //      model.UnitCode = priceList.UnitCode;
            model.PriceListType     = priceList.PriceListType;
            model.TourOperatorCode  = priceList.TourOperatorCode;
            model.SeasonPriceList   = priceList.SeasonPriceList;
            model.ActionsList       = priceList.ActionsList;
            model.AvailabilityList  = priceList.AvailabilityList;
            model.ConditionsList    = priceList.ConditionsList;
            model.PaymentModeList   = priceList.PaymentModeList;
            model.ServicesList      = priceList.ServicesList;
            model.SpecialPricesList = priceList.SpecialPricesList;

            var masterDataManager = PlugInManager.GetMasterDataManager();
            var offer             = masterDataManager.GetUnitOffer(tourOperatorCode, siteCode, offerCode);
            var unit = masterDataManager.GetTouristUnit(siteCode, offer.UnitCode);

            model.SiteName = unit.SiteName;
            model.UnitName = unit.UnitTitel;
            int counter = 0;

            foreach (var item in model.SeasonPriceList)
            {
                item.Id = (++counter).ToString();
            }
            List <SeasonAndPrice> season = model.SeasonPriceList;

            season = season.OrderBy(m => m.FromDate).ToList();
            model.SeasonPriceList = season;
            counter = 0;
            foreach (var item in model.SpecialPricesList)
            {
                item.Id = (++counter).ToString();
            }
            counter = 0;
            foreach (var item in model.ActionsList)
            {
                item.Id = (++counter).ToString();
            }
            counter = 0;
            foreach (var item in model.AvailabilityList)
            {
                item.Id = (++counter).ToString();
            }
            counter = 0;
            foreach (var item in model.ConditionsList)
            {
                item.Id = (++counter).ToString();
            }
            counter = 0;
            foreach (var item in model.PaymentModeList)
            {
                item.Id = (++counter).ToString();
            }
            counter = 0;
            foreach (var item in model.ServicesList)
            {
                item.Id = (++counter).ToString();
            }


            return(model);
        }
        private CalculatorPriceList ConvertToCalculatorPriceList(IntOffice.PriceList priceList, List <QTouristik.Data.DateInterval> stopbookingList)
        {
            var pl = new CalculatorPriceList();

            foreach (var l1 in priceList.ActionsList)
            {
                pl.ActionsList.Add(new Utility.PriceCalculator.SeasonUnitAction()
                {
                    ActionEnd       = l1.ActionEnd.Date,
                    ActionStart     = l1.ActionStart.Date,
                    ActionType      = (Utility.PriceCalculator.ActionType)l1.ActionType,
                    CanBeCombined   = l1.CanBeCombined,
                    DiscountEur     = l1.DiscountEur,
                    DiscountPercent = l1.DiscountPercent,
                    FreeNights      = l1.FreeNights,
                    FromDate        = l1.FromDate.Date,
                    MinPrice        = l1.MinPrice,
                    MinStayDays     = l1.MinStayDays,
                    ToDate          = l1.ToDate.Date
                });
            }

            foreach (var l in priceList.AvailabilityList)
            {
                pl.AvailabilityList.Add(new Utility.PriceCalculator.SeasonUnitAvailability()
                {
                    FromDate = ConvertTime(l.FromDate), ToDate = ConvertTime(l.ToDate), IsAutoStopBooking = l.IsAutoStopBooking, UnitCount = l.UnitCount
                });
            }

            foreach (var l in priceList.ConditionsList)
            {
                var itm = new Utility.PriceCalculator.SeasonUnitCondition()
                {
                    Arrival     = l.Arrival,
                    Departure   = l.Departure,
                    FromDate    = l.FromDate.Date,
                    ToDate      = l.ToDate.Date,
                    MinStay     = l.MinStay,
                    ReleaseDays = l.ReleaseDays
                };
                if (itm.Arrival.Count == 0)
                {
                    itm.Arrival.Add(l.ArrivalActual);
                }
                if (itm.Departure.Count == 0)
                {
                    itm.Departure.Add(l.DepartureActual);
                }
                pl.ConditionsList.Add(itm);
            }

            foreach (var l in priceList.PaymentModeList)
            {
                pl.PaymentModeList.Add(new Utility.PriceCalculator.PaymentMode()
                {
                    BookingFromDate           = l.BookingFromDate,
                    BookingToDate             = l.BookingToDate,
                    CancellationFeesPercent   = l.CancellationFeesPercent,
                    CancellationFeesToDays    = l.CancellationFeesToDays,
                    CheckInFromDate           = l.CheckInFromDate,
                    CheckInToDate             = l.CheckInToDate,
                    MaxDayToArrival           = l.MaxDayToArrival,
                    MinDayToArrival           = l.MinDayToArrival,
                    PaymentModeDescription    = l.PaymentModeDescription,
                    PaymentModeTitel          = l.PaymentModeTitel,
                    PriceDownPaymentAfterDays = l.PriceDownPaymentAfterDays,
                    PriceDownPaymentEur       = l.PriceDownPaymentEur,
                    PriceDownPaymentPercent   = l.PriceDownPaymentPercent,
                    PricePercentDiscount      = l.PricePercentDiscount,
                    PriceRemainingBeforDays   = l.PriceRemainingBeforDays
                });
            }

            foreach (var l in priceList.SeasonPriceList)
            {
                pl.SeasonPriceList.Add(new Utility.PriceCalculator.SeasonAndPrice()
                {
                    Eur         = l.Eur,
                    FromDate    = l.FromDate.Date,
                    FromPersons = l.FromPersons,
                    PriceType   = (Utility.PriceCalculator.PriceType)l.PriceType,
                    ToDate      = l.ToDate.Date,
                    ToPersons   = l.ToPersons
                });
            }

            foreach (var l in priceList.ServicesList)
            {
                pl.ServicesList.Add(new Utility.PriceCalculator.SeasonUnitService()
                {
                    Description     = l.Description,
                    FromDate        = l.FromDate.Date,
                    ToDate          = l.ToDate.Date,
                    OfDay           = l.OfDay,
                    ToDay           = l.ToDay,
                    Eur             = l.Eur,
                    IsOptional      = l.IsOptional,
                    OfOld           = l.OfOld,
                    PaymentPlace    = (Utility.PriceCalculator.PaymentPlace)l.PaymentPlace,
                    ServiceInterval = (Utility.PriceCalculator.ServiceInterval)l.ServiceInterval,
                    ServiceType     = (Utility.PriceCalculator.ServiceType)l.ServiceType,
                    ServiceUnit     = (Utility.PriceCalculator.ServiceUnit)l.ServiceUnit,
                    ToOld           = l.ToOld
                });
            }

            if (stopbookingList != null)
            {
                foreach (var l in stopbookingList)
                {
                    pl.StopBookingList.Add(new Utility.PriceCalculator.DateInterval()
                    {
                        FromDate = l.FromDate.Date,
                        ToDate   = l.ToDate.Date
                    });
                }
            }
            return(pl);
        }