Skip to content

Commit e0cf37c

Browse files
committed
chore: [LOB-1806] Reconciliation indexer endpoint
1 parent af83744 commit e0cf37c

File tree

33 files changed

+3391
-85
lines changed

33 files changed

+3391
-85
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.cardanofoundation.lob.app.accounting_reporting_core.domain.core;
2+
3+
import java.util.List;
4+
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
public record OnChainTransactionDto(
10+
@JsonProperty("id") String id,
11+
@JsonProperty("tx_hash") String txHash,
12+
@JsonProperty("internal_number") String internalNumber,
13+
@JsonProperty("accounting_period") String accountingPeriod,
14+
@JsonProperty("batch_id") String batchId,
15+
@JsonProperty("type") String type,
16+
@JsonProperty("date") String date,
17+
@JsonProperty("organisation_id") String organisationId,
18+
@JsonProperty("items") List<OnChainTransactionItemDto> items
19+
) {
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.cardanofoundation.lob.app.accounting_reporting_core.domain.core;
2+
3+
import java.math.BigDecimal;
4+
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
public record OnChainTransactionItemDto(
10+
@JsonProperty("id") String id,
11+
@JsonProperty("amountFcy") BigDecimal amountFcy,
12+
@JsonProperty("fxRate") String fxRate,
13+
@JsonProperty("documentNumber") String documentNumber,
14+
@JsonProperty("currency") String currency,
15+
@JsonProperty("costCenterName") String costCenterName,
16+
@JsonProperty("costCenterCustCode") String costCenterCustCode,
17+
@JsonProperty("vatRate") String vatRate,
18+
@JsonProperty("vatCustCode") String vatCustCode,
19+
@JsonProperty("eventCode") String eventCode,
20+
@JsonProperty("eventName") String eventName,
21+
@JsonProperty("projectCustCode") String projectCustCode,
22+
@JsonProperty("projectName") String projectName
23+
) {
24+
}

accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/domain/entity/TransactionEntity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ public class TransactionEntity extends CommonEntity implements Persistable<Strin
210210

211211
@OneToOne(fetch = FetchType.LAZY)
212212
@JoinColumn(name = "reconcilation_id")
213+
@DiffIgnore
213214
@Nullable
214215
private ReconcilationEntity lastReconcilation;
215216

accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/domain/entity/TransactionItemEntity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,7 @@ public int hashCode() {
256256
return Objects.hashCode(id);
257257
}
258258

259+
public int aggregatedHash() {
260+
return java.util.Objects.hash(accountEvent, fxRate, project, costCenter, document);
261+
}
259262
}

accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/domain/entity/reconcilation/ReconcilationViolation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,22 @@
2626
@AllArgsConstructor
2727
@NoArgsConstructor
2828
@Builder
29-
@EqualsAndHashCode
29+
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
3030
@Audited
3131
public class ReconcilationViolation {
3232

3333
@NotBlank
3434
@Getter
3535
@Setter
36+
@EqualsAndHashCode.Include
3637
private String transactionId;
3738

3839
@NotNull
3940
@Enumerated(STRING)
4041
@Getter
4142
@Setter
4243
@JdbcType(PostgreSQLEnumJdbcType.class)
44+
@EqualsAndHashCode.Include
4345
private ReconcilationRejectionCode rejectionCode;
4446

4547
@Type(value = io.hypersistence.utils.hibernate.type.json.JsonType.class)

accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/repository/AccountingCoreTransactionRepository.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ Set<TransactionEntity> findByEntryDateRangeAndNotReconciledYet(@Param("organisat
4141
@Param("startDate") LocalDate startDate,
4242
@Param("endDate") LocalDate endDate);
4343

44+
@Query("""
45+
SELECT t FROM accounting_reporting_core.TransactionEntity t
46+
WHERE t.organisation.id = :organisationId
47+
AND t.entryDate BETWEEN :startDate AND :endDate
48+
ORDER BY t.createdAt ASC, t.id ASC
49+
""")
50+
Set<TransactionEntity> findByEntryDateRange(@Param("organisationId") String organisactionId,
51+
@Param("startDate") LocalDate startDate,
52+
@Param("endDate") LocalDate endDate);
53+
54+
4455
@Query("""
4556
SELECT t FROM accounting_reporting_core.TransactionEntity t
4657
WHERE t.organisation.id = :organisationId

accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/repository/TransactionReconcilationRepository.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
import java.util.Optional;
44

5+
import jakarta.persistence.LockModeType;
6+
57
import org.springframework.data.jpa.repository.JpaRepository;
8+
import org.springframework.data.jpa.repository.Lock;
69

710
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.entity.reconcilation.ReconcilationEntity;
811

912
public interface TransactionReconcilationRepository extends JpaRepository<ReconcilationEntity, String> {
1013

1114
Optional<ReconcilationEntity> findTopByOrderByCreatedAtDesc();
15+
16+
@Lock(LockModeType.PESSIMISTIC_WRITE)
17+
Optional<ReconcilationEntity> findReconcilationEntityById(String id);
1218
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.cardanofoundation.lob.app.accounting_reporting_core.resource.requests;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public record OnChainTransactionSearchRequest(
6+
@JsonProperty("organisationId") String organisationId,
7+
@JsonProperty("dateFrom") String dateFrom,
8+
@JsonProperty("dateTo") String dateTo
9+
) {
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.cardanofoundation.lob.app.accounting_reporting_core.resource.response;
2+
3+
import java.util.List;
4+
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.core.OnChainTransactionDto;
9+
10+
@JsonIgnoreProperties(ignoreUnknown = true)
11+
public record OnChainTransactionsPageResponse(
12+
@JsonProperty("content") List<OnChainTransactionDto> content,
13+
@JsonProperty("total_elements") long totalElements,
14+
@JsonProperty("total_pages") int totalPages,
15+
@JsonProperty("last") boolean last,
16+
@JsonProperty("size") int size,
17+
@JsonProperty("number") int number,
18+
@JsonProperty("first") boolean first,
19+
@JsonProperty("empty") boolean empty
20+
) {
21+
}

accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/service/internal/AccountingCoreEventHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.event.extraction.ValidateIngestionResponseEvent;
2828
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.event.ledger.ReportsLedgerUpdatedEvent;
2929
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.event.ledger.TxsLedgerUpdatedEvent;
30-
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.event.reconcilation.ReconcilationChunkEvent;
31-
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.event.reconcilation.ReconcilationFailedEvent;
32-
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.event.reconcilation.ReconcilationFinalisationEvent;
33-
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.event.reconcilation.ReconcilationStartedEvent;
30+
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.event.reconcilation.*;
3431
import org.cardanofoundation.lob.app.accounting_reporting_core.job.TxStatusUpdaterJob;
3532
import org.cardanofoundation.lob.app.accounting_reporting_core.service.ValidateIngestionResponseWaiter;
3633
import org.cardanofoundation.lob.app.accounting_reporting_core.service.business_rules.ProcessorFlags;

0 commit comments

Comments
 (0)