Compare commits
No commits in common. "b00c4ce8a85e5506935ea20a8a15a57a48cc8c40" and "d069e87c01d41cba371a9f1c80e510d6ac70f627" have entirely different histories.
b00c4ce8a8
...
d069e87c01
4
.aliases
4
.aliases
@ -75,5 +75,5 @@ alias pg-sql-restore='gunzip --stdout | docker exec -i hsadmin-ng-postgres psql
|
||||
|
||||
alias fp='grep -r '@Accepts' src | sed -e 's/^.*@/@/g' | sort -u | wc -l'
|
||||
|
||||
alias gw-spotless='./gradlew spotlessApply -x pitest -x test -x :processResources'
|
||||
alias gw-test='. .aliases; ./gradlew test'
|
||||
alias spotless='./gradlew spotlessApply -x pitest -x test -x :processResources'
|
||||
|
||||
|
@ -4,69 +4,31 @@
|
||||
classDiagram
|
||||
direction TD
|
||||
|
||||
namespace Hostsharing {
|
||||
class person-HostsharingEG
|
||||
}
|
||||
|
||||
namespace Partner {
|
||||
class partner-MeierGmbH
|
||||
class role-MeierGmbH
|
||||
class personDetails-MeierGmbH
|
||||
class contactData-MeierGmbH
|
||||
class person-MeierGmbH
|
||||
}
|
||||
|
||||
namespace Representatives {
|
||||
class person-FrankMeier
|
||||
class contactData-FrankMeier
|
||||
class role-MeierGmbH-FrankMeier
|
||||
}
|
||||
class partner-MeierGmbH
|
||||
class personDetails-MeierGmbH
|
||||
class contactData-MeierGmbH
|
||||
class person-MeierGmbH
|
||||
|
||||
class person-FrankMeier
|
||||
class contactData-FrankMeier
|
||||
class role-MeierGmbH-FrankMeier
|
||||
|
||||
class person-SabineMeier
|
||||
class contactData-SabineMeier
|
||||
class role-MeierGmbH-SabineMeier
|
||||
|
||||
namespace Debitors {
|
||||
class debitor-MeierGmbH
|
||||
class contactData-MeierGmbH-Buha
|
||||
class role-MeierGmbH-Buha
|
||||
}
|
||||
|
||||
namespace Operations {
|
||||
class person-SabineMeier
|
||||
class contactData-SabineMeier
|
||||
class role-MeierGmbH-SabineMeier
|
||||
}
|
||||
|
||||
namespace Enums {
|
||||
|
||||
class RoleType {
|
||||
<<enumeration>>
|
||||
UNKNOWN
|
||||
REPRESENTATIVE
|
||||
ACCOUNTING
|
||||
OPERATIONS
|
||||
}
|
||||
|
||||
class PersonType {
|
||||
<<enumeration>>
|
||||
UNKNOWN: nur für Import
|
||||
NATURAL_PERSON: natürliche Person
|
||||
LEGAL_PERSON: z.B. GmbH, e.K., eG, e.V.
|
||||
INCORORATED_FIRM: z.B. OHG, Partnerschaftsgesellschaft
|
||||
UNINCORPORATED_FIRM: z.B. GbR, ARGE, Erbengemeinschaft
|
||||
PUBLIC_INSTITUTION: KdöR, AöR [ohne Registergericht/Registernummer]
|
||||
}
|
||||
}
|
||||
|
||||
class person-HostsharingEG {
|
||||
+personType: LEGAL
|
||||
+tradeName: Hostsahring eG
|
||||
+familyName
|
||||
+givenName
|
||||
}
|
||||
|
||||
class partner-MeierGmbH {
|
||||
+Numeric partnerNumber: 12345
|
||||
+Role partnerRole
|
||||
+partnerNumber: 12345
|
||||
+person
|
||||
}
|
||||
partner-MeierGmbH o-- role-MeierGmbH
|
||||
partner-MeierGmbH o-- person-MeierGmbH
|
||||
|
||||
class person-MeierGmbH {
|
||||
+personType: LEGAL
|
||||
@ -74,15 +36,17 @@ classDiagram
|
||||
+familyName
|
||||
+givenName
|
||||
}
|
||||
person-MeierGmbH *-- personDetails-MeierGmbH
|
||||
person-MeierGmbH *-- personDetails-MeierGmbH : optiona
|
||||
|
||||
class personDetails-MeierGmbH {
|
||||
+personContact
|
||||
+registrationOffice: AG Hamburg
|
||||
+registrationNumber: ABC123434
|
||||
+birthName
|
||||
+birthPlace
|
||||
+dateOfDeath
|
||||
}
|
||||
personDetails-MeierGmbH o-- contactData-MeierGmbH
|
||||
|
||||
class contactData-MeierGmbH {
|
||||
+postalAddress: Hauptstraße 5, 22345 Hamburg
|
||||
@ -90,18 +54,6 @@ classDiagram
|
||||
+emailAddresses: office@meier-gmbh.de
|
||||
}
|
||||
|
||||
class role-MeierGmbH {
|
||||
+RoleType RoleType PARTNER
|
||||
+Person anchor
|
||||
+Person holder
|
||||
+Contact roleContact
|
||||
}
|
||||
role-MeierGmbH o-- person-HostsharingEG : anchor
|
||||
role-MeierGmbH o-- person-MeierGmbH : holder
|
||||
role-MeierGmbH o-- contactData-MeierGmbH
|
||||
|
||||
%% --- Debitors ---
|
||||
|
||||
class debitor-MeierGmbH {
|
||||
+Partner partner
|
||||
+Numeric[2] debitorNumberSuffix: 00
|
||||
@ -133,8 +85,6 @@ classDiagram
|
||||
role-MeierGmbH-Buha o-- person-MeierGmbH : holder
|
||||
role-MeierGmbH-Buha o-- contactData-MeierGmbH-Buha
|
||||
|
||||
%% --- Representatives ---
|
||||
|
||||
class person-FrankMeier {
|
||||
+ personType: NATURAL
|
||||
+ tradeName
|
||||
@ -158,8 +108,6 @@ classDiagram
|
||||
role-MeierGmbH-FrankMeier o-- person-FrankMeier : holder
|
||||
role-MeierGmbH-FrankMeier o-- contactData-FrankMeier
|
||||
|
||||
%% --- Operations ---
|
||||
|
||||
class person-SabineMeier {
|
||||
+personType: NATURAL
|
||||
+tradeName
|
||||
@ -183,4 +131,25 @@ classDiagram
|
||||
role-MeierGmbH-SabineMeier o-- person-SabineMeier : holder
|
||||
role-MeierGmbH-SabineMeier o-- contactData-SabineMeier
|
||||
|
||||
namespace Enums {
|
||||
|
||||
class RoleType {
|
||||
<<enumeration>>
|
||||
UNKNOWN
|
||||
REPRESENTATIVE
|
||||
ACCOUNTING
|
||||
OPERATIONS
|
||||
}
|
||||
|
||||
class PersonType {
|
||||
<<enumeration>>
|
||||
UNKNOWN: nur für Import
|
||||
NATURAL_PERSON: natürliche Person
|
||||
LEGAL_PERSON: z.B. GmbH, e.K., eG, e.V.
|
||||
INCORORATED_FIRM: z.B. OHG, Partnerschaftsgesellschaft
|
||||
UNINCORPORATED_FIRM: z.B. GbR, ARGE, Erbengemeinschaft
|
||||
PUBLIC_INSTITUTION: KdöR, AöR [ohne Registergericht/Registernummer]
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.hostsharing.hsadminng.hs.office.debitor;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
||||
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
||||
@ -36,10 +35,6 @@ class HsOfficeDebitorEntityPatcher implements EntityPatcher<HsOfficeDebitorPatch
|
||||
verifyNotNull(newValue, "defaultPrefix");
|
||||
entity.setDefaultPrefix(newValue);
|
||||
});
|
||||
OptionalFromJson.of(resource.getRefundBankAccountUuid()).ifPresent(newValue -> {
|
||||
verifyNotNull(newValue, "refundBankAccount");
|
||||
entity.setRefundBankAccount(em.getReference(HsOfficeBankAccountEntity.class, newValue));
|
||||
});
|
||||
}
|
||||
|
||||
private void verifyNotNull(final Object newValue, final String propertyName) {
|
||||
|
@ -17,7 +17,7 @@ create table hs_office_debitor
|
||||
vatReverseCharge boolean not null,
|
||||
refundBankAccountUuid uuid references hs_office_bankaccount(uuid),
|
||||
defaultPrefix char(3) not null
|
||||
constraint check_default_prefix check (
|
||||
constraint check_member_code check (
|
||||
defaultPrefix::text ~ '^([a-z]{3}|al0|bh1|c4s|f3k|k8i|l3d|mh1|o13|p2m|s80|t4w)$'
|
||||
)
|
||||
-- TODO.impl: SEPA-mandate
|
||||
|
@ -33,6 +33,7 @@ begin
|
||||
select c.* from hs_office_contact c where c.label = billingContactLabel into relatedContact;
|
||||
select b.uuid from hs_office_bankaccount b where b.holder = partnerTradeName into relatedBankAccountUuid;
|
||||
|
||||
-- raise notice 'creating test debitor: % (#%)', idName, relatedPartner.debitorNumberPrefix || '00';
|
||||
raise notice 'creating test debitor: % (#%)', idName, debitorNumberSuffix;
|
||||
raise notice '- using partner (%): %', relatedPartner.uuid, relatedPartner;
|
||||
raise notice '- using billingContact (%): %', relatedContact.uuid, relatedContact;
|
||||
|
@ -8,11 +8,14 @@
|
||||
/*
|
||||
Creates a single membership test record.
|
||||
*/
|
||||
-- create or replace procedure createHsOfficeMembershipTestData( forPartnerTradeName varchar, forMainDebitorNumber integer )
|
||||
create or replace procedure createHsOfficeMembershipTestData( forPartnerTradeName varchar, forMainDebitorNumber numeric )
|
||||
language plpgsql as $$
|
||||
declare
|
||||
currentTask varchar;
|
||||
idName varchar;
|
||||
-- forDebitorNumberPrefix integer;
|
||||
-- forDebitorNumberSuffix integer;
|
||||
relatedPartner hs_office_partner;
|
||||
relatedDebitor hs_office_debitor;
|
||||
newMemberNumber numeric;
|
||||
@ -25,6 +28,9 @@ begin
|
||||
select partner.* from hs_office_partner partner
|
||||
join hs_office_person person on person.uuid = partner.personUuid
|
||||
where person.tradeName = forPartnerTradeName into relatedPartner;
|
||||
-- forDebitorNumberPrefix := forMainDebitorNumber/ 100;
|
||||
-- forDebitorNumberSuffix := mod(forMainDebitorNumber, 100);
|
||||
-- select d.* from hs_office_debitor d where d.debitorNumberSuffix = forDebitorNumberSuffix into relatedDebitor;
|
||||
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;
|
||||
|
||||
@ -33,6 +39,7 @@ begin
|
||||
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, forDebitorNumberPrefix, daterange('20221001' , null, '[]'), 'NONE');
|
||||
values (uuid_generate_v4(), relatedPartner.uuid, relatedDebitor.uuid, newMemberNumber, daterange('20221001' , null, '[]'), 'NONE');
|
||||
end; $$;
|
||||
--//
|
||||
@ -48,5 +55,10 @@ do language plpgsql $$
|
||||
call createHsOfficeMembershipTestData('Second e.K.', 12);
|
||||
call createHsOfficeMembershipTestData('Third OHG', 13);
|
||||
end;
|
||||
-- begin
|
||||
-- call createHsOfficeMembershipTestData('First GmbH', 1000100);
|
||||
-- call createHsOfficeMembershipTestData('Second e.K.', 1000200);
|
||||
-- call createHsOfficeMembershipTestData('Third OHG', 1000300);
|
||||
-- end;
|
||||
$$;
|
||||
--//
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.hostsharing.hsadminng.hs.office.debitor;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
@ -43,9 +42,6 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
private static final boolean INITIAL_VAT_REVERSE_CHARGE = true;
|
||||
private static final boolean PATCHED_VAT_REVERSE_CHARGE = false;
|
||||
|
||||
private static final UUID INITIAL_REFUND_BANK_ACCOUNT_UUID = UUID.randomUUID();
|
||||
private static final UUID PATCHED_REFUND_BANK_ACCOUNT_UUID = UUID.randomUUID();
|
||||
|
||||
private final HsOfficePartnerEntity givenInitialPartner = HsOfficePartnerEntity.builder()
|
||||
.uuid(INITIAL_PARTNER_UUID)
|
||||
.build();
|
||||
@ -53,10 +49,6 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
private final HsOfficeContactEntity givenInitialContact = HsOfficeContactEntity.builder()
|
||||
.uuid(INITIAL_CONTACT_UUID)
|
||||
.build();
|
||||
|
||||
private final HsOfficeBankAccountEntity givenInitialBankAccount = HsOfficeBankAccountEntity.builder()
|
||||
.uuid(INITIAL_REFUND_BANK_ACCOUNT_UUID)
|
||||
.build();
|
||||
@Mock
|
||||
private EntityManager em;
|
||||
|
||||
@ -64,8 +56,8 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
void initMocks() {
|
||||
lenient().when(em.getReference(eq(HsOfficeContactEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeContactEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficeBankAccountEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeBankAccountEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficeContactEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeContactEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,7 +72,6 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
entity.setVatBusiness(true);
|
||||
entity.setVatReverseCharge(INITIAL_VAT_REVERSE_CHARGE);
|
||||
entity.setDefaultPrefix("abc");
|
||||
entity.setRefundBankAccount(givenInitialBankAccount);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ -129,7 +120,7 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
new SimpleProperty<>(
|
||||
"personType",
|
||||
HsOfficeDebitorPatchResource::setVatBusiness,
|
||||
PATCHED_VAT_BUSINESS,
|
||||
PATCHED_BILLABLE,
|
||||
HsOfficeDebitorEntity::setVatBusiness)
|
||||
.notNullable(),
|
||||
new SimpleProperty<>(
|
||||
@ -143,13 +134,6 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
HsOfficeDebitorPatchResource::setDefaultPrefix,
|
||||
PATCHED_DEFAULT_PREFIX,
|
||||
HsOfficeDebitorEntity::setDefaultPrefix)
|
||||
.notNullable(),
|
||||
new JsonNullableProperty<>(
|
||||
"refundBankAccount",
|
||||
HsOfficeDebitorPatchResource::setRefundBankAccountUuid,
|
||||
PATCHED_REFUND_BANK_ACCOUNT_UUID,
|
||||
HsOfficeDebitorEntity::setRefundBankAccount,
|
||||
newBankAccount(PATCHED_REFUND_BANK_ACCOUNT_UUID))
|
||||
.notNullable()
|
||||
);
|
||||
}
|
||||
@ -159,10 +143,4 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
newContact.setUuid(uuid);
|
||||
return newContact;
|
||||
}
|
||||
|
||||
private HsOfficeBankAccountEntity newBankAccount(final UUID uuid) {
|
||||
final var newBankAccount = new HsOfficeBankAccountEntity();
|
||||
newBankAccount.setUuid(uuid);
|
||||
return newBankAccount;
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,14 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf;
|
||||
@ -64,6 +65,8 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
@MockBean
|
||||
HttpServletRequest request;
|
||||
|
||||
Set<HsOfficeDebitorEntity> tempDebitors = new HashSet<>();
|
||||
|
||||
@Nested
|
||||
class CreateDebitor {
|
||||
|
||||
@ -94,34 +97,6 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
assertThat(debitorRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"", "a", "ab", "a12", "123", "12a"})
|
||||
@Transactional
|
||||
public void canNotCreateNewDebitorWithInvalidDefaultPrefix(final String givenPrefix) {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var count = debitorRepo.count();
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First GmbH").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("first contact").get(0);
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix((byte)21)
|
||||
.partner(givenPartner)
|
||||
.billingContact(givenContact)
|
||||
.billable(true)
|
||||
.vatReverseCharge(false)
|
||||
.vatBusiness(false)
|
||||
.defaultPrefix(givenPrefix)
|
||||
.build();
|
||||
return debitorRepo.save(newDebitor);
|
||||
});
|
||||
|
||||
// then
|
||||
result.assertExceptionWithRootCauseMessage(org.hibernate.exception.ConstraintViolationException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsAndGrantsRoles() {
|
||||
// given
|
||||
@ -589,6 +564,14 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
}).assertSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@AfterEach
|
||||
void cleanup() {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
// TODO em.createQuery("DELETE FROM HsOfficeDebitorEntity d where d.debitorNumberSuffix >= 20").executeUpdate();
|
||||
em.createQuery("DELETE FROM HsOfficeDebitorEntity d where d.debitorNumberSuffix >= 20000").executeUpdate();
|
||||
}
|
||||
|
||||
void exactlyTheseDebitorsAreReturned(final List<HsOfficeDebitorEntity> actualResult, final String... debitorNames) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsOfficeDebitorEntity::toString)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.hostsharing.test;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.migration.HasUuid;
|
||||
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
||||
import org.junit.jupiter.api.Named;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -233,7 +232,7 @@ public abstract class PatchUnitTestBase<R, E> {
|
||||
}
|
||||
}
|
||||
|
||||
protected static class JsonNullableProperty<R, RV, E extends HasUuid, EV> extends Property<R, RV, E, EV> {
|
||||
protected static class JsonNullableProperty<R, RV, E, EV> extends Property<R, RV, E, EV> {
|
||||
|
||||
private final BiConsumer<R, JsonNullable<RV>> resourceSetter;
|
||||
public final RV givenPatchValue;
|
||||
|
Loading…
Reference in New Issue
Block a user