Example #1
0
 /**
  * Create & Proce Cost Detail for Variances
  *
  * @param ccv
  * @param amt
  * @param qty
  * @param cd (optional)
  * @param product
  * @param as
  * @param element
  * @return
  */
 private MCostDetail createVarianceCostDetail(
     I_PP_Cost_Collector ccv,
     BigDecimal amt,
     BigDecimal qty,
     MCostDetail cd,
     I_M_Product product,
     I_C_AcctSchema as,
     I_M_CostElement element) {
   final Properties ctx = InterfaceWrapperHelper.getCtx(ccv);
   final String trxName = InterfaceWrapperHelper.getTrxName(ccv);
   final MCostDetail cdv = new MCostDetail(ctx, 0, trxName);
   if (cd != null) {
     MCostDetail.copyValues(cd, cdv);
     cdv.setProcessed(false);
   }
   if (product != null) {
     cdv.setM_Product_ID(product.getM_Product_ID());
     cdv.setM_AttributeSetInstance_ID(0);
   }
   if (as != null) {
     cdv.setC_AcctSchema_ID(as.getC_AcctSchema_ID());
   }
   if (element != null) {
     cdv.setM_CostElement_ID(element.getM_CostElement_ID());
   }
   //
   cdv.setPP_Cost_Collector_ID(ccv.getPP_Cost_Collector_ID());
   cdv.setAmt(amt);
   cdv.setQty(qty);
   cdv.saveEx();
   processCostDetail(cdv);
   return cdv;
 }
  @Override
  public I_M_AttributeSetExclude retrieveAttributeSetExclude(
      I_M_AttributeSet attributeSet, int columnId, boolean isSOTrx) {
    if (columnId <= 0) {
      return null;
    }

    final Properties ctx = InterfaceWrapperHelper.getCtx(attributeSet);
    final String trxName = InterfaceWrapperHelper.getTrxName(attributeSet);
    final I_AD_Column column =
        InterfaceWrapperHelper.create(ctx, columnId, I_AD_Column.class, trxName);
    // guard against null, when column was not found
    if (column == null) {
      return null;
    }

    return Services.get(IQueryBL.class)
        .createQueryBuilder(I_M_AttributeSetExclude.class, attributeSet)
        .addEqualsFilter(I_M_AttributeSetExclude.COLUMNNAME_AD_Table_ID, column.getAD_Table_ID())
        .addEqualsFilter(I_M_AttributeSetExclude.COLUMNNAME_IsSOTrx, isSOTrx)
        .addEqualsFilter(
            I_M_AttributeSetExclude.COLUMNNAME_M_AttributeSet_ID,
            attributeSet.getM_AttributeSet_ID())
        .addOnlyActiveRecordsFilter()
        .create()
        .firstOnly(I_M_AttributeSetExclude.class);
  }
Example #3
0
  /**
   * Creates a dummy MRP firm demand.
   *
   * <p>NOTE:
   *
   * <ul>
   *   <li>DocStatus will be Completed
   *   <li>OrderType will be SalesOrder
   * </ul>
   *
   * @param product
   * @param qty
   * @param date
   * @param plant
   * @param warehouse
   * @return demand MRP record
   */
  public I_PP_MRP createMRPDemand(
      final I_M_Product product,
      final BigDecimal qty,
      final Date date,
      final I_S_Resource plant,
      final I_M_Warehouse warehouse,
      final I_C_BPartner bpartner) {
    final I_PP_MRP mrp = InterfaceWrapperHelper.newInstance(I_PP_MRP.class, contextProvider);
    mrp.setAD_Org_ID(warehouse.getAD_Org_ID());
    mrp.setS_Resource(plant);
    mrp.setM_Warehouse(warehouse);
    mrp.setC_BPartner(bpartner);
    //
    final Timestamp dateTS = TimeUtil.asTimestamp(date);
    mrp.setDatePromised(dateTS);
    mrp.setDateStartSchedule(dateTS);
    mrp.setDateFinishSchedule(dateTS);
    //
    mrp.setTypeMRP(X_PP_MRP.TYPEMRP_Demand);
    mrp.setDocStatus(X_PP_MRP.DOCSTATUS_Completed); // Firm Demand
    mrp.setOrderType(X_PP_MRP.ORDERTYPE_SalesOrder); // Sales Order
    mrp.setIsAvailable(true);
    //
    mrp.setM_Product(product);
    Services.get(IMRPBL.class).setQty(mrp, qty, qty, product.getC_UOM());
    //
    // mrp.setC_BPartner(C_BPartner);

    InterfaceWrapperHelper.save(mrp);

    return mrp;
  }
  @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();
  }
  @Override
  public void assertNotChanged(final I_M_HU_LUTU_Configuration lutuConfiguration) {
    Check.assumeNotNull(lutuConfiguration, "lutuConfiguration not null");

    //
    // Check if we were explicitly asked to not check the changes
    final Boolean disableChangeCheckingOnSave =
        InterfaceWrapperHelper.getDynAttribute(
            lutuConfiguration, DYNATTR_DisableChangeCheckingOnSave);
    if (disableChangeCheckingOnSave != null && disableChangeCheckingOnSave == true) {
      return;
    }

    //
    // Make sure LU/TU configuration does not changed (from LUTU Producer perspective)
    final I_M_HU_LUTU_Configuration lutuConfigurationOld =
        InterfaceWrapperHelper.createOld(lutuConfiguration, I_M_HU_LUTU_Configuration.class);
    if (isSameForHUProducer(lutuConfiguration, lutuConfigurationOld)) {
      return;
    }

    //
    // Prevent changing the configuration
    // NOTE: it's safe to throw an english/internal error because mainly this is an internal error
    throw new HUException(
        "Changing already saved LU/TU Configuration is not allowed: " + lutuConfiguration);
  }
Example #6
0
  private void setupContext(final boolean initEnvironment) {
    ctx = Env.getCtx();
    trxName = ITrx.TRXNAME_None;

    //
    // Setup context: #AD_Client_ID
    int adClientId = Env.getAD_Client_ID(ctx);
    if (adClientId <= 0) {
      adClient = InterfaceWrapperHelper.create(ctx, I_AD_Client.class, ITrx.TRXNAME_None);
      InterfaceWrapperHelper.save(adClient);
      adClientId = adClient.getAD_Client_ID();
      Env.setContext(ctx, Env.CTXNAME_AD_Client_ID, adClientId);
    } else {
      adClient =
          InterfaceWrapperHelper.create(ctx, adClientId, I_AD_Client.class, ITrx.TRXNAME_None);
    }

    int adOrgId = Env.getAD_Org_ID(ctx);
    if (adOrgId <= 0) {
      adOrg01 = createOrg("Org01");
      adOrgId = adOrg01.getAD_Org_ID();
      Env.setContext(ctx, Env.CTXNAME_AD_Org_ID, adOrgId);
    } else {
      adOrg01 = InterfaceWrapperHelper.create(ctx, adOrgId, I_AD_Org.class, ITrx.TRXNAME_None);
    }

    SystemTime.setTimeSource(
        new TimeSource() {
          @Override
          public long millis() {
            return _today.getTime();
          }
        });
  }
Example #7
0
  /** Suggests the {@link I_M_HU_PI_Item_Product} for Order Quick Input */
  @Override
  public I_M_HU_PI_Item_Product getM_HU_PI_ItemProductFor(final Object document) {
    Check.assumeInstanceOf(document, I_C_Order.class, "param 'document'");

    final Properties ctx = InterfaceWrapperHelper.getCtx(document);
    final String trxName = InterfaceWrapperHelper.getTrxName(document);

    final I_C_Order order = InterfaceWrapperHelper.create(document, I_C_Order.class);

    final I_M_PriceList_Version plv = Services.get(IOrderBL.class).getPriceListVersion(order);

    final I_M_ProductPrice_Attribute productPriceAttribute =
        Services.get(IAttributePricingBL.class)
            .getDefaultAttributePriceOrNull(
                order, order.getM_Product_ID(), plv, false); // strictDefault

    if (null != productPriceAttribute) {
      final de.metas.handlingunits.model.I_M_ProductPrice_Attribute productPriceAttributeExt =
          InterfaceWrapperHelper.create(
              productPriceAttribute, de.metas.handlingunits.model.I_M_ProductPrice_Attribute.class);
      final I_M_HU_PI_Item_Product hu_pip =
          InterfaceWrapperHelper.create(
              ctx,
              productPriceAttributeExt.getM_HU_PI_Item_Product_ID(),
              I_M_HU_PI_Item_Product.class,
              trxName);
      return hu_pip;
    }

    return null;
  }
  private final I_C_TaxDeclarationAcct createTaxDeclarationAcct(
      final I_C_TaxDeclarationLine taxDeclarationLine, final I_Fact_Acct fact) {
    final I_C_TaxDeclaration taxDeclaration = getC_TaxDeclaration();

    final I_C_TaxDeclarationAcct taxDeclarationAcct =
        InterfaceWrapperHelper.create(
            getCtx(), I_C_TaxDeclarationAcct.class, ITrx.TRXNAME_ThreadInherited);
    taxDeclarationAcct.setAD_Org_ID(fact.getAD_Org_ID());
    taxDeclarationAcct.setC_TaxDeclaration(taxDeclaration);

    // Link to C_TaxDeclarationLine ONLY if the Fact_Acct record is about tax booking
    // NOTE: very important, reports are relying on this (e.g. see RV_TaxDeclarationLine)
    if (taxDeclarationLine != null && taxDeclarationLine.getC_Tax_ID() == fact.getC_Tax_ID()) {
      taxDeclarationAcct.setC_TaxDeclarationLine(taxDeclarationLine);
    } else {
      taxDeclarationAcct.setC_TaxDeclarationLine(null);
    }

    taxDeclarationAcct.setFact_Acct_ID(
        fact.getFact_Acct_ID()); // this FK shall block Fact_Acct to be deleted
    taxDeclarationAcct.setC_AcctSchema_ID(fact.getC_AcctSchema_ID());

    //
    // Save
    final int line = lineNoOffset_TaxDeclarationAcct + (countAcctLinesCreated + 1) * 10;
    taxDeclarationAcct.setLine(line);
    InterfaceWrapperHelper.save(taxDeclarationAcct);
    countAcctLinesCreated++;

    return taxDeclarationAcct;
  }
Example #9
0
  /**
   * Recalculate order tax
   *
   * @param oldTax true if the old C_Tax_ID should be used
   * @return true if success, false otherwise
   * @author teo_sarca [ 1583825 ]
   */
  private boolean updateOrderTax(final boolean oldTax) {
    // NOTE: keep in sync with org.compiere.model.MInvoiceLine.updateInvoiceTax(boolean)

    final String trxName = get_TrxName();
    final int taxPrecision = getPrecision();
    final MOrderTax tax = MOrderTax.get(this, taxPrecision, oldTax, trxName);
    if (tax == null) {
      return true;
    }

    if (!tax.calculateTaxFromLines()) {
      return false;
    }

    //
    // If tax has invoice lines behind => fine, save it
    if (tax.isActive()) {
      InterfaceWrapperHelper.save(tax, trxName);
    }
    // Tax has no longer any invoice lines behind => deleted it if it's not new
    else {
      if (!InterfaceWrapperHelper.isNew(tax)) {
        InterfaceWrapperHelper.delete(tax);
      }
    }

    return true;
  }
Example #10
0
 public I_C_BP_Group createBPGroup(final String name) {
   final I_C_BP_Group bpGroup =
       InterfaceWrapperHelper.newInstance(I_C_BP_Group.class, contextProvider);
   bpGroup.setValue(name);
   bpGroup.setName(name);
   InterfaceWrapperHelper.save(bpGroup);
   return bpGroup;
 }
Example #11
0
 public I_AD_Workflow createWorkflow(final String name) {
   final I_AD_Workflow wf =
       InterfaceWrapperHelper.newInstance(I_AD_Workflow.class, contextProvider);
   wf.setValue(name);
   wf.setName(name);
   wf.setWorkflowType(X_AD_Workflow.WORKFLOWTYPE_Manufacturing);
   InterfaceWrapperHelper.save(wf);
   return wf;
 }
Example #12
0
  public I_M_Shipper createShipper(final I_C_BPartner bpartner) {
    final I_M_Shipper shipper =
        InterfaceWrapperHelper.newInstance(I_M_Shipper.class, contextProvider);
    shipper.setName(bpartner.getName());
    shipper.setC_BPartner_ID(bpartner.getC_BPartner_ID());

    InterfaceWrapperHelper.save(shipper);
    return shipper;
  }
Example #13
0
 public void createMRPMessage(final String code) {
   final I_AD_Message message =
       InterfaceWrapperHelper.newInstance(I_AD_Message.class, contextProvider);
   InterfaceWrapperHelper.setValue(message, "AD_Client_ID", 0);
   message.setAD_Org_ID(0);
   message.setValue(code);
   message.setMsgText(code);
   InterfaceWrapperHelper.save(message);
 }
Example #14
0
  public I_M_Product_Category createProductCategory(final String name) {
    final I_M_Product_Category productCategory =
        InterfaceWrapperHelper.newInstance(I_M_Product_Category.class, contextProvider);
    productCategory.setValue(name);
    productCategory.setName(name);
    InterfaceWrapperHelper.save(productCategory);

    return productCategory;
  }
Example #15
0
  private final I_M_HU createHU_InTrx(final I_M_HU_Item parentHUItem) {
    //
    // Get HUStatus to set
    final String huStatus;
    if (isHUStatusSet()) {
      huStatus = getHUStatus();
    } else if (parentHUItem != null) {
      huStatus = parentHUItem.getM_HU().getHUStatus();
    } else {
      huStatus = null;
    }

    //
    // Get M_Locator to set
    final I_M_Locator locator;
    if (_locatorSet) {
      locator = _locator;
    } else if (parentHUItem != null) {
      locator = parentHUItem.getM_HU().getM_Locator();
    } else {
      locator = null;
    }

    //
    // Create and save HU
    final I_M_HU hu = InterfaceWrapperHelper.newInstance(I_M_HU.class, getContext());
    POJOWrapper.setInstanceName(hu, _instanceName);
    hu.setM_HU_PI_Version(getM_HU_PI_Version());
    hu.setM_HU_Item_Parent(parentHUItem);
    hu.setC_BPartner(_bpartner);
    hu.setC_BPartner_Location(_bpartnerLocation);
    hu.setHUStatus(huStatus);
    hu.setM_Locator(locator);
    InterfaceWrapperHelper.save(hu);

    //
    // Create HU Attributes
    if (attributesExpectations != null) {
      attributesExpectations.createHUAttributes(hu);
    }

    //
    // Create HU Items
    if (huItemExpectations != null) {
      for (final HUItemExpectation<HUExpectation<ParentExpectationType>> huItemExpectation :
          huItemExpectations) {
        huItemExpectation.createHUItem(hu);
      }
    }

    // Capture the HU if required
    if (_huToSetRef != null) {
      _huToSetRef.setValue(hu);
    }

    return hu;
  }
  @Override
  public IQueryBuilder<I_M_HU_Assignment> retrieveHUAssignmentsForModelQuery(final Object model) {
    final Properties ctx = InterfaceWrapperHelper.getCtx(model);
    final int adTableId = InterfaceWrapperHelper.getModelTableId(model);
    final int recordId = InterfaceWrapperHelper.getId(model);
    final String trxName = InterfaceWrapperHelper.getTrxName(model);

    return retrieveHUAssignmentsForModelQuery(ctx, adTableId, recordId, trxName);
  }
  private void reactivateAndComplete(
      final GridWindowHelper dataEntryHelper, final I_C_Flatrate_DataEntry dataEntry) {
    assertThat(
        dataEntry + " has wrong DocStatus",
        dataEntry.getDocStatus(),
        is(X_C_Flatrate_DataEntry.DOCSTATUS_Completed));

    final I_C_Invoice_Candidate icBeforeReactivation = dataEntry.getC_Invoice_Candidate();
    final I_C_Invoice_Candidate icCorrBeforeReactivation = dataEntry.getC_Invoice_Candidate_Corr();

    helper.reactivateEntry(dataEntryHelper);

    assertThat(
        dataEntry + " has wrong C_Invoice_Candidate_ID",
        dataEntry.getC_Invoice_Candidate_ID(),
        is(0));
    assertThat(
        dataEntry + " has wrong C_Invoice_Candidate_Corr_ID",
        dataEntry.getC_Invoice_Candidate_Corr_ID(),
        is(0));

    // invoice cand(s) should have been deleted
    final I_C_Invoice_Candidate icAfterReactivation =
        InterfaceWrapperHelper.create(
            driver.getCtx(),
            icBeforeReactivation.getC_Invoice_Candidate_ID(),
            I_C_Invoice_Candidate.class,
            driver.getTrxName());
    assertThat(icAfterReactivation, nullValue());
    final I_C_Invoice_Candidate icCorrAfterReactivation =
        InterfaceWrapperHelper.create(
            driver.getCtx(),
            icCorrBeforeReactivation.getC_Invoice_Candidate_ID(),
            I_C_Invoice_Candidate.class,
            driver.getTrxName());
    assertThat(icCorrAfterReactivation, nullValue());

    //
    // completing again
    //

    // expecting completion to fail, because depending invoice candidates have no been updated yet
    helper.completeEntry(dataEntryHelper, X_C_Flatrate_DataEntry.DOCSTATUS_Invalid);

    // running UpdateInvoiceCands and expecting the completIt to succeed
    invoiceCandHelper.runProcess_UpdateInvoiceCands();
    try {
      Thread.sleep(1000); // do nothing for 1000 miliseconds (1 second)
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    helper.completeEntry(dataEntryHelper, X_C_Flatrate_DataEntry.DOCSTATUS_Completed);

    invoiceCandHelper.runProcess_UpdateInvoiceCands();
    dataEntryHelper.refresh();
  }
Example #18
0
 public I_C_Queue_Processor createQueueProcessor(
     final String name, final int poolSize, final int maxPoolSize, final int keepAliveTimeMillis) {
   final I_C_Queue_Processor queueProcessorDef =
       InterfaceWrapperHelper.create(ctx, I_C_Queue_Processor.class, ITrx.TRXNAME_None);
   queueProcessorDef.setName(name);
   queueProcessorDef.setPoolSize(poolSize);
   queueProcessorDef.setKeepAliveTimeMillis(keepAliveTimeMillis);
   InterfaceWrapperHelper.save(queueProcessorDef);
   return queueProcessorDef;
 }
  @Override
  public I_M_HU_LUTU_Configuration copy(final I_M_HU_LUTU_Configuration lutuConfiguration) {
    Check.assumeNotNull(lutuConfiguration, "lutuConfiguration not null");
    final I_M_HU_LUTU_Configuration lutuConfigurationNew =
        InterfaceWrapperHelper.newInstance(I_M_HU_LUTU_Configuration.class, lutuConfiguration);
    final boolean honorIsCalculated = true;
    InterfaceWrapperHelper.copyValues(lutuConfiguration, lutuConfigurationNew, honorIsCalculated);

    return lutuConfigurationNew;
  }
Example #20
0
 public I_C_UOM createUOM(final String name, final int stdPrecision) {
   final I_C_UOM uom = InterfaceWrapperHelper.newInstance(I_C_UOM.class, contextProvider);
   uom.setName(name);
   uom.setUOMSymbol(name);
   uom.setX12DE355(name);
   uom.setStdPrecision(stdPrecision);
   uom.setCostingPrecision(0);
   InterfaceWrapperHelper.save(uom);
   return uom;
 }
  /**
   * Get active Payment Allocation of Payment
   *
   * @param parent payment
   * @return array of allocations
   */
  public static MPaymentAllocate[] get(I_C_Payment parent) {
    final Properties ctx = InterfaceWrapperHelper.getCtx(parent);
    final String trxName = InterfaceWrapperHelper.getTrxName(parent);

    final String whereClause = "C_Payment_ID=? AND IsActive=?";
    Query query = MTable.get(ctx, Table_ID).createQuery(whereClause, trxName);
    query.setParameters(new Object[] {parent.getC_Payment_ID(), "Y"});
    List<MPaymentAllocate> list = query.list();
    return list.toArray(new MPaymentAllocate[list.size()]);
  } //	get
Example #22
0
  public I_C_DocType createDocType(final String docBaseType) {
    final I_C_DocType docType =
        InterfaceWrapperHelper.newInstance(I_C_DocType.class, contextProvider);
    docType.setAD_Org_ID(adOrg01.getAD_Org_ID());
    docType.setDocBaseType(docBaseType);
    docType.setName(docBaseType);

    InterfaceWrapperHelper.save(docType);
    return docType;
  }
Example #23
0
  public I_C_Queue_PackageProcessor createPackageProcessor(
      Properties ctx,
      Class<? extends IWorkpackageProcessor> packageProcessorClass,
      String trxName) {
    final I_C_Queue_PackageProcessor packageProcessorDef =
        InterfaceWrapperHelper.create(ctx, I_C_Queue_PackageProcessor.class, trxName);
    packageProcessorDef.setClassname(packageProcessorClass.getCanonicalName());
    InterfaceWrapperHelper.save(packageProcessorDef);

    return packageProcessorDef;
  }
Example #24
0
  public void markUnprocessed(final I_C_Queue_WorkPackage workpackage) {
    workpackage.setIsReadyForProcessing(false);
    InterfaceWrapperHelper.save(workpackage);

    workpackage.setProcessed(false);
    workpackage.setIsError(false);
    workpackage.setSkippedAt(null);
    workpackage.setAD_Issue(null);

    InterfaceWrapperHelper.save(workpackage);
  }
Example #25
0
 public I_C_BPartner_Location createBPLocation(final I_C_BPartner bpartner) {
   final I_C_BPartner_Location bpLocation =
       InterfaceWrapperHelper.newInstance(I_C_BPartner_Location.class, bpartner);
   bpLocation.setC_BPartner_ID(bpartner.getC_BPartner_ID());
   bpLocation.setIsBillToDefault(true);
   bpLocation.setIsBillTo(true);
   bpLocation.setIsShipToDefault(true);
   bpLocation.setIsShipTo(true);
   InterfaceWrapperHelper.save(bpLocation);
   return bpLocation;
 }
Example #26
0
  public void assignPackageProcessor(
      final I_C_Queue_Processor queueProcessorDef,
      final I_C_Queue_PackageProcessor packageProcessorDef) {
    final Properties ctx = InterfaceWrapperHelper.getCtx(queueProcessorDef);
    final String trxName = InterfaceWrapperHelper.getTrxName(queueProcessorDef);

    final I_C_Queue_Processor_Assign assignment =
        InterfaceWrapperHelper.create(ctx, I_C_Queue_Processor_Assign.class, trxName);
    assignment.setC_Queue_Processor(queueProcessorDef);
    assignment.setC_Queue_PackageProcessor(packageProcessorDef);
    InterfaceWrapperHelper.save(assignment);
  }
Example #27
0
  public I_C_Queue_PackageProcessor assignPackageProcessor(
      I_C_Queue_Processor queueProcessorDef,
      Class<? extends IWorkpackageProcessor> packageProcessorClass) {
    final Properties ctx = InterfaceWrapperHelper.getCtx(queueProcessorDef);
    final String trxName = InterfaceWrapperHelper.getTrxName(queueProcessorDef);

    final I_C_Queue_PackageProcessor packageProcessorDef =
        createPackageProcessor(ctx, packageProcessorClass, trxName);
    assignPackageProcessor(queueProcessorDef, packageProcessorDef);

    return packageProcessorDef;
  }
Example #28
0
  public I_S_ResourceType createResourceType(final String name) {
    final I_S_ResourceType resourceType =
        InterfaceWrapperHelper.newInstance(I_S_ResourceType.class, contextProvider);
    resourceType.setIsActive(true);
    resourceType.setName(name);
    resourceType.setValue(name);
    resourceType.setIsDateSlot(false);
    resourceType.setIsTimeSlot(false);
    InterfaceWrapperHelper.save(resourceType);

    return resourceType;
  }
  @Override
  public boolean hasHUAssignmentsForModel(final Object model) {
    final int adTableId = InterfaceWrapperHelper.getModelTableId(model);
    final int recordId = InterfaceWrapperHelper.getId(model);

    return Services.get(IQueryBL.class)
        .createQueryBuilder(I_M_HU_Assignment.class, model)
        .addOnlyActiveRecordsFilter()
        .addEqualsFilter(I_M_HU_Assignment.COLUMN_AD_Table_ID, adTableId)
        .addEqualsFilter(I_M_HU_Assignment.COLUMN_Record_ID, recordId)
        .create()
        .match();
  }
  @Override
  public IQueryBuilder<I_M_HU_Assignment> retrieveTUHUAssignmentsForModelQuery(final Object model) {
    final int adTableId = InterfaceWrapperHelper.getModelTableId(model);
    final int recordId = InterfaceWrapperHelper.getId(model);

    final IQueryBL queryBL = Services.get(IQueryBL.class);
    return queryBL
        .createQueryBuilder(I_M_HU_Assignment.class, model)
        .addEqualsFilter(I_M_HU_Assignment.COLUMN_AD_Table_ID, adTableId)
        .addEqualsFilter(I_M_HU_Assignment.COLUMN_Record_ID, recordId)
        .addNotEqualsFilter(I_M_HU_Assignment.COLUMN_M_TU_HU_ID, null) // TU is set
        .addOnlyActiveRecordsFilter();
  }