rename membernumber -> membernumbersuffix

This commit is contained in:
Michael Hoennig 2024-01-22 13:15:20 +01:00
parent 9f9575f51f
commit 3c89164a67
26 changed files with 82 additions and 82 deletions

View File

@ -27,7 +27,7 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, HasUuid {
private static Stringify<HsOfficeCoopAssetsTransactionEntity> stringify = stringify(HsOfficeCoopAssetsTransactionEntity.class)
.withProp(e -> e.getMembership().getMemberNumber())
.withProp(e -> e.getMembership().getMemberNumberSuffix())
.withProp(HsOfficeCoopAssetsTransactionEntity::getValueDate)
.withProp(HsOfficeCoopAssetsTransactionEntity::getTransactionType)
.withProp(HsOfficeCoopAssetsTransactionEntity::getAssetValue)
@ -67,6 +67,6 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, HasUu
@Override
public String toShortString() {
return membership.getMemberNumber() + new DecimalFormat("+0.00").format(assetValue);
return membership.getMemberNumberSuffix() + new DecimalFormat("+0.00").format(assetValue);
}
}

View File

@ -17,7 +17,7 @@ public interface HsOfficeCoopAssetsTransactionRepository extends Repository<HsOf
WHERE ( CAST(:membershipUuid AS org.hibernate.type.UUIDCharType) IS NULL OR at.membership.uuid = :membershipUuid)
AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (at.valueDate >= :fromValueDate))
AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (at.valueDate <= :toValueDate))
ORDER BY at.membership.memberNumber, at.valueDate
ORDER BY at.membership.memberNumberSuffix, at.valueDate
""")
List<HsOfficeCoopAssetsTransactionEntity> findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate);

View File

@ -24,7 +24,7 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUuid {
private static Stringify<HsOfficeCoopSharesTransactionEntity> stringify = stringify(HsOfficeCoopSharesTransactionEntity.class)
.withProp(e -> e.getMembership().getMemberNumber())
.withProp(e -> e.getMembership().getMemberNumberSuffix())
.withProp(HsOfficeCoopSharesTransactionEntity::getValueDate)
.withProp(HsOfficeCoopSharesTransactionEntity::getTransactionType)
.withProp(HsOfficeCoopSharesTransactionEntity::getShareCount)
@ -63,6 +63,6 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUu
@Override
public String toShortString() {
return "%s%+d".formatted(membership.getMemberNumber(), shareCount);
return "%s%+d".formatted(membership.getMemberNumberSuffix(), shareCount);
}
}

View File

@ -17,7 +17,7 @@ public interface HsOfficeCoopSharesTransactionRepository extends Repository<HsOf
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(:toValueDate AS java.time.LocalDate)IS NULL OR (st.valueDate <= :toValueDate))
ORDER BY st.membership.memberNumber, st.valueDate
ORDER BY st.membership.memberNumberSuffix, st.valueDate
""")
List<HsOfficeCoopSharesTransactionEntity> findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(
UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate);

View File

@ -41,11 +41,11 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
final String currentUser,
final String assumedRoles,
UUID partnerUuid,
Integer memberNumber) {
Integer memberNumberSuffix) {
context.define(currentUser, assumedRoles);
final var entities =
membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(partnerUuid, memberNumber);
membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(partnerUuid, memberNumberSuffix);
final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class,
SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER);

View File

@ -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::getMemberNumber)
.withProp(HsOfficeMembershipEntity::getMemberNumberSuffix)
.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 = "membernumber")
private int memberNumber; // TODO: migrate to suffix, like debitorNumberSuffix
@Column(name = "membernumbersuffix")
private int 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(memberNumber);
return String.valueOf(memberNumberSuffix);
}
@PrePersist

View File

@ -13,12 +13,12 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
@Query("""
SELECT membership FROM HsOfficeMembershipEntity membership
WHERE (:memberNumber is null OR membership.memberNumber = :memberNumber)
WHERE (:memberNumberSuffix is null OR membership.memberNumberSuffix = :memberNumberSuffix)
AND ( CAST(:partnerUuid as org.hibernate.type.UUIDCharType) IS NULL
OR membership.partner.uuid = :partnerUuid )
ORDER BY membership.memberNumber
ORDER BY membership.memberNumberSuffix
""")
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(UUID partnerUuid, Integer memberNumber);
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(UUID partnerUuid, Integer memberNumberSuffix);
HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity);

View File

@ -23,7 +23,7 @@ components:
$ref: './hs-office-partner-schemas.yaml#/components/schemas/HsOfficePartner'
mainDebitor:
$ref: './hs-office-debitor-schemas.yaml#/components/schemas/HsOfficeDebitor'
memberNumber:
memberNumberSuffix:
type: integer
validFrom:
type: string
@ -66,7 +66,7 @@ components:
type: string
format: uuid
nullable: false
memberNumber:
memberNumberSuffix:
type: integer
nullable: false
validFrom:

View File

@ -14,7 +14,7 @@ get:
type: string
format: uuid
description: UUID of the business partner.
- name: memberNumber
- name: memberNumberSuffix
in: query
required: false
schema:

View File

@ -13,7 +13,7 @@ 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),
memberNumber numeric(5) not null unique,
memberNumberSuffix numeric(5) not null unique,
validity daterange not null,
reasonForTermination HsOfficeReasonForTermination not null default 'NONE',
membershipFeeBillable boolean not null default true

View File

@ -92,7 +92,7 @@ execute procedure hsOfficeMembershipRbacRolesTrigger();
--changeset hs-office-membership-rbac-IDENTITY-VIEW:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
call generateRbacIdentityView('hs_office_membership', idNameExpression => $idName$
target.memberNumber ||
target.memberNumberSuffix ||
':' || (select split_part(idName, ':', 2) from hs_office_partner_iv p where p.uuid = target.partnerUuid)
$idName$);
--//
@ -102,7 +102,7 @@ call generateRbacIdentityView('hs_office_membership', idNameExpression => $idNam
--changeset hs-office-membership-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
call generateRbacRestrictedView('hs_office_membership',
orderby => 'target.memberNumber',
orderby => 'target.memberNumberSuffix',
columnUpdates => $updates$
validity = new.validity,
reasonForTermination = new.reasonForTermination,

View File

@ -15,7 +15,7 @@ declare
idName varchar;
relatedPartner hs_office_partner;
relatedDebitor hs_office_debitor;
newMemberNumber numeric;
newMemberNumberSuffix numeric;
begin
idName := cleanIdentifier( forPartnerTradeName || '#' || forMainDebitorNumber);
currentTask := 'creating Membership test-data ' || idName;
@ -26,14 +26,14 @@ begin
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(memberNumber)+1, 10001) from hs_office_membership into newMemberNumber;
select coalesce(max(memberNumberSuffix)+1, 10001) from hs_office_membership into newMemberNumberSuffix;
raise notice 'creating test Membership: %', idName;
raise notice '- using partner (%): %', relatedPartner.uuid, relatedPartner;
raise notice '- using debitor (%): %', relatedDebitor.uuid, relatedDebitor;
insert
into hs_office_membership (uuid, partneruuid, maindebitoruuid, membernumber, validity, reasonfortermination)
values (uuid_generate_v4(), relatedPartner.uuid, relatedDebitor.uuid, newMemberNumber, daterange('20221001' , null, '[]'), 'NONE');
into hs_office_membership (uuid, partneruuid, maindebitoruuid, memberNumberSuffix, validity, reasonfortermination)
values (uuid_generate_v4(), relatedPartner.uuid, relatedDebitor.uuid, newMemberNumberSuffix, daterange('20221001' , null, '[]'), 'NONE');
end; $$;
--//

View File

@ -18,7 +18,7 @@ begin
execute format('set local hsadminng.currentTask to %L', currentTask);
call defineContext(currentTask);
select m.uuid from hs_office_membership m where m.memberNumber = givenMembershipNumber into membership;
select m.uuid from hs_office_membership m where m.memberNumberSuffix = givenMembershipNumber into membership;
raise notice 'creating test coopSharesTransaction: %', givenMembershipNumber;
insert

View File

@ -18,7 +18,7 @@ begin
execute format('set local hsadminng.currentTask to %L', currentTask);
call defineContext(currentTask);
select m.uuid from hs_office_membership m where m.memberNumber = givenMembershipNumber into membership;
select m.uuid from hs_office_membership m where m.memberNumberSuffix = givenMembershipNumber into membership;
raise notice 'creating test coopAssetsTransaction: %', givenMembershipNumber;
insert

View File

@ -72,10 +72,10 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
}
@Test
void globalAdmin_canFindCoopAssetsTransactionsByMemberNumber() {
void globalAdmin_canFindCoopAssetsTransactionsByMemberNumberSuffix() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
.get(0);
RestAssured // @formatter:off
@ -115,10 +115,10 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
}
@Test
void globalAdmin_canFindCoopAssetsTransactionsByMemberNumberAndDateRange() {
void globalAdmin_canFindCoopAssetsTransactionsByMemberNumberSuffixAndDateRange() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
.get(0);
RestAssured // @formatter:off
@ -153,7 +153,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
void globalAdmin_canAddCoopAssetsTransaction() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001)
.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.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001)
.get(0);
final var location = RestAssured // @formatter:off

View File

@ -26,7 +26,7 @@ class HsOfficeCoopAssetsTransactionEntityUnitTest {
}
@Test
void toShortStringContainsOnlyMemberNumberAndSharesCountOnly() {
void toShortStringContainsOnlyMemberNumberSuffixAndSharesCountOnly() {
final var result = givenCoopAssetTransaction.toShortString();
assertThat(result).isEqualTo("300001+128.00");

View File

@ -62,7 +62,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
// given
context("superuser-alex@hostsharing.net");
final var count = coopAssetsTransactionRepo.count();
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001)
.get(0);
// when
@ -96,7 +96,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
// when
attempt(em, () -> {
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
null,
10001).get(0);
final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
@ -161,7 +161,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
public void globalAdmin_canViewCoopAssetsTransactions_filteredByMembershipUuid() {
// given
context("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
.get(0);
// when
@ -182,7 +182,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
public void globalAdmin_canViewCoopAssetsTransactions_filteredByMembershipUuidAndValueDateRange() {
// given
context("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
.get(0);
// when

View File

@ -72,10 +72,10 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
}
@Test
void globalAdmin_canFindCoopSharesTransactionsByMemberNumber() {
void globalAdmin_canFindCoopSharesTransactionsByMemberNumberSuffix() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002).get(0);
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002).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("""
@ -106,10 +106,10 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
}
@Test
void globalAdmin_canFindCoopSharesTransactionsByMemberNumberAndDateRange() {
void globalAdmin_canFindCoopSharesTransactionsByMemberNumberSuffixAndDateRange() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002).get(0);
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002).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.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001).get(0);
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001).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.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001).get(0);
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001).get(0);
final var location = RestAssured // @formatter:off
.given().header("current-user", "superuser-alex@hostsharing.net").contentType(ContentType.JSON).body("""

View File

@ -25,7 +25,7 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
}
@Test
void toShortStringContainsOnlyMemberNumberAndshareCountOnly() {
void toShortStringContainsOnlyMemberNumberSuffixAndshareCountOnly() {
final var result = givenCoopSharesTransaction.toShortString();
assertThat(result).isEqualTo("300001+4");

View File

@ -61,7 +61,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
// given
context("superuser-alex@hostsharing.net");
final var count = coopSharesTransactionRepo.count();
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10001)
.get(0);
// when
@ -95,7 +95,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
// when
attempt(em, () -> {
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
null,
10001).get(0);
final var newCoopSharesTransaction = HsOfficeCoopSharesTransactionEntity.builder()
@ -160,7 +160,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
public void globalAdmin_canViewCoopSharesTransactions_filteredByMembershipUuid() {
// given
context("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
.get(0);
// when
@ -181,7 +181,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
public void globalAdmin_canViewCoopSharesTransactions_filteredByMembershipUuidAndValueDateRange() {
// given
context("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002)
.get(0);
// when

View File

@ -61,7 +61,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
@PersistenceContext
EntityManager em;
private static int tempMemberNumber = 20010;
private static int tempMemberNumberSuffix = 20010;
@Nested
@Accepts({ "Membership:F(Find)" })
@ -84,7 +84,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
{
"partner": { "person": { "tradeName": "First GmbH" } },
"mainDebitor": { "debitorNumber": 1000111 },
"memberNumber": 10001,
"memberNumberSuffix": 10001,
"validFrom": "2022-10-01",
"validTo": null,
"reasonForTermination": "NONE"
@ -92,7 +92,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
{
"partner": { "person": { "tradeName": "Second e.K." } },
"mainDebitor": { "debitorNumber": 1000212 },
"memberNumber": 10002,
"memberNumberSuffix": 10002,
"validFrom": "2022-10-01",
"validTo": null,
"reasonForTermination": "NONE"
@ -100,7 +100,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
{
"partner": { "person": { "tradeName": "Third OHG" } },
"mainDebitor": { "debitorNumber": 1000313 },
"memberNumber": 10003,
"memberNumberSuffix": 10003,
"validFrom": "2022-10-01",
"validTo": null,
"reasonForTermination": "NONE"
@ -130,7 +130,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
{
"partnerUuid": "%s",
"mainDebitorUuid": "%s",
"memberNumber": 20001,
"memberNumberSuffix": 20001,
"validFrom": "2022-10-13",
"membershipFeeBillable": "true"
}
@ -145,7 +145,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
.body("mainDebitor.debitorNumber", is(givenDebitor.getDebitorNumber()))
.body("mainDebitor.debitorNumberSuffix", is((int) givenDebitor.getDebitorNumberSuffix()))
.body("partner.person.tradeName", is("Third OHG"))
.body("memberNumber", is(20001))
.body("memberNumberSuffix", is(20001))
.body("validFrom", is("2022-10-13"))
.body("validTo", equalTo(null))
.header("Location", startsWith("http://localhost"))
@ -166,7 +166,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
@Test
void globalAdmin_canGetArbitraryMembership() {
context.define("superuser-alex@hostsharing.net");
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
null,
10001)
.get(0)
@ -185,7 +185,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
{
"partner": { "person": { "tradeName": "First GmbH" } },
"mainDebitor": { "debitorNumber": 1000111 },
"memberNumber": 10001,
"memberNumberSuffix": 10001,
"validFrom": "2022-10-01",
"validTo": null,
"reasonForTermination": "NONE"
@ -197,7 +197,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
@Accepts({ "Membership:X(Access Control)" })
void normalUser_canNotGetUnrelatedMembership() {
context.define("superuser-alex@hostsharing.net");
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
null,
10001)
.get(0)
@ -217,7 +217,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
@Accepts({ "Membership:X(Access Control)" })
void debitorAgentUser_canGetRelatedMembership() {
context.define("superuser-alex@hostsharing.net");
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(
final var givenMembershipUuid = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
null,
10003)
.get(0)
@ -240,7 +240,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
"debitorNumber": 1000313,
"billingContact": { "label": "third contact" }
},
"memberNumber": 10003,
"memberNumberSuffix": 10003,
"validFrom": "2022-10-01",
"validTo": null,
"reasonForTermination": "NONE"
@ -279,7 +279,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
.body("partner.person.tradeName", is(givenMembership.getPartner().getPerson().getTradeName()))
.body("mainDebitor.debitorNumber", is(givenMembership.getMainDebitor().getDebitorNumber()))
.body("mainDebitor.debitorNumberSuffix", is((int) givenMembership.getMainDebitor().getDebitorNumberSuffix()))
.body("memberNumber", is(givenMembership.getMemberNumber()))
.body("memberNumberSuffix", is(givenMembership.getMemberNumberSuffix()))
.body("validFrom", is("2022-11-01"))
.body("validTo", is("2023-12-31"))
.body("reasonForTermination", is("CANCELLATION"));
@ -290,7 +290,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
.matches(mandate -> {
assertThat(mandate.getPartner().toShortString()).isEqualTo("LEGAL First GmbH");
assertThat(mandate.getMainDebitor().toString()).isEqualTo(givenMembership.getMainDebitor().toString());
assertThat(mandate.getMemberNumber()).isEqualTo(givenMembership.getMemberNumber());
assertThat(mandate.getMemberNumberSuffix()).isEqualTo(givenMembership.getMemberNumberSuffix());
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2024-01-01)");
assertThat(mandate.getReasonForTermination()).isEqualTo(HsOfficeReasonForTermination.CANCELLATION);
return true;
@ -322,7 +322,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
.body("uuid", isUuidValid())
.body("partner.person.tradeName", is(givenMembership.getPartner().getPerson().getTradeName()))
.body("mainDebitor.debitorNumber", is(1000313))
.body("memberNumber", is(givenMembership.getMemberNumber()))
.body("memberNumberSuffix", is(givenMembership.getMemberNumberSuffix()))
.body("validFrom", is("2022-11-01"))
.body("validTo", nullValue())
.body("reasonForTermination", is("NONE"));
@ -333,7 +333,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
.matches(mandate -> {
assertThat(mandate.getPartner().toShortString()).isEqualTo("LEGAL First GmbH");
assertThat(mandate.getMainDebitor().toString()).isEqualTo(givenMembership.getMainDebitor().toString());
assertThat(mandate.getMemberNumber()).isEqualTo(givenMembership.getMemberNumber());
assertThat(mandate.getMemberNumberSuffix()).isEqualTo(givenMembership.getMemberNumberSuffix());
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,)");
assertThat(mandate.getReasonForTermination()).isEqualTo(NONE);
return true;
@ -444,7 +444,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
.uuid(UUID.randomUUID())
.partner(givenPartner)
.mainDebitor(givenDebitor)
.memberNumber(++tempMemberNumber)
.memberNumberSuffix(++tempMemberNumberSuffix)
.validity(Range.closedInfinite(LocalDate.parse("2022-11-01")))
.reasonForTermination(NONE)
.membershipFeeBillable(true)
@ -459,7 +459,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
void cleanup() {
jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net", null);
final var query = em.createQuery("DELETE FROM HsOfficeMembershipEntity m WHERE m.memberNumber >= 20000");
final var query = em.createQuery("DELETE FROM HsOfficeMembershipEntity m WHERE m.memberNumberSuffix >= 20000");
query.executeUpdate();
});
}

View File

@ -71,7 +71,7 @@ public class HsOfficeMembershipControllerRestTest {
{
"partnerUuid": null,
"mainDebitorUuid": "%s",
"memberNumber": 20001,
"memberNumberSuffix": 20001,
"validFrom": "2022-10-13",
"membershipFeeBillable": "true"
}
@ -97,7 +97,7 @@ public class HsOfficeMembershipControllerRestTest {
{
"partnerUuid": "%s",
"mainDebitorUuid": null,
"memberNumber": 20001,
"memberNumberSuffix": 20001,
"validFrom": "2022-10-13",
"membershipFeeBillable": "true"
}
@ -129,7 +129,7 @@ public class HsOfficeMembershipControllerRestTest {
{
"partnerUuid": "%s",
"mainDebitorUuid": "%s",
"memberNumber": 20001,
"memberNumberSuffix": 20001,
"validFrom": "2022-10-13",
"membershipFeeBillable": "true"
}
@ -161,7 +161,7 @@ public class HsOfficeMembershipControllerRestTest {
{
"partnerUuid": "%s",
"mainDebitorUuid": "%s",
"memberNumber": 20001,
"memberNumberSuffix": 20001,
"validFrom": "2022-10-13",
"membershipFeeBillable": "true"
}

View File

@ -17,7 +17,7 @@ class HsOfficeMembershipEntityUnitTest {
public static final LocalDate GIVEN_VALID_FROM = LocalDate.parse("2020-01-01");
final HsOfficeMembershipEntity givenMembership = HsOfficeMembershipEntity.builder()
.memberNumber(10001)
.memberNumberSuffix(10001)
.partner(TEST_PARTNER)
.mainDebitor(TEST_DEBITOR)
.validity(Range.closedInfinite(GIVEN_VALID_FROM))
@ -31,7 +31,7 @@ class HsOfficeMembershipEntityUnitTest {
}
@Test
void toShortStringContainsMemberNumberOnly() {
void toShortStringContainsMemberNumberSuffixOnly() {
final var result = givenMembership.toShortString();
assertThat(result).isEqualTo("10001");

View File

@ -77,7 +77,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
// when
final var result = attempt(em, () -> {
final var newMembership = toCleanup(HsOfficeMembershipEntity.builder()
.memberNumber(20001)
.memberNumberSuffix(20001)
.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()
.memberNumber(20002)
.memberNumberSuffix(20002)
.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.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, null);
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, null);
// then
exactlyTheseMembershipsAreReturned(
@ -196,7 +196,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0);
// when
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(
givenPartner.getUuid(),
null);
@ -205,12 +205,12 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
}
@Test
public void globalAdmin_withoutAssumedRole_canFindAllMembershipByMemberNumber() {
public void globalAdmin_withoutAssumedRole_canFindAllMembershipByMemberNumberSuffix() {
// given
context("superuser-alex@hostsharing.net");
// when
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002);
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumberSuffix(null, 10002);
// then
exactlyTheseMembershipsAreReturned(result, "Membership(10002, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)");
@ -401,7 +401,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
});
jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net", null);
em.createQuery("DELETE FROM HsOfficeMembershipEntity WHERE memberNumber >= 20000");
em.createQuery("DELETE FROM HsOfficeMembershipEntity WHERE memberNumberSuffix >= 20000");
});
}
@ -411,7 +411,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()
.memberNumber(20002)
.memberNumberSuffix(20002)
.partner(givenPartner)
.mainDebitor(givenDebitor)
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))

View File

@ -11,7 +11,7 @@ public class TestHsMembership {
public static final HsOfficeMembershipEntity TEST_MEMBERSHIP =
HsOfficeMembershipEntity.builder()
.partner(TEST_PARTNER)
.memberNumber(300001)
.memberNumberSuffix(300001)
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
.build();
}

View File

@ -575,7 +575,7 @@ public class ImportOfficeData extends ContextBasedTest {
if (isNotBlank(rec.getString("member_since"))) {
final var membership = HsOfficeMembershipEntity.builder()
.partner(partner)
.memberNumber(rec.getInteger("member_id"))
.memberNumberSuffix(rec.getInteger("member_id"))
.validity(toPostgresDateRange(
rec.getLocalDate("member_since"),
rec.getLocalDate("member_until")))