feature/prefixes-for-partner-member-debitor-in-api #122

Merged
hsh-michaelhoennig merged 10 commits from feature/prefixes-for-partner-member-debitor-in-api into master 2024-11-18 12:11:18 +01:00
4 changed files with 19 additions and 13 deletions
Showing only changes of commit 628f984ae6 - Show all commits

View File

@ -125,7 +125,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
} }
final BiConsumer<HsOfficeMembershipEntity, HsOfficeMembershipResource> SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> { final BiConsumer<HsOfficeMembershipEntity, HsOfficeMembershipResource> SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
// TODO.refa: this should be possible via ModelMapper config resource.setMemberNumber(entity.getTaggedMemberNumber());
resource.setValidFrom(entity.getValidity().lower()); resource.setValidFrom(entity.getValidity().lower());
if (entity.getValidity().hasUpperBound()) { if (entity.getValidity().hasUpperBound()) {
resource.setValidTo(entity.getValidity().upper().minusDays(1)); resource.setValidTo(entity.getValidity().upper().minusDays(1));

View File

@ -130,6 +130,7 @@ public class HsOfficeMembershipEntity implements BaseEntity<HsOfficeMembershipEn
} }
return validity; return validity;
} }
public Integer getMemberNumber() { public Integer getMemberNumber() {
if (partner == null || partner.getPartnerNumber() == null || memberNumberSuffix == null ) { if (partner == null || partner.getPartnerNumber() == null || memberNumberSuffix == null ) {
return null; return null;
@ -138,6 +139,10 @@ public class HsOfficeMembershipEntity implements BaseEntity<HsOfficeMembershipEn
return getPartner().getPartnerNumber() * 100 + Integer.parseInt(memberNumberSuffix, 10); return getPartner().getPartnerNumber() * 100 + Integer.parseInt(memberNumberSuffix, 10);
} }
public String getTaggedMemberNumber() {
return MEMBER_NUMBER_TAG + getMemberNumber();
}
@Override @Override
public String toString() { public String toString() {
return stringify.apply(this); return stringify.apply(this);

View File

@ -26,9 +26,10 @@ components:
mainDebitor: mainDebitor:
$ref: 'hs-office-debitor-schemas.yaml#/components/schemas/HsOfficeDebitor' $ref: 'hs-office-debitor-schemas.yaml#/components/schemas/HsOfficeDebitor'
memberNumber: memberNumber:
type: integer type: string
minimum: 1000000 minLength: 9
maximum: 9999999 maxLength: 9
pattern: 'M-[0-9]{7}'
memberNumberSuffix: memberNumberSuffix:
type: string type: string
minLength: 2 minLength: 2

View File

@ -78,7 +78,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
[ [
{ {
"partner": { "partnerNumber": "P-10001" }, "partner": { "partnerNumber": "P-10001" },
"memberNumber": 1000101, "memberNumber": "M-1000101",
"memberNumberSuffix": "01", "memberNumberSuffix": "01",
"validFrom": "2022-10-01", "validFrom": "2022-10-01",
"validTo": null, "validTo": null,
@ -86,7 +86,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}, },
{ {
"partner": { "partnerNumber": "P-10002" }, "partner": { "partnerNumber": "P-10002" },
"memberNumber": 1000202, "memberNumber": "M-1000202",
"memberNumberSuffix": "02", "memberNumberSuffix": "02",
"validFrom": "2022-10-01", "validFrom": "2022-10-01",
"validTo": null, "validTo": null,
@ -94,7 +94,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}, },
{ {
"partner": { "partnerNumber": "P-10003" }, "partner": { "partnerNumber": "P-10003" },
"memberNumber": 1000303, "memberNumber": "M-1000303",
"memberNumberSuffix": "03", "memberNumberSuffix": "03",
"validFrom": "2022-10-01", "validFrom": "2022-10-01",
"validTo": null, "validTo": null,
@ -125,7 +125,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
[ [
{ {
"partner": { "partnerNumber": "P-10001" }, "partner": { "partnerNumber": "P-10001" },
"memberNumber": 1000101, "memberNumber": "M-1000101",
"memberNumberSuffix": "01", "memberNumberSuffix": "01",
"validFrom": "2022-10-01", "validFrom": "2022-10-01",
"validTo": null, "validTo": null,
@ -153,7 +153,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
[ [
{ {
"partner": { "partnerNumber": "P-10002" }, "partner": { "partnerNumber": "P-10002" },
"memberNumber": 1000202, "memberNumber": "M-1000202",
"memberNumberSuffix": "02", "memberNumberSuffix": "02",
"validFrom": "2022-10-01", "validFrom": "2022-10-01",
"validTo": null, "validTo": null,
@ -196,7 +196,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("partner.partnerNumber", is("P-10003")) .body("partner.partnerNumber", is("P-10003"))
.body("memberNumber", is(expectedMemberNumber)) .body("memberNumber", is("M-" + expectedMemberNumber))
.body("memberNumberSuffix", is(givenMemberSuffix)) .body("memberNumberSuffix", is(givenMemberSuffix))
.body("validFrom", is("2022-10-13")) .body("validFrom", is("2022-10-13"))
.body("validTo", equalTo(null)) .body("validTo", equalTo(null))
@ -231,7 +231,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
{ {
"partner": { "partnerNumber": "P-10001" }, "partner": { "partnerNumber": "P-10001" },
"memberNumber": 1000101, "memberNumber": "M-1000101",
"memberNumberSuffix": "01", "memberNumberSuffix": "01",
"validFrom": "2022-10-01", "validFrom": "2022-10-01",
"validTo": null, "validTo": null,
@ -256,7 +256,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Test @Test
void parnerRelAgent_canGetRelatedMembership() { void partnerRelAgent_canGetRelatedMembership() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMembershipUuid = membershipRepo.findMembershipByMemberNumber(1000303).getUuid(); final var givenMembershipUuid = membershipRepo.findMembershipByMemberNumber(1000303).getUuid();
@ -273,7 +273,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
{ {
"partner": { "partnerNumber": "P-10003" }, "partner": { "partnerNumber": "P-10003" },
"memberNumber": 1000303, "memberNumber": "M-1000303",
"memberNumberSuffix": "03", "memberNumberSuffix": "03",
"validFrom": "2022-10-01", "validFrom": "2022-10-01",
"validTo": null, "validTo": null,