Exemplo n.º 1
0
 public RecoveryOrder VConfirmObject(RecoveryOrder recoveryOrder, ICoreIdentificationDetailService _coreIdentificationDetailService,
                                     IRecoveryOrderDetailService _recoveryOrderDetailService, ICoreBuilderService _coreBuilderService, IItemService _itemService, IWarehouseItemService _warehouseItemService)
 {
     VHasConfirmationDate(recoveryOrder);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VHasNotBeenConfirmed(recoveryOrder);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VHasRecoveryOrderDetails(recoveryOrder, _recoveryOrderDetailService);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VQuantityReceivedEqualDetails(recoveryOrder, _recoveryOrderDetailService);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VQuantityIsInStock(recoveryOrder, _coreIdentificationDetailService, _recoveryOrderDetailService, _coreBuilderService, _itemService, _warehouseItemService);
     return(recoveryOrder);
 }
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);
        }
        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));
        }
Exemplo n.º 4
0
 public bool ValidConfirmObject(RecoveryOrder recoveryOrder, ICoreIdentificationDetailService _coreIdentificationDetailService,
                                IRecoveryOrderDetailService _recoveryOrderDetailService, ICoreBuilderService _coreBuilderService, IItemService _itemService, IWarehouseItemService _warehouseItemService)
 {
     recoveryOrder.Errors.Clear();
     VConfirmObject(recoveryOrder, _coreIdentificationDetailService, _recoveryOrderDetailService, _coreBuilderService, _itemService, _warehouseItemService);
     return(isValid(recoveryOrder));
 }
Exemplo n.º 5
0
 public RecoveryOrder VHasNotBeenCompleted(RecoveryOrder recoveryOrder)
 {
     if (recoveryOrder.IsCompleted)
     {
         recoveryOrder.Errors.Add("Generic", "Sudah complete");
     }
     return(recoveryOrder);
 }
Exemplo n.º 6
0
 public RecoveryOrder VHasBeenCompleted(RecoveryOrder recoveryOrder)
 {
     if (!recoveryOrder.IsCompleted)
     {
         recoveryOrder.Errors.Add("Generic", "Belum complete");
     }
     return(recoveryOrder);
 }
Exemplo n.º 7
0
 public RecoveryOrder VHasNotBeenConfirmed(RecoveryOrder recoveryOrder)
 {
     if (recoveryOrder.IsConfirmed)
     {
         recoveryOrder.Errors.Add("Generic", "Sudah dikonfirmasi");
     }
     return(recoveryOrder);
 }
Exemplo n.º 8
0
 public RecoveryOrder VHasBeenConfirmed(RecoveryOrder recoveryOrder)
 {
     if (!recoveryOrder.IsConfirmed)
     {
         recoveryOrder.Errors.Add("Generic", "Belum dikonfirmasi");
     }
     return(recoveryOrder);
 }
Exemplo n.º 9
0
 public RecoveryOrder VHasConfirmationDate(RecoveryOrder obj)
 {
     if (obj.ConfirmationDate == null)
     {
         obj.Errors.Add("ConfirmationDate", "Tidak boleh kosong");
     }
     return(obj);
 }
Exemplo n.º 10
0
 public RecoveryOrder VHasQuantityReceived(RecoveryOrder recoveryOrder)
 {
     if (recoveryOrder.QuantityReceived <= 0)
     {
         recoveryOrder.Errors.Add("QuantityReceived", "Harus lebih dari 0");
     }
     return(recoveryOrder);
 }
Exemplo n.º 11
0
 public RecoveryOrder CompleteObject(RecoveryOrder recoveryOrder, ICoreIdentificationDetailService _coreIdentificationDetailService, IRecoveryOrderDetailService _recoveryOrderDetailService,
                                     IRecoveryAccessoryDetailService _recoveryAccessoryDetailService)
 {
     if (_validator.ValidCompleteObject(recoveryOrder, _recoveryOrderDetailService, _recoveryAccessoryDetailService))
     {
         _repository.CompleteObject(recoveryOrder);
     }
     return(recoveryOrder);
 }
Exemplo n.º 12
0
        void rollerbuilder_validation()
        {
            it["validates_rollerbuilder"] = () =>
            {
                d.item.Errors.Count().should_be(0);
                d.itemCompound.Errors.Count().should_be(0);
                d.machine.Errors.Count().should_be(0);
                d.coreBuilder.Errors.Count().should_be(0);
                d.coreIdentification.Errors.Count().should_be(0);
                d.coreIdentificationDetail.Errors.Count().should_be(0);
                d.rollerBuilder.Errors.Count().should_be(0);
            };

            it["delete_rollerbuilder"] = () =>
            {
                d.rollerBuilder = d._rollerBuilderService.SoftDeleteObject(d.rollerBuilder, d._itemService, d._recoveryOrderDetailService,
                                                                           d._coreBuilderService, d._warehouseItemService, d._stockMutationService, d._itemTypeService);
                d.rollerBuilder.Errors.Count().should_be(0);
            };

            it["delete_rollerbuilder_with_recoveryorderdetail"] = () =>
            {
                d._itemService.AdjustQuantity(d._coreBuilderService.GetNewCore(d.coreBuilder.Id), 1);
                d._itemService.AdjustQuantity(d._coreBuilderService.GetUsedCore(d.coreBuilder.Id), 1);

                d.coreIdentification = d._coreIdentificationService.ConfirmObject(d.coreIdentification, DateTime.Today,
                                                                                  d._coreIdentificationDetailService, d._stockMutationService, d._recoveryOrderService, d._recoveryOrderDetailService,
                                                                                  d._coreBuilderService, d._itemService, d._warehouseItemService, d._barringService);
                d.coreIdentification.Errors.Count().should_be(0);

                RecoveryOrder recoveryOrder = new RecoveryOrder()
                {
                    Code = "RO0001",
                    CoreIdentificationId = d.coreIdentification.Id,
                    QuantityReceived     = 1,
                    WarehouseId          = d.localWarehouse.Id
                };
                recoveryOrder = d._recoveryOrderService.CreateObject(recoveryOrder, d._coreIdentificationService);
                recoveryOrder.Errors.Count().should_be(0);

                RecoveryOrderDetail recoveryOrderDetail = new RecoveryOrderDetail()
                {
                    RecoveryOrderId            = recoveryOrder.Id,
                    CoreIdentificationDetailId = d.coreIdentificationDetail.Id,
                    RollerBuilderId            = d.rollerBuilder.Id,
                    CoreTypeCase      = Core.Constants.Constant.CoreTypeCase.R,
                    RepairRequestCase = Core.Constants.Constant.RepairRequestCase.BearingSeat,
                    Acc = "Y",
                };
                recoveryOrderDetail = d._recoveryOrderDetailService.CreateObject(recoveryOrderDetail, d._recoveryOrderService, d._coreIdentificationDetailService, d._rollerBuilderService);
                recoveryOrderDetail.Errors.Count().should_be(0);

                d.rollerBuilder = d._rollerBuilderService.SoftDeleteObject(d.rollerBuilder, d._itemService, d._recoveryOrderDetailService, d._coreBuilderService, d._warehouseItemService,
                                                                           d._stockMutationService, d._itemTypeService);
                d.rollerBuilder.Errors.Count().should_not_be(0);
            };
        }
        public RecoveryOrderDetail VRecoveryOrderHasNotBeenCompleted(RecoveryOrderDetail recoveryOrderDetail, IRecoveryOrderService _recoveryOrderService)
        {
            RecoveryOrder recoveryOrder = _recoveryOrderService.GetObjectById(recoveryOrderDetail.RecoveryOrderId);

            if (recoveryOrder.IsCompleted)
            {
                recoveryOrderDetail.Errors.Add("Generic", "Recovery order sudah complete");
            }
            return(recoveryOrderDetail);
        }
        public RecoveryOrderDetail VHasRecoveryOrder(RecoveryOrderDetail recoveryOrderDetail, IRecoveryOrderService _recoveryOrderService)
        {
            RecoveryOrder recoveryOrder = _recoveryOrderService.GetObjectById(recoveryOrderDetail.RecoveryOrderId);

            if (recoveryOrder == null)
            {
                recoveryOrderDetail.Errors.Add("RecoveryOrderId", "Tidak terasosiasi dengan Recovery Order");
            }
            return(recoveryOrderDetail);
        }
Exemplo n.º 15
0
        public RecoveryOrder VQuantityReceivedEqualDetails(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService)
        {
            IList <RecoveryOrderDetail> details = _recoveryOrderDetailService.GetObjectsByRecoveryOrderId(recoveryOrder.Id);

            if (recoveryOrder.QuantityReceived != details.Count())
            {
                recoveryOrder.Errors.Add("QuantityReceived", "Jumlah quantity received dan jumlah recovery order detail tidak sama");
            }
            return(recoveryOrder);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        public RecoveryOrder VHasNoRecoveryOrderDetail(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService)
        {
            IList <RecoveryOrderDetail> details = _recoveryOrderDetailService.GetObjectsByRecoveryOrderId(recoveryOrder.Id);

            if (details.Any())
            {
                recoveryOrder.Errors.Add("Generic", "Tidak boleh terasosiasi dengan recovery order detail");
            }
            return(recoveryOrder);
        }
Exemplo n.º 18
0
 public RecoveryOrder VDeleteObject(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService, IRecoveryAccessoryDetailService _recoveryAccessoryDetailService)
 {
     VHasNotBeenConfirmed(recoveryOrder);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VHasNoRecoveryOrderDetail(recoveryOrder, _recoveryOrderDetailService);
     return(recoveryOrder);
 }
Exemplo n.º 19
0
        public RecoveryOrder VHasRecoveryOrderDetails(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService)
        {
            IList <RecoveryOrderDetail> details = _recoveryOrderDetailService.GetObjectsByRecoveryOrderId(recoveryOrder.Id);

            if (!details.Any())
            {
                recoveryOrder.Errors.Add("Generic", "Harus membuat recovery order detail dahulu");
            }
            return(recoveryOrder);
        }
Exemplo n.º 20
0
 public RecoveryOrder VUpdateObject(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService, ICoreIdentificationService _coreIdentificationService, IRecoveryOrderService _recoveryOrderService)
 {
     VHasNotBeenConfirmed(recoveryOrder);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VCreateObject(recoveryOrder, _coreIdentificationService, _recoveryOrderService);
     return(recoveryOrder);
 }
Exemplo n.º 21
0
        public RecoveryOrder VQuantityReceivedEqualDetails(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService)
        {
            IList <RecoveryOrderDetail> details = _recoveryOrderDetailService.GetObjectsByRecoveryOrderId(recoveryOrder.Id);

            if (recoveryOrder.QuantityReceived != details.Count())
            {
                recoveryOrder.Errors.Add("Generic", "Quantity Received = " + recoveryOrder.QuantityReceived + ", " +
                                         "sementara jumlah roller = " + details.Count());
            }
            return(recoveryOrder);
        }
Exemplo n.º 22
0
        public RecoveryOrder CreateObject(int CoreIdentificationId, string Code, int QuantityReceived, int WarehouseId, ICoreIdentificationService _coreIdentificationService)
        {
            RecoveryOrder recoveryOrder = new RecoveryOrder
            {
                CoreIdentificationId = CoreIdentificationId,
                Code             = Code,
                QuantityReceived = QuantityReceived,
                WarehouseId      = WarehouseId
            };

            return(this.CreateObject(recoveryOrder, _coreIdentificationService));
        }
        public RecoveryAccessoryDetail VQuantityInStock(RecoveryAccessoryDetail recoveryAccessoryDetail, IRecoveryOrderService _recoveryOrderService, IRecoveryOrderDetailService _recoveryOrderDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService)
        {
            RecoveryOrderDetail detail        = _recoveryOrderDetailService.GetObjectById(recoveryAccessoryDetail.RecoveryOrderDetailId);
            RecoveryOrder       recoveryOrder = _recoveryOrderService.GetObjectById(detail.RecoveryOrderId);
            WarehouseItem       warehouseItem = _warehouseItemService.FindOrCreateObject(recoveryOrder.WarehouseId, recoveryAccessoryDetail.ItemId);

            if (warehouseItem.Quantity < recoveryAccessoryDetail.Quantity)
            {
                recoveryAccessoryDetail.Errors.Add("Quantity", "Tidak boleh lebih dari jumlah stock barang");
            }
            return(recoveryAccessoryDetail);
        }
Exemplo n.º 24
0
 public RecoveryOrder VHasUniqueCode(RecoveryOrder recoveryOrder, IRecoveryOrderService _recoveryOrderService)
 {
     if (String.IsNullOrEmpty(recoveryOrder.Code) || recoveryOrder.Code.Trim() == "")
     {
         recoveryOrder.Errors.Add("Code", "Tidak boleh kosong");
     }
     if (_recoveryOrderService.IsCodeDuplicated(recoveryOrder))
     {
         recoveryOrder.Errors.Add("Code", "Tidak boleh ada duplikasi");
     }
     return(recoveryOrder);
 }
Exemplo n.º 25
0
        public string PrintError(RecoveryOrder obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
Exemplo n.º 26
0
        public RecoveryOrder VAllDetailsHaveNotBeenDisassembledNorRejected(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService)
        {
            IList <RecoveryOrderDetail> details = _recoveryOrderDetailService.GetObjectsByRecoveryOrderId(recoveryOrder.Id);

            foreach (var detail in details)
            {
                if (detail.IsDisassembled || detail.IsRejected)
                {
                    recoveryOrder.Errors.Add("Generic", "Semua recovery order detail harus belum di disassemble atau di reject");
                    return(recoveryOrder);
                }
            }
            return(recoveryOrder);
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
0
        public RecoveryOrder VAllDetailsHaveBeenFinishedOrRejected(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService)
        {
            IList <RecoveryOrderDetail> details = _recoveryOrderDetailService.GetObjectsByRecoveryOrderId(recoveryOrder.Id);

            foreach (var detail in details)
            {
                if (!detail.IsFinished && !detail.IsRejected)
                {
                    recoveryOrder.Errors.Add("Generic", "Semua recovery order detail harus telah selesai atau di reject");
                    return(recoveryOrder);
                }
            }
            return(recoveryOrder);
        }
Exemplo n.º 29
0
 public RecoveryOrder VCompleteObject(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService, IRecoveryAccessoryDetailService _recoveryAccessoryDetailService)
 {
     VHasBeenConfirmed(recoveryOrder);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VHasNotBeenCompleted(recoveryOrder);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VAllDetailsHaveBeenFinishedOrRejected(recoveryOrder, _recoveryOrderDetailService);
     return(recoveryOrder);
 }
Exemplo n.º 30
0
 public RecoveryOrder VUnconfirmObject(RecoveryOrder recoveryOrder, IRecoveryOrderDetailService _recoveryOrderDetailService, IRecoveryAccessoryDetailService _recoveryAccessoryDetailService)
 {
     VHasBeenConfirmed(recoveryOrder);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VHasNotBeenCompleted(recoveryOrder);
     if (!isValid(recoveryOrder))
     {
         return(recoveryOrder);
     }
     VAllDetailsHaveNotBeenDisassembledNorRejected(recoveryOrder, _recoveryOrderDetailService);
     return(recoveryOrder);
 }