@Override protected final void setFieldValue(final BigDecimal value, final boolean fireEvent) { final BigDecimal valueOld = this._valueOld; // backup for event // // Fix value to set final BigDecimal valueNew; if (value == null) { valueNew = Env.ZERO; } else { // Qty Editor it shall be a small component and we don't want to clutter it with pointless // trailing zeros (06112) valueNew = NumberUtils.stripTrailingDecimalZeros(value); } // // Get the number editor final ITerminalTextField fNumber = this.fNumber; if (isDisposed() || fNumber == null) { // shall not happen but we are throwing an exception because we got a weird case (FRESH-331) new TerminalException( "Atempt to set value but field is disposed." + "\n field: " + this + "\n value: " + valueOld + "->" + valueNew + "\n fireEvent: " + fireEvent + "\n fNumber: " + fNumber) .throwOrLogWarningIfDeveloperMode(log); return; } // // Actually setting the new value fNumber.setText(valueNew.toString()); this._valueOld = valueNew; // // Fire event if (fireEvent) { final boolean changed = valueOld == null || valueOld.compareTo(valueNew) != 0; if (changed) { firePropertyChange(ITerminalField.ACTION_ValueChanged, valueOld, valueNew); } } }
private ArrayKey createKeyForHUProducer(final I_M_HU_LUTU_Configuration lutuConfiguration) { Check.assumeNotNull(lutuConfiguration, "lutuConfiguration not null"); final List<Object> keyItems = new ArrayList<Object>(); // // LU: PI final int luPIItemId = lutuConfiguration.getM_LU_HU_PI_Item_ID(); final boolean hasLU; if (luPIItemId > 0) { final int luPIId = lutuConfiguration.getM_LU_HU_PI_ID(); Check.assume(luPIId > 0, "LU PI ID shall be set for {}", lutuConfiguration); keyItems.add(luPIItemId); // LU M_HU_PI_Item_ID keyItems.add(luPIId); // LU M_HU_PI_ID hasLU = true; } else { keyItems.add(-1); // LU M_HU_PI_Item_ID keyItems.add(-1); // LU M_HU_PI_ID hasLU = false; } // // LU: Qty // NOTE: we skip QtyLU because it's not relevant when we check if the configuration is still // compliant with an HU // // TU: PI final int tuPIId = lutuConfiguration.getM_TU_HU_PI_ID(); if (tuPIId > 0) { keyItems.add(tuPIId); // TU M_HU_PI_ID } else { keyItems.add(-1); // TU M_HU_PI_ID } // // TU: Qty if (lutuConfiguration.isInfiniteQtyTU()) { keyItems.add(true); // IsInfiniteQtyTU keyItems.add(0); // Qty TU } // case: there is no LU. In this case we can ignore the QtyTU because it's not relevant when we // check if configuration is still compiant with an HU else if (!hasLU) { keyItems.add(false); // IsInfiniteQtyTU keyItems.add("QtyTU_NA"); // Qty TU: N/A } else { keyItems.add(false); // IsInfiniteQtyTU keyItems.add(lutuConfiguration.getQtyTU().intValue()); // Qty TU } // // CU final int productId = lutuConfiguration.getM_Product_ID(); final int uomId = lutuConfiguration.getC_UOM_ID(); keyItems.add(productId > 0 ? productId : -1); keyItems.add(uomId > 0 ? uomId : -1); if (lutuConfiguration.isInfiniteQtyCU()) { keyItems.add(true); // IsInfiniteQtyCU keyItems.add(BigDecimal.ZERO); // Qty CU } else { final BigDecimal qtyCU = NumberUtils.stripTrailingDecimalZeros(lutuConfiguration.getQtyCU()); keyItems.add(false); // IsInfiniteQtyCU keyItems.add(qtyCU); // Qty CU } // // Misc final int locatorId = lutuConfiguration.getM_Locator_ID(); final int bpartnerId = lutuConfiguration.getC_BPartner_ID(); final int bpartnerLocationId = lutuConfiguration.getC_BPartner_Location_ID(); final String huStatus = lutuConfiguration.getHUStatus(); keyItems.add(locatorId > 0 ? locatorId : -1); keyItems.add(bpartnerId > 0 ? bpartnerId : -1); keyItems.add(bpartnerLocationId > 0 ? bpartnerLocationId : -1); keyItems.add(huStatus); keyItems.add(lutuConfiguration.isActive()); return Util.mkKey(keyItems.toArray()); }