Exemplo n.º 1
0
        private void BillPromotionInfo_PromotionOnBillByPercentage_UpdateData()
        {
            char promotionCalculationType = Utility.Constant.CALCULATION_TYPE_ON_BILL_BY_PERCENTAGE;

            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
            {
                Bill          bill          = uow.GetObjectByKey <Bill>(BillId);
                BillPromotion billPromotion = bill.BillPromotions.FirstOrDefault();

                bill.PromotionCalculationType = promotionCalculationType;

                billPromotion.PromotionInPercentage = (double)spinPromotionOnBillByPercentage.Number;

                double subTotal = bill.BillItems.Sum(r => r.TotalPrice);
                billPromotion.PromotionInNumber = (subTotal * billPromotion.PromotionInPercentage) / 100;

                bill.SumOfPromotion = billPromotion.PromotionInNumber;

                BillBOBase.UpdateSumOfTax(uow, bill);

                bill.Total = bill.SumOfItemPrice - bill.SumOfPromotion + bill.SumOfTax;

                uow.CommitChanges();
            }
        }
Exemplo n.º 2
0
        private void BillPromotionInfo_PromotionOnItems_UpdateData()
        {
            char promotionCalculationType = Utility.Constant.CALCULATION_TYPE_ON_ITEMS;

            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
            {
                Bill          bill          = uow.GetObjectByKey <Bill>(BillId);
                BillPromotion billPromotion = bill.BillPromotions.FirstOrDefault();

                bill.PromotionCalculationType = promotionCalculationType;

                double promotionInNumber =
                    bill.BillItems.Where(r => r.PromotionInNumber > 0).Sum(r => r.PromotionInNumber);

                billPromotion.PromotionInNumber     = promotionInNumber;
                billPromotion.PromotionInPercentage = 0;

                bill.SumOfPromotion = promotionInNumber;

                BillBOBase.UpdateSumOfTax(uow, bill);

                bill.Total = bill.SumOfItemPrice - bill.SumOfPromotion + bill.SumOfTax;

                uow.CommitChanges();
            }
        }