コード例 #1
0
 public bool ValidUnconfirmObject(RollerWarehouseMutation rollerWarehouseMutation, IRollerWarehouseMutationService _rollerWarehouseMutationService, IRollerWarehouseMutationDetailService _rollerWarehouseMutationDetailService,
                                  IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     rollerWarehouseMutation.Errors.Clear();
     VUnconfirmObject(rollerWarehouseMutation, _rollerWarehouseMutationService, _rollerWarehouseMutationDetailService, _itemService, _barringService, _warehouseItemService);
     return(isValid(rollerWarehouseMutation));
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        public RollerWarehouseMutation VDetailsAreVerifiedConfirmable(RollerWarehouseMutation rollerWarehouseMutation, IRollerWarehouseMutationService _rollerWarehouseMutationService, IRollerWarehouseMutationDetailService _rollerWarehouseMutationDetailService,
                                                                      IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
        {
            IList <RollerWarehouseMutationDetail> details           = _rollerWarehouseMutationDetailService.GetObjectsByRollerWarehouseMutationId(rollerWarehouseMutation.Id);
            IDictionary <int, int> ValuePairWarehouseItemIdQuantity = new Dictionary <int, int>();

            foreach (var detail in details)
            {
                WarehouseItem warehouseItemFrom = _warehouseItemService.FindOrCreateObject(rollerWarehouseMutation.WarehouseFromId, detail.ItemId);
                if (ValuePairWarehouseItemIdQuantity.ContainsKey(warehouseItemFrom.Id))
                {
                    ValuePairWarehouseItemIdQuantity[warehouseItemFrom.Id] += 1;
                }
                else
                {
                    ValuePairWarehouseItemIdQuantity.Add(warehouseItemFrom.Id, 1);
                }
            }

            foreach (var ValuePair in ValuePairWarehouseItemIdQuantity)
            {
                WarehouseItem warehouseItemFrom = _warehouseItemService.GetObjectById(ValuePair.Key);
                if (ValuePair.Value > warehouseItemFrom.Quantity)
                {
                    rollerWarehouseMutation.Errors.Add("Generic", "Stock barang tidak boleh kurang dari stock yang mau dimutasikan");
                    return(rollerWarehouseMutation);
                }
            }
            return(rollerWarehouseMutation);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public dynamic GetInfo(int Id)
        {
            RollerWarehouseMutation model = new RollerWarehouseMutation();

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

            return(Json(new
            {
                model.Id,
                model.Code,
                model.CoreIdentificationId,
                CoreIdentification = _coreIdentificationService.GetObjectById(model.CoreIdentificationId).Code,
                model.WarehouseFromId,
                WarehouseFromCode = _warehouseService.GetObjectById(model.WarehouseFromId).Code,
                WarehouseFrom = _warehouseService.GetObjectById(model.WarehouseFromId).Name,
                model.WarehouseToId,
                model.MutationDate,
                WarehouseToCode = _warehouseService.GetObjectById(model.WarehouseToId).Code,
                WarehouseTo = _warehouseService.GetObjectById(model.WarehouseToId).Name,
                model.Quantity,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
 public RollerWarehouseMutation VHasConfirmationDate(RollerWarehouseMutation obj)
 {
     if (obj.ConfirmationDate == null)
     {
         obj.Errors.Add("ConfirmationDate", "Tidak boleh kosong");
     }
     return(obj);
 }
コード例 #7
0
 public RollerWarehouseMutation VHasNotBeenConfirmed(RollerWarehouseMutation rollerWarehouseMutation)
 {
     if (rollerWarehouseMutation.IsConfirmed)
     {
         rollerWarehouseMutation.Errors.Add("IsConfirmed", "Tidak boleh sudah dikonfirmasi");
     }
     return(rollerWarehouseMutation);
 }
コード例 #8
0
 public RollerWarehouseMutation VHasMutationDate(RollerWarehouseMutation rollerWarehouseMutation)
 {
     if (rollerWarehouseMutation.MutationDate == null)
     {
         rollerWarehouseMutation.Errors.Add("MutationDate", "Tidak boleh kosong");
     }
     return(rollerWarehouseMutation);
 }
コード例 #9
0
 public RollerWarehouseMutation VHasBeenConfirmed(RollerWarehouseMutation rollerWarehouseMutation)
 {
     if (!rollerWarehouseMutation.IsConfirmed)
     {
         rollerWarehouseMutation.Errors.Add("IsConfirmed", "Harus sudah dikonfirmasi");
     }
     return(rollerWarehouseMutation);
 }
コード例 #10
0
 public RollerWarehouseMutation VHasDifferentWarehouse(RollerWarehouseMutation rollerWarehouseMutation)
 {
     if (rollerWarehouseMutation.WarehouseFromId == rollerWarehouseMutation.WarehouseToId)
     {
         rollerWarehouseMutation.Errors.Add("Generic", "Warehouse sebelum dan sesudah tidak boleh sama");
     }
     return(rollerWarehouseMutation);
 }
コード例 #11
0
 public RollerWarehouseMutation VUpdateObject(RollerWarehouseMutation rollerWarehouseMutation, IWarehouseService _warehouseService, ICoreIdentificationService _coreIdentificationService)
 {
     VHasNotBeenConfirmed(rollerWarehouseMutation);
     if (!isValid(rollerWarehouseMutation))
     {
         return(rollerWarehouseMutation);
     }
     VCreateObject(rollerWarehouseMutation, _warehouseService, _coreIdentificationService);
     return(rollerWarehouseMutation);
 }
コード例 #12
0
        public RollerWarehouseMutationDetail VHasRollerWarehouseMutation(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, IRollerWarehouseMutationService _rollerWarehouseMutationService)
        {
            RollerWarehouseMutation rollerWarehouseMutation = _rollerWarehouseMutationService.GetObjectById(rollerWarehouseMutationDetail.RollerWarehouseMutationId);

            if (rollerWarehouseMutation == null)
            {
                rollerWarehouseMutationDetail.Errors.Add("RollerWarehouseMutationId", "Tidak terasosiasi dengan Roller Warehouse Mutation");
            }
            return(rollerWarehouseMutationDetail);
        }
コード例 #13
0
        public RollerWarehouseMutationDetail VRollerWarehouseMutationHasBeenConfirmed(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, IRollerWarehouseMutationService _rollerWarehouseMutationService)
        {
            RollerWarehouseMutation rollerWarehouseMutation = _rollerWarehouseMutationService.GetObjectById(rollerWarehouseMutationDetail.RollerWarehouseMutationId);

            if (!rollerWarehouseMutation.IsConfirmed)
            {
                rollerWarehouseMutationDetail.Errors.Add("Generic", "RollerWarehouseMutation harus sudah dikonfirmasi");
            }
            return(rollerWarehouseMutationDetail);
        }
コード例 #14
0
        public RollerWarehouseMutationDetail VRollerWarehouseMutationHasNotBeenCompleted(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, IRollerWarehouseMutationService _rollerWarehouseMutationService)
        {
            RollerWarehouseMutation rollerWarehouseMutation = _rollerWarehouseMutationService.GetObjectById(rollerWarehouseMutationDetail.RollerWarehouseMutationId);

            if (rollerWarehouseMutation.IsCompleted)
            {
                rollerWarehouseMutationDetail.Errors.Add("Generic", "RollerWarehouseMutation tidak boleh sudah complete");
            }
            return(rollerWarehouseMutationDetail);
        }
コード例 #15
0
        public RollerWarehouseMutation VHasRollerWarehouseMutationDetails(RollerWarehouseMutation rollerWarehouseMutation, IRollerWarehouseMutationDetailService _rollerWarehouseMutationDetailService)
        {
            IList <RollerWarehouseMutationDetail> details = _rollerWarehouseMutationDetailService.GetObjectsByRollerWarehouseMutationId(rollerWarehouseMutation.Id);

            if (!details.Any())
            {
                rollerWarehouseMutation.Errors.Add("Generic", "Details tidak boleh tidak ada");
            }
            return(rollerWarehouseMutation);
        }
コード例 #16
0
        public RollerWarehouseMutation VHasWarehouseTo(RollerWarehouseMutation rollerWarehouseMutation, IWarehouseService _warehouseService)
        {
            Warehouse warehouseTo = _warehouseService.GetObjectById(rollerWarehouseMutation.WarehouseToId);

            if (warehouseTo == null)
            {
                rollerWarehouseMutation.Errors.Add("WarehouseToId", "Tidak terasosiasi dengan warehouse");
            }
            return(rollerWarehouseMutation);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        public RollerWarehouseMutationDetail VHasWarehouseItemTo(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, IRollerWarehouseMutationService _rollerWarehouseMutationService, IWarehouseItemService _warehouseItemService)
        {
            RollerWarehouseMutation rollerWarehouseMutation = _rollerWarehouseMutationService.GetObjectById(rollerWarehouseMutationDetail.RollerWarehouseMutationId);
            WarehouseItem           warehouseItemTo         = _warehouseItemService.FindOrCreateObject(rollerWarehouseMutation.WarehouseToId, rollerWarehouseMutationDetail.ItemId);

            if (warehouseItemTo == null)
            {
                rollerWarehouseMutationDetail.Errors.Add("Generic", "Tidak terasosiasi dengan item dari warehouse yang dituju");
            }
            return(rollerWarehouseMutationDetail);
        }
コード例 #19
0
        public string PrintError(RollerWarehouseMutation 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);
        }
コード例 #20
0
        public RollerWarehouseMutationDetail VNonNegativeStockQuantity(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, IRollerWarehouseMutationService _rollerWarehouseMutationService,
                                                                       IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService, bool CaseConfirm)
        {
            int Quantity = CaseConfirm ? 1 : -1;
            RollerWarehouseMutation rollerWarehouseMutation = _rollerWarehouseMutationService.GetObjectById(rollerWarehouseMutationDetail.RollerWarehouseMutationId);
            WarehouseItem           warehouseItemFrom       = _warehouseItemService.FindOrCreateObject(rollerWarehouseMutation.WarehouseFromId, rollerWarehouseMutationDetail.ItemId);

            if (warehouseItemFrom.Quantity + Quantity < 0)
            {
                rollerWarehouseMutationDetail.Errors.Add("Quantity", "Stock barang tidak boleh menjadi kurang dari 0");
                return(rollerWarehouseMutationDetail);
            }
            return(rollerWarehouseMutationDetail);
        }
コード例 #21
0
        public dynamic Insert(RollerWarehouseMutation model)
        {
            try
            {
                model = _rollerWarehouseMutationService.CreateObject(model, _warehouseService, _coreIdentificationService);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
コード例 #22
0
        public dynamic Delete(RollerWarehouseMutation model)
        {
            try
            {
                var data = _rollerWarehouseMutationService.GetObjectById(model.Id);
                model = _rollerWarehouseMutationService.SoftDeleteObject(data);
            }
            catch (Exception ex)
            {
                LOG.Error("Delete Failed", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
コード例 #23
0
 public RollerWarehouseMutation UnconfirmObject(RollerWarehouseMutation rollerWarehouseMutation, IRollerWarehouseMutationDetailService _rollerWarehouseMutationDetailService,
                                                IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService,
                                                IStockMutationService _stockMutationService, ICoreIdentificationDetailService _coreIdentificationDetailService,
                                                ICoreIdentificationService _coreIdentificationService)
 {
     if (_validator.ValidUnconfirmObject(rollerWarehouseMutation, this, _rollerWarehouseMutationDetailService,
                                         _itemService, _barringService, _warehouseItemService))
     {
         IList <RollerWarehouseMutationDetail> rollerWarehouseMutationDetails = _rollerWarehouseMutationDetailService.GetObjectsByRollerWarehouseMutationId(rollerWarehouseMutation.Id);
         foreach (var detail in rollerWarehouseMutationDetails)
         {
             detail.Errors = new Dictionary <string, string>();
             _rollerWarehouseMutationDetailService.UnconfirmObject(detail, this, _itemService, _barringService, _warehouseItemService,
                                                                   _stockMutationService, _coreIdentificationDetailService, _coreIdentificationService);
         }
         _repository.UnconfirmObject(rollerWarehouseMutation);
     }
     return(rollerWarehouseMutation);
 }
コード例 #24
0
        public dynamic UnConfirm(RollerWarehouseMutation model)
        {
            try
            {
                var data = _rollerWarehouseMutationService.GetObjectById(model.Id);
                model = _rollerWarehouseMutationService.UnconfirmObject(data, _rollerWarehouseMutationDetailService
                                                                        , _itemService, _barringService, _warehouseItemService, _stockMutationService, _coreIdentificationDetailService
                                                                        , _coreIdentificationService);
            }
            catch (Exception ex)
            {
                LOG.Error("Unconfirm Failed", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
コード例 #25
0
 public RollerWarehouseMutation VCreateObject(RollerWarehouseMutation rollerWarehouseMutation, IWarehouseService _warehouseService, ICoreIdentificationService _coreIdentificationService)
 {
     VHasCoreIdentification(rollerWarehouseMutation, _coreIdentificationService);
     if (!isValid(rollerWarehouseMutation))
     {
         return(rollerWarehouseMutation);
     }
     VHasDifferentWarehouse(rollerWarehouseMutation);
     if (!isValid(rollerWarehouseMutation))
     {
         return(rollerWarehouseMutation);
     }
     VHasWarehouseFrom(rollerWarehouseMutation, _warehouseService);
     if (!isValid(rollerWarehouseMutation))
     {
         return(rollerWarehouseMutation);
     }
     VHasWarehouseTo(rollerWarehouseMutation, _warehouseService);
     return(rollerWarehouseMutation);
 }
コード例 #26
0
 public RollerWarehouseMutation VConfirmObject(RollerWarehouseMutation rollerWarehouseMutation, IRollerWarehouseMutationService _rollerWarehouseMutationService, IRollerWarehouseMutationDetailService _rollerWarehouseMutationDetailService,
                                               IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     VHasConfirmationDate(rollerWarehouseMutation);
     if (!isValid(rollerWarehouseMutation))
     {
         return(rollerWarehouseMutation);
     }
     VHasNotBeenConfirmed(rollerWarehouseMutation);
     if (!isValid(rollerWarehouseMutation))
     {
         return(rollerWarehouseMutation);
     }
     VHasRollerWarehouseMutationDetails(rollerWarehouseMutation, _rollerWarehouseMutationDetailService);
     if (!isValid(rollerWarehouseMutation))
     {
         return(rollerWarehouseMutation);
     }
     VDetailsAreVerifiedConfirmable(rollerWarehouseMutation, _rollerWarehouseMutationService, _rollerWarehouseMutationDetailService, _itemService, _barringService, _warehouseItemService);
     return(rollerWarehouseMutation);
 }
コード例 #27
0
        public dynamic Update(RollerWarehouseMutation model)
        {
            try
            {
                var data = _rollerWarehouseMutationService.GetObjectById(model.Id);
                data.CoreIdentificationId = model.CoreIdentificationId;
                data.WarehouseFromId      = model.WarehouseFromId;
                data.WarehouseToId        = model.WarehouseToId;
                data.Quantity             = model.Quantity;
                data.MutationDate         = model.MutationDate;
                model = _rollerWarehouseMutationService.UpdateObject(data, _warehouseService, _coreIdentificationService);
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
コード例 #28
0
 public RollerWarehouseMutation SoftDeleteObject(RollerWarehouseMutation rollerWarehouseMutation)
 {
     return(rollerWarehouseMutation = _validator.ValidDeleteObject(rollerWarehouseMutation) ? _repository.SoftDeleteObject(rollerWarehouseMutation) : rollerWarehouseMutation);
 }
コード例 #29
0
 public RollerWarehouseMutation UpdateObject(RollerWarehouseMutation rollerWarehouseMutation, IWarehouseService _warehouseService, ICoreIdentificationService _coreIdentificationService)
 {
     return(rollerWarehouseMutation = _validator.ValidUpdateObject(rollerWarehouseMutation, _warehouseService, _coreIdentificationService) ? _repository.UpdateObject(rollerWarehouseMutation) : rollerWarehouseMutation);
 }
コード例 #30
0
 public RollerWarehouseMutation CreateObject(RollerWarehouseMutation rollerWarehouseMutation, IWarehouseService _warehouseService, ICoreIdentificationService _coreIdentificationService)
 {
     rollerWarehouseMutation.Errors = new Dictionary <String, String>();
     return(_validator.ValidCreateObject(rollerWarehouseMutation, _warehouseService, _coreIdentificationService) ? _repository.CreateObject(rollerWarehouseMutation) : rollerWarehouseMutation);
 }