memberNumber as partnerNumber+memberNumberSuffix #13
@ -41,11 +41,10 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
|
||||
final String currentUser,
|
||||
final String assumedRoles,
|
||||
UUID partnerUuid,
|
||||
Integer memberNumberSuffix) {
|
||||
Integer memberNumber) {
|
||||
context.define(currentUser, assumedRoles);
|
||||
|
||||
final var entities =
|
||||
membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(partnerUuid, memberNumberSuffix);
|
||||
final var entities = membershipRepo.findMembershipsByOptionalPartherNumber(partnerUuid);
|
||||
|
||||
final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class,
|
||||
SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER);
|
||||
|
@ -31,7 +31,7 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
||||
public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
|
||||
|
||||
private static Stringify<HsOfficeMembershipEntity> stringify = stringify(HsOfficeMembershipEntity.class)
|
||||
.withProp(HsOfficeMembershipEntity::getMemberNumberSuffix)
|
||||
.withProp(e -> e.getPartner().getPartnerNumber() + e.memberNumberSuffix)
|
||||
.withProp(e -> e.getPartner().toShortString())
|
||||
.withProp(e -> e.getMainDebitor().toShortString())
|
||||
.withProp(e -> e.getValidity().asString())
|
||||
@ -52,8 +52,8 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
|
||||
@JoinColumn(name = "maindebitoruuid")
|
||||
private HsOfficeDebitorEntity mainDebitor;
|
||||
|
||||
@Column(name = "membernumbersuffix")
|
||||
private int memberNumberSuffix;
|
||||
@Column(name = "membernumbersuffix", length = 2)
|
||||
private String memberNumberSuffix;
|
||||
|
||||
@Column(name = "validity", columnDefinition = "daterange")
|
||||
@Type(PostgreSQLRangeType.class)
|
||||
@ -98,7 +98,7 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
|
||||
|
||||
@Override
|
||||
public String toShortString() {
|
||||
return String.valueOf(memberNumberSuffix);
|
||||
return partner.getPartnerNumber() + String.valueOf(memberNumberSuffix);
|
||||
}
|
||||
|
||||
@PrePersist
|
||||
|
@ -3,6 +3,7 @@ package net.hostsharing.hsadminng.hs.office.membership;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -11,16 +12,30 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
|
||||
|
||||
Optional<HsOfficeMembershipEntity> findByUuid(UUID id);
|
||||
|
||||
HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity);
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT membership FROM HsOfficeMembershipEntity membership
|
||||
WHERE (:memberNumberSuffix is null OR membership.memberNumberSuffix = :memberNumberSuffix)
|
||||
AND ( CAST(:partnerUuid as org.hibernate.type.UUIDCharType) IS NULL
|
||||
WHERE ( CAST(:partnerUuid as org.hibernate.type.UUIDCharType) IS NULL
|
||||
OR membership.partner.uuid = :partnerUuid )
|
||||
ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix
|
||||
""")
|
||||
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartherNumber(UUID partnerUuid);
|
||||
@Query("""
|
||||
SELECT membership FROM HsOfficeMembershipEntity membership
|
||||
WHERE (:partnerNumber = membership.partner.partnerNumber)
|
||||
AND (membership.memberNumberSuffix = :suffix)
|
||||
ORDER BY membership.memberNumberSuffix
|
||||
""")
|
||||
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(UUID partnerUuid, Integer memberNumberSuffix);
|
||||
|
||||
HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity);
|
||||
List<HsOfficeMembershipEntity> findMembershipsByPartnerNumberAndSuffix(
|
||||
@NotNull Integer partnerNumber,
|
||||
@NotNull String suffix);
|
||||
default List<HsOfficeMembershipEntity> findMembershipsByMemberNumber(Integer memberNumber) {
|
||||
final var partnerNumber = memberNumber / 100;
|
||||
final var suffix = memberNumber % 100;
|
||||
return findMembershipsByPartnerNumberAndSuffix(partnerNumber, String.format("%02d", suffix));
|
||||
}
|
||||
|
||||
long count();
|
||||
|
||||
|
@ -32,7 +32,7 @@ call create_journal('hs_office_partner_details');
|
||||
create table hs_office_partner
|
||||
(
|
||||
uuid uuid unique references RbacObject (uuid) initially deferred,
|
||||
partnerNumber varchar(5),
|
||||
partnerNumber numeric(5),
|
||||
personUuid uuid not null references hs_office_person(uuid),
|
||||
contactUuid uuid not null references hs_office_contact(uuid),
|
||||
detailsUuid uuid not null references hs_office_partner_details(uuid) on delete cascade
|
||||
|
@ -13,7 +13,8 @@ create table if not exists hs_office_membership
|
||||
uuid uuid unique references RbacObject (uuid) initially deferred,
|
||||
partnerUuid uuid not null references hs_office_partner(uuid),
|
||||
mainDebitorUuid uuid not null references hs_office_debitor(uuid),
|
||||
memberNumberSuffix numeric(5) not null unique,
|
||||
memberNumberSuffix char(2) not null check (
|
||||
hsh-michaelhoennig marked this conversation as resolved
|
||||
memberNumberSuffix::text ~ '^[0-9][0-9]$'),
|
||||
validity daterange not null,
|
||||
reasonForTermination HsOfficeReasonForTermination not null default 'NONE',
|
||||
membershipFeeBillable boolean not null default true
|
||||
|
@ -8,16 +8,18 @@
|
||||
/*
|
||||
Creates a single membership test record.
|
||||
*/
|
||||
create or replace procedure createHsOfficeMembershipTestData( forPartnerTradeName varchar, forMainDebitorNumber numeric )
|
||||
create or replace procedure createHsOfficeMembershipTestData(
|
||||
forPartnerTradeName varchar,
|
||||
forMainDebitorNumberSuffix numeric,
|
||||
newMemberNumberSuffix char(2) )
|
||||
language plpgsql as $$
|
||||
declare
|
||||
currentTask varchar;
|
||||
idName varchar;
|
||||
relatedPartner hs_office_partner;
|
||||
relatedDebitor hs_office_debitor;
|
||||
newMemberNumberSuffix numeric;
|
||||
begin
|
||||
idName := cleanIdentifier( forPartnerTradeName || '#' || forMainDebitorNumber);
|
||||
idName := cleanIdentifier( forPartnerTradeName || '#' || forMainDebitorNumberSuffix);
|
||||
currentTask := 'creating Membership test-data ' || idName;
|
||||
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global.admin');
|
||||
execute format('set local hsadminng.currentTask to %L', currentTask);
|
||||
@ -25,8 +27,10 @@ begin
|
||||
select partner.* from hs_office_partner partner
|
||||
join hs_office_person person on person.uuid = partner.personUuid
|
||||
where person.tradeName = forPartnerTradeName into relatedPartner;
|
||||
select d.* from hs_office_debitor d where d.debitorNumberSuffix = forMainDebitorNumber into relatedDebitor;
|
||||
select coalesce(max(memberNumberSuffix)+1, 10001) from hs_office_membership into newMemberNumberSuffix;
|
||||
select d.* from hs_office_debitor d
|
||||
where d.partneruuid = relatedPartner.uuid
|
||||
and d.debitorNumberSuffix = forMainDebitorNumberSuffix
|
||||
into relatedDebitor;
|
||||
|
||||
raise notice 'creating test Membership: %', idName;
|
||||
raise notice '- using partner (%): %', relatedPartner.uuid, relatedPartner;
|
||||
@ -44,9 +48,9 @@ end; $$;
|
||||
|
||||
do language plpgsql $$
|
||||
begin
|
||||
call createHsOfficeMembershipTestData('First GmbH', 11);
|
||||
call createHsOfficeMembershipTestData('Second e.K.', 12);
|
||||
call createHsOfficeMembershipTestData('Third OHG', 13);
|
||||
call createHsOfficeMembershipTestData('First GmbH', 11, '01');
|
||||
call createHsOfficeMembershipTestData('Second e.K.', 12, '02');
|
||||
call createHsOfficeMembershipTestData('Third OHG', 13, '03');
|
||||
end;
|
||||
$$;
|
||||
--//
|
||||
|
@ -8,25 +8,33 @@
|
||||
/*
|
||||
Creates a single coopSharesTransaction test record.
|
||||
*/
|
||||
create or replace procedure createHsOfficeCoopSharesTransactionTestData(givenMembershipNumber numeric)
|
||||
create or replace procedure createHsOfficeCoopSharesTransactionTestData(
|
||||
givenPartnerNumber numeric,
|
||||
givenMemberNumberSuffix varchar -- TODO char(2)?
|
||||
)
|
||||
language plpgsql as $$
|
||||
declare
|
||||
currentTask varchar;
|
||||
membership hs_office_membership;
|
||||
begin
|
||||
currentTask = 'creating coopSharesTransaction test-data ' || givenMembershipNumber;
|
||||
currentTask = 'creating coopSharesTransaction test-data ' || givenPartnerNumber::text || givenMemberNumberSuffix;
|
||||
execute format('set local hsadminng.currentTask to %L', currentTask);
|
||||
|
||||
call defineContext(currentTask);
|
||||
select m.uuid from hs_office_membership m where m.memberNumberSuffix = givenMembershipNumber into membership;
|
||||
select m.uuid
|
||||
from hs_office_membership m
|
||||
join hs_office_partner p on p.uuid = m.partneruuid
|
||||
where p.partnerNumber = givenPartnerNumber
|
||||
and m.memberNumberSuffix = givenMemberNumberSuffix
|
||||
into membership;
|
||||
|
||||
raise notice 'creating test coopSharesTransaction: %', givenMembershipNumber;
|
||||
raise notice 'creating test coopSharesTransaction: %', givenPartnerNumber::text || givenMemberNumberSuffix;
|
||||
insert
|
||||
into hs_office_coopsharestransaction(uuid, membershipuuid, transactiontype, valuedate, sharecount, reference, comment)
|
||||
values
|
||||
(uuid_generate_v4(), membership.uuid, 'SUBSCRIPTION', '2010-03-15', 4, 'ref '||givenMembershipNumber||'-1', 'initial subscription'),
|
||||
(uuid_generate_v4(), membership.uuid, 'CANCELLATION', '2021-09-01', -2, 'ref '||givenMembershipNumber||'-2', 'cancelling some'),
|
||||
(uuid_generate_v4(), membership.uuid, 'ADJUSTMENT', '2022-10-20', 2, 'ref '||givenMembershipNumber||'-3', 'some adjustment');
|
||||
(uuid_generate_v4(), membership.uuid, 'SUBSCRIPTION', '2010-03-15', 4, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-1', 'initial subscription'),
|
||||
(uuid_generate_v4(), membership.uuid, 'CANCELLATION', '2021-09-01', -2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-2', 'cancelling some'),
|
||||
(uuid_generate_v4(), membership.uuid, 'ADJUSTMENT', '2022-10-20', 2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-3', 'some adjustment');
|
||||
end; $$;
|
||||
--//
|
||||
|
||||
@ -37,8 +45,8 @@ end; $$;
|
||||
|
||||
do language plpgsql $$
|
||||
begin
|
||||
call createHsOfficeCoopSharesTransactionTestData(10001);
|
||||
call createHsOfficeCoopSharesTransactionTestData(10002);
|
||||
call createHsOfficeCoopSharesTransactionTestData(10003);
|
||||
call createHsOfficeCoopSharesTransactionTestData(10001, '01');
|
||||
call createHsOfficeCoopSharesTransactionTestData(10002, '02');
|
||||
call createHsOfficeCoopSharesTransactionTestData(10003, '03');
|
||||
end;
|
||||
$$;
|
||||
|
@ -8,25 +8,33 @@
|
||||
/*
|
||||
Creates a single coopAssetsTransaction test record.
|
||||
*/
|
||||
create or replace procedure createHsOfficeCoopAssetsTransactionTestData(givenMembershipNumber numeric)
|
||||
create or replace procedure createHsOfficeCoopAssetsTransactionTestData(
|
||||
givenPartnerNumber numeric,
|
||||
givenMemberNumberSuffix char(2)
|
||||
)
|
||||
language plpgsql as $$
|
||||
declare
|
||||
currentTask varchar;
|
||||
membership hs_office_membership;
|
||||
begin
|
||||
currentTask = 'creating coopAssetsTransaction test-data ' || givenMembershipNumber;
|
||||
currentTask = 'creating coopAssetsTransaction test-data ' || givenPartnerNumber || givenMemberNumberSuffix;
|
||||
execute format('set local hsadminng.currentTask to %L', currentTask);
|
||||
|
||||
call defineContext(currentTask);
|
||||
select m.uuid from hs_office_membership m where m.memberNumberSuffix = givenMembershipNumber into membership;
|
||||
select m.uuid
|
||||
from hs_office_membership m
|
||||
join hs_office_partner p on p.uuid = m.partneruuid
|
||||
where p.partnerNumber = givenPartnerNumber
|
||||
and m.memberNumberSuffix = givenMemberNumberSuffix
|
||||
into membership;
|
||||
|
||||
raise notice 'creating test coopAssetsTransaction: %', givenMembershipNumber;
|
||||
raise notice 'creating test coopAssetsTransaction: %', givenPartnerNumber || givenMemberNumberSuffix;
|
||||
insert
|
||||
into hs_office_coopassetstransaction(uuid, membershipuuid, transactiontype, valuedate, assetvalue, reference, comment)
|
||||
values
|
||||
(uuid_generate_v4(), membership.uuid, 'DEPOSIT', '2010-03-15', 320.00, 'ref '||givenMembershipNumber||'-1', 'initial deposit'),
|
||||
(uuid_generate_v4(), membership.uuid, 'DISBURSAL', '2021-09-01', -128.00, 'ref '||givenMembershipNumber||'-2', 'partial disbursal'),
|
||||
(uuid_generate_v4(), membership.uuid, 'ADJUSTMENT', '2022-10-20', 128.00, 'ref '||givenMembershipNumber||'-3', 'some adjustment');
|
||||
(uuid_generate_v4(), membership.uuid, 'DEPOSIT', '2010-03-15', 320.00, 'ref '||givenPartnerNumber || givenMemberNumberSuffix||'-1', 'initial deposit'),
|
||||
(uuid_generate_v4(), membership.uuid, 'DISBURSAL', '2021-09-01', -128.00, 'ref '||givenPartnerNumber || givenMemberNumberSuffix||'-2', 'partial disbursal'),
|
||||
(uuid_generate_v4(), membership.uuid, 'ADJUSTMENT', '2022-10-20', 128.00, 'ref '||givenPartnerNumber || givenMemberNumberSuffix||'-3', 'some adjustment');
|
||||
end; $$;
|
||||
--//
|
||||
|
||||
@ -37,8 +45,8 @@ end; $$;
|
||||
|
||||
do language plpgsql $$
|
||||
begin
|
||||
call createHsOfficeCoopAssetsTransactionTestData(10001);
|
||||
call createHsOfficeCoopAssetsTransactionTestData(10002);
|
||||
call createHsOfficeCoopAssetsTransactionTestData(10003);
|
||||
call createHsOfficeCoopAssetsTransactionTestData(10001, '01');
|
||||
call createHsOfficeCoopAssetsTransactionTestData(10002, '02');
|
||||
call createHsOfficeCoopAssetsTransactionTestData(10003, '03');
|
||||
end;
|
||||
$$;
|
||||
|
@ -75,7 +75,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
|
||||
void globalAdmin_canFindCoopAssetsTransactionsByMemberNumberSuffix() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000202)
|
||||
.get(0);
|
||||
|
||||
RestAssured // @formatter:off
|
||||
@ -118,7 +118,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
|
||||
void globalAdmin_canFindCoopAssetsTransactionsByMemberNumberSuffixAndDateRange() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000202)
|
||||
.get(0);
|
||||
|
||||
RestAssured // @formatter:off
|
||||
@ -153,7 +153,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
|
||||
void globalAdmin_canAddCoopAssetsTransaction() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000101)
|
||||
.get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
@ -199,7 +199,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
|
||||
void globalAdmin_canNotCancelMoreAssetsThanCurrentlySubscribed() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000101)
|
||||
.get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
|
@ -62,7 +62,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var count = coopAssetsTransactionRepo.count();
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000101)
|
||||
.get(0);
|
||||
|
||||
// when
|
||||
@ -96,9 +96,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
|
||||
|
||||
// when
|
||||
attempt(em, () -> {
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
|
||||
null,
|
||||
10001).get(0);
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000101).get(0);
|
||||
final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
|
||||
.membership(givenMembership)
|
||||
.transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT)
|
||||
@ -161,8 +159,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
|
||||
public void globalAdmin_canViewCoopAssetsTransactions_filteredByMembershipUuid() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
|
||||
.get(0);
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(null).get(1000202);
|
||||
|
||||
// when
|
||||
final var result = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
|
||||
@ -182,7 +179,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
|
||||
public void globalAdmin_canViewCoopAssetsTransactions_filteredByMembershipUuidAndValueDateRange() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000202)
|
||||
.get(0);
|
||||
|
||||
// when
|
||||
|
@ -75,7 +75,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
|
||||
void globalAdmin_canFindCoopSharesTransactionsByMemberNumberSuffix() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002).get(0);
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000202).get(0);
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given().header("current-user", "superuser-alex@hostsharing.net").port(port).when().get("http://localhost/api/hs/office/coopsharestransactions?membershipUuid=" + givenMembership.getUuid()).then().log().all().assertThat().statusCode(200).contentType("application/json").body("", lenientlyEquals("""
|
||||
@ -109,7 +109,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
|
||||
void globalAdmin_canFindCoopSharesTransactionsByMemberNumberSuffixAndDateRange() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002).get(0);
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000202).get(0);
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given().header("current-user", "superuser-alex@hostsharing.net").port(port).when().get("http://localhost/api/hs/office/coopsharestransactions?membershipUuid=" + givenMembership.getUuid() + "&fromValueDate=2020-01-01&toValueDate=2021-12-31").then().log().all().assertThat().statusCode(200).contentType("application/json").body("", lenientlyEquals("""
|
||||
@ -134,7 +134,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
|
||||
void globalAdmin_canAddCoopSharesTransaction() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001).get(0);
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000101).get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given().header("current-user", "superuser-alex@hostsharing.net").contentType(ContentType.JSON).body("""
|
||||
@ -165,7 +165,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
|
||||
void globalAdmin_canNotCancelMoreSharesThanCurrentlySubscribed() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001).get(0);
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000101).get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given().header("current-user", "superuser-alex@hostsharing.net").contentType(ContentType.JSON).body("""
|
||||
|
@ -61,7 +61,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var count = coopSharesTransactionRepo.count();
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000101)
|
||||
.get(0);
|
||||
|
||||
// when
|
||||
@ -95,9 +95,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
||||
|
||||
// when
|
||||
attempt(em, () -> {
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
|
||||
null,
|
||||
10001).get(0);
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000101)
|
||||
.get(0);
|
||||
final var newCoopSharesTransaction = HsOfficeCoopSharesTransactionEntity.builder()
|
||||
.membership(givenMembership)
|
||||
.transactionType(HsOfficeCoopSharesTransactionType.SUBSCRIPTION)
|
||||
@ -160,7 +159,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
||||
public void globalAdmin_canViewCoopSharesTransactions_filteredByMembershipUuid() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000202)
|
||||
.get(0);
|
||||
|
||||
// when
|
||||
@ -181,7 +180,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
||||
public void globalAdmin_canViewCoopSharesTransactions_filteredByMembershipUuidAndValueDateRange() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
|
||||
final var givenMembership = membershipRepo.findMembershipsByMemberNumber(1000202)
|
||||
.get(0);
|
||||
|
||||
// when
|
||||
|
@ -61,7 +61,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
private static int tempMemberNumberSuffix = 20010;
|
||||
private static int tempMemberNumberSuffix = 10;
|
||||
|
||||
@Nested
|
||||
@Accepts({ "Membership:F(Find)" })
|
||||
@ -166,9 +166,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
|
||||
@Test
|
||||
void globalAdmin_canGetArbitraryMembership() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
|
||||
null,
|
||||
10001)
|
||||
final var givenMembershipUuid = membershipRepo.findMembershipsByMemberNumber(1000101)
|
||||
.get(0)
|
||||
.getUuid();
|
||||
|
||||
@ -197,9 +195,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
|
||||
@Accepts({ "Membership:X(Access Control)" })
|
||||
void normalUser_canNotGetUnrelatedMembership() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
|
||||
null,
|
||||
10001)
|
||||
final var givenMembershipUuid = membershipRepo.findMembershipsByMemberNumber(1000101)
|
||||
.get(0)
|
||||
.getUuid();
|
||||
|
||||
@ -217,9 +213,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
|
||||
@Accepts({ "Membership:X(Access Control)" })
|
||||
void debitorAgentUser_canGetRelatedMembership() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
|
||||
null,
|
||||
10003)
|
||||
final var givenMembershipUuid = membershipRepo.findMembershipsByMemberNumber(1000303)
|
||||
.get(0)
|
||||
.getUuid();
|
||||
|
||||
@ -444,7 +438,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
|
||||
.uuid(UUID.randomUUID())
|
||||
.partner(givenPartner)
|
||||
.mainDebitor(givenDebitor)
|
||||
.memberNumberSuffix(++tempMemberNumberSuffix)
|
||||
.memberNumberSuffix(toPaddedSuffix(++tempMemberNumberSuffix))
|
||||
.validity(Range.closedInfinite(LocalDate.parse("2022-11-01")))
|
||||
.reasonForTermination(NONE)
|
||||
.membershipFeeBillable(true)
|
||||
@ -454,12 +448,16 @@ class HsOfficeMembershipControllerAcceptanceTest {
|
||||
}).assertSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
private String toPaddedSuffix(final int numericSuffix) {
|
||||
return String.format("%02d", numericSuffix);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@AfterEach
|
||||
void cleanup() {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net", null);
|
||||
final var query = em.createQuery("DELETE FROM HsOfficeMembershipEntity m WHERE m.memberNumberSuffix >= 20000");
|
||||
final var query = em.createQuery("DELETE FROM HsOfficeMembershipEntity m WHERE m.memberNumberSuffix >= '20'");
|
||||
query.executeUpdate();
|
||||
});
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class HsOfficeMembershipEntityUnitTest {
|
||||
public static final LocalDate GIVEN_VALID_FROM = LocalDate.parse("2020-01-01");
|
||||
|
||||
final HsOfficeMembershipEntity givenMembership = HsOfficeMembershipEntity.builder()
|
||||
.memberNumberSuffix(10001)
|
||||
.memberNumberSuffix("01")
|
||||
.partner(TEST_PARTNER)
|
||||
.mainDebitor(TEST_DEBITOR)
|
||||
.validity(Range.closedInfinite(GIVEN_VALID_FROM))
|
||||
@ -27,14 +27,14 @@ class HsOfficeMembershipEntityUnitTest {
|
||||
void toStringContainsAllProps() {
|
||||
final var result = givenMembership.toString();
|
||||
|
||||
assertThat(result).isEqualTo("Membership(10001, LEGAL Test Ltd., 1000100, [2020-01-01,))");
|
||||
assertThat(result).isEqualTo("Membership(1000101, LEGAL Test Ltd., 1000100, [2020-01-01,))");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toShortStringContainsMemberNumberSuffixOnly() {
|
||||
final var result = givenMembership.toShortString();
|
||||
|
||||
assertThat(result).isEqualTo("10001");
|
||||
assertThat(result).isEqualTo("1000101");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -77,7 +77,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
final var newMembership = toCleanup(HsOfficeMembershipEntity.builder()
|
||||
.memberNumberSuffix(20001)
|
||||
.memberNumberSuffix("01")
|
||||
.partner(givenPartner)
|
||||
.mainDebitor(givenDebitor)
|
||||
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
|
||||
@ -108,7 +108,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0);
|
||||
final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("First").get(0);
|
||||
final var newMembership = toCleanup(HsOfficeMembershipEntity.builder()
|
||||
.memberNumberSuffix(20002)
|
||||
.memberNumberSuffix("02")
|
||||
.partner(givenPartner)
|
||||
.mainDebitor(givenDebitor)
|
||||
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
|
||||
@ -179,7 +179,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
|
||||
// when
|
||||
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, null);
|
||||
final var result = membershipRepo.findMembershipsByOptionalPartherNumber(null);
|
||||
|
||||
// then
|
||||
exactlyTheseMembershipsAreReturned(
|
||||
@ -196,21 +196,19 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0);
|
||||
|
||||
// when
|
||||
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
|
||||
givenPartner.getUuid(),
|
||||
null);
|
||||
final var result = membershipRepo.findMembershipsByOptionalPartherNumber(givenPartner.getUuid());
|
||||
|
||||
// then
|
||||
exactlyTheseMembershipsAreReturned(result, "Membership(10001, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void globalAdmin_withoutAssumedRole_canFindAllMembershipByMemberNumberSuffix() {
|
||||
public void globalAdmin_withoutAssumedRole_canFindAllMemberships() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
|
||||
// when
|
||||
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002);
|
||||
final var result = membershipRepo.findMembershipsByOptionalPartherNumber(null);
|
||||
|
||||
// then
|
||||
exactlyTheseMembershipsAreReturned(result, "Membership(10002, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)");
|
||||
@ -401,7 +399,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
});
|
||||
jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", null);
|
||||
em.createQuery("DELETE FROM HsOfficeMembershipEntity WHERE memberNumberSuffix >= 20000");
|
||||
em.createQuery("DELETE FROM HsOfficeMembershipEntity WHERE memberNumberSuffix >= '20'");
|
||||
});
|
||||
}
|
||||
|
||||
@ -411,7 +409,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike(partnerTradeName).get(0);
|
||||
final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike(debitorName).get(0);
|
||||
final var newMembership = HsOfficeMembershipEntity.builder()
|
||||
.memberNumberSuffix(20002)
|
||||
.memberNumberSuffix("02")
|
||||
.partner(givenPartner)
|
||||
.mainDebitor(givenDebitor)
|
||||
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
|
||||
|
@ -11,7 +11,7 @@ public class TestHsMembership {
|
||||
public static final HsOfficeMembershipEntity TEST_MEMBERSHIP =
|
||||
HsOfficeMembershipEntity.builder()
|
||||
.partner(TEST_PARTNER)
|
||||
.memberNumberSuffix(300001)
|
||||
.memberNumberSuffix("01")
|
||||
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
|
||||
.build();
|
||||
}
|
||||
|
@ -573,9 +573,10 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
partners.put(rec.getInteger("bp_id"), partner);
|
||||
|
||||
if (isNotBlank(rec.getString("member_since"))) {
|
||||
assertThat(rec.getInteger("member_id")).isEqualTo(partner.getPartnerNumber());
|
||||
final var membership = HsOfficeMembershipEntity.builder()
|
||||
.partner(partner)
|
||||
.memberNumberSuffix(rec.getInteger("member_id"))
|
||||
.memberNumberSuffix("00")
|
||||
.validity(toPostgresDateRange(
|
||||
rec.getLocalDate("member_since"),
|
||||
rec.getLocalDate("member_until")))
|
||||
@ -612,7 +613,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
: HsOfficeCoopSharesTransactionType.ADJUSTMENT
|
||||
)
|
||||
.shareCount(rec.getInteger("quantity"))
|
||||
.reference(rec.getString("comment"))
|
||||
.comment( rec.getString("comment"))
|
||||
.build();
|
||||
|
||||
coopShares.put(rec.getInteger("member_share_id"), shareTransaction);
|
||||
@ -655,7 +656,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
.valueDate(rec.getLocalDate("date"))
|
||||
.transactionType(assetTypeMapping.get(rec.getString("action")))
|
||||
.assetValue(rec.getBigDecimal("amount"))
|
||||
.reference(rec.getString("comment"))
|
||||
.comment(rec.getString("comment"))
|
||||
.build();
|
||||
|
||||
coopAssets.put(rec.getInteger("member_asset_id"), assetTransaction);
|
||||
|
Loading…
Reference in New Issue
Block a user
add unique constraint mit partnerNumber