hs-office-coopshares: use only membership uuid in filter
This commit is contained in:
parent
5764accbc5
commit
ca0589d084
@ -40,14 +40,13 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
|
|||||||
final String currentUser,
|
final String currentUser,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final UUID membershipUuid,
|
final UUID membershipUuid,
|
||||||
Integer memberNumber, // TODO: remove
|
|
||||||
final @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromValueDate,
|
final @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromValueDate,
|
||||||
final @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toValueDate) {
|
final @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toValueDate) {
|
||||||
context.define(currentUser, assumedRoles);
|
context.define(currentUser, assumedRoles);
|
||||||
|
|
||||||
|
|
||||||
final var entities = coopSharesTransactionRepo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(
|
final var entities = coopSharesTransactionRepo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(
|
||||||
memberNumber,
|
membershipUuid,
|
||||||
fromValueDate,
|
fromValueDate,
|
||||||
toValueDate);
|
toValueDate);
|
||||||
|
|
||||||
|
@ -14,13 +14,13 @@ public interface HsOfficeCoopSharesTransactionRepository extends Repository<HsOf
|
|||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
SELECT st FROM HsOfficeCoopSharesTransactionEntity st
|
SELECT st FROM HsOfficeCoopSharesTransactionEntity st
|
||||||
WHERE (:memberNumber IS NULL OR st.membership.memberNumber = :memberNumber)
|
WHERE ( CAST(:membershipUuid AS org.hibernate.type.UUIDCharType) IS NULL OR st.membership.uuid = :membershipUuid)
|
||||||
AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (st.valueDate >= :fromValueDate))
|
AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (st.valueDate >= :fromValueDate))
|
||||||
AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (st.valueDate <= :toValueDate))
|
AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (st.valueDate <= :toValueDate))
|
||||||
ORDER BY st.membership.memberNumber, st.valueDate
|
ORDER BY st.membership.memberNumber, st.valueDate
|
||||||
""")
|
""")
|
||||||
List<HsOfficeCoopSharesTransactionEntity> findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(
|
List<HsOfficeCoopSharesTransactionEntity> findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(
|
||||||
Integer memberNumber, LocalDate fromValueDate, LocalDate toValueDate);
|
UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate);
|
||||||
|
|
||||||
HsOfficeCoopSharesTransactionEntity save(final HsOfficeCoopSharesTransactionEntity entity);
|
HsOfficeCoopSharesTransactionEntity save(final HsOfficeCoopSharesTransactionEntity entity);
|
||||||
|
|
||||||
|
@ -14,12 +14,6 @@ get:
|
|||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
description: Optional UUID of the related membership.
|
description: Optional UUID of the related membership.
|
||||||
- name: memberNumber
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
description: Optional member number of the related membership.
|
|
||||||
- name: fromValueDate
|
- name: fromValueDate
|
||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
|
@ -75,12 +75,16 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
|
|||||||
@Test
|
@Test
|
||||||
void globalAdmin_canFindCoopSharesTransactionsByMemberNumber() {
|
void globalAdmin_canFindCoopSharesTransactionsByMemberNumber() {
|
||||||
|
|
||||||
|
context.define("superuser-alex@hostsharing.net");
|
||||||
|
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
|
||||||
|
.get(0);
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/office/coopsharestransactions?memberNumber=10002")
|
.get("http://localhost/api/hs/office/coopsharestransactions?membershipUuid="+givenMembership.getUuid())
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
@ -114,12 +118,17 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
|
|||||||
@Test
|
@Test
|
||||||
void globalAdmin_canFindCoopSharesTransactionsByMemberNumberAndDateRange() {
|
void globalAdmin_canFindCoopSharesTransactionsByMemberNumberAndDateRange() {
|
||||||
|
|
||||||
|
context.define("superuser-alex@hostsharing.net");
|
||||||
|
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
|
||||||
|
.get(0);
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/office/coopsharestransactions?memberNumber=10002&fromValueDate=2020-01-01&toValueDate=2021-12-31")
|
.get("http://localhost/api/hs/office/coopsharestransactions?membershipUuid="
|
||||||
|
+ givenMembership.getUuid() + "&fromValueDate=2020-01-01&toValueDate=2021-12-31")
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
|
@ -134,7 +134,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
|||||||
class FindAllCoopSharesTransactions {
|
class FindAllCoopSharesTransactions {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void globalAdmin_withoutAssumedRole_canViewAllCoopSharesTransactions() {
|
public void globalAdmin_anViewAllCoopSharesTransactions() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
|
|
||||||
@ -160,6 +160,44 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
|||||||
"CoopShareTransaction(10003, 2022-10-20, CANCELLATION, 12, ref 10003-3)");
|
"CoopShareTransaction(10003, 2022-10-20, CANCELLATION, 12, ref 10003-3)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void globalAdmin_canViewCoopSharesTransactions_filteredByMembershipUuid() {
|
||||||
|
// given
|
||||||
|
context("superuser-alex@hostsharing.net");
|
||||||
|
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002).get(0);
|
||||||
|
|
||||||
|
// when
|
||||||
|
final var result = coopSharesTransactionRepo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(
|
||||||
|
givenMembership.getUuid(),
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// then
|
||||||
|
allTheseCoopSharesTransactionsAreReturned(
|
||||||
|
result,
|
||||||
|
"CoopShareTransaction(10002, 2010-03-15, SUBSCRIPTION, 2, ref 10002-1)",
|
||||||
|
"CoopShareTransaction(10002, 2021-09-01, SUBSCRIPTION, 24, ref 10002-2)",
|
||||||
|
"CoopShareTransaction(10002, 2022-10-20, CANCELLATION, 12, ref 10002-3)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void globalAdmin_canViewCoopSharesTransactions_filteredByMembershipUuidAndValueDateRange() {
|
||||||
|
// given
|
||||||
|
context("superuser-alex@hostsharing.net");
|
||||||
|
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002).get(0);
|
||||||
|
|
||||||
|
// when
|
||||||
|
final var result = coopSharesTransactionRepo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(
|
||||||
|
givenMembership.getUuid(),
|
||||||
|
LocalDate.parse("2021-09-01"),
|
||||||
|
LocalDate.parse("2021-09-01"));
|
||||||
|
|
||||||
|
// then
|
||||||
|
allTheseCoopSharesTransactionsAreReturned(
|
||||||
|
result,
|
||||||
|
"CoopShareTransaction(10002, 2021-09-01, SUBSCRIPTION, 24, ref 10002-2)");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void normalUser_canViewOnlyRelatedCoopSharesTransactions() {
|
public void normalUser_canViewOnlyRelatedCoopSharesTransactions() {
|
||||||
// given:
|
// given:
|
||||||
|
Loading…
Reference in New Issue
Block a user