private void GetModelData(PaymentToSupplierForm pqf) { if (IsNew == false) { // this.ID = pqf.PaymentToSupplier.ID; this.SelectedSupplierID = pqf.PaymentToSupplier.SupplierID; this.SelectedAccountID = pqf.PaymentToSupplier.AccountId; this.Date = pqf.PaymentToSupplier.Date; this.AmountStr = pqf.PaymentToSupplier.AmountStr; this.IsCheque = pqf.PaymentToSupplier.IsCheque; if (IsCheque == true) { IsChequeTrue = true; IsChequeFalse = false; } else { IsChequeFalse = true; IsChequeTrue = false; } this.CashChequeNo = pqf.PaymentToSupplier.CashChequeNo; this.Remarks = pqf.PaymentToSupplier.Remarks; } var result = pqf.PaymentToSupplierDetails.OrderByDescending(e => e.CreatedDate).GroupBy(e => e.PurchaseNo).Select(e => e.First()).ToList(); this.PQDetailsEntity = new ObservableCollection <CollectAmountDataGridViewModel>(); foreach (var item in result) { CollectAmountDataGridViewModel pqEntity = new CollectAmountDataGridViewModel(); pqEntity.PurchaseNo = item.PurchaseNo; pqEntity.PurchaseDate = item.PurchaseDate; pqEntity.PurchaseDateStr = changedateformat(item.PurchaseDate); pqEntity.PurchaseAmountStr = Convert.ToString(item.PurchaseAmount); pqEntity.PurchaseAmount = item.PurchaseAmount; pqEntity.PaymentDueDate = item.PaymentDueDate; pqEntity.PaymentDueDateStr = changedateformat(item.PaymentDueDate); pqEntity.AmountDue = item.AmountDue; pqEntity.AmountDueStr = Convert.ToString(item.AmountDue); pqEntity.AmountAdjusted = item.AmountAdjusted; pqEntity.AmountAdjustedStr = Convert.ToString(item.AmountAdjusted); pqEntity.Discount = item.Discount; pqEntity.DiscountStr = Convert.ToString(item.Discount); PQDetailsEntity.Add(pqEntity); OnPropertyChanged("PQDetailsEntity"); } PQDetailsEntityLst = PQDetailsEntity; }
/// <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; QuotationNo = GenerateNewQuotationNo(); TermsAndConditions = TandC; QuotationDate = DateTime.Now.Date; TotalBeforeTax = 0; TotalTax = 0; TotalAfterTax = 0; TotalBeforeTaxStr = Convert.ToString(0); TotalTaxStr = Convert.ToString(0); TotalAfterTaxStr = Convert.ToString(0); PQErrors = string.Empty; AllFieldsEnabled = true; SupplierEnabled = true; AllFieldsReadonly = false; PurchaseQuotationEntity = new PurchaseQuotationEntity(); PQDetailsEntity.Clear(); LstSuppliers = supplierRepository.GetAllSupplier().Where(s => s.IsInActive != "Y").ToList(); ProductAndServices = ProductAndServices.OrderBy(x => x.PSName).Where(x => x.IsInActive == "N").ToObservable(); // PQDetailsEntity = new ObservableCollection<DataGridViewModel>(); var row = new DataGridViewModel(ProductList.Where(x => x.IsInActive == "N").ToList()); //row.PQQty = 1; //row.PQDiscount = 0; //row.GSTRateStr = Convert.ToString(TaxRate) + "%"; //row.GSTRate = TaxRate; PQDetailsEntity.Add(row); OnPropertyChanged("PQDetailsEntity"); var lstOptions = pandsRepository.GetOptionDetails(); bool?tax = lstOptions.ShowAmountIncGST; if (tax == true) { ExcludingTax = false; IncludingTax = true; } else { IncludingTax = false; ExcludingTax = true; } }
public void OnAmountChange(int index) { var query = PQDetailsEntity.ToList(); if (query != null) { query[index].AmountAdjustedStr = (Math.Abs(decimal.Parse(query[index].AmountDueStr.ToString()))).ToString(); query[index].AmountAdjusted = Convert.ToDecimal(query[index].AmountAdjustedStr); //query[index].AmountDueStr = Convert.ToString("0"); } TotalSalesAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.SalesAmount)); TotalAmountDue = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountDue)); TotalAmountPaid = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted)); // OnPropertyChanged("PQDetailsEntity"); }
public void OnAmountChange(int index) { var query = PQDetailsEntity.ToList(); if (query != null) { query[index].AmountAdjustedStr = query[index].AmountDueStr; query[index].AmountAdjusted = Convert.ToDecimal(query[index].AmountAdjustedStr); //query[index].AmountDueStr = Convert.ToString("0"); } // decimal? totalOfAdjustedAmount = query.Sum(x => Convert.ToDecimal(x.AmountAdjustedStr)); TotalAdjutedAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted)); //OnPropertyChanged("PQDetailsEntity"); }
private void GetModelData(RefundToCustomerForm pqf) { if (IsNew == false) { this.ID = pqf.RefundToCustomer.ID; this.SelectedCustomerID = pqf.RefundToCustomer.CustomerID; this.SelectedAccountID = pqf.RefundToCustomer.AccountId; this.AmountStr = pqf.RefundToCustomer.AmountStr; this.IsCheque = pqf.RefundToCustomer.IsCheque; if (IsCheque == true) { IsChequeTrue = true; } else { IsChequeFalse = true; } this.CashChequeNo = pqf.RefundToCustomer.CashChequeNo; this.Remarks = pqf.RefundToCustomer.Remarks; } this.PQDetailsEntity = new ObservableCollection <CollectSalesAmountDataGridViewModel>(); foreach (var item in pqf.RefundToCustomerDetails) { CollectSalesAmountDataGridViewModel pqEntity = new CollectSalesAmountDataGridViewModel(); pqEntity.SalesNo = item.SalesNo; pqEntity.SalesDate = item.SalesDate; pqEntity.SalesDateStr = changedateformat(item.SalesDate); pqEntity.SalesAmount = Math.Abs(decimal.Parse(item.SalesAmount.ToString())); pqEntity.SalesAmountStr = Convert.ToString(pqEntity.SalesAmount); pqEntity.PaymentDueDate = item.PaymentDueDate; pqEntity.PaymentDueDateStr = changedateformat(item.PaymentDueDate); pqEntity.AmountDue = Math.Abs(decimal.Parse(item.AmountDue.ToString())); pqEntity.AmountDueStr = Convert.ToString(pqEntity.AmountDue); pqEntity.AmountAdjusted = Math.Abs(decimal.Parse(item.AmountAdjusted.ToString())); pqEntity.AmountAdjustedStr = Convert.ToString(pqEntity.AmountAdjusted); pqEntity.Discount = item.Discount; PQDetailsEntity.Add(pqEntity); OnPropertyChanged("PQDetailsEntity"); } TotalSalesAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.SalesAmount)); TotalAmountDue = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountDue)); TotalAmountPaid = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted)); PQDetailsEntityLst = PQDetailsEntity; }
public void GetDebitNote(object param) { if (param != null) { DebitNoteForm pqf = dnRepository.GetDebitNoteDetails(Convert.ToString(param)); this.ID = pqf.DebitNote.ID; this.DebitNo = pqf.DebitNote.DebitNo; this.DebitDate = pqf.DebitNote.DebitDate; this.SupplierCreditNoteNo = pqf.DebitNote.SupplierCreditNoteNo; this.SupplierCreditNoteDate = pqf.DebitNote.SupplierCreditNoteDate; this.SupplierCreditNoteAmount = pqf.DebitNote.SupplierCreditNoteAmount; this.SelectedSupplierID = pqf.DebitNote.SupplierID; this.PurchaseInvoiceID = pqf.DebitNote.PurchaseInvoiceID; this.PurchaseInvoiceNo = pqf.DebitNote.PurchaseInvoiceNo; this.TermsAndConditions = pqf.DebitNote.TermsAndConditions; this.TotalBeforeTax = pqf.DebitNote.TotalBeforeTax; this.TotalTax = pqf.DebitNote.TotalTax; this.TotalAfterTax = pqf.DebitNote.TotalAfterTax; this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax); this.TotalTaxStr = Convert.ToString(TotalTax); this.TotalAfterTaxStr = Convert.ToString(TotalAfterTax); this.Status = pqf.DebitNote.Status; this.PQDetailsEntity = new ObservableCollection <DataGridViewModel>(); foreach (var item in pqf.InvoiceDetails) { DataGridViewModel pqEntity = new DataGridViewModel(ProductList); pqEntity.SelectedPSID = Convert.ToString(item.PINo); pqEntity.PandSCode = item.PandSCode; pqEntity.PandSName = item.PandSName; pqEntity.GSTRate = Math.Round(Convert.ToDecimal(item.GSTRate), DecimalPlaces); pqEntity.GSTRateStr = Convert.ToString(pqEntity.GSTRate) + "%"; pqEntity.PQQty = item.PIQty; pqEntity.PQPrice = Convert.ToString(item.Price); pqEntity.PQDiscount = Math.Round((decimal)item.PIDiscount, 2); // PQDEntity.GSTRate = item.GSTRate; pqEntity.PQAmount = item.PIAmount; PQDetailsEntity.Add(pqEntity); } } }
public void GetCreditNote(object param) { if (param != null) { CreditNoteForm pqf = dnRepository.GetCreditNoteDetails(Convert.ToString(param)); this.ID = pqf.CreditNote.ID; this.CreditNo = pqf.CreditNote.CreditNo; this.CreditDate = pqf.CreditNote.CreditDate; this.CustomerDebitNoteNo = pqf.CreditNote.CustomerDebitNoteNo; this.CustomerDebitNoteDate = pqf.CreditNote.CustomerDebitNoteDate; this.CustomerDebitNoteAmount = pqf.CreditNote.CustomerDebitNoteAmount; this.SelectedCustomerID = pqf.CreditNote.CustomerID; this.SalesInvoiceID = pqf.CreditNote.SalesInvoiceID; this.SalesInvoiceNo = pqf.CreditNote.SalesInvoiceNo; this.TermsAndConditions = pqf.CreditNote.TermsAndConditions; this.TotalBeforeTax = pqf.CreditNote.TotalBeforeTax; this.TotalTax = pqf.CreditNote.TotalTax; this.TotalAfterTax = pqf.CreditNote.TotalAfterTax; this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax); this.TotalTaxStr = Convert.ToString(TotalTax); this.TotalAfterTaxStr = Convert.ToString(TotalAfterTax); this.Status = pqf.CreditNote.Status; this.PQDetailsEntity = new ObservableCollection <DataGridViewModel>(); foreach (var item in pqf.InvoiceDetails) { DataGridViewModel pqEntity = new DataGridViewModel(ProductList); pqEntity.SelectedPSID = Convert.ToString(item.SINo); pqEntity.PandSCode = item.PandSCode; pqEntity.PandSName = item.PandSName; pqEntity.GSTRate = item.GSTRate; pqEntity.SQQty = item.SIQty; pqEntity.SQPrice = Convert.ToString(item.Price); pqEntity.SQDiscount = item.SIDiscount; // PQDEntity.GSTRate = item.GSTRate; pqEntity.SQAmount = item.SIAmount; PQDetailsEntity.Add(pqEntity); } } }
private string ValidateAdjustCreditNote() { string msg = string.Empty; int i = 0; foreach (var item in PQDetailsEntity) { if (string.IsNullOrEmpty(item.AmountAdjustedStr)) { //return msg = "Please enter Amount Adjusted"; item.CheckAmountAdjusted = false; } else { i++; item.CheckAmountAdjusted = true; item.AmountAdjusted = Convert.ToDecimal(item.AmountAdjustedStr); item.Discount = Convert.ToDecimal(item.DiscountStr); } } if (i == 0) { return(msg = "Please enter Amount Adjusted"); } if (IsNew == true) { //if (!string.IsNullOrEmpty(CashChequeNo)) //{ // if (psRepository.IsChequeNoPresent(CashChequeNo)) // { // return msg = "Entry against Cheque No is already done"; // } //} } if (Convert.ToDecimal(AmountStr) != (PQDetailsEntity.Sum(e => e.AmountAdjusted))) { return(msg = "Total of Amount Adjusted column must be equal to Credit Note Amount."); } return(msg); }
public void OnAmountChange(int index) { var query = PQDetailsEntity.ToList(); if (query != null) { query[index].AmountAdjustedStr = query[index].AmountDueStr; query[index].AmountAdjusted = Convert.ToDecimal(query[index].AmountAdjustedStr); //query[index].AmountDueStr = Convert.ToString("0"); } TotalAmountPaid = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted)); //decimal? sum= query.Where(x=>x.AmountAdjustedStr != null).Sum(g => decimal.Parse(g.AmountAdjustedStr)); //decimal sum =Convert.ToDecimal(query[index-0].AmountAdjustedStr); //decimal x = sum + sum; // decimal? sum = query.Sum(g => decimal.Parse(g.AmountAdjustedStr)); // OnPropertyChanged("PQDetailsEntity"); }
void GetNewPS(object param) { IsNew = true; // SelectedCustomerID = 0; IsCustomerEnabled = true; IsCreditNoEnabled = true; PSErrors = string.Empty; GetNewPS(); if (PQDetailsEntity != null) { if (PQDetailsEntity.Count > 0) { PQDetailsEntity.Clear(); var row = new CollectSalesAmountDataGridViewModel(); PQDetailsEntity.Add(row); OnPropertyChanged("PQDetailsEntity"); } } }
void GetNewPS(object param) { IsNew = true; // SelectedCustomerID = 0; IsCustomerEnabled = true; IsCashChequeEnabled = true; GetNewPS(); SelectedCustomerID = 0; if (PQDetailsEntity != null) { if (PQDetailsEntity.Count > 0) { PQDetailsEntity.Clear(); //var row = new CollectSalesAmountDataGridViewModel(); //PQDetailsEntity.Add(row); OnPropertyChanged("PQDetailsEntity"); } } }
/// <summary> /// This method is used to calculate total amount of PandS with tax /// </summary> public void CalculateTotal(bool excludeTax) { decimal?totalBeforeTax = 0; decimal?mTotalTax = 0; decimal?mTotalAfterTax = 0; if (PQDetailsEntity != null) { totalBeforeTax = PQDetailsEntity.Sum(e => e.AmountBeforeTax); TotalBeforeTax = Math.Round(Convert.ToDecimal(totalBeforeTax), DecimalPlaces); mTotalTax = PQDetailsEntity.Sum(e => e.TaxAmount); TotalTax = Math.Round(Convert.ToDecimal(mTotalTax), DecimalPlaces); mTotalAfterTax = totalBeforeTax + mTotalTax; TotalAfterTax = Math.Round(Convert.ToDecimal(mTotalAfterTax), DecimalPlaces); TotalBeforeTaxStr = Convert.ToString(TotalBeforeTax); TotalTaxStr = Convert.ToString(TotalTax); TotalAfterTaxStr = Convert.ToString(TotalAfterTax); } }
void GetNewPS(object param) { IsNew = true; // SelectedSupplierID = 0; IsCashChequeEnabled = true; IsSupplierEnabled = true; IsTextBoxReadOnly = false; PSErrors = string.Empty; GetNewPS(); SelectedSupplierID = 0; if (PQDetailsEntity != null) { if (PQDetailsEntity.Count > 0) { PQDetailsEntity.Clear(); // var row = new CollectAmountDataGridViewModel(); // PQDetailsEntity.Add(row); OnPropertyChanged("PQDetailsEntity"); } } }
public bool CanSave(object param) { if (SelectedSupplierID == 0 || InvoiceDate == null || PaymentDueDate == null || PQDetailsEntity.Count() == 0) { return(false); } else if (PIStatus == Convert.ToByte(PI_Status.Cancelled)) { return(false); } else if (PIStatus == Convert.ToByte(PI_Status.Paid)) { return(false); } else if (PIStatus == Convert.ToByte(PI_Status.Adjusted)) { return(false); } else { return(true); } }
public bool CanSave(object param) { string date = this.DateFormat as string; var c = CompanyD.GetCompanyDetails().Comp_year_start_date; if ((SelectedSupplierID != null || SelectedSupplierID != 0) && (SelectedAccountID != null || SelectedAccountID != 0) && !(string.IsNullOrEmpty(AmountStr)) && !(string.IsNullOrEmpty(CashChequeNo)) && Date != null) { if (DateStr != null) { try { if (!string.IsNullOrEmpty(DateStr) && !string.IsNullOrWhiteSpace(DateStr)) { //item.StartDate = item.StartDate.Replace('.', '/'); //item.StartDate = item.StartDate.Replace('-', '/'); //item.EndDate = item.EndDate.Replace('.', '/'); //item.EndDate = item.EndDate.Replace('-', '/'); var Start = (DateTime.ParseExact(DateStr, date, CultureInfo.InvariantCulture)); this.DateErrors = ""; //var End = (DateTime.ParseExact(item.EndDate, date, CultureInfo.InvariantCulture)); if (Start < 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); } if (PQDetailsEntity == null) { return(false); } else { foreach (var item in PQDetailsEntity.Where(e => Convert.ToDecimal(e.AmountAdjustedStr) != 0)) { RefundFromSupplierDetailsEntity pqEntity = new RefundFromSupplierDetailsEntity(); var amtDue = pqEntity.AmountDue = Convert.ToDecimal(item.AmountDueStr); var amtadjusted = pqEntity.AmountAdjusted = Convert.ToDecimal(item.AmountAdjustedStr); //if (amtadjusted <= amtDue) //{ // this.DateErrors = "Adjusted Amount Can't exceed with Amount Due"; // return false; //} if (amtadjusted < 0) { this.DateErrors = "amount adjusted Can't be negative"; return(false); } else if (amtadjusted > amtDue) { this.DateErrors = "Amount adjusted must not exceed amount due"; return(false); } } return(true); } return(true); } return(true); } else { return(false); } }
public void GetPurchaseQuotation(string pqNo) { // Mouse.OverrideCursor = Cursors.Wait; PurchaseQuotationForm pqf = pqRepository.GetPurchaseQuotation(pqNo); this.ID = pqf.Quotation.ID; this.QuotationNo = pqf.Quotation.QuotationNo; this.QuotationDate = pqf.Quotation.QuotationDate; this.ValidForDays = pqf.Quotation.ValidForDays; this.SelectedSupplierID = pqf.Quotation.SupplierID; //if (this.SelectedSupplierID > 0) //{ // GetSupplierDetails(); //} this.TermsAndConditions = pqf.Quotation.TermsAndConditions; this.TotalBeforeTax = pqf.Quotation.TotalBeforeTax; this.TotalTax = pqf.Quotation.TotalTax; this.TotalAfterTax = pqf.Quotation.TotalAfterTax; this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax); this.TotalTaxStr = Convert.ToString(TotalTax); this.TotalAfterTaxStr = Convert.ToString(TotalAfterTax); if (pqf.Quotation.ExcIncGST == true) { ExcludingTax = false; IncludingTax = true; // PQDEntity.GSTRate = 0; } else { ExcludingTax = true; IncludingTax = false; // PQDEntity.GSTRate = TaxRate; } this.PQ_Conv_to_PO = pqf.Quotation.PQ_Conv_to_PO; this.PQ_Conv_to_PI = pqf.Quotation.PQ_Conv_to_PI; if (PQ_Conv_to_PO == true || PQ_Conv_to_PI == true) { AllFieldsReadonly = true; AllFieldsEnabled = false; } else { AllFieldsReadonly = false; AllFieldsEnabled = true; LstSuppliers = supplierRepository.GetAllSupplier().Where(s => s.IsInActive != "Y").ToList(); ProductAndServices = ProductAndServices.OrderBy(x => x.PSName).Where(x => x.IsInActive != "Y").ToObservable(); } SupplierEnabled = false; this.PQDetailsEntity = new ObservableCollection <DataGridViewModel>(); foreach (var item in pqf.QuotationDetails) { DataGridViewModel pqEntity = new DataGridViewModel(ProductList); pqEntity.SelectedPSID = Convert.ToString(item.PQNo); pqEntity.PandSCode = item.PandSCode; pqEntity.PandSName = item.PandSName; pqEntity.GSTRate = Math.Round(Convert.ToDecimal(item.GSTRate), DecimalPlaces); pqEntity.GSTRateStr = Convert.ToString(pqEntity.GSTRate) + "%"; pqEntity.PQQty = item.PQQty; pqEntity.PQPrice = Convert.ToString(item.Price); pqEntity.PQDiscount = item.PQDiscount; // PQDEntity.GSTRate = item.GSTRate; pqEntity.PQAmount = item.PQAmount; PQDetailsEntity.Add(pqEntity); } }
public void GetCreditNote(object param) { OptionsEntity oData = new OptionsEntity(); ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository(); oData = purchaseRepository.GetOptionSettings(); if (param != null) { CreditNoteForm pqf = dnRepository.GetCreditNoteDetails(Convert.ToString(param)); this.ID = pqf.CreditNote.ID; this.CreditNo = pqf.CreditNote.CreditNo; this.CreditDate = pqf.CreditNote.CreditDate; this.CustomerDebitNoteNo = pqf.CreditNote.CustomerDebitNoteNo; if (CustomerDebitNoteDate == null) { this.CustomerDebitNoteDate = pqf.CreditNote.CustomerDebitNoteDate; } else { DateTime DateinStr = (DateTime)pqf.CreditNote.CustomerDebitNoteDate; this.CustomerDebitNoteDateStr = DateinStr.ToString(oData.DateFormat); } this.CustomerDebitNoteAmount = pqf.CreditNote.CustomerDebitNoteAmount; this.SelectedCustomerID = pqf.CreditNote.CustomerID; this.SalesInvoiceID = pqf.CreditNote.SalesInvoiceID; this.SalesInvoiceNo = pqf.CreditNote.SalesInvoiceNo; this.TermsAndConditions = pqf.CreditNote.TermsAndConditions; this.TotalBeforeTax = Convert.ToDecimal(pqf.CreditNote.TotalBeforeTax); this.TotalTax = Convert.ToDecimal(pqf.CreditNote.TotalTax); this.TotalAfterTax = Convert.ToDecimal(pqf.CreditNote.TotalAfterTax); this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax); this.TotalTaxStr = Convert.ToString(TotalTax); this.TotalAfterTaxStr = Convert.ToString(TotalAfterTax); this.Status = pqf.CreditNote.Status; if (this.Status == 1) { RubberAdjusted = true; } this.PQDetailsEntity = new ObservableCollection <DataGridViewModel>(); foreach (var item in pqf.InvoiceDetails) { DataGridViewModel pqEntity = new DataGridViewModel(ProductList); pqEntity.SelectedPSID = Convert.ToString(item.SINo); pqEntity.PandSCode = item.PandSCode; pqEntity.PandSName = item.PandSName; pqEntity.GSTRate = item.GSTRate; pqEntity.SQQty = item.SIQty; pqEntity.SQPrice = Convert.ToString(item.Price); pqEntity.SQDiscount = item.SIDiscount; // PQDEntity.GSTRate = item.GSTRate; pqEntity.SQAmount = item.SIAmount; PQDetailsEntity.Add(pqEntity); } } }
public void GetPurchaseInvoice(string pqNo) { // Mouse.OverrideCursor = Cursors.Wait; PurchaseInvoiceForm pqf = pqRepository.GetPurchaseInvoice(pqNo); this.ID = pqf.Invoice.ID; this.InvoiceNo = pqf.Invoice.InvoiceNo; this.OurPONo = pqf.Invoice.OurPONo; this.InvoiceDate = pqf.Invoice.InvoiceDate; this.PaymentDueDate = pqf.Invoice.PaymentDueDate; 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; } if (this.PIStatus == Convert.ToByte(PI_Status.Paid)) { AllFieldsReadonly = true; AllFieldsEnabled = false; } else { AllFieldsReadonly = false; AllFieldsEnabled = true; LstSuppliers = supplierRepository.GetAllSupplier().Where(s => s.IsInActive != "Y").ToList(); ProductAndServices = ProductAndServices.OrderBy(x => x.PSName).Where(x => x.IsInActive != "Y").ToObservable(); } this.PIStatus = pqf.Invoice.PIStatus; if (PIStatus == Convert.ToByte(PI_Status.Cancelled)) { StatusString = "Cancelled"; VisibilityForImage = Visibility.Visible; AllFieldsEnabled = false; AllFieldsReadonly = true; } else if (PIStatus == Convert.ToByte(PI_Status.Paid)) { StatusString = " Paid"; VisibilityForImage = Visibility.Visible; AllFieldsEnabled = false; AllFieldsReadonly = true; } else if (PIStatus == Convert.ToByte(PI_Status.Adjusted)) { StatusString = "Adjusted"; VisibilityForImage = Visibility.Visible; AllFieldsEnabled = false; AllFieldsReadonly = true; } else { StatusString = ""; VisibilityForImage = Visibility.Collapsed; AllFieldsEnabled = true; AllFieldsReadonly = false; } SupplierEnabled = false;// added on 23 may 2017 this.PQDetailsEntity = new ObservableCollection <DataGridViewModel>(); foreach (var item in pqf.InvoiceDetails) { DataGridViewModel pqEntity = new DataGridViewModel(ProductList); pqEntity.SelectedPSID = Convert.ToString(item.PINo); pqEntity.PandSCode = item.PandSCode; pqEntity.PandSName = item.PandSName; pqEntity.GSTRate = Math.Round(Convert.ToDecimal(item.GSTRate), DecimalPlaces); pqEntity.GSTRateStr = Convert.ToString(pqEntity.GSTRate) + "%"; pqEntity.PQQty = item.PIQty; pqEntity.PQPrice = Convert.ToString(item.Price); pqEntity.PQDiscount = item.PIDiscount; // PQDEntity.GSTRate = item.GSTRate; pqEntity.PQAmount = item.PIAmount; PQDetailsEntity.Add(pqEntity); } }
public int ManageDuplicatePandS() { int rowFocusindex = -1; lst = new ObservableCollection <DataGridViewModel>(); lst = PQDetailsEntity; var query = lst.GroupBy(x => x.SelectedPSID) .Where(g => g.Count() > 1) .ToList(); if (query.Count > 0 && PQDetailsEntity.Count > 1) { var obj1 = query[0].ElementAt(0); var obj2 = query[0].ElementAt(1); int? qty = 1; decimal?productPrice2 = 0; decimal?discountP2 = 0; qty = query[0].ElementAt(0).PQQty + query[0].ElementAt(1).PQQty; productPrice2 = Convert.ToDecimal(query[0].ElementAt(1).PQPrice); discountP2 = query[0].ElementAt(1).PQDiscount; var index1 = lst.IndexOf(query[0].ElementAt(0)); var index2 = lst.IndexOf(query[0].ElementAt(1)); if (productPrice2 != null) { obj1.PQQty = qty; obj1.PQPrice = Convert.ToString(productPrice2); obj1.PQDiscount = discountP2; PQDetailsEntity[index1] = obj1; var row = new DataGridViewModel(ProductList); //row.PQQty = 1; //row.GSTRate = TaxRate; //row.GSTRateStr = Convert.ToString(TaxRate) + "%"; PQDetailsEntity[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("PQDetailsEntity"); } else { int count = PQDetailsEntity.Count(x => x.SelectedPSID == null); if (count == 0) { var row = new DataGridViewModel(ProductList); //row.PQQty = 1; //row.GSTRate = TaxRate; //row.GSTRateStr = Convert.ToString(TaxRate) + "%"; PQDetailsEntity.Add(row); OnPropertyChanged("PQDetailsEntity"); rowFocusindex = -1; } else { var emptyRow = lst.Where(y => y.SelectedPSID == null).FirstOrDefault(); rowFocusindex = PQDetailsEntity.IndexOf(emptyRow); } } return(rowFocusindex); }
public AdjustCreditNoteForm GetDataIntoModel() { OptionsEntity oData = new OptionsEntity(); ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository(); oData = purchaseRepository.GetOptionSettings(); AdjustCreditNoteForm PQForm = new AdjustCreditNoteForm(); PQForm.AdjustCreditNoteDetails = new List <AdjustCreditNoteDetailsEntity>(); AdjustCreditNoteEntity model = new AdjustCreditNoteEntity(); // this.ID = pqf.AdjustCreditNote.ID; model.CustomerID = this.SelectedCustomerID; model.AccountId = this.SelectedAccountID; model.Date = this.Date; model.AmountStr = this.AmountStr; model.Amount = Convert.ToDecimal(this.AmountStr); model.IsCheque = this.IsCheque; //model.CashChequeNo = this.CashChequeNo; model.Remarks = this.Remarks; model.CreditNoteNo = this.CreditNoteNo; //entity of adjust credit note model.AdjustCreditNoteNumber = this.AdjustCreditNoteNumber; model.AdjustCreditNoteDate = DateTime.ParseExact(this.AdjustCreditNoteDateStr, oData.DateFormat, null); //end if (this.IsChequeTrue == true) { model.IsCheque = true; } else { model.IsCheque = false; } PQForm.AdjustCreditNote = model; foreach (var item in PQDetailsEntity.Where(e => !(string.IsNullOrEmpty(e.AmountAdjustedStr)))) { AdjustCreditNoteDetailsEntity pqEntity = new AdjustCreditNoteDetailsEntity(); pqEntity.SalesNo = item.SalesNo; pqEntity.SalesDate = item.SalesDate; pqEntity.SalesAmount = Convert.ToDecimal(item.SalesAmountStr); //item.SalesAmount=pqEntity.SalesAmount; //pqEntity.PaymentDueDate = Convert.ToDateTime(item.PaymentDueDateStr); //pqEntity.PaymentDueDate = DateTime.ParseExact(item.PaymentDueDateStr, "dd'/'MM'/'yyyy", CultureInfo.InvariantCulture); pqEntity.PaymentDueDate = DateTime.ParseExact(item.PaymentDueDateStr, "dd'/'MM'/'yy", CultureInfo.InvariantCulture); //pqEntity.AmountDueStr = Convert.ToString(item.AmountDue); pqEntity.AmountDue = Convert.ToDecimal(item.AmountDueStr); // pqEntity.AmountAdjustedStr = Convert.ToString(item.AmountAdjusted); pqEntity.AmountAdjusted = Convert.ToDecimal(item.AmountAdjustedStr); pqEntity.Discount = Convert.ToDecimal(item.DiscountStr); pqEntity.CheckAmountAdjusted = item.CheckAmountAdjusted; PQForm.AdjustCreditNoteDetails.Add(pqEntity); } return(PQForm); }
private void GetModelData(AdjustDebitNoteForm pqf) { if (IsNew == false) { this.ID = pqf.AdjustDebitNote.ID; this.SelectedSupplierID = pqf.AdjustDebitNote.SupplierID; this.DebitNoteNo = pqf.AdjustDebitNote.DebitNoteNo; this.SelectedAccountID = pqf.AdjustDebitNote.AccountId; this.Date = pqf.AdjustDebitNote.Date; this.AmountStr = pqf.AdjustDebitNote.AmountStr; this.IsCheque = pqf.AdjustDebitNote.IsCheque; this.AdjustDebitNoteNumber = pqf.AdjustDebitNote.AdjustDebitNoteNumber; if (IsCheque == true) { IsChequeTrue = true; } else { IsChequeFalse = true; } //this.CashChequeNo = pqf.AdjustDebitNote.CashChequeNo; this.Remarks = pqf.AdjustDebitNote.Remarks; if (this.ListSuppliers != null) { foreach (var item in this.ListSuppliers) { if (item.ID == this.SelectedSupplierID) { this.SelectedSupplierName = item.SupplierName; } } } } var result = pqf.AdjustDebitNoteDetails.OrderByDescending(e => e.UpdatedDate).GroupBy(e => e.PurchaseNo).Select(e => e.First()).ToList(); OptionsEntity oData = new OptionsEntity(); ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository(); oData = purchaseRepository.GetOptionSettings(); this.PQDetailsEntity = new ObservableCollection <CollectAmountDataGridViewModel>(); if (result != null) { foreach (var item in result) { CollectAmountDataGridViewModel pqEntity = new CollectAmountDataGridViewModel(); pqEntity.PurchaseNo = item.PurchaseNo; if (item.PurchaseDate != null) { pqEntity.PurchaseDate = item.PurchaseDate; DateTime Dateinstr = (DateTime)item.PurchaseDate; pqEntity.PurchaseDateStr = Dateinstr.ToString(oData.DateFormat); } else { } pqEntity.PurchaseAmountStr = Convert.ToString(item.PurchaseAmount); pqEntity.PurchaseAmount = item.PurchaseAmount; if (item.PaymentDueDate != null) { pqEntity.PaymentDueDate = item.PaymentDueDate; DateTime Dateinstr1 = (DateTime)item.PaymentDueDate; pqEntity.PaymentDueDateStr = changedateformat(item.PaymentDueDate); } else { } pqEntity.AmountDueStr = Convert.ToString(item.AmountDue); //pqEntity.AmountDue = item.AmountDue; pqEntity.AmountAdjusted = item.AmountAdjusted; pqEntity.AmountAdjustedStr = Convert.ToString(item.AmountAdjusted); //pqEntity.Discount = item.Discount; PQDetailsEntity.Add(pqEntity); TotalPurchaseAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.PurchaseAmount)); TotalAdjutedAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted)); OnPropertyChanged("PQDetailsEntity"); } } PQDetailsEntityLst = PQDetailsEntity; }