예제 #1
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 CoreIdentification VConfirmObject(CoreIdentification coreIdentification, ICoreIdentificationDetailService _coreIdentificationDetailService,
                                          ICoreBuilderService _coreBuilderService, IItemService _itemService, IWarehouseItemService _warehouseItemService)
 {
     VHasConfirmationDate(coreIdentification);
     if (!isValid(coreIdentification))
     {
         return(coreIdentification);
     }
     VHasCoreIdentificationDetails(coreIdentification, _coreIdentificationDetailService);
     if (!isValid(coreIdentification))
     {
         return(coreIdentification);
     }
     VQuantityEqualNumberOfDetails(coreIdentification, _coreIdentificationDetailService);
     if (!isValid(coreIdentification))
     {
         return(coreIdentification);
     }
     VHasNotBeenConfirmed(coreIdentification);
     if (!isValid(coreIdentification))
     {
         return(coreIdentification);
     }
     VQuantityIsInStock(coreIdentification, _coreIdentificationDetailService, _coreBuilderService, _itemService, _warehouseItemService);
     return(coreIdentification);
 }
 public bool ValidConfirmObject(CoreIdentification coreIdentification, ICoreIdentificationDetailService _coreIdentificationDetailService,
                                ICoreBuilderService _coreBuilderService, IItemService _itemService, IWarehouseItemService _warehouseItemService)
 {
     coreIdentification.Errors.Clear();
     VConfirmObject(coreIdentification, _coreIdentificationDetailService, _coreBuilderService, _itemService, _warehouseItemService);
     return(isValid(coreIdentification));
 }
 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 CoreIdentification VHasConfirmationDate(CoreIdentification coreIdentification)
 {
     if (coreIdentification.ConfirmationDate == null)
     {
         coreIdentification.Errors.Add("ConfirmationDate", "Tidak boleh kosong");
     }
     return(coreIdentification);
 }
 public CoreIdentification VQuantity(CoreIdentification coreIdentification)
 {
     if (coreIdentification.Quantity <= 0)
     {
         coreIdentification.Errors.Add("Quantity", "Tidak boleh 0 atau negatif");
     }
     return(coreIdentification);
 }
 public CoreIdentification VHasBeenConfirmed(CoreIdentification coreIdentification)
 {
     if (!coreIdentification.IsConfirmed)
     {
         coreIdentification.Errors.Add("Generic", "Belum dikonfirmasi");
     }
     return(coreIdentification);
 }
예제 #8
0
 public CoreIdentification CompleteObject(CoreIdentification coreIdentification, ICoreIdentificationDetailService _coreIdentificationDetailService)
 {
     if (_validator.ValidCompleteObject(coreIdentification, _coreIdentificationDetailService))
     {
         _repository.CompleteObject(coreIdentification);
     }
     return(coreIdentification);
 }
 public CoreIdentification VHasNotBeenConfirmed(CoreIdentification coreIdentification)
 {
     if (coreIdentification.IsConfirmed)
     {
         coreIdentification.Errors.Add("Generic", "Telah dikonfirmasi");
     }
     return(coreIdentification);
 }
 public CoreIdentification VHasIdentifiedDate(CoreIdentification coreIdentification)
 {
     // will always be true since date is not null
     if (coreIdentification.IdentifiedDate == null)
     {
         coreIdentification.Errors.Add("IdentifiedDate", "Tidak boleh kosong");
     }
     return(coreIdentification);
 }
        public CoreIdentification VIsInRecoveryOrder(CoreIdentification coreIdentification, IRecoveryOrderService _recoveryOrderService)
        {
            IList <RecoveryOrder> recoveryOrders = _recoveryOrderService.GetObjectsByCoreIdentificationId(coreIdentification.Id);

            if (recoveryOrders.Any())
            {
                coreIdentification.Errors.Add("Generic", "Tidak boleh ada asosiasi dengan Recovery Order");
            }
            return(coreIdentification);
        }
예제 #12
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);
        }
예제 #13
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);
        }
예제 #14
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);
        }
 public CoreIdentification VUnconfirmObject(CoreIdentification coreIdentification, IRecoveryOrderService _recoveryOrderService)
 {
     VHasBeenConfirmed(coreIdentification);
     if (!isValid(coreIdentification))
     {
         return(coreIdentification);
     }
     VIsInRecoveryOrder(coreIdentification, _recoveryOrderService);
     return(coreIdentification);
 }
예제 #16
0
 public CoreIdentification VUpdateObject(CoreIdentification coreIdentification, ICoreIdentificationService _coreIdentificationService, IContactService _contactService)
 {
     VCreateObject(coreIdentification, _coreIdentificationService, _contactService);
     if (!isValid(coreIdentification))
     {
         return(coreIdentification);
     }
     VHasNotBeenConfirmed(coreIdentification);
     return(coreIdentification);
 }
예제 #17
0
 public CoreIdentification UnconfirmObject(CoreIdentification coreIdentification, ICoreIdentificationDetailService _coreIdentificationDetailService, IStockMutationService _stockMutationService,
                                           IRecoveryOrderService _recoveryOrderService, ICoreBuilderService _coreBuilderService, IItemService _itemService,
                                           IWarehouseItemService _warehouseItemService, IBarringService _barringService)
 {
     if (_validator.ValidUnconfirmObject(coreIdentification, _recoveryOrderService))
     {
         _repository.UnconfirmObject(coreIdentification);
     }
     return(coreIdentification);
 }
예제 #18
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 CoreIdentification VQuantityEqualNumberOfDetails(CoreIdentification coreIdentification, ICoreIdentificationDetailService _coreIdentificationDetailService)
        {
            IList <CoreIdentificationDetail> details = _coreIdentificationDetailService.GetObjectsByCoreIdentificationId(coreIdentification.Id);

            if (coreIdentification.Quantity != details.Count())
            {
                coreIdentification.Errors.Add("Quantity", "Tidak sama dengan jumlah Core Identification Detail");
            }
            return(coreIdentification);
        }
        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);
        }
        public CoreIdentification VHasCoreIdentificationDetails(CoreIdentification coreIdentification, ICoreIdentificationDetailService _coreIdentificationDetailService)
        {
            IList <CoreIdentificationDetail> details = _coreIdentificationDetailService.GetObjectsByCoreIdentificationId(coreIdentification.Id);

            if (!details.Any())
            {
                coreIdentification.Errors.Add("Generic", "Harus membuat core identification detail dahulu");
            }
            return(coreIdentification);
        }
예제 #22
0
 public CoreIdentification ConfirmObject(CoreIdentification coreIdentification, DateTime ConfirmationDate, ICoreIdentificationDetailService _coreIdentificationDetailService, IStockMutationService _stockMutationService,
                                         IRecoveryOrderService _recoveryOrderService, IRecoveryOrderDetailService _recoveryOrderDetailService, ICoreBuilderService _coreBuilderService,
                                         IItemService _itemService, IWarehouseItemService _warehouseItemService, IBarringService _barringService)
 {
     coreIdentification.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(coreIdentification, _coreIdentificationDetailService, _coreBuilderService, _itemService, _warehouseItemService))
     {
         _repository.ConfirmObject(coreIdentification);
     }
     return(coreIdentification);
 }
 public CoreIdentification VHasUniqueCode(CoreIdentification coreIdentification, ICoreIdentificationService _coreIdentificationService)
 {
     if (String.IsNullOrEmpty(coreIdentification.Code) || coreIdentification.Code.Trim() == "")
     {
         coreIdentification.Errors.Add("Code", "Tidak boleh kosong");
     }
     if (_coreIdentificationService.IsCodeDuplicated(coreIdentification))
     {
         coreIdentification.Errors.Add("Code", "Tidak boleh ada duplikasi");
     }
     return(coreIdentification);
 }
예제 #24
0
 public CoreIdentification SoftDeleteObject(CoreIdentification coreIdentification, ICoreIdentificationDetailService _coreIdentificationDetailService, IRecoveryOrderService _recoveryOrderService)
 {
     if (_validator.ValidDeleteObject(coreIdentification, _recoveryOrderService))
     {
         IList <CoreIdentificationDetail> details = _coreIdentificationDetailService.GetObjectsByCoreIdentificationId(coreIdentification.Id);
         foreach (var detail in details)
         {
             _coreIdentificationDetailService.GetRepository().SoftDeleteObject(detail);
         }
         _repository.SoftDeleteObject(coreIdentification);
     }
     return(coreIdentification);
 }
        public string PrintError(CoreIdentification 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);
        }
예제 #26
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);
        }
예제 #27
0
        public CoreIdentification CreateObjectForInHouse(string Code, int Quantity, DateTime IdentifiedDate, int WarehouseId, IContactService _contactService)
        {
            CoreIdentification coreIdentification = new CoreIdentification
            {
                ContactId      = null,
                IsInHouse      = true,
                Code           = Code,
                Quantity       = Quantity,
                IdentifiedDate = IdentifiedDate,
                WarehouseId    = WarehouseId
            };

            return(this.CreateObject(coreIdentification, _contactService));
        }
        public CoreIdentification VAllDetailsHaveBeenDelivered(CoreIdentification coreIdentification, ICoreIdentificationDetailService _coreIdentificationDetailService)
        {
            IList <CoreIdentificationDetail> details = _coreIdentificationDetailService.GetObjectsByCoreIdentificationId(coreIdentification.Id);

            foreach (var detail in details)
            {
                if (!detail.IsDelivered)
                {
                    coreIdentification.Errors.Add("Generic", "Semua detail harus telah terkirim");
                    return(coreIdentification);
                }
            }
            return(coreIdentification);
        }
        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);
        }
 public CoreIdentification VInHouseOrHasContact(CoreIdentification coreIdentification, IContactService _contactService)
 {
     if ((coreIdentification.IsInHouse && coreIdentification.ContactId != null) ||
         (!coreIdentification.IsInHouse && coreIdentification.ContactId == null))
     {
         coreIdentification.Errors.Add("Generic", "Core Identification harus memilih InHouse atau menyertakan informasi Contact");
     }
     else if (!coreIdentification.IsInHouse && coreIdentification.ContactId != null)
     {
         Contact contact = _contactService.GetObjectById((int)coreIdentification.ContactId);
         if (contact == null)
         {
             coreIdentification.Errors.Add("ContactId", "Tidak terasosiasi dengan contact");
         }
     }
     return(coreIdentification);
 }