public dynamic GetList(string _search, long nd, int rows, int?page, string sidx, string sord, string filters = "")
        {
            // Construct where statement

            string strWhere = GeneralFunction.ConstructWhere(filters);

            // Get Data
            var query = _rollerWarehouseMutationService.GetAll().Where(d => d.IsDeleted == false);

            var list = query as IEnumerable <RollerWarehouseMutation>;

            var pageIndex    = Convert.ToInt32(page) - 1;
            var pageSize     = rows;
            var totalRecords = query.Count();
            var totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            // default last page
            if (totalPages > 0)
            {
                if (!page.HasValue)
                {
                    pageIndex = totalPages - 1;
                    page      = totalPages;
                }
            }

            list = list.Skip(pageIndex * pageSize).Take(pageSize);

            return(Json(new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = (
                    from model in list
                    select new
                {
                    id = model.Id,
                    cell = new object[] {
                        model.Id,
                        model.Code,
                        model.CoreIdentificationId,
                        _coreIdentificationService.GetObjectById(model.CoreIdentificationId).Code,
                        model.WarehouseFromId,
                        _warehouseService.GetObjectById(model.WarehouseFromId).Code,
                        _warehouseService.GetObjectById(model.WarehouseFromId).Name,
                        model.WarehouseToId,
                        _warehouseService.GetObjectById(model.WarehouseToId).Code,
                        _warehouseService.GetObjectById(model.WarehouseToId).Name,
                        model.Quantity,
                        model.IsConfirmed,
                        model.ConfirmationDate,
                        model.CreatedAt,
                        model.UpdatedAt,
                    }
                }).ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public dynamic GetInfo(int Id)
        {
            CoreIdentification model = new CoreIdentification();

            try
            {
                model = _coreIdentificationService.GetObjectById(Id);
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Id,
                model.Code,
                model.WarehouseId,
                WarehouseCode = _warehouseService.GetObjectById(model.WarehouseId).Code,
                Warehouse = _warehouseService.GetObjectById(model.WarehouseId).Name,
                model.ContactId,
                Contact = model.ContactId.HasValue ?_contactService.GetObjectById(model.ContactId.Value).Name : "",
                model.IsInHouse,
                model.Quantity,
                model.IdentifiedDate,
                model.IsConfirmed,
                model.ConfirmationDate,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
 public CoreIdentificationDetail UnfinishObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService,
                                                ICoreBuilderService _coreBuilderService, IStockMutationService _stockMutationService,
                                                IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     if (_validator.ValidUnfinishObject(coreIdentificationDetail, _coreIdentificationService, this, _coreBuilderService, _warehouseItemService))
     {
         CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(coreIdentificationDetail.CoreIdentificationId);
         if (coreIdentification.ContactId != null)
         {
             // reduce contact core
             int  MaterialCase = coreIdentificationDetail.MaterialCase;
             Item item         = (MaterialCase == Core.Constants.Constant.MaterialCase.New ?
                                  _coreBuilderService.GetNewCore(coreIdentificationDetail.CoreBuilderId) :
                                  _coreBuilderService.GetUsedCore(coreIdentificationDetail.CoreBuilderId));
             WarehouseItem         warehouseItem  = _warehouseItemService.FindOrCreateObject(coreIdentification.WarehouseId, item.Id);
             IList <StockMutation> stockMutations = _stockMutationService.SoftDeleteStockMutationForCoreIdentification(coreIdentificationDetail, warehouseItem);
             foreach (var stockMutation in stockMutations)
             {
                 _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
             }
         }
         _repository.UnfinishObject(coreIdentificationDetail);
     }
     return(coreIdentificationDetail);
 }
        public dynamic GetInfo(int Id)
        {
            RecoveryOrder model = new RecoveryOrder();

            try
            {
                model = _recoveryOrderService.GetObjectById(Id);
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Id,
                model.Code,
                model.WarehouseId,
                model.CoreIdentificationId,
                CoreIdentification = _coreIdentificationService.GetObjectById(model.CoreIdentificationId).Code,
                WarehouseCode = _warehouseService.GetObjectById(model.WarehouseId).Code,
                Warehouse = _warehouseService.GetObjectById(model.WarehouseId).Name,
                model.QuantityReceived,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public RecoveryOrder VQuantityReceivedLessThanCoreIdentification(RecoveryOrder recoveryOrder, ICoreIdentificationService _coreIdentificationService)
        {
            CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(recoveryOrder.CoreIdentificationId);

            if (coreIdentification.Quantity < recoveryOrder.QuantityReceived)
            {
                recoveryOrder.Errors.Add("QuantityReceived", "Harus sama atau lebih sedikit dari Core Identification");
            }
            return(recoveryOrder);
        }
        public RollerWarehouseMutation VHasCoreIdentification(RollerWarehouseMutation rollerWarehouseMutation, ICoreIdentificationService _coreIdentificationService)
        {
            CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(rollerWarehouseMutation.CoreIdentificationId);

            if (coreIdentification == null)
            {
                rollerWarehouseMutation.Errors.Add("CoreIdentificationId", "Tidak terasosiasi dengan core identification");
            }
            return(rollerWarehouseMutation);
        }
Ejemplo n.º 7
0
        public CoreIdentificationDetail VCoreIdentificationHasNotBeenCompleted(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService)
        {
            CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(coreIdentificationDetail.CoreIdentificationId);

            if (coreIdentification.IsCompleted)
            {
                coreIdentificationDetail.Errors.Add("Generic", "CoreIdentification sudah selesai");
            }
            return(coreIdentificationDetail);
        }
Ejemplo n.º 8
0
        public CoreIdentificationDetail VCoreIdentificationHasBeenConfirmed(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService)
        {
            CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(coreIdentificationDetail.CoreIdentificationId);

            if (!coreIdentification.IsConfirmed)
            {
                coreIdentificationDetail.Errors.Add("Generic", "CoreIdentification belum dikonfirmasi");
            }
            return(coreIdentificationDetail);
        }
Ejemplo n.º 9
0
        public CoreIdentificationDetail VHasCoreIdentification(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService)
        {
            CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(coreIdentificationDetail.CoreIdentificationId);

            if (coreIdentification == null)
            {
                coreIdentificationDetail.Errors.Add("Generic", "CoreIdentificationDetail harus memiliki Core Identification");
            }
            return(coreIdentificationDetail);
        }
Ejemplo n.º 10
0
        public RecoveryOrder VHasCoreIdentificationAndConfirmed(RecoveryOrder recoveryOrder, ICoreIdentificationService _coreIdentificationService)
        {
            CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(recoveryOrder.CoreIdentificationId);

            if (coreIdentification == null)
            {
                recoveryOrder.Errors.Add("CoreIdentificationId", "Tidak terasosiasi dengan core identification");
            }
            else if (!coreIdentification.IsConfirmed)
            {
                recoveryOrder.Errors.Add("CoreIdentifcationId", "Belum dikonfirmasi");
            }
            return(recoveryOrder);
        }
        public CoreIdentificationDetail DeliverObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService, IRollerWarehouseMutationDetailService _rollerWarehouseMutationDetailService)
        {
            if (_validator.ValidDeliverObject(coreIdentificationDetail, _rollerWarehouseMutationDetailService))
            {
                _repository.DeliverObject(coreIdentificationDetail);

                CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(coreIdentificationDetail.CoreIdentificationId);
                if (_coreIdentificationService.GetValidator().ValidCompleteObject(coreIdentification, this))
                {
                    _coreIdentificationService.CompleteObject(coreIdentification, this);
                }
            }
            return(coreIdentificationDetail);
        }
Ejemplo n.º 12
0
        public CoreIdentificationDetail VQuantityIsInStockForContact(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService, ICoreBuilderService _coreBuilderService, IWarehouseItemService _warehouseItemService)
        {
            CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(coreIdentificationDetail.CoreIdentificationId);

            if (coreIdentification.ContactId != null)
            {
                int  MaterialCase = coreIdentificationDetail.MaterialCase;
                Item item         = (MaterialCase == Core.Constants.Constant.MaterialCase.New ?
                                     _coreBuilderService.GetNewCore(coreIdentificationDetail.CoreBuilderId) :
                                     _coreBuilderService.GetUsedCore(coreIdentificationDetail.CoreBuilderId));
                WarehouseItem warehouseItem = _warehouseItemService.FindOrCreateObject(coreIdentification.WarehouseId, item.Id);
                if (warehouseItem.Quantity < 1)
                {
                    coreIdentificationDetail.Errors.Add("Generic", "Stock barang tidak boleh kurang dari stock yang mau dimutasikan");
                }
            }
            return(coreIdentificationDetail);
        }
 public CoreIdentificationDetail FinishObject(CoreIdentificationDetail coreIdentificationDetail, DateTime FinishedDate, ICoreIdentificationService _coreIdentificationService,
                                              ICoreBuilderService _coreBuilderService, IStockMutationService _stockMutationService,
                                              IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     coreIdentificationDetail.FinishedDate = FinishedDate;
     if (_validator.ValidFinishObject(coreIdentificationDetail, _coreIdentificationService, this, _coreBuilderService, _warehouseItemService))
     {
         CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(coreIdentificationDetail.CoreIdentificationId);
         if (coreIdentification.ContactId != null)
         {
             // add contact core
             int  MaterialCase = coreIdentificationDetail.MaterialCase;
             Item item         = (MaterialCase == Core.Constants.Constant.MaterialCase.New ?
                                  _coreBuilderService.GetNewCore(coreIdentificationDetail.CoreBuilderId) :
                                  _coreBuilderService.GetUsedCore(coreIdentificationDetail.CoreBuilderId));
             WarehouseItem warehouseItem = _warehouseItemService.FindOrCreateObject(coreIdentification.WarehouseId, item.Id);
             StockMutation stockMutation = _stockMutationService.CreateStockMutationForCoreIdentification(coreIdentificationDetail, warehouseItem);
             _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
         }
         _repository.FinishObject(coreIdentificationDetail);
     }
     return(coreIdentificationDetail);
 }