@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;
  }
Пример #2
0
 private I_PP_Cost_Collector createVarianceCostCollector(
     I_PP_Cost_Collector cc, String CostCollectorType) {
   final I_PP_Cost_Collector ccv =
       InterfaceWrapperHelper.newInstance(I_PP_Cost_Collector.class, cc);
   InterfaceWrapperHelper.copyValues(cc, ccv);
   ccv.setProcessing(false);
   ccv.setProcessed(false);
   ccv.setDocStatus(X_PP_Cost_Collector.DOCSTATUS_Drafted);
   ccv.setDocAction(X_PP_Cost_Collector.DOCACTION_Complete);
   ccv.setCostCollectorType(CostCollectorType);
   ccv.setDocumentNo(null); // reset
   cc.setPP_Cost_Collector_Parent(cc); // link to parent
   InterfaceWrapperHelper.save(ccv);
   return ccv;
 }
Пример #3
0
  private final void createReversal(
      final I_M_CostDetail costDetail, final I_PP_Cost_Collector reversalCostCollector) {
    final I_M_CostDetail costDetailReversal =
        InterfaceWrapperHelper.newInstance(I_M_CostDetail.class, costDetail);
    InterfaceWrapperHelper.copyValues(
        costDetail, costDetailReversal, true); // honorIsCalculated=true
    costDetailReversal.setPP_Cost_Collector_ID(reversalCostCollector.getPP_Cost_Collector_ID());
    costDetailReversal.setQty(costDetail.getQty().negate());
    costDetailReversal.setAmt(costDetail.getAmt().negate());
    costDetailReversal.setDeltaQty(costDetail.getDeltaQty().negate());
    costDetailReversal.setDeltaAmt(costDetail.getDeltaAmt().negate());
    costDetailReversal.setProcessed(false);
    InterfaceWrapperHelper.save(costDetailReversal);

    processCostDetail(costDetailReversal);
  }
  private MAttributeSetInstance saveSelection0() {
    log.info("");

    final MAttributeSet as = asiTemplate.getMAttributeSet();
    Check.assumeNotNull(as, "as not null");

    // Create a new ASI which is copying the existing one
    final MAttributeSetInstance asi =
        new MAttributeSetInstance(getCtx(), 0, ITrx.TRXNAME_ThreadInherited);
    InterfaceWrapperHelper.copyValues(
        asiTemplate, asi, false); // honorIsCalculated=false => copy everything
    asi.setM_AttributeSet(as); // make sure we have the right AttributeSet model set

    //
    boolean changed = false;
    final Set<String> mandatory = new LinkedHashSet<>();

    // Lot
    if (!m_productWindow && as.isLot()) {
      String text = fieldLotString.getText();
      asi.setLot(text);
      if (as.isLotMandatory() && (text == null || text.length() == 0)) {
        mandatory.add(msgBL.translate(getCtx(), "Lot"));
      }
      changed = true;
    } // Lot

    // Serial No
    if (!m_productWindow && as.isSerNo()) {
      final String serNo = fieldSerNo.getText();
      asi.setSerNo(serNo);
      if (as.isSerNoMandatory() && Check.isEmpty(serNo, true)) {
        mandatory.add(msgBL.translate(getCtx(), "SerNo"));
      }
      changed = true;
    } // SerNo

    //
    // Guarantee Date (if required)
    if (fieldGuaranteeDateDisplayed) {
      final Timestamp guaranteeDate = fieldGuaranteeDate.getValue();
      asi.setGuaranteeDate(guaranteeDate);
      if (as.isGuaranteeDate() && as.isGuaranteeDateMandatory() && guaranteeDate == null) {
        mandatory.add(msgBL.translate(getCtx(), I_M_AttributeSetInstance.COLUMNNAME_GuaranteeDate));
      }
      changed = true;
    }

    //
    // New Instance
    if (changed || asi.getM_AttributeSetInstance_ID() <= 0) {
      InterfaceWrapperHelper.save(asi);
      changed = true;
    }
    final int attributeSetInstanceId = asi.getM_AttributeSetInstance_ID();

    //
    // Save Instance Attributes
    for (final MAttribute attribute : m_attributes) {
      final CEditor editor = attributeId2editor.get(attribute.getM_Attribute_ID());

      if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attribute.getAttributeValueType())) {
        @SuppressWarnings("unchecked")
        final CComboBox<I_M_AttributeValue> editorCombo = (CComboBox<I_M_AttributeValue>) editor;
        final I_M_AttributeValue attributeValue = editorCombo.getSelectedItem();
        if (attribute.isMandatory() && attributeValue == null) {
          mandatory.add(attribute.getName());
        }
        attribute.setMAttributeInstance(attributeSetInstanceId, attributeValue);
      } else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attribute.getAttributeValueType())) {
        final VNumber editorNumber = (VNumber) editor;
        final BigDecimal value = (BigDecimal) editorNumber.getValue();
        if (attribute.isMandatory() && value == null) {
          mandatory.add(attribute.getName());
        }
        attribute.setMAttributeInstance(attributeSetInstanceId, value);
      } else if (MAttribute.ATTRIBUTEVALUETYPE_Date.equals(attribute.getAttributeValueType())) {
        final VDate editorDate = (VDate) editor;
        final Timestamp value = editorDate.getValue();
        if (attribute.isMandatory() && value == null) {
          mandatory.add(attribute.getName());
        }
        attribute.setMAttributeInstance(attributeSetInstanceId, value);
      } else {
        final VString editorString = (VString) editor;
        final String value = editorString.getText();
        if (attribute.isMandatory() && Check.isEmpty(value, false)) {
          mandatory.add(attribute.getName());
        }
        attribute.setMAttributeInstance(attributeSetInstanceId, value);
      }
      changed = true;
    } // for all attributes

    //
    // Throw exception if there are some mandatory fields which were not set
    if (!mandatory.isEmpty()) {
      throw new AdempiereException("@FillMandatory@ " + StringUtils.toString(mandatory, ", "));
    }

    // Save Model
    if (changed) {
      asi.setMAttributeSet(as); // NOTE: this is workaround for the case when M_AttributeSet_ID=0
      attributeSetInstanceBL.setDescription(asi);
      InterfaceWrapperHelper.save(asi);
    }

    return asi;
  }