From 2b7ab7384f506cc86f7b743cf83dd08813886f6c Mon Sep 17 00:00:00 2001 From: Vincent Zwingmann Date: Sat, 12 Oct 2024 23:27:54 +0200 Subject: [PATCH] fix #59 --- .../operations/business/BudgetService.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/operations/src/main/java/io/github/vzwingma/finances/budget/serverless/services/operations/business/BudgetService.java b/operations/src/main/java/io/github/vzwingma/finances/budget/serverless/services/operations/business/BudgetService.java index 288c41d..4cbe710 100644 --- a/operations/src/main/java/io/github/vzwingma/finances/budget/serverless/services/operations/business/BudgetService.java +++ b/operations/src/main/java/io/github/vzwingma/finances/budget/serverless/services/operations/business/BudgetService.java @@ -482,7 +482,8 @@ public Uni createOperationsIntercomptes(String idBudget, final Li final String libelleOperation = ligneOperation.getLibelle(); String idBudgetDestination = BudgetDataUtils.getBudgetId(idCompteDestination, BudgetDataUtils.getMoisFromBudgetId(idBudget), BudgetDataUtils.getAnneeFromBudgetId(idBudget)); String idCompteSource = BudgetDataUtils.getCompteFromBudgetId(idBudget); - + Month moisFromBudgetId = BudgetDataUtils.getMoisFromBudgetId(idBudget); + Integer anneeFromBudgetId = BudgetDataUtils.getAnneeFromBudgetId(idBudget); LOGGER.info("Ajout d'un transfert intercompte de {} vers {} ({}) > {} ", idBudget, idBudgetDestination, idCompteDestination, ligneOperation); /* @@ -511,18 +512,14 @@ public Uni createOperationsIntercomptes(String idBudget, final Li /* * Opération sur Compte cible */ - - Uni budgetCible = - Uni.combine().all().unis( - getBudgetAndCompteActif(idBudgetDestination).map(Tuple2::getItem1), - this.comptesService.getCompteById(idCompteSource)) - .asTuple() + Uni budgetCible = this.comptesService.getCompteById(idCompteDestination) + .onItem().ifNotNull() + .transformToUni(compteDestination -> chargerBudgetMensuelSurCompteActif(compteDestination, moisFromBudgetId, anneeFromBudgetId)) .invoke(tuple -> { BusinessTraceContext.get().put(BusinessTraceContextKeyEnum.BUDGET, idBudgetDestination).put(BusinessTraceContextKeyEnum.COMPTE, idCompteSource); - String libelleOperationCible = "[depuis " + tuple.getItem2().getId() + "] " + libelleOperation; - this.operationsAppProvider.addOperationIntercompte(tuple.getItem1().getListeOperations(), ligneOperation, libelleOperationCible, auteur); + String libelleOperationCible = "[depuis " + idCompteSource+ "] " + libelleOperation; + this.operationsAppProvider.addOperationIntercompte(tuple.getListeOperations(), ligneOperation, libelleOperationCible, auteur); }) - .map(Tuple2::getItem1) .onItem().ifNotNull() .invoke(this::recalculSoldes) // Sauvegarde du budget