Exemplo n.º 1
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();
     }
   }
 }
  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;
  }
Exemplo n.º 3
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
Exemplo n.º 4
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