Arytmetyka na stream

0

Hej,

mam dwie encje
dokument

public class Document {
    @Id
    Integer id;
    // some another fields
    Set<Position> positions = new HashSet<>();

    @Transient
    public BigDecimal getPoints() {
        return positions.stream()
                .map(Position::getPoints)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
    }
}

jego pozycje

public class Position {
    @Id
    String id;
    @Column(name = "document_id")
    int documentId;
    String skuGroup;
    BigDecimal converter;
    BigDecimal netAmount;
    BigDecimal points;
}

metodą getPoints() sumuję po prostu "points" dla każdego dokumentu.
Potrzebuję zrobić kolejną metodę, która:

  • zsumuje netAmount dla każdego skuGroup
  • przemnoży razy converter ( taki sam dla danego skuGroup )
  • zsumuje powyższe
1

W czym konkretnie jest problem? Co nie działa?

1 użytkowników online, w tym zalogowanych: 0, gości: 1