This is an automated email from the git hooks/post-receive script. New commit to branch feature/1298-FixNPE in repository lima. See http://git.chorem.org/lima.git commit 3f7ad97368ea7551173140c5e9a7b28b6a4efcb4 Author: dcosse <cosse@codelutin.com> Date: Thu Sep 24 14:46:52 2015 +0200 refs #1298 corrige NPE dans le cas ou aucune donnée existe --- .../lima/business/ejb/AccountServiceImpl.java | 9 ++++---- .../FinancialTransactionViewHandler.java | 27 +++++++++++++++------- .../FiscalControlExportViewHandler.java | 2 +- .../resources/i18n/lima-swing_en_GB.properties | 1 + .../resources/i18n/lima-swing_fr_FR.properties | 1 + 5 files changed, 27 insertions(+), 13 deletions(-) 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 29055f7..b19619f 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 @@ -298,10 +298,11 @@ public class AccountServiceImpl extends AbstractLimaService implements AccountSe @Override public Account findAccountById(String accountId) { - - AccountTopiaDao accountDao = getDaoHelper().getAccountDao(); - Account account = accountDao.forTopiaIdEquals(accountId).findUniqueOrNull(); - + Account account = null; + if (StringUtils.isNotBlank(accountId)) { + AccountTopiaDao accountDao = getDaoHelper().getAccountDao(); + account = accountDao.forTopiaIdEquals(accountId).findUniqueOrNull(); + } return account; } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java index c4b7466..ed8e0a4 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java @@ -38,6 +38,7 @@ import org.chorem.lima.business.exceptions.AfterLastFiscalPeriodException; import org.chorem.lima.business.exceptions.BeforeFirstFiscalPeriodException; import org.chorem.lima.business.exceptions.LockedEntryBookException; import org.chorem.lima.business.exceptions.LockedFinancialPeriodException; +import org.chorem.lima.business.exceptions.NoFiscalPeriodFoundException; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryImpl; @@ -478,7 +479,7 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo table.changeSelection(index, 1, false, false); table.requestFocus(); table.scrollRowToVisible(Math.max(0, index - 5)); - table.scrollRowToVisible(Math.min(tableModel.size() -1 , index + transaction.sizeEntry() + 5)); + table.scrollRowToVisible(Math.min(tableModel.size() - 1, index + transaction.sizeEntry() + 5)); } catch (LockedFinancialPeriodException e) { errorHelper.showErrorMessage(t("lima.entries.paste.transaction.error.lockedFinancialPeriod", e.getFinancialPeriod().getBeginDate(), @@ -495,6 +496,8 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo e.getClosedPeriodicEntryBook().getEntryBook().getLabel(), e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(), e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate())); + } catch (NoFiscalPeriodFoundException e) { + errorHelper.showErrorMessage(t("lima.entries.add.transaction.error.noFiscalPeriodExistException")); } } } @@ -604,6 +607,8 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo e.getClosedPeriodicEntryBook().getEntryBook().getLabel(), e.getClosedPeriodicEntryBook().getFinancialPeriod().getBeginDate(), e.getClosedPeriodicEntryBook().getFinancialPeriod().getEndDate())); + } catch (NoFiscalPeriodFoundException e) { + errorHelper.showErrorMessage(t("lima.entries.add.transaction.error.noFiscalPeriodExistException")); } } @@ -983,18 +988,24 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo } } - public Date getUseDate() { + public Date getUseDate() throws NoFiscalPeriodFoundException { FinancialPeriod financialPeriod = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem(); - Date beginDate = financialPeriod.getBeginDate(); - Date endDate = financialPeriod.getEndDate(); - if (lastAssignDate == null - || lastAssignDate.before(beginDate) - || lastAssignDate.after(endDate) ) { - lastAssignDate = beginDate; + if (financialPeriod != null) { + Date beginDate = financialPeriod.getBeginDate(); + Date endDate = financialPeriod.getEndDate(); + + if (lastAssignDate == null + || lastAssignDate.before(beginDate) + || lastAssignDate.after(endDate) ) { + lastAssignDate = beginDate; + } + } else { + throw new NoFiscalPeriodFoundException(); } + return lastAssignDate; } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalControlExport/FiscalControlExportViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalControlExport/FiscalControlExportViewHandler.java index f5b892f..4bcca2a 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalControlExport/FiscalControlExportViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalControlExport/FiscalControlExportViewHandler.java @@ -92,7 +92,7 @@ public class FiscalControlExportViewHandler { List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); view.getEntryBookAtNewComboBoxModel().setObjects(entryBooks); Identity identity = identityService.getIdentity(); - view.getSirenWarnLabel().setVisible(StringUtils.isBlank(identity.getBusinessNumber())); + view.getSirenWarnLabel().setVisible(identity != null && StringUtils.isBlank(identity.getBusinessNumber())); } public void export() { diff --git a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties index 1bfb522..c9fc584 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties @@ -525,3 +525,4 @@ lima.vatStatement.remove.title=Remove line ? lima.vatStatement.shortened=Shortened vat statement chart lima.vatStatements=VAT statements lima.wait=Work in progress +lima.entries.add.transaction.error.noFiscalPeriodExistException=No fiscal period exist ! \ No newline at end of file diff --git a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties index 54a9304..50e7d3b 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties @@ -530,3 +530,4 @@ lima.vatStatement.remove.title=supprimer de ligne ? lima.vatStatement.shortened=Abrégé lima.vatStatements=Plan TVA lima.wait=Traitement en cours +lima.entries.add.transaction.error.noFiscalPeriodExistException=Aucun exercice de créer ! \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.