Ejemplo n.º 1
0
        public string GetNewTransactionNumber(TransactionHeaderDTO transaction)
        {
            var tranNumber = "";

            try
            {
                var selectedWarehouse = new WarehouseService(true)
                                        .Find(transaction.WarehouseId.ToString());
                var prefix = transaction.TransactionType.ToString().Substring(0, 1);
                var clDto  = new ClientService(true).GetClient();

                if (clDto != null && clDto.HasOnlineAccess)
                {
                    prefix = Singleton.Edition == AMStockEdition.OnlineEdition ? prefix + "S" : prefix + "L";
                }

                var lastNum = transaction.Id + 1000000;

                var subLength = 1;
                if (clDto != null && clDto.Organizations.Count > 1)
                {
                    subLength = 0;
                }

                transaction.TransactionNumber = prefix +
                                                selectedWarehouse.WarehouseNumber.ToString().Substring(subLength) +
                                                lastNum.ToString().Substring(1);
                _transactionRepository.InsertUpdate(transaction);
                _unitOfWork.Commit();
            }
            catch (Exception exception)
            {
                tranNumber = "Problem getting transaction number, try again..." + Environment.NewLine + exception.Message;
            }
            return(tranNumber);
        }
Ejemplo n.º 2
0
        public IEnumerable <PaymentDTO> GetAll(SearchCriteria <PaymentDTO> criteria = null)
        {
            IEnumerable <PaymentDTO> piList = new List <PaymentDTO>();

            try
            {
                if (criteria != null && criteria.CurrentUserId != -1)
                {
                    var warehouseList = new WarehouseService(true)
                                        .GetWarehousesPrevilegedToUser(criteria.CurrentUserId).ToList();
                    if (criteria.SelectedWarehouseId != null)
                    {
                        warehouseList = warehouseList.Where(w => w.Id == criteria.SelectedWarehouseId).ToList();
                    }

                    foreach (var warehouse in warehouseList.Where(w => w.Id != -1))
                    {
                        var pdto = Get();

                        foreach (var cri in criteria.FiList)
                        {
                            pdto.FilterList(cri);
                        }

                        #region By Warehouse
                        var warehouse1 = warehouse;
                        pdto.FilterList(p => p.WarehouseId == warehouse1.Id);
                        #endregion

                        #region By Duration

                        if (criteria.BeginingDate != null)
                        {
                            var beginDate = new DateTime(criteria.BeginingDate.Value.Year, criteria.BeginingDate.Value.Month,
                                                         criteria.BeginingDate.Value.Day, 0, 0, 0);
                            pdto.FilterList(p => p.PaymentDate >= beginDate);
                        }

                        if (criteria.EndingDate != null)
                        {
                            var endDate = new DateTime(criteria.EndingDate.Value.Year, criteria.EndingDate.Value.Month,
                                                       criteria.EndingDate.Value.Day, 23, 59, 59);
                            pdto.FilterList(p => p.PaymentDate <= endDate);
                        }

                        #endregion

                        #region By Transaction Type
                        if (criteria.TransactionType != -1)
                        {
                            switch ((TransactionTypes)criteria.TransactionType)
                            {
                            case TransactionTypes.Sale:
                            {
                                pdto.FilterList(p => p.PaymentType == PaymentTypes.Sale);
                            }
                            break;

                            case TransactionTypes.Purchase:
                            {
                                pdto.FilterList(p => p.PaymentType == PaymentTypes.Purchase);
                            }
                            break;
                            }
                        }
                        #endregion

                        #region By Payment List Types
                        if (criteria.PaymentListType != -1)
                        {
                            switch ((PaymentListTypes)criteria.PaymentListType)
                            {
                            case PaymentListTypes.All:
                                break;

                            case PaymentListTypes.Cleared:
                                pdto.FilterList(p => p.Status == PaymentStatus.Cleared);
                                break;

                            case PaymentListTypes.NotCleared:
                                pdto.FilterList(p => p.Status == PaymentStatus.NotCleared);
                                break;

                            case PaymentListTypes.NotClearedandOverdue:
                                pdto.FilterList(p => p.Status == PaymentStatus.NotCleared && (p.DueDate != null && p.DueDate > DateTime.Now));
                                break;

                            case PaymentListTypes.NotDeposited:
                                pdto.FilterList(p => p.Status == PaymentStatus.NotDeposited && p.PaymentMethod == PaymentMethods.Cash);
                                break;

                            case PaymentListTypes.DepositedNotCleared:
                                pdto.FilterList(p => p.Status == PaymentStatus.NotCleared && p.PaymentMethod == PaymentMethods.Cash);
                                break;

                            case PaymentListTypes.DepositedCleared:
                                pdto.FilterList(p => p.Status == PaymentStatus.Cleared && p.PaymentMethod == PaymentMethods.Cash);
                                break;

                            case PaymentListTypes.CreditNotCleared:
                                pdto.FilterList(p => p.Status == PaymentStatus.NotCleared && p.PaymentMethod == PaymentMethods.Credit);
                                break;

                            case PaymentListTypes.CheckNotCleared:
                                pdto.FilterList(p => p.Status == PaymentStatus.NotCleared && p.PaymentMethod == PaymentMethods.Check);
                                break;

                            case PaymentListTypes.CheckCleared:
                                pdto.FilterList(p => p.Status == PaymentStatus.Cleared && p.PaymentMethod == PaymentMethods.Check);
                                break;
                            }
                        }
                        #endregion

                        #region By Payment Method
                        if (criteria.PaymentMethodType != -1)
                        {
                            switch ((PaymentMethods)criteria.PaymentMethodType)
                            {
                            case PaymentMethods.Cash:
                                pdto.FilterList(p => p.PaymentMethod == PaymentMethods.Cash);
                                break;

                            case PaymentMethods.Credit:
                                pdto.FilterList(p => p.PaymentMethod == PaymentMethods.Credit);
                                break;

                            case PaymentMethods.Check:
                                pdto.FilterList(p => p.PaymentMethod == PaymentMethods.Check);
                                break;
                            }
                        }
                        #endregion

                        #region By Payment Type
                        if (criteria.PaymentType != -1)
                        {
                            switch (criteria.PaymentType)
                            {
                            case 2:
                                pdto.FilterList(p => p.PaymentType == PaymentTypes.CashOut);
                                break;

                            case 5:
                                pdto.FilterList(p => p.PaymentType == PaymentTypes.CashIn);
                                break;
                            }
                        }
                        #endregion

                        piList = piList.Concat(pdto.GetList().ToList());
                    }
                }
                else
                {
                    piList = Get().Get().ToList();
                }
            }
            finally
            {
                Dispose(_disposeWhenDone);
            }

            return(piList);
        }
Ejemplo n.º 3
0
        public IEnumerable <PhysicalInventoryHeaderDTO> GetAll(SearchCriteria <PhysicalInventoryHeaderDTO> criteria = null)
        {
            IEnumerable <PhysicalInventoryHeaderDTO> piList = new List <PhysicalInventoryHeaderDTO>();

            try
            {
                if (criteria != null && criteria.CurrentUserId != -1)
                {
                    var warehouseList = new WarehouseService(true)
                                        .GetWarehousesPrevilegedToUser(criteria.CurrentUserId).ToList();
                    if (criteria.SelectedWarehouseId != null)
                    {
                        warehouseList = warehouseList.Where(w => w.Id == criteria.SelectedWarehouseId).ToList();
                    }

                    foreach (var warehouse in warehouseList.Where(w => w.Id != -1))
                    {
                        var pdto = Get();

                        foreach (var cri in criteria.FiList)
                        {
                            pdto.FilterList(cri);
                        }

                        #region By Warehouse

                        var warehouse1 = warehouse;
                        pdto.FilterList(p => p.WarehouseId == warehouse1.Id);

                        #endregion

                        #region By Duration

                        if (criteria.BeginingDate != null)
                        {
                            var beginDate = new DateTime(criteria.BeginingDate.Value.Year, criteria.BeginingDate.Value.Month,
                                                         criteria.BeginingDate.Value.Day, 0, 0, 0);
                            pdto.FilterList(p => p.PhysicalInventoryDate >= beginDate);
                        }

                        if (criteria.EndingDate != null)
                        {
                            var endDate = new DateTime(criteria.EndingDate.Value.Year, criteria.EndingDate.Value.Month,
                                                       criteria.EndingDate.Value.Day, 23, 59, 59);
                            pdto.FilterList(p => p.PhysicalInventoryDate <= endDate);
                        }

                        #endregion

                        IList <PhysicalInventoryHeaderDTO> pdtoList;
                        if (criteria.Page != 0 && criteria.PageSize != 0)
                        {
                            int totalCount;
                            pdtoList = pdto.GetPage(criteria.Page, criteria.PageSize, out totalCount).ToList();
                        }
                        else
                        {
                            pdtoList = pdto.GetList().ToList();
                        }



                        piList = piList.Concat(pdtoList).ToList();
                    }
                }
                else
                {
                    piList = Get().Get().ToList();
                }
            }
            finally
            {
                Dispose(_disposeWhenDone);
            }

            return(piList);
        }
Ejemplo n.º 4
0
        public IEnumerable <TransactionHeaderDTO> GetAll(SearchCriteria <TransactionHeaderDTO> criteria, out int totalCount)
        {
            totalCount = 0;
            IEnumerable <TransactionHeaderDTO> piList = new List <TransactionHeaderDTO>();

            try
            {
                if (criteria != null && criteria.CurrentUserId != -1)
                {
                    var warehouseList = new WarehouseService(true)
                                        .GetWarehousesPrevilegedToUser(criteria.CurrentUserId).ToList();

                    if (criteria.SelectedWarehouseId != null)
                    {
                        warehouseList = warehouseList.Where(w => w.Id == criteria.SelectedWarehouseId).ToList();
                    }

                    foreach (var warehouse in warehouseList.Where(w => w.Id != -1))
                    {
                        var pdto = Get();

                        foreach (var cri in criteria.FiList)
                        {
                            pdto.FilterList(cri);
                        }

                        #region By Warehouse

                        var warehouse1 = warehouse;
                        pdto.FilterList(p => p.WarehouseId == warehouse1.Id);

                        #endregion

                        #region By Duration

                        if (criteria.BeginingDate != null)
                        {
                            var beginDate = new DateTime(criteria.BeginingDate.Value.Year, criteria.BeginingDate.Value.Month,
                                                         criteria.BeginingDate.Value.Day, 0, 0, 0);
                            pdto.FilterList(p => p.TransactionDate >= beginDate);
                        }

                        if (criteria.EndingDate != null)
                        {
                            var endDate = new DateTime(criteria.EndingDate.Value.Year, criteria.EndingDate.Value.Month,
                                                       criteria.EndingDate.Value.Day, 23, 59, 59);
                            pdto.FilterList(p => p.TransactionDate <= endDate);
                        }

                        #endregion

                        #region For Business Partner

                        if (criteria.BusinessPartnerId != null && criteria.BusinessPartnerId != -1)
                        {
                            pdto.FilterList(w => w.BusinessPartnerId == criteria.BusinessPartnerId);
                        }

                        #endregion

                        IList <TransactionHeaderDTO> pdtoList;
                        if (criteria.Page != 0 && criteria.PageSize != 0 && criteria.PaymentListType == -1)
                        {
                            int totalCount2;
                            pdtoList   = pdto.GetPage(criteria.Page, criteria.PageSize, out totalCount2).ToList();
                            totalCount = totalCount2;
                        }
                        else
                        {
                            pdtoList   = pdto.GetList().ToList();
                            totalCount = pdtoList.Count;
                        }


                        #region By Payment List Types //Since PaymentCompleted is n't in the table can't use Linq

                        if (criteria.PaymentListType != -1)
                        {
                            int b = pdtoList.Count;
                            switch (criteria.PaymentListType)
                            {
                            case 0:
                                break;

                            case 1:
                                var nopayment = EnumUtil.GetEnumDesc(PaymentStatus.NoPayment);
                                pdtoList = pdtoList.Where(s => s.PaymentCompleted == nopayment).ToList();
                                break;

                            case 2:
                                var notCleared = EnumUtil.GetEnumDesc(PaymentStatus.NotCleared);
                                pdtoList = pdtoList.Where(s => s.PaymentCompleted == notCleared).ToList();
                                break;

                            case 3:
                                var cleared = EnumUtil.GetEnumDesc(PaymentStatus.Cleared);
                                pdtoList = pdtoList.Where(s => s.PaymentCompleted == cleared).ToList();
                                break;
                            }
                            int c = pdtoList.Count;
                            totalCount = totalCount - (b - c);

                            if (criteria.Page != 0 && criteria.PageSize != 0)
                            {
                                pdtoList = pdtoList.Skip(criteria.PageSize * (criteria.Page - 1)).Take(criteria.PageSize).ToList();
                            }
                        }

                        #endregion

                        piList = piList.Concat(pdtoList).ToList();
                    }
                }
                else
                {
                    piList = Get().Get().ToList();
                }

                //#region For Eager Loading Childs
                //foreach (var transactionHeaderDTO in piList)
                //{
                //    var transactionLineDtos =
                //        (ICollection<TransactionLineDTO>)GetChilds(transactionHeaderDTO.Id, false);
                //}
                //#endregion
            }
            finally
            {
                Dispose(_disposeWhenDone);
            }

            return(piList);
        }