@Test public void shouldConvertLotMovementItemWithRightStockOnHand() throws Exception { viewModel.setQuantity("10"); viewModel.setLotNumber("lot1"); viewModel.setExpiryDate("Feb 2015"); viewModel.setLotSoh("20"); LotMovementItem lotMovementItem = viewModel.convertViewToModelAndResetSOH(new Product()); assertThat(lotMovementItem.getStockOnHand(), is(10L)); }
public LotMovementItem convertViewToModelAndResetSOH(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); long previousStockOnHand = Long.parseLong(getLotSoh()); long currentStockOnHand = Long.parseLong(getQuantity()); 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); lotMovementItem.setStockOnHand(currentStockOnHand); lotMovementItem.setMovementQuantity(currentStockOnHand - previousStockOnHand); return lotMovementItem; }
LotMovementViewModel implements Serializable { public LotMovementItem convertViewToModelAndResetSOH(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); long previousStockOnHand = Long.parseLong(getLotSoh()); long currentStockOnHand = Long.parseLong(getQuantity()); 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); lotMovementItem.setStockOnHand(currentStockOnHand); lotMovementItem.setMovementQuantity(currentStockOnHand - previousStockOnHand); return lotMovementItem; } }
LotMovementViewModel implements Serializable { public LotMovementItem convertViewToModelAndResetSOH(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); long previousStockOnHand = Long.parseLong(getLotSoh()); long currentStockOnHand = Long.parseLong(getQuantity()); 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); lotMovementItem.setStockOnHand(currentStockOnHand); lotMovementItem.setMovementQuantity(currentStockOnHand - previousStockOnHand); 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 convertViewToModelAndResetSOH(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); long previousStockOnHand = Long.parseLong(getLotSoh()); long currentStockOnHand = Long.parseLong(getQuantity()); 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); lotMovementItem.setStockOnHand(currentStockOnHand); lotMovementItem.setMovementQuantity(currentStockOnHand - previousStockOnHand); 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 convertViewToModelAndResetSOH(Product product) { LotMovementItem lotMovementItem = new LotMovementItem(); long previousStockOnHand = Long.parseLong(getLotSoh()); long currentStockOnHand = Long.parseLong(getQuantity()); 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); lotMovementItem.setStockOnHand(currentStockOnHand); lotMovementItem.setMovementQuantity(currentStockOnHand - previousStockOnHand); 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();  }