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)); }
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); }
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); }
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); }
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)); }
public RollerWarehouseMutation VHasConfirmationDate(RollerWarehouseMutation obj) { if (obj.ConfirmationDate == null) { obj.Errors.Add("ConfirmationDate", "Tidak boleh kosong"); } return(obj); }
public RollerWarehouseMutation VHasNotBeenConfirmed(RollerWarehouseMutation rollerWarehouseMutation) { if (rollerWarehouseMutation.IsConfirmed) { rollerWarehouseMutation.Errors.Add("IsConfirmed", "Tidak boleh sudah dikonfirmasi"); } return(rollerWarehouseMutation); }
public RollerWarehouseMutation VHasMutationDate(RollerWarehouseMutation rollerWarehouseMutation) { if (rollerWarehouseMutation.MutationDate == null) { rollerWarehouseMutation.Errors.Add("MutationDate", "Tidak boleh kosong"); } return(rollerWarehouseMutation); }
public RollerWarehouseMutation VHasBeenConfirmed(RollerWarehouseMutation rollerWarehouseMutation) { if (!rollerWarehouseMutation.IsConfirmed) { rollerWarehouseMutation.Errors.Add("IsConfirmed", "Harus sudah dikonfirmasi"); } return(rollerWarehouseMutation); }
public RollerWarehouseMutation VHasDifferentWarehouse(RollerWarehouseMutation rollerWarehouseMutation) { if (rollerWarehouseMutation.WarehouseFromId == rollerWarehouseMutation.WarehouseToId) { rollerWarehouseMutation.Errors.Add("Generic", "Warehouse sebelum dan sesudah tidak boleh sama"); } return(rollerWarehouseMutation); }
public RollerWarehouseMutation VUpdateObject(RollerWarehouseMutation rollerWarehouseMutation, IWarehouseService _warehouseService, ICoreIdentificationService _coreIdentificationService) { VHasNotBeenConfirmed(rollerWarehouseMutation); if (!isValid(rollerWarehouseMutation)) { return(rollerWarehouseMutation); } VCreateObject(rollerWarehouseMutation, _warehouseService, _coreIdentificationService); return(rollerWarehouseMutation); }
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); }
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); }
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); }
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); }
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); }
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 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); }
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); }
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); }
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 })); }
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 })); }
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); }
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 })); }
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); }
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); }
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 })); }
public RollerWarehouseMutation SoftDeleteObject(RollerWarehouseMutation rollerWarehouseMutation) { return(rollerWarehouseMutation = _validator.ValidDeleteObject(rollerWarehouseMutation) ? _repository.SoftDeleteObject(rollerWarehouseMutation) : rollerWarehouseMutation); }
public RollerWarehouseMutation UpdateObject(RollerWarehouseMutation rollerWarehouseMutation, IWarehouseService _warehouseService, ICoreIdentificationService _coreIdentificationService) { return(rollerWarehouseMutation = _validator.ValidUpdateObject(rollerWarehouseMutation, _warehouseService, _coreIdentificationService) ? _repository.UpdateObject(rollerWarehouseMutation) : rollerWarehouseMutation); }
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); }