Esempio n. 1
0
        public float AddItemToReceipt(PriceList _PriceList, String itemName, Int16 qty)
        {
            IEnumerable <PriceListItem> tieredPrice = _PriceList._Content.Where(obj => (obj.name == itemName));

            Int16 initialQty = qty;
            float subtotal   = 0;

            do
            {
                for (int j = tieredPrice.First()._SpecialPrice.Count - 1; j >= 0; j--)
                {
                    if (qty >= tieredPrice.First()._SpecialPrice[j].quantity)
                    {
                        subtotal += tieredPrice.First()._SpecialPrice[j].price * tieredPrice.First()._SpecialPrice[j].quantity;
                        total    += tieredPrice.First()._SpecialPrice[j].price * tieredPrice.First()._SpecialPrice[j].quantity;
                        qty      -= tieredPrice.First()._SpecialPrice[j].quantity;
                    }
                }
            } while (qty == 1);

            ReceiptItem _ReceiptItem = new ReceiptItem();

            _ReceiptItem.name            = itemName;
            _ReceiptItem.quantity        = initialQty;
            _ReceiptItem.price           = subtotal;
            _ReceiptItem.discountApplied = false;
            _Content.Add(_ReceiptItem);

            return(_ReceiptItem.price);
        }
Esempio n. 2
0
        public float AddItemToReceipt(PriceList _PriceList, String itemName)
        {
            ReceiptItem _ReceiptItem = new ReceiptItem();

            IEnumerable <PriceListItem> tieredPrice = _PriceList._Content.Where(obj => ((obj.name == itemName)));

            for (int i = 0; i < tieredPrice.First()._SpecialPrice.Count; i++)
            {
                if (tieredPrice.First()._SpecialPrice[i].quantity == 1)
                {
                    _ReceiptItem.price = tieredPrice.First()._SpecialPrice[i].price;
                    break;
                }
            }
            _ReceiptItem.name            = itemName;
            _ReceiptItem.quantity        = 1;
            _ReceiptItem.discountApplied = false;
            _Content.Add(_ReceiptItem);

            total += _ReceiptItem.price;

            return(_ReceiptItem.price);
        }