コード例 #1
0
ファイル: DeclareVat.ascx.cs プロジェクト: ewin66/dev
        protected void BindData(Bill bill)
        {
            double _amount     = 0;
            double _taxAmount  = 0;
            double _taxPercent = 0;

            var taxPercentageList = BillBOBase.GetDistinctTaxPercentageList(bill.BillId);

            if (taxPercentageList == null || taxPercentageList.Count() == 0)
            {
                _amount     = bill.SumOfItemPrice;
                _taxAmount  = 0;
                _taxPercent = 0;
            }
            else
            {
                _taxPercent = taxPercentageList.First().Percentage;
                _taxAmount  = bill.SumOfTax;
                _amount     = bill.SumOfItemPrice - bill.SumOfPromotion;
            }

            lblTaxPercent.Text = _taxPercent > 0 ? _taxPercent.ToString() : "-";
            lblTaxAmount.Text  = _taxAmount > 0 ? _taxAmount.ToString("n0") : "-";
            lblAmount.Text     = _amount > 0 ? _amount.ToString("n0") : "-";

            XPQuery <BillTaxClaim>        billTaxClaim        = new XPQuery <BillTaxClaim>(session);
            XPQuery <SaleInvoiceArtiface> saleInvoiceArtiface = new XPQuery <SaleInvoiceArtiface>(session);



            var list = from btc in billTaxClaim.AsEnumerable()
                       join sia in saleInvoiceArtiface on btc.BillId.BillId equals sia.BillId.BillId
                       where btc.BillId.BillId == bill.BillId
                       select new C011GTGT()
            {
                Amount          = btc.Amount,
                ClaimItem       = btc.ClaimItem,
                Comment         = btc.Comment,
                CreateDate      = btc.CreateDate,
                TaxInNumber     = btc.TaxInNumber,
                TaxInPercentage = btc.TaxInPercentage,
                TotalAmount     = btc.TotalAmount,
                BillCode        = sia.IssuedArtifaceCode,
                SeriesNumber    = sia.SeriesNumber,
                ObjectName      = btc.BillId.SourceOrganizationId.Name,
                ObjectTax       = btc.BillId.SourceOrganizationId.TaxNumber,
                LegalInvoiceArtifactTypeCode = sia.LegalInvoiceArtifactTypeId.Code,
                LegalInvoiceArtifactTypeName = sia.LegalInvoiceArtifactTypeId.Name
            };

            try
            {
                grdBillTaxClaim.DataSource = list.ToList();
                grdBillTaxClaim.DataBind();
                grdBillTaxClaim.ExpandAll();
            }
            catch
            {
            }
        }
コード例 #2
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();
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
0
ファイル: BillItemEditForm.ascx.cs プロジェクト: ewin66/dev
 protected void gridviewBillItem_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableDataCellEventArgs e)
 {
     if (e.DataColumn.Name.Equals("VATInPercentage"))
     {
         var val = gridviewBillItem.GetRowValues(e.VisibleIndex, "BillItemId");
         if (val == null)
         {
             return;
         }
         if (!BillBOBase.IsMostAppearTaxPercentage((Guid)val))
         {
             e.Cell.BackColor = System.Drawing.Color.FromArgb(230, 185, 184);
         }
     }
 }
コード例 #5
0
        private void BillTaxInfo_TaxOnItems_UpdateGUI()
        {
            ClearBillTaxValidationState();


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

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

            Bill bill = session.GetObjectByKey <Bill>(BillId, true);

            double taxInNumber = bill.SumOfTax;

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

            var distinctTaxPercentageList = BillBOBase.GetDistinctTaxPercentageList(bill.BillId);

            if (distinctTaxPercentageList == null ||
                distinctTaxPercentageList.Count() != 1)
            {
                lblVATOnBillPercentage.Text = "N/A";
            }
            else
            {
                int countBillItems =
                    bill.BillItems.Count(r => r.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE);
                if (countBillItems != distinctTaxPercentageList.First().Count)
                {
                    lblVATOnBillPercentage.Text = "N/A";
                }
                else
                {
                    lblVATOnBillPercentage.Text = String.Format("{0:#,###}", distinctTaxPercentageList.First().Percentage);
                }
            }
        }
コード例 #6
0
ファイル: DeclareVat.ascx.cs プロジェクト: ewin66/dev
        protected void cpDeclareVat_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[]         para = e.Parameter.Split('|');
            CriteriaOperator filter;

            switch (para[0])
            {
            case "show":
                cboItem.Text = "";
                bill         = session.GetObjectByKey <Bill>(Guid.Parse(para[1]));

                if (bill != null)
                {
                    filter = new BinaryOperator("BillId.BillId", bill.BillId, BinaryOperatorType.Equal);
                    SaleInvoiceArtiface saleInvoiceArtiface = session.FindObject <SaleInvoiceArtiface>(filter);

                    if (saleInvoiceArtiface != null)
                    {
                        cboLegalInvoiceArtifactType.Value = saleInvoiceArtiface.LegalInvoiceArtifactTypeId.LegalInvoiceArtifactTypeId;
                        txtIssuedArtifactCode.Text        = saleInvoiceArtiface.IssuedArtifaceCode;
                        txtSeriesNumber.Text = saleInvoiceArtiface.SeriesNumber;
                    }
                    else
                    {
                        cboLegalInvoiceArtifactType.Value = null;
                        txtIssuedArtifactCode.Text        = "";
                        txtSeriesNumber.Text = "";
                    }

                    filter       = new BinaryOperator("BillId.BillId", Guid.Parse(para[1]), BinaryOperatorType.Equal);
                    billTaxClaim = session.FindObject <BillTaxClaim>(filter);

                    if (billTaxClaim != null)
                    {
                        filter = new BinaryOperator("Name", billTaxClaim.ClaimItem, BinaryOperatorType.Equal);
                        Item item = session.FindObject <Item>(filter);

                        if (item != null)
                        {
                            cboItem.Value = item.ItemId;
                        }

                        txtDescription.Text = billTaxClaim.Comment;
                    }
                    else
                    {
                        switch (bill.PaymentTerm)
                        {
                        case 1:
                            txtDescription.Text = "Tiền mặt";
                            break;

                        case 2:
                            txtDescription.Text = "Chuyển khoản";
                            break;

                        default:
                            txtDescription.Text = "";
                            break;
                        }
                    }

                    if (bill is SalesInvoice)
                    {
                        m_VatType = Constant.VAT_OUT;
                    }
                    else if (bill is PurchaseInvoice)
                    {
                        m_VatType = Constant.VAT_IN;
                    }

                    //Bill salesInvoice = session.GetObjectByKey<SalesInvoice>(bill.BillId);
                    //m_VatType = Constant.VAT_OUT;
                    //if (salesInvoice == null)
                    //{
                    //    m_VatType = Constant.VAT_IN;
                    //}

                    BindData(bill);
                }

                break;

            case "declare":

                filter = new BinaryOperator("BillId", Guid.Parse(para[1]), BinaryOperatorType.Equal);
                bill   = session.GetObjectByKey <Bill>(Guid.Parse(para[1]));

                if (bill != null)
                {
                    filter       = new BinaryOperator("BillId.BillId", Guid.Parse(para[1]), BinaryOperatorType.Equal);
                    billTaxClaim = session.FindObject <BillTaxClaim>(filter);
                    if (billTaxClaim == null)
                    {
                        billTaxClaim            = new BillTaxClaim(session);
                        billTaxClaim.BillId     = bill;
                        billTaxClaim.CreateDate = bill.IssuedDate;
                        billTaxClaim.RowStatus  = 1;
                        bill.TaxClaimStatus     = Constant.VAT_YES_DECLARE;
                    }

                    billTaxClaim.ClaimItem = cboItem.Text;
                    var taxPercentageList = BillBOBase.GetDistinctTaxPercentageList(bill.BillId);
                    if (taxPercentageList == null || taxPercentageList.Count() == 0)
                    {
                        billTaxClaim.TaxInPercentage = 0;
                    }
                    else
                    {
                        billTaxClaim.TaxInPercentage = taxPercentageList.First().Percentage;
                    }
                    //billTaxClaim.TaxInPercentage = bill.BillItems[0].BillItemTaxs[0].TaxInPercentage;
                    billTaxClaim.Amount = bill.SumOfItemPrice - bill.SumOfPromotion;
                    //billTaxClaim.TaxInNumber = billTaxClaim.Amount * billTaxClaim.TaxInPercentage / 100;
                    billTaxClaim.TaxInNumber    = bill.SumOfTax;
                    billTaxClaim.Comment        = txtDescription.Text;
                    billTaxClaim.LastUpdateDate = DateTime.Now;
                    billTaxClaim.CreateDate     = bill.IssuedDate;

                    billTaxClaim.Save();

                    filter = new BinaryOperator("BillId.BillId", bill.BillId, BinaryOperatorType.Equal);
                    SaleInvoiceArtiface saleInvoiceArtiface = session.FindObject <SaleInvoiceArtiface>(filter);
                    if (saleInvoiceArtiface == null)
                    {
                        saleInvoiceArtiface = new SaleInvoiceArtiface(session);
                        saleInvoiceArtiface.SaleInvoiceArtifaceId = Guid.NewGuid();
                        saleInvoiceArtiface.RowStatus             = 1;
                        saleInvoiceArtiface.BillId = bill;
                    }

                    NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType legalInvoiceArtifactType = session.GetObjectByKey <NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType>(Guid.Parse(cboLegalInvoiceArtifactType.Value.ToString()));
                    if (legalInvoiceArtifactType != null)
                    {
                        saleInvoiceArtiface.LegalInvoiceArtifactTypeId = legalInvoiceArtifactType;
                    }

                    saleInvoiceArtiface.SeriesNumber       = txtSeriesNumber.Text;
                    saleInvoiceArtiface.IssuedArtifaceCode = txtIssuedArtifactCode.Text;

                    saleInvoiceArtiface.Save();

                    //SalesInvoice salesInvoice = session.GetObjectByKey<SalesInvoice>(bill.BillId);
                    //m_VatType = Constant.VAT_OUT;
                    //if (salesInvoice == null)
                    //{
                    //    m_VatType = Constant.VAT_IN;
                    //}

                    if (bill is SalesInvoice)
                    {
                        m_VatType = Constant.VAT_OUT;
                    }
                    else if (bill is PurchaseInvoice)
                    {
                        m_VatType = Constant.VAT_IN;
                    }

                    BindData(bill);

                    cpDeclareVat.JSProperties.Add("cpDisableAccept", "Disable");
                }

                break;
            }
        }