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);
        }
Пример #2
0
        public CBasketSet MergeUsedToAvailable(CBasketSet inBasket, Boolean trayFlag)
        {
            BasketTypeEnum type1 = BasketTypeEnum.Available;
            BasketTypeEnum type2 = BasketTypeEnum.Used;
            String         name  = "MergeUsedToAvailable";

            if (trayFlag)
            {
                type1 = BasketTypeEnum.AvailableTray;
                type2 = BasketTypeEnum.UsedTray;
                name  = name + "Tray";
            }

            CBasketSet output = new CBasketSet();

            CProcessingResult res = new CProcessingResult(name);

            res.SetInputBasketSet(inBasket.Clone());

            ArrayList useds  = inBasket.GetAllBasketByType(type2);
            ArrayList avails = inBasket.GetAllBasketByType(type1);

            if (avails != null)
            {
                foreach (CBasket a in avails)
                {
                    //Move the original 'Available' basket
                    CBasket na = new CBasket(type1);
                    na.CopyEntireFrom(a);
                    output.AddBasket(na);
                }
            }

            if (useds != null)
            {
                foreach (CBasket u in useds)
                {
                    CBasket nb = new CBasket(type1);
                    nb.CopyEntireFrom(u);

                    output.AddBasket(nb);
                }
            }

            Hashtable filterSet = new Hashtable();

            filterSet[type1] = null;
            filterSet[type2] = null;
            copyBasketsExc(output, inBasket, filterSet);

            res.IsOperation = true;
            res.SetOutputBasketSet(output);
            res.SetStatus(ProcessingResultStatus.ProcessingSuccess);
            addProcessingResult(res);

            return(output);
        }
        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);
        }