예제 #1
0
        public void GetPurchaseInvoice(string pqNo)
        {
            OptionsEntity oData = new OptionsEntity();
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            oData = purchaseRepository.GetOptionSettings();
            // Mouse.OverrideCursor = Cursors.Wait;
            PurchaseInvoiceForm pqf = pqRepository.GetPurchaseInvoice(pqNo);

            if (pqf.Invoice != null)
            {
                this.ID             = pqf.Invoice.ID;
                this.InvoiceNo      = pqf.Invoice.InvoiceNo;
                this.OurPONo        = pqf.Invoice.OurPONo;
                this.InvoiceDateStr = pqf.Invoice.InvoiceDate.ToString(oData.DateFormat);
                DateTime Dateinstr = (DateTime)pqf.Invoice.PaymentDueDate;
                this.PaymentDueDateStr = Dateinstr.ToString(oData.DateFormat);

                this.SelectedSupplierID = pqf.Invoice.SupplierID;
                if (this.SelectedSupplierID > 0)
                {
                    GetSupplierDetails();
                }

                this.TermsAndConditions = pqf.Invoice.TermsAndConditions;

                this.TotalBeforeTax    = pqf.Invoice.TotalBeforeTax;
                this.TotalTax          = pqf.Invoice.TotalTax;
                this.TotalAfterTax     = pqf.Invoice.TotalAfterTax;
                this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax);
                this.TotalTaxStr       = Convert.ToString(TotalTax);
                this.TotalAfterTaxStr  = Convert.ToString(TotalAfterTax);

                if (pqf.Invoice.ExcIncGST == true)
                {
                    ExcludingTax = false;
                    IncludingTax = true;
                    //  PQDEntity.GSTRate = 0;
                }
                else
                {
                    ExcludingTax = true;
                    IncludingTax = false;
                    // PQDEntity.GSTRate = TaxRate;
                }
                this.PIStatus = pqf.Invoice.PIStatus;
                if (this.PIStatus == Convert.ToByte(PI_Status.Paid))
                {
                    AllFieldsReadonly = true;
                    AllFieldsEnabled  = false;
                }
                else
                {
                    AllFieldsReadonly = false;
                    AllFieldsEnabled  = true;
                }

                this.BEDetailsEntity = new ObservableCollection <AccountDataGridViewModel>();
                if (pqf.BEInvoiceDetails.Count() > 0)
                {
                    foreach (var item in pqf.BEInvoiceDetails)
                    {
                        AccountDataGridViewModel pqEntity = new AccountDataGridViewModel(AccountsList);
                        pqEntity.SelectedAccountName = item.AccountName;

                        var acc = Accounts.Where(e => e.AccountName == item.AccountName).FirstOrDefault();
                        if (acc != null)
                        {
                            pqEntity.SelectedAccountId = acc.AccountID;
                        }
                        pqEntity.PQAmount    = item.PQAmount;
                        pqEntity.PQAmountStr = Convert.ToString(item.PQAmount);
                        pqEntity.GSTRate     = item.GSTRate;
                        pqEntity.Description = item.Description;
                        var tax = Taxes.Where(e => e.TaxRate == item.GSTRate).FirstOrDefault();
                        if (tax != null)
                        {
                            pqEntity.SelectedTaxID = tax.TaxID;
                        }
                        BEDetailsEntity.Add(pqEntity);
                    }
                }
                else
                {
                    var row = new AccountDataGridViewModel(AccountsList);
                    BEDetailsEntity.Add(row);
                    OnPropertyChanged("BEDetailsEntity");
                }
            }
            else
            {
                GetNewPQ();
            }
        }
        void GetOptionsandTaxValues()
        {
            OptionsEntity oData = new OptionsEntity();
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            oData = purchaseRepository.GetOptionSettings();
            if (oData != null)
            {
                this.CurrencyName   = oData.CurrencyCode;   //there is no currency name field in database
                this.CurrencyCode   = oData.CurrencyCode;
                this.CurrencyFormat = oData.NumberFormat;
                this.DateFormat     = oData.DateFormat;
                this.DecimalPlaces  = oData.DecimalPlaces;
                if (oData.ShowAmountIncGST == true)
                {
                    this.IncludingGSTTrue  = true;
                    this.IncludingGSTFalse = false;
                    //int decimalpoints = Convert.ToInt32(DecimalPlaces);
                    //foreach (var item in this.PurchaseQuotationList)
                    //{
                    //    item.QuotationAmount = Math.Round(Convert.ToDouble(item.QuotationAmount), decimalpoints).ToString();
                    //}
                    //this.PurchaseQuotationList = this.PurchaseQuotationList.Where(x => x.ExcIncGST == true).ToList();
                }
                else
                {
                    this.IncludingGSTTrue  = false;
                    this.IncludingGSTFalse = true;
                    int decimalpoints = Convert.ToInt32(DecimalPlaces);
                    //foreach (var item in this.PurchaseQuotationList)
                    //{
                    //    //item.QuotationAmount = item.QuotationAmountExcGST;
                    //    //item.QuotationAmount = Math.Round(Convert.ToDouble(item.QuotationAmountExcGST), decimalpoints).ToString();
                    //    item.QuotationAmount = Math.Round(Convert.ToDouble(item.QuotationAmount), decimalpoints).ToString();
                    //}
                    //commented on 23 May 2017
                    //if (this.PurchaseQuotationList != null)
                    //    this.PurchaseQuotationList = this.PurchaseQuotationList.Where(x => x.ExcIncGST == false).ToList();
                }
            }
            else
            {
                this.CurrencyName   = "USD";
                this.CurrencyCode   = "USD";
                this.CurrencyFormat = "en-US";
                this.DateFormat     = "dd/MM/yyyy";
            }



            //var objDefaultTax = new List<TaxModel>();
            var objDefaultTax = purchaseRepository.GetDefaultTaxes().FirstOrDefault();

            if (objDefaultTax != null)
            {
                this.TaxName = objDefaultTax.TaxName;
                //this.TaxName = objDefaultTax.TaxRate;
            }
            else
            {
                this.TaxName = "GST";
                //this.TaxRate = 0;
            }
        }