@Test public void shouldConvertLotMovementItemWithRightExpiryDate() throws Exception { viewModel.setQuantity("10"); viewModel.setLotNumber("lot1"); viewModel.setExpiryDate("Feb 2015"); LotMovementItem lotMovementItem = viewModel.convertViewToModel(new Product()); assertEquals(new GregorianCalendar(2015, 1, 28).getTime(), lotMovementItem.getLot().getExpirationDate()); }
public LotMovementItem convertViewToModel(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); Lot lot = new Lot(); lot.setProduct(product); lot.setLotNumber(lotNumber); lot.setExpirationDate(DateUtil.getActualMaximumDate(DateUtil.parseString(expiryDate, DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR))); lotMovementItem.setLot(lot); if (StringUtils.isNoneBlank(quantity)) { lotMovementItem.setMovementQuantity(Long.parseLong(quantity)); } else { lotMovementItem.setMovementQuantity(null); } return lotMovementItem; }
LotMovementViewModel implements Serializable { public LotMovementItem convertViewToModel(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); Lot lot = new Lot(); lot.setProduct(product); lot.setLotNumber(lotNumber); lot.setExpirationDate(DateUtil.getActualMaximumDate(DateUtil.parseString(expiryDate, DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR))); lotMovementItem.setLot(lot); if (StringUtils.isNoneBlank(quantity)) { lotMovementItem.setMovementQuantity(Long.parseLong(quantity)); } else { lotMovementItem.setMovementQuantity(null); } return lotMovementItem; } }
LotMovementViewModel implements Serializable { public LotMovementItem convertViewToModel(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); Lot lot = new Lot(); lot.setProduct(product); lot.setLotNumber(lotNumber); lot.setExpirationDate(DateUtil.getActualMaximumDate(DateUtil.parseString(expiryDate, DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR))); lotMovementItem.setLot(lot); if (StringUtils.isNoneBlank(quantity)) { lotMovementItem.setMovementQuantity(Long.parseLong(quantity)); } else { lotMovementItem.setMovementQuantity(null); } return lotMovementItem; } LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, String quantityOnHand, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType, String quantity); }
LotMovementViewModel implements Serializable { public LotMovementItem convertViewToModel(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); Lot lot = new Lot(); lot.setProduct(product); lot.setLotNumber(lotNumber); lot.setExpirationDate(DateUtil.getActualMaximumDate(DateUtil.parseString(expiryDate, DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR))); lotMovementItem.setLot(lot); if (StringUtils.isNoneBlank(quantity)) { lotMovementItem.setMovementQuantity(Long.parseLong(quantity)); } else { lotMovementItem.setMovementQuantity(null); } return lotMovementItem; } LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, String quantityOnHand, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType, String quantity); boolean validateQuantityNotGreaterThanSOH(); LotMovementItem convertViewToModel(Product product); boolean quantityGreaterThanZero(); LotMovementItem convertViewToModelAndResetSOH(Product product); boolean validateLotWithPositiveQuantity(); boolean validateLotWithNoEmptyFields(); boolean isExpiredLot(); boolean isNewAdded(); static String generateLotNumberForProductWithoutLot(String productCode, String expiryDate); long getAdjustmentQuantity(); @Override String toString(); }
LotMovementViewModel implements Serializable { public LotMovementItem convertViewToModel(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); Lot lot = new Lot(); lot.setProduct(product); lot.setLotNumber(lotNumber); lot.setExpirationDate(DateUtil.getActualMaximumDate(DateUtil.parseString(expiryDate, DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR))); lotMovementItem.setLot(lot); if (StringUtils.isNoneBlank(quantity)) { lotMovementItem.setMovementQuantity(Long.parseLong(quantity)); } else { lotMovementItem.setMovementQuantity(null); } return lotMovementItem; } LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, String quantityOnHand, MovementReasonManager.MovementType movementType);  LotMovementViewModel(String lotNumber, String expiryDate, MovementReasonManager.MovementType movementType, String quantity); boolean validateQuantityNotGreaterThanSOH(); LotMovementItem convertViewToModel(Product product); boolean quantityGreaterThanZero(); LotMovementItem convertViewToModelAndResetSOH(Product product); boolean validateLotWithPositiveQuantity(); boolean validateLotWithNoEmptyFields(); boolean isExpiredLot(); boolean isNewAdded(); static String generateLotNumberForProductWithoutLot(String productCode, String expiryDate); long getAdjustmentQuantity(); @Override String toString();  }