add missing membershipfeebillable to DB, OpenAPI and Patcher

This commit is contained in:
Michael Hoennig 2024-01-19 13:40:58 +01:00
parent a382c141b3
commit 6d4ba9b094
9 changed files with 39 additions and 16 deletions

View File

@ -59,8 +59,8 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
@Type(PostgreSQLRangeType.class) @Type(PostgreSQLRangeType.class)
private Range<LocalDate> validity; private Range<LocalDate> validity;
@Column(name = "membership_fee_billable") @Column(name = "membershipfeebillable", nullable = false)
private boolean membershipFeeBillable; private Boolean membershipFeeBillable; // not primitive to force setting the value
@Column(name = "reasonfortermination") @Column(name = "reasonfortermination")
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)

View File

@ -37,6 +37,8 @@ public class HsOfficeMembershipEntityPatcher implements EntityPatcher<HsOfficeMe
Optional.ofNullable(resource.getReasonForTermination()) Optional.ofNullable(resource.getReasonForTermination())
.map(v -> mapper.map(v, HsOfficeReasonForTermination.class)) .map(v -> mapper.map(v, HsOfficeReasonForTermination.class))
.ifPresent(entity::setReasonForTermination); .ifPresent(entity::setReasonForTermination);
OptionalFromJson.of(resource.getMembershipFeeBillable()).ifPresent(
entity::setMembershipFeeBillable);
} }
private void verifyNotNull(final UUID newValue, final String propertyName) { private void verifyNotNull(final UUID newValue, final String propertyName) {

View File

@ -33,6 +33,8 @@ components:
format: date format: date
reasonForTermination: reasonForTermination:
$ref: '#/components/schemas/HsOfficeReasonForTermination' $ref: '#/components/schemas/HsOfficeReasonForTermination'
membershipFeeBillable:
type: boolean
HsOfficeMembershipPatch: HsOfficeMembershipPatch:
type: object type: object
@ -48,6 +50,9 @@ components:
reasonForTermination: reasonForTermination:
nullable: true nullable: true
$ref: '#/components/schemas/HsOfficeReasonForTermination' $ref: '#/components/schemas/HsOfficeReasonForTermination'
membershipFeeBillable:
nullable: true
type: boolean
additionalProperties: false additionalProperties: false
HsOfficeMembershipInsert: HsOfficeMembershipInsert:
@ -74,8 +79,12 @@ components:
nullable: true nullable: true
reasonForTermination: reasonForTermination:
$ref: '#/components/schemas/HsOfficeReasonForTermination' $ref: '#/components/schemas/HsOfficeReasonForTermination'
membershipFeeBillable:
nullable: false
type: boolean
required: required:
- partnerUuid - partnerUuid
- mainDebitorUuid - mainDebitorUuid
- validFrom - validFrom
- membershipFeeBillable
additionalProperties: false additionalProperties: false

View File

@ -16,7 +16,7 @@ create table if not exists hs_office_membership
memberNumber numeric(5) not null unique, memberNumber numeric(5) not null unique,
validity daterange not null, validity daterange not null,
reasonForTermination HsOfficeReasonForTermination not null default 'NONE', reasonForTermination HsOfficeReasonForTermination not null default 'NONE',
membership_fee_billable boolean not null default true membershipFeeBillable boolean not null default true
); );
--// --//

View File

@ -106,7 +106,7 @@ call generateRbacRestrictedView('hs_office_membership',
columnUpdates => $updates$ columnUpdates => $updates$
validity = new.validity, validity = new.validity,
reasonForTermination = new.reasonForTermination, reasonForTermination = new.reasonForTermination,
membership_fee_billable = new.membership_fee_billable membershipFeeBillable = new.membershipFeeBillable
$updates$); $updates$);
--// --//

View File

@ -131,7 +131,8 @@ class HsOfficeMembershipControllerAcceptanceTest {
"partnerUuid": "%s", "partnerUuid": "%s",
"mainDebitorUuid": "%s", "mainDebitorUuid": "%s",
"memberNumber": 20001, "memberNumber": 20001,
"validFrom": "2022-10-13" "validFrom": "2022-10-13",
"membershipFeeBillable": "true"
} }
""".formatted(givenPartner.getUuid(), givenDebitor.getUuid())) """.formatted(givenPartner.getUuid(), givenDebitor.getUuid()))
.port(port) .port(port)
@ -446,6 +447,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
.memberNumber(++tempMemberNumber) .memberNumber(++tempMemberNumber)
.validity(Range.closedInfinite(LocalDate.parse("2022-11-01"))) .validity(Range.closedInfinite(LocalDate.parse("2022-11-01")))
.reasonForTermination(NONE) .reasonForTermination(NONE)
.membershipFeeBillable(true)
.build(); .build();
return membershipRepo.save(newMembership); return membershipRepo.save(newMembership);

View File

@ -72,7 +72,8 @@ public class HsOfficeMembershipControllerRestTest {
"partnerUuid": null, "partnerUuid": null,
"mainDebitorUuid": "%s", "mainDebitorUuid": "%s",
"memberNumber": 20001, "memberNumber": 20001,
"validFrom": "2022-10-13" "validFrom": "2022-10-13",
"membershipFeeBillable": "true"
} }
""".formatted(UUID.randomUUID())) """.formatted(UUID.randomUUID()))
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
@ -97,7 +98,8 @@ public class HsOfficeMembershipControllerRestTest {
"partnerUuid": "%s", "partnerUuid": "%s",
"mainDebitorUuid": null, "mainDebitorUuid": null,
"memberNumber": 20001, "memberNumber": 20001,
"validFrom": "2022-10-13" "validFrom": "2022-10-13",
"membershipFeeBillable": "true"
} }
""".formatted(UUID.randomUUID())) """.formatted(UUID.randomUUID()))
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
@ -128,7 +130,8 @@ public class HsOfficeMembershipControllerRestTest {
"partnerUuid": "%s", "partnerUuid": "%s",
"mainDebitorUuid": "%s", "mainDebitorUuid": "%s",
"memberNumber": 20001, "memberNumber": 20001,
"validFrom": "2022-10-13" "validFrom": "2022-10-13",
"membershipFeeBillable": "true"
} }
""".formatted(givenPartnerUuid, givenMainDebitorUuid)) """.formatted(givenPartnerUuid, givenMainDebitorUuid))
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
@ -159,7 +162,8 @@ public class HsOfficeMembershipControllerRestTest {
"partnerUuid": "%s", "partnerUuid": "%s",
"mainDebitorUuid": "%s", "mainDebitorUuid": "%s",
"memberNumber": 20001, "memberNumber": 20001,
"validFrom": "2022-10-13" "validFrom": "2022-10-13",
"membershipFeeBillable": "true"
} }
""".formatted(givenPartnerUuid, givenMainDebitorUuid)) """.formatted(givenPartnerUuid, givenMainDebitorUuid))
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))

View File

@ -36,6 +36,9 @@ class HsOfficeMembershipEntityPatcherUnitTest extends PatchUnitTestBase<
private static final LocalDate GIVEN_VALID_FROM = LocalDate.parse("2020-04-15"); private static final LocalDate GIVEN_VALID_FROM = LocalDate.parse("2020-04-15");
private static final LocalDate PATCHED_VALID_TO = LocalDate.parse("2022-12-31"); private static final LocalDate PATCHED_VALID_TO = LocalDate.parse("2022-12-31");
private static final Boolean GIVEN_MEMBERSHIP_FEE_BILLABLE = true;
private static final Boolean PATCHED_MEMBERSHIP_FEE_BILLABLE = false;
@Mock @Mock
private EntityManager em; private EntityManager em;
@ -56,6 +59,7 @@ class HsOfficeMembershipEntityPatcherUnitTest extends PatchUnitTestBase<
entity.setMainDebitor(TEST_DEBITOR); entity.setMainDebitor(TEST_DEBITOR);
entity.setPartner(TEST_PARTNER); entity.setPartner(TEST_PARTNER);
entity.setValidity(Range.closedInfinite(GIVEN_VALID_FROM)); entity.setValidity(Range.closedInfinite(GIVEN_VALID_FROM));
entity.setMembershipFeeBillable(GIVEN_MEMBERSHIP_FEE_BILLABLE);
return entity; return entity;
} }
@ -90,7 +94,12 @@ class HsOfficeMembershipEntityPatcherUnitTest extends PatchUnitTestBase<
HsOfficeReasonForTerminationResource.CANCELLATION, HsOfficeReasonForTerminationResource.CANCELLATION,
HsOfficeMembershipEntity::setReasonForTermination, HsOfficeMembershipEntity::setReasonForTermination,
HsOfficeReasonForTermination.CANCELLATION) HsOfficeReasonForTermination.CANCELLATION)
.notNullable() .notNullable(),
new JsonNullableProperty<>(
"membershipFeeBillable",
HsOfficeMembershipPatchResource::setMembershipFeeBillable,
PATCHED_MEMBERSHIP_FEE_BILLABLE,
HsOfficeMembershipEntity::setMembershipFeeBillable)
); );
} }
@ -99,10 +108,4 @@ class HsOfficeMembershipEntityPatcherUnitTest extends PatchUnitTestBase<
newDebitor.setUuid(uuid); newDebitor.setUuid(uuid);
return newDebitor; return newDebitor;
} }
private HsOfficeMembershipEntity newMembership(final UUID uuid) {
final var newMembership = new HsOfficeMembershipEntity();
newMembership.setUuid(uuid);
return newMembership;
}
} }

View File

@ -81,6 +81,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
.partner(givenPartner) .partner(givenPartner)
.mainDebitor(givenDebitor) .mainDebitor(givenDebitor)
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01"))) .validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
.membershipFeeBillable(true)
.build()); .build());
return membershipRepo.save(newMembership); return membershipRepo.save(newMembership);
}); });
@ -111,6 +112,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
.partner(givenPartner) .partner(givenPartner)
.mainDebitor(givenDebitor) .mainDebitor(givenDebitor)
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01"))) .validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
.membershipFeeBillable(true)
.build()); .build());
return membershipRepo.save(newMembership); return membershipRepo.save(newMembership);
}); });
@ -416,6 +418,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
.partner(givenPartner) .partner(givenPartner)
.mainDebitor(givenDebitor) .mainDebitor(givenDebitor)
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01"))) .validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
.membershipFeeBillable(true)
.build(); .build();
toCleanup(newMembership); toCleanup(newMembership);