diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java index 332ea8dd..74787b0d 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java @@ -77,16 +77,16 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable { public String getDebitorNumberString() { // TODO: refactor - if (partner.getDebitorNumberPrefix() == null ) { + if (partner.getPartnerNumber() == null ) { if (debitorNumberSuffix == null) { return null; } return String.format("%02d", debitorNumberSuffix); } if (debitorNumberSuffix == null) { - return partner.getDebitorNumberPrefix() + "??"; + return partner.getPartnerNumber() + "??"; } - return partner.getDebitorNumberPrefix() + String.format("%02d", debitorNumberSuffix); + return partner.getPartnerNumber() + String.format("%02d", debitorNumberSuffix); } public Integer getDebitorNumber() { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java index 5ca04719..64be98b1 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java @@ -13,10 +13,10 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByDebitorNumber(int debitorNumberPrefix, byte debitorNumberSuffix); + List findDebitorByDebitorNumber(int partnerNumber, byte debitorNumberSuffix); default List findDebitorByDebitorNumber(int debitorNumber) { return findDebitorByDebitorNumber( debitorNumber/100, (byte) (debitorNumber%100)); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java index 95a30290..850b94db 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java @@ -36,8 +36,8 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid { @GeneratedValue private UUID uuid; - @Column(name = "debitornumberprefix", columnDefinition = "numeric(5) not null") - private Integer debitorNumberPrefix; + @Column(name = "partnernumber", columnDefinition = "numeric(5) not null") + private Integer partnerNumber; @ManyToOne @JoinColumn(name = "personuuid", nullable = false) diff --git a/src/main/resources/api-definition/hs-office/hs-office-partner-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-partner-schemas.yaml index 6b044a27..a6a94f67 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-partner-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-partner-schemas.yaml @@ -9,7 +9,7 @@ components: uuid: type: string format: uuid - debitorNumberPrefix: + partnerNumber: type: integer format: int8 minimum: 10000 @@ -91,7 +91,7 @@ components: HsOfficePartnerInsert: type: object properties: - debitorNumberPrefix: + partnerNumber: type: integer format: int8 minimum: 10000 @@ -105,7 +105,7 @@ components: details: $ref: '#/components/schemas/HsOfficePartnerDetailsInsert' required: - - debitorNumberPrefix + - partnerNumber - personUuid - contactUuid - details diff --git a/src/main/resources/db/changelog/220-hs-office-partner.sql b/src/main/resources/db/changelog/220-hs-office-partner.sql index 340c0455..67126766 100644 --- a/src/main/resources/db/changelog/220-hs-office-partner.sql +++ b/src/main/resources/db/changelog/220-hs-office-partner.sql @@ -32,7 +32,7 @@ call create_journal('hs_office_partner_details'); create table hs_office_partner ( uuid uuid unique references RbacObject (uuid) initially deferred, - debitorNumberPrefix varchar(5), + partnerNumber varchar(5), personUuid uuid not null references hs_office_person(uuid), contactUuid uuid not null references hs_office_contact(uuid), detailsUuid uuid not null references hs_office_partner_details(uuid) on delete cascade diff --git a/src/main/resources/db/changelog/223-hs-office-partner-rbac.sql b/src/main/resources/db/changelog/223-hs-office-partner-rbac.sql index db5db365..852ed8ad 100644 --- a/src/main/resources/db/changelog/223-hs-office-partner-rbac.sql +++ b/src/main/resources/db/changelog/223-hs-office-partner-rbac.sql @@ -165,8 +165,8 @@ execute procedure hsOfficePartnerRbacRolesTrigger(); --changeset hs-office-partner-rbac-IDENTITY-VIEW:1 endDelimiter:--// -- ---------------------------------------------------------------------------- call generateRbacIdentityView('hs_office_partner', $idName$ - -- TODO: simplify by using just debitorNumberPrefix for the essential part - debitorNumberPrefix || ':' || + -- TODO: simplify by using just partnerNumber for the essential part + partnerNumber || ':' || (select idName from hs_office_person_iv p where p.uuid = target.personuuid) || '-' || (select idName from hs_office_contact_iv c where c.uuid = target.contactuuid) @@ -180,7 +180,7 @@ call generateRbacIdentityView('hs_office_partner', $idName$ call generateRbacRestrictedView('hs_office_partner', '(select idName from hs_office_person_iv p where p.uuid = target.personUuid)', $updates$ - debitorNumberPrefix = new.debitorNumberPrefix, + partnerNumber = new.partnerNumber, personUuid = new.personUuid, contactUuid = new.contactUuid $updates$); diff --git a/src/main/resources/db/changelog/228-hs-office-partner-test-data.sql b/src/main/resources/db/changelog/228-hs-office-partner-test-data.sql index 759c48c9..64df0695 100644 --- a/src/main/resources/db/changelog/228-hs-office-partner-test-data.sql +++ b/src/main/resources/db/changelog/228-hs-office-partner-test-data.sql @@ -9,7 +9,7 @@ Creates a single partner test record. */ create or replace procedure createHsOfficePartnerTestData( - debitorNumberPrefix numeric(5), + partnerNumber numeric(5), personTradeOrFamilyName varchar, contactLabel varchar ) language plpgsql as $$ @@ -54,8 +54,8 @@ begin end if; insert - into hs_office_partner (uuid, debitorNumberPrefix, personuuid, contactuuid, detailsUuid) - values (uuid_generate_v4(), debitorNumberPrefix, relatedPerson.uuid, relatedContact.uuid, relatedDetailsUuid); + into hs_office_partner (uuid, partnerNumber, personuuid, contactuuid, detailsUuid) + values (uuid_generate_v4(), partnerNumber, relatedPerson.uuid, relatedContact.uuid, relatedDetailsUuid); end; $$; --// diff --git a/src/main/resources/db/changelog/273-hs-office-debitor-rbac.sql b/src/main/resources/db/changelog/273-hs-office-debitor-rbac.sql index 78daaea5..ad12e713 100644 --- a/src/main/resources/db/changelog/273-hs-office-debitor-rbac.sql +++ b/src/main/resources/db/changelog/273-hs-office-debitor-rbac.sql @@ -173,7 +173,7 @@ execute procedure hsOfficeDebitorRbacRolesTrigger(); -- ---------------------------------------------------------------------------- call generateRbacIdentityView('hs_office_debitor', $idName$ '#' || - (select debitornumberprefix from hs_office_partner p where p.uuid = target.partnerUuid) || + (select partnerNumber from hs_office_partner p where p.uuid = target.partnerUuid) || to_char(debitorNumberSuffix, 'fm00') || ':' || (select split_part(idName, ':', 2) from hs_office_partner_iv pi where pi.uuid = target.partnerUuid) $idName$); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java index 270431b9..c1cb6c18 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java @@ -21,7 +21,7 @@ class HsOfficeDebitorEntityUnitTest { .tradeName("some trade name") .build()) .details(HsOfficePartnerDetailsEntity.builder().birthName("some birth name").build()) - .debitorNumberPrefix(12345) + .partnerNumber(12345) .build()) .billingContact(HsOfficeContactEntity.builder().label("some label").build()) .defaultPrefix("som") @@ -39,7 +39,7 @@ class HsOfficeDebitorEntityUnitTest { .partner(HsOfficePartnerEntity.builder() .person(null) .details(HsOfficePartnerDetailsEntity.builder().birthName("some birth name").build()) - .debitorNumberPrefix(12345) + .partnerNumber(12345) .build()) .billingContact(HsOfficeContactEntity.builder().label("some label").build()) .build(); @@ -53,7 +53,7 @@ class HsOfficeDebitorEntityUnitTest { void toShortStringContainsDebitorNumber() { final var given = HsOfficeDebitorEntity.builder() .partner(HsOfficePartnerEntity.builder() - .debitorNumberPrefix(12345) + .partnerNumber(12345) .build()) .debitorNumberSuffix((byte)67) .build(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index fea66f1b..a711aed0 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -551,7 +551,7 @@ public class ImportOfficeData extends ContextBasedTest { final var person = HsOfficePersonEntity.builder().build(); final var partner = HsOfficePartnerEntity.builder() - .debitorNumberPrefix(rec.getInteger("member_id")) + .partnerNumber(rec.getInteger("member_id")) .details(HsOfficePartnerDetailsEntity.builder().build()) .contact(null) // is set during contacts import depending on assigned roles .person(person) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java index 0ac1eb2d..61196cae 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java @@ -125,7 +125,7 @@ class HsOfficePartnerControllerAcceptanceTest { .contentType(ContentType.JSON) .body(""" { - "debitorNumberPrefix": "12345", + "partnerNumber": "12345", "contactUuid": "%s", "personUuid": "%s", "details": { @@ -167,7 +167,7 @@ class HsOfficePartnerControllerAcceptanceTest { .contentType(ContentType.JSON) .body(""" { - "debitorNumberPrefix": "12345", + "partnerNumber": "12345", "contactUuid": "%s", "personUuid": "%s", "details": {} @@ -195,7 +195,7 @@ class HsOfficePartnerControllerAcceptanceTest { .contentType(ContentType.JSON) .body(""" { - "debitorNumberPrefix": "12345", + "partnerNumber": "12345", "contactUuid": "%s", "personUuid": "%s", "details": {} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java index ad41e939..18eb063d 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java @@ -105,7 +105,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest { final var givenPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0); final var newPartner = toCleanup(HsOfficePartnerEntity.builder() - .debitorNumberPrefix(22222) + .partnerNumber(22222) .person(givenPerson) .contact(givenContact) .details(HsOfficePartnerDetailsEntity.builder().build()) @@ -396,13 +396,13 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest { } private HsOfficePartnerEntity givenSomeTemporaryPartnerBessler( - final Integer debitorNumberPrefix, final String person, final String contact) { + final Integer partnerNumber, final String person, final String contact) { return jpaAttempt.transacted(() -> { context("superuser-alex@hostsharing.net"); final var givenPerson = personRepo.findPersonByOptionalNameLike(person).get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike(contact).get(0); final var newPartner = HsOfficePartnerEntity.builder() - .debitorNumberPrefix(debitorNumberPrefix) + .partnerNumber(partnerNumber) .person(givenPerson) .contact(givenContact) .details(HsOfficePartnerDetailsEntity.builder().build()) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java index 8ac5ae85..316496bc 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java @@ -12,7 +12,7 @@ public class TestHsOfficePartner { static public HsOfficePartnerEntity hsOfficePartnerWithLegalPerson(final String tradeName) { return HsOfficePartnerEntity.builder() - .debitorNumberPrefix(10001) + .partnerNumber(10001) .person(HsOfficePersonEntity.builder() .personType(LEGAL) .tradeName(tradeName)