示例#1
0
  /**
   * @param ctx
   * @param whereClause
   * @param trxName
   * @return true if records selected by given <code>whereClause</code> are subject of this index
   */
  public boolean isWhereClauseMatched(
      final Properties ctx, final String whereClause, final String trxName) {
    Check.assume(!Check.isEmpty(whereClause, true), "whereClause parameter not empty");

    // If this index does not have an where clause, it means all records are matched, so there is no
    // need to do an actual query
    if (Check.isEmpty(getWhereClause(), true)) {
      return true;
    }

    final StringBuilder whereClauseFinal =
        new StringBuilder()
            .append("(")
            .append(getWhereClause())
            .append(")")
            .append(" AND ")
            .append("(")
            .append(whereClause)
            .append(")");

    final String tableName = getTableName();
    final boolean matched = new Query(ctx, tableName, whereClauseFinal.toString(), trxName).match();

    return matched;
  }
示例#2
0
  public MRPDemandsPool(
      final IMRPContext mrpContext,
      final IMRPNotesCollector mrpNotesCollector,
      final IMRPDemand mrpDemand) {
    super();

    Check.assumeNotNull(mrpContext, "mrpContext not null");
    this._mrpContext = mrpContext;

    Check.assumeNotNull(mrpNotesCollector, "mrpNotesCollector not null");
    this._mrpNotesCollector = mrpNotesCollector;

    Check.assumeNotNull(mrpDemand, LiberoException.class, "mrpDemand not null");

    //
    // Create MRP Demand & Qty that we will need to allocated
    BigDecimal qtyGrossReq = BigDecimal.ZERO;
    final List<IMutableMRPRecordAndQty> mrpDemandAndQtys = new ArrayList<IMutableMRPRecordAndQty>();
    final MRPYield yield = mrpDemand.getYield();
    for (final I_PP_MRP mrpDemandRecord : mrpDemand.getMRPDemandRecords()) {
      final BigDecimal mrpDemandQty = mrpDemandRecord.getQty();
      final BigDecimal mrpDemandQtyWithYield = yield.calculateQtyWithYield(mrpDemandQty);
      final MRPRecordAndQty mrpDemandAndQty =
          new MRPRecordAndQty(mrpDemandRecord, mrpDemandQtyWithYield);

      qtyGrossReq = qtyGrossReq.add(mrpDemandQtyWithYield);
      mrpDemandAndQtys.add(mrpDemandAndQty);
    }

    this.demandDateStartSchedule = mrpDemand.getDateStartSchedule();

    this.qtyNetReqRemaining = qtyGrossReq;
    this.mrpDemandsToAllocate = mrpDemandAndQtys;
  }
  @Override
  public void deleteHUAssignments(
      final Object model, final Collection<I_M_HU> husToUnAssign, final String trxName) {
    Check.assumeNotNull(model, "model not null");
    Check.assumeNotNull(husToUnAssign, "husToUnAssign not null");

    final Properties ctx = InterfaceWrapperHelper.getCtx(model);
    final int adTableId = InterfaceWrapperHelper.getModelTableId(model);
    final int recordId = InterfaceWrapperHelper.getId(model);

    final Set<Integer> huIds = new HashSet<Integer>(husToUnAssign.size());
    for (final I_M_HU hu : husToUnAssign) {
      huIds.add(hu.getM_HU_ID());
    }

    if (huIds.isEmpty()) {
      return;
    }

    final IQueryBuilder<I_M_HU_Assignment> queryBuilder =
        Services.get(IQueryBL.class).createQueryBuilder(I_M_HU_Assignment.class, ctx, trxName);

    //
    // Note that here we don't want to skip anything; we want the HUAssignmentBL to do it's job, so
    // we clean everything up
    queryBuilder
        .addEqualsFilter(I_M_HU_Assignment.COLUMN_AD_Table_ID, adTableId)
        .addEqualsFilter(I_M_HU_Assignment.COLUMN_Record_ID, recordId)
        .addInArrayFilter(I_M_HU_Assignment.COLUMN_M_HU_ID, huIds)
        .create()
        .delete();
  }
示例#4
0
  /**
   * Gets {@link HUItemExpectation} for given <code>piItem</code>.
   *
   * @param piItem
   * @return
   * @return {@link HUItemExpectation}; never return null
   */
  public HUItemExpectation<HUExpectation<ParentExpectationType>> huItemExpectation(
      final I_M_HU_PI_Item piItem) {
    Check.assumeNotNull(piItem, "piItem not null");
    Check.assumeNotNull(huItemExpectations, "huItemExpectations not null");

    final List<HUItemExpectation<HUExpectation<ParentExpectationType>>> result = new ArrayList<>();
    for (final HUItemExpectation<HUExpectation<ParentExpectationType>> huItemExpectation :
        huItemExpectations) {
      final I_M_HU_PI_Item current_piItem = huItemExpectation.getM_HU_PI_Item();
      if (current_piItem == null) {
        continue;
      }

      if (current_piItem.getM_HU_PI_Item_ID() != piItem.getM_HU_PI_Item_ID()) {
        continue;
      }

      result.add(huItemExpectation);
    }

    if (result.isEmpty()) {
      throw new IllegalArgumentException("No HU Item Expectation found for " + piItem);
    } else if (result.size() > 1) {
      throw new IllegalArgumentException(
          "More then one HU Item Expectation found for " + piItem + "\n\n" + result);
    }

    return result.get(0);
  }
  public CalloutMethodPointcut(
      final Class<?> modelClass,
      final Method method,
      final String[] columnNames,
      final boolean paramCalloutFieldRequired,
      final boolean skipIfCopying) {
    super();

    Check.assumeNotNull(modelClass, "modelClass not null");
    this.modelClass = modelClass;

    Check.assumeNotNull(method, "method not null");
    this.method = method;

    Check.assumeNotNull(columnNames, "columnNames not null");
    Check.assume(columnNames.length > 0, "columnNames not empty");

    this.columnNames = new HashSet<String>(columnNames.length);
    for (final String columnName : columnNames) {
      Check.assumeNotNull(columnName, "columnName not null");
      this.columnNames.add(columnName);
    }

    this.paramCalloutFieldRequired = paramCalloutFieldRequired;

    this.skipIfCopying = skipIfCopying;
  }
示例#6
0
  private BigDecimal calculateQtyInvoicedInPriceUOM(final I_C_InvoiceLine invoiceLine) {
    Check.assumeNotNull(invoiceLine, "invoiceLine not null");

    final BigDecimal qty = invoiceLine.getQtyInvoiced();

    Check.assumeNotNull(qty, "qty not null");

    final I_C_UOM priceUOM = invoiceLine.getPrice_UOM();
    if (invoiceLine.getPrice_UOM_ID() <= 0) {
      return qty;
    }
    if (invoiceLine.getM_Product_ID() <= 0) {
      return qty;
    }

    final I_M_Product product = invoiceLine.getM_Product();
    if (product.getC_UOM_ID() <= 0) {
      return qty;
    }

    final Properties ctx = InterfaceWrapperHelper.getCtx(invoiceLine);
    final BigDecimal qtyInPriceUOM =
        Services.get(IUOMConversionBL.class).convertFromProductUOM(ctx, product, priceUOM, qty);

    return qtyInPriceUOM;
  }
示例#7
0
  public PlainPackingMaterialDocumentLineSource(
      final I_M_HU_PackingMaterial packingMaterial, final BigDecimal qty) {
    super();
    Check.assumeNotNull(packingMaterial, "packingMaterial not null");
    packingMaterials = Collections.singletonList(packingMaterial);

    Check.assumeNotNull(qty, "qty not null");
    this.qty = qty;
  }
  public MonthDayCalendarIncrementor(final int monthsAmount, final int dayOfMonth) {
    super();

    Check.assume(monthsAmount >= 0, "monthsAmount({}) >= 0", monthsAmount);
    this.monthsAmount = monthsAmount;

    Check.assume(dayOfMonth > 0, "dayOfMonth({}) > 0", dayOfMonth);
    this.dayOfMonth = dayOfMonth;
  }
  private final SyncProduct createSyncProductNoCache(final I_PMM_Product pmmProduct) {
    final String product_uuid = SyncUUIDs.toUUIDString(pmmProduct);

    final I_M_Product product = pmmProduct.getM_Product();

    String productName = pmmProduct.getProductName();
    // Fallback to M_Product.Name (shall not happen)
    if (Check.isEmpty(productName, true)) {
      productName = product == null ? null : product.getName();
    }

    final SyncProduct syncProduct = new SyncProduct();

    final boolean valid =
        pmmProduct.isActive()
            && pmmProduct.getM_Warehouse_ID() > 0
            && pmmProduct.getM_Product_ID() > 0
            && pmmProduct.getM_HU_PI_Item_Product_ID() > 0;

    syncProduct.setUuid(product_uuid);
    syncProduct.setName(productName);
    syncProduct.setPackingInfo(pmmProduct.getPackDescription());

    syncProduct.setShared(
        pmmProduct.getC_BPartner_ID()
            <= 0); // share, unless it is assigned to a particular BPartner
    syncProduct.setDeleted(!valid);

    //
    // Translations
    {
      final Map<String, String> syncProductNamesTrl = syncProduct.getNamesTrl();
      final IModelTranslationMap productTrls =
          InterfaceWrapperHelper.getModelTranslationMap(product);
      final PMMProductNameBuilder productNameTrlBuilder =
          PMMProductNameBuilder.newBuilder().setPMM_Product(pmmProduct);
      for (final IModelTranslation productLanguageTrl : productTrls.getAllTranslations().values()) {
        final String adLanguage = productLanguageTrl.getAD_Language();

        final String productNamePartTrl =
            productLanguageTrl.getTranslation(I_M_Product.COLUMNNAME_Name);
        if (Check.isEmpty(productNamePartTrl, true)) {
          continue;
        }

        final String productNameTrl =
            productNameTrlBuilder.setProductNamePartIfUsingMProduct(productNamePartTrl).build();
        if (Check.isEmpty(productNameTrl, true)) {
          continue;
        }

        syncProductNamesTrl.put(adLanguage, productNameTrl.trim());
      }
    }

    return syncProduct;
  }
  /* package */ String getComment_ToUse() {
    if (Check.isEmpty(_comment, true)) {
      return "";
    }

    String commentTrl = msgBL.parseTranslation(getCtx(), _comment);
    if (Check.isEmpty(commentTrl, true)) {
      commentTrl = _comment;
    }
    return commentTrl;
  }
示例#11
0
  private Info_Column createColumnInfo(final I_AD_InfoColumn field) {
    final Properties ctx = getCtx();

    String columnName = field.getAD_Element().getColumnName();
    String name = msgBL.translate(ctx, columnName);
    final int displayType = field.getAD_Reference_ID();
    Class<?> colClass = DisplayType.getClass(displayType, true);
    String colSQL =
        Check.isEmpty(field.getDisplayField(), true)
            ? field.getSelectClause()
            : field.getDisplayField();
    String idColSQL = null;

    if (DisplayType.isLookup(field.getAD_Reference_ID())) {
      colClass = KeyNamePair.class;
      idColSQL = field.getSelectClause();
      final String displayColumnSQL =
          MLookupFactory.getLookupEmbed(
              ctx,
              colSQL, // BaseColumn
              null, // BaseTable
              field.getAD_Reference_ID(),
              field.getAD_Reference_Value_ID());
      if (!Check.isEmpty(displayColumnSQL, true)) {
        colSQL = "(" + displayColumnSQL + ")";
      }
    }
    if (DisplayType.List == field.getAD_Reference_ID()) {
      columnName = field.getName();
    }
    if (columnName.endsWith("_ID")
        && DisplayType.ID == field.getAD_Reference_ID()) // should be only ID, 02883
    {
      name = " ";
      colClass = IDColumn.class;
    }

    final Info_Column ic = new Info_Column(name, columnName, colClass);
    ic.setDisplayType(displayType);
    ic.setIDcolSQL(idColSQL);
    ic.setColSQL(colSQL);
    ic.setColumnName(columnName);

    //
    // Check/Load Column Controller
    final IInfoColumnController columnController = getInfoColumnControllerOrNull(field);
    if (columnController != null) {
      ic.setColumnController(columnController);
      columnController.customize(this, ic);
    }

    return ic;
  }
示例#12
0
 public void createBeforeChangeFunction(MIndexTable index) throws SQLException {
   final String ddlFunction = index.getBeforeChangeCodeFunctionDDL();
   if (Check.isEmpty(ddlFunction, true)) return;
   executeDDL(ddlFunction, index.get_TrxName());
   //
   final String ddlTrigger = index.getBeforeChangeCodeTriggerDDL();
   if (Check.isEmpty(ddlTrigger, true)) return;
   if (existsFunction(index.getDBFunctionName()))
     executeDDL(
         "DROP TRIGGER IF EXISTS " + index.getDBTriggerName() + " ON " + index.getTableName(),
         index.get_TrxName());
   executeDDL(ddlTrigger, index.get_TrxName());
 }
示例#13
0
  public IQueryBuilder<I_M_Material_Tracking> createQueryBuilder(
      final IMaterialTrackingQuery queryVO) {
    Check.assumeNotNull(queryVO, "queryVO not null");

    final IQueryBuilder<I_M_Material_Tracking> queryBuilder =
        queryBL
            .createQueryBuilder(I_M_Material_Tracking.class)
            .setContext(getCtx(), getTrxName())
            .addOnlyContextClient()
            .addOnlyActiveRecordsFilter();

    final IQueryOrderByBuilder<I_M_Material_Tracking> orderBy = queryBuilder.orderBy();

    //
    // M_Product_ID
    final int productId = queryVO.getM_Product_ID();
    Check.assume(productId > 0, "productId > 0");
    queryBuilder.addEqualsFilter(I_M_Material_Tracking.COLUMN_M_Product_ID, productId);

    //
    // C_BPartner_ID
    final int bpartnerId = queryVO.getC_BPartner_ID();
    queryBuilder.addInArrayFilter(I_M_Material_Tracking.COLUMN_C_BPartner_ID, null, bpartnerId);
    orderBy.addColumn(I_M_Material_Tracking.COLUMN_C_BPartner_ID, Direction.Descending, Nulls.Last);

    // TODO: ValidFrom, ValidTo

    //
    // Processed
    final Boolean processed = queryVO.getProcessed();
    if (processed != null) {
      queryBuilder.addEqualsFilter(I_M_Material_Tracking.COLUMN_Processed, processed);
    }

    //
    // Linked documents
    final List<?> linkedModels = queryVO.getWithLinkedDocuments();
    if (linkedModels != null && !linkedModels.isEmpty()) {
      final IQuery<I_M_Material_Tracking_Ref> materialTrackingRefQuery =
          createMaterialTrackingRefQueryForModels(linkedModels);
      if (materialTrackingRefQuery != null) {
        queryBuilder.addInSubQueryFilter(
            I_M_Material_Tracking.COLUMN_M_Material_Tracking_ID,
            I_M_Material_Tracking_Ref.COLUMN_M_Material_Tracking_ID,
            materialTrackingRefQuery);
      }
      // TODO
    }

    return queryBuilder;
  }
  public CoProductReceiptHUProducer(final I_PP_Cost_Collector cc) {
    super(cc);

    Check.assumeNotNull(cc, "cc not null");
    _costCollector = cc;

    Check.assume(
        cc.getPP_Order_BOMLine_ID() > 0,
        "Order BOM Line shall be set to cost collector when receiving co/bu products: {}",
        cc);
    _ppOrderBOMLine =
        InterfaceWrapperHelper.create(cc.getPP_Order_BOMLine(), I_PP_Order_BOMLine.class);
    Check.assumeNotNull(_ppOrderBOMLine, "ppOrderBOMLine not null");
  }
示例#15
0
  public static final LockOwner newOwner(
      final String ownerNamePrefix, final Object ownerNameUniquePart) {
    Check.assumeNotNull(ownerNameUniquePart, "ownerNameUniquePart not null");

    final String ownerNamePrefixToUse;
    if (Check.isEmpty(ownerNamePrefix, true)) {
      ownerNamePrefixToUse = "Unknown";
    } else {
      ownerNamePrefixToUse = ownerNamePrefix.trim();
    }

    final String ownerName = ownerNamePrefixToUse + "_" + ownerNameUniquePart;
    return new LockOwner(ownerName, OwnerType.RealOwner);
  }
示例#16
0
  public MutableAttributeSplitRequest(
      final IAttributeStorage parentAttributeStorage,
      final List<IAttributeStorage> attributeStorages,
      final org.compiere.model.I_M_Attribute attribute) {
    super();
    Check.assumeNotNull(parentAttributeStorage, "parentAttributeStorage not null");
    this.parentAttributeStorage = parentAttributeStorage;

    Check.assumeNotNull(attributeStorages, "attributeStorages not null");
    this.attributeStorages = Collections.unmodifiableList(attributeStorages);

    Check.assumeNotNull(attribute, "attribute not null");
    this.attribute = InterfaceWrapperHelper.create(attribute, I_M_Attribute.class);
  }
示例#17
0
  @Override
  public void linkBankStatementLine(
      final I_C_PaySelectionLine psl,
      final org.compiere.model.I_C_BankStatementLine bankStatementLine,
      final de.metas.banking.model.I_C_BankStatementLine_Ref bankStatementLineRef) {
    Check.assumeNotNull(bankStatementLine, "bankStatementLine not null");
    Check.assume(
        bankStatementLine.getC_BankStatementLine_ID() > 0,
        "bankStatementLine is saved: {}",
        bankStatementLine);

    psl.setC_BankStatementLine(bankStatementLine);
    psl.setC_BankStatementLine_Ref(bankStatementLineRef);
    InterfaceWrapperHelper.save(psl);
  }
示例#18
0
  @Override
  public void onTableNameRename(final I_AD_Table table) {
    Check.assumeNotNull(table, "table not null");
    final I_AD_Table tableOld = InterfaceWrapperHelper.createOld(table, I_AD_Table.class);
    final String tableNameOld = tableOld.getTableName();
    final String tableNameNew = table.getTableName();

    // Do nothing if the table name was not actually changed
    if (Check.equals(tableNameOld, tableNameNew)) {
      return;
    }

    final Properties ctx = InterfaceWrapperHelper.getCtx(table);
    Services.get(ISequenceDAO.class).renameTableSequence(ctx, tableNameOld, tableNameNew);
  }
  @Override
  public <T extends IAttributeStrategy> T retrieveStrategy(
      final Properties ctx, final int adJavaClassId, final Class<T> strategyClass) {
    final I_AD_JavaClass javaClass =
        Services.get(IJavaClassDAO.class).retriveJavaClassOrNull(ctx, adJavaClassId);

    if (javaClass == null) {
      return getDefaultStrategy(strategyClass);
    }

    final String classname = javaClass.getClassname();
    if (Check.isEmpty(classname, true)) {
      throw new AdempiereException("Java Class name is empty for " + javaClass);
    }

    //
    // Check if we have defined a static strategy
    @SuppressWarnings("unchecked")
    final T strategyInstance = (T) classname2strategy.get(classname);
    if (strategyInstance != null) {
      return strategyInstance;
    }

    return Util.getInstance(strategyClass, classname);
  }
示例#20
0
  /**
   * Get and calculate Product Pricing
   *
   * @param M_PriceList_ID id
   * @param M_PriceList_Version_ID
   * @return product pricing
   */
  private MProductPricing getProductPricing(int M_PriceList_ID, int M_PriceList_Version_ID) {
    final I_M_PriceList_Version plv =
        InterfaceWrapperHelper.create(
            getCtx(), M_PriceList_Version_ID, I_M_PriceList_Version.class, get_TrxName());
    if (M_PriceList_Version_ID > 0) {
      // If we have a pricelist version, make sure it belongs to the pricelist
      Check.assume(
          M_PriceList_ID == plv.getM_PriceList_ID(),
          Msg.getMsg(getCtx(), MSG_PriceListVersionInvalid));
    }

    m_productPrice =
        new MProductPricing(getM_Product_ID(), getC_BPartner_ID(), getQtyOrdered(), m_IsSOTrx);

    m_productPrice.setReferencedObject(
        this); // 03152: setting the 'ol' to allow the subscription system to compute the right
               // price
    m_productPrice.setPriceDate(
        getDatePromised()); // important: need to use the data when the service will be provided, so
                            // we make sure that we get the right PLV
    m_productPrice.setM_PriceList_ID(M_PriceList_ID);
    m_productPrice.setPriceDate(getDateOrdered());
    m_productPrice.setM_PriceList_Version_ID(M_PriceList_Version_ID);
    //
    m_productPrice.calculatePrice();
    return m_productPrice;
  } // getProductPrice
  /* package */ String getParametersAsString() {
    if (_parameters == null || _parameters.isEmpty()) {
      return "";
    }

    final StringBuilder parametersStr = new StringBuilder();
    final Properties ctx = getCtx();
    for (final Map.Entry<String, Object> param : _parameters.entrySet()) {
      final String parameterName = param.getKey();
      String parameterDisplayName = messagesBL.translate(ctx, parameterName);
      if (Check.isEmpty(parameterDisplayName, true)) {
        parameterDisplayName = parameterName;
      }
      final Object parameterValue = param.getValue();
      final String parameterValueStr = toParameterValueString(parameterValue);

      //
      if (parametersStr.length() > 0) {
        parametersStr.append("\n");
      }
      parametersStr.append(parameterDisplayName).append(": ").append(parameterValueStr);
    }

    return parametersStr.toString();
  }
  private List<SyncProductSupply> createPlannedSyncProductSupplies(
      final I_C_RfQResponseLine rfqResponseLine) {
    final I_C_Flatrate_Term contract = rfqResponseLine.getC_Flatrate_Term();
    Check.assumeNotNull(contract, "contract not null");

    final List<I_C_RfQResponseLineQty> rfqResponseLineQtys =
        pmmRfQDAO.retrieveResponseLineQtys(rfqResponseLine);
    if (rfqResponseLineQtys.isEmpty()) {
      return ImmutableList.of();
    }

    final String bpartner_uuid = SyncUUIDs.toUUIDString(contract.getDropShip_BPartner());
    final String contractLine_uuid = SyncUUIDs.toUUIDString(contract);
    final String product_uuid = SyncUUIDs.toUUIDString(contract.getPMM_Product());

    final List<SyncProductSupply> plannedSyncProductSupplies =
        new ArrayList<>(rfqResponseLineQtys.size());
    for (final I_C_RfQResponseLineQty rfqResponseLineQty : rfqResponseLineQtys) {
      final SyncProductSupply syncProductSupply = new SyncProductSupply();
      syncProductSupply.setBpartner_uuid(bpartner_uuid);
      syncProductSupply.setContractLine_uuid(contractLine_uuid);
      syncProductSupply.setProduct_uuid(product_uuid);

      syncProductSupply.setDay(rfqResponseLineQty.getDatePromised());
      syncProductSupply.setQty(rfqResponseLineQty.getQtyPromised());
      plannedSyncProductSupplies.add(syncProductSupply);
    }

    return plannedSyncProductSupplies;
  }
示例#23
0
 @Override
 public boolean isExistingTable(final String tableName) {
   if (Check.isEmpty(tableName, true)) {
     return false;
   }
   return retrieveTableId(tableName) > 0;
 }
示例#24
0
  @Override
  public void allocateAllMRPDemands(final List<IMRPSuppliesPool> mrpSuppliesPools) {
    Check.assumeNotEmpty(mrpSuppliesPools, "mrpSuppliesPools not empty");

    //
    // Iterate each existing MRP demand that needs to be allocated
    final Iterator<IMutableMRPRecordAndQty> mrpDemandsToAllocateIterator =
        mrpDemandsToAllocate.iterator();
    while (mrpDemandsToAllocateIterator.hasNext()) {
      final IMutableMRPRecordAndQty mrpDemand = mrpDemandsToAllocateIterator.next();

      //
      // Iterate each MRP supplies pool and ask to allocate
      for (final IMRPSuppliesPool mrpSuppliesPool : mrpSuppliesPools) {
        // Check if the MRP demand was fully allocated. If it was there is no point to try
        // allocating it.
        if (mrpDemand.isZeroQty()) {
          break;
        }

        // Ask current MRP supplies pool to allocate it
        final List<IMRPDemandToSupplyAllocation> mrpDemandAllocations =
            mrpSuppliesPool.allocate(mrpDemand);
        addAllocationsPerformed(mrpDemandAllocations);
      }
    }
  }
示例#25
0
  private final void addAllocationPerformed(final IMRPDemandToSupplyAllocation alloc) {
    Check.assumeNotNull(alloc, "alloc not null");

    final I_PP_MRP mrpSupplyRecord = alloc.getMRPSupply();
    final BigDecimal mrpSupplyQty = alloc.getQtyAllocated();

    //
    // Check allocated MRP supply and create MRP notes in case something is not ok
    checkMRPSupplyDates(alloc);

    //
    // Update cummulated values
    if (mrpBL.isQtyOnHandReservation(mrpSupplyRecord)) {
      this.qtyOnHandReserved = this.qtyOnHandReserved.add(mrpSupplyQty);
    } else if (mrpBL.isQtyOnHandAnyReservation(mrpSupplyRecord)) {
      // skip any other kind of reservations
    } else {
      final boolean mrpSupplyIsFirm = mrpBL.isReleased(mrpSupplyRecord);
      if (mrpSupplyIsFirm) {
        this.qtyScheduledReceipts = qtyScheduledReceipts.add(mrpSupplyQty);
      }
      this.qtySuppliedTotal = qtySuppliedTotal.add(mrpSupplyQty);
    }

    subtractFromQtyToSupplyRemaining(mrpSupplyQty);

    mrpDemand2supplyAllocations.add(alloc);
  }
示例#26
0
  public static String getBeforeChangeWarning(
      final Properties ctx, final GridTab tab, final boolean newRecord) {
    final List<I_AD_Index_Table> indexes = getAffectedIndexes(ctx, tab, newRecord);
    if (indexes.size() == 0) {
      return null;
    }
    // metas start: [email protected] : 02280
    final int rowCount = tab.getRowCount();
    // metas end: [email protected] : 02280

    final StringBuffer msg = new StringBuffer();
    for (final I_AD_Index_Table index : indexes) {
      if (Check.isEmpty(index.getBeforeChangeWarning())) {
        continue;
      }
      // metas start: [email protected] : 02280
      // if the new entry is the only row, there is nothing to be changed, so a before change
      // warning is not needed.
      if (rowCount == 1) {
        return null;
      }
      // metas end: [email protected] : 02280
      if (msg.length() > 0) {
        msg.append("\n");
      }
      msg.append(index.getBeforeChangeWarning());
    }
    return msg.toString();
  }
示例#27
0
  @Override
  @Cached(cacheName = I_C_ConversionType_Default.Table_Name + "#by#Dimension")
  public I_C_ConversionType retrieveDefaultConversionType(
      @CacheCtx final Properties ctx, final int adClientId, final int adOrgId, final Date date) {
    // NOTE to developer: keep in sync with: getDefaultConversionType_ID database function

    Check.assumeNotNull(date, "date not null");
    final Date dateDay = TimeUtil.trunc(date, TimeUtil.TRUNC_DAY);

    return Services.get(IQueryBL.class)
        .createQueryBuilder(I_C_ConversionType_Default.class, ctx, ITrx.TRXNAME_None)
        .addOnlyActiveRecordsFilter()
        .addInArrayFilter(
            I_C_ConversionType_Default.COLUMN_AD_Client_ID,
            adClientId,
            Env.CTXVALUE_AD_Client_ID_System)
        .addInArrayFilter(
            I_C_ConversionType_Default.COLUMN_AD_Org_ID, adClientId, Env.CTXVALUE_AD_Org_ID_System)
        .addCompareFilter(
            I_C_ConversionType_Default.COLUMN_ValidFrom, Operator.LESS_OR_EQUAL, dateDay)
        //
        .orderBy()
        .addColumn(I_C_ConversionType_Default.COLUMN_ValidFrom, Direction.Descending, Nulls.Last)
        .addColumn(I_C_ConversionType_Default.COLUMN_AD_Client_ID, Direction.Descending, Nulls.Last)
        .addColumn(I_C_ConversionType_Default.COLUMN_AD_Org_ID, Direction.Descending, Nulls.Last)
        .endOrderBy()
        //
        .setLimit(1) // only the first one
        //
        .andCollect(I_C_ConversionType_Default.COLUMN_C_ConversionType_ID)
        .create()
        .firstOnlyNotNull(I_C_ConversionType.class);
  }
示例#28
0
  public String getBeforeChangeCodeTriggerDDL() {
    if (Check.isEmpty(getBeforeChangeCode(), true)) {
      return null;
    }

    final String triggerName = getDBTriggerName();
    final String functionName = getDBFunctionName();

    final StringBuffer sqlColumns = new StringBuffer();
    for (final String columnName : getColumnNames()) {
      if (sqlColumns.length() > 0) {
        sqlColumns.append(",");
      }
      sqlColumns.append(columnName);
    }

    final StringBuffer sql = new StringBuffer();
    sql.append("CREATE TRIGGER " + triggerName)
        .append(" BEFORE INSERT OR UPDATE ")
        // .append(" OF ").append(sqlColumns) // PG 8.5 specific
        .append(" ON " + getTableName())
        .append(" FOR EACH ROW")
        .append(" EXECUTE PROCEDURE " + functionName + "()");
    return sql.toString();
  }
示例#29
0
 public String getDDL() {
   final StringBuffer sql_columns = new StringBuffer();
   for (final MIndexColumn ic : getColumns()) {
     if (sql_columns.length() > 0) {
       sql_columns.append(",");
     }
     sql_columns.append(ic.getColumnName());
   }
   if (sql_columns.length() == 0) {
     throw new AdempiereException("Index has no columns defined");
   }
   //
   final StringBuffer sql = new StringBuffer("CREATE ");
   if (isUnique()) {
     sql.append("UNIQUE ");
   }
   sql.append("INDEX ")
       .append(getName())
       .append(" ON ")
       .append(getTableName())
       .append(" (")
       .append(sql_columns)
       .append(")");
   //
   final String whereClause = getWhereClause();
   if (!Check.isEmpty(whereClause, true)) {
     if (DB.isPostgreSQL()) {
       sql.append(" WHERE ").append(whereClause);
     } else {
       throw new AdempiereException("Partial Index not supported for this database");
     }
   }
   //
   return sql.toString();
 }
示例#30
0
  protected AbstractTerminalNumericField(
      final ITerminalContext tc,
      final String name,
      final int displayType,
      final float fontSize,
      final boolean withButtons,
      final boolean withLabel,
      final String constr) {
    super(tc);

    this.name = name;
    this.displayType = displayType;
    if (fontSize > 0) {
      this.fontSize = fontSize;
    } else {
      this.fontSize = tc.getDefaultFontSize();
    }

    this.withButtons = withButtons;
    this.withLabel = withLabel;
    if (!Check.isEmpty(constr, true)) {
      constraints = constr;
    }

    initComponents();
    initUI();
    setValue(Env.ZERO, false);
  }