コード例 #1
0
  // 消耗
  @Test
  public void testUseUp() throws BusinessException, SQLException {
    StockActionDao.getStockAndDetail(mStaff, null, null);
    Department deptIn;
    List<Department> depts = DepartmentDao.getDepartments4Inventory(mStaff);
    if (depts.isEmpty()) {
      throw new BusinessException(DeptError.DEPT_NOT_EXIST);
    } else {
      deptIn = depts.get(2);
    }

    //		Map<Object, Object> params = new HashMap<Object, Object>();
    //		params.put(SQLUtil.SQL_PARAMS_EXTRA, " AND M.restaurant_id = " + mStaff.getRestaurantId());
    List<Material> materials = MaterialDao.getByCond(mStaff, null);
    if (materials.isEmpty()) {
      throw new BusinessException(MaterialError.SELECT_NOT_ADD);
    }

    InsertBuilder builder =
        StockAction.InsertBuilder.newDamage(mStaff.getRestaurantId())
            .setOperatorId((int) mStaff.getId())
            .setOperator(mStaff.getName())
            .setOriStockId("bbb111")
            .setOriStockDate(DateUtil.parseDate("2013-09-26 12:12:12"))
            .setComment("use_up")
            .setDeptIn(deptIn.getId())
            .setCateType(MaterialCate.Type.MATERIAL)
            .addDetail(new StockActionDetail(materials.get(0).getId(), 1.5f, 10))
            .addDetail(new StockActionDetail(materials.get(2).getId(), 1.5f, 8));

    testInsert(builder);
  }
コード例 #2
0
  // 退货
  @Test
  public void testStockOut() throws BusinessException, SQLException {
    Supplier supplier;
    List<Supplier> suppliers = SupplierDao.getSuppliers(mStaff, null, null);
    if (suppliers.isEmpty()) {
      throw new BusinessException(SupplierError.SUPPLIER_NOT_ADD);
    } else {
      supplier = suppliers.get(0);
    }
    Department deptOut;
    List<Department> depts = DepartmentDao.getDepartments4Inventory(mStaff);
    if (depts.isEmpty()) {
      throw new BusinessException(DeptError.DEPT_NOT_EXIST);
    } else {
      deptOut = depts.get(2);
    }

    //		Map<Object, Object> params = new HashMap<Object, Object>();
    //		params.put(SQLUtil.SQL_PARAMS_EXTRA, " AND M.restaurant_id = " + mStaff.getRestaurantId());
    List<Material> materials = MaterialDao.getByCond(mStaff, null);
    if (materials.isEmpty()) {
      throw new BusinessException(MaterialError.SELECT_NOT_ADD);
    }

    InsertBuilder builder =
        StockAction.InsertBuilder.newStockOut(
                mStaff.getRestaurantId(), DateUtil.parseDate("2013-09-28 12:12:12"), 300)
            .setOriStockId("asd12000")
            .setOperatorId((int) mStaff.getId())
            .setOperator(mStaff.getName())
            .setComment("good...")
            .setDeptOut(deptOut.getId())
            .setCateType(MaterialCate.Type.GOOD)
            .setSupplierId(supplier.getSupplierId())
            .addDetail(new StockActionDetail(materials.get(0).getId(), 1.5f, 12))
            .addDetail(new StockActionDetail(materials.get(2).getId(), 1.5f, 12));

    testInsert(builder);
  }