コード例 #1
0
  /**
   * get Material transaction for Reversal Document
   *
   * @param trx MTransaction
   * @return
   */
  public static MTransaction getByDocumentLine(MTransaction trx) {
    IDocumentLine reversal = trx.getDocumentLine().getReversalDocumentLine();
    List<Object> parameters = new ArrayList();
    String columnName = reversal.get_TableName() + "_ID";
    StringBuffer whereClause = new StringBuffer(I_M_Transaction.COLUMNNAME_M_Product_ID);
    whereClause.append("=? AND ");
    parameters.add(reversal.getM_Product_ID());
    whereClause.append(columnName).append("=? AND ");
    parameters.add(reversal.get_ID());

    if (trx.getM_AttributeSetInstance_ID() > 0) {
      whereClause.append(I_M_Transaction.COLUMNNAME_M_AttributeSetInstance_ID).append("=? AND ");
      parameters.add(trx.getM_AttributeSetInstance_ID());
    }

    whereClause.append(I_M_Transaction.COLUMNNAME_MovementType).append("=? AND ");
    if (MTransaction.MOVEMENTTYPE_InventoryIn.equals(trx.getMovementType()))
      parameters.add(MTransaction.MOVEMENTTYPE_InventoryOut);
    else if (MTransaction.MOVEMENTTYPE_InventoryOut.equals(trx.getMovementType()))
      parameters.add(MTransaction.MOVEMENTTYPE_InventoryIn);
    else parameters.add(trx.getMovementType());

    whereClause.append(I_M_Transaction.COLUMNNAME_M_Transaction_ID).append("<>?");
    parameters.add(trx.getM_Transaction_ID());
    return new Query(trx.getCtx(), Table_Name, whereClause.toString(), trx.get_TrxName())
        .setClient_ID()
        .setParameters(parameters)
        .first();
  }
コード例 #2
0
  /**
   * get the Material Transaction after Date Account
   *
   * @param ctx Context
   * @param M_Product_ID Product ID
   * @param dateAcct Date Account
   * @param trxName Transaction name
   * @return List with the MTransaction after date account
   */
  public static List<MTransaction> getAfterDateAcct(
      Properties ctx, int M_Product_ID, Timestamp dateAcct, String trxName) {
    ArrayList<MTransaction> list = new ArrayList();
    final String whereClause = I_M_Transaction.COLUMNNAME_M_Product_ID + "=?";
    List<MTransaction> trxs =
        new Query(ctx, Table_Name, whereClause, trxName)
            .setClient_ID()
            .setParameters(M_Product_ID)
            .list();

    for (MTransaction trx : trxs) {
      IDocumentLine model = trx.getDocumentLine();
      if (model.getDateAcct().compareTo(dateAcct) > 0) {
        list.add(trx);
      }
    }
    return list;
  }