Skip to content

Commit

Permalink
fix(product stock response): product stock quantity was not updated
Browse files Browse the repository at this point in the history
update was not working due to messing up parameter order in partner product stock retrieval
  • Loading branch information
tom-rm-meyer-ISST committed Aug 2, 2023
1 parent 03cd94e commit 13151e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public interface PartnerProductStockService {

PartnerProductStock update(PartnerProductStock partnerProductStock);

List<PartnerProductStock> findAllByMaterialUuidAndPartnerUuid(UUID partnerUuid,
UUID materialUuid);
List<PartnerProductStock> findAllByMaterialUuidAndPartnerUuid(UUID materialUuid,
UUID partnerUuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public PartnerProductStock update(PartnerProductStock partnerProductStock) {
}

@Override
public List<PartnerProductStock> findAllByMaterialUuidAndPartnerUuid(UUID partnerUuid, UUID materialUuid) {
public List<PartnerProductStock> findAllByMaterialUuidAndPartnerUuid(UUID materialUuid, UUID partnerUuid) {
return partnerProductStockRepository.findAllByMaterial_UuidAndTypeAndSupplierPartner_Uuid(materialUuid, DT_StockTypeEnum.PRODUCT, partnerUuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public void consumeResponse(ResponseDto responseDto) {
// or whether an update is sufficient.
List<PartnerProductStock> existingPartnerProductStocks =
partnerProductStockService.findAllByMaterialUuidAndPartnerUuid(
partnerProductStockDto.getSupplierPartner().getUuid(),
partnerProductStockDto.getMaterial().getUuid()
);
partnerProductStockDto.getMaterial().getUuid(),
partnerProductStockDto.getSupplierPartner().getUuid()
);

// currently we only accept a one to one mapping of partner - material - stock -site
// therefore the can only be one PartnerProductStock
Expand All @@ -104,8 +104,12 @@ public void consumeResponse(ResponseDto responseDto) {
log.info(String.format("Created Partner ProductStock from SAMM: %s",
createdPartnerProductStock));
} else {
// update quantity only
PartnerProductStock existingPartnerProductStock = existingPartnerProductStocks.get(0);
existingPartnerProductStock.setQuantity(partnerProductStockDto.getQuantity());

PartnerProductStock updatedPartnerProductStock =
partnerProductStockService.update(existingPartnerProductStocks.get(0));
partnerProductStockService.update(existingPartnerProductStock);
log.info(String.format("Updated Partner ProductStock from SAMM: %s",
updatedPartnerProductStock));
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/StockView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ export default {
methods: {
addOrUpdateStock(changedStock) {
if (changedStock.type === "Material") {
var existingMaterialStock = this.bdMaterialStocks.filter(
var existingMaterialStocks = this.bdMaterialStocks.filter(
(stock) => (stock.material.uuid === changedStock.materialId)
);
if (existingMaterialStock.length === 1) { // Update existing material stock
var existingMaterialStock = existingMaterialStock[0];
if (existingMaterialStocks.length === 1) { // Update existing material stock
var existingMaterialStock = existingMaterialStocks[0];
existingMaterialStock.quantity = changedStock.quantity;
this.putData(this.backendURL + this.endpointMaterialStocks, existingMaterialStock);
Expand Down

0 comments on commit 13151e9

Please sign in to comment.