private static CPromotionProcessor getPromotionProcessor(MPackage pkg, MBaseModel bill) { String pkgType = pkg.PackageType; CPromotionProcessor o = null; if (pkgType.Equals("1")) { o = new CPromotionProcessorPricing(pkg, CLanguage.getValue("pkg_group_pricing"), bill); } else if (pkgType.Equals("2")) { o = new CPromotionProcessorBonus(pkg, CLanguage.getValue("pkg_group_grouping"), bill); } else if (pkgType.Equals("3")) { o = new CPromotionProcessorItemDiscount(pkg, CLanguage.getValue("pkg_group_discount"), bill); } else if (pkgType.Equals("4")) { //Voucher/Gift o = new CPromotionProcessorGift(pkg, CLanguage.getValue("pkg_group_grouping"), bill); } else if (pkgType.Equals("5")) { //Bundle o = new CPromotionProcessorBundle(pkg, CLanguage.getValue("pkg_group_grouping"), bill); } else if (pkgType.Equals("6")) { //Final Discount o = new CPromotionProcessorFinalDiscount(pkg, CLanguage.getValue("pkg_group_final_discount"), bill); } else if (pkgType.Equals("7")) { //Post Gift o = new CPromotionProcessorPostGift(pkg, CLanguage.getValue("pkg_group_post_gift"), bill); } else if (pkgType.Equals("8")) { //Tray Price/Discount o = new CPromotionProcessorTrayPricing(pkg, CLanguage.getValue("tray_package_price"), bill); } else if (pkgType.Equals("9")) { //Tray Bonus o = new CPromotionProcessorTrayBonus(pkg, CLanguage.getValue("tray_package_group"), bill); } else if (pkgType.Equals("10")) { //Tray Bundle o = new CPromotionProcessorTrayBundle(pkg, CLanguage.getValue("tray_package_group"), bill); } return(o); }
/* Create BasketSet */ public static CBasketSet PromotionProcessing(MCompanyPackage companyPackage, CBasketSet inBskSet, MBaseModel bill) { CBasketSet tmpBs = inBskSet; resultsArr.Clear(); totalFinalDiscount = 0.00; ArrayList pkgArr = new ArrayList(); pkgArr.Add(companyPackage.TrayPackageGroup); pkgArr.Add(companyPackage.TrayPricePackage); pkgArr.Add(companyPackage.GroupingPackage); pkgArr.Add(companyPackage.PricingPackage); pkgArr.Add(companyPackage.DiscountPackage); pkgArr.Add(companyPackage.FinalDiscountPackage); pkgArr.Add(companyPackage.PostGiftPackage); /* Tray Process Grouping ... until Post Gift */ for (int i = 1; i <= 7; i++) { ObservableCollection <MCompanyPackage> pkgList = (ObservableCollection <MCompanyPackage>)pkgArr[i - 1]; foreach (MCompanyPackage cp in pkgList) { if (!cp.ExtFlag.Equals("D")) { MPackage pkg = getLoadedPackage(cp.PackageGroup, cp.PackageID); CPromotionProcessor pp = getPromotionProcessor(pkg, bill); CBasketSet outBs = pp.ApplyPakageLogic(tmpBs); if (pp is CPromotionProcessorFinalDiscount) { CPromotionProcessorFinalDiscount fd = (CPromotionProcessorFinalDiscount)pp; if (fd.IsFinalDiscount) { totalFinalDiscount = totalFinalDiscount + fd.FinalDiscount; } } collectResults(pp.GetProcessingResults()); //Use output as an input in the next try tmpBs = outBs; } } if (i == 1) { /* Post Tray Grouping processing */ CPromotionProcessorOperation opt1 = new CPromotionProcessorOperation(null, CLanguage.getValue("pkg_group_operation"), bill); CBasketSet mrg = opt1.MergeUsedToAvailable(tmpBs, true); CBasketSet sum1 = opt1.SumInGroup(mrg, BasketTypeEnum.FreeAnnonymousTray); CBasketSet sum2 = opt1.SumInGroup(sum1, BasketTypeEnum.AvailableTray); collectResults(opt1.GetProcessingResults()); tmpBs = sum2; } else if (i == 3) { /* Post Grouping processing */ CPromotionProcessorOperation opt1 = new CPromotionProcessorOperation(null, CLanguage.getValue("pkg_group_operation"), bill); CBasketSet mrg = opt1.MergeUsedToAvailable(tmpBs, false); CBasketSet sum1 = opt1.SumInGroup(mrg, BasketTypeEnum.FreeAnnonymous); CBasketSet sum2 = opt1.SumInGroup(sum1, BasketTypeEnum.Available); collectResults(opt1.GetProcessingResults()); tmpBs = sum2; } else if (i == 4) { MPackage defPkg = new MPackage(new CTable("")); defPkg.PackageName = CLanguage.getValue("pkg_default_price"); /* Post Pricing processing */ CPromotionProcessor def1 = new CPromotionProcessorPricingDefault(defPkg, CLanguage.getValue("pkg_group_pricing"), bill); CBasketSet defBs = def1.ApplyPakageLogic(tmpBs); collectResults(def1.GetProcessingResults()); tmpBs = defBs; } } return(tmpBs); }