Esempio n. 1
0
        private void BillTaxInfo_TaxOnBill_UpdateGUI()
        {
            ClearBillTaxValidationState();
            Bill bill = session.GetObjectByKey <Bill>(BillId);

            radBillTaxInfoOnItems.Checked = false;
            radBillTaxInfoOnBill.Checked  = true;

            panelBillTaxInfoOnItems.ClientVisible = false;
            panelBillTaxInfoOnBill.ClientVisible  = true;

            double subtotalAfterPromotion = bill.SumOfItemPrice - bill.SumOfPromotion;

            if (subtotalAfterPromotion != 0)
            {
                lblSubtotalAfterPromotion.Text = String.Format("{0:#,###}", subtotalAfterPromotion);
            }
            else
            {
                lblSubtotalAfterPromotion.Text = "0";
            }

            BillTax billTax = bill.BillTaxs.FirstOrDefault();

            if (billTax == null)
            {
                billTax = new BillTax(session)
                {
                    BillId          = bill,
                    TaxInNumber     = 0,
                    TaxInPercentage = 0
                };
                billTax.Save();
            }
            if (billTax.TaxId != null)
            {
                comboVAT.Value = billTax.TaxId.TaxId;
                comboVAT.DataBindItems();

                double taxTotal = subtotalAfterPromotion * billTax.TaxId.Percentage / 100;
                if (taxTotal != 0)
                {
                    panelBillTaxInfoOnBill_lblVATAmount.Text = String.Format("{0:#,###}", taxTotal);
                }
                else
                {
                    panelBillTaxInfoOnBill_lblVATAmount.Text = "0";
                }
            }
            else
            {
                comboVAT.SelectedIndex = -1;
                panelBillTaxInfoOnBill_lblVATAmount.Text = "0";
            }
        }
Esempio n. 2
0
 public static void UpdateSumOfTax(Session session, NAS.DAL.Invoice.Bill bill)
 {
     #region Update SumOfTax of the bill
     if (bill.TaxCalculationType.Equals(Utility.Constant.CALCULATION_TYPE_ON_BILL_BY_PERCENTAGE))
     {
         BillTax billTax = bill.BillTaxs.FirstOrDefault();
         if (billTax == null)
         {
             billTax = new BillTax(session)
             {
                 BillId          = bill,
                 TaxInNumber     = 0,
                 TaxInPercentage = 0
             };
             billTax.Save();
         }
         if (billTax.TaxId == null)
         {
             bill.SumOfTax = 0;
         }
         else
         {
             bill.SumOfTax = (bill.SumOfItemPrice - bill.SumOfPromotion)
                             * billTax.TaxId.Percentage / 100;
         }
     }
     else if (bill.TaxCalculationType.Equals(Utility.Constant.CALCULATION_TYPE_ON_ITEMS))
     {
         if (bill.PromotionCalculationType.Equals(Utility.Constant.CALCULATION_TYPE_ON_ITEMS))
         {
             var    billItemTaxs = bill.BillItems.SelectMany(r => r.BillItemTaxs);
             double taxInNumber  = billItemTaxs.Sum(r =>
                                                    (r.BillItemId.TotalPrice - r.BillItemId.PromotionInNumber) * r.TaxInPercentage / 100);
             bill.SumOfTax = taxInNumber;
             bill.Save();
         }
         else if (bill.PromotionCalculationType.Equals(Utility.Constant.CALCULATION_TYPE_ON_BILL_BY_AMOUNT) ||
                  bill.PromotionCalculationType.Equals(Utility.Constant.CALCULATION_TYPE_ON_BILL_BY_PERCENTAGE))
         {
             var    billItemTaxs = bill.BillItems.SelectMany(r => r.BillItemTaxs);
             double taxInNumber  = billItemTaxs.Sum(r =>
                                                    r.BillItemId.TotalPrice * r.TaxInPercentage / 100);
             bill.SumOfTax = taxInNumber;
             bill.Save();
         }
     }
     session.FlushChanges();
     #endregion Update SumOfTax of the bill
 }
Esempio n. 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();
            }
        }
Esempio n. 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();
            }
        }