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 from 4775428 refs #1174 Correction sur affichage des résultats d'import dans le cas ou il n'y a pas eu d'erreur new 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 new 187f651 refs #1174 suppression de l'exception de la signature de la méthode new eb4e038 refs #1174 Rollback Changes, les résultats ne sont pas satifaisant au regard de la balance de référence The 3 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 eb4e038e358fa0f4b4149259d584a86afbca0978 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 187f6511c734f190c9869c8807caa22dace97ea1 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 e9e58f9c2a94d76091541a77b16aeb78fe29cb35 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 Summary of changes: .../org/chorem/lima/business/AccountingRules.java | 3 +- .../accountingrules/DefaultAccountingRules.java | 6 +- .../lima/business/ejb/AccountServiceImpl.java | 4 ++ .../lima/business/ejb/ImportServiceImpl.java | 84 ++++++---------------- .../lima/business/ImportExportServiceTest.java | 32 ++++----- 5 files changed, 43 insertions(+), 86 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 e9e58f9c2a94d76091541a77b16aeb78fe29cb35 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 --- .../main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java | 4 ++++ 2 files changed, 4 insertions(+), 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 98a9a33..96e98d1 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()); } 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 df767a4..07c62ce 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 -- 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 187f6511c734f190c9869c8807caa22dace97ea1 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 96e98d1..993c31b 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 eb4e038e358fa0f4b4149259d584a86afbca0978 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 | 32 ++++----- 2 files changed, 37 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 2aa826e..e16a87f 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; @@ -993,7 +992,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(); @@ -1012,7 +1011,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); @@ -1056,68 +1055,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 @@ -1135,24 +1100,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 757599f..97b562f 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 @@ -46,6 +46,7 @@ import org.chorem.lima.entity.FiscalPeriodImpl; import org.chorem.lima.entity.Identity; import org.chorem.lima.entity.IdentityImpl; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import java.io.BufferedWriter; @@ -55,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; @@ -564,6 +564,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")+"/"; @@ -589,10 +590,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); } @@ -601,22 +603,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, @@ -678,4 +670,10 @@ public class ImportExportServiceTest extends AbstractLimaTest { Assert.assertNotNull(compteTiers); Assert.assertNotNull(employeAccount); } + + @Test + @Ignore + public void getLimaTestDefaultConfFilename() { + context.showCreateSchema(); + } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm