Skip to content

Commit

Permalink
feat: report endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
M4rc0Russ0 committed Dec 17, 2024
1 parent c375953 commit 1820779
Show file tree
Hide file tree
Showing 20 changed files with 1,150 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Report {

private String reportId;

private String idReport;

private Organisation organisation;

private ReportType type;
Expand All @@ -27,6 +29,8 @@ public class Report {

private short year;

private String ver;

@Builder.Default
private Optional<Short> period = Optional.empty();

Expand All @@ -51,6 +55,19 @@ public class Report {
private LedgerDispatchStatus ledgerDispatchStatus = LedgerDispatchStatus.NOT_DISPATCHED;

public static String id(String organisationId,
ReportType reportType,
IntervalType intervalType,
short year,
String ver,
Optional<Short> period) {
return period.map(p -> {
return digestAsHex(STR."\{organisationId}::\{reportType}::\{intervalType}::\{year}::\{ver}::\{p}");
}).orElseGet(() -> {
return digestAsHex(STR."\{organisationId}::\{reportType}::\{intervalType}::\{year}::\{ver}");
});
}

public static String idControl(String organisationId,
ReportType reportType,
IntervalType intervalType,
short year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jakarta.persistence.Embeddable;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.core.Validable;
import org.cardanofoundation.lob.app.support.calc.BigDecimals;
import org.cardanofoundation.lob.app.support.calc.Summable;
Expand All @@ -10,6 +11,7 @@
import java.math.BigDecimal;
import java.util.Optional;

@Slf4j
@AllArgsConstructor
@Builder(toBuilder = true)
@EqualsAndHashCode
Expand All @@ -30,7 +32,7 @@ public class BalanceSheetData implements Validable, Summable {
@Override
public boolean isValid() {
return getAssets().isPresent() && getLiabilities().isPresent() && getCapital().isPresent()
&& assets.sumOf().equals(BigDecimals.sum(liabilities, capital));
&& 0 == assets.sumOf().compareTo(BigDecimals.sum(liabilities, capital));
}

public Optional<Assets> getAssets() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public class ReportEntity extends CommonEntity implements Persistable<String>, V
@Setter
private String reportId;

@Column(name = "id_control", nullable = false, length = 64)
@NotBlank
@Getter
@Setter
private String idControl;

@Column(name = "ver", nullable = false, length = 64)
@NotBlank
@Getter
@Setter
private String ver = "1";

@Override
public String getId() {
return reportId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;
import java.util.Set;

public interface ReportRepository extends JpaRepository<ReportEntity, String> {
Expand All @@ -19,4 +20,16 @@ public interface ReportRepository extends JpaRepository<ReportEntity, String> {
Set<ReportEntity> findDispatchableTransactions(@Param("organisationId") String organisationId,
Limit limit);


@Query("""
SELECT r FROM accounting_reporting_core.report.ReportEntity r
WHERE r.organisation.id = :organisationId
ORDER BY r.createdAt ASC, r.reportId ASC""")
Set<ReportEntity> findByOrganisationId(@Param("organisationId") String organisationId);

@Query("""
SELECT r FROM accounting_reporting_core.report.ReportEntity r
WHERE r.organisation.id = :organisationId
AND r.idControl = :idControl""")
Optional<ReportEntity> findByIdControl(@Param("organisationId") String organisationId,@Param("idControl") String idControl);
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.cardanofoundation.lob.app.accounting_reporting_core.resource.requests;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.core.report.IntervalType;
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.core.report.ReportType;

@Getter
@Setter
@AllArgsConstructor
//@Builder todo: For testing
@NoArgsConstructor
@Slf4j
public class BalanceSheetRequest {

@Schema(example = "75f95560c1d883ee7628993da5adf725a5d97a13929fd4f477be0faf5020ca94")
private String organisationID;

private ReportType reportType;

private IntervalType intervalType;

@Schema(example = "2024")
private short year;

@Schema(example = "3")
private short period;

@Schema(example = "265306.12")
private String propertyPlantEquipment;

@Schema(example = "63673.47")
private String intangibleAssets;

@Schema(example = "106122.45")
private String investments;

@Schema(example = "79591.84")
private String financialAssets;

@Schema(example = "15918.37")
private String prepaymentsAndOtherShortTermAssets;

@Schema(example = "26530.61")
private String otherReceivables;

@Schema(example = "53061.22")
private String cryptoAssets;

@Schema(example = "39795.92")
private String cashAndCashEquivalents;

@Schema(example = "20000.00")
private String provisions;

@Schema(example = "15000.00")
private String tradeAccountsPayables;

@Schema(example = "10000.00")
private String otherCurrentLiabilities;

@Schema(example = "5000.00")
private String accrualsAndShortTermProvisions;

@Schema(example = "300000.00")
private String capital;

@Schema(example = "100000.00")
private String profitForTheYear;

@Schema(example = "200000.00")
private String resultsCarriedForward;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package org.cardanofoundation.lob.app.accounting_reporting_core.resource.requests;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.core.report.IntervalType;
import org.cardanofoundation.lob.app.accounting_reporting_core.domain.core.report.ReportType;

@Getter
@Setter
@AllArgsConstructor
//@Builder todo: For testing
@NoArgsConstructor
@Slf4j
public class IncomeStatementRequest {

@Schema(example = "75f95560c1d883ee7628993da5adf725a5d97a13929fd4f477be0faf5020ca94")
private String organisationID;

@Schema(example = "INCOME_STATEMENT")
private ReportType reportType;

private IntervalType intervalType;

@Schema(example = "2024")
private short year;

@Schema(example = "3")
private short period;

@Schema(example = "10000.90")
private String otherIncome;

@Schema(example = "1000000.10")
private String buildOfLongTermProvision;

@Schema(example = "500000.15")
private String costOfProvidingServices;

@Schema(example = "200000.53")
private String financialRevenues;

@Schema(example = "100000.10")
private String netIncomeOptionsSale;

@Schema(example = "50000.15")
private String realisedGainsOnSaleOfCryptocurrencies;

@Schema(example = "10000.53")
private String stakingRewardsIncome;

@Schema(example = "20000.10")
private String financialExpenses;

@Schema(example = "10000.10")
private String extraordinaryExpenses;

@Schema(example = "1000.51")
private String incomeTaxExpense;

@Schema(example = "500000.15")
private String personnelExpenses;

@Schema(example = "200000.53")
private String generalAndAdministrativeExpenses;

@Schema(example = "200000.53")
private String depreciationAndImpairmentLossesOnTangibleAssets;

@Schema(example = "200000.53")
private String amortizationOnIntangibleAssets;

@Schema(example = "200000.53")
private String rentExpenses;

}
Loading

0 comments on commit 1820779

Please sign in to comment.