Example #1
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();
     }
 }
Example #2
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;
            }
        }
Example #3
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();
            }
        }
Example #4
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();
            }
        }