@Test public void shouldValidateEarlyExpiredLotIssued() throws Exception { stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder() .setLotSOH("100") .setExpiryDate(DateUtil.formatDateWithoutDay(oldCalendar.getTime())) .setQuantity(null).build()); assertEquals(NewMovementLotListView.LotStatus.containExpiredLots, stockMovementViewModel.getSoonestToExpireLotsIssued()); stockMovementViewModel.existingLotMovementViewModelList.clear(); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder() .setLotSOH("100") .setExpiryDate(DateUtil.formatDateWithoutDay(featureCalendar.getTime())) .setQuantity("50").build()); assertEquals(NewMovementLotListView.LotStatus.defaultStatus, stockMovementViewModel.getSoonestToExpireLotsIssued()); stockMovementViewModel.existingLotMovementViewModelList.clear(); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder().build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder().build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder().build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder() .setLotSOH("100") .setExpiryDate(DateUtil.formatDateWithoutDay(featureCalendar.getTime())) .setQuantity("50").build()); assertEquals(NewMovementLotListView.LotStatus.containExpiredLots, stockMovementViewModel.getSoonestToExpireLotsIssued()); stockMovementViewModel.existingLotMovementViewModelList.clear(); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder() .setLotSOH("100") .setExpiryDate(DateUtil.formatDateWithoutDay(featureCalendar.getTime())) .setQuantity("100").build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder().build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder().build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder().build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder() .setLotSOH("100") .setExpiryDate(DateUtil.formatDateWithoutDay(featureCalendar.getTime())) .setQuantity("50").build()); assertEquals(NewMovementLotListView.LotStatus.containExpiredLots, stockMovementViewModel.getSoonestToExpireLotsIssued()); stockMovementViewModel.existingLotMovementViewModelList.clear(); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder().build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder() .setLotSOH("100") .setExpiryDate(DateUtil.formatDateWithoutDay(featureCalendar.getTime())) .setQuantity("50") .build()); assertEquals(NewMovementLotListView.LotStatus.containExpiredLots, stockMovementViewModel.getSoonestToExpireLotsIssued()); stockMovementViewModel.existingLotMovementViewModelList.clear(); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder() .setLotSOH("100") .setExpiryDate(DateUtil.formatDateWithoutDay(featureCalendar.getTime())) .setQuantity(null) .build()); stockMovementViewModel.existingLotMovementViewModelList.add(new LotMovementViewModelBuilder() .setLotSOH("100") .setExpiryDate(DateUtil.formatDateWithoutDay(featureCalendar1.getTime())) .setQuantity("10") .build()); assertEquals(NewMovementLotListView.LotStatus.notSoonestToExpireLotsIssued, stockMovementViewModel.getSoonestToExpireLotsIssued()); }
public LotStatus getSoonestToExpireLotsIssued() { boolean soonestToExpireLotsIssued = true; boolean containExpiredLot = false; for (LotMovementViewModel lotMovementViewModel : existingLotMovementViewModelList) { if (!containExpiredLot) { containExpiredLot = lotMovementViewModel.isExpiredLot(); } if (!StringUtils.isEmpty(lotMovementViewModel.getQuantity()) && Long.parseLong(lotMovementViewModel.getQuantity()) > 0) { if (!soonestToExpireLotsIssued) { return LotStatus.notSoonestToExpireLotsIssued; } if (Long.parseLong(lotMovementViewModel.getQuantity()) < Long.parseLong(lotMovementViewModel.getLotSoh())) { soonestToExpireLotsIssued = false; } } else { if (containExpiredLot) { return LotStatus.containExpiredLots; } soonestToExpireLotsIssued = false; } } return LotStatus.defaultStatus; }
StockMovementViewModel extends BaseStockMovementViewModel { public LotStatus getSoonestToExpireLotsIssued() { boolean soonestToExpireLotsIssued = true; boolean containExpiredLot = false; for (LotMovementViewModel lotMovementViewModel : existingLotMovementViewModelList) { if (!containExpiredLot) { containExpiredLot = lotMovementViewModel.isExpiredLot(); } if (!StringUtils.isEmpty(lotMovementViewModel.getQuantity()) && Long.parseLong(lotMovementViewModel.getQuantity()) > 0) { if (!soonestToExpireLotsIssued) { return LotStatus.notSoonestToExpireLotsIssued; } if (Long.parseLong(lotMovementViewModel.getQuantity()) < Long.parseLong(lotMovementViewModel.getLotSoh())) { soonestToExpireLotsIssued = false; } } else { if (containExpiredLot) { return LotStatus.containExpiredLots; } soonestToExpireLotsIssued = false; } } return LotStatus.defaultStatus; } }
StockMovementViewModel extends BaseStockMovementViewModel { public LotStatus getSoonestToExpireLotsIssued() { boolean soonestToExpireLotsIssued = true; boolean containExpiredLot = false; for (LotMovementViewModel lotMovementViewModel : existingLotMovementViewModelList) { if (!containExpiredLot) { containExpiredLot = lotMovementViewModel.isExpiredLot(); } if (!StringUtils.isEmpty(lotMovementViewModel.getQuantity()) && Long.parseLong(lotMovementViewModel.getQuantity()) > 0) { if (!soonestToExpireLotsIssued) { return LotStatus.notSoonestToExpireLotsIssued; } if (Long.parseLong(lotMovementViewModel.getQuantity()) < Long.parseLong(lotMovementViewModel.getLotSoh())) { soonestToExpireLotsIssued = false; } } else { if (containExpiredLot) { return LotStatus.containExpiredLots; } soonestToExpireLotsIssued = false; } } return LotStatus.defaultStatus; } StockMovementViewModel(StockMovementItem item); }
StockMovementViewModel extends BaseStockMovementViewModel { public LotStatus getSoonestToExpireLotsIssued() { boolean soonestToExpireLotsIssued = true; boolean containExpiredLot = false; for (LotMovementViewModel lotMovementViewModel : existingLotMovementViewModelList) { if (!containExpiredLot) { containExpiredLot = lotMovementViewModel.isExpiredLot(); } if (!StringUtils.isEmpty(lotMovementViewModel.getQuantity()) && Long.parseLong(lotMovementViewModel.getQuantity()) > 0) { if (!soonestToExpireLotsIssued) { return LotStatus.notSoonestToExpireLotsIssued; } if (Long.parseLong(lotMovementViewModel.getQuantity()) < Long.parseLong(lotMovementViewModel.getLotSoh())) { soonestToExpireLotsIssued = false; } } else { if (containExpiredLot) { return LotStatus.containExpiredLots; } soonestToExpireLotsIssued = false; } } return LotStatus.defaultStatus; } StockMovementViewModel(StockMovementItem item); String getReceived(); void setReceived(String received); String getIssued(); void setIssued(String issued); String getNegativeAdjustment(); void setNegativeAdjustment(String negativeAdjustment); String getPositiveAdjustment(); void setPositiveAdjustment(String positiveAdjustment); StockMovementItem convertViewToModel(StockCard stockCard); boolean validateEmpty(); boolean validateInputValid(); boolean validateQuantitiesNotZero(); boolean isIssuedReason(); void populateStockExistence(long previousStockOnHand); boolean movementQuantitiesExist(); boolean isLotEmpty(); LotStatus getSoonestToExpireLotsIssued(); boolean hasLotDataChanged(); boolean validateSignature(); boolean validateMovementReason(); }
StockMovementViewModel extends BaseStockMovementViewModel { public LotStatus getSoonestToExpireLotsIssued() { boolean soonestToExpireLotsIssued = true; boolean containExpiredLot = false; for (LotMovementViewModel lotMovementViewModel : existingLotMovementViewModelList) { if (!containExpiredLot) { containExpiredLot = lotMovementViewModel.isExpiredLot(); } if (!StringUtils.isEmpty(lotMovementViewModel.getQuantity()) && Long.parseLong(lotMovementViewModel.getQuantity()) > 0) { if (!soonestToExpireLotsIssued) { return LotStatus.notSoonestToExpireLotsIssued; } if (Long.parseLong(lotMovementViewModel.getQuantity()) < Long.parseLong(lotMovementViewModel.getLotSoh())) { soonestToExpireLotsIssued = false; } } else { if (containExpiredLot) { return LotStatus.containExpiredLots; } soonestToExpireLotsIssued = false; } } return LotStatus.defaultStatus; } StockMovementViewModel(StockMovementItem item); String getReceived(); void setReceived(String received); String getIssued(); void setIssued(String issued); String getNegativeAdjustment(); void setNegativeAdjustment(String negativeAdjustment); String getPositiveAdjustment(); void setPositiveAdjustment(String positiveAdjustment); StockMovementItem convertViewToModel(StockCard stockCard); boolean validateEmpty(); boolean validateInputValid(); boolean validateQuantitiesNotZero(); boolean isIssuedReason(); void populateStockExistence(long previousStockOnHand); boolean movementQuantitiesExist(); boolean isLotEmpty(); LotStatus getSoonestToExpireLotsIssued(); boolean hasLotDataChanged(); boolean validateSignature(); boolean validateMovementReason();  }