use of org.compiere.model.I_M_AttributeSetInstance in project metasfresh-webui-api by metasfresh.
the class ForecastLineQuickInputProcessor method createASI.
private static final int createASI(final ProductAndAttributes productAndAttributes) {
final ImmutableAttributeSet attributes = productAndAttributes.getAttributes();
if (attributes.isEmpty()) {
return -1;
}
final IAttributeSetInstanceBL asiBL = Services.get(IAttributeSetInstanceBL.class);
final I_M_AttributeSetInstance asi = asiBL.createASIWithASFromProductAndInsertAttributeSet(productAndAttributes.getProductId(), attributes);
return asi.getM_AttributeSetInstance_ID();
}
use of org.compiere.model.I_M_AttributeSetInstance in project metasfresh-webui-api by metasfresh.
the class ASIDocument method complete.
IntegerLookupValue complete() {
assertNotCompleted();
final I_M_AttributeSetInstance asiRecord = createM_AttributeSetInstance(this);
final IntegerLookupValue lookupValue = IntegerLookupValue.of(asiRecord.getM_AttributeSetInstance_ID(), asiRecord.getDescription());
completed = true;
return lookupValue;
}
use of org.compiere.model.I_M_AttributeSetInstance in project metasfresh-webui-api by metasfresh.
the class MaterialCockpitRowFactoryTest method createRows_contains_attribute_groups.
/**
* Verifies that the {@link I_MD_Cockpit} and {@link I_MD_Stock} data rows are correctly applied to {@link MaterialCockpitRow}s based on the given dimension spec.
* In this test, we have a dimension spec with tree groups, on of them is empty.
*/
@Test
public void createRows_contains_attribute_groups() {
final I_M_AttributeSetInstance asi1 = newInstance(I_M_AttributeSetInstance.class);
save(asi1);
final IAttributeSetInstanceBL attributeSetInstanceBL = Services.get(IAttributeSetInstanceBL.class);
attributeSetInstanceBL.getCreateAttributeInstance(asi1, attr1_value1);
attributeSetInstanceBL.getCreateAttributeInstance(asi1, attr2_value1);
final AttributesKey attributesKeyWithAttr1_and_attr2 = AttributesKeys.createAttributesKeyFromASIAllAttributeValues(asi1.getM_AttributeSetInstance_ID()).get();
final I_MD_Cockpit cockpitRecordWithAttributes = newInstance(I_MD_Cockpit.class);
cockpitRecordWithAttributes.setM_Product(product);
cockpitRecordWithAttributes.setDateGeneral(SystemTime.asTimestamp());
cockpitRecordWithAttributes.setAttributesKey(attributesKeyWithAttr1_and_attr2.getAsString());
cockpitRecordWithAttributes.setQtyReserved_Purchase(TEN);
save(cockpitRecordWithAttributes);
final AttributesKey attributesKey2 = AttributesKey.NONE;
final I_MD_Cockpit cockpitRecordWithEmptyAttributesKey = newInstance(I_MD_Cockpit.class);
cockpitRecordWithEmptyAttributesKey.setM_Product(product);
cockpitRecordWithEmptyAttributesKey.setDateGeneral(SystemTime.asTimestamp());
cockpitRecordWithEmptyAttributesKey.setAttributesKey(attributesKey2.getAsString());
cockpitRecordWithEmptyAttributesKey.setQtyReserved_Purchase(ONE);
save(cockpitRecordWithEmptyAttributesKey);
final I_M_Warehouse warehouseWithPlant = createWarehousewithPlant("plantName");
final I_MD_Stock stockRecordWithAttributes = newInstance(I_MD_Stock.class);
stockRecordWithAttributes.setM_Product(product);
stockRecordWithAttributes.setAttributesKey(attributesKeyWithAttr1_and_attr2.getAsString());
stockRecordWithAttributes.setM_Warehouse(warehouseWithPlant);
stockRecordWithAttributes.setQtyOnHand(ELEVEN);
save(stockRecordWithAttributes);
final I_MD_Stock stockRecordWithEmptyAttributesKey = newInstance(I_MD_Stock.class);
stockRecordWithEmptyAttributesKey.setM_Product(product);
stockRecordWithEmptyAttributesKey.setAttributesKey(attributesKey2.getAsString());
stockRecordWithEmptyAttributesKey.setM_Warehouse(warehouseWithPlant);
stockRecordWithEmptyAttributesKey.setQtyOnHand(TWELVE);
save(stockRecordWithEmptyAttributesKey);
final Timestamp today = TimeUtil.getDay(SystemTime.asTimestamp());
final CreateRowsRequest request = CreateRowsRequest.builder().date(today).productsToListEvenIfEmpty(ImmutableList.of()).cockpitRecords(ImmutableList.of(cockpitRecordWithAttributes, cockpitRecordWithEmptyAttributesKey)).stockRecords(ImmutableList.of(stockRecordWithAttributes, stockRecordWithEmptyAttributesKey)).build();
// invoke method under test
final List<MaterialCockpitRow> result = materialCockpitRowFactory.createRows(request);
assertThat(result).hasSize(1);
final MaterialCockpitRow mainRow = result.get(0);
assertThat(mainRow.getQtyOnHandStock()).isEqualByComparingTo(ELEVEN.add(TWELVE));
assertThat(mainRow.getQtyReservedPurchase()).isEqualByComparingTo(TEN.add(ONE));
final List<MaterialCockpitRow> includedRows = mainRow.getIncludedRows();
// there shall be 4 rows:
// 2: the cockpitRecordWithAttributes and stockRecordWithAttributes are added to the matching non-empty groups of the dimension spec
// 1: the cockpit and stock record with the empty attributesKey is added to the empty dimension spec group
// 1: both stock records are added to a counting record
assertThat(includedRows).hasSize(4);
final MaterialCockpitRow emptyGroupRow = extractRowWithDimensionSpecGroup(includedRows, dimensionspecGroup_empty);
assertThat(emptyGroupRow.getQtyOnHandStock()).isEqualByComparingTo(TWELVE);
assertThat(emptyGroupRow.getQtyReservedPurchase()).isEqualByComparingTo(ONE);
final MaterialCockpitRow attr1GroupRow = extractRowWithDimensionSpecGroup(includedRows, dimensionspecGroup_attr1_value1);
assertThat(attr1GroupRow.getQtyOnHandStock()).isEqualByComparingTo(ELEVEN);
assertThat(attr1GroupRow.getQtyReservedPurchase()).isEqualByComparingTo(TEN);
final MaterialCockpitRow attr2GroupRow = extractRowWithDimensionSpecGroup(includedRows, dimensionspecGroup_attr2_value1);
assertThat(attr2GroupRow.getQtyOnHandStock()).isEqualByComparingTo(ELEVEN);
assertThat(attr2GroupRow.getQtyReservedPurchase()).isEqualByComparingTo(TEN);
final MaterialCockpitRow countingRow = extractSingleCountingRow(includedRows);
assertThat(countingRow.getQtyOnHandStock()).isEqualByComparingTo(ELEVEN.add(TWELVE));
assertThat(countingRow.getProductCategoryOrSubRowName()).isEqualTo("plantName");
}
use of org.compiere.model.I_M_AttributeSetInstance in project metasfresh-webui-api by metasfresh.
the class ASIDocument method createM_AttributeSetInstance.
private static final I_M_AttributeSetInstance createM_AttributeSetInstance(final ASIDocument asiDoc) {
//
// Create M_AttributeSetInstance
final int attributeSetId = asiDoc.getM_AttributeSet_ID();
final I_M_AttributeSetInstance asiRecord = InterfaceWrapperHelper.create(Env.getCtx(), I_M_AttributeSetInstance.class, ITrx.TRXNAME_ThreadInherited);
asiRecord.setM_AttributeSet_ID(attributeSetId);
// TODO: set Lot, GuaranteeDate etc
InterfaceWrapperHelper.save(asiRecord);
//
// Create M_AttributeInstances
asiDoc.getFieldViews().stream().forEach(asiField -> asiField.getDescriptor().getDataBindingNotNull(ASIAttributeFieldBinding.class).createAndSaveM_AttributeInstance(asiRecord, asiField));
//
// Update the ASI description
Services.get(IAttributeSetInstanceBL.class).setDescription(asiRecord);
InterfaceWrapperHelper.save(asiRecord);
return asiRecord;
}
use of org.compiere.model.I_M_AttributeSetInstance in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputProcessor method createASI.
private static final int createASI(final ProductAndAttributes productAndAttributes) {
final ImmutableAttributeSet attributes = productAndAttributes.getAttributes();
if (attributes.isEmpty()) {
return -1;
}
final IAttributeSetInstanceBL asiBL = Services.get(IAttributeSetInstanceBL.class);
final I_M_AttributeSetInstance asi = asiBL.createASIWithASFromProductAndInsertAttributeSet(productAndAttributes.getProductId(), attributes);
return asi.getM_AttributeSetInstance_ID();
}
Aggregations