private string ValidatePaymentFromCustomer()
        {
            string msg = string.Empty;

            foreach (var item in PQDetailsEntity)
            {
                if (string.IsNullOrEmpty(item.AmountAdjustedStr))
                {
                    return(msg = "Please enter Amount Adjusted");
                }
                else
                {
                    item.AmountAdjusted = Convert.ToDecimal(item.AmountAdjustedStr);
                    item.Discount       = Convert.ToDecimal(item.DiscountStr);
                }
            }

            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 Cash/Cheque Amount.");
            }

            return(msg);
        }
        private void GetModelData(PaymentFromCustomerForm pqf)
        {
            if (IsNew == false)
            {
                // this.ID = pqf.PaymentFromCustomer.ID;
                this.SelectedCustomerID = pqf.PaymentFromCustomer.CustomerID;
                this.SelectedAccountID  = pqf.PaymentFromCustomer.AccountId;

                this.AmountStr    = pqf.PaymentFromCustomer.AmountStr;
                this.IsCheque     = pqf.PaymentFromCustomer.IsCheque;
                this.CashChequeNo = pqf.PaymentFromCustomer.CashChequeNo;
                this.Remarks      = pqf.PaymentFromCustomer.Remarks;

                if (IsCheque == true)
                {
                    IsChequeTrue  = true;
                    IsChequeFalse = false;
                }
                else
                {
                    IsChequeFalse = true;
                    IsChequeTrue  = false;
                }
            }

            var result = pqf.PaymentFromCustomerDetails.OrderByDescending(e => e.CreatedDate).GroupBy(e => e.SalesNo).Select(e => e.First()).ToList();

            this.PQDetailsEntity = new ObservableCollection <CollectSalesAmountDataGridViewModel>();
            foreach (var item in result)
            {
                CollectSalesAmountDataGridViewModel pqEntity = new CollectSalesAmountDataGridViewModel();
                pqEntity.SalesNo           = item.SalesNo;
                pqEntity.SalesDate         = item.SalesDate;
                pqEntity.SalesDateStr      = changedateformat(item.SalesDate);
                pqEntity.SalesAmountStr    = Convert.ToString(item.SalesAmount);
                pqEntity.SalesAmount       = item.SalesAmount;
                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;

                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 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");
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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");
        }
Ejemplo n.º 8
0
        /// <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);
            }
        }
        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;
        }