예제 #1
0
        protected override long insert(bool forceWrite, bool callSaveMethod)
        {
            var deduction = (from d in new QueryableEntity<MiscCharge>()
                             where d.Default == true
                             orderby d.ChargeOrder
                             select d).ToList();
            var order = (from o in new QueryableEntity<Order>()
                         where o.OrderID == this.OrderID
                         select o).AppFirst();
            MiscCharge tempD = new MiscCharge();
            foreach (var d in deduction)
            {
                if (tempD == null)
                    tempD = d;
                if (tempD.ChargeOrder == d.ChargeOrder)
                    TempValue = order.Amount;
                else if (tempD.ChargeOrder <= d.ChargeOrder)
                {
                    tempD = d;
                    TempValue = order.Amount + this.Amount;
                }

                if (d.DeductionType == DeductionType.Fixed)
                    this.Amount += d.Value;
                else if (d.DeductionType == DeductionType.Percentage)
                    this.Amount += (TempValue * d.Value) / 100;

            }
            return base.insert(forceWrite, callSaveMethod);
        }
예제 #2
0
        private void removeMiscChargesForItem()
        {           
            var deduction = (from d in new QueryableEntity<MiscCharge>()
                             where d.Default == true
                             orderby d.ChargeOrder
                             select d).ToList();
            
            MiscCharge tempD = new MiscCharge();
            foreach (var d in deduction)
            {
                if (tempD == null)
                    tempD = d;
                if (tempD.ChargeOrder == d.ChargeOrder)
                    TempValue = Amount;
                else if (tempD.ChargeOrder <= d.ChargeOrder)
                {
                    tempD = d;
                    TempValue = Amount + ExtraCharge;
                }

                if (d.DeductionType == DeductionType.Fixed)
                    ExtraCharge = d.Value;
                else if (d.DeductionType == DeductionType.Percentage)
                    ExtraCharge = (TempValue * d.Value) / 100;

                var orderMiscCharge = (from o in new QueryableEntity<OrderMiscCharges>()
                                       where o.OrderID == this.OrderID && o.MiscChargeID == d.DeductionID
                                       select o).AppFirst();
                orderMiscCharge.Amount -= ExtraCharge;
                orderMiscCharge.TempMoney = -ExtraCharge;
                orderMiscCharge.update();
            }
        }