public RefundFromSupplierForm GetDataIntoModel()
        {
            OptionsEntity             oData = new OptionsEntity();
            ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository();

            oData = purchaseRepository.GetOptionSettings();
            RefundFromSupplierForm PQForm = new RefundFromSupplierForm();

            PQForm.RefundFromSupplierDetails = new List <RefundFromSupplierDetailsEntity>();
            RefundFromSupplierEntity model = new RefundFromSupplierEntity();

            //  this.ID = pqf.RefundFromSupplier.ID;
            model.SupplierID   = this.SelectedSupplierID;
            model.AccountId    = this.SelectedAccountID;
            model.Date         = DateTime.ParseExact(this.DateStr, oData.DateFormat, null);
            model.AmountStr    = this.AmountStr;
            model.Amount       = Convert.ToDecimal(this.AmountStr);
            model.IsCheque     = this.IsCheque;
            model.CashChequeNo = this.CashChequeNo;
            model.Remarks      = this.Remarks;
            if (this.IsChequeTrue == true)
            {
                model.IsCheque = true;
            }
            else
            {
                model.IsCheque = false;
            }

            PQForm.RefundFromSupplier = model;

            foreach (var item in PQDetailsEntity.Where(e => Convert.ToDecimal(e.AmountAdjustedStr) != 0))
            {
                RefundFromSupplierDetailsEntity pqEntity = new RefundFromSupplierDetailsEntity();

                pqEntity.PurchaseNo     = item.PurchaseNo;
                pqEntity.PurchaseDate   = item.PurchaseDate;
                pqEntity.PurchaseAmount = Convert.ToDecimal(item.PurchaseAmountStr);
                //item.PurchaseAmount=pqEntity.PurchaseAmount;
                pqEntity.PaymentDueDate = Convert.ToDateTime(item.PaymentDueDateStr);
                //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);

                PQForm.RefundFromSupplierDetails.Add(pqEntity);
            }
            return(PQForm);
        }
예제 #2
0
        public RefundFromSupplierForm GetDataIntoModel()
        {
            RefundFromSupplierForm PQForm = new RefundFromSupplierForm();

            PQForm.RefundFromSupplierDetails = new List <RefundFromSupplierDetailsEntity>();
            RefundFromSupplierEntity model = new RefundFromSupplierEntity();

            //  this.ID = pqf.RefundFromSupplier.ID;
            model.SupplierID   = this.SelectedSupplierID;
            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;
            if (this.IsChequeTrue == true)
            {
                model.IsCheque = true;
            }
            else
            {
                model.IsCheque = false;
            }

            PQForm.RefundFromSupplier = model;

            foreach (var item in PQDetailsEntity)
            {
                RefundFromSupplierDetailsEntity pqEntity = new RefundFromSupplierDetailsEntity();

                pqEntity.PurchaseNo     = item.PurchaseNo;
                pqEntity.PurchaseDate   = item.PurchaseDate;
                pqEntity.PurchaseAmount = Convert.ToDecimal(item.PurchaseAmountStr);
                //item.PurchaseAmount=pqEntity.PurchaseAmount;
                pqEntity.PaymentDueDate = Convert.ToDateTime(item.PaymentDueDateStr);
                //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);

                PQForm.RefundFromSupplierDetails.Add(pqEntity);
            }
            return(PQForm);
        }
        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);
            }
        }