1
0

Bugfix: properly handle invalid membership with empty validity - and other empty ranges (#169)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/169
Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
This commit is contained in:
Michael Hoennig
2025-04-02 12:09:08 +02:00
parent 4f00d1b920
commit 399512bd98
6 changed files with 241 additions and 57 deletions

View File

@@ -157,9 +157,9 @@ public class HsBookingItemController implements HsBookingItemsApi {
}
}
final BiConsumer<HsBookingItem, HsBookingItemResource> ITEM_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
final static BiConsumer<HsBookingItem, HsBookingItemResource> ITEM_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
resource.setValidFrom(entity.getValidity().lower());
if (entity.getValidity().hasUpperBound()) {
if (entity.getValidity().upper() != null) {
resource.setValidTo(entity.getValidity().upper().minusDays(1));
}
};

View File

@@ -162,7 +162,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
final BiConsumer<HsOfficeMembershipEntity, HsOfficeMembershipResource> SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
resource.setMemberNumber(entity.getTaggedMemberNumber());
resource.setValidFrom(entity.getValidity().lower());
if (entity.getValidity().hasUpperBound()) {
if (entity.getValidity().upper() != null) {
resource.setValidTo(entity.getValidity().upper().minusDays(1));
}
resource.getPartner().setPartnerNumber(entity.getPartner().getTaggedPartnerNumber()); // TODO.refa: use partner mapper?

View File

@@ -17,8 +17,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.validation.ValidationException;
import java.util.List;
import java.util.UUID;
@@ -45,9 +43,6 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi {
@Autowired
private HsOfficeSepaMandateRepository sepaMandateRepo;
@PersistenceContext
private EntityManager em;
@Override
@Transactional(readOnly = true)
@Timed("app.office.sepaMandates.api.getListOfSepaMandates")
@@ -140,7 +135,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi {
final BiConsumer<HsOfficeSepaMandateEntity, HsOfficeSepaMandateResource> SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
resource.setValidFrom(entity.getValidity().lower());
if (entity.getValidity().hasUpperBound()) {
if (entity.getValidity().upper() != null) {
resource.setValidTo(entity.getValidity().upper().minusDays(1));
}
resource.setDebitor(mapper.map(entity.getDebitor(), HsOfficeDebitorResource.class));