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 bde81288585be9c20472a785e35282967a76a3af 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 | 28 +++++++++++++++------- .../FiscalControlExportViewHandler.java | 2 +- .../resources/i18n/lima-swing_en_GB.properties | 1 + .../resources/i18n/lima-swing_fr_FR.properties | 1 + 5 files changed, 28 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 2ad6138..78b66f0 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; @@ -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")); } } @@ -987,20 +992,27 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo * * @return the last edited transaction, if none the selected transaction date, if none the begin date. */ - protected 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) ) { + if (financialPeriod != null) { + Date beginDate = financialPeriod.getBeginDate(); + Date endDate = financialPeriod.getEndDate(); - FinancialTransaction selectedTransaction = getSelectedFinancialTransaction(); - lastAssignDate = selectedTransaction == null ? beginDate : selectedTransaction.getTransactionDate(); + if (lastAssignDate == null + || lastAssignDate.before(beginDate) + || lastAssignDate.after(endDate) ) { + + FinancialTransaction selectedTransaction = getSelectedFinancialTransaction(); + lastAssignDate = selectedTransaction == null ? beginDate : selectedTransaction.getTransactionDate(); + } + + } 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>.