Exemplo n.º 1
0
  @Override
  public String modelChange(final PO po, final int type) throws Exception {
    if (type == TYPE_BEFORE_CHANGE) {
      final I_C_Order order = InterfaceWrapperHelper.create(po, I_C_Order.class);

      if (po.is_ValueChanged(I_C_Invoice_Candidate.COLUMNNAME_DateOrdered)) {
        final IOrderPA orderPA = Services.get(IOrderPA.class);
        final IInvoiceCandDAO invoiceCandDB = Services.get(IInvoiceCandDAO.class);

        for (final I_C_OrderLine ol : orderPA.retrieveOrderLines(order, I_C_OrderLine.class)) {
          for (final I_C_Invoice_Candidate icOfOl : invoiceCandDB.retrieveReferencing(ol)) {
            if (icOfOl.isToClear()) {
              // If the column was updatable, we would have to
              // *check if new and old term are the same
              // *check if ICAs need update, creation or deletion and do it;
              // *check which dataEntries' ActualQty needs update and make sure that they are not
              // yet
              // completed
              // *check is isToClear needs update;
              throw new AdempiereException(
                  Env.getAD_Language(po.getCtx()),
                  MSG_ORDER_DATE_ORDERED_CHANGE_FORBIDDEN_1P,
                  new Object[] {ol.getLine()});
            }
          }
        }
      }
    }
    return null;
  }
Exemplo n.º 2
0
  // Note: this code used to be located in
  // /sw01_swat_it/src/java/org/adempiere/order/subscription/modelvalidator/OrderValidator.java
  @Override
  public String docValidate(final PO po, final int timing) {
    if (timing != TIMING_AFTER_COMPLETE && timing != TIMING_AFTER_REACTIVATE) {
      return null;
    }

    final String trxName = po.get_TrxName();
    final I_C_Order order = InterfaceWrapperHelper.create(po, I_C_Order.class);

    final IOrderPA orderPA = Services.get(IOrderPA.class);

    for (final I_C_OrderLine ol : orderPA.retrieveOrderLines(order, I_C_OrderLine.class)) {
      if (ol.getC_Flatrate_Conditions_ID() <= 0) {
        logger.debug("Order line " + ol + " has no subscription");
        continue;
      }
      if (timing == TIMING_AFTER_COMPLETE) {
        handleOrderLineComplete(order, ol, trxName);

      } else if (timing == TIMING_AFTER_REACTIVATE) {
        handleOrderLineReactivate(ol, trxName);
      }
    }
    return null;
  }