/// <summary> /// This method is used to get new PQ /// </summary> public void GetNewPQ() { IsNew = true; ID = 0; SelectedSupplierID = 0; BillToAddress = string.Empty; ShipToAddress = string.Empty; // ValidForDays = 0; InvoiceNo = string.Empty; // PQDetailsEntity.Clear(); this.OurPONo = GenerateNewInvoiceNo(); TotalBeforeTax = 0; TotalTax = 0; TotalAfterTax = 0; TotalBeforeTaxStr = Convert.ToString(0); TotalTaxStr = Convert.ToString(0); TotalAfterTaxStr = Convert.ToString(0); PQErrors = string.Empty; AllFieldsEnabled = true; AllFieldsReadonly = false; this.PaymentDueDateStr = null; this.InvoiceNo = "PI-" + pqRepository.GetNewLatestInvoiceNo(); PurchaseInvoiceEntity = new PurchaseInvoiceEntity(); BEDetailsEntity.Clear(); LstSuppliers = supplierRepository.GetAllSupplier().Where(s => s.IsInActive != "Y").ToList(); Accounts = Accounts.OrderBy(x => x.AccountName).Where(x => x.IsInactive == "N").ToObservable(); //PQDetailsEntity = new ObservableCollection<DataGridViewModel>(); var row = new AccountDataGridViewModel(AccountsList.Where(x => x.IsInactive == "N").ToList()); row.TaxList = Taxes.ToList();; BEDetailsEntity.Add(row); OnPropertyChanged("BEDetailsEntity"); }
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(); } }
public int ManageDuplicatePandS() { int rowFocusindex = -1; lst = new ObservableCollection <AccountDataGridViewModel>(); lst = BEDetailsEntity; var query = lst.GroupBy(x => x.SelectedAccountId) .Where(g => g.Count() > 1) .ToList(); if (query.Count > 0 && BEDetailsEntity.Count > 1) { var obj1 = query[0].ElementAt(0); var obj2 = query[0].ElementAt(1); var index1 = lst.IndexOf(query[0].ElementAt(0)); var index2 = lst.IndexOf(query[0].ElementAt(1)); //obj1.PQQty = qty; //obj1.PQPrice = Convert.ToString(productPrice2); //obj1.PQDiscount = discountP2; BEDetailsEntity[index1] = obj1; var row = new AccountDataGridViewModel(AccountsList); row.GSTRate = TaxRate; BEDetailsEntity[index2] = row; rowFocusindex = index2; //for (int i = 0; i < 2; i++) //{ // var p = PQDetailsEntity.Where(e => e.SelectedPSID == obj2.SelectedPSID ).FirstOrDefault(); // if (p.PQPrice == null) // { // PQDetailsEntity.Remove(p); // } //} OnPropertyChanged("BEDetailsEntity"); } else { int count = BEDetailsEntity.Count(x => x.SelectedAccountId == null); if (count == 0) { var row = new AccountDataGridViewModel(AccountsList); //row.PQQty = 1; //row.GSTRate = TaxRate; //row.GSTRateStr = Convert.ToString(TaxRate) + "%"; BEDetailsEntity.Add(row); OnPropertyChanged("BEDetailsEntity"); rowFocusindex = -1; } else { var emptyRow = lst.Where(y => y.SelectedAccountId == null).FirstOrDefault(); rowFocusindex = BEDetailsEntity.IndexOf(emptyRow); } } return(rowFocusindex); }