/// <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 bool CanPaymentToSupplier(object param) { if (SelectedSupplierID == 0 || InvoiceDateStr == null || PaymentDueDateStr == null || BEDetailsEntity.Count() == 0) { return(false); } else { return(true); } }
/// <summary> /// This method is used to calculate total amount of PandS with tax /// </summary> public void CalculateTotal() { if (BEDetailsEntity != null) { TotalBeforeTax = BEDetailsEntity.Sum(e => e.AmountBeforeTax); TotalBeforeTax = Math.Round(Convert.ToDecimal(TotalBeforeTax), DecimalPlaces); TotalTax = BEDetailsEntity.Sum(e => e.TaxAmount); TotalTax = Math.Round(Convert.ToDecimal(TotalTax), DecimalPlaces); TotalAfterTax = BEDetailsEntity.Sum(e => e.AmountAfterTax); TotalAfterTax = Math.Round(Convert.ToDecimal(TotalAfterTax), DecimalPlaces); TotalBeforeTaxStr = Convert.ToString(TotalBeforeTax); TotalTaxStr = Convert.ToString(TotalTax); TotalAfterTaxStr = Convert.ToString(TotalAfterTax); } }
public bool CanSave(object param) { string date = this.DateFormat as string; var c = CompanyD.GetCompanyDetails().Comp_year_start_date; if (SelectedSupplierID == 0 || InvoiceDateStr == null || PaymentDueDateStr == null || BEDetailsEntity.Count() == 0) { return(false); } if (InvoiceDateStr != null && PaymentDueDateStr != null) { try { if (!string.IsNullOrEmpty(InvoiceDateStr) && !string.IsNullOrWhiteSpace(InvoiceDateStr) && !string.IsNullOrEmpty(PaymentDueDateStr) && !string.IsNullOrWhiteSpace(PaymentDueDateStr)) { //item.StartDate = item.StartDate.Replace('.', '/'); //item.StartDate = item.StartDate.Replace('-', '/'); //item.EndDate = item.EndDate.Replace('.', '/'); //item.EndDate = item.EndDate.Replace('-', '/'); var Invoicedate = (DateTime.ParseExact(InvoiceDateStr, date, CultureInfo.InvariantCulture)); var Payduedate = (DateTime.ParseExact(PaymentDueDateStr, date, CultureInfo.InvariantCulture)); this.DateErrors = ""; //var End = (DateTime.ParseExact(item.EndDate, date, CultureInfo.InvariantCulture)); if (Invoicedate < c || Payduedate < c) { this.DateErrors = "Date should be greater than Start Financial year"; return(false); } } } catch (Exception ex) { this.DateErrors = "Please enter the date in " + date + " format!"; return(false); } return(true); } else { return(true); } }
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); }