private void DefaultUnusedFields(HRATES hrate) { hrate.H_L = "1"; //doesn't mean anything hrate.CHD_GRATE = 0; hrate.CHD_NRATE = 0; hrate.JR_GRATE = 0; hrate.JR_NRATE = 0; hrate.JR_LIMIT = string.Empty; hrate.OTH_GRATE = 0; hrate.OTH_NRATE = 0; hrate.MAX_OTH = 0; hrate.ChdCostBeforeTax = 0; hrate.OthCostBeforeTax = 0; hrate.JrCostBeforeTax = 0; hrate.SOthCostBeforeTax = 0; hrate.SChdCostBeforeTax = 0; hrate.SJrCostBeforeTax = 0; hrate.MEAL1_CODE = string.Empty; hrate.MEAL1_ADG = 0; hrate.MEAL1_ADN = 0; hrate.MEAL2_CODE = string.Empty; hrate.MEAL2_ADG = 0; hrate.MEAL2_ADN = 0; hrate.MEAL3_CODE = string.Empty; hrate.MEAL3_ADG = 0; hrate.MEAL3_ADN = 0; hrate.MEAL4_CODE = string.Empty; hrate.MEAL4_ADG = 0; hrate.MEAL4_ADN = 0; hrate.MEAL5_CODE = string.Empty; hrate.MEAL5_ADG = 0; hrate.MEAL5_ADN = 0; hrate.COMM_FLG = "Y"; hrate.COMM_PCT = 0; hrate.SSGL_GRATE = 0; hrate.SSGL_NRATE = 0; hrate.SDBL_NRATE = 0; hrate.SDBL_GRATE = 0; hrate.STPL_NRATE = 0; hrate.STPL_GRATE = 0; hrate.SQUA_NRATE = 0; hrate.SQUA_GRATE = 0; hrate.SOTH_NRATE = 0; hrate.SOTH_GRATE = 0; hrate.SCHD_NRATE = 0; hrate.SCHD_GRATE = 0; hrate.SCHD_LIMIT = string.Empty; hrate.SJR_NRATE = 0; hrate.SJR_GRATE = 0; hrate.SJR_LIMIT = string.Empty; hrate.SMEAL1_ADG = 0; hrate.SMEAL1_ADN = 0; hrate.SMEAL2_ADG = 0; hrate.SMEAL2_ADN = 0; hrate.SMEAL3_ADG = 0; hrate.SMEAL3_ADN = 0; hrate.SMEAL4_ADG = 0; hrate.SMEAL4_ADN = 0; hrate.SMEAL5_ADG = 0; hrate.SMEAL5_ADN = 0; hrate.SCOMM_FLG = string.Empty; hrate.SCOMM_PCT = 0; hrate.SUN_FLG = "0"; hrate.MON_FLG = "0"; hrate.TUE_FLG = "0"; hrate.WED_FLG = "0"; hrate.THU_FLG = "0"; hrate.FRI_FLG = "0"; hrate.SAT_FLG = "0"; hrate.OVRCOMM_PCT = 0; hrate.NightsPay = 0; hrate.NightsStay = 0; hrate.Inactive = false; hrate.RepeatCount = 0; hrate.Inhouse = false; hrate.MarkupPct = 0; }
private HRATES PopulateHRates(ImportMapping mapping, string special, DateTime date, decimal newRate, decimal currentRate, decimal markupPct, decimal markupFlat) { string[] rateplan = Array.Empty <string>(); if (!string.IsNullOrEmpty(special)) { rateplan = special.Split('-'); } HRATES hrate = new HRATES(); hrate.CODE = mapping.HOTEL.CODE; hrate.CAT = mapping.Cat; hrate.START_DATE = date; hrate.END_DATE = date; hrate.AGENCY = _sys.Settings.DefaultAgency; hrate.LAST_UPD = DateTime.Now; hrate.RATE_DESC = mapping.HOTEL.NAME; hrate.UPD_INIT = _sys.User.Name; if (rateplan.Length > 0) { if (rateplan[0].Trim().Length <= 16) { hrate.SpecialValue_Code = rateplan[0].Trim(); } else if (rateplan[0].Trim().Length <= 64) { //Use the code as the description by default hrate.COMMENT1 = rateplan[0].Trim(); hrate.COMMENT2 = rateplan[0].Trim(); } } //Overwrite the description with a description if there is one, and if the comment fields //are not required to hold the code (which would be if the code is longer than 16 chars) if (rateplan.Length > 1 && rateplan[0].Trim().Length <= 16 && rateplan[1].Trim().Length <= 64) { hrate.COMMENT1 = rateplan[1].Trim(); hrate.COMMENT2 = rateplan[1].Trim(); } hrate.YEAR = date.Year; if (dateEditEffectiveDate.EditValue != null) { hrate.ResDate_Start = dateEditEffectiveDate.DateTime; } if (dateEditExpirationDate.EditValue != null) { hrate.ResDate_End = dateEditExpirationDate.DateTime; } string day = date.ToString("ddd").ToLower(); bool isWeekend = mapping.WeekendDays.ToLower().Contains(day); decimal taxRate = (decimal)((mapping.HOTEL.TAXRATE ?? 0) / 100); decimal baseCostBeforeTax = newRate > 0 ? newRate : currentRate; if (isWeekend) { baseCostBeforeTax += mapping.WeekendSurcharge ?? 0; } else { baseCostBeforeTax += mapping.WeekdaySurcharge ?? 0; } //We don't actually know whether CHD's markups are inclusive of tax, but probably not so add the tax //If there is a flat amount it is per room, so it will need to be divided by persons later decimal baseMarkupAfterTax = (markupFlat + (baseCostBeforeTax * (markupPct / 100))) * (1 + taxRate); decimal baseCostAfterTax = baseCostBeforeTax * (1 + taxRate); decimal surchargeBeforeTax = mapping.PerPersonSurcharge ?? 0; decimal surchargeAfterTax = surchargeBeforeTax * (1 + taxRate); decimal surchargeMarkupWithTax = (surchargeBeforeTax * (markupPct / 100)) * (1 + taxRate); decimal perPersonCostBeforeTax = baseCostBeforeTax; decimal perPersonCostAfterTax = baseCostAfterTax; int occupancy = 1; hrate.SglCostBeforeTax = Math.Round(perPersonCostBeforeTax, 2); hrate.SGL_NRATE = (float)Math.Round(perPersonCostAfterTax, 2); hrate.SGL_GRATE = (float)Math.Round(perPersonCostAfterTax + baseMarkupAfterTax, 2); occupancy = 2; //costBeforeTax = baseCostBeforeTax / occupancy; //costAfterTax = baseCostAfterTax / occupancy; //Find out at what occupancy the per person surcharge kicks in and multiply by the difference //in number of occupants for this occupancy level int perPersonMultiplier = occupancy - (mapping.BaseRateOccupancy ?? 1); perPersonCostBeforeTax = (baseCostBeforeTax + (surchargeBeforeTax * perPersonMultiplier)) / occupancy; perPersonCostAfterTax = (baseCostAfterTax + (surchargeAfterTax * perPersonMultiplier)) / occupancy; hrate.DblCostBeforeTax = Math.Round(perPersonCostBeforeTax, 2); hrate.DBL_NRATE = (float)Math.Round(perPersonCostAfterTax, 2); hrate.DBL_GRATE = (float)Math.Round(perPersonCostAfterTax + ((baseMarkupAfterTax + (surchargeMarkupWithTax * perPersonMultiplier)) / occupancy), 2); occupancy = 3; //costBeforeTax = baseCostBeforeTax / occupancy; //costAfterTax = baseCostAfterTax / occupancy; perPersonMultiplier = occupancy - (mapping.BaseRateOccupancy ?? 1); perPersonCostBeforeTax = (baseCostBeforeTax + (surchargeBeforeTax * perPersonMultiplier)) / occupancy; perPersonCostAfterTax = (baseCostAfterTax + (surchargeAfterTax * perPersonMultiplier)) / occupancy; hrate.TplCostBeforeTax = Math.Round(perPersonCostBeforeTax, 2); hrate.TPL_NRATE = (float)Math.Round(perPersonCostAfterTax, 2); hrate.TPL_GRATE = (float)Math.Round(perPersonCostAfterTax + ((baseMarkupAfterTax + (surchargeMarkupWithTax * perPersonMultiplier)) / occupancy), 2); occupancy = 4; //costBeforeTax = baseCostBeforeTax / occupancy; //costAfterTax = baseCostAfterTax / occupancy; perPersonMultiplier = occupancy - (mapping.BaseRateOccupancy ?? 1); perPersonCostBeforeTax = (baseCostBeforeTax + (surchargeBeforeTax * perPersonMultiplier)) / occupancy; perPersonCostAfterTax = (baseCostAfterTax + (surchargeAfterTax * perPersonMultiplier)) / occupancy; hrate.QuaCostBeforeTax = Math.Round(perPersonCostBeforeTax, 2); hrate.QUA_NRATE = (float)Math.Round(perPersonCostAfterTax, 2); hrate.QUA_GRATE = (float)Math.Round(perPersonCostAfterTax + ((baseMarkupAfterTax + (surchargeMarkupWithTax * perPersonMultiplier)) / occupancy), 2); hrate.CHD_LIMIT = mapping.FreeAgeLimit.ToString(); //If the rate was marked up by an import rule, don't apply further markups in availability checks hrate.MarkupAllowed = !(markupFlat > 0 || markupPct > 0); //Pull the max occs from the hotel if nothing is specified on the import if ((mapping.MaxOccupancy ?? 0) > 0) { hrate.MAX_SGL = mapping.MaxOccupancy; hrate.MAX_DBL = mapping.MaxOccupancy; hrate.MAX_TPL = mapping.MaxOccupancy; hrate.MAX_QUA = mapping.MaxOccupancy; } else { hrate.MAX_SGL = mapping.HOTEL.MAX_SGL; hrate.MAX_DBL = mapping.HOTEL.MAX_DBL; hrate.MAX_TPL = mapping.HOTEL.MAX_TPL; hrate.MAX_QUA = mapping.HOTEL.MAX_QUA; } DefaultUnusedFields(hrate); return(hrate); }