This is an automated email from the git hooks/post-receive script. New change to branch feature/1174-Import_EBP_Transactions in repository lima. See https://gitlab.nuiton.org/chorem/lima.git discards eb4e038 refs #1174 Rollback Changes, les résultats ne sont pas satifaisant au regard de la balance de référence discards 187f651 refs #1174 suppression de l'exception de la signature de la méthode discards e9e58f9 refs #1174 l'exception sur la non existance d'un compte dont la suppression est demandée ne doit pas être levé au niveau des règles métier discards 4775428 refs #1174 Correction sur affichage des résultats d'import dans le cas ou il n'y a pas eu d'erreur discards 89c8a76 refs #1174 [ISO] mise à jour des tests suite au rebase discards 7f40bc8 refs #1174 ajout d'une exception pour gérer le cas ou l'on essaye de supprimer un compte qui 'existe pas discards 7a00a52 refs #1174 création de transaction pour chaque changement de date puis de pièce comptable (déplacement de branche) adds 52e8196 refs #1174 ajout d'une exception pour gérer le cas ou l'on essaye de supprimer un compte qui 'existe pas adds 82499b6 refs #1314 mise à jour urls adds f2039b7 refs #1207 afficahge du nom du thread de l'exception adds b698a64 refs #1174 ajout d'une exception pour gérer le cas ou l'on essaye de supprimer un compte qui 'existe pas adds a88940f refs #1207 retrait de la signature de méthode des exceptions non remontées adds 80bf13b refs #1207 fource le charset à UTF8 adds 6d64b20 refs #1207 utilisation de la variable sauveagarder plutot que celle à sauvegarder adds 73bc6af refs #1207 [ISO] suppression d'un appel non utilisé adds ca0f149 refs #1207 [ISO] suppression d'une méthode morte adds 970f2cd refs #1207 [ISO] Nettoyage, petite corrections adds 33dd445 refs #1314 Mise à jour licence d'olap4j adds 02c6404 refs #1314 mise à jour des sources de dépos nexus pour Jasper adds f52366b refs #1174 correction de merge adds 9316918 refs #1314 passage en java 1.8 new 328cd94 refs #1174 création de transaction pour chaque changement de date puis de pièce comptable (déplacement de branche) new 8f3fbd5 refs #1174 ajout d'une exception pour gérer le cas ou l'on essaye de supprimer un compte qui 'existe pas new 49a9e45 refs #1174 Correction sur affichage des résultats d'import dans le cas ou il n'y a pas eu d'erreur new 15ca0fe refs #1174 l'exception sur la non existance d'un compte dont la suppression est demandée ne doit pas être levé au niveau des règles métier new 2cd8ecd refs #1174 suppression de l'exception de la signature de la méthode new 45cac9a refs #1174 Rollback Changes, les résultats ne sont pas satifaisant au regard de la balance de référence This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (eb4e038) \ N -- N -- N refs/heads/feature/1174-Import_EBP_Transactions (45cac9a) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omits" are not gone; other references still refer to them. Any revisions marked "discards" are gone forever. The 6 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 45cac9a26f1bddfae8f8a910b2917d30628a83f6 Author: David Cossé <cosse@codelutin.com> Date: Thu Sep 8 15:20:44 2016 +0200 refs #1174 Rollback Changes, les résultats ne sont pas satifaisant au regard de la balance de référence commit 2cd8ecd3774bcd6cd5d7d72694e18ec1c4a29076 Author: David Cossé <cosse@codelutin.com> Date: Thu Sep 8 15:18:56 2016 +0200 refs #1174 suppression de l'exception de la signature de la méthode commit 15ca0fe9bfa6aebb5586680dc805e4f6a9fbf92d Author: David Cossé <cosse@codelutin.com> Date: Thu Sep 8 15:16:31 2016 +0200 refs #1174 l'exception sur la non existance d'un compte dont la suppression est demandée ne doit pas être levé au niveau des règles métier commit 49a9e4543b9f0e5179c4838d225f854cb23ceaba Author: David Cossé <cosse@codelutin.com> Date: Thu Sep 8 13:38:54 2016 +0200 refs #1174 Correction sur affichage des résultats d'import dans le cas ou il n'y a pas eu d'erreur commit 8f3fbd5dfa2219ed181c487786dbd780fb396f79 Author: David Cossé <cosse@codelutin.com> Date: Fri Jul 8 10:33:23 2016 +0200 refs #1174 ajout d'une exception pour gérer le cas ou l'on essaye de supprimer un compte qui 'existe pas commit 328cd94b08837a89fdbe295a80d25c4785efcff2 Author: dcosse <japbiw74> Date: Wed Feb 25 22:37:58 2015 +0100 refs #1174 création de transaction pour chaque changement de date puis de pièce comptable (déplacement de branche) Summary of changes: .../src/license/THIRD-PARTY.properties | 10 ++-- .../chorem/lima/business/LimaServiceFactory.java | 2 +- .../lima/business/ServiceMonitorableHandler.java | 28 +++++----- .../org/chorem/lima/business/api/EntryService.java | 7 --- .../chorem/lima/business/api/ImportService.java | 4 +- .../business/exceptions/UnexistingAccount.java | 4 +- lima-business-api/src/site/site.xml | 4 +- lima-business/src/license/THIRD-PARTY.properties | 12 +++-- .../lima/business/LimaConfigurationHelper.java | 21 -------- .../accountingrules/DefaultAccountingRules.java | 4 +- .../accountingrules/FranceAccountingRules.java | 2 +- .../lima/business/ejb/AccountServiceImpl.java | 4 +- .../chorem/lima/business/ejb/EntryServiceImpl.java | 9 ---- .../lima/business/ejb/ExportServiceImpl.java | 7 ++- .../business/ejb/FinancialPeriodServiceImpl.java | 4 +- .../ejb/FinancialStatementServiceImpl.java | 2 +- .../ejb/FinancialTransactionServiceImpl.java | 62 +++++++++++----------- .../lima/business/ejb/FiscalPeriodServiceImpl.java | 14 +++-- .../lima/business/ejb/ImportServiceImpl.java | 13 ++--- .../lima/business/ejb/ReportServiceImpl.java | 4 +- .../lima/business/ejb/VatStatementServiceImpl.java | 2 +- .../lima/business/ejb/csv/AbstractLimaModel.java | 4 +- .../chorem/lima/business/ejb/csv/EntryModel.java | 2 +- .../lima/business/ejb/ebp/EntryBookEBPModel.java | 2 +- .../business/ejb/report/CommonsDocumentReport.java | 11 ++-- lima-business/src/site/site.xml | 4 +- .../org/chorem/lima/business/AbstractLimaTest.java | 18 ++----- .../FinancialTransactionServiceImplTest.java | 10 ++-- .../lima/business/ImportExportServiceTest.java | 1 + .../accountingrules/TestAccountingRules.java | 2 +- lima-callao/src/license/THIRD-PARTY.properties | 11 ++-- .../main/java/org/chorem/lima/beans/Condition.java | 4 +- .../lima/beans/FinancialTransactionCondition.java | 2 +- .../main/java/org/chorem/lima/beans/Labeled.java | 2 +- .../org/chorem/lima/beans/VisitorCondition.java | 24 ++++----- .../main/java/org/chorem/lima/clause/Clause.java | 2 +- .../java/org/chorem/lima/clause/DateClause.java | 2 +- .../java/org/chorem/lima/clause/NumberClause.java | 2 +- .../java/org/chorem/lima/clause/SetClause.java | 2 +- .../java/org/chorem/lima/clause/StringClause.java | 2 +- .../org/chorem/lima/clause/SubFilterClause.java | 2 +- .../java/org/chorem/lima/clause/VisitorClause.java | 18 +++---- .../main/java/org/chorem/lima/filter/Filter.java | 6 +-- .../org/chorem/lima/filter/FilterGenerator.java | 19 ++++--- .../java/org/chorem/lima/filter/VisitorFilter.java | 8 +-- lima-report/src/license/THIRD-PARTY.properties | 12 +++-- .../chorem/lima/report/DocumentReportTypes.java | 2 +- .../lima/report/service/DocumentService.java | 2 +- .../chorem/lima/report/service/JasperReports.java | 2 +- lima-server/src/license/THIRD-PARTY.properties | 4 +- lima-server/src/main/assembly/bin.xml | 4 +- lima-swing/src/license/THIRD-PARTY.properties | 4 +- .../java/org/chorem/lima/LimaExceptionHandler.java | 2 +- .../src/main/java/org/chorem/lima/LimaMain.java | 5 +- .../chorem/lima/LimaSwingApplicationContext.java | 3 +- .../java/org/chorem/lima/ui/MainViewHandler.java | 4 +- .../chorem/lima/ui/account/AccountViewHandler.java | 4 +- .../ui/accountViewer/AccountViewerViewHandler.java | 9 ++-- .../FinancialTransactionUnbalancedViewHandler.java | 4 +- .../FiscalControlExportViewHandler.java | 9 ++-- .../chorem/lima/ui/importexport/ImportExport.java | 2 +- .../chorem/lima/ui/opening/OpeningViewHandler.java | 11 ++-- .../org/chorem/lima/util/BigDecimalToString.java | 1 - .../java/org/chorem/lima/util/ErrorHelper.java | 2 +- pom.xml | 12 ++--- src/site/site.xml | 4 +- 66 files changed, 218 insertions(+), 263 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1174-Import_EBP_Transactions in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 328cd94b08837a89fdbe295a80d25c4785efcff2 Author: dcosse <japbiw74> Date: Wed Feb 25 22:37:58 2015 +0100 refs #1174 création de transaction pour chaque changement de date puis de pièce comptable (déplacement de branche) --- .../org/chorem/lima/business/ImportResult.java | 5 +- .../accountingrules/DefaultAccountingRules.java | 6 +- .../lima/business/ejb/AccountServiceImpl.java | 4 + .../lima/business/ejb/ImportServiceImpl.java | 93 ++++++++++++----- .../resources/i18n/lima-business_en_GB.properties | 34 ++++--- .../resources/i18n/lima-business_fr_FR.properties | 51 +++++++--- .../org/chorem/lima/business/AbstractLimaTest.java | 110 ++++++++++++++++++--- .../lima/business/AccountServiceImplTest.java | 8 +- .../lima/business/EntryBookServiceImplTest.java | 6 +- .../business/FinancialPeriodServiceImplTest.java | 6 +- .../FinancialTransactionServiceImplTest.java | 6 +- .../lima/business/FiscalPeriodServiceImplTest.java | 4 +- .../lima/business/ImportExportServiceTest.java | 88 +++++++++-------- .../lima/business/ReportServiceImplTest.java | 8 +- .../lima/entity/FinancialTransactionDAOTest.java | 8 +- .../resources/i18n/lima-swing_en_GB.properties | 3 + .../resources/i18n/lima-swing_fr_FR.properties | 3 + 17 files changed, 305 insertions(+), 138 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java b/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java index 8cec320..4d0a7b3 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java @@ -22,10 +22,10 @@ package org.chorem.lima.business; * #L% */ +import com.google.common.collect.Maps; import org.chorem.lima.business.exceptions.LimaException; import java.io.Serializable; -import java.util.HashMap; import java.util.Map; /** @@ -50,6 +50,7 @@ public class ImportResult implements Serializable{ nbUpdated = 0; nbIgnored = 0; lineIndex = 2;// line 1 s header + allExceptions = Maps.newHashMap(); this.fromSource = fromSource; } @@ -81,14 +82,12 @@ public class ImportResult implements Serializable{ } public void addException(LimaException e) { - allExceptions = allExceptions == null ? new HashMap<Integer, LimaException>() : allExceptions; allExceptions.put(this.lineIndex, e); nbIgnored++; lineIndex++; } public void addInitException(LimaException e) { - allExceptions = allExceptions == null ? new HashMap<Integer, LimaException>() : allExceptions; allExceptions.put(1, e); nbIgnored++; lineIndex++; diff --git a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java index 410bf2b..9c2fafb 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java +++ b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java @@ -41,7 +41,6 @@ import org.chorem.lima.business.exceptions.NotLockedClosedPeriodicEntryBooksExce import org.chorem.lima.business.exceptions.NotNumberAccountNumberException; import org.chorem.lima.business.exceptions.UnbalancedEntriesException; import org.chorem.lima.business.exceptions.UnbalancedFinancialTransactionsException; -import org.chorem.lima.business.exceptions.UnexistingAccount; import org.chorem.lima.business.exceptions.UnfilledEntriesException; import org.chorem.lima.business.exceptions.UsedAccountException; import org.chorem.lima.business.exceptions.UsedEntryBookException; @@ -176,13 +175,10 @@ public class DefaultAccountingRules implements AccountingRules { * Recursive function */ @Override - public void removeAccountRules(Account account) throws UsedAccountException, UnexistingAccount { + public void removeAccountRules(Account account) throws UsedAccountException { EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); // Check if account have entries - if (!account.isPersisted()) { - throw new UnexistingAccount(account.getAccountNumber(), "Unsaved Account, this account can not be removed"); - } if (entryTopiaDao.forAccountEquals(account).exists()) { throw new UsedAccountException(account.getAccountNumber()); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java index 63add0f..7a7cfdd 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java @@ -193,6 +193,10 @@ public class AccountServiceImpl extends AbstractLimaService implements AccountSe @Override public void removeAccount(Account account) throws UsedAccountException, UnexistingAccount { + if (!account.isPersisted()) { + throw new UnexistingAccount(account.getAccountNumber(), "Unsaved Account, this account can not be removed"); + } + AccountingRules accountingRules = LimaBusinessConfig.getInstance().getAccountingRules(); // Check rules for account if have entries diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java index 173f4e3..11feab7 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java @@ -23,6 +23,7 @@ package org.chorem.lima.business.ejb; */ import com.google.common.base.Function; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Ordering; import com.google.common.collect.Sets; @@ -60,7 +61,6 @@ import org.chorem.lima.business.exceptions.AlreadyExistFinancialStatementExcepti import org.chorem.lima.business.exceptions.AlreadyExistVatStatementException; import org.chorem.lima.business.exceptions.BeforeFirstFiscalPeriodException; import org.chorem.lima.business.exceptions.BeginAfterEndFiscalPeriodException; -import org.chorem.lima.business.exceptions.ImportEbpException; import org.chorem.lima.business.exceptions.ImportFileException; import org.chorem.lima.business.exceptions.InvalidAccountNumberException; import org.chorem.lima.business.exceptions.LimaException; @@ -939,12 +939,14 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ // if entry date have fiscalperiod open if (dateEcr.compareTo(fiscalPeriodsBiginDate) < 0 || dateEcr.compareTo(fiscalPeriodsEndingDate) > 0) { - importResult.addException(new ImportEbpException(t("lima-business.import.entriesoutofdatesrange", dateEcr))); + importResult.addException(new ImportFileException(t("lima.import.error.entriesOutOfDatesRange", dateEcr))); + importResult.increaseIgnored(); result = false; } // if account not exist not export -> exception else if (account == null) { - importResult.addException(new ImportEbpException(t("lima-business.import.ebpmissingaccount", targetedAccount))); + importResult.addException(new ImportFileException(t("lima.import.error.invalidAccountNumber", targetedAccount))); + importResult.increaseIgnored(); result =false; } return result; @@ -984,9 +986,9 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ // the entry is validate (checking for valide FiscalPeriod and existing Account associated to it) // if valid entry // the entry entity is created and the association with it's dependant entites (Account are FinancialTransaction) are created - Date fiscalPeriodsBiginDate = fiscalPeriods.get(0).getBeginDate(); + Date fiscalPeriodsBeginDate = fiscalPeriods.get(0).getBeginDate(); Date fiscalPeriodsEndingDate = fiscalPeriods.get(fiscalPeriods.size() - 1).getEndDate(); - Map<EntryBook, Map<Date, FinancialTransaction>> entryBookFinancialTransactionByDate = getEntryBookFinancialTransactionOrderedByDate(fiscalPeriodsBiginDate, fiscalPeriodsEndingDate); + Map<EntryBook, Map<Date, Set<FinancialTransaction>>> entryBookFinancialTransactionsByDate = getEntryBookFinancialTransactionOrderedByDate(fiscalPeriodsBeginDate, fiscalPeriodsEndingDate); for (EntryEBP entryEBP : entryEBPs) { Date dateEcr = entryEBP.getDatEcr(); @@ -994,7 +996,7 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ // account loading Account account = indexedAccounts.get(entryEBP.getCompte()); - if (!validEntry(result, dateEcr, fiscalPeriodsBiginDate, fiscalPeriodsEndingDate, account, entryEBP.getCompte())) { + if (!validEntry(result, dateEcr, fiscalPeriodsBeginDate, fiscalPeriodsEndingDate, account, entryEBP.getCompte())) { continue; } // create entry @@ -1005,7 +1007,7 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ try { // find financial transactions for entry period and entrybook - addEntryToFinancialTransaction(entry, entryEBP.getJournal(), indexedEntryBooks, entryBookFinancialTransactionByDate, dateEcr); + addEntryToFinancialTransaction(entry, entryEBP.getJournal(), indexedEntryBooks, entryBookFinancialTransactionsByDate, dateEcr); } catch (LockedFinancialPeriodException | LockedEntryBookException | AlreadyExistEntryBookException | AfterLastFiscalPeriodException | BeforeFirstFiscalPeriodException e) { result.addException(e); @@ -1049,34 +1051,68 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ return entry; } - protected void addEntryToFinancialTransaction(Entry entry, String entryBookCode, Map<String, EntryBook> indexedEntryBooks, Map<EntryBook, Map<Date, FinancialTransaction>> entryBookFinancialTransactionByDate, Date dateEcr) throws LockedFinancialPeriodException, LockedEntryBookException, AlreadyExistEntryBookException, AfterLastFiscalPeriodException, BeforeFirstFiscalPeriodException { + protected void addEntryToFinancialTransaction(Entry entry, String entryBookCode, Map<String, EntryBook> indexedEntryBooks, Map<EntryBook, Map<Date, Set<FinancialTransaction>>> entryBookFinancialTransactionsByDate, Date dateEcr) throws LockedFinancialPeriodException, LockedEntryBookException, AlreadyExistEntryBookException, AfterLastFiscalPeriodException, BeforeFirstFiscalPeriodException { EntryBook entryBook = getEntryBook(indexedEntryBooks, entryBookCode); - Map<Date, FinancialTransaction> financialTransactionsByDate = entryBookFinancialTransactionByDate.get(entryBook); + Map<Date, Set<FinancialTransaction>> financialTransactionsByDate = entryBookFinancialTransactionsByDate.get(entryBook); if (financialTransactionsByDate == null) { financialTransactionsByDate = new HashMap<>(); - entryBookFinancialTransactionByDate.put(entryBook, financialTransactionsByDate); + entryBookFinancialTransactionsByDate.put(entryBook, financialTransactionsByDate); } - // create transaction - FinancialTransaction financialTransaction = financialTransactionsByDate.get(dateEcr); - if (financialTransaction == null - || !(dateEcr.equals(financialTransaction - .getTransactionDate()) && entryBook + // find financial transaction for this required date and required voucher. + Set<FinancialTransaction> financialTransactionsForDate = financialTransactionsByDate.get(dateEcr); + if (financialTransactionsForDate == null) { + financialTransactionsForDate = Sets.newHashSet(); + financialTransactionsByDate.put(dateEcr, financialTransactionsForDate); + } + + String voucher = entry.getVoucher(); + + // look for an existing one + FinancialTransaction financialTransactionForDateAndVoucher = getFinancialTransactionForVoucher(financialTransactionsForDate, voucher); + + // if none exist a new one is created + if (financialTransactionForDateAndVoucher == null + || !(dateEcr.equals(financialTransactionForDateAndVoucher.getTransactionDate()) && entryBook .getCode().equals( - financialTransaction.getEntryBook() + financialTransactionForDateAndVoucher.getEntryBook() .getCode()))) { // create financial transaction - financialTransaction = financialTransactionService.createNewFinancialTransaction(); - financialTransaction.setEntryBook(entryBook); - financialTransaction.setTransactionDate(dateEcr); - financialTransaction = financialTransactionService.createFinancialTransaction(financialTransaction); - financialTransactionsByDate.put(financialTransaction.getTransactionDate(), financialTransaction); + financialTransactionForDateAndVoucher = financialTransactionService.createNewFinancialTransaction(); + financialTransactionForDateAndVoucher.setEntryBook(entryBook); + financialTransactionForDateAndVoucher.setTransactionDate(dateEcr); + financialTransactionForDateAndVoucher = financialTransactionService.createFinancialTransaction(financialTransactionForDateAndVoucher); + financialTransactionsForDate.add(financialTransactionForDateAndVoucher); } - financialTransaction.addEntry(entry); + + // add entry to financial transaction + financialTransactionForDateAndVoucher.addEntry(entry); financialTransactionService.createEntry(entry); } + private FinancialTransaction getFinancialTransactionForVoucher(Set<FinancialTransaction> financialTransactions, String voucher) { + FinancialTransaction financialTransactionForEntry = null; + if (financialTransactions != null) { + for (FinancialTransaction financialTransaction : financialTransactions) { + Collection<Entry> entries = financialTransaction.getEntry(); + if (entries != null && entries.iterator().hasNext()) { + Entry firstEntry = entries.iterator().next(); + if (firstEntry.getVoucher().contentEquals(voucher)) { + financialTransactionForEntry = financialTransaction; + break; + } + } else { + entries = Lists.newArrayList(); + financialTransaction.setEntry(entries); + financialTransactionForEntry = financialTransaction; + break; + } + } + } + return financialTransactionForEntry; + } + protected EntryBook getEntryBook(Map<String, EntryBook> indexedEntryBooks, String entryBookCode) throws AlreadyExistEntryBookException { EntryBook entryBook; // entryBook loading @@ -1094,19 +1130,24 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ return entryBook; } - protected Map<EntryBook, Map<Date, FinancialTransaction>> getEntryBookFinancialTransactionOrderedByDate(Date fiscalPeriodsBiginDate, Date fiscalPeriodsEndingDate) { - Map<EntryBook, Map<Date, FinancialTransaction>> entryBookFinancialTransactionByDate = new HashMap<>(); + protected Map<EntryBook, Map<Date, Set<FinancialTransaction>>> getEntryBookFinancialTransactionOrderedByDate(Date fiscalPeriodsBiginDate, Date fiscalPeriodsEndingDate) { + Map<EntryBook, Map<Date, Set<FinancialTransaction>>> entryBookFinancialTransactionByDate = new HashMap<>(); List<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(fiscalPeriodsBiginDate, fiscalPeriodsEndingDate); for (FinancialTransaction ft : financialTransactions) { EntryBook eb = ft.getEntryBook(); - Map<Date, FinancialTransaction> entryBooksFTs = entryBookFinancialTransactionByDate.get(eb); + Map<Date, Set<FinancialTransaction>> entryBooksFTs = entryBookFinancialTransactionByDate.get(eb); if (entryBooksFTs == null) { entryBooksFTs = new HashMap<>(); entryBookFinancialTransactionByDate.put(eb, entryBooksFTs); } // maybe not unique financial transaction for one date. // is there a way to know wich one to take ? - entryBooksFTs.put(ft.getTransactionDate(), ft); + Set<FinancialTransaction> financialTransactionsForEntryBook = entryBooksFTs.get(ft.getTransactionDate()); + if (financialTransactionsForEntryBook == null) { + financialTransactionsForEntryBook = Sets.newHashSet(); + } + financialTransactionsForEntryBook.add(ft); + entryBooksFTs.put(ft.getTransactionDate(), financialTransactionsForEntryBook); } return entryBookFinancialTransactionByDate; } diff --git a/lima-business/src/main/resources/i18n/lima-business_en_GB.properties b/lima-business/src/main/resources/i18n/lima-business_en_GB.properties index 89e4c1a..62a13bd 100644 --- a/lima-business/src/main/resources/i18n/lima-business_en_GB.properties +++ b/lima-business/src/main/resources/i18n/lima-business_en_GB.properties @@ -134,24 +134,32 @@ lima.config.scale.label= lima.config.serveraddress.description=Server Address lima.config.thousandSeparator.description= lima.config.thousandSeparator.label= -lima.configFileName.description=Descriontion -lima.financialtransaction.account=Account -lima.fiscalperiod.fiscalperiod=Fiscal period +lima.configFileName.description= +lima.financialtransaction.account= +lima.fiscalperiod.fiscalperiod= lima.host.address.description= lima.host.ejb.port.description= lima.host.http.address.description= lima.host.http.port.description= -lima.importexport.import.alreadyExistFinancialStatement=Same financial statement exists -lima.lettering.accountRegularization=Regulatory account +lima.import.error.entriesOutOfDatesRange= +lima.import.error.invalidAccountNumber= +lima.importexport.import.alreadyExistFinancialStatement= +lima.lettering.accountRegularization= lima.report.fromDateToDate= lima.reports.account.noAccount=Any account present lima.reports.account.noAccountTitle=Any account present -lima.reports.accounts=Accounts -lima.table.credit=Credit -lima.table.date=Date -lima.table.debit=Debit -lima.table.description=Description +lima.reports.account.noaccount= +lima.reports.account.noaccounttitle= +lima.reports.accounts= +lima.services.application.version= +lima.table.credit= +lima.table.date= +lima.table.debit= +lima.table.decription= +lima.table.description= lima.table.entryBook=Entry book -lima.table.letter=Letter -lima.table.number=Account number -lima.table.voucher=Voucher +lima.table.entrybook= +lima.table.letter= +lima.table.number= +lima.table.voucher= +llima.importexport.import.alreadyExistFinancialStatement= diff --git a/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties b/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties index 17c85be..6496672 100644 --- a/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties +++ b/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties @@ -100,6 +100,24 @@ lima-business.import.ebpmissingaccount=Échec \: Compte %s inexistant. \nCréer lima-business.import.entries.error.lockedEntryBook= lima-business.import.entries.error.lockedFinancialPeriod= lima-business.import.entriesoutofdatesrange=Attention \: Cette entrée %s ne fait partie d'aucune période ouverte. Entrée non importée. +lima-business.import.entryadded=Succès \: Entrée %s %s ajoutée \n +lima-business.import.entrybookalreadyexist=Échec \: Le journal %s exist déjà \!\n +lima-business.import.entrybooknotexist=Attention \: Le journal %s inexistant a été créé \!\n +lima-business.import.financialstatementadded=Succès \: Mouvement %s ajoutée \n +lima-business.import.financialstatementalnomaster=u00C9chec \: Le mouvement %s possède le master \: %s inexistant \n +lima-business.import.financialstatementalreadyexist=u00C9chec \: Le mouvement %s exist déjà \!\n +lima-business.import.fiscalperiodadded=Succès \: Exercice %s - %s ajoutée \! \n +lima-business.import.fiscalperiodalreadyexist=u00C9chec \: L'exerice %s - %s existe déjà \!\n +lima-business.import.fiscalperiodscloseperiodicentrybooks= +lima-business.import.identityadded=Succès \: Identité %s ajoutée \! \n +lima-business.import.lineformatmismatch=Le format de la ligne est incorrect. +lima-business.import.noaccount=Erreur \: Ce fichier ne contient aucun compte. +lima-business.import.nofiscalperiodopen=u00C9chec \: Aucun exercice ouvert \! \n +lima-business.import.transactionadded=Succès \: Transaction, %s, %s, ajoutée\n +lima-business.import.vatstatementadded=Succès \: Plan de TVA %s ajoutée \n +lima-business.import.vatstatementalnomaster=u00C9chec \: Le plan %s possède le master \: %s inexsitant \n +lima-business.import.vatstatementalreadyexist=u00C9chec \: Le plan %s exist déjà \!\n +lima.account.error.invalidAccountNumber= lima.config.configFileName.description=Nom du fichier de configuration de Lima lima.config.currency.description= lima.config.currency.label= @@ -138,21 +156,30 @@ lima.config.scale.label= lima.config.thousandSeparator.description= lima.config.thousandSeparator.label= lima.configFileName.description= -lima.financialtransaction.account=compte -lima.fiscalperiod.fiscalperiod=Période fiscale +lima.financialtransaction.account= +lima.fiscalperiod.fiscalperiod= lima.host.address.description=Addresse serveur lima.host.ejb.port.description=Port pour connexion du client au serveur lima.host.http.address.description= lima.host.http.port.description=Port du serveur web de Lima -lima.importexport.import.alreadyExistFinancialStatement=Transaction financière exitante -lima.lettering.accountRegularization=Compte de régulation +lima.import.error.entriesOutOfDatesRange= +lima.import.error.invalidAccountNumber= +lima.importexport.import.alreadyExistFinancialStatement= +lima.lettering.accountRegularization= lima.reports.account.noAccount=Aucun compte présent -lima.reports.accounts=Comptes -lima.table.credit=Credit -lima.table.date=Date -lima.table.debit=Débit -lima.table.description=Description +lima.reports.account.noaccount= +lima.reports.account.noaccounttitle= +lima.reports.accounts= +lima.services.application.version= +lima.table.credit= +lima.table.date= +lima.table.debit= +lima.table.decription= +lima.table.description= lima.table.entryBook=Journal -lima.table.letter=Lettre -lima.table.number=Numéro de compte -lima.table.voucher=Pièce comptable +lima.table.entrybook= +lima.table.letter= +lima.table.number= +lima.table.voucher= +lima.ui.importexport.import.exceptions.reason=Reason\:% +llima.importexport.import.alreadyExistFinancialStatement= diff --git a/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java b/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java index bbfeb59..118646d 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java @@ -38,10 +38,6 @@ import org.chorem.lima.business.api.IdentityService; import org.chorem.lima.business.api.ImportService; import org.chorem.lima.business.api.ReportService; import org.chorem.lima.business.api.VatStatementService; -import org.chorem.lima.business.exceptions.AlreadyExistAccountException; -import org.chorem.lima.business.exceptions.InvalidAccountNumberException; -import org.chorem.lima.business.exceptions.NotAllowedLabelException; -import org.chorem.lima.business.exceptions.NotNumberAccountNumberException; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.entity.Entry; @@ -205,7 +201,7 @@ public abstract class AbstractLimaTest { * @throws org.chorem.lima.business.exceptions.InvalidAccountNumberException * @throws org.chorem.lima.business.exceptions.NotNumberAccountNumberException */ - protected void createAccounts() throws AlreadyExistAccountException, NotAllowedLabelException, InvalidAccountNumberException, NotNumberAccountNumberException { + protected void initTestWithAccounts() throws Exception { // creation d'un plan compatble de test Account classFinancier = new AccountImpl(); @@ -250,7 +246,7 @@ public abstract class AbstractLimaTest { * @throws org.chorem.lima.business.exceptions.LimaException * @throws java.text.ParseException */ - protected void createEntryBooks() throws Exception { + protected void initTestWithEntryBooks() throws Exception { // creation d'un journal EntryBook journalDesVentes = new EntryBookImpl(); journalDesVentes.setLabel("Journal des ventes"); @@ -275,8 +271,7 @@ public abstract class AbstractLimaTest { * @throws org.chorem.lima.business.exceptions.LimaException * @throws java.text.ParseException */ - protected void createFiscalPeriod() throws Exception { - + protected void initTestWithFiscalPeriod() throws Exception { // creation d'un exercice fiscal FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); fiscalPeriod.setBeginDate(df.parse("January 1, 2012")); @@ -288,15 +283,100 @@ public abstract class AbstractLimaTest { * Create FinancialTransaction with 2 entries * @throws Exception */ - protected void createFinancialTransaction() throws Exception { + protected void initTestWithFinancialTransaction() throws Exception { + + Account accountVmpVae = accountService.getAccountByNumber("511"); + EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv"); + + FinancialTransaction transaction1 = new FinancialTransactionImpl(); + transaction1.setTransactionDate(df.parse("April 4, 2012")); + transaction1.setEntryBook(journalDesVentes); + transaction1 = financialTransactionService.createFinancialTransaction(transaction1); + + Entry tr1Entry1 = new EntryImpl(); + tr1Entry1.setAmount(BigDecimal.valueOf(42.0)); + tr1Entry1.setAccount(accountVmpVae); + tr1Entry1.setFinancialTransaction(transaction1); + tr1Entry1.setDescription("test desc"); + tr1Entry1.setVoucher("voucher"); + tr1Entry1 = financialTransactionService.createEntry(tr1Entry1); + + Entry tr1Entry2 = new EntryImpl(); + tr1Entry2.setAmount(BigDecimal.valueOf(42.0)); + tr1Entry2.setDebit(true); + tr1Entry2.setAccount(accountVmpVae); + tr1Entry2.setFinancialTransaction(transaction1); + tr1Entry2.setDescription("test desc"); + tr1Entry2.setVoucher("voucher"); + tr1Entry2 = financialTransactionService.createEntry(tr1Entry2); + + transaction1.setEntry(Lists.newArrayList(tr1Entry1, tr1Entry2)); + financialTransactionService.updateFinancialTransaction(transaction1); + } - createFinancialTransaction("jdv", df.parse("April 4, 2012"), "511", "501", BigDecimal.valueOf(42.0)); + + protected void initTestWithSomeFinancialTransaction() throws Exception { + + Account accountVmpVae = accountService.getAccountByNumber("511"); + EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv"); + + FinancialTransaction transaction1 = new FinancialTransactionImpl(); + transaction1.setTransactionDate(df.parse("April 4, 2012")); + transaction1.setEntryBook(journalDesVentes); + transaction1 = financialTransactionService.createFinancialTransaction(transaction1); + + Entry tr1Entry1 = new EntryImpl(); + tr1Entry1.setAmount(BigDecimal.valueOf(42.0)); + tr1Entry1.setAccount(accountVmpVae); + tr1Entry1.setFinancialTransaction(transaction1); + tr1Entry1.setDescription("test desc"); + tr1Entry1.setVoucher("voucherA"); + tr1Entry1 = financialTransactionService.createEntry(tr1Entry1); + + Entry tr1Entry2 = new EntryImpl(); + tr1Entry2.setAmount(BigDecimal.valueOf(42.0)); + tr1Entry2.setDebit(true); + tr1Entry2.setAccount(accountVmpVae); + tr1Entry2.setFinancialTransaction(transaction1); + tr1Entry2.setDescription("test desc"); + tr1Entry2.setVoucher("voucherA"); + tr1Entry2 = financialTransactionService.createEntry(tr1Entry2); + + transaction1.setEntry(Lists.newArrayList(tr1Entry1, tr1Entry2)); + financialTransactionService.updateFinancialTransaction(transaction1); + + FinancialTransaction transaction2 = new FinancialTransactionImpl(); + transaction2.setTransactionDate(df.parse("April 4, 2012")); + transaction2.setEntryBook(journalDesVentes); + transaction2 = financialTransactionService.createFinancialTransaction(transaction2); + + Entry tr1Entry1b = new EntryImpl(); + tr1Entry1b.setAmount(BigDecimal.valueOf(12.0)); + tr1Entry1b.setAccount(accountVmpVae); + tr1Entry1b.setFinancialTransaction(transaction2); + tr1Entry1b.setDescription("test desc"); + tr1Entry1b.setVoucher("voucherB"); + financialTransactionService.createEntry(tr1Entry1b); + + Entry tr1Entry2b = new EntryImpl(); + tr1Entry2b.setAmount(BigDecimal.valueOf(6.0)); + tr1Entry2b.setDebit(true); + tr1Entry2b.setAccount(accountVmpVae); + tr1Entry2b.setFinancialTransaction(transaction2); + tr1Entry2b.setDescription("test desc"); + tr1Entry2b.setVoucher("voucherB"); + financialTransactionService.createEntry(tr1Entry2b); + + Entry tr1Entry3b = new EntryImpl(); + tr1Entry3b.setAmount(BigDecimal.valueOf(6.0)); + tr1Entry3b.setDebit(true); + tr1Entry3b.setAccount(accountVmpVae); + tr1Entry3b.setFinancialTransaction(transaction2); + tr1Entry3b.setDescription("test desc"); + tr1Entry3b.setVoucher("voucherB"); + financialTransactionService.createEntry(tr1Entry3b); } - /** - * Create FinancialTransaction with 2 entries - * @throws Exception - */ protected FinancialTransaction createFinancialTransaction(String entryBookCode, Date date, String accountDebitNumber, String accountCreditNumber, BigDecimal amount) throws Exception { @@ -333,4 +413,4 @@ public abstract class AbstractLimaTest { return transaction; } -} +} \ No newline at end of file diff --git a/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java b/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java index 26df6ff..cb02753 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java @@ -52,7 +52,7 @@ public class AccountServiceImplTest extends AbstractLimaTest { @Before public void initTest() throws Exception { - createAccounts(); + initTestWithAccounts(); } @Test @@ -362,9 +362,9 @@ public class AccountServiceImplTest extends AbstractLimaTest { */ @Test(expected = UsedAccountException.class) public void removeUsedAccountTest() throws Exception { - createEntryBooks(); - createFiscalPeriod(); - createFinancialTransaction(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); + initTestWithFinancialTransaction(); Account account = accountService.getAccountByNumber("511"); accountService.removeAccount(account); } diff --git a/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java b/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java index 8455e99..56b768f 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java @@ -48,7 +48,7 @@ public class EntryBookServiceImplTest extends AbstractLimaTest { @Before public void initTest() throws Exception { - createEntryBooks(); + initTestWithEntryBooks(); } @Test @@ -175,8 +175,8 @@ public class EntryBookServiceImplTest extends AbstractLimaTest { */ @Test(expected=UsedEntryBookException.class) public void deleteUsedEntryBook() throws Exception { - createFiscalPeriod(); - createFinancialTransaction(); + initTestWithFiscalPeriod(); + initTestWithFinancialTransaction(); EntryBook entryBook = entryBookService.getEntryBookByCode("jdv"); entryBookService.removeEntryBook(entryBook); diff --git a/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java b/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java index 5da0a81..8dbc49c 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java @@ -58,9 +58,9 @@ public class FinancialPeriodServiceImplTest extends AbstractLimaTest { @Before public void initTest() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); } @Test diff --git a/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java b/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java index 0ebf319..e4a9e16 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java @@ -63,9 +63,9 @@ public class FinancialTransactionServiceImplTest extends AbstractLimaTest { @Before public void initTest() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); } @Test diff --git a/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java b/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java index 08168f9..8f5f9ed 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java @@ -72,8 +72,8 @@ public class FiscalPeriodServiceImplTest extends AbstractLimaTest { @Before public void initTest() throws Exception { - createAccounts(); - createEntryBooks(); + initTestWithAccounts(); + initTestWithEntryBooks(); } @Test diff --git a/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java b/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java index 4e147a7..dbaf7d5 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java @@ -55,6 +55,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; +import java.math.BigDecimal; import java.nio.charset.Charset; import java.text.ParseException; import java.util.ArrayList; @@ -72,9 +73,9 @@ public class ImportExportServiceTest extends AbstractLimaTest { @Test public void testExportImportAccounts() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); // make sure they are some accounts. List<Account> accounts = accountService.getAllAccounts(); Assert.assertTrue(accountService.getAllAccounts().size() > 0); @@ -105,7 +106,7 @@ public class ImportExportServiceTest extends AbstractLimaTest { // make sure all account have been created Assert.assertEquals(nbEntities, accountService.getAllAccounts().size()); Assert.assertEquals(nbEntities, result.getImportResults().get(0).getNbCreated()); - Assert.assertNull(result.getImportResults().get(0).getAllExceptionsByLine()); + Assert.assertTrue(result.getImportResults().get(0).getAllExceptionsByLine().isEmpty()); } finally { IOUtils.closeQuietly(contentStream); } @@ -117,7 +118,7 @@ public class ImportExportServiceTest extends AbstractLimaTest { ImportExportResults result = importService.importAccountAsCSV(inportStream); Assert.assertNotNull(result); Map<Integer, LimaException> exceptionMap = result.getImportResults().get(0).getAllExceptionsByLine(); - Assert.assertNotNull(exceptionMap); + Assert.assertTrue(!exceptionMap.isEmpty()); Collection<LimaException> exceptions = exceptionMap.values(); Assert.assertEquals(1, exceptions.size()); ImportFileException exception = (ImportFileException) exceptions.iterator().next(); @@ -126,8 +127,8 @@ public class ImportExportServiceTest extends AbstractLimaTest { @Test public void testExportImportEntryBooks() throws Exception { - createAccounts(); - createEntryBooks(); + initTestWithAccounts(); + initTestWithEntryBooks(); String tmpDir = System.getProperty("java.io.tmpdir")+"/"; ImportExportResults export = exportService.exportEntryBooksAsCSV(Charset.defaultCharset().name()); @@ -157,15 +158,15 @@ public class ImportExportServiceTest extends AbstractLimaTest { Assert.assertEquals(nbEntities, entryBookService.getAllEntryBooks().size()); Assert.assertEquals(nbEntities, result.getNbCreated()); - Assert.assertNull(result.getAllExceptionsByLine()); + Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); } @Test public void testExportImportEntries() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); - createFinancialTransaction(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); + initTestWithFinancialTransaction(); List<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("April 4, 2012"),df.parse("December 31, 2012")); List<Entry> entries = Lists.newArrayList(); @@ -214,14 +215,14 @@ public class ImportExportServiceTest extends AbstractLimaTest { Assert.assertEquals(nbEntities, entries.size()); Assert.assertEquals(nbEntities, result.getNbCreated()); - Assert.assertNull(result.getAllExceptionsByLine()); + Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); } @Test public void testExportImportFiscalPeriodsAsCSV() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); String tmpDir = System.getProperty("java.io.tmpdir")+"/"; String export = exportService.exportFiscalPeriodsAsCSV(Charset.defaultCharset().name()).getExportResults().get(0).getExportData(); @@ -249,15 +250,15 @@ public class ImportExportServiceTest extends AbstractLimaTest { Assert.assertEquals(nbFiscalPeriods, fiscalPeriodService.getAllFiscalPeriods().size()); Assert.assertEquals(nbFiscalPeriods, result.getNbCreated()); - Assert.assertNull(result.getAllExceptionsByLine()); + Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); } @Test public void exportImportAllAsCSVTest() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); - createFinancialTransaction(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); + initTestWithFinancialTransaction(); Identity identity = new IdentityImpl(); identity.setName("Code Lutin"); @@ -284,7 +285,7 @@ public class ImportExportServiceTest extends AbstractLimaTest { ImportResult importResult = importResults.get(i); log.info(imported[i] +": created:"+importResult.getNbCreated() + " updated:" + importResult.getNbUpdated() + " ignoded:" + importResult.getNbIgnored()); Assert.assertTrue(importResult.getNbCreated()>0); - Assert.assertNull(importResult.getAllExceptionsByLine()); + Assert.assertTrue(importResult.getAllExceptionsByLine().isEmpty()); } } @@ -444,7 +445,7 @@ public class ImportExportServiceTest extends AbstractLimaTest { result = importService.importFinancialStatementsAsCSV(bcr_developed).getImportResults().get(0); - Assert.assertNull(result.getAllExceptionsByLine()); + Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); Assert.assertEquals(162, result.getNbCreated()); Assert.assertEquals(162, financialStatementService.getAllFinancialStatements().size()); FinancialStatement actifImmobiliseStatement = financialStatementService.getFinancialStatementByLabel("ACTIF IMMOBILISÉ"); @@ -465,7 +466,7 @@ public class ImportExportServiceTest extends AbstractLimaTest { result = importService.importVATStatementsAsCSV(bcr_developed).getImportResults().get(0); - Assert.assertNull(result.getAllExceptionsByLine()); + Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); Assert.assertEquals(55, result.getNbCreated()); Assert.assertEquals(55, vatStatementService.getAllVatStatements().size()); } @@ -506,7 +507,7 @@ public class ImportExportServiceTest extends AbstractLimaTest { InputStream entriesStream = ImportExportServiceTest.class.getResourceAsStream("/ebp/ecritures.txt"); String entriesData = IOUtils.toString(entriesStream, "ISO-8859-1"); ImportResult result = importService.importEntriesFromEbp(entriesData).getImportResults().get(0); - Assert.assertNull(result.getAllExceptionsByLine()); + Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); Assert.assertEquals(28, result.getNbCreated()); entriesStream.close(); @@ -552,10 +553,10 @@ public class ImportExportServiceTest extends AbstractLimaTest { @Test public void testExportImportEntriesEbp() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); - createFinancialTransaction(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); + initTestWithSomeFinancialTransaction(); List<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("April 4, 2012"),df.parse("December 31, 2012")); List<Entry> entries = Lists.newArrayList(); @@ -564,7 +565,6 @@ public class ImportExportServiceTest extends AbstractLimaTest { entries.addAll(financialTransaction.getEntry()); } Assert.assertTrue(!entries.isEmpty()); - int nbEntities = entries.size(); //test export String tmpDir = System.getProperty("java.io.tmpdir")+"/"; @@ -590,27 +590,33 @@ public class ImportExportServiceTest extends AbstractLimaTest { // test import FileInputStream contentStream = null; - ImportResult result; try { contentStream = new FileInputStream(tmpDir + "export-entries-EBP.csv"); String inputStream = IOUtils.toString(contentStream); - result = importService.importEntriesFromEbp(inputStream).getImportResults().get(0); + importService.importEntriesFromEbp(inputStream).getImportResults().get(0); } finally { IOUtils.closeQuietly(contentStream); } // valid import financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("April 4, 2012"),df.parse("December 31, 2012")); - Assert.assertEquals(1, financialTransactions.size()); + Assert.assertEquals(2, financialTransactions.size()); for (FinancialTransaction financialTransaction : financialTransactions) { - entries.addAll(financialTransaction.getEntry()); - } - - Assert.assertEquals(nbEntities, entries.size()); - Assert.assertEquals(nbEntities, result.getNbCreated()); - Assert.assertNull(result.getAllExceptionsByLine()); - for (Entry entry : entries) { - Assert.assertTrue(42.0 == entry.getAmount().doubleValue()); + if (financialTransaction.getAmountDebit().compareTo(BigDecimal.valueOf(42.0)) == 0) { + Collection<Entry> voucherAEntries = financialTransaction.getEntry(); + Assert.assertEquals(2L, voucherAEntries.size()); + for (Entry entry : voucherAEntries) { + Assert.assertTrue(entry.getVoucher().contentEquals("voucherA")); + } + } else if (financialTransaction.getAmountDebit().compareTo(BigDecimal.valueOf(12.0)) == 0) { + Collection<Entry> voucherBEntries = financialTransaction.getEntry(); + Assert.assertEquals(3L, voucherBEntries.size()); + for (Entry entry : voucherBEntries) { + Assert.assertTrue(entry.getVoucher().contentEquals("voucherB")); + } + } else { + Assert.fail("Fail to import financial transactions"); + } } } diff --git a/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java b/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java index 6851851..a3e05e0 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/ReportServiceImplTest.java @@ -48,10 +48,10 @@ public class ReportServiceImplTest extends AbstractLimaTest { @Before public void initTest() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); - createFinancialTransaction(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); + initTestWithFinancialTransaction(); } /** diff --git a/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java b/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java index 1ea0b63..a5dba3f 100644 --- a/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java +++ b/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java @@ -54,10 +54,10 @@ public class FinancialTransactionDAOTest extends AbstractLimaTest { @Test public void testFindAllUnbalancedTransactions() throws Exception { - createAccounts(); - createEntryBooks(); - createFiscalPeriod(); - createFinancialTransaction(); + initTestWithAccounts(); + initTestWithEntryBooks(); + initTestWithFiscalPeriod(); + initTestWithFinancialTransaction(); FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0); EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv"); diff --git a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties index 9022472..363fe27 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties @@ -428,7 +428,10 @@ lima.identity.phoneNumber=Phone number lima.identity.vatNumber=VAT number lima.identity.zipCode=Zip code lima.import.error=Import Failed +lima.import.error.andMoreErrors=And %d more errors +lima.import.error.entriesOutOfDatesRange=Open fiscal period lima.import.error.extractFile=Invalid file +lima.import.error.invalidAccountNumber=None existing account with number '%' lima.import.error.noDataToImport=Any data to import lima.import.error.unknown=Unknown error lima.import.line=line diff --git a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties index 541d2e3..5d8f7dd 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties @@ -439,7 +439,10 @@ lima.identity.phoneNumber=n° Tel lima.identity.vatNumber=Numéro TVA\: FR lima.identity.zipCode=Code Postal lima.import.error=Une erreur est survenue lors de l'import +lima.import.error.andMoreErrors=Et %d autres erreurs... +lima.import.error.entriesOutOfDatesRange=Periode fiscale non authorisé lima.import.error.extractFile=Le fichier n'est correct +lima.import.error.invalidAccountNumber=Le compte '%s' n'existe pas. lima.import.error.noDataToImport=Aucune donnée à importer. lima.import.error.unknown=Erreur inconnue. lima.import.line=Ligne %d\: -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1174-Import_EBP_Transactions in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 8f3fbd5dfa2219ed181c487786dbd780fb396f79 Author: David Cossé <cosse@codelutin.com> Date: Fri Jul 8 10:33:23 2016 +0200 refs #1174 ajout d'une exception pour gérer le cas ou l'on essaye de supprimer un compte qui 'existe pas --- .../business/exceptions/UnexistingAccount.java | 26 +++++++++++++++++++++- .../accountingrules/DefaultAccountingRules.java | 6 ++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/exceptions/UnexistingAccount.java b/lima-business-api/src/main/java/org/chorem/lima/business/exceptions/UnexistingAccount.java index f8c7528..34bc826 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/exceptions/UnexistingAccount.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/exceptions/UnexistingAccount.java @@ -1,10 +1,34 @@ package org.chorem.lima.business.exceptions; +/* + * #%L + * Lima :: business API + * %% + * Copyright (C) 2008 - 2014 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + /** - * Created by davidcosse on 08/07/16. + * @author David Cossé */ public class UnexistingAccount extends AccountException { + private static final long serialVersionUID = 1L; + public UnexistingAccount(String accountNumber, String message) { super(accountNumber, message); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java index 9c2fafb..182b557 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java +++ b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java @@ -39,6 +39,7 @@ import org.chorem.lima.business.exceptions.NoEmptyFiscalPeriodException; import org.chorem.lima.business.exceptions.NotBeginNextDayOfLastFiscalPeriodException; import org.chorem.lima.business.exceptions.NotLockedClosedPeriodicEntryBooksException; import org.chorem.lima.business.exceptions.NotNumberAccountNumberException; +import org.chorem.lima.business.exceptions.UnexistingAccount; import org.chorem.lima.business.exceptions.UnbalancedEntriesException; import org.chorem.lima.business.exceptions.UnbalancedFinancialTransactionsException; import org.chorem.lima.business.exceptions.UnfilledEntriesException; @@ -175,10 +176,13 @@ public class DefaultAccountingRules implements AccountingRules { * Recursive function */ @Override - public void removeAccountRules(Account account) throws UsedAccountException { + public void removeAccountRules(Account account) throws UsedAccountException, UnexistingAccount { EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); // Check if account have entries + if (!account.isPersisted()) { + throw new UnexistingAccount(account.getAccountNumber(), "Unsaved Account, this account can not be removed"); + } if (entryTopiaDao.forAccountEquals(account).exists()) { throw new UsedAccountException(account.getAccountNumber()); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1174-Import_EBP_Transactions in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 49a9e4543b9f0e5179c4838d225f854cb23ceaba Author: David Cossé <cosse@codelutin.com> Date: Thu Sep 8 13:38:54 2016 +0200 refs #1174 Correction sur affichage des résultats d'import dans le cas ou il n'y a pas eu d'erreur --- .../test/java/org/chorem/lima/business/ImportExportServiceTest.java | 3 ++- .../src/main/java/org/chorem/lima/ui/importexport/ImportExport.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java b/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java index dbaf7d5..e4e6a4d 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java @@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringUtils; import org.chorem.lima.LimaTechnicalException; import org.chorem.lima.business.exceptions.AlreadyExistEntryBookException; import org.chorem.lima.business.exceptions.BeginAfterEndFiscalPeriodException; +import org.chorem.lima.business.exceptions.ImportEbpException; import org.chorem.lima.business.exceptions.ImportFileException; import org.chorem.lima.business.exceptions.LimaException; import org.chorem.lima.business.exceptions.MoreOneUnlockFiscalPeriodException; @@ -621,7 +622,7 @@ public class ImportExportServiceTest extends AbstractLimaTest { } protected void importEBPData() throws IOException, ParseException, BeginAfterEndFiscalPeriodException, - NotBeginNextDayOfLastFiscalPeriodException, MoreOneUnlockFiscalPeriodException { + NotBeginNextDayOfLastFiscalPeriodException, MoreOneUnlockFiscalPeriodException, ImportEbpException { // create fiscal period (mandatory for import) FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java b/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java index 970d1b1..6ee3c74 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java @@ -395,7 +395,7 @@ public class ImportExport { Class fromSource = result.getFromSource(); message.append("Import "); message.append(getFromSourceMessage(fromSource)); - message.append(result.getAllExceptionsByLine().size() > 0 ? "Des erreurs sont survenues lors de l'import, veuillez regarder le fichier de log pour plus de détails.\n" : "Aucune erreur rencontrée\n"); + message.append(result.getAllExceptionsByLine().isEmpty() ? "Aucune erreur rencontrée\n" : "Des erreurs sont survenues lors de l'import, veuillez regarder le fichier de log pour plus de détails.\n"); message.append(t("lima.import.report", result.getNbCreated(), result.getNbIgnored(), result.getNbUpdated())); logErrorMessage(result, fromSource); @@ -420,7 +420,7 @@ public class ImportExport { protected void logErrorMessage(ImportResult result,Class fromSource) { Map<Integer, LimaException> exceptionsByLine = result.getAllExceptionsByLine(); - if (exceptionsByLine != null) { + if (!exceptionsByLine.isEmpty()) { StringBuilder errorMessage = new StringBuilder(); errorMessage.append("\n" + "Import " + getFromSourceMessage(fromSource)); errorMessage.append("\n" + t("lima.import.report", result.getNbCreated(), result.getNbIgnored(), result.getNbUpdated())); @@ -701,7 +701,7 @@ public class ImportExport { protected ImportExportResults processBackup(ImportResult result, String tmpDir, String determinant) { ImportExportResults results = null; InputStream entryBooksStream = null, transactionsStream = null, fiscalPeriodsStream = null, accountsStream = null, entriesStream = null, identityStream = null; - if (result.getAllExceptionsByLine() == null || result.getAllExceptionsByLine().isEmpty()) { + if (result.getAllExceptionsByLine().isEmpty()) { try { entryBooksStream = new FileInputStream(tmpDir + EntryBook.class.getSimpleName() + "-" + determinant + ".csv"); String entryBooksStreamString = IOUtils.toString(entryBooksStream); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1174-Import_EBP_Transactions in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 15ca0fe9bfa6aebb5586680dc805e4f6a9fbf92d Author: David Cossé <cosse@codelutin.com> Date: Thu Sep 8 15:16:31 2016 +0200 refs #1174 l'exception sur la non existance d'un compte dont la suppression est demandée ne doit pas être levé au niveau des règles métier --- .../chorem/lima/business/accountingrules/DefaultAccountingRules.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java index 182b557..dca2f1d 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java +++ b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java @@ -180,9 +180,6 @@ public class DefaultAccountingRules implements AccountingRules { EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); // Check if account have entries - if (!account.isPersisted()) { - throw new UnexistingAccount(account.getAccountNumber(), "Unsaved Account, this account can not be removed"); - } if (entryTopiaDao.forAccountEquals(account).exists()) { throw new UsedAccountException(account.getAccountNumber()); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1174-Import_EBP_Transactions in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 2cd8ecd3774bcd6cd5d7d72694e18ec1c4a29076 Author: David Cossé <cosse@codelutin.com> Date: Thu Sep 8 15:18:56 2016 +0200 refs #1174 suppression de l'exception de la signature de la méthode --- .../src/main/java/org/chorem/lima/business/AccountingRules.java | 3 +-- .../chorem/lima/business/accountingrules/DefaultAccountingRules.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java b/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java index 93cb419..a319a22 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java +++ b/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java @@ -36,7 +36,6 @@ import org.chorem.lima.business.exceptions.NotLockedClosedPeriodicEntryBooksExce import org.chorem.lima.business.exceptions.NotNumberAccountNumberException; import org.chorem.lima.business.exceptions.UnbalancedEntriesException; import org.chorem.lima.business.exceptions.UnbalancedFinancialTransactionsException; -import org.chorem.lima.business.exceptions.UnexistingAccount; import org.chorem.lima.business.exceptions.UnfilledEntriesException; import org.chorem.lima.business.exceptions.UsedAccountException; import org.chorem.lima.business.exceptions.UsedEntryBookException; @@ -68,7 +67,7 @@ public interface AccountingRules { void updateAccountRules(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException; - void removeAccountRules(Account account) throws UsedAccountException, UnexistingAccount; + void removeAccountRules(Account account) throws UsedAccountException; /** * Entrybook rules. diff --git a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java index dca2f1d..9c2fafb 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java +++ b/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java @@ -39,7 +39,6 @@ import org.chorem.lima.business.exceptions.NoEmptyFiscalPeriodException; import org.chorem.lima.business.exceptions.NotBeginNextDayOfLastFiscalPeriodException; import org.chorem.lima.business.exceptions.NotLockedClosedPeriodicEntryBooksException; import org.chorem.lima.business.exceptions.NotNumberAccountNumberException; -import org.chorem.lima.business.exceptions.UnexistingAccount; import org.chorem.lima.business.exceptions.UnbalancedEntriesException; import org.chorem.lima.business.exceptions.UnbalancedFinancialTransactionsException; import org.chorem.lima.business.exceptions.UnfilledEntriesException; @@ -176,7 +175,7 @@ public class DefaultAccountingRules implements AccountingRules { * Recursive function */ @Override - public void removeAccountRules(Account account) throws UsedAccountException, UnexistingAccount { + public void removeAccountRules(Account account) throws UsedAccountException { EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); // Check if account have entries -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1174-Import_EBP_Transactions in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 45cac9a26f1bddfae8f8a910b2917d30628a83f6 Author: David Cossé <cosse@codelutin.com> Date: Thu Sep 8 15:20:44 2016 +0200 refs #1174 Rollback Changes, les résultats ne sont pas satifaisant au regard de la balance de référence --- .../lima/business/ejb/ImportServiceImpl.java | 84 ++++++---------------- .../lima/business/ImportExportServiceTest.java | 25 +++---- 2 files changed, 30 insertions(+), 79 deletions(-) diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java index 11feab7..11a23d1 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java @@ -23,7 +23,6 @@ package org.chorem.lima.business.ejb; */ import com.google.common.base.Function; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Ordering; import com.google.common.collect.Sets; @@ -988,7 +987,7 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ // the entry entity is created and the association with it's dependant entites (Account are FinancialTransaction) are created Date fiscalPeriodsBeginDate = fiscalPeriods.get(0).getBeginDate(); Date fiscalPeriodsEndingDate = fiscalPeriods.get(fiscalPeriods.size() - 1).getEndDate(); - Map<EntryBook, Map<Date, Set<FinancialTransaction>>> entryBookFinancialTransactionsByDate = getEntryBookFinancialTransactionOrderedByDate(fiscalPeriodsBeginDate, fiscalPeriodsEndingDate); + Map<EntryBook, Map<Date, FinancialTransaction>> entryBookFinancialTransactionByDate = getEntryBookFinancialTransactionOrderedByDate(fiscalPeriodsBeginDate, fiscalPeriodsEndingDate); for (EntryEBP entryEBP : entryEBPs) { Date dateEcr = entryEBP.getDatEcr(); @@ -1007,7 +1006,7 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ try { // find financial transactions for entry period and entrybook - addEntryToFinancialTransaction(entry, entryEBP.getJournal(), indexedEntryBooks, entryBookFinancialTransactionsByDate, dateEcr); + addEntryToFinancialTransaction(entry, entryEBP.getJournal(), indexedEntryBooks, entryBookFinancialTransactionByDate, dateEcr); } catch (LockedFinancialPeriodException | LockedEntryBookException | AlreadyExistEntryBookException | AfterLastFiscalPeriodException | BeforeFirstFiscalPeriodException e) { result.addException(e); @@ -1051,68 +1050,34 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ return entry; } - protected void addEntryToFinancialTransaction(Entry entry, String entryBookCode, Map<String, EntryBook> indexedEntryBooks, Map<EntryBook, Map<Date, Set<FinancialTransaction>>> entryBookFinancialTransactionsByDate, Date dateEcr) throws LockedFinancialPeriodException, LockedEntryBookException, AlreadyExistEntryBookException, AfterLastFiscalPeriodException, BeforeFirstFiscalPeriodException { + protected void addEntryToFinancialTransaction(Entry entry, String entryBookCode, Map<String, EntryBook> indexedEntryBooks, Map<EntryBook, Map<Date, FinancialTransaction>> entryBookFinancialTransactionByDate, Date dateEcr) throws LockedFinancialPeriodException, LockedEntryBookException, AlreadyExistEntryBookException, AfterLastFiscalPeriodException, BeforeFirstFiscalPeriodException { EntryBook entryBook = getEntryBook(indexedEntryBooks, entryBookCode); - Map<Date, Set<FinancialTransaction>> financialTransactionsByDate = entryBookFinancialTransactionsByDate.get(entryBook); + Map<Date, FinancialTransaction> financialTransactionsByDate = entryBookFinancialTransactionByDate.get(entryBook); if (financialTransactionsByDate == null) { financialTransactionsByDate = new HashMap<>(); - entryBookFinancialTransactionsByDate.put(entryBook, financialTransactionsByDate); + entryBookFinancialTransactionByDate.put(entryBook, financialTransactionsByDate); } - // find financial transaction for this required date and required voucher. - Set<FinancialTransaction> financialTransactionsForDate = financialTransactionsByDate.get(dateEcr); - if (financialTransactionsForDate == null) { - financialTransactionsForDate = Sets.newHashSet(); - financialTransactionsByDate.put(dateEcr, financialTransactionsForDate); - } - - String voucher = entry.getVoucher(); - - // look for an existing one - FinancialTransaction financialTransactionForDateAndVoucher = getFinancialTransactionForVoucher(financialTransactionsForDate, voucher); - - // if none exist a new one is created - if (financialTransactionForDateAndVoucher == null - || !(dateEcr.equals(financialTransactionForDateAndVoucher.getTransactionDate()) && entryBook + // create transaction + FinancialTransaction financialTransaction = financialTransactionsByDate.get(dateEcr); + if (financialTransaction == null + || !(dateEcr.equals(financialTransaction + .getTransactionDate()) && entryBook .getCode().equals( - financialTransactionForDateAndVoucher.getEntryBook() + financialTransaction.getEntryBook() .getCode()))) { // create financial transaction - financialTransactionForDateAndVoucher = financialTransactionService.createNewFinancialTransaction(); - financialTransactionForDateAndVoucher.setEntryBook(entryBook); - financialTransactionForDateAndVoucher.setTransactionDate(dateEcr); - financialTransactionForDateAndVoucher = financialTransactionService.createFinancialTransaction(financialTransactionForDateAndVoucher); - financialTransactionsForDate.add(financialTransactionForDateAndVoucher); + financialTransaction = financialTransactionService.createNewFinancialTransaction(); + financialTransaction.setEntryBook(entryBook); + financialTransaction.setTransactionDate(dateEcr); + financialTransaction = financialTransactionService.createFinancialTransaction(financialTransaction); + financialTransactionsByDate.put(financialTransaction.getTransactionDate(), financialTransaction); } - - // add entry to financial transaction - financialTransactionForDateAndVoucher.addEntry(entry); + financialTransaction.addEntry(entry); financialTransactionService.createEntry(entry); } - private FinancialTransaction getFinancialTransactionForVoucher(Set<FinancialTransaction> financialTransactions, String voucher) { - FinancialTransaction financialTransactionForEntry = null; - if (financialTransactions != null) { - for (FinancialTransaction financialTransaction : financialTransactions) { - Collection<Entry> entries = financialTransaction.getEntry(); - if (entries != null && entries.iterator().hasNext()) { - Entry firstEntry = entries.iterator().next(); - if (firstEntry.getVoucher().contentEquals(voucher)) { - financialTransactionForEntry = financialTransaction; - break; - } - } else { - entries = Lists.newArrayList(); - financialTransaction.setEntry(entries); - financialTransactionForEntry = financialTransaction; - break; - } - } - } - return financialTransactionForEntry; - } - protected EntryBook getEntryBook(Map<String, EntryBook> indexedEntryBooks, String entryBookCode) throws AlreadyExistEntryBookException { EntryBook entryBook; // entryBook loading @@ -1130,24 +1095,19 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ return entryBook; } - protected Map<EntryBook, Map<Date, Set<FinancialTransaction>>> getEntryBookFinancialTransactionOrderedByDate(Date fiscalPeriodsBiginDate, Date fiscalPeriodsEndingDate) { - Map<EntryBook, Map<Date, Set<FinancialTransaction>>> entryBookFinancialTransactionByDate = new HashMap<>(); - List<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(fiscalPeriodsBiginDate, fiscalPeriodsEndingDate); + protected Map<EntryBook, Map<Date, FinancialTransaction>> getEntryBookFinancialTransactionOrderedByDate(Date fiscalPeriodsBeginDate, Date fiscalPeriodsEndingDate) { + Map<EntryBook, Map<Date, FinancialTransaction>> entryBookFinancialTransactionByDate = new HashMap<>(); + List<FinancialTransaction> financialTransactions = financialTransactionService.getAllFinancialTransactions(fiscalPeriodsBeginDate, fiscalPeriodsEndingDate); for (FinancialTransaction ft : financialTransactions) { EntryBook eb = ft.getEntryBook(); - Map<Date, Set<FinancialTransaction>> entryBooksFTs = entryBookFinancialTransactionByDate.get(eb); + Map<Date, FinancialTransaction> entryBooksFTs = entryBookFinancialTransactionByDate.get(eb); if (entryBooksFTs == null) { entryBooksFTs = new HashMap<>(); entryBookFinancialTransactionByDate.put(eb, entryBooksFTs); } // maybe not unique financial transaction for one date. // is there a way to know wich one to take ? - Set<FinancialTransaction> financialTransactionsForEntryBook = entryBooksFTs.get(ft.getTransactionDate()); - if (financialTransactionsForEntryBook == null) { - financialTransactionsForEntryBook = Sets.newHashSet(); - } - financialTransactionsForEntryBook.add(ft); - entryBooksFTs.put(ft.getTransactionDate(), financialTransactionsForEntryBook); + entryBooksFTs.put(ft.getTransactionDate(), ft); } return entryBookFinancialTransactionByDate; } diff --git a/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java b/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java index e4e6a4d..4fbd06a 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java @@ -56,7 +56,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; -import java.math.BigDecimal; import java.nio.charset.Charset; import java.text.ParseException; import java.util.ArrayList; @@ -566,6 +565,7 @@ public class ImportExportServiceTest extends AbstractLimaTest { entries.addAll(financialTransaction.getEntry()); } Assert.assertTrue(!entries.isEmpty()); + int nbEntities = entries.size(); //test export String tmpDir = System.getProperty("java.io.tmpdir")+"/"; @@ -591,10 +591,11 @@ public class ImportExportServiceTest extends AbstractLimaTest { // test import FileInputStream contentStream = null; + ImportResult result; try { contentStream = new FileInputStream(tmpDir + "export-entries-EBP.csv"); String inputStream = IOUtils.toString(contentStream); - importService.importEntriesFromEbp(inputStream).getImportResults().get(0); + result = importService.importEntriesFromEbp(inputStream).getImportResults().get(0); } finally { IOUtils.closeQuietly(contentStream); } @@ -603,22 +604,12 @@ public class ImportExportServiceTest extends AbstractLimaTest { financialTransactions = financialTransactionService.getAllFinancialTransactions(df.parse("April 4, 2012"),df.parse("December 31, 2012")); Assert.assertEquals(2, financialTransactions.size()); for (FinancialTransaction financialTransaction : financialTransactions) { - if (financialTransaction.getAmountDebit().compareTo(BigDecimal.valueOf(42.0)) == 0) { - Collection<Entry> voucherAEntries = financialTransaction.getEntry(); - Assert.assertEquals(2L, voucherAEntries.size()); - for (Entry entry : voucherAEntries) { - Assert.assertTrue(entry.getVoucher().contentEquals("voucherA")); - } - } else if (financialTransaction.getAmountDebit().compareTo(BigDecimal.valueOf(12.0)) == 0) { - Collection<Entry> voucherBEntries = financialTransaction.getEntry(); - Assert.assertEquals(3L, voucherBEntries.size()); - for (Entry entry : voucherBEntries) { - Assert.assertTrue(entry.getVoucher().contentEquals("voucherB")); - } - } else { - Assert.fail("Fail to import financial transactions"); - } + entries.addAll(financialTransaction.getEntry()); } + + Assert.assertEquals(nbEntities, entries.size()); + Assert.assertEquals(nbEntities, result.getNbCreated()); + Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); } protected void importEBPData() throws IOException, ParseException, BeginAfterEndFiscalPeriodException, -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm