Compare commits

..

No commits in common. "c70705a2e6e914822ee76b9233e88b75dfa4b241" and "cf4caf6e6617e76619fb6f85a474383f1b557310" have entirely different histories.

10 changed files with 49 additions and 103 deletions

View File

@ -53,25 +53,12 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, HasUu
@Column(name = "valuedate") @Column(name = "valuedate")
private LocalDate valueDate; private LocalDate valueDate;
/**
* The signed value which directly affects the booking balance.
*
* <p>This means, that a DEPOSIT is always positive, a DISBURSAL is always negative,
* but an ADJUSTMENT can bei either positive or negative.
* See {@link HsOfficeCoopAssetsTransactionType} for</p> more information.
*/
@Column(name = "assetvalue") @Column(name = "assetvalue")
private BigDecimal assetValue; private BigDecimal assetValue;
/**
* The booking reference.
*/
@Column(name = "reference") @Column(name = "reference")
private String reference; private String reference;
/**
* An optional arbitrary comment.
*/
@Column(name = "comment") @Column(name = "comment")
private String comment; private String comment;

View File

@ -1,43 +1,12 @@
package net.hostsharing.hsadminng.hs.office.coopassets; package net.hostsharing.hsadminng.hs.office.coopassets;
public enum HsOfficeCoopAssetsTransactionType { public enum HsOfficeCoopAssetsTransactionType {
/** ADJUSTMENT, // correction of wrong bookings
* correction of wrong bookings, value can be positive or negative DEPOSIT, // payment received from member after signing shares, >0
*/ DISBURSAL, // payment send to member after cancellation of shares, <0
ADJUSTMENT, TRANSFER, // transferring shares to another member, <0
ADOPTION, // receiving shares from another member, >0
/** CLEARING, // settlement with members dept, <0
* payment received from member after signing shares, value >0 LOSS, // assignment of balance sheet loss in case of cancellation of shares, <0
*/ LIMITATION // limitation period was reached after impossible disbursal, <0
DEPOSIT,
/**
* payment send to member after cancellation of shares, value <0
*/
DISBURSAL,
/**
* transferring shares to another member, value <0
*/
TRANSFER,
/**
* receiving shares from another member, value >0
*/
ADOPTION,
/**
* settlement with members dept, value <0
*/
CLEARING,
/**
* assignment of balance sheet loss in case of cancellation of shares, value <0
*/
LOSS,
/**
* limitation period was reached after impossible disbursal, value <0
*/
LIMITATION
} }

View File

@ -46,13 +46,6 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUu
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private HsOfficeCoopSharesTransactionType transactionType; private HsOfficeCoopSharesTransactionType transactionType;
/**
* The signed value which directly affects the booking balance.
*
* <p>This means, that a SUBSCRIPTION is always positive, a CANCELLATION is always negative,
* but an ADJUSTMENT can bei either positive or negative.
* See {@link HsOfficeCoopSharesTransactionType} for</p> more information.
*/
@Column(name = "valuedate") @Column(name = "valuedate")
private LocalDate valueDate; private LocalDate valueDate;
@ -76,6 +69,6 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUu
@Override @Override
public String toShortString() { public String toShortString() {
return "M-%s%+d".formatted(getMemberNumber(), shareCount); return "%s%+d".formatted(getMemberNumber(), shareCount);
} }
} }

View File

@ -1,18 +1,7 @@
package net.hostsharing.hsadminng.hs.office.coopshares; package net.hostsharing.hsadminng.hs.office.coopshares;
public enum HsOfficeCoopSharesTransactionType { public enum HsOfficeCoopSharesTransactionType {
/** ADJUSTMENT, // correction of wrong bookings
* correction of wrong bookings, with either positive or negative value SUBSCRIPTION, // shares signed, e.g. with the declaration of accession, >0
*/ CANCELLATION; // shares terminated, e.g. when a membership is resigned, <0
ADJUSTMENT,
/**
* shares signed, e.g. with the declaration of accession, value >0
*/
SUBSCRIPTION,
/**
* shares terminated, e.g. when a membership is resigned, value <0
*/
CANCELLATION;
} }

View File

@ -15,6 +15,7 @@ import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.*; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.*;

View File

@ -165,6 +165,7 @@ execute procedure hsOfficePartnerRbacRolesTrigger();
--changeset hs-office-partner-rbac-IDENTITY-VIEW:1 endDelimiter:--// --changeset hs-office-partner-rbac-IDENTITY-VIEW:1 endDelimiter:--//
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
call generateRbacIdentityView('hs_office_partner', $idName$ call generateRbacIdentityView('hs_office_partner', $idName$
-- TODO: simplify by using just partnerNumber for the essential part
partnerNumber || ':' || partnerNumber || ':' ||
(select idName from hs_office_person_iv p where p.uuid = target.personuuid) (select idName from hs_office_person_iv p where p.uuid = target.personuuid)
|| '-' || || '-' ||

View File

@ -10,7 +10,7 @@
*/ */
create or replace procedure createHsOfficeCoopSharesTransactionTestData( create or replace procedure createHsOfficeCoopSharesTransactionTestData(
givenPartnerNumber numeric, givenPartnerNumber numeric,
givenMemberNumberSuffix char(2) givenMemberNumberSuffix varchar -- TODO char(2)?
) )
language plpgsql as $$ language plpgsql as $$
declare declare

View File

@ -29,7 +29,7 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
void toShortStringContainsOnlyMemberNumberAndShareCountOnly() { void toShortStringContainsOnlyMemberNumberAndShareCountOnly() {
final var result = givenCoopSharesTransaction.toShortString(); final var result = givenCoopSharesTransaction.toShortString();
assertThat(result).isEqualTo("M-1000101+4"); assertThat(result).isEqualTo("1000101+4");
} }
@Test @Test
@ -43,6 +43,6 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
void toShortStringEmptyTransactionDoesNotThrowException() { void toShortStringEmptyTransactionDoesNotThrowException() {
final var result = givenEmptyCoopSharesTransaction.toShortString(); final var result = givenEmptyCoopSharesTransaction.toShortString();
assertThat(result).isEqualTo("M-null+0"); assertThat(result).isEqualTo("null+0");
} }
} }

View File

@ -11,6 +11,7 @@ import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.test.JpaAttempt;
import org.json.JSONException; import org.json.JSONException;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -36,8 +37,6 @@ import static org.hamcrest.Matchers.*;
@Transactional @Transactional
class HsOfficeMembershipControllerAcceptanceTest { class HsOfficeMembershipControllerAcceptanceTest {
private static String TEMP_MEMBER_NUMBER_SUFFIX = "90";
@LocalServerPort @LocalServerPort
private Integer port; private Integer port;
@ -62,6 +61,8 @@ class HsOfficeMembershipControllerAcceptanceTest {
@PersistenceContext @PersistenceContext
EntityManager em; EntityManager em;
private static int tempMemberNumberSuffix = 90; // TODO: check if we even need multiple distinct values
@Nested @Nested
@Accepts({ "Membership:F(Find)" }) @Accepts({ "Membership:F(Find)" })
class ListMemberships { class ListMemberships {
@ -184,8 +185,9 @@ class HsOfficeMembershipControllerAcceptanceTest {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0);
final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0);
final var givenMemberSuffix = TEMP_MEMBER_NUMBER_SUFFIX; final var givenMemberSuffixNumber = ++tempMemberNumberSuffix;
final var expectedMemberNumber = Integer.parseInt(givenPartner.getPartnerNumber() + TEMP_MEMBER_NUMBER_SUFFIX); final var givenMemberSuffix = toPaddedSuffix(givenMemberSuffixNumber);
final var expectedMemberNumber = givenPartner.getPartnerNumber()*100+givenMemberSuffixNumber;
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -501,7 +503,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.partner(givenPartner) .partner(givenPartner)
.mainDebitor(givenDebitor) .mainDebitor(givenDebitor)
.memberNumberSuffix(TEMP_MEMBER_NUMBER_SUFFIX) .memberNumberSuffix(toPaddedSuffix(++tempMemberNumberSuffix))
.validity(Range.closedInfinite(LocalDate.parse("2022-11-01"))) .validity(Range.closedInfinite(LocalDate.parse("2022-11-01")))
.reasonForTermination(NONE) .reasonForTermination(NONE)
.membershipFeeBillable(true) .membershipFeeBillable(true)
@ -511,15 +513,19 @@ class HsOfficeMembershipControllerAcceptanceTest {
}).assertSuccessful().returnedValue(); }).assertSuccessful().returnedValue();
} }
private String toPaddedSuffix(final int numericSuffix) {
return String.format("%02d", numericSuffix);
}
@BeforeEach
@AfterEach @AfterEach
void cleanup() { void cleanup() {
jpaAttempt.transacted(() -> { jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net", null); context.define("superuser-alex@hostsharing.net", null);
final var query = em.createQuery( final var query = em.createQuery("DELETE FROM HsOfficeMembershipEntity m WHERE m.memberNumberSuffix >= '90'");
"DELETE FROM HsOfficeMembershipEntity m WHERE m.memberNumberSuffix >= '%s'" if ( query.executeUpdate() > 0 ) {
.formatted(TEMP_MEMBER_NUMBER_SUFFIX) query.toString();
); }
query.executeUpdate();
}).assertSuccessful(); }).assertSuccessful();
} }
} }

View File

@ -176,15 +176,15 @@ public class ImportOfficeData extends ContextBasedTest {
assertThat(toFormattedString(contacts)).isEqualTo("{}"); assertThat(toFormattedString(contacts)).isEqualTo("{}");
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
{ {
17=debitor(D-1001700: null null, null: mih), 17=debitor(1001700: null null, null: mih),
20=debitor(D-1002000: null null, null: xyz), 20=debitor(1002000: null null, null: xyz),
22=debitor(D-1102200: null null, null: xxx)} 22=debitor(1102200: null null, null: xxx)}
"""); """);
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
{ {
17=Membership(M-1001700, null null, null, D-1001700, [2000-12-06,), NONE), 17=Membership(1001700, null null, null, 1001700, [2000-12-06,), NONE),
20=Membership(M-1002000, null null, null, D-1002000, [2000-12-06,2016-01-01), UNKNOWN), 20=Membership(1002000, null null, null, 1002000, [2000-12-06,2016-01-01), UNKNOWN),
22=Membership(M-1102200, null null, null, D-1102200, [2021-04-01,), NONE) 22=Membership(1102200, null null, null, 1102200, [2021-04-01,), NONE)
} }
"""); """);
} }
@ -235,16 +235,16 @@ public class ImportOfficeData extends ContextBasedTest {
"""); """);
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
{ {
17=debitor(D-1001700: NATURAL Mellies, Michael: mih), 17=debitor(1001700: NATURAL Mellies, Michael: mih),
20=debitor(D-1002000: LEGAL JM GmbH: xyz), 20=debitor(1002000: LEGAL JM GmbH: xyz),
22=debitor(D-1102200: LEGAL Test PS: xxx) 22=debitor(1102200: LEGAL Test PS: xxx)
} }
"""); """);
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
{ {
17=Membership(M-1001700, NATURAL Mellies, Michael, D-1001700, [2000-12-06,), NONE), 17=Membership(10017, NATURAL Mellies, Michael, 1001700, [2000-12-06,), NONE),
20=Membership(M-1002000, LEGAL JM GmbH, D-1002000, [2000-12-06,2016-01-01), UNKNOWN), 20=Membership(10020, LEGAL JM GmbH, 1002000, [2000-12-06,2016-01-01), UNKNOWN),
22=Membership(M-1102200, LEGAL Test PS, D-1102200, [2021-04-01,), NONE) 22=Membership(11022, LEGAL Test PS, 1102200, [2021-04-01,), NONE)
} }
"""); """);
assertThat(toFormattedString(relationships)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(relationships)).isEqualToIgnoringWhitespace("""
@ -312,10 +312,10 @@ public class ImportOfficeData extends ContextBasedTest {
assertThat(toFormattedString(coopShares)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(coopShares)).isEqualToIgnoringWhitespace("""
{ {
33443=CoopShareTransaction(M-1001700, 2000-12-06, SUBSCRIPTION, 20, initial share subscription), 33443=CoopShareTransaction(10017, 2000-12-06, SUBSCRIPTION, 20, initial share subscription),
33451=CoopShareTransaction(M-1002000, 2000-12-06, SUBSCRIPTION, 2, initial share subscription), 33451=CoopShareTransaction(10020, 2000-12-06, SUBSCRIPTION, 2, initial share subscription),
33701=CoopShareTransaction(M-1001700, 2005-01-10, SUBSCRIPTION, 40, increase), 33701=CoopShareTransaction(10017, 2005-01-10, SUBSCRIPTION, 40, increase),
33810=CoopShareTransaction(M-1002000, 2016-12-31, CANCELLATION, 22, membership ended) 33810=CoopShareTransaction(10020, 2016-12-31, CANCELLATION, 22, membership ended)
} }
"""); """);
} }