@Test public void shouldMakeNegativeAdjustment() throws LMISException { InventoryViewModel model = new InventoryViewModel(stockCardWithIdNine); model.getNewLotMovementViewModelList().add(new LotMovementViewModelBuilder().setExpiryDate("Jan 2015").setQuantity("80").build()); StockMovementItem item = presenter.calculateAdjustment(model, stockCardWithIdNine); assertThat(item.getMovementType(), is(MovementReasonManager.MovementType.NEGATIVE_ADJUST)); assertThat(item.getMovementQuantity(), is(20L)); assertThat(item.getStockOnHand(), is(80L)); assertThat(item.getStockCard(), is(stockCardWithIdNine)); }
protected StockMovementItem calculateAdjustment(InventoryViewModel model, StockCard stockCard) { Long inventory = model.getLotListQuantityTotalAmount(); long stockOnHand = model.getStockOnHand(); StockMovementItem item = new StockMovementItem(); item.setSignature(model.getSignature()); item.setMovementDate(new Date()); item.setMovementQuantity(Math.abs(inventory - stockOnHand)); item.setStockOnHand(inventory); item.setStockCard(stockCard); if (inventory > stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_POSITIVE); item.setMovementType(MovementReasonManager.MovementType.POSITIVE_ADJUST); } else if (inventory < stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_NEGATIVE); item.setMovementType(MovementReasonManager.MovementType.NEGATIVE_ADJUST); } else { item.setReason(MovementReasonManager.INVENTORY); item.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); } item.populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(model.getExistingLotMovementViewModelList(), model.getNewLotMovementViewModelList()); return item; }
PhysicalInventoryPresenter extends InventoryPresenter { protected StockMovementItem calculateAdjustment(InventoryViewModel model, StockCard stockCard) { Long inventory = model.getLotListQuantityTotalAmount(); long stockOnHand = model.getStockOnHand(); StockMovementItem item = new StockMovementItem(); item.setSignature(model.getSignature()); item.setMovementDate(new Date()); item.setMovementQuantity(Math.abs(inventory - stockOnHand)); item.setStockOnHand(inventory); item.setStockCard(stockCard); if (inventory > stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_POSITIVE); item.setMovementType(MovementReasonManager.MovementType.POSITIVE_ADJUST); } else if (inventory < stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_NEGATIVE); item.setMovementType(MovementReasonManager.MovementType.NEGATIVE_ADJUST); } else { item.setReason(MovementReasonManager.INVENTORY); item.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); } item.populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(model.getExistingLotMovementViewModelList(), model.getNewLotMovementViewModelList()); return item; } }
PhysicalInventoryPresenter extends InventoryPresenter { protected StockMovementItem calculateAdjustment(InventoryViewModel model, StockCard stockCard) { Long inventory = model.getLotListQuantityTotalAmount(); long stockOnHand = model.getStockOnHand(); StockMovementItem item = new StockMovementItem(); item.setSignature(model.getSignature()); item.setMovementDate(new Date()); item.setMovementQuantity(Math.abs(inventory - stockOnHand)); item.setStockOnHand(inventory); item.setStockCard(stockCard); if (inventory > stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_POSITIVE); item.setMovementType(MovementReasonManager.MovementType.POSITIVE_ADJUST); } else if (inventory < stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_NEGATIVE); item.setMovementType(MovementReasonManager.MovementType.NEGATIVE_ADJUST); } else { item.setReason(MovementReasonManager.INVENTORY); item.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); } item.populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(model.getExistingLotMovementViewModelList(), model.getNewLotMovementViewModelList()); return item; }  }
PhysicalInventoryPresenter extends InventoryPresenter { protected StockMovementItem calculateAdjustment(InventoryViewModel model, StockCard stockCard) { Long inventory = model.getLotListQuantityTotalAmount(); long stockOnHand = model.getStockOnHand(); StockMovementItem item = new StockMovementItem(); item.setSignature(model.getSignature()); item.setMovementDate(new Date()); item.setMovementQuantity(Math.abs(inventory - stockOnHand)); item.setStockOnHand(inventory); item.setStockCard(stockCard); if (inventory > stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_POSITIVE); item.setMovementType(MovementReasonManager.MovementType.POSITIVE_ADJUST); } else if (inventory < stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_NEGATIVE); item.setMovementType(MovementReasonManager.MovementType.NEGATIVE_ADJUST); } else { item.setReason(MovementReasonManager.INVENTORY); item.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); } item.populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(model.getExistingLotMovementViewModelList(), model.getNewLotMovementViewModelList()); return item; }  @Override Observable<List<InventoryViewModel>> loadInventory(); Observable<Object> saveDraftInventoryObservable(); Observable<Object> doInventory(final String sign); void updateAvgMonthlyConsumption(); int getCompleteCount(); }
PhysicalInventoryPresenter extends InventoryPresenter { protected StockMovementItem calculateAdjustment(InventoryViewModel model, StockCard stockCard) { Long inventory = model.getLotListQuantityTotalAmount(); long stockOnHand = model.getStockOnHand(); StockMovementItem item = new StockMovementItem(); item.setSignature(model.getSignature()); item.setMovementDate(new Date()); item.setMovementQuantity(Math.abs(inventory - stockOnHand)); item.setStockOnHand(inventory); item.setStockCard(stockCard); if (inventory > stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_POSITIVE); item.setMovementType(MovementReasonManager.MovementType.POSITIVE_ADJUST); } else if (inventory < stockOnHand) { item.setReason(MovementReasonManager.INVENTORY_NEGATIVE); item.setMovementType(MovementReasonManager.MovementType.NEGATIVE_ADJUST); } else { item.setReason(MovementReasonManager.INVENTORY); item.setMovementType(MovementReasonManager.MovementType.PHYSICAL_INVENTORY); } item.populateLotAndResetStockOnHandOfLotAccordingPhysicalAdjustment(model.getExistingLotMovementViewModelList(), model.getNewLotMovementViewModelList()); return item; }  @Override Observable<List<InventoryViewModel>> loadInventory(); Observable<Object> saveDraftInventoryObservable(); Observable<Object> doInventory(final String sign); void updateAvgMonthlyConsumption(); int getCompleteCount();  }