@Test public void shouldQueryStockMovementsByMovementDate() throws Exception { StockCard stockCard = saveStockCardWithOneMovement(stockRepository, productRepository); createMovementItem(MovementReasonManager.MovementType.PHYSICAL_INVENTORY, 1000, stockCard, DateUtil.parseString("2015-12-12", DateUtil.DB_DATE_FORMAT), DateUtil.parseString("2015-12-11", DateUtil.DB_DATE_FORMAT), false); createMovementItem(MovementReasonManager.MovementType.PHYSICAL_INVENTORY, 1001, stockCard, DateUtil.parseString("2015-12-13", DateUtil.DB_DATE_FORMAT), DateUtil.parseString("2015-12-12", DateUtil.DB_DATE_FORMAT), false); createMovementItem(MovementReasonManager.MovementType.PHYSICAL_INVENTORY, 1002, stockCard, DateUtil.parseString("2015-12-14", DateUtil.DB_DATE_FORMAT), DateUtil.parseString("2015-12-13", DateUtil.DB_DATE_FORMAT), false); List<StockMovementItem> stockMovementItems = stockMovementRepository.queryStockMovementsByMovementDate(stockCard.getId(), DateUtil.parseString("2015-12-11", DateUtil.DB_DATE_FORMAT), DateUtil.parseString("2015-12-12", DateUtil.DB_DATE_FORMAT)); assertEquals(2, stockMovementItems.size()); assertEquals(stockCard.getStockMovementItemsWrapper().get(1), stockMovementItems.get(0)); assertEquals(stockCard.getStockMovementItemsWrapper().get(2), stockMovementItems.get(1)); }
public List<StockMovementItem> queryStockMovementsByMovementDate(final long stockCardId, final Date startDate, final Date endDate) throws LMISException { return dbUtil.withDao(StockMovementItem.class, dao -> dao.queryBuilder() .orderBy("movementDate", true) .orderBy("createdTime", true) .where() .eq("stockCard_id", stockCardId) .and().ge("movementDate", startDate) .and().le("movementDate", endDate) .query()); }
StockMovementRepository { public List<StockMovementItem> queryStockMovementsByMovementDate(final long stockCardId, final Date startDate, final Date endDate) throws LMISException { return dbUtil.withDao(StockMovementItem.class, dao -> dao.queryBuilder() .orderBy("movementDate", true) .orderBy("createdTime", true) .where() .eq("stockCard_id", stockCardId) .and().ge("movementDate", startDate) .and().le("movementDate", endDate) .query()); } }
StockMovementRepository { public List<StockMovementItem> queryStockMovementsByMovementDate(final long stockCardId, final Date startDate, final Date endDate) throws LMISException { return dbUtil.withDao(StockMovementItem.class, dao -> dao.queryBuilder() .orderBy("movementDate", true) .orderBy("createdTime", true) .where() .eq("stockCard_id", stockCardId) .and().ge("movementDate", startDate) .and().le("movementDate", endDate) .query()); } @Inject  StockMovementRepository(Context context); }
StockMovementRepository { public List<StockMovementItem> queryStockMovementsByMovementDate(final long stockCardId, final Date startDate, final Date endDate) throws LMISException { return dbUtil.withDao(StockMovementItem.class, dao -> dao.queryBuilder() .orderBy("movementDate", true) .orderBy("createdTime", true) .where() .eq("stockCard_id", stockCardId) .and().ge("movementDate", startDate) .and().le("movementDate", endDate) .query()); } @Inject  StockMovementRepository(Context context); List<StockMovementItem> listUnSynced(); void batchCreateStockMovementItemAndLotItems(final StockMovementItem stockMovementItem); void batchCreateOrUpdateStockMovementsAndLotMovements(final List<StockMovementItem> stockMovementItems); StockMovementItem getFirstStockMovement(); List<String> queryStockMovementDatesByProgram(final String programCode); Date queryEarliestStockMovementDateByProgram(final String programCode); StockMovementItem queryFirstStockMovementByStockCardId(final long stockCardId); List<StockMovementItem> queryStockMovementHistory(final long stockCardId, final long startIndex, final long maxRows); List<StockMovementItem> queryStockItemsByCreatedDate(final long stockCardId, final Date periodBeginDate, final Date periodEndDate); List<StockMovementItem> queryStockMovementsByMovementDate(final long stockCardId, final Date startDate, final Date endDate); List<StockMovementItem> listLastFiveStockMovements(final long stockCardId); List<StockMovementItem> listLastTwoStockMovements(final long stockCardId); List<StockMovementItem> queryMovementByStockCardId(final long stockCardId); List<StockMovementItem> queryEachStockCardNewestMovement(); void deleteStockMovementItems(final StockCard stockCard); }
StockMovementRepository { public List<StockMovementItem> queryStockMovementsByMovementDate(final long stockCardId, final Date startDate, final Date endDate) throws LMISException { return dbUtil.withDao(StockMovementItem.class, dao -> dao.queryBuilder() .orderBy("movementDate", true) .orderBy("createdTime", true) .where() .eq("stockCard_id", stockCardId) .and().ge("movementDate", startDate) .and().le("movementDate", endDate) .query()); } @Inject  StockMovementRepository(Context context); List<StockMovementItem> listUnSynced(); void batchCreateStockMovementItemAndLotItems(final StockMovementItem stockMovementItem); void batchCreateOrUpdateStockMovementsAndLotMovements(final List<StockMovementItem> stockMovementItems); StockMovementItem getFirstStockMovement(); List<String> queryStockMovementDatesByProgram(final String programCode); Date queryEarliestStockMovementDateByProgram(final String programCode); StockMovementItem queryFirstStockMovementByStockCardId(final long stockCardId); List<StockMovementItem> queryStockMovementHistory(final long stockCardId, final long startIndex, final long maxRows); List<StockMovementItem> queryStockItemsByCreatedDate(final long stockCardId, final Date periodBeginDate, final Date periodEndDate); List<StockMovementItem> queryStockMovementsByMovementDate(final long stockCardId, final Date startDate, final Date endDate); List<StockMovementItem> listLastFiveStockMovements(final long stockCardId); List<StockMovementItem> listLastTwoStockMovements(final long stockCardId); List<StockMovementItem> queryMovementByStockCardId(final long stockCardId); List<StockMovementItem> queryEachStockCardNewestMovement(); void deleteStockMovementItems(final StockCard stockCard);  }