Exemplo n.º 1
0
        public CoreIdentificationDetail VUnsetJobScheduled(CoreIdentificationDetail coreIdentificationDetail, IRecoveryOrderService _recoveryOrderService,
                                                           IRecoveryOrderDetailService _recoveryOrderDetailService)
        {
            IList <RecoveryOrderDetail> details = _recoveryOrderDetailService.GetObjectsByCoreIdentificationDetailId(coreIdentificationDetail.Id);

            if (!details.Any())
            {
                return(coreIdentificationDetail);
            }
            bool IsFinished = false;

            foreach (var detail in details)
            {
                if (detail.IsFinished)
                {
                    IsFinished = true;
                }
            }
            if (!IsFinished)
            {
                coreIdentificationDetail.Errors.Add("Generic", "Belum bisa di unset Job Schedule");
            }

            return(coreIdentificationDetail);
        }
Exemplo n.º 2
0
        public RecoveryOrder VQuantityIsInStock(RecoveryOrder recoveryOrder, ICoreIdentificationDetailService _coreIdentificationDetailService,
                                                IRecoveryOrderDetailService _recoveryOrderDetailService, ICoreBuilderService _coreBuilderService, IItemService _itemService,
                                                IWarehouseItemService _warehouseItemService)
        {
            IList <RecoveryOrderDetail> details = _recoveryOrderDetailService.GetObjectsByRecoveryOrderId(recoveryOrder.Id);
            IDictionary <int, int>      ValuePairItemIdQuantity = new Dictionary <int, int>();

            foreach (var detail in details)
            {
                CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(detail.CoreIdentificationDetailId);
                CoreBuilder coreBuilder = _coreBuilderService.GetObjectById(coreIdentificationDetail.CoreBuilderId);
                Item        item        = (coreIdentificationDetail.MaterialCase == Core.Constants.Constant.MaterialCase.New) ?
                                          _coreBuilderService.GetNewCore(coreBuilder.Id) : _coreBuilderService.GetUsedCore(coreBuilder.Id);
                WarehouseItem warehouseItem = _warehouseItemService.FindOrCreateObject(recoveryOrder.WarehouseId, item.Id);
                if (ValuePairItemIdQuantity.ContainsKey(warehouseItem.Id))
                {
                    ValuePairItemIdQuantity[warehouseItem.Id] += 1;
                }
                else
                {
                    ValuePairItemIdQuantity.Add(warehouseItem.Id, 1);
                }
            }

            foreach (var ValuePair in ValuePairItemIdQuantity)
            {
                WarehouseItem warehouseItem = _warehouseItemService.GetObjectById(ValuePair.Key);
                if (warehouseItem.Quantity < ValuePair.Value)
                {
                    recoveryOrder.Errors.Add("Generic", "Stock quantity core item tidak boleh kurang dari jumlah di dalam recovery order");
                    return(recoveryOrder);
                }
            }
            return(recoveryOrder);
        }
Exemplo n.º 3
0
        public dynamic GetInfoDetail(int Id)
        {
            CoreIdentificationDetail model = new CoreIdentificationDetail();

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

            return(Json(new
            {
                model.Id,
                model.DetailId,
                model.CoreIdentificationId,
                model.MaterialCase,
                model.CoreBuilderId,
                CoreBuilder = _coreBuilderService.GetObjectById(model.CoreBuilderId).Name,
                model.RollerTypeId,
                RollerType = _rollerTypeService.GetObjectById(model.RollerTypeId).Name,
                model.MachineId,
                Machine = _machineService.GetObjectById(model.MachineId).Name,
                model.RD,
                model.CD,
                model.RL,
                model.WL,
                model.TL,
                model.FinishedDate,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
        public RollerWarehouseMutationDetail ConfirmObject(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, DateTime ConfirmationDate, IRollerWarehouseMutationService _rollerWarehouseMutationService,
                                                           IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService, IStockMutationService _stockMutationService,
                                                           ICoreIdentificationDetailService _coreIdentificationDetailService, ICoreIdentificationService _coreIdentificationService)
        {
            rollerWarehouseMutationDetail.ConfirmationDate = ConfirmationDate;
            if (_validator.ValidConfirmObject(rollerWarehouseMutationDetail, _rollerWarehouseMutationService, _itemService, _barringService, _warehouseItemService))
            {
                _repository.ConfirmObject(rollerWarehouseMutationDetail);

                // Set IsDelivered = true
                CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(rollerWarehouseMutationDetail.CoreIdentificationDetailId);
                _coreIdentificationDetailService.DeliverObject(coreIdentificationDetail, _coreIdentificationService, this);

                // reduce warehouseFromItem
                // add warehouseToItem

                RollerWarehouseMutation rollerWarehouseMutation = _rollerWarehouseMutationService.GetObjectById(rollerWarehouseMutationDetail.RollerWarehouseMutationId);
                WarehouseItem           warehouseItemFrom       = _warehouseItemService.FindOrCreateObject(rollerWarehouseMutation.WarehouseFromId, rollerWarehouseMutationDetail.ItemId);
                WarehouseItem           warehouseItemTo         = _warehouseItemService.FindOrCreateObject(rollerWarehouseMutation.WarehouseToId, rollerWarehouseMutationDetail.ItemId);

                IList <StockMutation> stockMutations = _stockMutationService.CreateStockMutationForRollerWarehouseMutation(rollerWarehouseMutationDetail, warehouseItemFrom, warehouseItemTo);
                foreach (var stockMutation in stockMutations)
                {
                    _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
                }
            }
            return(rollerWarehouseMutationDetail);
        }
Exemplo n.º 5
0
        public dynamic UpdateDetail(CoreIdentificationDetail model)
        {
            decimal amount = 0;

            try
            {
                var data = _coreIdentificationDetailService.GetObjectById(model.Id);
                data.DetailId      = model.DetailId;
                data.MaterialCase  = model.MaterialCase;
                data.CoreBuilderId = model.CoreBuilderId;
                data.RollerTypeId  = model.RollerTypeId;
                data.MachineId     = model.MachineId;
                data.RD            = model.RD;
                data.CD            = model.CD;
                data.RL            = model.RL;
                data.WL            = model.WL;
                data.TL            = model.TL;
                model = _coreIdentificationDetailService.UpdateObject(data, _coreIdentificationService
                                                                      , _coreBuilderService, _rollerTypeService, _machineService);
                amount = _coreIdentificationService.GetObjectById(model.CoreIdentificationId).Quantity;
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors,
                AmountPayable = amount
            }));
        }
        public RollerWarehouseMutationDetail UnconfirmObject(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, IRollerWarehouseMutationService _rollerWarehouseMutationService,
                                                             IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService, IStockMutationService _stockMutationService,
                                                             ICoreIdentificationDetailService _coreIdentificationDetailService, ICoreIdentificationService _coreIdentificationService)
        {
            if (_validator.ValidUnconfirmObject(rollerWarehouseMutationDetail, _rollerWarehouseMutationService, _itemService, _barringService, _warehouseItemService))
            {
                _repository.UnconfirmObject(rollerWarehouseMutationDetail);

                // Set IsDelivered = false
                CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(rollerWarehouseMutationDetail.CoreIdentificationDetailId);
                _coreIdentificationDetailService.UndoDeliverObject(coreIdentificationDetail, _coreIdentificationService, this);

                // reverse stock mutate warehouseFromItem and warehouseToItem
                RollerWarehouseMutation rollerWarehouseMutation = _rollerWarehouseMutationService.GetObjectById(rollerWarehouseMutationDetail.RollerWarehouseMutationId);
                WarehouseItem           warehouseItemFrom       = _warehouseItemService.FindOrCreateObject(rollerWarehouseMutation.WarehouseFromId, rollerWarehouseMutationDetail.ItemId);
                WarehouseItem           warehouseItemTo         = _warehouseItemService.FindOrCreateObject(rollerWarehouseMutation.WarehouseToId, rollerWarehouseMutationDetail.ItemId);

                IList <StockMutation> stockMutations = _stockMutationService.SoftDeleteStockMutationForRollerWarehouseMutation(rollerWarehouseMutationDetail, warehouseItemFrom, warehouseItemTo);
                foreach (var stockMutation in stockMutations)
                {
                    _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
                }
            }
            return(rollerWarehouseMutationDetail);
        }
Exemplo n.º 7
0
 public bool ValidUnsetJobScheduled(CoreIdentificationDetail coreIdentificationDetail, IRecoveryOrderService _recoveryOrderService,
                                    IRecoveryOrderDetailService _recoveryOrderDetailService)
 {
     coreIdentificationDetail.Errors.Clear();
     VUnsetJobScheduled(coreIdentificationDetail, _recoveryOrderService, _recoveryOrderDetailService);
     return(isValid(coreIdentificationDetail));
 }
 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);
 }
Exemplo n.º 9
0
 public bool ValidUnfinishObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService,
                                 ICoreIdentificationDetailService _coreIdentificationDetailService, ICoreBuilderService _coreBuilderService, IWarehouseItemService _warehouseItemService)
 {
     coreIdentificationDetail.Errors.Clear();
     VUnfinishObject(coreIdentificationDetail, _coreIdentificationService, _coreIdentificationDetailService, _coreBuilderService, _warehouseItemService);
     return(isValid(coreIdentificationDetail));
 }
Exemplo n.º 10
0
 public bool ValidCreateObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService,
                               ICoreIdentificationDetailService _coreIdentificationDetailService, ICoreBuilderService _coreBuilderService,
                               IRollerTypeService _rollerTypeService, IMachineService _machineService)
 {
     VCreateObject(coreIdentificationDetail, _coreIdentificationService, _coreIdentificationDetailService, _coreBuilderService, _rollerTypeService, _machineService);
     return(isValid(coreIdentificationDetail));
 }
Exemplo n.º 11
0
 public bool ValidDeleteObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService,
                               IRecoveryOrderDetailService _recoveryOrderDetailService, IRollerWarehouseMutationDetailService _rollerWarehouseMutationDetailService)
 {
     coreIdentificationDetail.Errors.Clear();
     VDeleteObject(coreIdentificationDetail, _coreIdentificationService, _recoveryOrderDetailService, _rollerWarehouseMutationDetailService);
     return(isValid(coreIdentificationDetail));
 }
 public CoreIdentificationDetail CreateObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService,
                                              ICoreBuilderService _coreBuilderService, IRollerTypeService _rollerTypeService, IMachineService _machineService)
 {
     coreIdentificationDetail.Errors = new Dictionary <String, String>();
     return(_validator.ValidCreateObject(coreIdentificationDetail, _coreIdentificationService, this, _coreBuilderService, _rollerTypeService, _machineService) ?
            _repository.CreateObject(coreIdentificationDetail) : coreIdentificationDetail);
 }
Exemplo n.º 13
0
 public CoreIdentificationDetail VHasNotBeenDelivered(CoreIdentificationDetail coreIdentificationDetail)
 {
     if (coreIdentificationDetail.IsDelivered)
     {
         coreIdentificationDetail.Errors.Add("Generic", "Roller sudah dikirim");
     }
     return(coreIdentificationDetail);
 }
Exemplo n.º 14
0
 public bool ValidUpdateObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService,
                               ICoreIdentificationDetailService _coreIdentificationDetailService, ICoreBuilderService _coreBuilderService,
                               IRollerTypeService _rollerTypeService, IMachineService _machineService)
 {
     coreIdentificationDetail.Errors.Clear();
     VUpdateObject(coreIdentificationDetail, _coreIdentificationService, _coreIdentificationDetailService, _coreBuilderService, _rollerTypeService, _machineService);
     return(isValid(coreIdentificationDetail));
 }
 public CoreIdentificationDetail UndoDeliverObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService, IRollerWarehouseMutationDetailService _rollerWarehouseMutationDetailService)
 {
     if (_validator.ValidUndoDeliverObject(coreIdentificationDetail, _coreIdentificationService, _rollerWarehouseMutationDetailService))
     {
         _repository.UndoDeliverObject(coreIdentificationDetail);
     }
     return(coreIdentificationDetail);
 }
Exemplo n.º 16
0
 public CoreIdentificationDetail VHasFinishedDate(CoreIdentificationDetail coreIdentificationDetail)
 {
     if (coreIdentificationDetail.FinishedDate == null)
     {
         coreIdentificationDetail.Errors.Add("FinishedDate", "Tidak boleh kosong");
     }
     return(coreIdentificationDetail);
 }
Exemplo n.º 17
0
 public CoreIdentificationDetail VHasNotBeenFinished(CoreIdentificationDetail coreIdentificationDetail)
 {
     if (coreIdentificationDetail.IsFinished)
     {
         coreIdentificationDetail.Errors.Add("Generic", "CoreIdentificationDetail sudah selesai");
     }
     return(coreIdentificationDetail);
 }
Exemplo n.º 18
0
 public CoreIdentificationDetail VHasBeenRollerBuilt(CoreIdentificationDetail coreIdentificationDetail)
 {
     if (!coreIdentificationDetail.IsRollerBuilt)
     {
         coreIdentificationDetail.Errors.Add("Generic", "Roller is not built yet");
     }
     return(coreIdentificationDetail);
 }
Exemplo n.º 19
0
 public CoreIdentificationDetail VHasBeenDelivered(CoreIdentificationDetail coreIdentificationDetail)
 {
     if (!coreIdentificationDetail.IsDelivered)
     {
         coreIdentificationDetail.Errors.Add("Generic", "Item belum dikirim");
     }
     return(coreIdentificationDetail);
 }
Exemplo n.º 20
0
 public CoreIdentificationDetail VHasNotBeenJobScheduled(CoreIdentificationDetail coreIdentificationDetail)
 {
     if (coreIdentificationDetail.IsJobScheduled)
     {
         coreIdentificationDetail.Errors.Add("Generic", "Job sudah terschedule");
     }
     return(coreIdentificationDetail);
 }
Exemplo n.º 21
0
 public CoreIdentificationDetail VHasBeenJobScheduled(CoreIdentificationDetail coreIdentificationDetail)
 {
     if (!coreIdentificationDetail.IsJobScheduled)
     {
         coreIdentificationDetail.Errors.Add("Generic", "Job masih belum di schedule");
     }
     return(coreIdentificationDetail);
 }
        public Item GetCore(CoreIdentificationDetail coreIdentificationDetail, ICoreBuilderService _coreBuilderService)
        {
            Item core = (coreIdentificationDetail.MaterialCase == Core.Constants.Constant.MaterialCase.New) ?
                        _coreBuilderService.GetNewCore(coreIdentificationDetail.CoreBuilderId) :
                        _coreBuilderService.GetUsedCore(coreIdentificationDetail.CoreBuilderId);

            return(core);
        }
Exemplo n.º 23
0
 public CoreIdentificationDetail VHasMaterialCase(CoreIdentificationDetail coreIdentificationDetail)
 {
     if (coreIdentificationDetail.MaterialCase != Core.Constants.Constant.MaterialCase.New &&
         coreIdentificationDetail.MaterialCase != Core.Constants.Constant.MaterialCase.Used)
     {
         coreIdentificationDetail.Errors.Add("MaterialCase", "Hanya boleh 1. New atau 2. Used");
     }
     return(coreIdentificationDetail);
 }
Exemplo n.º 24
0
        public Item GetRoller(RecoveryOrderDetail recoveryOrderDetail, ICoreIdentificationDetailService _coreIdentificationDetailService,
                              IRollerBuilderService _rollerBuilderService, IItemService _itemService)
        {
            CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(recoveryOrderDetail.CoreIdentificationDetailId);
            Item roller = (coreIdentificationDetail.MaterialCase == Core.Constants.Constant.MaterialCase.New) ?
                          _rollerBuilderService.GetRollerNewCore(recoveryOrderDetail.RollerBuilderId) : _rollerBuilderService.GetRollerUsedCore(recoveryOrderDetail.RollerBuilderId);

            return(roller);
        }
Exemplo n.º 25
0
        public Item GetCore(RecoveryOrderDetail recoveryOrderDetail, ICoreIdentificationDetailService _coreIdentificationDetailService,
                            ICoreBuilderService _coreBuilderService, IItemService _itemService)
        {
            CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(recoveryOrderDetail.CoreIdentificationDetailId);
            Item core = (coreIdentificationDetail.MaterialCase == Core.Constants.Constant.MaterialCase.New) ?
                        _coreBuilderService.GetNewCore(coreIdentificationDetail.CoreBuilderId) : _coreBuilderService.GetUsedCore(coreIdentificationDetail.CoreBuilderId);

            return(core);
        }
        public RecoveryOrderDetail VHasCoreIdentificationDetail(RecoveryOrderDetail recoveryOrderDetail, ICoreIdentificationDetailService _coreIdentificationDetailService)
        {
            CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(recoveryOrderDetail.CoreIdentificationDetailId);

            if (coreIdentificationDetail == null)
            {
                recoveryOrderDetail.Errors.Add("CoreIdentificationDetailId", "Tidak terasosiasi dengan Core Identification Detail");
            }
            return(recoveryOrderDetail);
        }
        public RollerWarehouseMutationDetail VHasCoreIdentificationDetail(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, ICoreIdentificationDetailService _coreIdentificationDetailService)
        {
            CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(rollerWarehouseMutationDetail.CoreIdentificationDetailId);

            if (coreIdentificationDetail == null)
            {
                rollerWarehouseMutationDetail.Errors.Add("CoreIdentificationDetailId", "Tidak terasosiasi dengan core identification detail");
            }
            return(rollerWarehouseMutationDetail);
        }
Exemplo n.º 28
0
        public CoreIdentificationDetail VHasMachine(CoreIdentificationDetail coreIdentificationDetail, IMachineService _machineService)
        {
            Machine machine = _machineService.GetObjectById(coreIdentificationDetail.MachineId);

            if (machine == null)
            {
                coreIdentificationDetail.Errors.Add("MachineId", "Tidak terasosiasi dengan machine");
            }
            return(coreIdentificationDetail);
        }
Exemplo n.º 29
0
        public CoreIdentificationDetail VHasRollerType(CoreIdentificationDetail coreIdentificationDetail, IRollerTypeService _rollerTypeService)
        {
            RollerType rollerType = _rollerTypeService.GetObjectById(coreIdentificationDetail.RollerTypeId);

            if (rollerType == null)
            {
                coreIdentificationDetail.Errors.Add("RollerTypeId", "Tidak terasosiasi dengan rollerType");
            }
            return(coreIdentificationDetail);
        }
Exemplo n.º 30
0
        public CoreIdentificationDetail VHasCoreBuilder(CoreIdentificationDetail coreIdentificationDetail, ICoreBuilderService _coreBuilderService)
        {
            CoreBuilder coreBuilder = _coreBuilderService.GetObjectById(coreIdentificationDetail.CoreBuilderId);

            if (coreBuilder == null)
            {
                coreIdentificationDetail.Errors.Add("CoreBuilderId", "Tidak terasosiasi dengan coreBuilder");
            }
            return(coreIdentificationDetail);
        }