private CBasketSet finalizeOutput(CBasketSet input, Hashtable filterHash)
        {
            CBasketSet interim = new CBasketSet();
            MPackage   pkg     = getPackage();

            ArrayList types = input.GetBasketTypes();

            foreach (BasketTypeEnum bt in types)
            {
                ArrayList baskets = input.GetAllBasketByType(bt);

                foreach (CBasket bk in baskets)
                {
                    if (bt == BasketTypeEnum.Bundled)
                    {
                        if (isInBasketType(bt))
                        {
                            totalBundleAmt = totalBundleAmt + bk.BundledAmount;
                        }
                    }

                    CBasket nbk = new CBasket(bt);
                    nbk.CopyEntireFrom(bk);

                    if (isInBasketType(bk.BasketType))
                    {
                        updateBasketItem(nbk, filterHash);
                    }

                    interim.AddBasket(nbk);
                }
            }

            return(interim);
        }
        private Hashtable getAccumulateHash(CBasketSet inBasket)
        {
            Hashtable hash = new Hashtable();

            ArrayList types = inBasket.GetBasketTypes();

            foreach (BasketTypeEnum bt in types)
            {
                if (!isInBasketType(bt))
                {
                    continue;
                }

                ArrayList arr = inBasket.GetAllBasketByType(bt);

                foreach (CBasket bs in arr)
                {
                    int cnt = bs.GetBasketItemCount();

                    for (int i = 0; i < cnt; i++)
                    {
                        CBasketItem bi = bs.GetBasketItem(i);
                        if (bi.IsFinalDiscounted)
                        {
                            //Don't need to discount it again
                            continue;
                        }

                        String key = bi.Key;
                        CPrice p   = null;

                        //At this point, the Amount of Bundle items is 0.00 (will be added in later step)
                        if (!hash.ContainsKey(key))
                        {
                            p             = new CPrice();
                            p.Quantity    = bi.Quantity;
                            p.TotalAmount = bi.GetTotal();

                            hash.Add(key, p);
                        }
                        else
                        {
                            p             = (CPrice)hash[key];
                            p.Quantity    = p.Quantity + bi.Quantity;
                            p.TotalAmount = p.TotalAmount + bi.GetTotal();
                        }
                    }
                }
            }

            return(hash);
        }
Example #3
0
 private static void processBasketSetNode(CBasketSet bset)
 {
     bset.ClearItem();
     foreach (BasketTypeEnum bt in bset.GetBasketTypes())
     {
         ArrayList arr = bset.GetAllBasketByType(bt);
         foreach (CBasket bk in arr)
         {
             processBasketNode(bk);
             if (bk.Items.Count > 0)
             {
                 bset.AddItem(bk);
             }
         }
     }
 }
        protected void copyBasketsExc(CBasketSet dst, CBasketSet src, Hashtable incSet)
        {
            ArrayList types = src.GetBasketTypes();

            foreach (BasketTypeEnum t in types)
            {
                if (!incSet.ContainsKey(t))
                {
                    ArrayList arr = src.GetAllBasketByType(t);
                    if (arr.Count > 0)
                    {
                        dst.AddByArray(arr);
                    }
                }
            }
        }
Example #5
0
        public static void CreateDisplayView(CBasketSet basketSet, MBillSimulate bsim, ItemDisplayUpdate callback)
        {
            ArrayList sorted = new ArrayList();

            bsim.ResultItemsCTable.Clear();

            bsim.ClearPromotionItem("BILL_RESULT_ITEM");
            bsim.ClearPromotionItem("BILL_FREE_ITEM");
            bsim.ClearPromotionItem("BILL_VOUCHER_ITEM");
            bsim.ClearPromotionItem("BILL_POSTGIFT_ITEM");

            double total = 0.00;

            ArrayList bts = basketSet.GetBasketTypes();

            foreach (BasketTypeEnum bt in bts)
            {
                ArrayList arr = basketSet.GetAllBasketByType(bt);
                int       grp = 1;

                foreach (CBasket bk in arr)
                {
                    MPackage pkg = bk.GetAppliedPackage();

                    int cnt = bk.GetBasketItemCount();
                    int seq = 0;
                    for (int j = 0; j < cnt; j++)
                    {
                        CBasketItem bi = bk.GetBasketItem(j);

                        if (bi.Quantity > 0)
                        {
                            CBasketItemDisplay bid = new CBasketItemDisplay(bi, bt, grp, seq, bk);

                            seq++;

                            bid.SetPromotion(pkg);
                            if (bt.ToString().Contains("Tray"))
                            {
                                bid.IsTray = true;
                            }

                            if ((bt == BasketTypeEnum.FreeAnnonymous) || (bt == BasketTypeEnum.FreeAnnonymousTray))
                            {
                                //bsim.FreeItems.Add(bid);
                                bsim.AddPromotionItem(bid, "BILL_FREE_ITEM");
                            }
                            else if (bt == BasketTypeEnum.FreeVoucher)
                            {
                                //bsim.VoucherItems.Add(bid);
                                bsim.AddPromotionItem(bid, "BILL_VOUCHER_ITEM");
                            }
                            else if (bt == BasketTypeEnum.PostFree)
                            {
                                //bsim.PostGiftItems.Add(bid);
                                bsim.AddPromotionItem(bid, "BILL_POSTGIFT_ITEM");
                            }
                            else
                            {
                                sorted.Add(bid);
                            }
                        }
                    }
                    grp++;
                }
            }

            sorted.Sort(new SelectedItemComparator());
            total = populateResultItems(bsim, "BILL_RESULT_ITEM", sorted, callback);

            bsim.TotalAmount    = total.ToString();
            bsim.DiscountAmount = totalFinalDiscount.ToString();
            bsim.NetAmount      = (total - totalFinalDiscount).ToString();
        }
        private CBasketSet finalizeOutput(CBasketSet input, Hashtable filterHash, CPrice accum)
        {
            CBasketSet interim = new CBasketSet();
            MPackage   pkg     = getPackage();

            double totalBundleAmt = getSumAmount(input, BasketTypeEnum.Bundled);

            accum.TotalAmount = accum.TotalAmount + totalBundleAmt;
            double ratio = calculateRatio(accum);

            if (ratio > 0)
            {
                ObservableCollection <MPackageVoucher> gifts = pkg.PackagePostGiftFrees;
                CBasket nbk = new CBasket(BasketTypeEnum.PostFree);

                foreach (MPackageVoucher g in gifts)
                {
                    if (g.EnabledFlag.Equals("N"))
                    {
                        continue;
                    }

                    double qty = CUtil.StringToDouble(g.Quantity) * ratio;
                    if (qty > 0)
                    {
                        MSelectedItem si  = createSelectedItem(g);
                        CBasketItem   nbi = new CBasketItem(si.Key, si, qty);
                        nbk.AddBasketItem(nbi);
                    }
                }

                if (nbk.GetBasketItemCount() > 0)
                {
                    interim.AddBasket(nbk);
                    giftCount++;
                }
            }

            //Copy the originals to output
            ArrayList types = input.GetBasketTypes();

            foreach (BasketTypeEnum bt in types)
            {
                ArrayList baskets = input.GetAllBasketByType(bt);

                foreach (CBasket bk in baskets)
                {
                    CBasket obk = new CBasket(bt);
                    obk.CopyEntireFrom(bk);

                    if (isInBasketType(bk.BasketType) && (giftCount > 0))
                    {
                        updateBasketItem(obk, filterHash);
                    }

                    interim.AddBasket(obk);
                }
            }

            return(interim);
        }