diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapper.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapper.java index bb3097ca..05119dbf 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapper.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapper.java @@ -122,6 +122,10 @@ public List itemStockSammToReportedProductItemStock(It return outputList; } + // When deserializing a Samm from a customer, who has sent a report on the + // stocks he received from us, the materialGlobalAssetId used in the communication + // was set by us (as the supplying side). Therefore the materialGlobalAssetId in + // the Samm is the one in our Material entity. Material material = materialService.findByMaterialNumberCx(matNbrCatenaX); if (material == null) { log.warn("Could not identify materialPartnerRelation with matNbrCatenaX " + matNbrCatenaX + " and partner bpnl " + partner.getBpnl()); @@ -130,8 +134,6 @@ public List itemStockSammToReportedProductItemStock(It var mpr = mprService.find(material, partner); - - for (var position : samm.getPositions()) { String supplierOrderId = null, customerOrderPositionId = null, customerOrderId = null; if (position.getOrderPositionReference() != null) { @@ -173,13 +175,16 @@ public List itemStockSammToReportedMaterialItemStock( log.warn("Could not identify materialPartnerRelation with matNbrCatenaX " + matNbrCatenaX + " and partner bpnl " + partner.getBpnl()); return outputList; } + // When deserializing a Samm from a supplier, who has sent a report on the + // stocks he has prepared for us, the materialGlobalAssetId used in the communication + // was set by the supplying partner. Therefore the materialGlobalAssetId in + // the Samm is the one in our MaterialPartnerRelation entity with that partner. Material material = mpr.getMaterial(); if (material == null) { log.warn("Could not identify material with CatenaXNbr " + matNbrCatenaX); return outputList; } - for (var position : samm.getPositions()) { String supplierOrderId = null, customerOrderPositionId = null, customerOrderId = null; if (position.getOrderPositionReference() != null) { diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapperTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapperTest.java index ab1066de..a161adad 100644 --- a/backend/src/test/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapperTest.java +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapperTest.java @@ -392,7 +392,6 @@ void test_unmarshalling() { mpr.setPartnerMaterialNumber(CUSTOMER_MAT_NUMBER); mpr.setPartnerCXNumber(CX_MAT_NUMBER); -// when(mprService.findByPartnerAndPartnerCXNumber(customerPartner, CX_MAT_NUMBER)).thenReturn(mpr); when(materialService.findByMaterialNumberCx(CX_MAT_NUMBER)).thenReturn(material); when(mprService.find(material, customerPartner)).thenReturn(mpr);