Пример #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();
            }
        }
Пример #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();
            }
        }
Пример #3
0
        private void BillPromotionInfo_PromotionOnBillByPercentage_UpdateGUI()
        {
            ClearBillPromotionValidationState();
            Bill bill = session.GetObjectByKey <Bill>(BillId);

            radPromotionOnItems.Checked = false;
            radPromotionOnBill.Checked  = true;

            radPromotionOnBillByAmount.Checked     = false;
            radPromotionOnBillByPercentage.Checked = true;

            spinPromotionOnBillByAmount.ReadOnly = true;
            panelPromotionOnItems.Visible        = false;
            panelPromotionOnBill.Visible         = true;
            //Display data to GUI
            //Get promotion total
            double promotionInPercentage = 0;
            double promotionInNumber     = 0;

            if (bill.BillPromotions != null && bill.BillPromotions.Count > 0)
            {
                BillPromotion billPromotion = bill.BillPromotions.FirstOrDefault();
                promotionInPercentage = billPromotion.PromotionInPercentage;
                promotionInNumber     = billPromotion.PromotionInNumber;
            }
            spinPromotionOnBillByPercentage.Number = (decimal)promotionInPercentage;
            spinPromotionOnBillByAmount.Number     = (decimal)promotionInNumber;

            double subTotal = bill.BillItems.Sum(r => r.TotalPrice);

            panelPromotionOnBill_lblSubtotal.Text = String.Format("{0:#,###}", subTotal);

            hfSubtotal["subtotal"] = subTotal;
        }
Пример #4
0
 protected override void CloneBillPromotionData(Session session, Guid billId, ref Bill ret)
 {
     NAS.DAL.Invoice.SalesInvoice source =
         session.GetObjectByKey <NAS.DAL.Invoice.SalesInvoice>(billId);
     foreach (var sourceBillPromotion in source.BillPromotions)
     {
         BillPromotion billPromotion = new BillPromotion(session)
         {
             BillId                = ret,
             PromotionInNumber     = sourceBillPromotion.PromotionInNumber,
             PromotionInPercentage = sourceBillPromotion.PromotionInPercentage,
             PromotionTypeId       = sourceBillPromotion.PromotionTypeId
         };
         billPromotion.Save();
     }
 }
Пример #5
0
        public void UpdatePromotionOnItems(Session session, Guid billId)
        {
            try
            {
                Bill bill = session.GetObjectByKey <Bill>(billId);

                if (!bill.PromotionCalculationType.Equals(Utility.Constant.CALCULATION_TYPE_ON_ITEMS))
                {
                    return;
                }

                BillPromotion billPromotion;

                //If have not any BillPromotion record
                if (bill.BillPromotions == null || bill.BillPromotions.Count == 0)
                {
                    //Create new BillPromotion
                    bill.PromotionCalculationType = Utility.Constant.CALCULATION_TYPE_ON_ITEMS;
                    bill.Save();

                    billPromotion = new BillPromotion(session)
                    {
                        BillId = bill
                    };
                    billPromotion.Save();
                }
                else
                {
                    billPromotion = bill.BillPromotions.FirstOrDefault();
                }
                //update promotion for the bill
                double promotionInNumber =
                    bill.BillItems.Where(r => r.PromotionInNumber > 0).Sum(r => r.PromotionInNumber);
                billPromotion.PromotionInNumber = promotionInNumber;
                billPromotion.Save();

                bill.SumOfPromotion = promotionInNumber;
                bill.Save();
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #6
0
        public void updatePurchaseInvoice(Session session,
                                          NAS.DAL.Invoice.PurchaseInvoice purchaseInvoice,
                                          BillPromotion billPromotionProduct,
                                          BillTax billTaxProduct,
                                          BillPromotion billPromotionService,
                                          BillTax billTaxServce
                                          )
        {
            UnitOfWork uow;

            using (uow = XpoHelper.GetNewUnitOfWork())
            {
                purchaseInvoice.Save();
                billPromotionProduct.Save();
                billTaxProduct.Save();
                billPromotionService.Save();
                billTaxServce.Save();

                uow.CommitChanges();
            }
        }
Пример #7
0
        public void updateSaleInvoice(Session session,
                                      NAS.DAL.Invoice.SalesInvoice salesInvoice,
                                      BillPromotion billPromotionProduct,
                                      BillTax billTaxProduct,
                                      BillPromotion billPromotionService,
                                      BillTax billTaxServce
                                      //SaleInvoiceTransaction saleInvoiceTransaction
                                      )
        {
            UnitOfWork uow;

            using (uow = XpoHelper.GetNewUnitOfWork())
            {
                salesInvoice.Save();
                billPromotionProduct.Save();
                billTaxProduct.Save();
                billPromotionService.Save();
                billTaxServce.Save();

                uow.CommitChanges();
            }
        }
Пример #8
0
        private void UpdateBillPromotion()
        {
            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
            {
                Bill          bill = uow.GetObjectByKey <Bill>(BillId);
                BillPromotion billPromotion;

                //If have not any BillPromotion record
                if (bill.BillPromotions == null || bill.BillPromotions.Count == 0)
                {
                    //Create new BillPromotion
                    bill.PromotionCalculationType = Utility.Constant.CALCULATION_TYPE_ON_ITEMS;

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

                    billPromotion = new BillPromotion(uow)
                    {
                        BillId            = bill,
                        PromotionInNumber = promotionInNumber
                    };

                    bill.SumOfPromotion = promotionInNumber;

                    uow.CommitChanges();
                }

                if (bill.SumOfPromotion != 0)
                {
                    lblPromotionTotal.Text = String.Format("{0:#,###}", bill.SumOfPromotion);
                }
                else
                {
                    lblPromotionTotal.Text = "0";
                }

                BillPromotionInNumber = bill.SumOfPromotion;
            }
        }
Пример #9
0
        public BillPromotion BillPromotionInit(Session session,
                                               Guid BillPromotionId,
                                               double PromotionInPercentage,
                                               double PromotionInNumber,
                                               Guid PromotionTypeId,
                                               Guid BillId
                                               )
        {
            BillPromotion billPromotion = session.GetObjectByKey <BillPromotion>(BillPromotionId);

            if (billPromotion == null)
            {
                billPromotion = new BillPromotion(session);
            }

            billPromotion.BillPromotionId       = BillPromotionId;
            billPromotion.PromotionInPercentage = PromotionInPercentage;
            billPromotion.PromotionInNumber     = PromotionInNumber;
            billPromotion.PromotionTypeId       = session.GetObjectByKey <PromotionType>(PromotionTypeId);
            billPromotion.BillId = session.GetObjectByKey <Bill>(BillId);

            return(billPromotion);
        }