protected CPrice getTierDiscount(MIntervalConfig ivc, CBasketItem bi) { MPackage pkg = getPackage(); double qty = 0.00; if (ivc.MappingType == 0) { //Map by quantity qty = bi.Quantity; } else { //Map by amount qty = bi.GetAmount(); } foreach (MInterval iv in ivc.IntervalItems) { double from = CUtil.StringToDouble(iv.FromValue); double to = CUtil.StringToDouble(iv.ToValue); double value = CUtil.StringToDouble(iv.ConfigValue); if ((qty > from) && (qty <= to)) { CPrice p = new CPrice(); if (ivc.TierScopeType == 0) { //Fixed p.DiscountAmount = value; } else if (ivc.TierScopeType == 1) { //Per unit p.DiscountAmount = bi.Quantity * value; } else { //2 - Percent of amount p.DiscountAmount = (value * bi.GetAmount()) / 100; } return(p); } } return(null); }
public CBasketItemDisplay(CBasketItem bi, BasketTypeEnum bt, int groupNum, int seq, CBasket bk) { initWeight(); basket = bk; basketType = bt; grpNum = groupNum; sequence = seq; bki = bi; si = (MSelectedItem)bi.Item; amount = bki.GetAmount(); totalAmount = bki.GetTotal(); }
private double getSumAmount(CBasketSet input, BasketTypeEnum type) { ArrayList baskets = input.GetAllBasketByType(type); if (baskets == null) { return(0.00); } double total = 0.00; foreach (CBasket bk in baskets) { BasketTypeEnum bt = bk.BasketType; if (type != bt) { continue; } if (!isInBasketType(bt)) { continue; } if (bt == BasketTypeEnum.Bundled) { total = total + bk.BundledAmount; } else { int cnt = bk.GetBasketItemCount(); for (int i = 0; i < cnt; i++) { CBasketItem bi = bk.GetBasketItem(i); total = total + bi.GetAmount(); } } } return(total); }
protected CPrice getStepDiscount(MIntervalConfig ivc, CBasketItem bi) { ArrayList intervals = new ArrayList(); MPackage pkg = getPackage(); int idx = 0; foreach (MInterval iv in ivc.IntervalItems) { iv.Used = 0.00; intervals.Add(iv); idx++; } double qty = 0.00; if (ivc.MappingType == 0) { qty = bi.Quantity; } else { //Map by amount //We can use both total bill amount or amount that we use for looking up qty = bi.GetAmount(); } double left = qty; int cnt = ivc.IntervalItems.Count; idx = 0; while (left > 0) { MInterval iv = (MInterval)intervals[idx]; double from = CUtil.StringToDouble(iv.FromValue); double to = CUtil.StringToDouble(iv.ToValue); double value = CUtil.StringToDouble(iv.ConfigValue); double gap = to - from; iv.RepeatCount++; double used = 0.00; if (left > gap) { left = left - gap; used = gap; } else { used = left; left = 0.00; } iv.Used = iv.Used + used; idx++; if (idx >= cnt) { idx = 0; } } double total = 0.00; foreach (MInterval vi in intervals) { if (ivc.TierScopeType == 0) { //Fixed total = total + vi.RepeatCount * CUtil.StringToDouble(vi.ConfigValue); } else if (ivc.TierScopeType == 1) { //Per unit if (ivc.MappingType == 0) { //Map by quantity total = total + vi.Used * CUtil.StringToDouble(vi.ConfigValue); } } else { //2 - Percent of amount if (ivc.MappingType == 1) { //Map by amount //For step, we can use the vi.Used from the amount that we split it up total = total + vi.Used * CUtil.StringToDouble(vi.ConfigValue) / 100; } } } CPrice p = new CPrice(); p.DiscountAmount = total; return(p); }