From 30041032880120df2facc8bd7f8ad6b85495a614 Mon Sep 17 00:00:00 2001 From: Marco Russo Date: Thu, 7 Nov 2024 23:55:47 +0000 Subject: [PATCH] feat: organisation costCenter and projects --- .../application-dev--yaci-dev-kit.properties | 2 +- .../CustomTransactionRepositoryImpl.java | 10 ++-- ...AccountingCorePresentationViewService.java | 16 +++++- .../organisation/OrganisationPublicApi.java | 1 - .../view/OrganisationCostCenterView.java | 17 ++++++ .../domain/view/OrganisationView.java | 5 ++ .../repository/CostCenterRepository.java | 7 +++ .../repository/ProjectMappingRepository.java | 7 ++- .../resource/OrganisationResource.java | 55 +++++++++++++++++++ .../service/CostCenterService.java | 6 ++ .../service/OrganisationService.java | 14 +++++ 11 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationCostCenterView.java diff --git a/_backend-services/cf-lob-ledger-follower-app/src/main/resources/application-dev--yaci-dev-kit.properties b/_backend-services/cf-lob-ledger-follower-app/src/main/resources/application-dev--yaci-dev-kit.properties index 688ca336..28ada459 100644 --- a/_backend-services/cf-lob-ledger-follower-app/src/main/resources/application-dev--yaci-dev-kit.properties +++ b/_backend-services/cf-lob-ledger-follower-app/src/main/resources/application-dev--yaci-dev-kit.properties @@ -23,4 +23,4 @@ store.cardano.shelley-genesis-file: classpath:/devkit/shelley-genesis.json store.cardano.alonzo-genesis-file: classpath:/devkit/alonzo-genesis.json store.cardano.conway-genesis-file: classpath:/devkit/conway-genesis.json -#spring.profiles.active=dev--yaci-dev-kit \ No newline at end of file +#spring.profiles.active=dev--yaci-dev-kit diff --git a/accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/repository/CustomTransactionRepositoryImpl.java b/accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/repository/CustomTransactionRepositoryImpl.java index dcff99e5..ca570d72 100644 --- a/accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/repository/CustomTransactionRepositoryImpl.java +++ b/accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/repository/CustomTransactionRepositoryImpl.java @@ -80,8 +80,8 @@ public List findAllReconciliationSpecialCount(Set findAllReconciliationSpecialCount(Set rejec if (getDateFrom.isPresent()) { where += " AND r.createdAt > :startDate AND r.createdAt < :endDate "; } - where += "GROUP BY rv.transactionId, tr.id, rv.amountLcySum, rv.rejectionCode, rv.sourceDiff, rv.transactionEntryDate, rv.transactionInternalNumber, rv.transactionType "; + where += "GROUP BY rv.transactionId, tr.id, rv.amountLcySum, rv.rejectionCode, rv.sourceDiff, rv.transactionEntryDate, rv.transactionInternalNumber, rv.transactionType ORDER BY rv.transactionId "; return jpql + where; } diff --git a/accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/resource/presentation_layer_service/AccountingCorePresentationViewService.java b/accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/resource/presentation_layer_service/AccountingCorePresentationViewService.java index 87ad5221..95f45b3a 100644 --- a/accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/resource/presentation_layer_service/AccountingCorePresentationViewService.java +++ b/accounting_reporting_core/src/main/java/org/cardanofoundation/lob/app/accounting_reporting_core/resource/presentation_layer_service/AccountingCorePresentationViewService.java @@ -53,7 +53,21 @@ public class AccountingCorePresentationViewService { public ReconciliationResponseView allReconciliationTransaction(ReconciliationFilterRequest body) { val transactionsStatistic = accountingCoreTransactionRepository.findCalcReconciliationStatistic(); if (body.getFilter().equals(ReconciliationFilterStatusRequest.UNRECONCILED)) { + Set txDuplicated = new HashSet<>(); val transactions = accountingCoreTransactionRepository.findAllReconciliationSpecial(body.getReconciliationRejectionCode(), body.getDateFrom(), body.getLimit(), body.getPage()).stream() + .filter(o -> { + if (o[0] instanceof TransactionEntity) { + if (!txDuplicated.contains(o[0])) { + txDuplicated.add(o[0]); + return true; + } + } + if (o[1] instanceof ReconcilationViolation) { + return true; + } + + return false; + }) .map(this::getReconciliationTransactionsSelector) .collect(toSet()); @@ -317,7 +331,7 @@ private TransactionReconciliationTransactionsView getTransactionReconciliationVi TransactionReconciliationTransactionsView.ReconciliationCodeView.NOK, TransactionReconciliationTransactionsView.ReconciliationCodeView.NOK, TransactionReconciliationTransactionsView.ReconciliationCodeView.NOK, - Set.of(ReconciliationRejectionCodeRequest.of(reconcilationViolation.getRejectionCode(),false)), + Set.of(ReconciliationRejectionCodeRequest.of(reconcilationViolation.getRejectionCode(), false)), null, new LinkedHashSet<>(), new LinkedHashSet<>() diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/OrganisationPublicApi.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/OrganisationPublicApi.java index e735fe7b..ae00f789 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/OrganisationPublicApi.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/OrganisationPublicApi.java @@ -54,5 +54,4 @@ public Optional getChartOfAccounts(String organisati public Optional findEventCode(String organisationId, String customerCode) { return accountEventService.findById(organisationId, customerCode); } - } diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationCostCenterView.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationCostCenterView.java new file mode 100644 index 00000000..0474da2d --- /dev/null +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationCostCenterView.java @@ -0,0 +1,17 @@ +package org.cardanofoundation.lob.app.organisation.domain.view; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +@AllArgsConstructor +public class OrganisationCostCenterView { + + private String customerCode; + + private String externalCustomerCode; + + private String name; +} diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationView.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationView.java index da5ee4cc..6a050f9f 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationView.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/domain/view/OrganisationView.java @@ -9,6 +9,7 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.Set; @Getter @Builder @@ -38,6 +39,10 @@ public class OrganisationView { @Schema(example = "lob@cardanofoundation.org") private String adminEmail; + private Set costCenter; + + private Set projects; + @Schema(example = "data:image/jpeg;base64,/9j/2wBDAAQDAwQDAwQEAwQFBAQFBgoHBgYGBg0JCggKDw0QEA8NDw4RExgUERIXEg4PFRwVFxkZGxsbEBQdHx0aHxgaGxr/2wBDAQQFBQYFBgwHBwwaEQ8RGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhr/wAARCAC/APwDASIAAhEBAxEB/8QAHQABAQACAwEBAQAAAAAAAAAAAAECBwUGCAkDBP/EAD8QAAECBAUCBgAEBAQDCQAAAAECEQADBAUGBxIhMUGBCBMiUWFxFDKRoRUjQvAJFrHBUnLxJSdTY3WSstHh/8QAGQEBAAMBAQAAAAAAAAAAAAAAAAECAwQF/8QAIxEAAwACAwACAwEBAQAAAAAAAAECAxESITETIkFRYQQyM//aAAwDAQACEQMRAD8A8Yd4d4d/uKkB2USB8CPYPBJtAl9+YOW+IQBW52LxkZyvKTKIGhJJG2+8YHfq/vFgPfSfUCz7O0WIYAEhgGAPv7w7wCizRYABjyW+hB3UXPXmJ8Q4+IApbpuPcxSkIcK3UwZtx3iRGAgB3h/bxeu3DwAKiQndt4Anwdj9w99n/wBoe8Za1hKkAkIU2oPy3EATo+7e8Tb3igkJI5H31iPAFDbuS/RhEG0U7KIBdvmJu7DkwAYQ2Hz3i7wgCd4d4RkopJBSnTsAXPXrAGP2Yd4yQkzFEI3IBJ3bYRiIAd4d4sIAIXoJLJVsQxDwWDKVpWCCwOxeJvAcbQA7wfeG8UEh2bcNAEBgdveKpRURqPAA4baG7wBNod4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9RAE7wO78dosO0AR/cw5Ii8nYNvGPPWAL13OzttFLOWJIBYP7RARu6QdjzD6gA/zF23Z/iKyggkbodifmICx3bvAEhtDcHcH6h2gB3h3MUAqIAG5idd/aADRQQAXA3HXpEHLRUpUt9PQEn6gCP8AMO8HikMSPaAP0pqWbWTkyqdOtZG27RgpCkTChbJUFaT9wQtctWqWooV7gxDuXLl94Earf8CklJUlQYg7iJ3i7vvz9w7QJD8Mw9yDzE7wEHgAfuH6xQd3IeCSUl07H3BgCfMHcuAweDEAq4BLPAHo7AwAf5h3h/8AUXff45gCd4veIDF7QAIDAuN+kTu8ICAEInPSL2gC94h+4vaJ8niAGzDffrF7xA8XtAFKlTCNSnYMH9oxBDh3IfcAw7Q4ERoFJckvzE7w3gHbh4kH/9k=") private String logo; diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/repository/CostCenterRepository.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/repository/CostCenterRepository.java index d94744cf..0f4f26b8 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/repository/CostCenterRepository.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/repository/CostCenterRepository.java @@ -2,7 +2,14 @@ import org.cardanofoundation.lob.app.organisation.domain.entity.OrganisationCostCenter; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import java.util.Optional; +import java.util.Set; public interface CostCenterRepository extends JpaRepository { + @Query("SELECT t FROM OrganisationCostCenter t WHERE t.id.organisationId = :organisationId") + Set findAllByOrganisationId(@Param("organisationId") String organisationId); } diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/repository/ProjectMappingRepository.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/repository/ProjectMappingRepository.java index d97f1ccc..21b6f142 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/repository/ProjectMappingRepository.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/repository/ProjectMappingRepository.java @@ -1,9 +1,14 @@ package org.cardanofoundation.lob.app.organisation.repository; +import org.cardanofoundation.lob.app.organisation.domain.entity.OrganisationCostCenter; import org.cardanofoundation.lob.app.organisation.domain.entity.OrganisationProject; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; -public interface ProjectMappingRepository extends JpaRepository { +import java.util.Set; +public interface ProjectMappingRepository extends JpaRepository { + @Query("SELECT t FROM OrganisationProject t WHERE t.id.organisationId = :organisationId") + Set findAllByOrganisationId(@Param("organisationId") String organisationId); } diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/resource/OrganisationResource.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/resource/OrganisationResource.java index 2e8a6a6c..62ae52d8 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/resource/OrganisationResource.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/resource/OrganisationResource.java @@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.val; +import org.cardanofoundation.lob.app.organisation.domain.view.OrganisationCostCenterView; import org.cardanofoundation.lob.app.organisation.domain.view.OrganisationView; import org.cardanofoundation.lob.app.organisation.service.OrganisationService; import org.springframework.http.ResponseEntity; @@ -20,7 +21,9 @@ import org.zalando.problem.Status; import java.time.LocalDate; +import java.util.LinkedHashSet; import java.util.Optional; +import java.util.stream.Collectors; @RestController @RequestMapping("/api") @@ -51,6 +54,8 @@ public ResponseEntity organisationList() { monthsAgo, yesterday, organisation.getAdminEmail(), + new LinkedHashSet<>(), + new LinkedHashSet<>(), organisation.getLogo() ); }).toList() @@ -82,6 +87,20 @@ public ResponseEntity organisationDetailSpecific(@PathVariable("orgId") @Para monthsAgo, yesterday, organisation1.getAdminEmail(), + organisationService.getAllCostCenter(organisation1.getId()).stream().map(organisationCostCenter -> { + return new OrganisationCostCenterView( + organisationCostCenter.getId() != null ? organisationCostCenter.getId().getCustomerCode() : null, + organisationCostCenter.getExternalCustomerCode(), + organisationCostCenter.getName() + ); + }).collect(Collectors.toSet()), + organisationService.getAllProjects(organisation1.getId()).stream().map(organisationProject -> { + return new OrganisationCostCenterView( + organisationProject.getId() != null ? organisationProject.getId().getCustomerCode() : null, + organisationProject.getExternalCustomerCode(), + organisationProject.getName() + ); + }).collect(Collectors.toSet()), organisation1.getLogo() ); }); @@ -98,4 +117,40 @@ public ResponseEntity organisationDetailSpecific(@PathVariable("orgId") @Para return ResponseEntity.ok().body(organisation); } + @Operation(description = "Organisation cost center", responses = { + @ApiResponse(content = + {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = OrganisationCostCenterView.class)))} + ), + }) + @GetMapping(value = "/organisation/{orgId}/cost-center", produces = "application/json") + public ResponseEntity organisationCostCenter(@PathVariable("orgId") @Parameter(example = "75f95560c1d883ee7628993da5adf725a5d97a13929fd4f477be0faf5020ca94") String orgId) { + return ResponseEntity.ok().body( + organisationService.getAllCostCenter(orgId).stream().map(organisationCostCenter -> { + return new OrganisationCostCenterView( + organisationCostCenter.getId() != null ? organisationCostCenter.getId().getCustomerCode() : null, + organisationCostCenter.getExternalCustomerCode(), + organisationCostCenter.getName() + ); + }).toList()); + + } + + @Operation(description = "Organisation cost center", responses = { + @ApiResponse(content = + {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = OrganisationCostCenterView.class)))} + ), + }) + @GetMapping(value = "/organisation/{orgId}/project", produces = "application/json") + public ResponseEntity organisationProject(@PathVariable("orgId") @Parameter(example = "75f95560c1d883ee7628993da5adf725a5d97a13929fd4f477be0faf5020ca94") String orgId) { + return ResponseEntity.ok().body( + organisationService.getAllProjects(orgId).stream().map(organisationProject -> { + return new OrganisationCostCenterView( + organisationProject.getId() != null ? organisationProject.getId().getCustomerCode() : null, + organisationProject.getExternalCustomerCode(), + organisationProject.getName() + ); + }).toList()); + + } + } diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/CostCenterService.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/CostCenterService.java index ffa5ac5d..a8d7b1df 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/CostCenterService.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/CostCenterService.java @@ -7,7 +7,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; import java.util.Optional; +import java.util.Set; @Service @Slf4j @@ -21,4 +23,8 @@ public Optional getCostCenter(String organisationId, Str return costCenterRepository.findById(new OrganisationCostCenter.Id(organisationId, customerCode)); } + public Set getAllCostCenter(String organisationId){ + return costCenterRepository.findAllByOrganisationId(organisationId); + } + } diff --git a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/OrganisationService.java b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/OrganisationService.java index e002b83e..b9b67b58 100644 --- a/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/OrganisationService.java +++ b/organisation/src/main/java/org/cardanofoundation/lob/app/organisation/service/OrganisationService.java @@ -3,12 +3,16 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.cardanofoundation.lob.app.organisation.domain.entity.Organisation; +import org.cardanofoundation.lob.app.organisation.domain.entity.OrganisationCostCenter; +import org.cardanofoundation.lob.app.organisation.domain.entity.OrganisationProject; import org.cardanofoundation.lob.app.organisation.repository.OrganisationRepository; +import org.cardanofoundation.lob.app.organisation.repository.ProjectMappingRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Optional; +import java.util.Set; @Service @RequiredArgsConstructor @@ -17,6 +21,8 @@ public class OrganisationService { private final OrganisationRepository organisationRepository; + private final CostCenterService costCenterService; + private final ProjectMappingRepository projectMappingRepository; public Optional findById(String organisationId) { return organisationRepository.findById(organisationId); @@ -26,4 +32,12 @@ public List findAll() { return organisationRepository.findAll(); } + public Set getAllCostCenter(String organisationId){ + return costCenterService.getAllCostCenter(organisationId); + } + + public Set getAllProjects(String organisationId){ + return projectMappingRepository.findAllByOrganisationId(organisationId); + } + }