Ejemplo n.º 1
0
        public PurchaseInvoiceForm GetDataIntoModel()
        {
            try
            {
                OptionsEntity oData = new OptionsEntity();
                oData = customerRepository.GetOptionSettings();
                PurchaseInvoiceForm PQForm = new PurchaseInvoiceForm();
                PQForm.BEInvoiceDetails = new List <PurchaseInvoiceBEDetailsEntity>();
                PurchaseInvoiceEntity model = new PurchaseInvoiceEntity();
                // model.InvoiceNo = this.InvoiceNo;
                model.InvoiceDate    = DateTime.ParseExact(this.InvoiceDateStr, oData.DateFormat, null);
                model.TotalBeforeTax = this.TotalBeforeTax;
                model.TotalTax       = this.TotalTax;
                model.TotalAfterTax  = this.TotalAfterTax;
                model.PaymentDueDate = DateTime.ParseExact(this.PaymentDueDateStr, oData.DateFormat, null);
                model.OurPONo        = this.OurPONo;
                if (!string.IsNullOrEmpty(InvoiceNo))
                {
                    model.InvoiceNo = this.InvoiceNo;
                }
                else
                {
                    model.InvoiceNo = this.OurPONo;
                    this.InvoiceNo  = this.OurPONo;
                }
                model.SupplierID = this.SelectedSupplierID;

                model.TermsAndConditions = this.TermsAndConditions;
                if (ExcludingTax == true)
                {
                    model.ExcIncGST = false;
                }
                else
                {
                    model.ExcIncGST = true;
                }

                PQForm.Invoice = model;

                foreach (var item in BEDetailsEntity)
                {
                    PurchaseInvoiceBEDetailsEntity pqEntity = new PurchaseInvoiceBEDetailsEntity();
                    pqEntity.SelectedAccountId = item.SelectedAccountId;
                    if (item.SelectedAccountId != null)
                    {
                        var acc = Accounts.Where(e => e.AccountID == item.SelectedAccountId).SingleOrDefault();
                        if (acc != null)
                        {
                            pqEntity.AccountName = acc.AccountName;
                        }
                    }
                    pqEntity.Description   = item.Description;
                    pqEntity.SelectedTaxID = item.SelectedTaxID;
                    if (item.SelectedTaxID != null)
                    {
                        var tax = Taxes.Where(e => e.TaxID == item.SelectedTaxID).SingleOrDefault();
                        if (tax != null)
                        {
                            pqEntity.GSTCode = tax.TaxCode;
                            pqEntity.GSTRate = tax.TaxRate;
                        }
                    }
                    pqEntity.PQAmountStr = item.PQAmountStr;
                    pqEntity.PQAmount    = Convert.ToDecimal(item.PQAmountStr);
                    //pqEntity.TaxList = item.TaxList;
                    pqEntity.PIType = "BE";
                    //pqEntity.Amount= item.PQAmountStr;
                    //pqEntity.AmountBeforeTax= Convert.ToDecimal(item.PQAmountStr);
                    //pqEntity.TaxAmount = Convert.ToDecimal(item.PQAmountStr) * pqEntity.GSTRate;
                    //pqEntity.AmountAfterTax = pqEntity.AmountBeforeTax + pqEntity.TaxAmount;
                    if (item.SelectedAccountId != null && Convert.ToInt32(item.SelectedAccountId) > 0)
                    {
                        PQForm.BEInvoiceDetails.Add(pqEntity);
                    }
                }
                return(PQForm);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
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();
            }
        }