Compare commits
3 Commits
345359fd18
...
528ad42fa6
Author | SHA1 | Date | |
---|---|---|---|
|
528ad42fa6 | ||
|
c987cba53c | ||
|
73ea6b8ccc |
@ -27,8 +27,8 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
||||
public class HsOfficeBankAccountEntity implements HasUuid, Stringifyable {
|
||||
|
||||
private static Stringify<HsOfficeBankAccountEntity> toString = stringify(HsOfficeBankAccountEntity.class, "bankAccount")
|
||||
.withIdProp(HsOfficeBankAccountEntity::getIban)
|
||||
.withProp(Fields.holder, HsOfficeBankAccountEntity::getHolder)
|
||||
.withProp(Fields.iban, HsOfficeBankAccountEntity::getIban)
|
||||
.withProp(Fields.bic, HsOfficeBankAccountEntity::getBic);
|
||||
|
||||
@Id
|
||||
|
@ -34,7 +34,6 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, HasUu
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getAssetValue)
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getReference)
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getComment)
|
||||
.withSeparator(", ")
|
||||
.quotedValues(false);
|
||||
|
||||
@Id
|
||||
|
@ -31,7 +31,6 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUu
|
||||
.withProp(HsOfficeCoopSharesTransactionEntity::getShareCount)
|
||||
.withProp(HsOfficeCoopSharesTransactionEntity::getReference)
|
||||
.withProp(HsOfficeCoopSharesTransactionEntity::getComment)
|
||||
.withSeparator(", ")
|
||||
.quotedValues(false);
|
||||
|
||||
@Id
|
||||
|
@ -28,15 +28,11 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
|
||||
|
||||
public static final String DEBITOR_NUMBER_TAG = "D-";
|
||||
|
||||
// TODO: I would rather like to generate something matching this example:
|
||||
// debitor(1234500: Test AG, tes)
|
||||
// maybe remove withSepararator (always use ', ') and add withBusinessIdProp (with ': ' afterwards)?
|
||||
private static Stringify<HsOfficeDebitorEntity> stringify =
|
||||
stringify(HsOfficeDebitorEntity.class, "debitor")
|
||||
.withProp(e -> DEBITOR_NUMBER_TAG + e.getDebitorNumber())
|
||||
.withIdProp(HsOfficeDebitorEntity::toShortString)
|
||||
.withProp(HsOfficeDebitorEntity::getPartner)
|
||||
.withProp(HsOfficeDebitorEntity::getDefaultPrefix)
|
||||
.withSeparator(": ")
|
||||
.quotedValues(false);
|
||||
|
||||
@Id
|
||||
|
@ -25,8 +25,10 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
|
||||
@Query("""
|
||||
SELECT debitor FROM HsOfficeDebitorEntity debitor
|
||||
JOIN HsOfficePartnerEntity partner ON partner.uuid = debitor.partner.uuid
|
||||
JOIN HsOfficePersonEntity person ON person.uuid = partner.person.uuid
|
||||
JOIN HsOfficeContactEntity contact ON contact.uuid = debitor.billingContact.uuid
|
||||
JOIN HsOfficeRelationshipEntity rel ON rel.uuid = partner.partnerRole.uuid
|
||||
JOIN HsOfficePersonEntity person ON person.uuid = rel.relHolder.uuid
|
||||
JOIN HsOfficeContactEntity contact
|
||||
ON contact.uuid = debitor.billingContact.uuid OR contact.uuid = rel.contact.uuid
|
||||
WHERE :name is null
|
||||
OR partner.details.birthName like concat(cast(:name as text), '%')
|
||||
OR person.tradeName like concat(cast(:name as text), '%')
|
||||
|
@ -38,7 +38,6 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
|
||||
.withProp(e -> e.getMainDebitor().toShortString())
|
||||
.withProp(e -> e.getValidity().asString())
|
||||
.withProp(HsOfficeMembershipEntity::getReasonForTermination)
|
||||
.withSeparator(", ")
|
||||
.quotedValues(false);
|
||||
|
||||
@Id
|
||||
|
@ -31,7 +31,6 @@ public class HsOfficePartnerDetailsEntity implements HasUuid, Stringifyable {
|
||||
.withProp(HsOfficePartnerDetailsEntity::getBirthday)
|
||||
.withProp(HsOfficePartnerDetailsEntity::getBirthName)
|
||||
.withProp(HsOfficePartnerDetailsEntity::getDateOfDeath)
|
||||
.withSeparator(", ")
|
||||
.quotedValues(false);
|
||||
|
||||
@Id
|
||||
|
@ -30,14 +30,15 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
|
||||
public static final String PARTNER_NUMBER_TAG = "P-";
|
||||
|
||||
private static Stringify<HsOfficePartnerEntity> stringify = stringify(HsOfficePartnerEntity.class, "partner")
|
||||
.withIdProp(HsOfficePartnerEntity::getPartnerNumber)
|
||||
.withIdProp(HsOfficePartnerEntity::toShortString)
|
||||
.withProp(p -> ofNullable(p.getPartnerRole())
|
||||
.map(HsOfficeRelationshipEntity::getRelHolder)
|
||||
.map(HsOfficePersonEntity::toShortString))
|
||||
.map(HsOfficePersonEntity::toShortString)
|
||||
.orElse(null))
|
||||
.withProp(p -> ofNullable(p.getPartnerRole())
|
||||
.map(HsOfficeRelationshipEntity::getContact)
|
||||
.map(HsOfficeContactEntity::toShortString))
|
||||
.withSeparator(", ")
|
||||
.map(HsOfficeContactEntity::toShortString)
|
||||
.orElse(null))
|
||||
.quotedValues(false);
|
||||
|
||||
@Id
|
||||
|
@ -13,8 +13,9 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
|
||||
|
||||
@Query("""
|
||||
SELECT partner FROM HsOfficePartnerEntity partner
|
||||
JOIN HsOfficeContactEntity contact ON contact.uuid = partner.contact.uuid
|
||||
JOIN HsOfficePersonEntity person ON person.uuid = partner.person.uuid
|
||||
JOIN HsOfficeRelationshipEntity rel ON rel.uuid = partner.partnerRole.uuid
|
||||
JOIN HsOfficeContactEntity contact ON contact.uuid = rel.contact.uuid
|
||||
JOIN HsOfficePersonEntity person ON person.uuid = rel.relAnchor.uuid
|
||||
WHERE :name is null
|
||||
OR partner.details.birthName like concat(cast(:name as text), '%')
|
||||
OR contact.label like concat(cast(:name as text), '%')
|
||||
|
@ -33,7 +33,6 @@ public class HsOfficeSepaMandateEntity implements Stringifyable, HasUuid {
|
||||
.withProp(HsOfficeSepaMandateEntity::getReference)
|
||||
.withProp(HsOfficeSepaMandateEntity::getAgreement)
|
||||
.withProp(e -> e.getValidity().asString())
|
||||
.withSeparator(", ")
|
||||
.quotedValues(false);
|
||||
|
||||
@Id
|
||||
|
@ -70,8 +70,8 @@ public final class Stringify<B> {
|
||||
})
|
||||
.map(propVal -> propName(propVal, "=") + optionallyQuoted(propVal))
|
||||
.collect(Collectors.joining(separator));
|
||||
return idProp == null
|
||||
? name + "(" + idProp + ": " + propValues + ")"
|
||||
return idProp != null
|
||||
? name + "(" + idProp.apply(object) + ": " + propValues + ")"
|
||||
: name + "(" + propValues + ")";
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ do language plpgsql $$
|
||||
call createHsOfficePersonTestData('NP', null, 'Fouler', 'Ellie');
|
||||
call createHsOfficePersonTestData('LP', 'Second e.K.', 'Smith', 'Peter');
|
||||
call createHsOfficePersonTestData('IF', 'Third OHG');
|
||||
call createHsOfficePersonTestData('IF', 'Fourth eG');
|
||||
call createHsOfficePersonTestData('LP', 'Fourth eG');
|
||||
call createHsOfficePersonTestData('UF', 'Erben Bessler', 'Mel', 'Bessler');
|
||||
call createHsOfficePersonTestData('NP', null, 'Bessler', 'Anita');
|
||||
call createHsOfficePersonTestData('NP', null, 'Winkler', 'Paul');
|
||||
|
@ -42,6 +42,8 @@ begin
|
||||
|
||||
if TG_OP = 'INSERT' then
|
||||
|
||||
|
||||
|
||||
perform createRoleWithGrants(
|
||||
hsOfficeRelationshipOwner(NEW),
|
||||
permissions => array['*'],
|
||||
|
@ -30,13 +30,7 @@ declare
|
||||
oldPartnerRole hs_office_relationship;
|
||||
newPartnerRole hs_office_relationship;
|
||||
|
||||
oldPersonX hs_office_person;
|
||||
newPersonX hs_office_person;
|
||||
|
||||
oldContactX hs_office_contact;
|
||||
newContactX hs_office_contact;
|
||||
begin
|
||||
|
||||
select * from hs_office_relationship as r where r.uuid = NEW.partnerroleuuid into newPartnerRole;
|
||||
|
||||
if TG_OP = 'INSERT' then
|
||||
@ -46,7 +40,9 @@ begin
|
||||
perform createRoleWithGrants(
|
||||
hsOfficePartnerOwner(NEW),
|
||||
permissions => array['*'],
|
||||
incomingSuperRoles => array[globalAdmin()]
|
||||
incomingSuperRoles => array[globalAdmin()],
|
||||
outgoingSubRoles => array[
|
||||
hsOfficeRelationshipOwner(newPartnerRole)]
|
||||
);
|
||||
|
||||
perform createRoleWithGrants(
|
||||
@ -55,14 +51,14 @@ begin
|
||||
incomingSuperRoles => array[
|
||||
hsOfficePartnerOwner(NEW)],
|
||||
outgoingSubRoles => array[
|
||||
hsOfficeRelationshipTenant(newPartnerRole)]
|
||||
hsOfficeRelationshipAdmin(newPartnerRole)]
|
||||
);
|
||||
|
||||
perform createRoleWithGrants(
|
||||
hsOfficePartnerAgent(NEW),
|
||||
incomingSuperRoles => array[
|
||||
hsOfficePartnerAdmin(NEW),
|
||||
hsOfficeRelationshipAdmin(newPartnerRole)]
|
||||
hsOfficeRelationshipAgent(newPartnerRole)]
|
||||
);
|
||||
|
||||
perform createRoleWithGrants(
|
||||
|
@ -59,7 +59,7 @@ do language plpgsql $$
|
||||
$$;
|
||||
|
||||
-- TODO.refa: the code below could be moved to a generator, maybe even the code above.
|
||||
-- Additionally, the code below is not neccesary for all entities, specifiy when it is!
|
||||
-- Additionally, the code below is not necessary for all entities, specify when it is!
|
||||
|
||||
/**
|
||||
Used by the trigger to prevent the add-partner-details to current user respectively assumed roles.
|
||||
|
@ -19,7 +19,7 @@ class HsOfficeBankAccountEntityUnitTest {
|
||||
.iban("DE02370502990000684712")
|
||||
.bic("COKSDE33")
|
||||
.build();
|
||||
assertThat("" + givenBankAccount).isEqualTo("bankAccount(holder='given holder', iban='DE02370502990000684712', bic='COKSDE33')");
|
||||
assertThat(givenBankAccount.toString()).isEqualTo("bankAccount(DE02370502990000684712: holder='given holder', bic='COKSDE33')");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -32,7 +32,7 @@ class HsOfficeDebitorEntityUnitTest {
|
||||
|
||||
final var result = given.toString();
|
||||
|
||||
assertThat(result).isEqualTo("debitor(D-1234567: LP some trade name: som)");
|
||||
assertThat(result).isEqualTo("debitor(D-1234567: P-12345, som)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -49,7 +49,7 @@ class HsOfficeDebitorEntityUnitTest {
|
||||
|
||||
final var result = given.toString();
|
||||
|
||||
assertThat(result).isEqualTo("debitor(D-1234567: <person=null>)");
|
||||
assertThat(result).isEqualTo("debitor(D-1234567: P-12345)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -213,9 +213,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
// then
|
||||
allTheseDebitorsAreReturned(
|
||||
result,
|
||||
"debitor(D-1000111: LP First GmbH: fir)",
|
||||
"debitor(D-1000212: LP Second e.K.: sec)",
|
||||
"debitor(D-1000313: IF Third OHG: thi)");
|
||||
"debitor(D-1000111: P-10001, fir)",
|
||||
"debitor(D-1000212: P-10002, sec)",
|
||||
"debitor(D-1000313: P-10003, thi)");
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ -234,8 +234,8 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
|
||||
// then:
|
||||
exactlyTheseDebitorsAreReturned(result,
|
||||
"debitor(D-1000111: LP First GmbH: fir)",
|
||||
"debitor(D-1000120: LP First GmbH: fif)");
|
||||
"debitor(D-1000111: P-10001, fir)",
|
||||
"debitor(D-1000120: P-10001, fif)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -263,7 +263,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var result = debitorRepo.findDebitorByDebitorNumber(1000313);
|
||||
|
||||
// then
|
||||
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: IF Third OHG: thi)");
|
||||
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: P-10003, thi)");
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var result = debitorRepo.findDebitorByOptionalNameLike("third contact");
|
||||
|
||||
// then
|
||||
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: IF Third OHG: thi)");
|
||||
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: P-10003, thi)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,6 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
|
||||
@MockBean
|
||||
HttpServletRequest request;
|
||||
|
||||
@Test
|
||||
@Order(1010)
|
||||
void importBusinessPartners() {
|
||||
@ -520,7 +519,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context(rbacSuperuser);
|
||||
coopAssets.forEach(this::persist);
|
||||
updateLegacyIds(coopShares, "hs_office_coopassetstransaction_legacy_id", "member_asset_id");
|
||||
updateLegacyIds(coopAssets, "hs_office_coopassetstransaction_legacy_id", "member_asset_id");
|
||||
}).assertSuccessful();
|
||||
|
||||
}
|
||||
|
@ -227,9 +227,11 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
// then
|
||||
allThesePartnersAreReturned(
|
||||
result,
|
||||
"partner(IF Third OHG: third contact)",
|
||||
"partner(LP Second e.K.: second contact)",
|
||||
"partner(LP First GmbH: first contact)");
|
||||
"partner(P-10001: LP First GmbH, first contact)",
|
||||
"partner(P-10002: LP Second e.K., second contact)",
|
||||
"partner(P-10003: IF Third OHG, third contact)",
|
||||
"partner(P-10004: LP Fourth eG, fourth contact)",
|
||||
"partner(P-10010: NP Smith, Peter, sixth contact)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -241,7 +243,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var result = partnerRepo.findPartnerByOptionalNameLike(null);
|
||||
|
||||
// then:
|
||||
exactlyThesePartnersAreReturned(result, "partner(LP First GmbH: first contact)");
|
||||
exactlyThesePartnersAreReturned(result, "partner(P-10001: LP First GmbH: first contact)");
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,7 +259,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var result = partnerRepo.findPartnerByOptionalNameLike("third contact");
|
||||
|
||||
// then
|
||||
exactlyThesePartnersAreReturned(result, "partner(IF Third OHG: third contact)");
|
||||
exactlyThesePartnersAreReturned(result, "partner(P-10003: IF Third OHG, third contact)");
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,7 +278,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
assertThat(result)
|
||||
.isNotNull()
|
||||
.extracting(Object::toString)
|
||||
.isEqualTo("partner(LP First GmbH: first contact)");
|
||||
.isEqualTo("partner(P-10001: LP First GmbH, first contact)");
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,7 +319,6 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO: enable once partner.person and partner.contact are removed
|
||||
public void partnerAgent_canNotUpdateRelatedPartner() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
|
@ -370,7 +370,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
|
||||
.matches(mandate -> {
|
||||
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: LP First GmbH: fir)");
|
||||
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: P-10001, fir)");
|
||||
assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH");
|
||||
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z - patched");
|
||||
assertThat(mandate.getValidFrom()).isEqualTo("2020-06-05");
|
||||
@ -411,7 +411,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
||||
// finally, the sepaMandate is actually updated
|
||||
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
|
||||
.matches(mandate -> {
|
||||
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: LP First GmbH: fir)");
|
||||
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: P-10001, fir)");
|
||||
assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH");
|
||||
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z");
|
||||
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-01-01)");
|
||||
|
Loading…
Reference in New Issue
Block a user