@Test public void shouldGetEarliestLotExpirationDate() throws Exception { stockCard.setLotOnHandListWrapper(new ArrayList<LotOnHand>()); assertNull(stockCard.getEarliestLotExpiryDate()); Lot lot1 = new Lot(); lot1.setExpirationDate(DateUtil.parseString("Sep 2014", DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR)); LotOnHand lotOnHand1 = new LotOnHand(); lotOnHand1.setLot(lot1); lotOnHand1.setQuantityOnHand(1L); Lot lot2 = new Lot(); lot2.setExpirationDate(DateUtil.parseString("Jan 2013", DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR)); LotOnHand lotOnHand2 = new LotOnHand(); lotOnHand2.setLot(lot2); lotOnHand2.setQuantityOnHand(0L); Lot lot3 = new Lot(); lot3.setExpirationDate(DateUtil.parseString("Feb 2014", DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR)); LotOnHand lotOnHand3 = new LotOnHand(); lotOnHand3.setLot(lot3); lotOnHand3.setQuantityOnHand(1L); stockCard.setLotOnHandListWrapper(Arrays.asList(lotOnHand1, lotOnHand2, lotOnHand3)); assertThat(DateUtil.formatDate(stockCard.getEarliestLotExpiryDate(), DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR), is("Feb 2014")); }
public Date getEarliestLotExpiryDate() { List<LotOnHand> lotOnHandList = FluentIterable.from(getNonEmptyLotOnHandList()).filter(lotOnHand -> lotOnHand.getQuantityOnHand() > 0).toList(); if (lotOnHandList.isEmpty()) { return null; } return Collections.min(lotOnHandList, (lhs, rhs) -> lhs.getLot().getExpirationDate().compareTo(rhs.getLot().getExpirationDate())).getLot().getExpirationDate(); }
StockCard extends BaseModel implements Comparable<StockCard> { public Date getEarliestLotExpiryDate() { List<LotOnHand> lotOnHandList = FluentIterable.from(getNonEmptyLotOnHandList()).filter(lotOnHand -> lotOnHand.getQuantityOnHand() > 0).toList(); if (lotOnHandList.isEmpty()) { return null; } return Collections.min(lotOnHandList, (lhs, rhs) -> lhs.getLot().getExpirationDate().compareTo(rhs.getLot().getExpirationDate())).getLot().getExpirationDate(); } }
StockCard extends BaseModel implements Comparable<StockCard> { public Date getEarliestLotExpiryDate() { List<LotOnHand> lotOnHandList = FluentIterable.from(getNonEmptyLotOnHandList()).filter(lotOnHand -> lotOnHand.getQuantityOnHand() > 0).toList(); if (lotOnHandList.isEmpty()) { return null; } return Collections.min(lotOnHandList, (lhs, rhs) -> lhs.getLot().getExpirationDate().compareTo(rhs.getLot().getExpirationDate())).getLot().getExpirationDate(); }  }
StockCard extends BaseModel implements Comparable<StockCard> { public Date getEarliestLotExpiryDate() { List<LotOnHand> lotOnHandList = FluentIterable.from(getNonEmptyLotOnHandList()).filter(lotOnHand -> lotOnHand.getQuantityOnHand() > 0).toList(); if (lotOnHandList.isEmpty()) { return null; } return Collections.min(lotOnHandList, (lhs, rhs) -> lhs.getLot().getExpirationDate().compareTo(rhs.getLot().getExpirationDate())).getLot().getExpirationDate(); }  @Override int compareTo(@NonNull StockCard another); @Override boolean equals(Object o); @Override int hashCode(); StockMovementItem generateInitialStockMovementItem(); List<StockMovementItem> getStockMovementItemsWrapper(); float getCMM(); boolean isOverStock(); boolean isLowStock(); long calculateSOHFromLots(); List<LotOnHand> getLotOnHandListWrapper(); Date getEarliestLotExpiryDate(); Date getLastStockMovementDate(); Date getLastStockMovementCreatedTime(); List<LotOnHand> getNonEmptyLotOnHandList(); List<LotOnHand> getNoneExpiredLotOnHandList(); @Override String toString(); }
StockCard extends BaseModel implements Comparable<StockCard> { public Date getEarliestLotExpiryDate() { List<LotOnHand> lotOnHandList = FluentIterable.from(getNonEmptyLotOnHandList()).filter(lotOnHand -> lotOnHand.getQuantityOnHand() > 0).toList(); if (lotOnHandList.isEmpty()) { return null; } return Collections.min(lotOnHandList, (lhs, rhs) -> lhs.getLot().getExpirationDate().compareTo(rhs.getLot().getExpirationDate())).getLot().getExpirationDate(); }  @Override int compareTo(@NonNull StockCard another); @Override boolean equals(Object o); @Override int hashCode(); StockMovementItem generateInitialStockMovementItem(); List<StockMovementItem> getStockMovementItemsWrapper(); float getCMM(); boolean isOverStock(); boolean isLowStock(); long calculateSOHFromLots(); List<LotOnHand> getLotOnHandListWrapper(); Date getEarliestLotExpiryDate(); Date getLastStockMovementDate(); Date getLastStockMovementCreatedTime(); List<LotOnHand> getNonEmptyLotOnHandList(); List<LotOnHand> getNoneExpiredLotOnHandList(); @Override String toString(); static final String DIVIDER; }