Ejemplo n.º 1
0
  /**
   * Initialize Validation
   *
   * @param engine validation engine
   * @param client client
   */
  public void initialize(ModelValidationEngine engine, MClient client) {
    // client = null for global validator
    if (client != null) {
      m_AD_Client_ID = client.getAD_Client_ID();
      if (log.isLoggable(Level.INFO)) log.info(client.toString());
    } else {
      if (log.isLoggable(Level.INFO)) log.info("Initializing global validator: " + this.toString());
    }

    //	We want to be informed when C_Order is created/changed
    engine.addModelChange(MOrder.Table_Name, this);
    //	We want to validate Order before preparing
    engine.addDocValidate(MOrder.Table_Name, this);
  } //	initialize
Ejemplo n.º 2
0
  @Override
  public void initialize(final ModelValidationEngine engine, final MClient client) {
    if (client != null) m_AD_Client_ID = client.getAD_Client_ID();

    engine.addModelChange(I_C_Order.Table_Name, this);
    engine.addDocValidate(I_C_Order.Table_Name, this);
  }
Ejemplo n.º 3
0
 @Override
 public void initialize(ModelValidationEngine engine, MClient client) {
   if (client != null) {
     ad_Client_ID = client.getAD_Client_ID();
   }
   engine.addModelChange(I_C_CountryArea_Assign.Table_Name, this);
 }
 public void initialize(ModelValidationEngine engine, MClient client) {
   if (client != null) {
     m_AD_Client_ID = client.getAD_Client_ID();
   }
   engine.addModelChange(MDDOrderLine.Table_Name, this);
   // engine.addDocValidate(MDDOrderLine.Table_Name, this);
   // engine.addDocValidate(MMovement.Table_Name, this);
 } //	initialize
Ejemplo n.º 5
0
 private void processCostDetail(I_M_CostDetail cd) {
   if (!cd.isProcessed()) {
     final Properties ctx = InterfaceWrapperHelper.getCtx(cd);
     final I_C_AcctSchema as = MAcctSchema.get(ctx, cd.getC_AcctSchema_ID());
     final I_AD_Client client = MClient.get(ctx, as.getAD_Client_ID());
     if (client.isCostImmediate()) {
       final MCostDetail cdPO = LegacyAdapters.convertToPO(cd);
       cdPO.process();
     }
   }
 }
Ejemplo n.º 6
0
  /**
   * Notify users
   *
   * @param users AD_User_ID list
   * @param subject email subject
   * @param message email message
   * @param attachments
   * @return how many email were sent
   */
  private int notifyUsers(
      Collection<Integer> users, String subject, String message, Collection<File> attachments) {
    int countMail = 0;
    for (int user_id : users) {
      MUser user = MUser.get(getCtx(), user_id);
      if (user.isNotificationEMail()) {
        if (m_client.sendEMailAttachments(user_id, subject, message, attachments)) {
          countMail++;
        }
      }

      if (user.isNotificationNote()) {
        Trx trx = null;
        try {
          trx = Trx.get(Trx.createTrxName("AP_NU"), true);
          // Notice
          int AD_Message_ID = 52244; /* TODO - Hardcoded message=notes */
          MNote note = new MNote(getCtx(), AD_Message_ID, user_id, trx.getTrxName());
          note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID());
          note.setTextMsg(message);
          note.saveEx();
          // Attachment
          MAttachment attachment =
              new MAttachment(getCtx(), MNote.Table_ID, note.getAD_Note_ID(), trx.getTrxName());
          for (File f : attachments) {
            attachment.addEntry(f);
          }
          attachment.setTextMsg(message);
          attachment.saveEx();
          countMail++;
          trx.commit();
        } catch (Throwable e) {
          if (trx != null) trx.rollback();
        } finally {
          if (trx != null) trx.close();
        }
      }
    }
    return countMail;
  }
Ejemplo n.º 7
0
  @Override
  public void initialize(final ModelValidationEngine engine, final MClient client) {
    adClientId = client == null ? -1 : client.getAD_Client_ID();

    engine.addModelValidator(new C_Invoice(), client);
    engine.addModelValidator(new C_BPartner(), client);
    engine.addModelValidator(C_Order.INSTANCE, client);
    engine.addModelValidator(C_OrderLine.INSTANCE, client);
    engine.addModelValidator(new C_OLCand(), client);

    engine.addModelValidator(EDI_Desadv.INSTANCE, client);
    engine.addModelValidator(EDI_DesadvLine.INSTANCE, client);
    engine.addModelValidator(new M_InOut(), client);
    engine.addModelValidator(M_InOutLine.INSTANCE, client);

    engine.addModelValidator(new C_Invoice_Candidate(), client);

    // task 08926
    // invoice candidate listener

    final IInvoiceCandidateListeners invoiceCandidateListeners =
        Services.get(IInvoiceCandidateListeners.class);
    invoiceCandidateListeners.addListener(EdiInvoiceCandidateListener.instance);

    // task 08926
    // invoice copy handler

    Services.get(ICopyHandlerBL.class)
        .registerCopyHandler(
            org.compiere.model.I_C_Invoice.class,
            new IQueryFilter<
                Pair<org.compiere.model.I_C_Invoice, org.compiere.model.I_C_Invoice>>() {
              @Override
              public boolean accept(
                  Pair<org.compiere.model.I_C_Invoice, org.compiere.model.I_C_Invoice> model) {
                return true;
              }
            },
            new EdiInvoiceCopyHandler());
  }
  public static boolean initWeb() {
    if (s_initOK) {
      // log.info(context.getServletContextName());
      return true;
    }

    // TODO:
    //  Load Environment Variables (serverApps/src/web/WEB-INF/web.xml)

    try {
      // CLogMgt.setLevel(Level.OFF);

      /* ADEMPIERE/COMPIERE */
      // s_initOK = Compiere.startup(false);
      s_initOK = Adempiere.startup(false);
    } catch (Exception ex) {
      log.log(Level.SEVERE, "startup", ex);
    }
    if (!s_initOK) return false;

    //	Logging now initiated
    // log.info(info.toString());

    //
    Properties ctx = new Properties();
    MClient client = MClient.get(ctx, 0);
    MSystem system = MSystem.get(ctx);

    // Env.setContext( ctx, "#AD_Language", "pl_PL" );
    // client.sendEMail(client.getRequestEMail(),
    //	"Server started: " + system.getName()
    //	,"ServerInfo: " + context.getServerInfo()
    // );

    return s_initOK;
  }
Ejemplo n.º 9
0
 /**
  * Alert Processor
  *
  * @param model model
  */
 public AlertProcessor(MAlertProcessor model) {
   super(model, 180); // 	3 minute delay
   m_model = model;
   m_client = MClient.get(model.getCtx(), model.getAD_Client_ID());
 } //	AlertProcessor
Ejemplo n.º 10
0
  /** Create Inventory Movements */
  private void createMovements() {
    int noMoves = 0;
    String info = "";
    //
    MClient client = null;
    MMovement move = null;
    int M_Warehouse_ID = 0;
    int M_WarehouseSource_ID = 0;
    MWarehouse whSource = null;
    MWarehouse wh = null;
    X_T_Replenish[] replenishs = getReplenish("M_WarehouseSource_ID IS NOT NULL");
    for (int i = 0; i < replenishs.length; i++) {
      X_T_Replenish replenish = replenishs[i];
      if (whSource == null
          || whSource.getM_WarehouseSource_ID() != replenish.getM_WarehouseSource_ID())
        whSource = MWarehouse.get(getCtx(), replenish.getM_WarehouseSource_ID());
      if (wh == null || wh.getM_Warehouse_ID() != replenish.getM_Warehouse_ID())
        wh = MWarehouse.get(getCtx(), replenish.getM_Warehouse_ID());
      if (client == null || client.getAD_Client_ID() != whSource.getAD_Client_ID())
        client = MClient.get(getCtx(), whSource.getAD_Client_ID());
      //
      if (move == null
          || M_WarehouseSource_ID != replenish.getM_WarehouseSource_ID()
          || M_Warehouse_ID != replenish.getM_Warehouse_ID()) {
        M_WarehouseSource_ID = replenish.getM_WarehouseSource_ID();
        M_Warehouse_ID = replenish.getM_Warehouse_ID();

        move = new MMovement(getCtx(), 0, get_TrxName());
        move.setC_DocType_ID(p_C_DocType_ID);
        move.setDescription(
            Msg.getMsg(getCtx(), "Replenishment")
                + ": "
                + whSource.getName()
                + "->"
                + wh.getName());
        //	Set Org
        move.setAD_Org_ID(whSource.getAD_Org_ID());
        if (!move.save()) return;
        log.debug(move.toString());
        noMoves++;
        info += " - " + move.getDocumentNo();
      }
      //	To
      int M_LocatorTo_ID = wh.getDefaultLocator().getM_Locator_ID();
      //	From: Look-up Storage
      MProduct product = MProduct.get(getCtx(), replenish.getM_Product_ID());
      String MMPolicy = product.getMMPolicy();
      MStorage[] storages =
          MStorage.getWarehouse(
              getCtx(),
              whSource.getM_Warehouse_ID(),
              replenish.getM_Product_ID(),
              0,
              0,
              true,
              null,
              MClient.MMPOLICY_FiFo.equals(MMPolicy),
              get_TrxName());
      //
      BigDecimal target = replenish.getQtyToOrder();
      for (int j = 0; j < storages.length; j++) {
        MStorage storage = storages[j];
        if (storage.getQtyOnHand().signum() <= 0) continue;
        BigDecimal moveQty = target;
        if (storage.getQtyOnHand().compareTo(moveQty) < 0) moveQty = storage.getQtyOnHand();
        //
        MMovementLine line = new MMovementLine(move);
        line.setM_Product_ID(replenish.getM_Product_ID());
        line.setMovementQty(moveQty);
        if (replenish.getQtyToOrder().compareTo(moveQty) != 0)
          line.setDescription("Total: " + replenish.getQtyToOrder());
        line.setM_Locator_ID(storage.getM_Locator_ID()); // 	from
        line.setM_AttributeSetInstance_ID(storage.getM_AttributeSetInstance_ID());
        line.setM_LocatorTo_ID(M_LocatorTo_ID); // 	to
        line.setM_AttributeSetInstanceTo_ID(storage.getM_AttributeSetInstance_ID());
        line.save();
        //
        target = target.subtract(moveQty);
        if (target.signum() == 0) break;
      }
    }
    if (replenishs.length == 0) {
      m_info = "No Source Warehouse";
      log.warn(m_info);
    } else {
      m_info = "#" + noMoves + info;
      log.info(m_info);
    }
  } //	createRequisition