From 4468a1d7ff1e7b93b8e4140eb14eb36946dea524 Mon Sep 17 00:00:00 2001 From: rth-axelor <82039632+rth-axelor@users.noreply.github.com> Date: Tue, 17 Jun 2025 18:32:11 +0200 Subject: [PATCH 1/2] 96507 BankReconciliation : blocked the reconciliation of multiple lines on a single move line. --- .../BankPaymentExceptionMessage.java | 3 ++ .../BankReconciliationToolService.java | 33 +++++++++++++++++++ .../web/BankReconciliationController.java | 20 +++++++++++ .../src/main/resources/i18n/messages.csv | 1 + .../src/main/resources/i18n/messages_en.csv | 1 + .../src/main/resources/i18n/messages_fr.csv | 1 + .../resources/views/BankReconciliation.xml | 19 +++++++++-- changelogs/unreleased/96507.yml | 3 ++ 8 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/96507.yml diff --git a/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/exception/BankPaymentExceptionMessage.java b/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/exception/BankPaymentExceptionMessage.java index 74ff211743d..36f247d9ef6 100644 --- a/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/exception/BankPaymentExceptionMessage.java +++ b/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/exception/BankPaymentExceptionMessage.java @@ -332,4 +332,7 @@ private BankPaymentExceptionMessage() {} public static final String BANK_RECONCILIATION_CREATING_MOVE_MISSING_JOURNAL = /*$$(*/ "Missing journal while creating a move from a bank reconciliation." /*)*/; + + public static final String BANK_RECONCILIATION_MULTIPLE_MOVE_LINE_RECONCILIATION_ERROR = /*$$(*/ + "The movelines %s are already reconciled with another bank statement line. Multiple bank statement lines can't be reconciled with the same move line." /*)*/; } diff --git a/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/service/BankReconciliationToolService.java b/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/service/BankReconciliationToolService.java index a0699f1a50d..65279fa58d9 100644 --- a/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/service/BankReconciliationToolService.java +++ b/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/service/BankReconciliationToolService.java @@ -18,8 +18,13 @@ */ package com.axelor.apps.bankpayment.service; +import com.axelor.apps.account.db.MoveLine; import com.axelor.apps.bankpayment.db.BankReconciliation; +import com.axelor.apps.bankpayment.db.BankReconciliationLine; import com.axelor.apps.base.db.Company; +import com.axelor.common.ObjectUtils; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; public class BankReconciliationToolService { @@ -33,4 +38,32 @@ public static boolean isForeignCurrency(BankReconciliation bankReconciliation) { } return false; } + + public static List getMoveLineOnMultipleReconciliationLine( + BankReconciliation bankReconciliation) { + List errorMoveLineList = new ArrayList<>(); + + if (bankReconciliation == null + || ObjectUtils.isEmpty(bankReconciliation.getBankReconciliationLineList())) { + return errorMoveLineList; + } + + List moveLineList = new ArrayList<>(); + + for (BankReconciliationLine bankReconciliationLine : + bankReconciliation.getBankReconciliationLineList()) { + MoveLine moveLine = bankReconciliationLine.getMoveLine(); + if (moveLine == null) { + continue; + } + + if (moveLineList.contains(moveLine)) { + errorMoveLineList.add(moveLine); + } else { + moveLineList.add(moveLine); + } + } + + return errorMoveLineList; + } } diff --git a/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/web/BankReconciliationController.java b/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/web/BankReconciliationController.java index cb27a08b37e..9077c78e90a 100644 --- a/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/web/BankReconciliationController.java +++ b/axelor-bank-payment/src/main/java/com/axelor/apps/bankpayment/web/BankReconciliationController.java @@ -51,6 +51,7 @@ import com.axelor.apps.base.db.repo.TraceBackRepository; import com.axelor.apps.base.service.BankDetailsService; import com.axelor.apps.base.service.exception.TraceBackService; +import com.axelor.common.ObjectUtils; import com.axelor.db.EntityHelper; import com.axelor.i18n.I18n; import com.axelor.inject.Beans; @@ -556,4 +557,23 @@ public void computeSelections(ActionRequest request, ActionResponse response) { TraceBackService.trace(response, e); } } + + public void checkMultipleMoveLine(ActionRequest request, ActionResponse response) { + BankReconciliation bankReconciliation = request.getContext().asType(BankReconciliation.class); + List moveLineList = + BankReconciliationToolService.getMoveLineOnMultipleReconciliationLine(bankReconciliation); + if (ObjectUtils.isEmpty(moveLineList)) { + return; + } + + response.setError( + String.format( + I18n.get( + BankPaymentExceptionMessage + .BANK_RECONCILIATION_MULTIPLE_MOVE_LINE_RECONCILIATION_ERROR), + moveLineList.stream() + .map(MoveLine::getName) + .distinct() + .collect(Collectors.joining(",")))); + } } diff --git a/axelor-bank-payment/src/main/resources/i18n/messages.csv b/axelor-bank-payment/src/main/resources/i18n/messages.csv index 76739997652..258be723755 100644 --- a/axelor-bank-payment/src/main/resources/i18n/messages.csv +++ b/axelor-bank-payment/src/main/resources/i18n/messages.csv @@ -744,6 +744,7 @@ "The company %s does not have bank order sequence",,, "The field encryption.bankorder.password in config file must be filled.",,, "The move %s can't be reversed because it is linked to a bank reconciliation with status validated",,, +"The movelines %s are already reconciled with another bank statement line. Multiple bank statement lines can't be reconciled with the same move line.",,, "The moves %s couldn't be reversed because these are linked to a bank reconciliation with status validated",,, "The password is incorrect.",,, "The payment status will not update.",,, diff --git a/axelor-bank-payment/src/main/resources/i18n/messages_en.csv b/axelor-bank-payment/src/main/resources/i18n/messages_en.csv index 1295150e704..df1a4970ffd 100644 --- a/axelor-bank-payment/src/main/resources/i18n/messages_en.csv +++ b/axelor-bank-payment/src/main/resources/i18n/messages_en.csv @@ -744,6 +744,7 @@ "The company %s does not have bank order sequence",,, "The field encryption.bankorder.password in config file must be filled.",,, "The move %s can't be reversed because it is linked to a bank reconciliation with status validated",,, +"The movelines %s are already reconciled with another bank statement line. Multiple bank statement lines can't be reconciled with the same move line.",,, "The moves %s couldn't be reversed because these are linked to a bank reconciliation with status validated",,, "The password is incorrect.",,, "The payment status will not update.",,, diff --git a/axelor-bank-payment/src/main/resources/i18n/messages_fr.csv b/axelor-bank-payment/src/main/resources/i18n/messages_fr.csv index bce92a0afff..633a9c0c3cd 100644 --- a/axelor-bank-payment/src/main/resources/i18n/messages_fr.csv +++ b/axelor-bank-payment/src/main/resources/i18n/messages_fr.csv @@ -744,6 +744,7 @@ "The company %s does not have bank order sequence","La société %s n'a pas de séquence d'ordre bancaire configurée",, "The field encryption.bankorder.password in config file must be filled.","Le champ encryption.bankorder.password dans la configuration doit être rempli.",, "The move %s can't be reversed because it is linked to a bank reconciliation with status validated","L'écriture %s ne peut être extournée car elle est liée à un rapprochement bancaire au statut validé",, +"The movelines %s are already reconciled with another bank statement line. Multiple bank statement lines can't be reconciled with the same move line.","Les lignes d'écriture %s pointent déjà vers une autre ligne de rapprochement bancaire. Il n'est pas possible de faire pointer plusieurs lignes de rapprochement bancaire vers une même ligne d'écriture.",, "The moves %s couldn't be reversed because these are linked to a bank reconciliation with status validated","Les écritures %s ne peuvent être extournées car elle sont liées à un rapprochement bancaire au statut validé",, "The password is incorrect.","Le mot de passe est incorrect.",, "The payment status will not update.","Le statut du paiement ne sera pas mis à jour.",, diff --git a/axelor-bank-payment/src/main/resources/views/BankReconciliation.xml b/axelor-bank-payment/src/main/resources/views/BankReconciliation.xml index da4cc8fbbf8..becbbeb0c32 100644 --- a/axelor-bank-payment/src/main/resources/views/BankReconciliation.xml +++ b/axelor-bank-payment/src/main/resources/views/BankReconciliation.xml @@ -21,7 +21,8 @@
+ onNew="action-bank-reconciliation-onnew-group" onLoad="action-bank-reconciliation-onload-group" + onSave="action-bank-reconciliation-method-check-multiple-move-line">