Пример #1
0
        private static double populateResultItems(MBillSimulate billSim, String arrName, ArrayList sorted, ItemDisplayUpdate callback)
        {
            double total = 0.00;
            double avg   = 0.00;

            foreach (CBasketItemDisplay id in sorted)
            {
                if ((id.BasketType == BasketTypeEnum.Bundled) || (id.BasketType == BasketTypeEnum.BundledTray))
                {
                    if (id.Sequence == 0)
                    {
                        avg = getBundleAvgAmount(sorted, id.GroupNo, id.BasketType);
                    }

                    id.Amount      = avg * id.Quantity;
                    id.TotalAmount = id.Amount;
                }

                total = total + id.TotalAmount;
                billSim.AddPromotionItem(id, arrName);

                if (callback != null)
                {
                    callback(id);
                }
                //results.Add(id);
            }
            return(total);
        }
        private void processPromotion(MAccountDoc doc)
        {
            MBillSimulate billSim = doc.BillSimulate;

            priceHash.Clear();

            CPriceProcessor.SetGetCompanyPackageAllCallback(OnixWebServiceAPI.GetCompanyPackageAll);

            CUtil.EnableForm(false, this);
            CPriceProcessor.LoadStandardPackages(companyPackage);
            CUtil.EnableForm(true, this);

            CBasketSet bks = CPriceProcessor.CreateInitialBasketSet(billSim.SelectedItems);

            CUtil.EnableForm(false, this);
            Boolean tmp = billSim.IsModified;

            CBasketSet output = CPriceProcessor.PromotionProcessing(companyPackage, bks, billSim);

            CPriceProcessor.CreateDisplayProcessingTreeView(billSim);
            CPriceProcessor.CreateDisplayView(output, billSim, updateDisplayItem);

            doc.PromotionAmount        = billSim.TotalAmount;
            doc.PromotionFinalDiscount = billSim.DiscountAmount;
            doc.PromotionTotalAmt      = billSim.NetAmount;
            doc.FreeItemCount          = billSim.FreeItemCount.ToString();
            doc.VoucherItemCount       = billSim.VoucherItemCount.ToString();
            doc.PostFreeItemCount      = billSim.PostFreeItemCount.ToString();
            updateDocumentItemPrice(doc);
            doc.NotifyPromotionCalulation();

            doc.FinalDiscount = billSim.DiscountAmount;

            CUtil.EnableForm(true, this);
        }
Пример #3
0
        private void cmdTest_Click(object sender, RoutedEventArgs e)
        {
            WinPackageTest w = new WinPackageTest(vw, billSim, CLanguage.getValue("test"));

            w.ShowDialog();
            billSim = w.BillSimulate;
        }
        private void populateBillSimulate(MAccountDoc doc)
        {
            MBillSimulate bs = doc.BillSimulate;

            bs.ClearSelectedItem();

            bs.DocumentDate   = doc.DocumentDate;
            bs.SimulateTime   = doc.DocumentDate;
            bs.CustomerObj    = doc.CustomerObj;
            bs.CustomerID     = doc.EntityId;
            bs.BranchId       = doc.BranchId;
            bs.DocumentType   = doc.DocumentType;
            bs.DocumentStatus = doc.DocumentStatus;

            foreach (MAccountDocItem di in doc.AccountItem)
            {
                if (di.ExtFlag.Equals("D"))
                {
                    continue;
                }

                MSelectedItem si = new MSelectedItem(new CTable(""));

                si.TrayFlag = "N";
                if (di.IsTrayFlag == true)
                {
                    si.TrayFlag = "Y";
                }

                si.SelectionType            = di.SelectType;
                si.ServiceID                = di.ServiceID;
                si.ItemID                   = di.ItemId;
                si.ServiceCode              = di.ServiceCode;
                si.ServiceName              = di.ServiceName;
                si.ItemCode                 = di.ItemCode;
                si.ItemNameThai             = di.ItemNameThai;
                si.ItemQuantity             = di.Quantity;
                si.ItemCategory             = di.ItemCategory;
                si.ServicePricingDefinition = di.ServicePricingDefinition;
                si.PricingDefination        = di.PricingDefinition;
                si.EnabledFlag              = "Y";

                bs.AddSelectedItem(si);
            }
        }
Пример #5
0
        private void cmdSearch_Click(object sender, RoutedEventArgs e)
        {
            CCriteriaBillSimulate cr = new CCriteriaBillSimulate();

            cr.SetActionEnable(false);
            cr.Init("");

            WinLookupSearch2 w = new WinLookupSearch2(cr, Caption);

            w.ShowDialog();
            if (w.IsOK)
            {
                MBillSimulate bs = (MBillSimulate)w.ReturnedObj;
                CConfig.AddParam("LAST_BILL_SIMULATE_ID", bs.BillSimulateID);
                loadLastBill();

                billSim.IsModified = false;
            }
        }
Пример #6
0
        public WinPackageTest(MCompanyPackage cp, MBillSimulate sources, String cpt)
        {
            if (sources == null)
            {
                billSim = new MBillSimulate(new CTable(""));
            }
            else
            {
                billSim = sources;
                isInit  = true;
            }

            originalState  = billSim.IsModified;
            caption        = cpt;
            companyPackage = cp;

            DataContext = billSim;
            InitializeComponent();
        }
Пример #7
0
        private Boolean isBranchEligible()
        {
            MBillSimulate bl = bill as MBillSimulate;

            ObservableCollection <MPackageBranch> branches = package.PackageBranches;

            foreach (MPackageBranch b in branches)
            {
                if (b.EnabledFlag.Equals("Y"))
                {
                    if (b.BranchId.Equals(bl.BranchId))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #8
0
        public override Tuple <CTable, ObservableCollection <MBaseModel> > QueryData()
        {
            items = OnixWebServiceAPI.GetBillSimulateList(model.GetDbObject());
            lastObjectReturned = OnixWebServiceAPI.GetLastObjectReturned();

            itemSources.Clear();
            int idx = 0;

            foreach (CTable o in items)
            {
                MBillSimulate v = new MBillSimulate(o);

                v.RowIndex = idx;
                itemSources.Add(v);
                idx++;
            }

            Tuple <CTable, ObservableCollection <MBaseModel> > tuple = new Tuple <CTable, ObservableCollection <MBaseModel> >(lastObjectReturned, itemSources);

            return(tuple);
        }
Пример #9
0
        public static void CreateDisplayProcessingTreeView(MBillSimulate billSim)
        {
            String prevGroup         = "";
            CProcessingResultGroup g = null;

            billSim.ProcessingTree.Clear();

            foreach (CProcessingResult r in resultsArr)
            {
                String currGrp = r.GetGroupName();

                if (!currGrp.Equals(prevGroup))
                {
                    g = new CProcessingResultGroup(r);
                    billSim.ProcessingTree.Add(g);
                    prevGroup = currGrp;
                }

                CProcessingResultJob j = createJobResultNode(r);
                g.AddItem(j);
            }
        }
Пример #10
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();
        }