Author: dcosse Date: 2014-08-06 13:53:01 +0200 (Wed, 06 Aug 2014) New Revision: 3900 Url: http://forge.chorem.org/projects/lima/repository/revisions/3900 Log: refs #1032 gestion des exceptions d'import Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoDataToImportException.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoFiscalPeriodFoundException.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotNumberAccountNumberException.java Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -48,9 +48,9 @@ * @param account new account * @throws LimaException if rule validation fails */ - void createAccountRules(Account account) throws InvalidAccountNumberException; + void createAccountRules(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel; - void updateAccountRules(Account account) throws InvalidAccountNumberException; + void updateAccountRules(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException; void removeAccountRules(Account account) throws UsedAccountException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -39,8 +39,10 @@ import org.chorem.lima.business.LockedFinancialPeriodException; import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException; import org.chorem.lima.business.NoEmptyFiscalPeriodException; +import org.chorem.lima.business.NotAllowedLabel; import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException; import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.business.UnbalancedEntriesException; import org.chorem.lima.business.UnbalancedFinancialTransactionsException; import org.chorem.lima.business.UnfilledEntriesException; @@ -94,16 +96,19 @@ * Rules to check before create accounts. */ @Override - public void createAccountRules(Account account) throws InvalidAccountNumberException { - + public void createAccountRules(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel { // Check if the numberaccount is not blank if (StringUtils.isBlank(account.getAccountNumber())) { throw new InvalidAccountNumberException(account.getAccountNumber()); } + if (account.getAccountNumber().contains("\\")){ + throw new NotAllowedLabel(account.getAccountNumber()); + } + } @Override - public void updateAccountRules(Account account) throws InvalidAccountNumberException { + public void updateAccountRules(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException { // Check if the numberaccount is not blank if (StringUtils.isBlank(account.getAccountNumber())) { throw new InvalidAccountNumberException(account.getAccountNumber()); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -34,8 +34,10 @@ import org.chorem.lima.business.LastUnlockedFiscalPeriodException; import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException; import org.chorem.lima.business.NoEmptyFiscalPeriodException; +import org.chorem.lima.business.NotAllowedLabel; import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException; import org.chorem.lima.business.NotLockedClosedPeriodicEntryBooksException; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.business.UnbalancedFinancialTransactionsException; import org.chorem.lima.business.UnfilledEntriesException; import org.chorem.lima.business.WithoutEntryBookFinancialTransactionsException; @@ -54,8 +56,6 @@ import java.util.Date; import java.util.List; -import static org.nuiton.i18n.I18n.t; - /** * Surcharge des regles par defaut pour application à la comptabilité française. * @@ -69,43 +69,30 @@ * Règles de vérification de la création du PCG, appliquées à la comptabilité française. */ @Override - public void createAccountRules(Account account) throws InvalidAccountNumberException { - super.createAccountRules(account); + public void createAccountRules(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel { - String accountNumber = account.getAccountNumber(); - - // ledger account must be located in 411 account - if (!StringUtils.isNumeric(accountNumber) && !accountNumber.startsWith("4")) { - log.warn(t("lima-business.franceaccountingrules.accountnumbernotnumeric", - account.getAccountNumber())); - throw new InvalidAccountNumberException(t("lima-business.franceaccountingrules.accountnumbernotnumeric", - account.getAccountNumber()), account.getAccountNumber()); - } - - // Check root account starts with 1 to 8 - if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) { - log.warn(t("lima-business.franceaccountingrules.accountstartnumbererror", - account.getAccountNumber())); - throw new InvalidAccountNumberException(t("lima-business.franceaccountingrules.accountstartnumbererror", - account.getAccountNumber()), account.getAccountNumber()); - } - + super.createAccountRules(account); + validFranceAccountingRules(account); } @Override - public void updateAccountRules(Account account) throws InvalidAccountNumberException { + public void updateAccountRules(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException { + super.updateAccountRules(account); + validFranceAccountingRules(account); + } + protected void validFranceAccountingRules(Account account) throws NotNumberAccountNumberException, InvalidAccountNumberException { String accountNumber = account.getAccountNumber(); - // Check if the number account is type numeric - if (!StringUtils.isNumeric(account.getAccountNumber())) { - throw new InvalidAccountNumberException(account.getAccountNumber()); + // ledger account must be located in 411 account + if (!StringUtils.isNumeric(accountNumber) && !accountNumber.startsWith("4")) { + throw new NotNumberAccountNumberException(account.getAccountNumber(), account.getAccountNumber()); } // Check root account starts with 1 to 8 if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) { - throw new InvalidAccountNumberException(account.getAccountNumber()); + throw new InvalidAccountNumberException(account.getAccountNumber(), account.getAccountNumber()); } } @@ -133,27 +120,24 @@ FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); - //Checks if is not the first fiscalperiod to create + // Checks if is not the first fiscal period to create if (fiscalPeriodTopiaDao.count() != 0) { FiscalPeriod lastFiscalPeriod = fiscalPeriodTopiaDao.getLastFiscalPeriod(); //check the new fiscal period adjoining the last Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate(); - dateLastFiscalPeriod = DateUtils. - addDays(dateLastFiscalPeriod, 1); - dateLastFiscalPeriod = DateUtils.truncate(dateLastFiscalPeriod, Calendar.DATE); - Date dateFiscalPeriod = fiscalPeriod.getBeginDate(); + Date newFiscalPeriodStartingDate = DateUtils.addDays(dateLastFiscalPeriod, 1); + newFiscalPeriodStartingDate = DateUtils.truncate(newFiscalPeriodStartingDate, Calendar.DATE); - if (dateLastFiscalPeriod.compareTo(dateFiscalPeriod) != 0) { + if (newFiscalPeriodStartingDate.compareTo(fiscalPeriod.getBeginDate()) != 0) { throw new NotBeginNextDayOfLastFiscalPeriodException(lastFiscalPeriod); } - //We can create a new fiscal period meantime the last fiscal period was not locked - //But not the ante periodfiscal - int unblockedFiscalPeriod = (int) fiscalPeriodTopiaDao.forLockedEquals(false).count(); - if (unblockedFiscalPeriod > 1) { - throw new MoreOneUnlockFiscalPeriodException(unblockedFiscalPeriod); + // No more than one unlocked fiscal period is allowed + long unblockedFiscalPeriod = fiscalPeriodTopiaDao.forLockedEquals(false).count(); + if (unblockedFiscalPeriod > 1L) { + throw new MoreOneUnlockFiscalPeriodException(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), fiscalPeriod.isLocked(), unblockedFiscalPeriod); } } @@ -191,11 +175,11 @@ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod) throws LastUnlockedFiscalPeriodException { FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); - FiscalPeriod oldestUnBlockedFiscalPeriod = + FiscalPeriod lastUnlockedFiscalPeriod = fiscalPeriodTopiaDao.getLastUnlockedFiscalPeriod(); //Check if the fiscal period to block is the oldest - if (oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)) { + if (lastUnlockedFiscalPeriod.equals(fiscalPeriod)) { throw new LastUnlockedFiscalPeriodException(fiscalPeriod); } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -31,6 +31,8 @@ import org.chorem.lima.business.InvalidAccountNumberException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.NotAllowedLabel; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.business.UsedAccountException; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.utils.AccountComparator; @@ -70,7 +72,7 @@ } @Override - public boolean createOrUbdateAccount(Account account) throws InvalidAccountNumberException { + public boolean createOrUbdateAccount(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel { // check if account number already exist AccountTopiaDao accountDao = getDaoHelper().getAccountDao(); @@ -92,7 +94,7 @@ * @throws LimaException */ @Override - public Account createAccount(Account account) throws AlreadyExistAccountException, InvalidAccountNumberException { + public Account createAccount(Account account) throws AlreadyExistAccountException, InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel { // check if account number already exist AccountTopiaDao accountDao = getDaoHelper().getAccountDao(); @@ -106,7 +108,7 @@ return result; } - protected Account createNewAccount(Account account) throws InvalidAccountNumberException { + protected Account createNewAccount(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel { // check rules before create the account AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules(); accountingRules.createAccountRules(account); @@ -215,7 +217,7 @@ * @throws InvalidAccountNumberException */ @Override - public Account updateAccount(Account account) throws InvalidAccountNumberException { + public Account updateAccount(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException { AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules(); @@ -224,7 +226,6 @@ Account originalAccount = accountDao.forAccountNumberEquals(account.getAccountNumber()).findUnique(); Binder<Account, Account> binder = BinderFactory.newBinder(Account.class, Account.class); binder.copy(account, originalAccount, Account.PROPERTY_LABEL, Account.PROPERTY_THIRD_PARTY); - //binder.copyExcluding(account, originalAccount, Account.PROPERTY_TOPIA_ID); accountingRules.updateAccountRules(originalAccount); Account result = accountDao.update(originalAccount); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -41,7 +41,9 @@ import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException; import org.chorem.lima.business.NoEmptyFiscalPeriodException; import org.chorem.lima.business.NoFoundFinancialPeriodException; +import org.chorem.lima.business.NotAllowedLabel; import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.business.api.FinancialPeriodService; @@ -294,14 +296,14 @@ LastUnlockedFiscalPeriodException, AlreadyLockedFiscalPeriodException, AlreadyExistAccountException, - InvalidAccountNumberException { + InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel { if (entryBook != null && retainedEarnings) { // re-attach entities to current session FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); - FiscalPeriod localFiscalPeriod = fiscalPeriodTopiaDao.findByTopiaId(fiscalPeriod.getTopiaId()); + FiscalPeriod localFiscalPeriod = fiscalPeriodTopiaDao.forTopiaIdEquals(fiscalPeriod.getTopiaId()).findUnique(); //if entrybook isn't found //then create it Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -32,7 +32,7 @@ import org.chorem.lima.business.AlreadyExistAccountException; import org.chorem.lima.business.AlreadyExistFinancialStatement; import org.chorem.lima.business.AlreadyExistVatStatement; -import org.chorem.lima.business.FiscalPeriodException; +import org.chorem.lima.business.BeginAfterEndFiscalPeriodException; import org.chorem.lima.business.ImportEbpException; import org.chorem.lima.business.ImportExportResults; import org.chorem.lima.business.ImportResult; @@ -40,7 +40,11 @@ import org.chorem.lima.business.LockedEntryBookException; import org.chorem.lima.business.LockedFinancialPeriodException; import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException; +import org.chorem.lima.business.NoDataToImportException; +import org.chorem.lima.business.NoFiscalPeriodFoundException; import org.chorem.lima.business.NotAllowedLabel; +import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.business.api.EntryService; @@ -143,27 +147,32 @@ ImportExportResults result = new ImportExportResults(); ImportResult importResult = result.createAddAndGetImportResult(Account.class); - InputStream contentStream = IOUtils.toInputStream(contents); - try { - ImportModel<Account> model = new AccountModel(); - Import<Account> accounts = Import.newImport(model, contentStream); - // csv line index - boolean updated; - for (Account account : accounts) { - try { - updated = accountService.createOrUbdateAccount(account); - if (updated) { - importResult.increaseUpdated(); - } else { - importResult.increaseCreated(); + if (StringUtils.isBlank(contents)) { + importResult.addException(new NoDataToImportException()); + } else { + InputStream contentStream = IOUtils.toInputStream(contents); + try { + ImportModel<Account> model = new AccountModel(); + Import<Account> accounts = Import.newImport(model, contentStream); + // csv line index + boolean updated; + for (Account account : accounts) { + try { + updated = accountService.createOrUbdateAccount(account); + if (updated) { + importResult.increaseUpdated(); + } else { + importResult.increaseCreated(); + } + } catch (InvalidAccountNumberException | NotNumberAccountNumberException | NotAllowedLabel e) { + importResult.addException(e); } - } catch (InvalidAccountNumberException e) { - importResult.addException(e); } + } finally { + IOUtils.closeQuietly(contentStream); } - } finally { - IOUtils.closeQuietly(contentStream); } + return result; } @@ -172,9 +181,11 @@ ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(EntryBook.class); - InputStream contentStream = IOUtils.toInputStream(contents); + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + InputStream contentStream = IOUtils.toInputStream(contents); - try { ImportModel<EntryBook> model = new EntryBookModel(); Import<EntryBook> entryBooks = Import.newImport(model, contentStream); @@ -186,7 +197,7 @@ result.increaseCreated(); } } - } finally { + IOUtils.closeQuietly(contentStream); } return results; @@ -197,25 +208,28 @@ ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(FiscalPeriod.class); - InputStream contentStream = IOUtils.toInputStream(contents); - try { - ImportModel<FiscalPeriod> model = new FiscalPeriodModel(); + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + InputStream contentStream = IOUtils.toInputStream(contents); + try { + ImportModel<FiscalPeriod> model = new FiscalPeriodModel(); - Import<FiscalPeriod> fiscalPeriods = Import.newImport(model, contentStream); + Import<FiscalPeriod> fiscalPeriods = Import.newImport(model, contentStream); - try { - for (FiscalPeriod fiscalPeriod : fiscalPeriods) { - fiscalPeriodService.createFiscalPeriod(fiscalPeriod); - result.increaseCreated(); + try { + for (FiscalPeriod fiscalPeriod : fiscalPeriods) { + fiscalPeriodService.createFiscalPeriod(fiscalPeriod); + result.increaseCreated(); + } + } catch (MoreOneUnlockFiscalPeriodException | BeginAfterEndFiscalPeriodException | NotBeginNextDayOfLastFiscalPeriodException e) { + result.addException(e); } - } catch (FiscalPeriodException e) { - result.addException(e); - } catch (MoreOneUnlockFiscalPeriodException e) { - result.increaseIgnored(); + } finally { + IOUtils.closeQuietly(contentStream); } - } finally { - IOUtils.closeQuietly(contentStream); } + return results; } @@ -223,24 +237,28 @@ ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(FinancialTransaction.class); - // import and save FinancialTransactions - InputStream contentStream = IOUtils.toInputStream(contents); - try { - ImportModel<FinancialTransaction> model = new FinancialTransactionModel(entryBookService); + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + // import and save FinancialTransactions + InputStream contentStream = IOUtils.toInputStream(contents); + try { + ImportModel<FinancialTransaction> model = new FinancialTransactionModel(entryBookService); - Import<FinancialTransaction> financialTransactions = Import.newImport(model, contentStream); + Import<FinancialTransaction> financialTransactions = Import.newImport(model, contentStream); - for (FinancialTransaction financialTransaction : financialTransactions) { - try { - financialTransactionService.createFinancialTransaction(financialTransaction); - result.increaseCreated(); - } catch (LockedFinancialPeriodException | LockedEntryBookException e) { - result.addException(e); + for (FinancialTransaction financialTransaction : financialTransactions) { + try { + financialTransactionService.createFinancialTransaction(financialTransaction); + result.increaseCreated(); + } catch (LockedFinancialPeriodException | LockedEntryBookException e) { + result.addException(e); + } } + + } finally { + IOUtils.closeQuietly(contentStream); } - - } finally { - IOUtils.closeQuietly(contentStream); } return results; } @@ -250,16 +268,17 @@ ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(Entry.class); - // import and save entries - InputStream contentStream = IOUtils.toInputStream(contents); - try { + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + // import and save entries + InputStream contentStream = IOUtils.toInputStream(contents); ImportModel<Entry> model = new EntryModel(accountService, financialTransactionService, false); Import<Entry> entries = Import.newImport(model, contentStream); for (Entry entry : entries) { entryService.createEntry(entry); result.increaseCreated(); } - } finally { IOUtils.closeQuietly(contentStream); } return results; @@ -269,10 +288,12 @@ ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(Identity.class); - // import and save identity - if (StringUtils.isNotBlank(contents)){ - InputStream contentStream = null; - try { + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + // import and save identity + if (StringUtils.isNotBlank(contents)){ + InputStream contentStream = null; contentStream = IOUtils.toInputStream(contents); ImportModel<Identity> model = new IdentityModel(); Import<Identity> identities = Import.newImport(model, contentStream); @@ -280,11 +301,9 @@ identityService.updateIdentity(identity); result.increaseCreated(); } - } finally { IOUtils.closeQuietly(contentStream); } } - return results; } @@ -331,103 +350,109 @@ ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(FinancialStatement.class); - // import and save FinancialTransactions - InputStream contentStream = IOUtils.toInputStream(contents); - try { - ImportModel<FinancialStatementImport> model = new FinancialStatementModel(); + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { - Import<FinancialStatementImport> financialStatementImports = Import.newImport(model, contentStream); + // import and save FinancialTransactions + InputStream contentStream = IOUtils.toInputStream(contents); + try { + ImportModel<FinancialStatementImport> model = new FinancialStatementModel(); - // path, FinancialStatement - Map<String, FinancialStatement> orderedFinancialStatements = new HashMap<>(); + Import<FinancialStatementImport> financialStatementImports = Import.newImport(model, contentStream); - List<FinancialStatement> rootFinancialStatements = financialStatementService.getRootFinancialStatements(); - for (FinancialStatement rootFinancialStatement : rootFinancialStatements) { - orderedFinancialStatements.put(rootFinancialStatement.getLabel(), rootFinancialStatement); - } + // path, FinancialStatement + Map<String, FinancialStatement> orderedFinancialStatements = new HashMap<>(); - for (FinancialStatementImport financialStatementBean : financialStatementImports) { - Binder<FinancialStatementImport, FinancialStatement> binder = BinderFactory.newBinder(FinancialStatementImport.class, FinancialStatement.class); - FinancialStatement financialStatement = financialStatementService.newFinancialStatement(); - binder.copyExcluding(financialStatementBean, financialStatement, FinancialStatement.PROPERTY_MASTER_FINANCIAL_STATEMENT); + List<FinancialStatement> rootFinancialStatements = financialStatementService.getRootFinancialStatements(); + for (FinancialStatement rootFinancialStatement : rootFinancialStatements) { + orderedFinancialStatements.put(rootFinancialStatement.getLabel(), rootFinancialStatement); + } - try{ - // full path to master - String masterPath = financialStatementBean.getMasterFinancialStatement(); + for (FinancialStatementImport financialStatementBean : financialStatementImports) { + Binder<FinancialStatementImport, FinancialStatement> binder = BinderFactory.newBinder(FinancialStatementImport.class, FinancialStatement.class); + FinancialStatement financialStatement = financialStatementService.newFinancialStatement(); + binder.copyExcluding(financialStatementBean, financialStatement, FinancialStatement.PROPERTY_MASTER_FINANCIAL_STATEMENT); - if (StringUtils.isBlank(masterPath)) { - // case of financialStatement is root - // look if root exists - // It can not have several FinancialStatement with the same from same path - FinancialStatement rootFinancialStatement = orderedFinancialStatements.get(financialStatementBean.getLabel()); + try{ + // full path to master + String masterPath = financialStatementBean.getMasterFinancialStatement(); - if (rootFinancialStatement == null) { - rootFinancialStatement = financialStatement; - rootFinancialStatement = financialStatementService.createFinancialStatement(null, rootFinancialStatement); + if (StringUtils.isBlank(masterPath)) { + // case of financialStatement is root + // look if root exists + // It can not have several FinancialStatement with the same from same path + FinancialStatement rootFinancialStatement = orderedFinancialStatements.get(financialStatementBean.getLabel()); + + if (rootFinancialStatement == null) { + rootFinancialStatement = financialStatement; + rootFinancialStatement = financialStatementService.createFinancialStatement(null, rootFinancialStatement); + } else { + // in case it exist (not ordered import and previously created) values are bind to the previously created one excepted + // the sub financial statements + Binder<FinancialStatement, FinancialStatement> rootBinder = BinderFactory.newBinder(FinancialStatement.class, FinancialStatement.class); + rootBinder.copyExcluding(financialStatement, rootFinancialStatement, FinancialStatement.PROPERTY_SUB_FINANCIAL_STATEMENTS); + } + orderedFinancialStatements.put(rootFinancialStatement.getLabel(), rootFinancialStatement); } else { - // in case it exist (not ordered import and previously created) values are bind to the previously created one excepted - // the sub financial statements - Binder<FinancialStatement, FinancialStatement> rootBinder = BinderFactory.newBinder(FinancialStatement.class, FinancialStatement.class); - rootBinder.copyExcluding(financialStatement, rootFinancialStatement, FinancialStatement.PROPERTY_SUB_FINANCIAL_STATEMENTS); - } - orderedFinancialStatements.put(rootFinancialStatement.getLabel(), rootFinancialStatement); - } else { - String[] masterNames = masterPath.split("/"); - String rootMasterName = masterNames[0]; + String[] masterNames = masterPath.split("/"); + String rootMasterName = masterNames[0]; - FinancialStatement rootFinancialStatement = orderedFinancialStatements.get(rootMasterName); + FinancialStatement rootFinancialStatement = orderedFinancialStatements.get(rootMasterName); - // case of not ordered import and subFinancialStatement is looking for it's master that has not been created yet - if (rootFinancialStatement == null) { - rootFinancialStatement = financialStatementService.newFinancialStatement(); - rootFinancialStatement.setLabel(rootMasterName); - rootFinancialStatement = financialStatementService.createFinancialStatement(null, rootFinancialStatement); - orderedFinancialStatements.put(rootMasterName, rootFinancialStatement); - } + // case of not ordered import and subFinancialStatement is looking for it's master that has not been created yet + if (rootFinancialStatement == null) { + rootFinancialStatement = financialStatementService.newFinancialStatement(); + rootFinancialStatement.setLabel(rootMasterName); + rootFinancialStatement = financialStatementService.createFinancialStatement(null, rootFinancialStatement); + orderedFinancialStatements.put(rootMasterName, rootFinancialStatement); + } - // explore branches to find the financialStatement's master one - FinancialStatement branchesFinancialStatement = rootFinancialStatement; - for (int i = 1; i < masterNames.length; i++) {// 0 is root - String masterName = masterNames[i]; - branchesFinancialStatement = returnFinancialStatement(branchesFinancialStatement, masterName); - } + // explore branches to find the financialStatement's master one + FinancialStatement branchesFinancialStatement = rootFinancialStatement; + for (int i = 1; i < masterNames.length; i++) {// 0 is root + String masterName = masterNames[i]; + branchesFinancialStatement = returnFinancialStatement(branchesFinancialStatement, masterName); + } - // in case it exist (not ordered import and previously created) values are bind to the previously created one excepted - // the sub financial statements - boolean alreadyCreated = false; - if (branchesFinancialStatement != null && branchesFinancialStatement.getSubFinancialStatements() != null) { - for (FinancialStatement bfs : branchesFinancialStatement.getSubFinancialStatements()) { - if (bfs.getLabel().equals(financialStatement.getLabel())){ - Binder<FinancialStatement, FinancialStatement> rootBinder = BinderFactory.newBinder(FinancialStatement.class, FinancialStatement.class); - rootBinder.copyExcluding(bfs, financialStatement, FinancialStatement.PROPERTY_SUB_FINANCIAL_STATEMENTS); - alreadyCreated = true; - break; + // in case it exist (not ordered import and previously created) values are bind to the previously created one excepted + // the sub financial statements + boolean alreadyCreated = false; + if (branchesFinancialStatement != null && branchesFinancialStatement.getSubFinancialStatements() != null) { + for (FinancialStatement bfs : branchesFinancialStatement.getSubFinancialStatements()) { + if (bfs.getLabel().equals(financialStatement.getLabel())){ + Binder<FinancialStatement, FinancialStatement> rootBinder = BinderFactory.newBinder(FinancialStatement.class, FinancialStatement.class); + rootBinder.copyExcluding(bfs, financialStatement, FinancialStatement.PROPERTY_SUB_FINANCIAL_STATEMENTS); + alreadyCreated = true; + break; + } } } - } - // if necessary financial statement is created - if (!alreadyCreated) { - // if the master finacial statement has been modified then the current one is replace by the new one. - financialStatement = financialStatementService.createFinancialStatement(branchesFinancialStatement, financialStatement); - FinancialStatement targetedRootFinancialStatement = returnRootFinancialStatement(financialStatement); + // if necessary financial statement is created + if (!alreadyCreated) { + // if the master finacial statement has been modified then the current one is replace by the new one. + financialStatement = financialStatementService.createFinancialStatement(branchesFinancialStatement, financialStatement); + FinancialStatement targetedRootFinancialStatement = returnRootFinancialStatement(financialStatement); - // replace modified root financial statement with new one - if (orderedFinancialStatements.get(targetedRootFinancialStatement.getLabel()) != null) { - orderedFinancialStatements.put(targetedRootFinancialStatement.getLabel(), targetedRootFinancialStatement); + // replace modified root financial statement with new one + if (orderedFinancialStatements.get(targetedRootFinancialStatement.getLabel()) != null) { + orderedFinancialStatements.put(targetedRootFinancialStatement.getLabel(), targetedRootFinancialStatement); + } } + } - + result.increaseCreated(); + } catch (AlreadyExistFinancialStatement | NotAllowedLabel e) { + result.addException(e); } - result.increaseCreated(); - } catch (AlreadyExistFinancialStatement | NotAllowedLabel e) { - result.addException(e); } + + } finally { + IOUtils.closeQuietly(contentStream); } + } - } finally { - IOUtils.closeQuietly(contentStream); - } return results; } @@ -474,102 +499,106 @@ ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(VatStatement.class); - // import and save VATStatements - InputStream contentStream = IOUtils.toInputStream(contents); - try { - ImportModel<VatStatementImport> model = new VatStatementModel(); + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + // import and save VATStatements + InputStream contentStream = IOUtils.toInputStream(contents); + try { + ImportModel<VatStatementImport> model = new VatStatementModel(); - Import<VatStatementImport> vatStatementImports = Import.newImport(model, contentStream); + Import<VatStatementImport> vatStatementImports = Import.newImport(model, contentStream); - // path, vatStatement - Map<String, VatStatement> orderedVATStatements = new HashMap<>(); + // path, vatStatement + Map<String, VatStatement> orderedVATStatements = new HashMap<>(); - List<VatStatement> rootVatStatements = vatStatementService.getRootVatStatements(); - for (VatStatement vatStatement : rootVatStatements) { - orderedVATStatements.put(vatStatement.getLabel(), vatStatement); - } + List<VatStatement> rootVatStatements = vatStatementService.getRootVatStatements(); + for (VatStatement vatStatement : rootVatStatements) { + orderedVATStatements.put(vatStatement.getLabel(), vatStatement); + } - for (VatStatementImport vatStatementBean : vatStatementImports) { - Binder<VatStatementImport, VatStatement> binder = BinderFactory.newBinder(VatStatementImport.class, VatStatement.class); - VatStatement vatStatement = vatStatementService.newVatStatement(); - binder.copyExcluding(vatStatementBean, vatStatement, VatStatement.PROPERTY_MASTER_VAT_STATEMENT); + for (VatStatementImport vatStatementBean : vatStatementImports) { + Binder<VatStatementImport, VatStatement> binder = BinderFactory.newBinder(VatStatementImport.class, VatStatement.class); + VatStatement vatStatement = vatStatementService.newVatStatement(); + binder.copyExcluding(vatStatementBean, vatStatement, VatStatement.PROPERTY_MASTER_VAT_STATEMENT); - try{ - // full path to master - String masterPath = vatStatementBean.getMasterVatStatement(); + try{ + // full path to master + String masterPath = vatStatementBean.getMasterVatStatement(); - if (StringUtils.isBlank(masterPath)) { - // case of vatStatement is root - // look if root exists - // It can not have several vatStatement with the same from same path - VatStatement rootVATStatement = orderedVATStatements.get(vatStatementBean.getLabel()); + if (StringUtils.isBlank(masterPath)) { + // case of vatStatement is root + // look if root exists + // It can not have several vatStatement with the same from same path + VatStatement rootVATStatement = orderedVATStatements.get(vatStatementBean.getLabel()); - if (rootVATStatement == null) { - rootVATStatement = vatStatement; - rootVATStatement = vatStatementService.createVatStatement(null, rootVATStatement); + if (rootVATStatement == null) { + rootVATStatement = vatStatement; + rootVATStatement = vatStatementService.createVatStatement(null, rootVATStatement); + } else { + // in case it exist (not ordered import and previously created) values are bind to the previously created one excepted + // the sub vatStatements + Binder<VatStatement, VatStatement> rootBinder = BinderFactory.newBinder(VatStatement.class, VatStatement.class); + rootBinder.copyExcluding(vatStatement, rootVATStatement, VatStatement.PROPERTY_SUB_VAT_STATEMENTS); + } + orderedVATStatements.put(rootVATStatement.getLabel(), rootVATStatement); } else { - // in case it exist (not ordered import and previously created) values are bind to the previously created one excepted - // the sub vatStatements - Binder<VatStatement, VatStatement> rootBinder = BinderFactory.newBinder(VatStatement.class, VatStatement.class); - rootBinder.copyExcluding(vatStatement, rootVATStatement, VatStatement.PROPERTY_SUB_VAT_STATEMENTS); - } - orderedVATStatements.put(rootVATStatement.getLabel(), rootVATStatement); - } else { - String[] masterNames = masterPath.split("/"); - String rootMasterName = masterNames[0]; + String[] masterNames = masterPath.split("/"); + String rootMasterName = masterNames[0]; - VatStatement rootVATStatement = orderedVATStatements.get(rootMasterName); + VatStatement rootVATStatement = orderedVATStatements.get(rootMasterName); - // case of not ordered import and subVATStatement is looking for it's master that has not been created yet - if (rootVATStatement == null) { - rootVATStatement = vatStatementService.newVatStatement(); - rootVATStatement.setLabel(rootMasterName); - rootVATStatement = vatStatementService.createVatStatement(null, rootVATStatement); - orderedVATStatements.put(rootMasterName, rootVATStatement); - } + // case of not ordered import and subVATStatement is looking for it's master that has not been created yet + if (rootVATStatement == null) { + rootVATStatement = vatStatementService.newVatStatement(); + rootVATStatement.setLabel(rootMasterName); + rootVATStatement = vatStatementService.createVatStatement(null, rootVATStatement); + orderedVATStatements.put(rootMasterName, rootVATStatement); + } - // explore branches to find the vatStatement's master one - VatStatement branchesVATStatement = rootVATStatement; - for (int i = 1; i < masterNames.length; i++) {// 0 is root - String masterName = masterNames[i]; - branchesVATStatement = returnVATStatement(branchesVATStatement, masterName); - } + // explore branches to find the vatStatement's master one + VatStatement branchesVATStatement = rootVATStatement; + for (int i = 1; i < masterNames.length; i++) {// 0 is root + String masterName = masterNames[i]; + branchesVATStatement = returnVATStatement(branchesVATStatement, masterName); + } - // in case it exist (not ordered import and previously created) values are bind to the previously created one excepted - // the sub vatStatements - boolean alreadyCreated = false; - if (branchesVATStatement != null && branchesVATStatement.getSubVatStatements() != null) { - for (VatStatement bfs : branchesVATStatement.getSubVatStatements()) { - if (bfs.getLabel().equals(vatStatement.getLabel())){ - Binder<VatStatement, VatStatement> rootBinder = BinderFactory.newBinder(VatStatement.class, VatStatement.class); - rootBinder.copyExcluding(bfs, vatStatement, VatStatement.PROPERTY_SUB_VAT_STATEMENTS); - alreadyCreated = true; - break; + // in case it exist (not ordered import and previously created) values are bind to the previously created one excepted + // the sub vatStatements + boolean alreadyCreated = false; + if (branchesVATStatement != null && branchesVATStatement.getSubVatStatements() != null) { + for (VatStatement bfs : branchesVATStatement.getSubVatStatements()) { + if (bfs.getLabel().equals(vatStatement.getLabel())){ + Binder<VatStatement, VatStatement> rootBinder = BinderFactory.newBinder(VatStatement.class, VatStatement.class); + rootBinder.copyExcluding(bfs, vatStatement, VatStatement.PROPERTY_SUB_VAT_STATEMENTS); + alreadyCreated = true; + break; + } } } - } - // if necessary vatStatement is created - if (!alreadyCreated) { - // if the master vatStatement has been modified then the current one is replace by the new one. - vatStatement = vatStatementService.createVatStatement(branchesVATStatement, vatStatement); - VatStatement targetedRootVATStatement = returnRootVATStatement(vatStatement); + // if necessary vatStatement is created + if (!alreadyCreated) { + // if the master vatStatement has been modified then the current one is replace by the new one. + vatStatement = vatStatementService.createVatStatement(branchesVATStatement, vatStatement); + VatStatement targetedRootVATStatement = returnRootVATStatement(vatStatement); - // replace modified root vatStatement with new one - if (orderedVATStatements.get(targetedRootVATStatement.getLabel()) != null) { - orderedVATStatements.put(targetedRootVATStatement.getLabel(), targetedRootVATStatement); + // replace modified root vatStatement with new one + if (orderedVATStatements.get(targetedRootVATStatement.getLabel()) != null) { + orderedVATStatements.put(targetedRootVATStatement.getLabel(), targetedRootVATStatement); + } } + } - + result.increaseCreated(); + } catch (AlreadyExistVatStatement | NotAllowedLabel e) { + result.addException(e); } - result.increaseCreated(); - } catch (AlreadyExistVatStatement | NotAllowedLabel e) { - result.addException(e); } + + } finally { + IOUtils.closeQuietly(contentStream); } - - } finally { - IOUtils.closeQuietly(contentStream); } return results; } @@ -590,60 +619,66 @@ @Override - public ImportExportResults importAccountFromEbp(String datas) { + public ImportExportResults importAccountFromEbp(String contents) { ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(Account.class); - ImportModel<Account> model = new AccountEBPModel(); + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + ImportModel<Account> model = new AccountEBPModel(); + InputStream contentStream = IOUtils.toInputStream(contents); + Import<Account> accounts = Import.newImport(model, contentStream); - InputStream contentStream = IOUtils.toInputStream(datas); - Import<Account> accounts = Import.newImport(model, contentStream); - - for (Account account : accounts) { - boolean updated = false; - try { - updated = accountService.createOrUbdateAccount(account); - } catch (InvalidAccountNumberException e) { - result.addException(e); + for (Account account : accounts) { + boolean updated = false; + try { + updated = accountService.createOrUbdateAccount(account); + } catch (InvalidAccountNumberException | NotNumberAccountNumberException | NotAllowedLabel e) { + result.addException(e); + } + if (updated) { + result.increaseUpdated(); + } else { + result.increaseCreated(); + } } - if (updated) { - result.increaseUpdated(); - } else { - result.increaseCreated(); - } } return results; } @Override - public ImportExportResults importEntryBookFromEbp(String datas) { + public ImportExportResults importEntryBookFromEbp(String contents) { ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(Account.class); - ImportModel<EntryBook> model = new EntryBookEBPModel(); + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + InputStream contentStream = IOUtils.toInputStream(contents); + ImportModel<EntryBook> model = new EntryBookEBPModel(); + Import<EntryBook> entryBooks = Import.newImport(model, contentStream); - InputStream contentStream = IOUtils.toInputStream(datas); - Import<EntryBook> entryBooks = Import.newImport(model, contentStream); - - for (EntryBook entryEBP : entryBooks) { - boolean updated = entryBookService.createOrUpdateEntryBook(entryEBP); - if (updated) { - result.increaseUpdated(); - } else { - result.increaseCreated(); + for (EntryBook entryEBP : entryBooks) { + boolean updated = entryBookService.createOrUpdateEntryBook(entryEBP); + if (updated) { + result.increaseUpdated(); + } else { + result.increaseCreated(); + } } } + return results; } - protected void basicEntriesFromEBPValidation(String datas, List<FiscalPeriod> fiscalPeriods) throws ImportEbpException { + protected void basicEntriesFromEBPValidation(String datas, List<FiscalPeriod> fiscalPeriods) throws NoDataToImportException, NoFiscalPeriodFoundException { if (datas.isEmpty()) { - throw new ImportEbpException(t("lima-business.import.ebpnoentry")); + throw new NoDataToImportException(); } // There are no valid fiscalPeriods -> exception if (fiscalPeriods.isEmpty()) { - throw new ImportEbpException( - t("lima-business.import.nofiscalperiodopen")); + throw new NoFiscalPeriodFoundException(); } } @@ -651,18 +686,15 @@ List<EntryEBP> result = new ArrayList<>(); InputStream contentStream = null; // convert file to bean - try { - contentStream = IOUtils.toInputStream(datas); - ImportModel<EntryEBP> model = new EntryEBPModel(); - Import<EntryEBP> importedEntryEBPs = Import.newImport(model, contentStream); - for (EntryEBP entryEBP : importedEntryEBPs) { - result.add(entryEBP); - } - // sort been by date - Collections.sort(result, new EntryEBPComparator()); - } finally { - IOUtils.closeQuietly(contentStream); + contentStream = IOUtils.toInputStream(datas); + ImportModel<EntryEBP> model = new EntryEBPModel(); + Import<EntryEBP> importedEntryEBPs = Import.newImport(model, contentStream); + for (EntryEBP entryEBP : importedEntryEBPs) { + result.add(entryEBP); } + // sort been by date + Collections.sort(result, new EntryEBPComparator()); + IOUtils.closeQuietly(contentStream); return result; } @@ -684,73 +716,77 @@ } @Override - public ImportExportResults importEntriesFromEbp(String datas) { + public ImportExportResults importEntriesFromEbp(String contents) { ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(Account.class); // use for logs long before = System.currentTimeMillis(); - // Get all the valid fiscalPeriods Ordered by date. - List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriodsByBeginDate(); - try { - basicEntriesFromEBPValidation(datas, fiscalPeriods); - } catch (ImportEbpException e) { - result.addException(e); - return results; - } + if (StringUtils.isBlank(contents)) { + result.addException(new NoDataToImportException()); + } else { + // Get all the valid fiscalPeriods Ordered by date. + List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriodsByBeginDate(); + try { + basicEntriesFromEBPValidation(contents, fiscalPeriods); + } catch (NoFiscalPeriodFoundException | NoDataToImportException e) { + result.addException(e); + } - List<Account> accounts = accountService.getAllAccounts(); - accounts = accounts == null ? new ArrayList<Account>() : accounts; - Map<String, Account> indexedAccounts = Maps.newHashMap(Maps.uniqueIndex(accounts, GET_ACCOUNT_NUMBER)); + List<Account> accounts = accountService.getAllAccounts(); + accounts = accounts == null ? new ArrayList<Account>() : accounts; + Map<String, Account> indexedAccounts = Maps.newHashMap(Maps.uniqueIndex(accounts, GET_ACCOUNT_NUMBER)); - List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); - entryBooks = entryBooks == null ? new ArrayList<EntryBook>() : entryBooks; - Map<String, EntryBook> indexedEntryBooks = Maps.newHashMap(Maps.uniqueIndex(entryBooks, GET_ENTRY_BOOK_CODE)); + List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); + entryBooks = entryBooks == null ? new ArrayList<EntryBook>() : entryBooks; + Map<String, EntryBook> indexedEntryBooks = Maps.newHashMap(Maps.uniqueIndex(entryBooks, GET_ENTRY_BOOK_CODE)); - List<EntryEBP> entryEBPs = loadDateOrderedEntryEBPbeans(datas); + List<EntryEBP> entryEBPs = loadDateOrderedEntryEBPbeans(contents); - // For all entries loaded from the file - // 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 fiscalPeriodsEndingDate = fiscalPeriods.get(fiscalPeriods.size() - 1).getEndDate(); - Map<EntryBook, Map<Date, FinancialTransaction>> entryBookFinancialTransactionByDate = getEntryBookFinancialTransactionOrderedByDate(fiscalPeriodsBiginDate, fiscalPeriodsEndingDate); + // For all entries loaded from the file + // 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 fiscalPeriodsEndingDate = fiscalPeriods.get(fiscalPeriods.size() - 1).getEndDate(); + Map<EntryBook, Map<Date, FinancialTransaction>> entryBookFinancialTransactionByDate = getEntryBookFinancialTransactionOrderedByDate(fiscalPeriodsBiginDate, fiscalPeriodsEndingDate); - for (EntryEBP entryEBP : entryEBPs) { - Date dateEcr = entryEBP.getDatEcr(); + for (EntryEBP entryEBP : entryEBPs) { + Date dateEcr = entryEBP.getDatEcr(); - // account loading - Account account = indexedAccounts.get(entryEBP.getCompte()); + // account loading + Account account = indexedAccounts.get(entryEBP.getCompte()); - if (!validEntry(result, dateEcr, fiscalPeriodsBiginDate, fiscalPeriodsEndingDate, account, entryEBP.getCompte())) { - continue; - } - // create entry - else { - // creation of the entry - // initialisation of this attributs - Entry entry = createEntry(entryEBP, account); + if (!validEntry(result, dateEcr, fiscalPeriodsBiginDate, fiscalPeriodsEndingDate, account, entryEBP.getCompte())) { + continue; + } + // create entry + else { + // creation of the entry + // initialisation of this attributs + Entry entry = createEntry(entryEBP, account); - try { - // find financial transactions for entry period and entrybook - addEntryToFinancialTransaction(entry, entryEBP.getJournal(), indexedEntryBooks, entryBookFinancialTransactionByDate, dateEcr); + try { + // find financial transactions for entry period and entrybook + addEntryToFinancialTransaction(entry, entryEBP.getJournal(), indexedEntryBooks, entryBookFinancialTransactionByDate, dateEcr); - } catch (LockedFinancialPeriodException | LockedEntryBookException e) { - result.addException(e); - continue; + } catch (LockedFinancialPeriodException | LockedEntryBookException e) { + result.addException(e); + continue; + } + } + result.increaseCreated(); + } + if (log.isInfoEnabled()) { + long after = System.currentTimeMillis(); + log.info("Imported form EBP : " + entryEBPs.size() + " entries in " + + (after - before) + " ms"); } - result.increaseCreated(); } - if (log.isInfoEnabled()) { - long after = System.currentTimeMillis(); - log.info("Imported form EBP : " + entryEBPs.size() + " entries in " - + (after - before) + " ms"); - } return results; } Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -87,7 +87,7 @@ //But not the ante periodfiscal int unblockedFiscalPeriod = fiscalPeriodDAO.forLockedEquals(false).findAll().size(); if (unblockedFiscalPeriod > 1) { - throw new MoreOneUnlockFiscalPeriodException(unblockedFiscalPeriod); + throw new MoreOneUnlockFiscalPeriodException(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), fiscalPeriod.isLocked(), unblockedFiscalPeriod); } } Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -47,7 +47,7 @@ nbCreated = 0; nbUpdated = 0; nbIgnored = 0; - lineIndex = 0; + lineIndex = 2;// line 1 s header this.fromSource = fromSource; } Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/MoreOneUnlockFiscalPeriodException.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -22,23 +22,39 @@ * #L% */ +import java.util.Date; + /** * @author Sylvain Bavencoff <bavencoff@codelutin.com> */ public class MoreOneUnlockFiscalPeriodException extends LimaException { - int countUnlockFiscalPeriod; + Date beginDate; + Date endDate; + Boolean isLocked; + long countUnlockFiscalPeriod; - public MoreOneUnlockFiscalPeriodException(int countUnlockFiscalPeriod) { + public MoreOneUnlockFiscalPeriodException(Date beginDate, Date endDate, Boolean isLocked, long countUnlockFiscalPeriod) { + this.beginDate = beginDate; + this.endDate = endDate; + this.isLocked = isLocked; this.countUnlockFiscalPeriod = countUnlockFiscalPeriod; + } - public MoreOneUnlockFiscalPeriodException(int countUnlockFiscalPeriod, Throwable cause) { - super(cause); - this.countUnlockFiscalPeriod = countUnlockFiscalPeriod; + public Date getBeginDate() { + return beginDate; } - public int getCountUnlockFiscalPeriod() { + public Date getEndDate() { + return endDate; + } + + public Boolean getIsLocked() { + return isLocked; + } + + public long getCountUnlockFiscalPeriod() { return countUnlockFiscalPeriod; } } Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoDataToImportException.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoDataToImportException.java (rev 0) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoDataToImportException.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -0,0 +1,7 @@ +package org.chorem.lima.business; + +/** + * Created by davidcosse on 06/08/14. + */ +public class NoDataToImportException extends LimaException { +} Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoFiscalPeriodFoundException.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoFiscalPeriodFoundException.java (rev 0) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NoFiscalPeriodFoundException.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -0,0 +1,7 @@ +package org.chorem.lima.business; + +/** + * Created by davidcosse on 06/08/14. + */ +public class NoFiscalPeriodFoundException extends LimaException { +} Copied: trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotNumberAccountNumberException.java (from rev 3897, trunk/lima-business-api/src/main/java/org/chorem/lima/business/InvalidAccountNumberException.java) =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotNumberAccountNumberException.java (rev 0) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotNumberAccountNumberException.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -0,0 +1,19 @@ +package org.chorem.lima.business; + +/** + * @author Sylvain Bavencoff <bavencoff@codelutin.com> + */ +public class NotNumberAccountNumberException extends AccountException { + + public NotNumberAccountNumberException(String accountNumber) { + super(accountNumber); + } + + public NotNumberAccountNumberException(String accountNumber, String message) { + super(accountNumber, message); + } + + public NotNumberAccountNumberException(String accountNumber, Throwable cause) { + super(accountNumber, cause); + } +} Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/AccountService.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -28,6 +28,8 @@ import org.chorem.lima.business.AlreadyExistAccountException; import org.chorem.lima.business.InvalidAccountNumberException; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.NotAllowedLabel; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.business.UsedAccountException; import org.chorem.lima.entity.Account; @@ -92,7 +94,7 @@ * @return true if updated or false if created * @throws InvalidAccountNumberException */ - boolean createOrUbdateAccount(Account account) throws InvalidAccountNumberException; + boolean createOrUbdateAccount(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel; /** * Create new account. If {@code masterAccount} is not null, {@code account} @@ -101,9 +103,9 @@ * @param account account * @throws LimaException */ - Account createAccount(Account account) throws AlreadyExistAccountException, InvalidAccountNumberException; + Account createAccount(Account account) throws AlreadyExistAccountException, InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel; - Account updateAccount(Account account) throws InvalidAccountNumberException; + Account updateAccount(Account account) throws InvalidAccountNumberException, NotNumberAccountNumberException; void removeAccount(Account account) throws UsedAccountException; Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -35,7 +35,9 @@ import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException; import org.chorem.lima.business.NoEmptyFiscalPeriodException; import org.chorem.lima.business.NoFoundFinancialPeriodException; +import org.chorem.lima.business.NotAllowedLabel; import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FiscalPeriod; @@ -88,7 +90,7 @@ LastUnlockedFiscalPeriodException, AlreadyLockedFiscalPeriodException, AlreadyExistAccountException, - InvalidAccountNumberException; + InvalidAccountNumberException, NotNumberAccountNumberException, NotAllowedLabel; /** * Test if we have retained earnings on a fiscal period Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -30,6 +30,8 @@ import org.chorem.lima.LimaConfig; import org.chorem.lima.business.AlreadyExistAccountException; import org.chorem.lima.business.InvalidAccountNumberException; +import org.chorem.lima.business.NotAllowedLabel; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.UsedAccountException; import org.chorem.lima.business.api.AccountService; @@ -275,6 +277,10 @@ errorHelper.showErrorMessage(t("lima.ui.account.add.error.alreadyExist", e.getAccountNumber())); } catch (InvalidAccountNumberException e) { errorHelper.showErrorMessage(t("lima.ui.account.add.error.InvalidAccountNumber", e.getAccountNumber())); + } catch (NotNumberAccountNumberException e) { + errorHelper.showErrorMessage(t("lima.fiscalPeriod.franceAccountingRules.notNumberAccountNumberException", e.getAccountNumber())); + } catch (NotAllowedLabel e) { + errorHelper.showErrorMessage(t("lima.all.notAllowedLabel", e.getLabel())); } finally { dialog.dispose(); } @@ -381,6 +387,8 @@ } catch (InvalidAccountNumberException e) { errorHelper.showErrorMessage(t("lima.ui.account.update.error.invalidAccountNumber", e.getAccountNumber())); + } catch (NotNumberAccountNumberException e) { + errorHelper.showErrorMessage(t("lima.fiscalPeriod.franceAccountingRules.notNumberAccountNumberException", e.getAccountNumber())); } finally { // close dialog dialog.dispose(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-08-06 11:53:01 UTC (rev 3900) @@ -33,10 +33,22 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.ImportBackupException; import org.chorem.lima.LimaTechnicalException; +import org.chorem.lima.business.AlreadyExistFinancialStatement; +import org.chorem.lima.business.AlreadyExistVatStatement; +import org.chorem.lima.business.BeginAfterEndFiscalPeriodException; import org.chorem.lima.business.ExportResult; import org.chorem.lima.business.ImportExportResults; import org.chorem.lima.business.ImportResult; +import org.chorem.lima.business.InvalidAccountNumberException; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.LockedEntryBookException; +import org.chorem.lima.business.LockedFinancialPeriodException; +import org.chorem.lima.business.MoreOneUnlockFiscalPeriodException; +import org.chorem.lima.business.NoDataToImportException; +import org.chorem.lima.business.NoFiscalPeriodFoundException; +import org.chorem.lima.business.NotAllowedLabel; +import org.chorem.lima.business.NotBeginNextDayOfLastFiscalPeriodException; +import org.chorem.lima.business.NotNumberAccountNumberException; import org.chorem.lima.business.api.ExportService; import org.chorem.lima.business.api.ImportService; import org.chorem.lima.entity.Account; @@ -65,6 +77,7 @@ import java.nio.charset.Charset; import java.rmi.server.ExportException; import java.text.SimpleDateFormat; +import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; @@ -262,13 +275,18 @@ log.debug(importedEntity + " nbCreated: " + result.getNbCreated()); log.debug(importedEntity + " nbUpdated: " + result.getNbUpdated()); log.debug(importedEntity + " nbIgnored: " + result.getNbIgnored()); + Collection<LimaException> exceptions = result.getAllExceptionsByLine().values(); + for (LimaException exception : exceptions) { + log.warn(exception.getCause()); + log.warn(exception.getStackTrace()); + } } } if (log.isDebugEnabled()) { log.debug("import.terminated"); } - String message = ""; + String message = t("lima.ui.importexport.import.terminated")+"\n"; for (ImportResult result : resultList) { Class fromSource = result.getFromSource(); message += "Import " + getFromSourceMessage(fromSource); @@ -276,18 +294,7 @@ message += t("lima.ui.importexport.import.nbUpdated", result.getNbUpdated())+"\n"; message += t("lima.ui.importexport.import.nbIgnored", result.getNbIgnored())+"\n"; Map<Integer, LimaException> exceptionsByLine = result.getAllExceptionsByLine(); - if (exceptionsByLine != null) { - Set<Integer> lines = exceptionsByLine.keySet(); - for (Integer line : lines) { - LimaException importException = exceptionsByLine.get(line); - message += t("lima.ui.importexport.import.exceptions", (line +1))+"\n"; - // TODO DCossé 05/08/14 display reason - //message += t("lima.ui.importexport.import.exceptions.reason", importException.getMessage()) +"\n"; - if (log.isErrorEnabled()) { - log.error(importException.getMessage()); - } - } - } + message = displayErrorMessage(message, exceptionsByLine); message +="\n"; } @@ -345,6 +352,48 @@ } } + private String displayErrorMessage(String message, Map<Integer, LimaException> exceptionsByLine) { + if (exceptionsByLine != null) { + Set<Integer> lines = exceptionsByLine.keySet(); + for (Integer line : lines) { + LimaException importException = exceptionsByLine.get(line); + message += t("lima.ui.importexport.import.ligne", line); + if (importException instanceof InvalidAccountNumberException) { + message += t("lima.fiscalPeriod.franceAccountingRules.invalidAccountNumberException", ((InvalidAccountNumberException) importException).getAccountNumber())+"\n"; + } else if (importException instanceof NotNumberAccountNumberException) { + message += t("lima.fiscalPeriod.franceAccountingRules.notNumberAccountNumberException", ((NotNumberAccountNumberException) importException).getAccountNumber())+"\n"; + } else if (importException instanceof NotAllowedLabel) { + message += t("lima.all.NotAllowedLabel", ((NotAllowedLabel) importException).getLabel())+"\n"; + } else if (importException instanceof MoreOneUnlockFiscalPeriodException) { + message += t("lima.fiscalPeriod.franceAccountingRules.moreOneUnlockFiscalPeriodException", ((MoreOneUnlockFiscalPeriodException) importException).getBeginDate(), ((MoreOneUnlockFiscalPeriodException) importException).getEndDate())+"\n"; + } else if (importException instanceof BeginAfterEndFiscalPeriodException) { + message += t("lima.fiscalPeriod.defaultAccountingRules.beginAfterEndFiscalPeriodException", ((BeginAfterEndFiscalPeriodException) importException).getFiscalPeriod().getBeginDate(), ((BeginAfterEndFiscalPeriodException) importException).getFiscalPeriod().getEndDate())+"\n"; + } else if (importException instanceof NotBeginNextDayOfLastFiscalPeriodException) { + message += t("lima.fiscalPeriod.franceAccountingRules.notBeginNextDayOfLastFiscalPeriodException", ((NotBeginNextDayOfLastFiscalPeriodException) importException).getFiscalPeriod().getBeginDate(), ((NotBeginNextDayOfLastFiscalPeriodException) importException).getFiscalPeriod().getEndDate())+"\n"; + } else if (importException instanceof LockedFinancialPeriodException) { + message += t("lima.financialTransaction.lockedFinancialPeriodException")+"\n"; + } else if (importException instanceof LockedEntryBookException) { + message += t("lima.financialTransaction.lockedEntryBookException", ((LockedEntryBookException) importException).getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(), ((LockedEntryBookException) importException).getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate())+"\n"; + } else if (importException instanceof AlreadyExistFinancialStatement) { + message += t("lima.financialStatement.alreadyExistFinancialStatement", ((AlreadyExistFinancialStatement) importException).getFinancialStatementLabel())+"\n"; + } else if (importException instanceof AlreadyExistVatStatement) { + message += t("lima.vatStatement.alreadyExistVatStatement", ((AlreadyExistVatStatement) importException).getVatStatementLabel())+"\n"; + } else if (importException instanceof NoFiscalPeriodFoundException) { + message += t("lima.import.entries.noFiscalPeriodFoundException")+"\n"; + } else if (importException instanceof NoDataToImportException) { + message += t("lima.import.noDataToImportException")+"\n"; + } else { + + } + //message += t("lima.ui.importexport.import.exceptions", (line))+"\n"; + if (log.isErrorEnabled()) { + log.error(importException.getMessage()); + } + } + } + return message; + } + private String getFromSourceMessage(Class fromSource) { String message; if (fromSource.equals(Account.class)){ Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-08-06 11:53:01 UTC (rev 3900) @@ -17,6 +17,8 @@ lima.accounts.plan= lima.accountsreports.listerror=Can't get entries list lima.action.commandline.help=Show help in console +lima.all.NotAllowedLabel= +lima.all.notAllowedLabel=Not allowed char "\\" found in account name %s. lima.balance.documentcreationerror=Enable to create document lima.balance.documentcreationfiscalerror=Can't create document on an open fiscal year lima.balance.listerror=Can't get entries list @@ -49,6 +51,8 @@ lima.charts.vatstatement.nothing=No vat statement chart lima.charts.vatstatement.question.remove=Do you really want to delete this line ? lima.charts.vatstatement.shortened=Shortened vat statement chart +lima.closedPeriodicEntryBook.franceAccountingRules.unbalancedFinancialTransactionsException=Fiscal Period has unbalanced transactions. +lima.closedPeriodicEntryBook.franceAccountingRules.withoutEntryBookFinancialTransactionsException=Can't block financialperiod / missing EntryBook in transactions lima.common.account=Account lima.common.amount=Amount lima.common.amountcredit=Credit amount @@ -250,10 +254,13 @@ lima.filter.letter= lima.filter.voucher= lima.financialPeriods= +lima.financialStatement.alreadyExistFinancialStatement=FAILED \: The financial statement %s already exists \! lima.financialStatements= lima.financialStatements.check= lima.financialStatements.check.nothing= lima.financialStatements.check.warn= +lima.financialTransaction.lockedEntryBookException=Entry can not be added as entry book is locked for period from %1$tm/%1$te/%1$tY to %1$tm/%1$te/%1$tY. +lima.financialTransaction.lockedFinancialPeriodException=locked financial transaction lima.financialstatement.accounts=Account list on debit and on credit lima.financialstatement.addfinancialStatementHeadererror=Can't add financialStatementHeader lima.financialstatement.check=Check accounts passing to movement @@ -268,6 +275,13 @@ lima.financialstatement.provisiondeprecationaccounts=Provisions and deprecations accounts list lima.financialstatement.subamount=Calculate a subamount lima.financialstatementreport.listerror=Can't get entries list +lima.fiscalPeriod.defaultAccountingRules.beginAfterEndFiscalPeriodException=Fiscal period ending date must be after the begining one, begin\: %1$tm/%1$te/%1$tY end\: %1$tm/%1$te/%1$tY. +lima.fiscalPeriod.franceAccountingRules.invalidAccountNumberException=Master account is not a digit between 1 to 8 \: %s" + account.getAccountNumber() +lima.fiscalPeriod.franceAccountingRules.lastUnlockedFiscalPeriodException=Current fiscal period must not be closed. +lima.fiscalPeriod.franceAccountingRules.moreOneUnlockFiscalPeriodException=The ante fiscal period is not locked\: concerned fiscal period from %1$tm/%1$te/%1$tY to %1$tm/%1$te/%1$tY. +lima.fiscalPeriod.franceAccountingRules.noEmptyFiscalPeriodException=The fiscal period is not empty \! +lima.fiscalPeriod.franceAccountingRules.notBeginNextDayOfLastFiscalPeriodException=The new fiscal period must adjoining the last\: concerned fiscal period from %1$tm/%1$te/%1$tY to %1$tm/%1$te/%1$tY. +lima.fiscalPeriod.franceAccountingRules.notNumberAccountNumberException=Account Number that doesn't start with 4 have to be numeric\: %s" + account.getAccountNumber() lima.fiscalYears= lima.fiscalperiod.unbalancedtransactions=Fiscal Period has unbalanced transactions lima.help= @@ -343,6 +357,9 @@ lima.identity.phoneNumber=Phone number lima.identity.vatNumber=VAT number lima.identity.zipCode=Zip code +lima.import.entries.noFiscalPeriodFoundException=No fiscal period found. +lima.import.noDataToImportException=No data to import. +lima.import.unknownError=Unknown error. lima.importexport.all= lima.importexport.choiceencoding= lima.importexport.csv= @@ -598,9 +615,7 @@ lima.ui.importexport.fiscalPeriod=Fiscal periods import completed. lima.ui.importexport.identity=Identity import completed. lima.ui.importexport.import= -lima.ui.importexport.import.exception= -lima.ui.importexport.import.exceptions=The line %d could not be imported. -lima.ui.importexport.import.exceptions.reason=Reason\:% +lima.ui.importexport.import.ligne=Line %d lima.ui.importexport.import.nbCreated=%d created lima.ui.importexport.import.nbIgnored=%d ignored lima.ui.importexport.import.nbUpdated=%d updated @@ -655,6 +670,7 @@ lima.ui.table.cell.comportmentEditingCell= lima.ui.table.cell.selectAllEditingCell= lima.ui.vatStatements= +lima.vatStatement.alreadyExistVatStatement=FAILED \: The vatStatement %s already exists \! lima.vatStatements= lima.vatreport.listerror=Can't get entries list lima.vatstatement.accounts=List of accounts Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-08-06 11:52:03 UTC (rev 3899) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-08-06 11:53:01 UTC (rev 3900) @@ -6,6 +6,8 @@ lima.accounts.plan=Plan comptable lima.accountsreports.listerror=Erreur lors de la récupération des données de la liste lima.action.commandline.help=Afficher l'aide en console +lima.all.NotAllowedLabel= +lima.all.notAllowedLabel=Le caractère "\\" n'est pas authorisé, trouvé sur le compte %s. lima.balance.documentcreationerror=Erreur lors de la création du document lima.balance.documentcreationfiscalerror=Impossible de créer le document quand la période fiscale est ouverte lima.balance.listerror=Erreur lors de la récupération des données de la liste @@ -38,6 +40,8 @@ lima.charts.vatstatement.nothing=<html><center>Aucun plan TVA chargé<br/>Veuillez sélectionner un plan par défaut, <br/>importer un plan personnalisé<br/> ou annuler pour créer votre propre plan.</center></html> lima.charts.vatstatement.question.remove=Etes vous sur de vouloir supprimer cette ligne ? lima.charts.vatstatement.shortened=Plan TVA abrégé +lima.closedPeriodicEntryBook.franceAccountingRules.unbalancedFinancialTransactionsException=Impossible de bloquer la période financière / le journal, il contient des transactions non équilibrées. +lima.closedPeriodicEntryBook.franceAccountingRules.withoutEntryBookFinancialTransactionsException=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY) lima.common.account=Compte lima.common.amount=Montant lima.common.amountcredit=Total Crédit @@ -233,10 +237,13 @@ lima.filter.letter=Ajouter un filtre sur les lettres lima.filter.voucher=Ajouter un filtre sur les pièces comptables lima.financialPeriods=Périodes comptables +lima.financialStatement.alreadyExistFinancialStatement=u00C9chec \: Le mouvement %s exist déjà \! lima.financialStatements=Plan BCR lima.financialStatements.check=Vérification des comptes aux postes lima.financialStatements.check.nothing=Introuvable \: %s - %s \n lima.financialStatements.check.warn=Attention cette fonctionnalité n'est qu'une aide utilisateur.\n Certains comptes ne doivent pas être présent au bilan et compte de résultat.\n Il est donc normal que des comptes sont marqués comme introuvable.\n\n +lima.financialTransaction.lockedEntryBookException=Impossible d'ajouter une entré car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY. +lima.financialTransaction.lockedFinancialPeriodException=La période financière est bloquée lima.financialstatement.accounts=Liste de comptes au crédit et au débit lima.financialstatement.addfinancialStatementHeadererror=Erreur lors de l'ajout de l'entête sur la déclaration financière lima.financialstatement.check= @@ -251,6 +258,13 @@ lima.financialstatement.provisiondeprecationaccounts=Liste de comptes d'amortissement et provisions lima.financialstatement.subamount=Calculer un sous-total lima.financialstatementreport.listerror=Erreur lors de la récupération des données de la liste +lima.fiscalPeriod.defaultAccountingRules.beginAfterEndFiscalPeriodException=La date de début doit être avant la date de fin, debut\: %1$te/%1$tm/%1$tY fin\: %1$te/%1$tm/%1$tY. +lima.fiscalPeriod.franceAccountingRules.invalidAccountNumberException=Le numéro du compte général n'est pas compris entre 1 et 8 \: %s +lima.fiscalPeriod.franceAccountingRules.lastUnlockedFiscalPeriodException=Impossible de clore la dernière période fiscale ouverte. +lima.fiscalPeriod.franceAccountingRules.moreOneUnlockFiscalPeriodException=Le nombre maximal d'exercices ouverts est déjà ateint\: periode fiscale concernée du %1$te/%1$tm/%1$tY au %1$te/%1$tm/%1$tY. +lima.fiscalPeriod.franceAccountingRules.noEmptyFiscalPeriodException=La période fiscale à supprimer n'est pas vide \! +lima.fiscalPeriod.franceAccountingRules.notBeginNextDayOfLastFiscalPeriodException=La nouvelle période fiscale doit suivre la précédente\: periode fiscale concernée du %1$te/%1$tm/%1$tY au %1$te/%1$tm/%1$tY. +lima.fiscalPeriod.franceAccountingRules.notNumberAccountNumberException=Un numéro de compte ne commençant pas par 4 doit être numérique \: %s lima.fiscalYears=Exercices lima.fiscalperiod.unbalancedtransactions=La période fiscale contient des transactions non équilibrées lima.help=Aide @@ -301,6 +315,9 @@ lima.identity.phoneNumber=n° Tel lima.identity.vatNumber=n° TVA lima.identity.zipCode=Code Postal +lima.import.entries.noFiscalPeriodFoundException=Aucune periode fiscale trouvée. +lima.import.noDataToImportException=Aucune donnée à importer. +lima.import.unknownError=Erreur inconnue. lima.importexport.all=Tout lima.importexport.choiceencoding=Choix de l'encodage lima.importexport.csv=Import/Export CSV @@ -517,8 +534,7 @@ lima.ui.importexport.identity=de l'identité terminé. lima.ui.importexport.import=Importer lima.ui.importexport.import.action=Import -lima.ui.importexport.import.exceptions=La ligne %d n'a pu être impotée. -lima.ui.importexport.import.exceptions.reason=Raison\: +lima.ui.importexport.import.ligne=Ligne %d lima.ui.importexport.import.nbCreated=%d créés lima.ui.importexport.import.nbIgnored=%d ignorés lima.ui.importexport.import.nbUpdated=%d mis à jours @@ -567,6 +583,7 @@ lima.ui.opening.title=Initialisation lima.ui.opening.welcome=<html><center>Bienvenue dans Lima<br/>Laissez vous guider par cet assistant pour démarrer votre comptabilité en quelques instants <br/>Ou bien importer directement une ancienne sauvegarde de LIMA au format CSV<br/><br/><br/><br/></center></html> lima.ui.retainedEarnings.wait=Report à nouveaux... +lima.vatStatement.alreadyExistVatStatement=u00C9chec \: Le plan %s exist déjà \! lima.vatStatements=Plan TVA lima.vatreport.listerror=Erreur lors de la récupération des données de la liste lima.vatstatement.accounts=Liste des comptes