Пример #1
0
        /// <summary>
        /// This method is used to get new PO
        /// </summary>
        public void GetNewPO()
        {
            VisibilityForImage = Visibility.Collapsed;
            IsNew = true;
            ID    = 0;
            SelectedSupplierID = 0;
            BillToAddress      = string.Empty;
            ShipToAddress      = string.Empty;
            //ValidForDays = 0;
            OrderNo             = GenerateNewOrderNo();
            TermsAndConditions  = TandC;
            OrderDate           = DateTime.Now.Date;
            DeliveryDate        = DateTime.Now.Date;
            TotalBeforeTax      = 0;
            TotalTax            = 0;
            TotalAfterTax       = 0;
            TotalBeforeTaxStr   = Convert.ToString(0);
            TotalTaxStr         = Convert.ToString(0);
            TotalAfterTaxStr    = Convert.ToString(0);
            POErrors            = string.Empty;
            AllFieldsEnabled    = true;
            AllFieldsReadonly   = false;
            SupplierEnabled     = true;// added on 23 may 2017
            PurchaseOrderEntity = new PurchaseOrderEntity();
            PODetailsEntity.Clear();

            LstSuppliers       = supplierRepository.GetAllSupplier().Where(s => s.IsInActive != "Y").ToList();
            ProductAndServices = ProductAndServices.OrderBy(x => x.PSName).Where(x => x.IsInActive == "N").ToObservable();
            // PODetailsEntity = new ObservableCollection<DataGridViewModel>();
            var row = new DataGridViewModel(ProductList.Where(x => x.IsInActive == "N").ToList());

            //row.PQQty = 1;
            //row.PQDiscount = 0;

            //row.GSTRate = TaxRate;
            //row.GSTRateStr = Convert.ToString(TaxRate) + "%";
            PODetailsEntity.Add(row);
            OnPropertyChanged("PODetailsEntity");
            var  lstOptions = pandsRepository.GetOptionDetails();
            bool?tax        = lstOptions.ShowAmountIncGST;

            if (tax == true)
            {
                ExcludingTax = false;
                IncludingTax = true;
            }
            else
            {
                IncludingTax = false;
                ExcludingTax = true;
            }
        }
Пример #2
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 (PODetailsEntity != null)
            {
                totalBeforeTax = PODetailsEntity.Sum(e => e.AmountBeforeTax);
                TotalBeforeTax = Math.Round(Convert.ToDecimal(totalBeforeTax), DecimalPlaces);
                mTotalTax      = PODetailsEntity.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);
            }
        }
Пример #3
0
 public bool CanSave(object param)
 {
     if (SelectedSupplierID == 0 || OrderDate == null ||
         PODetailsEntity.Count() == 0)
     {
         return(false);
     }
     else
     {
         if (IsNew == false)
         {
             if (PO_Conv_to_PI == true)
             {
                 return(false);
             }
             else if (Status == Convert.ToByte(PO_Status.Cancelled))
             {
                 return(false);
             }
             else if (Status == Convert.ToByte(PO_Status.Collected))
             {
                 return(false);
             }
             else if (Status == Convert.ToByte(PO_Status.Refunded))
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(true);
         }
     }
 }
Пример #4
0
        public void GetPurchaseOrder(string pqNo)
        {
            // Mouse.OverrideCursor = Cursors.Wait;
            PurchaseOrderForm pqf = pqRepository.GetPurchaseOrder(pqNo);

            this.ID        = pqf.Order.ID;
            this.OrderNo   = pqf.Order.OrderNo;
            this.OrderDate = pqf.Order.OrderDate;
            //this.ValidForDays = pqf.Order.ValidForDays;
            this.DeliveryDate       = pqf.Order.DeliveryDate;
            this.SelectedSupplierID = pqf.Order.SupplierID;
            //if (this.SelectedSupplierID > 0)
            //{
            //    GetSupplierDetails();
            //}

            this.TermsAndConditions = pqf.Order.TermsAndConditions;

            this.TotalBeforeTax    = pqf.Order.TotalBeforeTax;
            this.TotalTax          = pqf.Order.TotalTax;
            this.TotalAfterTax     = pqf.Order.TotalAfterTax;
            this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax);
            this.TotalTaxStr       = Convert.ToString(TotalTax);
            this.TotalAfterTaxStr  = Convert.ToString(TotalAfterTax);

            if (pqf.Order.ExcIncGST == true)
            {
                ExcludingTax = false;
                IncludingTax = true;
                //  PODEntity.GSTRate = 0;
            }
            else
            {
                ExcludingTax = true;
                IncludingTax = false;
                // PODEntity.GSTRate = TaxRate;
            }

            if (PO_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();
            }

            this.Status = pqf.Order.Status;
            if (Status == Convert.ToByte(PO_Status.Cancelled))
            {
                StatusString       = "Cancelled";
                VisibilityForImage = Visibility.Visible;
                AllFieldsEnabled   = false;
                AllFieldsReadonly  = true;
            }
            else if (Status == Convert.ToByte(PO_Status.Collected))
            {
                StatusString       = "Collected";
                VisibilityForImage = Visibility.Visible;
                AllFieldsEnabled   = false;
                AllFieldsReadonly  = true;
            }
            else if (Status == Convert.ToByte(PO_Status.Refunded))
            {
                StatusString       = "Refunded";
                VisibilityForImage = Visibility.Visible;
                AllFieldsEnabled   = false;
                AllFieldsReadonly  = true;
            }
            else
            {
                StatusString       = "";
                VisibilityForImage = Visibility.Collapsed;
                AllFieldsEnabled   = true;
                AllFieldsReadonly  = false;
            }

            //this.PO_Conv_to_PO = pqf.Order.PO_Conv_to_PO;
            this.PO_Conv_to_PI = pqf.Order.PO_Conv_to_PI;

            SupplierEnabled = false;// added on 23 may 2017

            this.PODetailsEntity = new ObservableCollection <DataGridViewModel>();
            foreach (var item in pqf.OrderDetails)
            {
                DataGridViewModel pqEntity = new DataGridViewModel(ProductList);
                pqEntity.SelectedPSID = Convert.ToString(item.PONo);
                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.POQty;
                pqEntity.PQPrice      = Convert.ToString(item.Price);
                pqEntity.PQDiscount   = item.PODiscount;

                //  PODEntity.GSTRate = item.GSTRate;
                pqEntity.PQAmount = item.POAmount;

                PODetailsEntity.Add(pqEntity);
            }
        }
Пример #5
0
        public int ManageDuplicatePandS()
        {
            int rowFocusindex = -1;

            lst = new ObservableCollection <DataGridViewModel>();
            lst = PODetailsEntity;

            var query = lst.GroupBy(x => x.SelectedPSID)
                        .Where(g => g.Count() > 1)
                        .ToList();

            if (query.Count > 0 && PODetailsEntity.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;
                    PODetailsEntity[index1] = obj1;
                    var row = new DataGridViewModel(ProductList);
                    //row.PQQty = 1;
                    //row.GSTRate = TaxRate;
                    //row.GSTRateStr = Convert.ToString(TaxRate) + "%";
                    PODetailsEntity[index2] = row;
                    rowFocusindex           = index2;
                }
                //for (int i = 0; i < 2; i++)
                //{
                //    var p = PODetailsEntity.Where(e => e.SelectedPSID == obj2.SelectedPSID ).FirstOrDefault();
                //    if (p.POPrice == null)
                //    {
                //        PODetailsEntity.Remove(p);
                //    }
                //}

                OnPropertyChanged("PODetailsEntity");
            }
            else
            {
                int count = PODetailsEntity.Count(x => x.SelectedPSID == null);
                if (count == 0)
                {
                    var row = new DataGridViewModel(ProductList);
                    //row.PQQty = 1;
                    //row.GSTRate = TaxRate;
                    //row.GSTRateStr = Convert.ToString(TaxRate) + "%";
                    PODetailsEntity.Add(row);
                    OnPropertyChanged("PODetailsEntity");
                    rowFocusindex = -1;
                }
                else
                {
                    var emptyRow = lst.Where(y => y.SelectedPSID == null).FirstOrDefault();
                    rowFocusindex = PODetailsEntity.IndexOf(emptyRow);
                }
            }

            return(rowFocusindex);
        }