Skip to content

Commit

Permalink
Remettre les article dans le stock apres un paiement expiré #17 - fix…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
benjaminpochat committed Jul 3, 2024
1 parent 9a31690 commit 33d492c
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ public class PackageLotQuantitySoldService {
PackageLotRepository packageLotRepository;

public void updateQuantitySold(PackageLot packageLot) {
int quantitySold = orderItemRepository.findByPackageLot(packageLot).stream()
var packageLotLoaded = packageLotRepository.findById(packageLot.getId()).get();
int quantitySold = orderItemRepository.findByPackageLot(packageLotLoaded).stream()
.filter(orderItem -> List.of(PAYMENT_COMPLETED, PAYMENT_PENDING, BOOKED_WITHOUT_PAYMENT, DELIVERED).contains(orderItem.getOrder().getStatus()))
.mapToInt(OrderItem::getQuantity)
.sum();
packageLot.setQuantitySold(quantitySold);
packageLotRepository.save(packageLot);
packageLotLoaded.setQuantitySold(quantitySold);
packageLotRepository.save(packageLotLoaded);
}
}

0 comments on commit 33d492c

Please sign in to comment.