@Test public void populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment() throws ParseException { LotMovementViewModel lotMovementViewModel1 = new LotMovementViewModel("ABC", "Dec 2016", "10", MovementReasonManager.MovementType.PHYSICAL_INVENTORY); lotMovementViewModel1.setQuantity("10"); LotMovementViewModel lotMovementViewModel2 = new LotMovementViewModel("DEF", "Nov 2016", "20", MovementReasonManager.MovementType.PHYSICAL_INVENTORY); lotMovementViewModel2.setQuantity("15"); LotMovementViewModel lotMovementViewModel3 = new LotMovementViewModel("HIJ", "Oct 2016", "30", MovementReasonManager.MovementType.PHYSICAL_INVENTORY); lotMovementViewModel3.setQuantity("5"); LotMovementViewModel lotMovementViewModelNew = new LotMovementViewModel("HIJ", "Oct 2016", "0L", MovementReasonManager.MovementType.PHYSICAL_INVENTORY); lotMovementViewModelNew.setQuantity("10"); List<LotMovementViewModel> lotMovementViewModelList = newArrayList(lotMovementViewModel1, lotMovementViewModel2, lotMovementViewModel3); List<LotMovementViewModel> newLotMovementViewModelList = newArrayList(lotMovementViewModelNew); StockCard stockCard = StockCardBuilder.buildStockCard(); StockMovementItem stockMovementItem = new StockMovementItemBuilder().withMovementDate("2016-11-30").build(); stockMovementItem.setStockCard(stockCard); stockMovementItem.populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(lotMovementViewModelList, newLotMovementViewModelList); assertThat(stockMovementItem.getLotMovementItemListWrapper().get(0).getStockOnHand(), is(10L)); assertThat(stockMovementItem.getLotMovementItemListWrapper().get(1).getMovementQuantity(), is(-5L)); assertThat(stockMovementItem.getLotMovementItemListWrapper().get(2).getMovementQuantity(), is(-25L)); assertThat(stockMovementItem.getNewAddedLotMovementItemListWrapper().get(0).getMovementQuantity(), is(10L)); }
public void populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(List<LotMovementViewModel> existingLotMovementList, List<LotMovementViewModel> newAddedLotMovementList) { final StockMovementItem stockMovementItem = this; ImmutableList<LotMovementItem> existingLotMovementItemList = FluentIterable .from(existingLotMovementList) .transform(lotMovementViewModel -> { LotMovementItem lotItem = lotMovementViewModel.convertViewToModelAndResetSOH(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); lotItem.setStockOnHandReset(true); return lotItem; }).toList(); ImmutableList<LotMovementItem> newAddedLotMovementItemList = FluentIterable .from(newAddedLotMovementList) .transform(lotMovementViewModel -> { lotMovementViewModel.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); LotMovementItem lotItem = lotMovementViewModel.convertViewToModel(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); return lotItem; }).toList(); setLotMovementItemListWrapper(existingLotMovementItemList); setNewAddedLotMovementItemListWrapper(newAddedLotMovementItemList); }
StockMovementItem extends BaseModel { public void populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(List<LotMovementViewModel> existingLotMovementList, List<LotMovementViewModel> newAddedLotMovementList) { final StockMovementItem stockMovementItem = this; ImmutableList<LotMovementItem> existingLotMovementItemList = FluentIterable .from(existingLotMovementList) .transform(lotMovementViewModel -> { LotMovementItem lotItem = lotMovementViewModel.convertViewToModelAndResetSOH(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); lotItem.setStockOnHandReset(true); return lotItem; }).toList(); ImmutableList<LotMovementItem> newAddedLotMovementItemList = FluentIterable .from(newAddedLotMovementList) .transform(lotMovementViewModel -> { lotMovementViewModel.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); LotMovementItem lotItem = lotMovementViewModel.convertViewToModel(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); return lotItem; }).toList(); setLotMovementItemListWrapper(existingLotMovementItemList); setNewAddedLotMovementItemListWrapper(newAddedLotMovementItemList); } }
StockMovementItem extends BaseModel { public void populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(List<LotMovementViewModel> existingLotMovementList, List<LotMovementViewModel> newAddedLotMovementList) { final StockMovementItem stockMovementItem = this; ImmutableList<LotMovementItem> existingLotMovementItemList = FluentIterable .from(existingLotMovementList) .transform(lotMovementViewModel -> { LotMovementItem lotItem = lotMovementViewModel.convertViewToModelAndResetSOH(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); lotItem.setStockOnHandReset(true); return lotItem; }).toList(); ImmutableList<LotMovementItem> newAddedLotMovementItemList = FluentIterable .from(newAddedLotMovementList) .transform(lotMovementViewModel -> { lotMovementViewModel.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); LotMovementItem lotItem = lotMovementViewModel.convertViewToModel(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); return lotItem; }).toList(); setLotMovementItemListWrapper(existingLotMovementItemList); setNewAddedLotMovementItemListWrapper(newAddedLotMovementItemList); } StockMovementItem(StockCard stockCard, InventoryViewModel model);  StockMovementItem(StockCard stockCard, InventoryViewModel model, boolean fromInitialInventory);  StockMovementItem(StockCard stockCard); }
StockMovementItem extends BaseModel { public void populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(List<LotMovementViewModel> existingLotMovementList, List<LotMovementViewModel> newAddedLotMovementList) { final StockMovementItem stockMovementItem = this; ImmutableList<LotMovementItem> existingLotMovementItemList = FluentIterable .from(existingLotMovementList) .transform(lotMovementViewModel -> { LotMovementItem lotItem = lotMovementViewModel.convertViewToModelAndResetSOH(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); lotItem.setStockOnHandReset(true); return lotItem; }).toList(); ImmutableList<LotMovementItem> newAddedLotMovementItemList = FluentIterable .from(newAddedLotMovementList) .transform(lotMovementViewModel -> { lotMovementViewModel.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); LotMovementItem lotItem = lotMovementViewModel.convertViewToModel(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); return lotItem; }).toList(); setLotMovementItemListWrapper(existingLotMovementItemList); setNewAddedLotMovementItemListWrapper(newAddedLotMovementItemList); } StockMovementItem(StockCard stockCard, InventoryViewModel model);  StockMovementItem(StockCard stockCard, InventoryViewModel model, boolean fromInitialInventory);  StockMovementItem(StockCard stockCard); boolean isPositiveMovement(); boolean isNegativeMovement(); Period getMovementPeriod(); long calculatePreviousSOH(); List<LotMovementItem> getLotMovementItemListWrapper(); List<LotMovementItem> getNewAddedLotMovementItemListWrapper(); void populateLotQuantitiesAndCalculateNewSOH(List<LotMovementViewModel> lotMovementViewModelList,
                                                        MovementReasonManager.MovementType movementType); void populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(List<LotMovementViewModel> existingLotMovementList,
                                                                               List<LotMovementViewModel> newAddedLotMovementList); @Override String toString(); }
StockMovementItem extends BaseModel { public void populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(List<LotMovementViewModel> existingLotMovementList, List<LotMovementViewModel> newAddedLotMovementList) { final StockMovementItem stockMovementItem = this; ImmutableList<LotMovementItem> existingLotMovementItemList = FluentIterable .from(existingLotMovementList) .transform(lotMovementViewModel -> { LotMovementItem lotItem = lotMovementViewModel.convertViewToModelAndResetSOH(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); lotItem.setStockOnHandReset(true); return lotItem; }).toList(); ImmutableList<LotMovementItem> newAddedLotMovementItemList = FluentIterable .from(newAddedLotMovementList) .transform(lotMovementViewModel -> { lotMovementViewModel.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); LotMovementItem lotItem = lotMovementViewModel.convertViewToModel(getStockCard().getProduct()); lotItem.setStockMovementItem(stockMovementItem); return lotItem; }).toList(); setLotMovementItemListWrapper(existingLotMovementItemList); setNewAddedLotMovementItemListWrapper(newAddedLotMovementItemList); } StockMovementItem(StockCard stockCard, InventoryViewModel model);  StockMovementItem(StockCard stockCard, InventoryViewModel model, boolean fromInitialInventory);  StockMovementItem(StockCard stockCard); boolean isPositiveMovement(); boolean isNegativeMovement(); Period getMovementPeriod(); long calculatePreviousSOH(); List<LotMovementItem> getLotMovementItemListWrapper(); List<LotMovementItem> getNewAddedLotMovementItemListWrapper(); void populateLotQuantitiesAndCalculateNewSOH(List<LotMovementViewModel> lotMovementViewModelList,
                                                        MovementReasonManager.MovementType movementType); void populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(List<LotMovementViewModel> existingLotMovementList,
                                                                               List<LotMovementViewModel> newAddedLotMovementList); @Override String toString();  }