branch feature/1293-addAccountViewerTab updated (7898a89 -> a383d34)
This is an automated email from the git hooks/post-receive script. New change to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git discards 7898a89 refs #1293 correction de merge discards ee5abac refs #1293 correction traductions discards e137b42 refs #1268 déplacement de donnés liées au model de l'handler au model et suppression de listener innutils discards 59ea9a6 refs #1268 déplacement des models du jaxx au handler discards 7ceeed6 refs #1293 Correction i18n discards a2e5011 refs #1293 corrige exception dans le cas ou aucune periode financière existe avec la date choisie discards 9f4bbb3 refs #1293 corrections pour le cas ou aucune données existe dans Lima discards 27350cb refs #1293 corrections et refactoring discards 0885bc3 refs #1293 refactoring et modification du calcul du sold précédent à l'année fiscale discards f6b8fc9 refs #1293 modification concernnt l'affichage des infos résumées discards 7b3c5c4 refs #1293 correction i18n discards 367ef5f refs #1293 Ajout de la possibilité de choisir une consultation de compte pour un exercice, une période financière ou un interval de dates discards d746f2e refs #1293 refactoring, modification de style discards 147c7cf refs #1293 Traduction des dates pickers discards 45b2d0c refs #1293 Correction sur les dates pickers et la recherche de compte appliquée égallement à l'onglet Lettering discards da320f5 refs #1293 Correction d'une exception survenant si un nom de compte est saisie est que aucun compte ne correspond discards df5f528 refs #1293 la validation des dates des date pickers est possible au Tab discards b5244af refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) discards 67b47c2 refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) + Ajout d'icones discards a859874 refs #1241 Ajout d'un oglet consultation de compte, travail en cours adds 4fe0543 montée de version mineur de libs adds 3c9b729 Mise à jour fichiers de licences adds 234f3ac Mise à jour fichiers de licences adds 1c09d51 Migration sur gitlab + utilisation chorempom 5-rc-2 adds 205012d refs #1182 valeur de clef de traduction manquante adds ce75d95 refs #1158 Il est de nouveau possible de créer une transaction sur une periode ou un exercice non clos adds 2bbb45e Merge branch 'feature/1158-Corriger-le-comportement-d-ajout-de-transaction' into develop new 747bd28 refs #1241 Ajout d'un oglet consultation de compte, travail en cours new fe9ed6b refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) + Ajout d'icones new 25f8c7c refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) new f66d9ad refs #1293 la validation des dates des date pickers est possible au Tab new 22f84a3 refs #1293 Correction d'une exception survenant si un nom de compte est saisie est que aucun compte ne correspond new 02e31e2 refs #1293 Correction sur les dates pickers et la recherche de compte appliquée égallement à l'onglet Lettering new 4bf2d82 refs #1293 Traduction des dates pickers new fd114e2 refs #1293 refactoring, modification de style new e5bd1d9 refs #1293 Ajout de la possibilité de choisir une consultation de compte pour un exercice, une période financière ou un interval de dates new 397fdb3 refs #1293 correction i18n new 754b9ae refs #1293 modification concernnt l'affichage des infos résumées new e2bbeb7 refs #1293 refactoring et modification du calcul du sold précédent à l'année fiscale new 94833f1 refs #1293 corrections et refactoring new 8373b34 refs #1293 corrections pour le cas ou aucune données existe dans Lima new 8ac5089 refs #1293 corrige exception dans le cas ou aucune periode financière existe avec la date choisie new 6b7523e refs #1293 Correction i18n new 358093c refs #1268 déplacement des models du jaxx au handler new 7824a86 refs #1268 déplacement de donnés liées au model de l'handler au model et suppression de listener innutils new 21a91b5 refs #1293 correction traductions new a383d34 refs #1293 correction de merge This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (7898a89) \ N -- N -- N refs/heads/feature/1293-addAccountViewerTab (a383d34) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omits" are not gone; other references still refer to them. Any revisions marked "discards" are gone forever. The 20 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit a383d34f0a1142d74b97e75f8ad363087d796b45 Author: dcosse <cosse@codelutin.com> Date: Mon Nov 30 16:06:14 2015 +0100 refs #1293 correction de merge commit 21a91b5fc02617d25eaecb9fe29428bdc0d8e58c Author: dcosse <cosse@codelutin.com> Date: Mon Nov 30 14:13:39 2015 +0100 refs #1293 correction traductions commit 7824a86c725617cd2db11fa6caed3b64ec91310a Author: dcosse <cosse@codelutin.com> Date: Wed Sep 30 15:30:48 2015 +0200 refs #1268 déplacement de donnés liées au model de l'handler au model et suppression de listener innutils commit 358093cc17895cd3dfd9aae8dca31d33743e7b07 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 30 14:49:39 2015 +0200 refs #1268 déplacement des models du jaxx au handler commit 6b7523e723a1bd264e043b84b5bcabdf65a0e591 Author: dcosse <cosse@codelutin.com> Date: Fri Sep 25 13:08:29 2015 +0200 refs #1293 Correction i18n commit 8ac5089a81041bf740453bcdca499227acd61e0d Author: dcosse <cosse@codelutin.com> Date: Fri Sep 25 13:05:56 2015 +0200 refs #1293 corrige exception dans le cas ou aucune periode financière existe avec la date choisie commit 8373b3460d6f4d3da372ed7a005e8e6b5fdbdad9 Author: dcosse <cosse@codelutin.com> Date: Thu Sep 24 14:19:40 2015 +0200 refs #1293 corrections pour le cas ou aucune données existe dans Lima commit 94833f16f8726df63a24abf9703799def4e28a2c Author: dcosse <cosse@codelutin.com> Date: Thu Sep 24 12:54:04 2015 +0200 refs #1293 corrections et refactoring commit e2bbeb7daca042477bb1b8136fb52e2067ba1f12 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 23 22:05:15 2015 +0200 refs #1293 refactoring et modification du calcul du sold précédent à l'année fiscale commit 754b9ae84e41668e2392e2fcb21abb878f149106 Author: dcosse <cosse@codelutin.com> Date: Tue Sep 22 17:58:13 2015 +0200 refs #1293 modification concernnt l'affichage des infos résumées commit 397fdb36c23d6c371f7198eb4036ea8ce66d7577 Author: dcosse <cosse@codelutin.com> Date: Sun Sep 20 00:49:12 2015 +0200 refs #1293 correction i18n commit e5bd1d96303a655ba46310d52eaae2212465f4d4 Author: dcosse <cosse@codelutin.com> Date: Sun Sep 20 00:38:53 2015 +0200 refs #1293 Ajout de la possibilité de choisir une consultation de compte pour un exercice, une période financière ou un interval de dates commit fd114e2f65c4d9984b1c457d16aeaf194841a3d3 Author: dcosse <cosse@codelutin.com> Date: Fri Sep 18 10:27:41 2015 +0200 refs #1293 refactoring, modification de style commit 4bf2d8247fb2939c65ad0d8aa6d5d02c8ccc69f8 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 16 22:11:13 2015 +0200 refs #1293 Traduction des dates pickers commit 02e31e252941a6254f6f60fec48879f5e6bc63bd Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 17:18:09 2015 +0200 refs #1293 Correction sur les dates pickers et la recherche de compte appliquée égallement à l'onglet Lettering commit 22f84a3829936fce05e3e93afeb47d195096fd09 Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 16:59:42 2015 +0200 refs #1293 Correction d'une exception survenant si un nom de compte est saisie est que aucun compte ne correspond commit f66d9ad9debbe23962602c929db31a53755b2c46 Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 16:57:35 2015 +0200 refs #1293 la validation des dates des date pickers est possible au Tab commit 25f8c7c63e5421b32e78cdaf99c08a3fecb92eb4 Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 15:56:35 2015 +0200 refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) commit fe9ed6b58d23d450baa0adc8700da467c923102a Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 15:14:19 2015 +0200 refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) + Ajout d'icones commit 747bd2832f8a68f7ded06b7474b2c42b9ed36a84 Author: dcosse <cosse@codelutin.com> Date: Mon Sep 14 18:30:15 2015 +0200 refs #1241 Ajout d'un oglet consultation de compte, travail en cours Summary of changes: lima-swing/src/license/THIRD-PARTY.properties | 6 ++-- .../FinancialTransactionViewHandler.java | 15 +++++++- .../resources/i18n/lima-swing_fr_FR.properties | 2 +- pom.xml | 41 +++++++--------------- src/site/site.xml | 14 ++++++-- 5 files changed, 42 insertions(+), 36 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 747bd2832f8a68f7ded06b7474b2c42b9ed36a84 Author: dcosse <cosse@codelutin.com> Date: Mon Sep 14 18:30:15 2015 +0200 refs #1241 Ajout d'un oglet consultation de compte, travail en cours --- .../business/api/FinancialTransactionService.java | 16 + .../lima/business/api/FiscalPeriodService.java | 8 + .../ejb/FinancialTransactionServiceImpl.java | 16 +- .../lima/business/ejb/FiscalPeriodServiceImpl.java | 10 + .../java/org/chorem/lima/entity/EntryTopiaDao.java | 42 ++ .../chorem/lima/entity/FiscalPeriodTopiaDao.java | 20 + .../src/main/java/org/chorem/lima/ui/MainView.css | 5 + .../src/main/java/org/chorem/lima/ui/MainView.jaxx | 2 + .../java/org/chorem/lima/ui/MainViewHandler.java | 8 + .../AccountViewerEditModel.java} | 111 ++-- .../accountViewer/AccountViewerSelectionModel.java | 158 ++++++ .../lima/ui/accountViewer/AccountViewerTable.java | 42 ++ .../ui/accountViewer/AccountViewerTableModel.java | 144 +++++ .../lima/ui/accountViewer/AccountViewerView.css | 73 +++ .../lima/ui/accountViewer/AccountViewerView.jaxx | 94 ++++ .../ui/accountViewer/AccountViewerViewHandler.java | 588 +++++++++++++++++++++ .../lima/ui/lettering/LetteringEditModel.java | 2 +- .../lima/ui/lettering/LetteringViewHandler.java | 63 +-- .../resources/i18n/lima-swing_en_GB.properties | 4 + .../resources/i18n/lima-swing_fr_FR.properties | 3 + 20 files changed, 1319 insertions(+), 90 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java index d46ef99..d653bc8 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java @@ -133,6 +133,22 @@ public interface FinancialTransactionService { List<Entry> getAllUnlockEntriesByFilter(LetteringFilter filter); /** + * Retourne la somme des débits credits des entrées associées à une action pour une prériode définie + * La période est défine entre DateStart inclus et DateEnd exclus + * @param filter sur le filter doit être définie la période et le compte cible. + * @return + */ + List<Object[]> getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(LetteringFilter filter); + + /** + * Retourne la somme des débits credits des entrées associées à une action pour une prériode définie + * La période est défine entre DateStart inclus et DateEnd inclus + * @param filter sur le filter doit être définie la période et le compte cible. + * @return + */ + List<Object[]> getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(LetteringFilter filter); + + /** * Retourne la dernière entrée d'une transaction * @param financialTransaction transaction sur laquelle la derniere entree est selectionnee * */ diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java index 2ce8af4..4e0c812 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java @@ -44,6 +44,7 @@ import org.chorem.lima.business.exceptions.WithoutEntryBookFinancialTransactions import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FiscalPeriod; +import java.util.Date; import java.util.List; /** @@ -141,4 +142,11 @@ public interface FiscalPeriodService { */ FiscalPeriod updateEndDate(FiscalPeriod fiscalPeriod); + /** + * Return the FiscalPeriod for the given date + * + * @param date fiscal period for this given date + * @return the FiscalPeriod for {@code date} + */ + FiscalPeriod getFiscalPeriodForDate(Date date); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java index 9dedbfb..71f5d0d 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java @@ -414,7 +414,7 @@ public class FinancialTransactionServiceImpl extends AbstractLimaService impleme public List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod financialPeriod, EntryBook entryBook) { List<FinancialTransaction> financialTransactions; - // ici + FinancialTransactionTopiaDao transactionTopiaDao = getDaoHelper().getFinancialTransactionDao(); if (entryBook != null) { @@ -486,6 +486,20 @@ public class FinancialTransactionServiceImpl extends AbstractLimaService impleme } @Override + public List<Object[]> getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(LetteringFilter filter) { + EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); + List<Object[]> result = entryTopiaDao.getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(filter); + return result; + } + + @Override + public List<Object[]> getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(LetteringFilter filter) { + EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); + List<Object[]> result = entryTopiaDao.getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(filter); + return result; + } + + @Override public Entry getLastEntry(FinancialTransaction financialTransaction) { EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java index 64b2346..40504d6 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java @@ -524,4 +524,14 @@ public class FiscalPeriodServiceImpl extends AbstractLimaService implements Fisc fiscalPeriodTopiaDao.delete(localFiscalPeriod); } + + @Override + public FiscalPeriod getFiscalPeriodForDate(Date date) { + + FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); + //get the last fiscal period + FiscalPeriod result = fiscalPeriodTopiaDao.findForDate(date); + + return result; + } } diff --git a/lima-business/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java b/lima-business/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java index 9f5aeef..4f23613 100644 --- a/lima-business/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java +++ b/lima-business/src/main/java/org/chorem/lima/entity/EntryTopiaDao.java @@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.LetteringFilter; import org.nuiton.topia.persistence.HqlAndParametersBuilder; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -298,6 +299,47 @@ public class EntryTopiaDao extends AbstractEntryTopiaDao<Entry> { return result; } + public List<Object[]> getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(LetteringFilter filter) { + List<Object[]> result; + if (filter != null) { + result = getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(filter.getAccount(), filter.getDateStart(), filter.getDateEnd(), false); + } else { + result = new ArrayList<>(); + } + return result; + } + + public List<Object[]> getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(LetteringFilter filter) { + List<Object[]> result; + if (filter != null) { + result = getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(filter.getAccount(), filter.getDateStart(), filter.getDateEnd(), true); + } else { + result = new ArrayList<>(); + } + return result; + } + + protected List<Object[]> getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(Account account, Date beginDate, Date endDate, boolean includeEndDate) { + + HqlAndParametersBuilder<Entry> builder = newHqlAndParametersBuilder(); + builder.addGreaterOrEquals(PROPERTY_TRANSACTION_DATE, beginDate); + builder.addEquals(Entry.PROPERTY_ACCOUNT, account); + + if (includeEndDate) { + builder.addLowerOrEquals(PROPERTY_TRANSACTION_DATE, endDate); + } else { + builder.addLowerThan(PROPERTY_TRANSACTION_DATE, endDate); + } + + String query = "SELECT " + builder.getAlias() + "." + Entry.PROPERTY_DEBIT + ", " + + "SUM(" + builder.getAlias() + "." + Entry.PROPERTY_AMOUNT + ") " + + builder.getHql() + + " GROUP BY " + builder.getAlias() + "." + Entry.PROPERTY_DEBIT ; + + List<Object[]> result = findAll(query, builder.getHqlParameters()); + return result; + } + public List<Entry> getAllEntriesByDatesForEntryBook(EntryBook entryBook, Date beginDate, Date endDate) { HqlAndParametersBuilder<Entry> builder = newHqlAndParametersBuilder(); diff --git a/lima-business/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java b/lima-business/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java index 25777aa..d413ec7 100644 --- a/lima-business/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java +++ b/lima-business/src/main/java/org/chorem/lima/entity/FiscalPeriodTopiaDao.java @@ -22,6 +22,10 @@ package org.chorem.lima.entity; +import org.nuiton.topia.persistence.HqlAndParametersBuilder; + +import java.util.Date; + /** * Fiscal period entity DAO. * @@ -73,4 +77,20 @@ public class FiscalPeriodTopiaDao extends AbstractFiscalPeriodTopiaDao<FiscalPer return result; } + + /** + * Return the FiscalPeriod for the given date + * + * @param date fiscal period for this given date + * @return the FiscalPeriod for {@code date} + */ + public FiscalPeriod findForDate(Date date) { + + HqlAndParametersBuilder<FiscalPeriod> builder = newHqlAndParametersBuilder(); + builder.addLowerOrEquals(FiscalPeriod.PROPERTY_BEGIN_DATE, date); + builder.addGreaterOrEquals(FiscalPeriod.PROPERTY_END_DATE, date); + + FiscalPeriod fiscalPeriod = findUniqueOrNull(builder.getHql(), builder.getHqlParameters()); + return fiscalPeriod; + } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css index dbf81c5..177cf8b 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css @@ -236,6 +236,11 @@ actionIcon : "lettering"; } +#accountViewer { + text : "lima.entries.accountViewer"; + actionIcon : "lettering"; +} + #help { text : "lima.help"; mnemonic : "H"; diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx index 0363a97..5203d08 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx @@ -144,6 +144,8 @@ onActionPerformed="getHandler().showTransactionSearchView(this)"/> <JMenuItem id="lettering" onActionPerformed="getHandler().showLetteringView(this)"/> + <JMenuItem id="accountViewer" + onActionPerformed="getHandler().showAccountViewerView(this)"/> </JMenu> <JMenu id="help"> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java index 01e22b2..91d18ba 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java @@ -34,6 +34,7 @@ import org.chorem.lima.business.LimaServiceFactory; import org.chorem.lima.business.api.OptionsService; import org.chorem.lima.enums.ImportExportEnum; import org.chorem.lima.ui.account.AccountView; +import org.chorem.lima.ui.accountViewer.AccountViewerView; import org.chorem.lima.ui.celleditor.NumberSeparatorCellRenderer; import org.chorem.lima.ui.celleditor.NumberSeparatorTableCellRenderer; import org.chorem.lima.ui.entrybook.EntryBookView; @@ -495,6 +496,13 @@ public class MainViewHandler { swingSession.add(letteringView); } + public void showAccountViewerView(JAXXContext rootContext) { + MainView mainView = getUI(rootContext); + AccountViewerView accountViewerView = new AccountViewerView(mainView); + showTab(mainView, t("lima.entries.accountViewer"), accountViewerView); + swingSession.add(accountViewerView); + } + public void showImportExportView(JAXXContext rootContext, ImportExportEnum type) { MainView mainView = getUI(rootContext); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java similarity index 61% copy from lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java copy to lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java index ddb2448..0c9b98c 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java @@ -19,19 +19,18 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -package org.chorem.lima.ui.lettering; +package org.chorem.lima.ui.accountViewer; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.Serializable; import java.math.BigDecimal; +import java.util.Date; /** * @author sletellier <letellier@codelutin.com> */ -public class LetteringEditModel implements Serializable { - - public static final String PROPERTY_EDITABLE = "editable"; +public class AccountViewerEditModel implements Serializable { public static final String PROPERTY_DEBIT = "debit"; @@ -39,26 +38,29 @@ public class LetteringEditModel implements Serializable { public static final String PROPERTY_SOLD = "sold"; - public static final String PROPERTY_LETTERED = "lettered"; + public static final String PROPERTY_GLOBAL_SOLD = "globalSold"; + + public static final String PROPERTY_LETTRED = "lettred"; - public static final String PROPERTY_UNLETTERED = "unLettered"; + public static final String PROPERTY_UNLETTRED = "unLettred"; public static final String PROPERTY_EQUALIZED = "equalized"; protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); - protected LetteringTableModel model; - protected boolean lettered; - protected boolean unLettered; + protected AccountViewerTableModel model; + protected boolean lettred; + protected boolean unLettred; protected boolean equalized; - protected boolean editable; protected BigDecimal debit = BigDecimal.ZERO; protected BigDecimal credit = BigDecimal.ZERO; protected BigDecimal sold = BigDecimal.ZERO; - protected BigDecimal tableDebit = BigDecimal.ZERO; - protected BigDecimal tableCredit = BigDecimal.ZERO; - protected BigDecimal tableSold = BigDecimal.ZERO; + protected BigDecimal globalDebit = BigDecimal.ZERO; + protected BigDecimal globalCredit = BigDecimal.ZERO; + protected BigDecimal globalSold = BigDecimal.ZERO; + + protected Date fiscalPeriodBeginDate; public boolean isEqualized() { return equalized; @@ -70,24 +72,24 @@ public class LetteringEditModel implements Serializable { firePropertyChange(PROPERTY_EQUALIZED, oldEqualized, this.equalized); } - public boolean isLettered() { - return lettered; + public boolean isLettred() { + return lettred; } - - public void setLettered(boolean lettered) { - boolean oldLettrer = isLettered(); - this.lettered = lettered && (BigDecimal.ZERO.equals(sold) || sold.doubleValue() == 0) && lettered; - firePropertyChange(PROPERTY_LETTERED, oldLettrer, this.lettered); + + public void setLettred(boolean lettered) { + boolean oldLetter = isLettred(); + this.lettred = lettered && (BigDecimal.ZERO.equals(sold) || sold.doubleValue() == 0); + firePropertyChange(PROPERTY_LETTRED, oldLetter, this.lettred); } - public boolean isUnLettered() { - return unLettered; + public boolean isUnLettred() { + return unLettred; } - public void setUnLettered(boolean unLettered) { - boolean oldDeletterer = isUnLettered(); - this.unLettered = unLettered; - firePropertyChange(PROPERTY_UNLETTERED, oldDeletterer, this.unLettered); + public void setUnLettred(boolean unLettred) { + boolean oldDeleter = isUnLettred(); + this.unLettred = unLettred; + firePropertyChange(PROPERTY_UNLETTRED, oldDeleter, this.unLettred); } public BigDecimal getDebit() { @@ -99,7 +101,7 @@ public class LetteringEditModel implements Serializable { if (!BigDecimal.ZERO.equals(debit)){ this.debit = debit.add(oldDebit); - } else { + }else{ this.debit = BigDecimal.ZERO; } @@ -115,7 +117,7 @@ public class LetteringEditModel implements Serializable { if (!BigDecimal.ZERO.equals(credit)){ this.credit = credit.add(oldCredit); - } else { + }else{ this.credit=BigDecimal.ZERO; } @@ -126,50 +128,47 @@ public class LetteringEditModel implements Serializable { return sold; } - public void setSold(BigDecimal solde, boolean credit) { + public void setSold(BigDecimal sold, boolean credit) { BigDecimal oldSold = getSold(); - if (!BigDecimal.ZERO.equals(solde)){ + if (!BigDecimal.ZERO.equals(sold)){ if (credit){ - this.sold = oldSold.subtract(solde); - } else { - this.sold = oldSold.add(solde); + this.sold = oldSold.subtract(sold); + }else{ + this.sold = oldSold.add(sold); } - } else { + }else{ this.sold =BigDecimal.ZERO; } firePropertyChange(PROPERTY_SOLD, oldSold, this.sold); } - public BigDecimal getTableDebit() { - return tableDebit; + public BigDecimal getGlobalSold() { + return globalSold; } - public void setTableDebit(BigDecimal tableDebit) { - this.tableDebit = tableDebit; - } + public void setGlobalSold(BigDecimal globalSold) { + BigDecimal oldSold = getGlobalSold(); - public BigDecimal getTableCredit() { - return tableCredit; + this.globalSold = globalSold; + firePropertyChange(PROPERTY_GLOBAL_SOLD, oldSold, this.globalSold); } - public void setTableCredit(BigDecimal tableCredit) { - this.tableCredit = tableCredit; + public BigDecimal getGlobalDebit() { + return globalDebit; } - public BigDecimal getTableSold() { - return tableSold; + public void setGlobalDebit(BigDecimal globalDebit) { + this.globalDebit = globalDebit; } - public void setTableSold(BigDecimal tableSold) { - this.tableSold = tableSold; + public BigDecimal getGlobalCredit() { + return globalCredit; } - public void resetDebitCreditBalance(){ - setDebit(BigDecimal.ZERO); - setCredit(BigDecimal.ZERO); - setSold(BigDecimal.ZERO, false); + public void setGlobalCredit(BigDecimal globalCredit) { + this.globalCredit = globalCredit; } public void addPropertyChangeListener(PropertyChangeListener listener) { @@ -196,13 +195,11 @@ public class LetteringEditModel implements Serializable { firePropertyChange(propertyName, null, newValue); } - public boolean isEditable() { - return editable; + public Date getFiscalPeriodBeginDate() { + return fiscalPeriodBeginDate; } - public void setEditable(boolean editable) { - boolean oldEditable = this.editable; - this.editable = editable; - firePropertyChange(PROPERTY_EDITABLE, oldEditable, this.editable); + public void setFiscalPeriodBeginDate(Date fiscalPeriodStartingDate) { + this.fiscalPeriodBeginDate = fiscalPeriodStartingDate; } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java new file mode 100644 index 0000000..fa1fea5 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java @@ -0,0 +1,158 @@ +package org.chorem.lima.ui.accountViewer; +/* + * #%L + * Lima :: Swing + * %% + * Copyright (C) 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import org.apache.commons.lang3.StringUtils; +import org.chorem.lima.entity.Entry; + +import javax.swing.*; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.List; + +/** + * @author sletellier <letellier@codelutin.com> + */ +public class AccountViewerSelectionModel extends DefaultListSelectionModel{ + + protected AccountViewerTableModel letteringTableModel; + protected Entry entry; + protected int lineSelected; + protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + + public AccountViewerSelectionModel(AccountViewerTableModel letteringTableModel){ + this.letteringTableModel = letteringTableModel; + } + + @Override + public void addSelectionInterval(int row, int column) { + setSelectionInterval(row, column); + } + + @Override + public void setSelectionInterval(int row, int column) { + if (!letteringNotExist(row)) { + + //lettred entries + if ( isSelectionEmpty() || !isSelectedIndex(row)){ + clearSelection(); + lineSelected = row; + String currentLettring = getCurrentLettring(); + + //select entries with the same letter of the selected entry + for(Entry entry : getEntries()){ + if (StringUtils.isNotBlank(entry.getLettering())){ + if (entry.getLettering().equals(currentLettring)){ + int entryToSelect = letteringTableModel.indexOf(entry); + super.addSelectionInterval(entryToSelect, entryToSelect); + } + } + } + } + } + else { + + //unlettred entries + //To clear the selection when it changes from lettered entry to unlettered + for(Entry entry : getEntries()){ + if (!StringUtils.isBlank(entry.getLettering())) { + int entryToSelect = letteringTableModel.indexOf(entry); + super.removeSelectionInterval(entryToSelect, entryToSelect); + } + } + + if (isSelectionEmpty() || !isSelectedIndex(row)){ + super.addSelectionInterval(row, column); + }else { + super.removeSelectionInterval(row, column); + } + + } + } + + /**return true if lettering is null, or not null but empty + * @param row index of the line to test + * @return boolean + * */ + public boolean letteringNotExist(int row){ + boolean emptyOrNull; + entry = letteringTableModel.get(row); + String lettering = entry.getLettering(); + emptyOrNull = (lettering==null||lettering.isEmpty()); + return emptyOrNull; + } + + public List<Entry> getEntries(){ + return letteringTableModel.getValues(); + } + + public String getCurrentLettring(){ + return getCurrentEntrySelected().getLettering(); + } + + public Entry getCurrentEntrySelected(){ + return letteringTableModel.get(lineSelected); + } + +// /**After rounding one of two entries, selection of its, and of the new entry, +// * resulting of rounding*/ +// public void selectRoundedAndNewEntries(int indexFirstRoundedEntry, int indexSecondRoundedEntry, Entry newResultRoundedEntry) { +// if (!isSelectedIndex(indexFirstRoundedEntry)) { +// addSelectionInterval(indexFirstRoundedEntry, indexFirstRoundedEntry); +// } +// if (!isSelectedIndex(indexSecondRoundedEntry)) { +// addSelectionInterval(indexSecondRoundedEntry, indexSecondRoundedEntry); +// } +// /*New entry*/ +// int newEntryIndex = letteringTableModel.indexOf(newResultRoundedEntry); +// addSelectionInterval(newEntryIndex, newEntryIndex); +// } + + @Override + public int getSelectionMode() { + return MULTIPLE_INTERVAL_SELECTION; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + pcs.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + pcs.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.removePropertyChangeListener(propertyName, listener); + } + + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + pcs.firePropertyChange(propertyName, oldValue, newValue); + } + + protected void firePropertyChange(String propertyName, Object newValue) { + firePropertyChange(propertyName, null, newValue); + } +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTable.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTable.java new file mode 100644 index 0000000..2266311 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTable.java @@ -0,0 +1,42 @@ +/* + * #%L + * Lima :: Swing + * %% + * Copyright (C) 2008 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.accountViewer; + +import org.chorem.lima.ui.common.AbstractLimaTable; + + +/** + * Table des transaction qui ajoute des comportement (keys). + * + * @author jpepin + */ +public class AccountViewerTable extends AbstractLimaTable<AccountViewerViewHandler> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3133690382049594727L; + + public AccountViewerTable(AccountViewerViewHandler handler) { + super(handler); + + } +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java new file mode 100644 index 0000000..e6a3a5a --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java @@ -0,0 +1,144 @@ +/* + * #%L + * Lima :: Swing + * %% + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.accountViewer; + +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.common.AbstractColumn; +import org.chorem.lima.ui.common.AbstractLimaTableModel; + +import java.math.BigDecimal; +import java.util.Date; + +import static org.nuiton.i18n.I18n.t; + +/** + * Basic transaction table model. + * <p/> + * + * @author ore + * @author chatellier + */ +public class AccountViewerTableModel extends AbstractLimaTableModel<Entry> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + public BigDecimal getPreviousPeriodSold() { + return previousPeriodSold; + } + + protected BigDecimal previousPeriodSold; + + @Override + protected void initColumn() { + addColumn(new AbstractColumn<AccountViewerTableModel>(Date.class, t("lima.table.date"), false) { + @Override + public Object getValueAt(int row) { + Entry entry = tableModel.get(row); + return entry.getFinancialTransaction().getTransactionDate(); + } + }); + + addColumn(new AbstractColumn<AccountViewerTableModel>(EntryBook.class, t("lima.table.entryBook"), false) { + @Override + public Object getValueAt(int row) { + Entry entry = tableModel.get(row); + return entry.getFinancialTransaction().getEntryBook(); + } + }); + + addColumn(new AbstractColumn<AccountViewerTableModel>(Account.class, t("lima.table.account"), false) { + @Override + public Object getValueAt(int row) { + Entry entry = tableModel.get(row); + return entry.getAccount(); + } + }); + + addColumn(new AbstractColumn<AccountViewerTableModel>(String.class, t("lima.table.voucher"), false) { + @Override + public Object getValueAt(int row) { + Entry entry = tableModel.get(row); + return entry.getVoucher(); + } + }); + + addColumn(new AbstractColumn<AccountViewerTableModel>(String.class, t("lima.table.description"), false) { + @Override + public Object getValueAt(int row) { + Entry entry = tableModel.get(row); + return entry.getDescription(); + } + }); + + addColumn(new AbstractColumn<AccountViewerTableModel>(String.class, t("lima.table.letter"), false) { + @Override + public Object getValueAt(int row) { + Entry entry = tableModel.get(row); + return entry.getLettering(); + } + }); + + addColumn(new AbstractColumn<AccountViewerTableModel>(BigDecimal.class, t("lima.table.debit"), false) { + @Override + public Object getValueAt(int row) { + Entry entry = tableModel.get(row); + return entry.isDebit() ? entry.getAmount() : BigDecimal.ZERO; + } + }); + + addColumn(new AbstractColumn<AccountViewerTableModel>(BigDecimal.class, t("lima.table.credit"), false) { + @Override + public Object getValueAt(int row) { + Entry entry = tableModel.get(row); + return entry.isDebit() ? BigDecimal.ZERO : entry.getAmount(); + } + }); + + addColumn(new AbstractColumn<AccountViewerTableModel>(BigDecimal.class, t("lima.table.balance"), false) { + @Override + public Object getValueAt(int row) { + Entry currentEntry = tableModel.get(row); + BigDecimal result = BigDecimal.ZERO; + result = currentEntry.isDebit() ? result.add(currentEntry.getAmount()) : result.subtract(currentEntry.getAmount()); + if (row > 0) { + int i = 1; + while (row - i >= 0) { + Entry prevEntry = tableModel.get(row - i); + result = prevEntry.isDebit() ? result.add(prevEntry.getAmount()) : result.subtract(prevEntry.getAmount()); + i++; + } + + } + return result; + } + }); + + } + + public void setPreviousPeriodSold(BigDecimal previousPeriodSold) { + this.previousPeriodSold = previousPeriodSold; + } +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css new file mode 100644 index 0000000..f0bd618 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css @@ -0,0 +1,73 @@ +/* + * #%L + * Lima :: Swing + * %% + * Copyright (C) 2008 - 2014 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +.toolbar { + floatable : false; +} + +#accountLabel { + actionIcon : "choose-account"; + labelFor : {accountComboBox}; +} + +#accountComboBox { + toolTipText : "lima.lettering.account"; + showDecorator : false; + selectedItem : {getHandler().getAccount()}; + minimumSize : {new Dimension(300,10)}; + preferredSize : {new Dimension(400,25)}; + maximumSize : {new Dimension(500,40)}; +} + +#back { + toolTipText : "lima.lettering.account.back"; + actionIcon : "previous"; +} + +#next { + toolTipText : "lima.lettering.account.next"; + actionIcon : "next"; +} + +#beginPeriodLabel { + text : "lima.lettering.period.begin"; + labelFor : {beginPeriodPicker}; +} + +#endPeriodLabel { + text : "lima.lettering.period.end"; + labelFor : {endPeriodPicker}; +} + +#refresh { + toolTipText : "lima.lettering.refresh"; + actionIcon : "refresh"; +} + +#table { + sortable : false; + rowHeight : 22; +} + +#balanceStatusLabel { + horizontalTextPosition:{JLabel.RIGHT}; + border: {BorderFactory.createEmptyBorder(0, 0, 0, 20)} +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx new file mode 100644 index 0000000..25a1066 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx @@ -0,0 +1,94 @@ +<!-- + #%L + Lima :: Swing + %% + Copyright (C) 2008 - 2010 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<JPanel layout="{new BorderLayout()}"> + + <import> + java.awt.Dimension + org.chorem.lima.util.WrapToolBarLayout + org.chorem.lima.ui.common.FinancialPeriodComboBoxModel + org.chorem.lima.util.BigDecimalToString + org.chorem.lima.ui.lettering.TypeEntry + org.chorem.lima.entity.Account + javax.swing.ListSelectionModel + org.jdesktop.swingx.JXDatePicker + static org.nuiton.i18n.I18n.t + org.chorem.lima.ui.combobox.AccountComboBox + </import> + + <AccountViewerViewHandler id="handler" constructorParams="this"/> + + <AccountViewerEditModel id='editModel'/> + + <script> + <![CDATA[ + void $afterCompleteSetup() { + handler.init(); + } + ]]> + </script> + + <JToolBar styleClass="toolbar" + constraints="BorderLayout.PAGE_START" + layout="{new WrapToolBarLayout()}"> + + <JLabel id="accountLabel"/> + <AccountComboBox id="accountComboBox" + constraints="BorderLayout.CENTER" + onPropertyChange="{getHandler().accountComboBoxChange(event);}"/> + <JButton id="back" + onActionPerformed="handler.back(accountComboBox)"/> + <JButton id="next" + onActionPerformed="handler.next(accountComboBox)"/> + + <JToolBar.Separator/> + + <JLabel id="beginPeriodLabel"/> + <JAXXDatePicker id="beginPeriodPicker" + patternLayout="dd/MM/yyy" + onActionPerformed="handler.setDateStart(beginPeriodPicker.getDate())"/> + + <JLabel id="endPeriodLabel"/> + <JAXXDatePicker id="endPeriodPicker" + patternLayout="dd/MM/yyy" + onActionPerformed="handler.setDateEnd(endPeriodPicker.getDate())"/> + + <JToolBar.Separator/> + + <JButton id="refresh" + onActionPerformed="handler.updateAllEntries()"/> + + </JToolBar> + <JScrollPane constraints="BorderLayout.CENTER"> + <AccountViewerTableModel id="tableModel"/> + <AccountViewerSelectionModel id='accountViewerSelectionModel' constructorParams='tableModel' + onValueChanged="handler.balanceAndActions()"/> + + <AccountViewerTable id="table" + constructorParams="handler" + model="{tableModel}" + selectionModel="{accountViewerSelectionModel}"/> + </JScrollPane> + + <JPanel constraints="BorderLayout.SOUTH" layout="{new BorderLayout()}"> + <JLabel id='balanceStatusLabel' constraints="BorderLayout.EAST"/> + </JPanel> + +</JPanel> \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java new file mode 100644 index 0000000..bf37cb0 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -0,0 +1,588 @@ +/* + * #%L + * Lima :: Swing + * %% + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.accountViewer; + +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.time.DateUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.LimaSwingConfig; +import org.chorem.lima.beans.LetteringFilter; +import org.chorem.lima.beans.LetteringFilterImpl; +import org.chorem.lima.business.LimaServiceFactory; +import org.chorem.lima.business.api.AccountService; +import org.chorem.lima.business.api.EntryBookService; +import org.chorem.lima.business.api.FinancialPeriodService; +import org.chorem.lima.business.api.FinancialTransactionService; +import org.chorem.lima.business.api.FiscalPeriodService; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryImpl; +import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.FinancialTransactionImpl; +import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.ui.combobox.AccountComboBox; +import org.chorem.lima.util.BigDecimalToString; +import org.chorem.lima.util.ErrorHelper; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n.t; + + +/** + * Handler associated with financial transaction view. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class AccountViewerViewHandler { + + // fixme Date format should be app parameters + protected static String DATE_FORMAT = "dd/MM/yyyy"; + + protected AccountViewerView view; + protected AccountViewerTable table; + + /** Transaction service. */ + protected FiscalPeriodService fiscalPeriodService; + protected FinancialPeriodService financialPeriodService; + protected AccountService accountService; + protected FinancialTransactionService financialTransactionService; + protected EntryBookService entryBookService; + + protected LetteringFilterImpl filter; + + protected BigDecimal debit = BigDecimal.ZERO; + protected BigDecimal credit = BigDecimal.ZERO; + protected AccountViewerEditModel editModel; + + protected ErrorHelper errorHelper; + + protected enum ButtonMode {DELETTRED, LETTRED, EQUALIZED, ALL} + + protected SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT); + + private static final Log log = LogFactory.getLog(AccountViewerViewHandler.class); + + + protected boolean initializationComplete; + + public AccountViewerViewHandler(AccountViewerView view) { + initializationComplete = false; + this.view = view; + initShortCuts(); + financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); + fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); + accountService = LimaServiceFactory.getService(AccountService.class); + financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); + entryBookService = LimaServiceFactory.getService(EntryBookService.class); + errorHelper = new ErrorHelper(LimaSwingConfig.getInstance()); + } + + /** + * Init all combo box in view. + */ + public void init() { + filter = new LetteringFilterImpl(); + editModel = view.getEditModel(); + //lettringSelectionModel = view.getLetteringSelectionModel(); + loadComboAndRows(); + + editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + updateSoldStatus(); + } + }); + + editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_CREDIT, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + updateSoldStatus(); + } + }); + + editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_SOLD, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + updateSoldStatus(); + } + }); + + editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_GLOBAL_SOLD, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + updateSoldStatus(); + } + }); + + initializationComplete = true; + updateAllEntries(); + updateSoldStatus(); + } + + public void updateSoldStatus() { + if (initializationComplete) { + view.getBalanceStatusLabel().setText(t("lima.lettering.accountViewerBalanceStatus", + dateFormatter.format(editModel.getFiscalPeriodBeginDate()), + dateFormatter.format(filter.getDateEnd()), + + BigDecimalToString.format(editModel.getGlobalDebit()), + BigDecimalToString.format(editModel.getGlobalCredit()), + BigDecimalToString.format(editModel.getGlobalSold()), + + BigDecimalToString.format(editModel.getDebit()), + BigDecimalToString.format(editModel.getCredit()), + BigDecimalToString.format(editModel.getSold()))); + } + } + + + protected void initShortCuts() { + + InputMap inputMap= view.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = view.getActionMap(); + Object binding; + + //To block reaction of the dual key 'ctrl+a' (Selection of all lines) + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK), "none"); + + + // refresh + binding = "refresh"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), binding); + actionMap.put(binding, new AbstractAction() { + private static final long serialVersionUID = -7192846839712951680L; + + @Override + public void actionPerformed(ActionEvent e) { + updateAllEntries(); + } + }); + } + + public void loadComboAndRows(){ + + //By default, we have the beginning of the fiscal period (Or of current + //date if no fiscal period) and the end of the current fiscal period + FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); + Date defaultDateBegFiscalPeriod, defaultDateEndCurrent; + + Calendar calendar = Calendar.getInstance(); + int lastCurrentMonthDay = calendar.getActualMaximum(Calendar.DATE); + int firstCurrentMonthDay = calendar.getActualMinimum(Calendar.DATE); + + if (fiscalPeriod != null){ + defaultDateBegFiscalPeriod = fiscalPeriod.getBeginDate(); + defaultDateEndCurrent = fiscalPeriod.getEndDate(); + } else{ + defaultDateBegFiscalPeriod = DateUtils.setDays(new Date(), firstCurrentMonthDay); + defaultDateEndCurrent = DateUtils.setDays(new Date(), lastCurrentMonthDay); + } + + view.getBeginPeriodPicker().setDate(defaultDateBegFiscalPeriod); + view.getEndPeriodPicker().setDate(defaultDateEndCurrent); + + editModel.setFiscalPeriodBeginDate(defaultDateBegFiscalPeriod); + + filter.setDateStart(defaultDateBegFiscalPeriod); + filter.setDateEnd(defaultDateEndCurrent); + } + + public void updateAllEntries() { + + if (initializationComplete + && filter.getAccount() != null + && filter.getDateStart() != null + && filter.getDateEnd() != null) { + + List<Entry> entriesAndResume = Lists.newArrayList(); + + List<Entry> entries = financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); + FiscalPeriod fiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()); + + LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(fiscalPeriod); + LetteringFilter actualPeriodFilter = computeActualPeriodFilter(fiscalPeriod); + setPreviousSold(previousPeriodFilter); + setActualSold(fiscalPeriod, actualPeriodFilter); + + // no previous sold to add if selected starting date is same as fiscal period one + if (!DateUtils.isSameDay(filter.getDateStart(), previousPeriodFilter.getDateStart()) && CollectionUtils.isNotEmpty(entries)) { + entriesAndResume.add(getFirstLinePreviousSoldEntry(entries, previousPeriodFilter)); + } + + entriesAndResume.addAll(entries); + view.getTableModel().setValues(entriesAndResume); + } + + onBalanceChanged(null); + } + + protected void addFiscalPeriodBeginDate(FiscalPeriod fiscalPeriod) { + if (fiscalPeriod != null) { + editModel.setFiscalPeriodBeginDate(fiscalPeriod.getBeginDate()); + } + } + + protected Entry getFirstLinePreviousSoldEntry(List<Entry> entries, LetteringFilter previousPeriodFilter) { + Entry firstEntry = entries.get(0); + FinancialTransaction firstTransaction = firstEntry.getFinancialTransaction(); + FinancialTransaction firstLineTransaction = new FinancialTransactionImpl(); + Binder<FinancialTransaction, FinancialTransaction> binder = BinderFactory.newBinder(FinancialTransaction.class); + binder.copyExcluding(firstTransaction, firstLineTransaction, FinancialTransaction.PROPERTY_TOPIA_ID); + Date previousSoldEndDate = getDayMinus1Calendar(previousPeriodFilter).getTime(); + firstLineTransaction.setTransactionDate(previousSoldEndDate); + + Entry resumeEntry = new EntryImpl(); + resumeEntry.setDescription(String.format(t("lima.accountViewer.previousSold"), dateFormatter.format(previousSoldEndDate))); + resumeEntry.setAmount(view.getTableModel().getPreviousPeriodSold().abs()); + resumeEntry.setDebit(BigDecimal.ZERO.compareTo(view.getTableModel().getPreviousPeriodSold()) < 0); + resumeEntry.setFinancialTransaction(firstLineTransaction); + return resumeEntry; + } + + protected void setPreviousSold(LetteringFilter previousPeriodFilter) { + BigDecimal previousSold; + if (previousPeriodFilter == null) { + previousSold = BigDecimal.ZERO; + } else { + List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(previousPeriodFilter); + DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); + previousSold = debitCreditSold.getSold(); + } + view.getTableModel().setPreviousPeriodSold(previousSold); + } + + protected void setActualSold(FiscalPeriod fiscalPeriod, LetteringFilter actualPeriodFilter) { + addFiscalPeriodBeginDate(fiscalPeriod); + List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(actualPeriodFilter); + DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); + editModel.setGlobalDebit(debitCreditSold.getDebit()); + editModel.setGlobalCredit(debitCreditSold.getCredit()); + editModel.setGlobalSold(debitCreditSold.getSold()); + } + + + public void balanceAndActions() { + if (log.isDebugEnabled()) { + log.debug("balanceAndActions"); + } + if (view.getTable().getSelectedRows().length == 0) { + onButtonModeChanged(ButtonMode.ALL); + onBalanceChanged(null); + } else if (!letteringNotExist(view.getTable().getSelectedRow())) { + + //lettred entries + onBalanceChanged(null); + setValuesForSelectedEntries(); + + //For U.I. buttons (Lettering and unlettering) + onButtonModeChanged(ButtonMode.DELETTRED); + } else { + if (log.isDebugEnabled()) { + log.debug("unlettred entries"); + } + int[] selectedRows = view.getTable().getSelectedRows(); + if (selectedRows.length == 2) { + if (log.isDebugEnabled()) { + log.debug("2 rows selected"); + } + /*Treatment only if one of values contains decimals*/ + AccountViewerTableModel tableModel = view.getTableModel(); + Entry firstSelectedEntry = tableModel.get(selectedRows[0]); + Entry secondSelectedEntry = tableModel.get(selectedRows[1]); + + /*Get decimals*/ + BigDecimal firstSelectedEntryAmount = firstSelectedEntry.getAmount(); + BigDecimal secondSelectedEntryAmount = secondSelectedEntry.getAmount(); + + if ( secondSelectedEntry.isDebit() != firstSelectedEntry.isDebit() + && (firstSelectedEntryAmount.subtract(secondSelectedEntryAmount).abs().compareTo(BigDecimal.ZERO) >0 + && firstSelectedEntryAmount.subtract(secondSelectedEntryAmount).abs().compareTo(BigDecimal.ONE) <0) ) { + onButtonModeChanged(ButtonMode.EQUALIZED); + } + }else { + if (log.isDebugEnabled()) { + log.debug("!2 rows selected"); + } + onButtonModeChanged(ButtonMode.ALL); + } + + //Unlettred entries + onBalanceChanged(null); + //treatment unuseful if no rows are selected + if (!view.getAccountViewerSelectionModel().isSelectionEmpty()) { + if (log.isDebugEnabled()) { + log.debug("Rows selected"); + } + setValuesForSelectedEntries(); + onButtonModeChanged(ButtonMode.LETTRED); + } else { + if (log.isDebugEnabled()) { + log.debug("No Rows selected"); + } + onButtonModeChanged(ButtonMode.ALL); + } + } + } + + /**return true if lettering is null, or not null but empty + * @param row index of the line to test + * @return boolean + * */ + public boolean letteringNotExist(int row){ + boolean emptyOrNull = false; + if (row != -1) { + Entry entry = view.getTableModel().get(row); + String lettering = entry.getLettering(); + emptyOrNull = (lettering==null||lettering.isEmpty()); + } + return emptyOrNull; + } + + public void onButtonModeChanged(ButtonMode buttonMode) { + + switch (buttonMode) { + case DELETTRED : + editModel.setLettred(false); + editModel.setUnLettred(true); + break; + case LETTRED: + editModel.setUnLettred(false); + editModel.setLettred(true); + break; + case EQUALIZED: + editModel.setEqualized(true); + break; + default: + editModel.setLettred(false); + editModel.setUnLettred(false); + editModel.setEqualized(false); + } + } + + public void setValuesForSelectedEntries() { + Entry selectedEntry; + AccountViewerTableModel tableModel = view.getTableModel(); + for (int i = 0; i < tableModel.getRowCount(); i ++){ + if (view.getAccountViewerSelectionModel().isSelectedIndex(i)){ + selectedEntry = tableModel.get(i); + //Set values for calculation (By AccountViewerEditModel) of balance + onBalanceChanged(selectedEntry); + } + } + } + + public void onBalanceChanged(Entry balance) { + if (balance == null) { + editModel.setCredit(BigDecimal.ZERO); + editModel.setDebit(BigDecimal.ZERO); + editModel.setSold(BigDecimal.ZERO, false); + } else { + balanceCalculation(balance.getAmount(), balance.isDebit()); + } + } + + /**Allow to add / subtract credit / debit and balance + * @param amount debit or credit + * @param debit it indicate if amount is debit or not + * */ + public void balanceCalculation(BigDecimal amount, boolean debit){ + + BigDecimal debitVal = debit ? amount : BigDecimal.ZERO; + BigDecimal creditVal = debit ? BigDecimal.ZERO : amount; + + if (log.isDebugEnabled()) { + log.debug("balance calculation"); + } + + if (debitVal.equals(BigDecimal.ZERO)){ + + if (!creditVal.equals(BigDecimal.ZERO)){ + + editModel.setCredit(creditVal); + editModel.setSold(creditVal, true); + } + }else if (creditVal.equals(BigDecimal.ZERO)){ + editModel.setDebit(debitVal); + editModel.setSold(debitVal, false); + }else{ + onBalanceChanged(null); + } + } + + protected Calendar getDayMinus1Calendar(LetteringFilter previousPeriodFilter) { + Calendar cal = Calendar.getInstance(); + cal.setTime(previousPeriodFilter.getDateEnd()); + cal.add(Calendar.DATE, -1); + return cal; + } + + protected LetteringFilter computePreviousPeriodFilter(FiscalPeriod fiscalPeriod) { + LetteringFilter previousPeriodFilter = null; + + if (fiscalPeriod != null) { + previousPeriodFilter = new LetteringFilterImpl(); + previousPeriodFilter.setDateStart(fiscalPeriod.getBeginDate()); + previousPeriodFilter.setDateEnd(filter.getDateStart()); + previousPeriodFilter.setAccount(filter.getAccount()); + } + + return previousPeriodFilter; + } + + private LetteringFilter computeActualPeriodFilter(FiscalPeriod fiscalPeriod) { + LetteringFilter actualPeriodFilter = null; + + if (fiscalPeriod != null) { + actualPeriodFilter = new LetteringFilterImpl(); + actualPeriodFilter.setDateStart(fiscalPeriod.getBeginDate()); + actualPeriodFilter.setDateEnd(filter.getDateEnd()); + actualPeriodFilter.setAccount(filter.getAccount()); + } + + return actualPeriodFilter; + } + + public void accountComboBoxChange(PropertyChangeEvent event) { + if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM)) { + if (event.getNewValue() != null && event.getNewValue() instanceof Account) { + setAccount((Account) event.getNewValue()); + } + } + } + + /** + * Select previous value in combo box. + * + * @param accountComboBox account combo box + */ + public void back(AccountComboBox accountComboBox) { + JComboBox comboBox = accountComboBox.getCombobox(); + int row = comboBox.getSelectedIndex(); + + if (row > 0) { + comboBox.setSelectedIndex(row - 1); + } + view.getAccountViewerSelectionModel().clearSelection(); + } + + /** + * Select next value in combo box. + * + * @param accountComboBox combo box + */ + public void next(AccountComboBox accountComboBox) { + JComboBox comboBox = accountComboBox.getCombobox(); + int size = comboBox.getItemCount(); + int row = comboBox.getSelectedIndex(); + + if (row < size - 1) { + comboBox.setSelectedIndex(row + 1); + } + view.getAccountViewerSelectionModel().clearSelection(); + } + + private class DebitCreditSold { + private BigDecimal debit; + private BigDecimal credit; + private BigDecimal sold; + + public BigDecimal getDebit() { + return debit; + } + + public BigDecimal getCredit() { + return credit; + } + + public BigDecimal getSold() { + return sold; + } + + public DebitCreditSold invoke(List<Object[]> initialDebitCredit) { + debit = BigDecimal.ZERO; + credit = BigDecimal.ZERO; + if (CollectionUtils.isNotEmpty(initialDebitCredit)) { + int nbAmount = initialDebitCredit.size(); + if (nbAmount == 2) { + debit = (BigDecimal) initialDebitCredit.get(0)[1]; + credit = (BigDecimal) initialDebitCredit.get(1)[1]; + } + if (nbAmount == 1) { + if ((Boolean) initialDebitCredit.get(0)[0]) { + debit = (BigDecimal) initialDebitCredit.get(0)[1]; + } else { + credit = (BigDecimal) initialDebitCredit.get(0)[1]; + } + } + } + + sold = debit.subtract(credit); + return this; + } + } + + public void setDateStart(Date date) { + filter.setDateStart(date); + updateAllEntries(); + } + + public void setDateEnd(Date date) { + filter.setDateEnd(date); + updateAllEntries(); + } + + public void setAccount(Account account) { + if (filter != null) { + filter.setAccount(account); + updateAllEntries(); + } + } + + public Account getAccount() { + Account account = null; + if (filter != null) { + account = filter.getAccount(); + } + return account; + } + +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java index ddb2448..d75c09c 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java @@ -73,7 +73,7 @@ public class LetteringEditModel implements Serializable { public boolean isLettered() { return lettered; } - + public void setLettered(boolean lettered) { boolean oldLettrer = isLettered(); this.lettered = lettered && (BigDecimal.ZERO.equals(sold) || sold.doubleValue() == 0) && lettered; diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java index dedc44d..77db344 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java @@ -440,37 +440,6 @@ public class LetteringViewHandler{ setTypeEntry(type); } - public void setDateStart(Date date) { - filter.setDateStart(date); - updateAllEntries(); - } - - public void setDateEnd(Date date) { - filter.setDateEnd(date); - updateAllEntries(); - } - - public void setAccount(Account account) { - if (filter != null) { - filter.setAccount(account); - updateAllEntries(); - } - } - - public Account getAccount() { - Account account = null; - if (filter != null) { - account = filter.getAccount(); - } - return account; - } - - public void setTypeEntry(TypeEntry typeEntry) { - filter.setDisplayLettered(typeEntry.isLettered()); - filter.setDisplayUnlettred(typeEntry.isNoLettered()); - updateAllEntries(); - } - public void updateAllEntries() { if (initializationComplete @@ -656,6 +625,38 @@ public class LetteringViewHandler{ } } + + public void setDateStart(Date date) { + filter.setDateStart(date); + updateAllEntries(); + } + + public void setDateEnd(Date date) { + filter.setDateEnd(date); + updateAllEntries(); + } + + public void setAccount(Account account) { + if (filter != null) { + filter.setAccount(account); + updateAllEntries(); + } + } + + public Account getAccount() { + Account account = null; + if (filter != null) { + account = filter.getAccount(); + } + return account; + } + + public void setTypeEntry(TypeEntry typeEntry) { + filter.setDisplayLettered(typeEntry.isLettered()); + filter.setDisplayUnlettred(typeEntry.isNoLettered()); + updateAllEntries(); + } + protected DateFormat getDateFormat() { Locale locale = LimaSwingConfig.getInstance().getLocale(); DateFormat result = DateFormat.getDateInstance(DateFormat.SHORT, locale); 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 76d6b08..4de6b2d 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 @@ -14,6 +14,7 @@ lima.account.remove.confirm.title=Delete account lima.account.remove.error.usedAccount=There are financial statement on this account lima.account.update.error.invalidAccountNumber=Invalid account number\: %1$s lima.account.update.form=Update account +lima.accountViewer.previousSold=Solde au %s lima.accounts=Accounts lima.action.commandline.help=Show help in console lima.balance=Balance @@ -133,6 +134,7 @@ lima.documents=Documents… lima.email.support.description=Mail for support lima.email.support.label=support lima.entries=Entries +lima.entries.accountViewer=Account viewer lima.entries.add.entry.error.afterLastFiscalPeriod=Add entry failed, financial transaction date is after last fiscal period date lima.entries.add.entry.error.beforeFirstFiscalPeriod=Add entry failed, financial transaction date is before first fiscal period date lima.entries.add.entry.error.lockedEntryBook=Add entry failed, closed entry book @@ -449,6 +451,8 @@ lima.lettering.account=Accounts lima.lettering.account.aAll=All lima.lettering.account.back=← lima.lettering.account.next=→ +lima.lettering.accountViewerBalanceStatus=<html>From %s to %s\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> - Selected entries\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> +lima.lettering.balanceStatus= lima.lettering.balanceStatus=<html>Debit\: <b>%s</b> - Credit\: <b>%s</b> - Sold\: <b>%s</b>. Selected entries\: Debit\: <b>%s</b> - Credit\: <b>%s</b> - Sold\: <b>%s</b> lima.lettering.checkAll=All lima.lettering.checkLettredEntry=Lettered 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 63aba53..7aca2bf 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 @@ -17,6 +17,7 @@ lima.account.remove.confirm.title=Suppression d'un compte lima.account.remove.error.usedAccount=Il exist des transactions sur ce compte lima.account.update.error.invalidAccountNumber=Le numéro du compte %1$s n'est pas valide lima.account.update.form=Modification d'un compte +lima.accountViewer.previousSold=Solde au %s lima.accounts=Comptes lima.action.commandline.help=Afficher l'aide en console lima.balance=Équilibrer @@ -149,6 +150,7 @@ lima.documents=Documents… lima.email.support.description=Adresse email de support lima.email.support.label=support lima.entries=Écritures +lima.entries.accountViewer=Consultation de compte lima.entries.add.entry.error.afterLastFiscalPeriod=Impossible d'ajouter une écriture car la date de la transaction est après le %1$te %1$tB %1$tY fin du dernier exercice. lima.entries.add.entry.error.beforeFirstFiscalPeriod=Impossible d'ajouter une écriture car la date de la transaction est avant le %1$te %1$tB %1$tY début du premier exercice. lima.entries.add.entry.error.lockedEntryBook=Impossible d'ajouter une écriture 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. @@ -461,6 +463,7 @@ lima.lettering.account=Comptes lima.lettering.account.aAll=TOUS lima.lettering.account.back=← lima.lettering.account.next=→ +lima.lettering.accountViewerBalanceStatus=<html>Pour la période du %s au %s\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> - Pour la sélection\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> lima.lettering.balanceStatus=<html>Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b>. Entrées sélectionnées\: Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b> lima.lettering.checkAll=Toutes lima.lettering.checkLettredEntry=Lettrées -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit fe9ed6b58d23d450baa0adc8700da467c923102a Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 15:14:19 2015 +0200 refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) + Ajout d'icones --- .../ui/accountViewer/AccountViewerEditModel.java | 58 +++++++++++----------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java index 0c9b98c..5c4f64f 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java @@ -62,35 +62,35 @@ public class AccountViewerEditModel implements Serializable { protected Date fiscalPeriodBeginDate; - public boolean isEqualized() { - return equalized; - } - - public void setEqualized(boolean equalized) { - boolean oldEqualized = isEqualized(); - this.equalized = equalized; - firePropertyChange(PROPERTY_EQUALIZED, oldEqualized, this.equalized); - } - - public boolean isLettred() { - return lettred; - } - - public void setLettred(boolean lettered) { - boolean oldLetter = isLettred(); - this.lettred = lettered && (BigDecimal.ZERO.equals(sold) || sold.doubleValue() == 0); - firePropertyChange(PROPERTY_LETTRED, oldLetter, this.lettred); - } - - public boolean isUnLettred() { - return unLettred; - } - - public void setUnLettred(boolean unLettred) { - boolean oldDeleter = isUnLettred(); - this.unLettred = unLettred; - firePropertyChange(PROPERTY_UNLETTRED, oldDeleter, this.unLettred); - } +// public boolean isEqualized() { +// return equalized; +// } + +// public void setEqualized(boolean equalized) { +// boolean oldEqualized = isEqualized(); +// this.equalized = equalized; +// firePropertyChange(PROPERTY_EQUALIZED, oldEqualized, this.equalized); +// } + +// public boolean isLettred() { +// return lettred; +// } + +// public void setLettred(boolean lettered) { +// boolean oldLetter = isLettred(); +// this.lettred = lettered && (BigDecimal.ZERO.equals(sold) || sold.doubleValue() == 0); +// firePropertyChange(PROPERTY_LETTRED, oldLetter, this.lettred); +// } + +// public boolean isUnLettred() { +// return unLettred; +// } + +// public void setUnLettred(boolean unLettred) { +// boolean oldDeleter = isUnLettred(); +// this.unLettred = unLettred; +// firePropertyChange(PROPERTY_UNLETTRED, oldDeleter, this.unLettred); +// } public BigDecimal getDebit() { return debit; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 25f8c7c63e5421b32e78cdaf99c08a3fecb92eb4 Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 15:56:35 2015 +0200 refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) --- .../src/main/java/org/chorem/lima/ui/MainView.css | 2 +- .../ui/accountViewer/AccountViewerEditModel.java | 40 +---- .../accountViewer/AccountViewerSelectionModel.java | 98 ++++++------ .../lima/ui/accountViewer/AccountViewerView.css | 9 ++ .../lima/ui/accountViewer/AccountViewerView.jaxx | 8 +- .../ui/accountViewer/AccountViewerViewHandler.java | 177 +++++++-------------- .../lima/ui/accountViewer/SelectionMode.java | 29 ++++ .../resources/i18n/lima-swing_en_GB.properties | 4 + .../resources/i18n/lima-swing_fr_FR.properties | 4 + .../main/resources/icons/action-account-viewer.png | Bin 0 -> 1062 bytes .../main/resources/icons/action-selection-mode.png | Bin 0 -> 1106 bytes 11 files changed, 165 insertions(+), 206 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css index 177cf8b..0053bbc 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css @@ -238,7 +238,7 @@ #accountViewer { text : "lima.entries.accountViewer"; - actionIcon : "lettering"; + actionIcon : "account-viewer"; } #help { diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java index 5c4f64f..57accc3 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java @@ -40,18 +40,10 @@ public class AccountViewerEditModel implements Serializable { public static final String PROPERTY_GLOBAL_SOLD = "globalSold"; - public static final String PROPERTY_LETTRED = "lettred"; - - public static final String PROPERTY_UNLETTRED = "unLettred"; - - public static final String PROPERTY_EQUALIZED = "equalized"; - protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); protected AccountViewerTableModel model; - protected boolean lettred; - protected boolean unLettred; - protected boolean equalized; + protected BigDecimal debit = BigDecimal.ZERO; protected BigDecimal credit = BigDecimal.ZERO; protected BigDecimal sold = BigDecimal.ZERO; @@ -62,36 +54,6 @@ public class AccountViewerEditModel implements Serializable { protected Date fiscalPeriodBeginDate; -// public boolean isEqualized() { -// return equalized; -// } - -// public void setEqualized(boolean equalized) { -// boolean oldEqualized = isEqualized(); -// this.equalized = equalized; -// firePropertyChange(PROPERTY_EQUALIZED, oldEqualized, this.equalized); -// } - -// public boolean isLettred() { -// return lettred; -// } - -// public void setLettred(boolean lettered) { -// boolean oldLetter = isLettred(); -// this.lettred = lettered && (BigDecimal.ZERO.equals(sold) || sold.doubleValue() == 0); -// firePropertyChange(PROPERTY_LETTRED, oldLetter, this.lettred); -// } - -// public boolean isUnLettred() { -// return unLettred; -// } - -// public void setUnLettred(boolean unLettred) { -// boolean oldDeleter = isUnLettred(); -// this.unLettred = unLettred; -// firePropertyChange(PROPERTY_UNLETTRED, oldDeleter, this.unLettred); -// } - public BigDecimal getDebit() { return debit; } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java index fa1fea5..5199a0b 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java @@ -37,6 +37,8 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ protected AccountViewerTableModel letteringTableModel; protected Entry entry; protected int lineSelected; + + protected boolean balancedSelectionMode; protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); public AccountViewerSelectionModel(AccountViewerTableModel letteringTableModel){ @@ -50,43 +52,54 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ @Override public void setSelectionInterval(int row, int column) { - if (!letteringNotExist(row)) { - - //lettred entries - if ( isSelectionEmpty() || !isSelectedIndex(row)){ - clearSelection(); - lineSelected = row; - String currentLettring = getCurrentLettring(); - - //select entries with the same letter of the selected entry - for(Entry entry : getEntries()){ - if (StringUtils.isNotBlank(entry.getLettering())){ - if (entry.getLettering().equals(currentLettring)){ - int entryToSelect = letteringTableModel.indexOf(entry); - super.addSelectionInterval(entryToSelect, entryToSelect); + if (balancedSelectionMode) { + if (!letteringNotExist(row)) { + + //lettred entries + if ( isSelectionEmpty() || !isSelectedIndex(row)){ + clearSelection(); + lineSelected = row; + String currentLettring = getCurrentLettring(); + + //select entries with the same letter of the selected entry + for(Entry entry : getEntries()){ + if (StringUtils.isNotBlank(entry.getLettering())){ + if (entry.getLettering().equals(currentLettring)){ + int entryToSelect = letteringTableModel.indexOf(entry); + super.addSelectionInterval(entryToSelect, entryToSelect); + } } } } } - } - else { - - //unlettred entries - //To clear the selection when it changes from lettered entry to unlettered - for(Entry entry : getEntries()){ - if (!StringUtils.isBlank(entry.getLettering())) { - int entryToSelect = letteringTableModel.indexOf(entry); - super.removeSelectionInterval(entryToSelect, entryToSelect); + else { + + //unlettred entries + //To clear the selection when it changes from lettered entry to unlettered + for(Entry entry : getEntries()){ + if (!StringUtils.isBlank(entry.getLettering())) { + int entryToSelect = letteringTableModel.indexOf(entry); + super.removeSelectionInterval(entryToSelect, entryToSelect); + } } - } - if (isSelectionEmpty() || !isSelectedIndex(row)){ - super.addSelectionInterval(row, column); - }else { - super.removeSelectionInterval(row, column); - } + if (isSelectionEmpty() || !isSelectedIndex(row)){ + super.addSelectionInterval(row, column); + }else { + super.removeSelectionInterval(row, column); + } + } + } else { + super.addSelectionInterval(row, column); + //super.setSelectionInterval(row, column); } + + } + + @Override + public int getSelectionMode() { + return MULTIPLE_INTERVAL_SELECTION; } /**return true if lettering is null, or not null but empty @@ -113,24 +126,6 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ return letteringTableModel.get(lineSelected); } -// /**After rounding one of two entries, selection of its, and of the new entry, -// * resulting of rounding*/ -// public void selectRoundedAndNewEntries(int indexFirstRoundedEntry, int indexSecondRoundedEntry, Entry newResultRoundedEntry) { -// if (!isSelectedIndex(indexFirstRoundedEntry)) { -// addSelectionInterval(indexFirstRoundedEntry, indexFirstRoundedEntry); -// } -// if (!isSelectedIndex(indexSecondRoundedEntry)) { -// addSelectionInterval(indexSecondRoundedEntry, indexSecondRoundedEntry); -// } -// /*New entry*/ -// int newEntryIndex = letteringTableModel.indexOf(newResultRoundedEntry); -// addSelectionInterval(newEntryIndex, newEntryIndex); -// } - - @Override - public int getSelectionMode() { - return MULTIPLE_INTERVAL_SELECTION; - } public void addPropertyChangeListener(PropertyChangeListener listener) { pcs.addPropertyChangeListener(listener); @@ -155,4 +150,13 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ protected void firePropertyChange(String propertyName, Object newValue) { firePropertyChange(propertyName, null, newValue); } + + public void setBalancedSelectionMode(boolean balancedSelectionMode) { + this.balancedSelectionMode = balancedSelectionMode; + clearSelection(); + } + + public boolean getBalancedSelectionMode() { + return balancedSelectionMode; + } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css index f0bd618..25f34fe 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css @@ -52,11 +52,20 @@ labelFor : {beginPeriodPicker}; } +#beginPeriodPicker { + patternLayout: {handler.DATE_FORMAT}; +} + #endPeriodLabel { text : "lima.lettering.period.end"; labelFor : {endPeriodPicker}; } +#endPeriodPicker { + patternLayout: {handler.DATE_FORMAT}; +} + + #refresh { toolTipText : "lima.lettering.refresh"; actionIcon : "refresh"; diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx index 25a1066..75a86df 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx @@ -62,16 +62,20 @@ <JLabel id="beginPeriodLabel"/> <JAXXDatePicker id="beginPeriodPicker" - patternLayout="dd/MM/yyy" onActionPerformed="handler.setDateStart(beginPeriodPicker.getDate())"/> <JLabel id="endPeriodLabel"/> <JAXXDatePicker id="endPeriodPicker" - patternLayout="dd/MM/yyy" onActionPerformed="handler.setDateEnd(endPeriodPicker.getDate())"/> <JToolBar.Separator/> + <JLabel id='balancedSelectionModeLabel' actionIcon='selection-mode'/> + <EnumEditor id='balancedSelectionMode' + genericType='SelectionMode' + constructorParams='SelectionMode.class' + onItemStateChanged="handler.onSelectionModeChanged(balancedSelectionMode.getSelectedItem())" /> + <JButton id="refresh" onActionPerformed="handler.updateAllEntries()"/> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index bf37cb0..7e9ceca 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -75,12 +75,11 @@ import static org.nuiton.i18n.I18n.t; public class AccountViewerViewHandler { // fixme Date format should be app parameters - protected static String DATE_FORMAT = "dd/MM/yyyy"; + protected static String DATE_FORMAT = t("lima.ui.dateFormat"); protected AccountViewerView view; protected AccountViewerTable table; - /** Transaction service. */ protected FiscalPeriodService fiscalPeriodService; protected FinancialPeriodService financialPeriodService; protected AccountService accountService; @@ -89,13 +88,11 @@ public class AccountViewerViewHandler { protected LetteringFilterImpl filter; - protected BigDecimal debit = BigDecimal.ZERO; - protected BigDecimal credit = BigDecimal.ZERO; protected AccountViewerEditModel editModel; protected ErrorHelper errorHelper; - protected enum ButtonMode {DELETTRED, LETTRED, EQUALIZED, ALL} + protected SelectionMode selectionMode = SelectionMode.BALANCED; protected SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT); @@ -122,7 +119,6 @@ public class AccountViewerViewHandler { public void init() { filter = new LetteringFilterImpl(); editModel = view.getEditModel(); - //lettringSelectionModel = view.getLetteringSelectionModel(); loadComboAndRows(); editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { @@ -153,6 +149,8 @@ public class AccountViewerViewHandler { } }); + onSelectionModeChanged(selectionMode); + initializationComplete = true; updateAllEntries(); updateSoldStatus(); @@ -238,16 +236,20 @@ public class AccountViewerViewHandler { List<Entry> entries = financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); FiscalPeriod fiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()); - LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(fiscalPeriod); - LetteringFilter actualPeriodFilter = computeActualPeriodFilter(fiscalPeriod); - setPreviousSold(previousPeriodFilter); - setActualSold(fiscalPeriod, actualPeriodFilter); - - // no previous sold to add if selected starting date is same as fiscal period one - if (!DateUtils.isSameDay(filter.getDateStart(), previousPeriodFilter.getDateStart()) && CollectionUtils.isNotEmpty(entries)) { - entriesAndResume.add(getFirstLinePreviousSoldEntry(entries, previousPeriodFilter)); + if (CollectionUtils.isNotEmpty(entries)) { + // can be null if there are no fiscal period for the begin date + if (fiscalPeriod != null) { + LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(fiscalPeriod); + LetteringFilter actualPeriodFilter = computeActualPeriodFilter(fiscalPeriod); + setPreviousSold(previousPeriodFilter); + setActualSold(fiscalPeriod, actualPeriodFilter); + + // no previous sold to add if selected starting date is same as fiscal period one + if (!DateUtils.isSameDay(filter.getDateStart(), previousPeriodFilter.getDateStart()) && CollectionUtils.isNotEmpty(entries)) { + entriesAndResume.add(getFirstLinePreviousSoldEntry(entries, previousPeriodFilter)); + } + } } - entriesAndResume.addAll(entries); view.getTableModel().setValues(entriesAndResume); } @@ -304,62 +306,10 @@ public class AccountViewerViewHandler { if (log.isDebugEnabled()) { log.debug("balanceAndActions"); } - if (view.getTable().getSelectedRows().length == 0) { - onButtonModeChanged(ButtonMode.ALL); - onBalanceChanged(null); - } else if (!letteringNotExist(view.getTable().getSelectedRow())) { - - //lettred entries - onBalanceChanged(null); + onBalanceChanged(null); + if (view.getTable().getSelectedRows().length > 0 && !letteringNotExist(view.getTable().getSelectedRow()) || + view.getTable().getSelectedRows().length > 0 && !view.getAccountViewerSelectionModel().isSelectionEmpty()) { setValuesForSelectedEntries(); - - //For U.I. buttons (Lettering and unlettering) - onButtonModeChanged(ButtonMode.DELETTRED); - } else { - if (log.isDebugEnabled()) { - log.debug("unlettred entries"); - } - int[] selectedRows = view.getTable().getSelectedRows(); - if (selectedRows.length == 2) { - if (log.isDebugEnabled()) { - log.debug("2 rows selected"); - } - /*Treatment only if one of values contains decimals*/ - AccountViewerTableModel tableModel = view.getTableModel(); - Entry firstSelectedEntry = tableModel.get(selectedRows[0]); - Entry secondSelectedEntry = tableModel.get(selectedRows[1]); - - /*Get decimals*/ - BigDecimal firstSelectedEntryAmount = firstSelectedEntry.getAmount(); - BigDecimal secondSelectedEntryAmount = secondSelectedEntry.getAmount(); - - if ( secondSelectedEntry.isDebit() != firstSelectedEntry.isDebit() - && (firstSelectedEntryAmount.subtract(secondSelectedEntryAmount).abs().compareTo(BigDecimal.ZERO) >0 - && firstSelectedEntryAmount.subtract(secondSelectedEntryAmount).abs().compareTo(BigDecimal.ONE) <0) ) { - onButtonModeChanged(ButtonMode.EQUALIZED); - } - }else { - if (log.isDebugEnabled()) { - log.debug("!2 rows selected"); - } - onButtonModeChanged(ButtonMode.ALL); - } - - //Unlettred entries - onBalanceChanged(null); - //treatment unuseful if no rows are selected - if (!view.getAccountViewerSelectionModel().isSelectionEmpty()) { - if (log.isDebugEnabled()) { - log.debug("Rows selected"); - } - setValuesForSelectedEntries(); - onButtonModeChanged(ButtonMode.LETTRED); - } else { - if (log.isDebugEnabled()) { - log.debug("No Rows selected"); - } - onButtonModeChanged(ButtonMode.ALL); - } } } @@ -377,27 +327,6 @@ public class AccountViewerViewHandler { return emptyOrNull; } - public void onButtonModeChanged(ButtonMode buttonMode) { - - switch (buttonMode) { - case DELETTRED : - editModel.setLettred(false); - editModel.setUnLettred(true); - break; - case LETTRED: - editModel.setUnLettred(false); - editModel.setLettred(true); - break; - case EQUALIZED: - editModel.setEqualized(true); - break; - default: - editModel.setLettred(false); - editModel.setUnLettred(false); - editModel.setEqualized(false); - } - } - public void setValuesForSelectedEntries() { Entry selectedEntry; AccountViewerTableModel tableModel = view.getTableModel(); @@ -520,7 +449,46 @@ public class AccountViewerViewHandler { view.getAccountViewerSelectionModel().clearSelection(); } - private class DebitCreditSold { + public void setDateStart(Date date) { + filter.setDateStart(date); + updateAllEntries(); + } + + public void setDateEnd(Date date) { + filter.setDateEnd(date); + updateAllEntries(); + } + + public void setAccount(Account account) { + if (filter != null) { + filter.setAccount(account); + updateAllEntries(); + } + } + + public Account getAccount() { + Account account = null; + if (filter != null) { + account = filter.getAccount(); + } + return account; + } + + public void onSelectionModeChanged(SelectionMode selectionMode) { + + switch (selectionMode) { + case BALANCED: + view.getAccountViewerSelectionModel().setBalancedSelectionMode(true); + break; + case MANUAL: + view.getAccountViewerSelectionModel().setBalancedSelectionMode(false); + break; + default: + view.getAccountViewerSelectionModel().setBalancedSelectionMode(true); + } + } + + protected class DebitCreditSold { private BigDecimal debit; private BigDecimal credit; private BigDecimal sold; @@ -560,29 +528,4 @@ public class AccountViewerViewHandler { } } - public void setDateStart(Date date) { - filter.setDateStart(date); - updateAllEntries(); - } - - public void setDateEnd(Date date) { - filter.setDateEnd(date); - updateAllEntries(); - } - - public void setAccount(Account account) { - if (filter != null) { - filter.setAccount(account); - updateAllEntries(); - } - } - - public Account getAccount() { - Account account = null; - if (filter != null) { - account = filter.getAccount(); - } - return account; - } - } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/SelectionMode.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/SelectionMode.java new file mode 100644 index 0000000..8d69868 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/SelectionMode.java @@ -0,0 +1,29 @@ +package org.chorem.lima.ui.accountViewer; + +import static org.nuiton.i18n.I18n.t; + +/** + * Created by davidcosse on 15/09/15. + */ +public enum SelectionMode { + + BALANCED, MANUAL; + + @Override + public String toString() { + + String result = ""; + + switch (this) { + case MANUAL: + result = t("lima.filter.condition.selectionMode.manual"); + break; + case BALANCED: + result = t("lima.filter.condition.selectionMode.balanced"); + break; + } + + return result; + + } +} 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 4de6b2d..2b0a17d 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 @@ -226,6 +226,9 @@ lima.filter=Filter lima.filter.account=Add account filter lima.filter.condition.all=Valid all criteria lima.filter.condition.one=Valid at least one criteria +lima.filter.condition.selectionMode=Balance entry selection +lima.filter.condition.selectionMode.balanced=Balanced +lima.filter.condition.selectionMode.manual=Manual lima.filter.credit=Add filter on credit lima.filter.date.interval=Filter on date range lima.filter.date.one=Filter for one date @@ -542,6 +545,7 @@ lima.treasury.sie=SIE lima.treasury.systemType=System Type lima.treasury.vatNumber=VAT number lima.treasury.zipCode=Zip Code +lima.ui.dateFormat=MM/dd/yyy lima.update=Modify lima.update.shortcut=Update (Ctrl+M) lima.validate=Validate 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 7aca2bf..44e6249 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 @@ -236,6 +236,9 @@ lima.filter.account=Ajouter un filtre sur les comptes lima.filter.condition.all=Valide toutes les conditions lima.filter.condition.delete=Supprimer la condition lima.filter.condition.one=Valide au moins une condition +lima.filter.condition.selectionMode=Sélection des écritures balancées +lima.filter.condition.selectionMode.balanced=Balancée +lima.filter.condition.selectionMode.manual=Manuelle lima.filter.credit=Ajouter un filtre sur les crédits lima.filter.date=Ajouter un filtre sur les dates lima.filter.date.interval=Ajouter un filtre sur un interval de dates @@ -547,6 +550,7 @@ lima.treasury.serviceCode=Code service lima.treasury.sie=SIE lima.treasury.systemType=Régime lima.treasury.zipCode=Code Postal +lima.ui.dateFormat=dd/MM/yyy lima.update=Modifier lima.update.shortcut=Modifier (Ctrl+M) lima.validate=Valider diff --git a/lima-swing/src/main/resources/icons/action-account-viewer.png b/lima-swing/src/main/resources/icons/action-account-viewer.png new file mode 100644 index 0000000..f6f840b Binary files /dev/null and b/lima-swing/src/main/resources/icons/action-account-viewer.png differ diff --git a/lima-swing/src/main/resources/icons/action-selection-mode.png b/lima-swing/src/main/resources/icons/action-selection-mode.png new file mode 100644 index 0000000..594d3a1 Binary files /dev/null and b/lima-swing/src/main/resources/icons/action-selection-mode.png differ -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit f66d9ad9debbe23962602c929db31a53755b2c46 Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 16:57:35 2015 +0200 refs #1293 la validation des dates des date pickers est possible au Tab --- .../org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx | 4 ++-- .../lima/ui/accountViewer/AccountViewerViewHandler.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx index 75a86df..2a13c27 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx @@ -62,11 +62,11 @@ <JLabel id="beginPeriodLabel"/> <JAXXDatePicker id="beginPeriodPicker" - onActionPerformed="handler.setDateStart(beginPeriodPicker.getDate())"/> + onPropertyChange="handler.setDateStart(beginPeriodPicker.getDate())"/> <JLabel id="endPeriodLabel"/> <JAXXDatePicker id="endPeriodPicker" - onActionPerformed="handler.setDateEnd(endPeriodPicker.getDate())"/> + onPropertyChange="handler.setDateEnd(endPeriodPicker.getDate())"/> <JToolBar.Separator/> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index 7e9ceca..7cef851 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -450,13 +450,17 @@ public class AccountViewerViewHandler { } public void setDateStart(Date date) { - filter.setDateStart(date); - updateAllEntries(); + if (initializationComplete) { + filter.setDateStart(date); + updateAllEntries(); + } } public void setDateEnd(Date date) { - filter.setDateEnd(date); - updateAllEntries(); + if (initializationComplete) { + filter.setDateEnd(date); + updateAllEntries(); + } } public void setAccount(Account account) { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 22f84a3829936fce05e3e93afeb47d195096fd09 Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 16:59:42 2015 +0200 refs #1293 Correction d'une exception survenant si un nom de compte est saisie est que aucun compte ne correspond --- .../src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java | 5 +---- .../main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java index 8392137..85f0b23 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java @@ -60,7 +60,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.SortedMap; @@ -210,9 +209,7 @@ public class AccountViewHandler implements ServiceListener { for (Account account : accounts) { // find parent DefaultMutableTreeTableNode parentNode = root; - Iterator<Map.Entry<String, DefaultMutableTreeTableNode>> itNodes = nodeCache.entrySet().iterator(); - while (itNodes.hasNext()) { - Map.Entry<String, DefaultMutableTreeTableNode> entry = itNodes.next(); + for (Map.Entry<String, DefaultMutableTreeTableNode> entry : nodeCache.entrySet()) { String accountNumber = entry.getKey(); if (account.getAccountNumber().startsWith(accountNumber)) { parentNode = entry.getValue(); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java index 77db344..15f9759 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java @@ -500,7 +500,7 @@ public class LetteringViewHandler{ } public void accountComboBoxChange(PropertyChangeEvent event) { - if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM)) { + if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM) && event.getNewValue() instanceof Account) { setAccount((Account) event.getNewValue()); } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 02e31e252941a6254f6f60fec48879f5e6bc63bd Author: dcosse <cosse@codelutin.com> Date: Tue Sep 15 17:18:09 2015 +0200 refs #1293 Correction sur les dates pickers et la recherche de compte appliquée égallement à l'onglet Lettering --- .../lima/ui/accountViewer/AccountViewerViewHandler.java | 6 ++---- .../java/org/chorem/lima/ui/lettering/LetteringView.css | 8 ++++++++ .../chorem/lima/ui/lettering/LetteringViewHandler.java | 16 +++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index 7cef851..37a4ba7 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -411,10 +411,8 @@ public class AccountViewerViewHandler { } public void accountComboBoxChange(PropertyChangeEvent event) { - if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM)) { - if (event.getNewValue() != null && event.getNewValue() instanceof Account) { - setAccount((Account) event.getNewValue()); - } + if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM) && event.getNewValue() != null && event.getNewValue() instanceof Account) { + setAccount((Account) event.getNewValue()); } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css index f5c7736..520059d 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css @@ -70,11 +70,19 @@ labelFor : {beginPeriodPicker}; } +#beginPeriodPicker { + patternLayout: {handler.DATE_FORMAT}; +} + #endPeriodLabel { text : "lima.lettering.period.end"; labelFor : {endPeriodPicker}; } +#endPeriodPicker { + patternLayout: {handler.DATE_FORMAT}; +} + #letteredEntryLabel { actionIcon : "choose-entry"; labelFor : {letteredEntryComboBox}; diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java index 15f9759..67abdc7 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java @@ -80,6 +80,8 @@ import static org.nuiton.i18n.I18n.t; */ public class LetteringViewHandler{ + protected static String DATE_FORMAT = t("lima.ui.dateFormat"); + protected LetteringView view; /** Transaction service. */ @@ -500,7 +502,7 @@ public class LetteringViewHandler{ } public void accountComboBoxChange(PropertyChangeEvent event) { - if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM) && event.getNewValue() instanceof Account) { + if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM) && event.getNewValue() != null && event.getNewValue() instanceof Account) { setAccount((Account) event.getNewValue()); } } @@ -627,13 +629,17 @@ public class LetteringViewHandler{ public void setDateStart(Date date) { - filter.setDateStart(date); - updateAllEntries(); + if (initializationComplete) { + filter.setDateStart(date); + updateAllEntries(); + } } public void setDateEnd(Date date) { - filter.setDateEnd(date); - updateAllEntries(); + if (initializationComplete) { + filter.setDateEnd(date); + updateAllEntries(); + } } public void setAccount(Account account) { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 4bf2d8247fb2939c65ad0d8aa6d5d02c8ccc69f8 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 16 22:11:13 2015 +0200 refs #1293 Traduction des dates pickers --- .../lima/ui/accountViewer/AccountViewerView.css | 9 --------- .../lima/ui/accountViewer/AccountViewerView.jaxx | 4 ++++ .../ui/accountViewer/AccountViewerViewHandler.java | 22 ++++++++++++++++------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css index 25f34fe..f0bd618 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css @@ -52,20 +52,11 @@ labelFor : {beginPeriodPicker}; } -#beginPeriodPicker { - patternLayout: {handler.DATE_FORMAT}; -} - #endPeriodLabel { text : "lima.lettering.period.end"; labelFor : {endPeriodPicker}; } -#endPeriodPicker { - patternLayout: {handler.DATE_FORMAT}; -} - - #refresh { toolTipText : "lima.lettering.refresh"; actionIcon : "refresh"; diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx index 2a13c27..8b46423 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx @@ -62,10 +62,14 @@ <JLabel id="beginPeriodLabel"/> <JAXXDatePicker id="beginPeriodPicker" + constructorParams="handler.getLocale()" + formats="{handler.getDateFormat()}" onPropertyChange="handler.setDateStart(beginPeriodPicker.getDate())"/> <JLabel id="endPeriodLabel"/> <JAXXDatePicker id="endPeriodPicker" + constructorParams="handler.getLocale()" + formats="{handler.getDateFormat()}" onPropertyChange="handler.setDateEnd(endPeriodPicker.getDate())"/> <JToolBar.Separator/> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index 37a4ba7..569d1a6 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -55,10 +55,11 @@ import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.math.BigDecimal; -import java.text.SimpleDateFormat; +import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Locale; import static org.nuiton.i18n.I18n.t; @@ -94,8 +95,6 @@ public class AccountViewerViewHandler { protected SelectionMode selectionMode = SelectionMode.BALANCED; - protected SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT); - private static final Log log = LogFactory.getLog(AccountViewerViewHandler.class); @@ -159,8 +158,8 @@ public class AccountViewerViewHandler { public void updateSoldStatus() { if (initializationComplete) { view.getBalanceStatusLabel().setText(t("lima.lettering.accountViewerBalanceStatus", - dateFormatter.format(editModel.getFiscalPeriodBeginDate()), - dateFormatter.format(filter.getDateEnd()), + getDateFormat().format(editModel.getFiscalPeriodBeginDate()), + getDateFormat().format(filter.getDateEnd()), BigDecimalToString.format(editModel.getGlobalDebit()), BigDecimalToString.format(editModel.getGlobalCredit()), @@ -273,7 +272,7 @@ public class AccountViewerViewHandler { firstLineTransaction.setTransactionDate(previousSoldEndDate); Entry resumeEntry = new EntryImpl(); - resumeEntry.setDescription(String.format(t("lima.accountViewer.previousSold"), dateFormatter.format(previousSoldEndDate))); + resumeEntry.setDescription(String.format(t("lima.accountViewer.previousSold"), getDateFormat().format(previousSoldEndDate))); resumeEntry.setAmount(view.getTableModel().getPreviousPeriodSold().abs()); resumeEntry.setDebit(BigDecimal.ZERO.compareTo(view.getTableModel().getPreviousPeriodSold()) < 0); resumeEntry.setFinancialTransaction(firstLineTransaction); @@ -530,4 +529,15 @@ public class AccountViewerViewHandler { } } + protected DateFormat getDateFormat() { + Locale locale = LimaSwingConfig.getInstance().getLocale(); + DateFormat result = DateFormat.getDateInstance(DateFormat.SHORT, locale); + return result; + } + + protected Locale getLocale() { + Locale locale = LimaSwingConfig.getInstance().getLocale(); + return locale; + } + } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit fd114e2f65c4d9984b1c457d16aeaf194841a3d3 Author: dcosse <cosse@codelutin.com> Date: Fri Sep 18 10:27:41 2015 +0200 refs #1293 refactoring, modification de style --- .../ui/accountViewer/AccountViewerTableModel.java | 14 +----- .../ui/accountViewer/AccountViewerViewHandler.java | 50 ++++++++++++--------- .../lima/ui/accountViewer/SelectionMode.java | 6 +-- .../resources/i18n/lima-swing_en_GB.properties | 6 +-- .../resources/i18n/lima-swing_fr_FR.properties | 6 ++- .../resources/icons/action-fiscalPeriod-close.png | Bin 715 -> 452 bytes 6 files changed, 40 insertions(+), 42 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java index e6a3a5a..3180fbf 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java @@ -22,9 +22,7 @@ package org.chorem.lima.ui.accountViewer; -import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; -import org.chorem.lima.entity.EntryBook; import org.chorem.lima.ui.common.AbstractColumn; import org.chorem.lima.ui.common.AbstractLimaTableModel; @@ -61,19 +59,11 @@ public class AccountViewerTableModel extends AbstractLimaTableModel<Entry> { } }); - addColumn(new AbstractColumn<AccountViewerTableModel>(EntryBook.class, t("lima.table.entryBook"), false) { + addColumn(new AbstractColumn<AccountViewerTableModel>(String.class, t("lima.table.entryBook"), false) { @Override public Object getValueAt(int row) { Entry entry = tableModel.get(row); - return entry.getFinancialTransaction().getEntryBook(); - } - }); - - addColumn(new AbstractColumn<AccountViewerTableModel>(Account.class, t("lima.table.account"), false) { - @Override - public Object getValueAt(int row) { - Entry entry = tableModel.get(row); - return entry.getAccount(); + return entry.getFinancialTransaction().getEntryBook().getCode(); } }); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index 569d1a6..f74ba39 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -23,6 +23,7 @@ package org.chorem.lima.ui.accountViewer; import com.google.common.collect.Lists; +import jaxx.runtime.SwingUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; @@ -75,17 +76,13 @@ import static org.nuiton.i18n.I18n.t; */ public class AccountViewerViewHandler { - // fixme Date format should be app parameters - protected static String DATE_FORMAT = t("lima.ui.dateFormat"); - protected AccountViewerView view; - protected AccountViewerTable table; - protected FiscalPeriodService fiscalPeriodService; - protected FinancialPeriodService financialPeriodService; protected AccountService accountService; - protected FinancialTransactionService financialTransactionService; protected EntryBookService entryBookService; + protected FinancialPeriodService financialPeriodService; + protected FinancialTransactionService financialTransactionService; + protected FiscalPeriodService fiscalPeriodService; protected LetteringFilterImpl filter; @@ -93,22 +90,23 @@ public class AccountViewerViewHandler { protected ErrorHelper errorHelper; - protected SelectionMode selectionMode = SelectionMode.BALANCED; + protected SelectionMode selectionMode = SelectionMode.LETTERED; private static final Log log = LogFactory.getLog(AccountViewerViewHandler.class); - protected boolean initializationComplete; public AccountViewerViewHandler(AccountViewerView view) { initializationComplete = false; this.view = view; initShortCuts(); - financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); - fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); + accountService = LimaServiceFactory.getService(AccountService.class); - financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); entryBookService = LimaServiceFactory.getService(EntryBookService.class); + financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); + financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); + fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); + errorHelper = new ErrorHelper(LimaSwingConfig.getInstance()); } @@ -150,6 +148,11 @@ public class AccountViewerViewHandler { onSelectionModeChanged(selectionMode); + SwingUtil.fixTableColumnWidth(view.getTable(), 0, 100); + SwingUtil.fixTableColumnWidth(view.getTable(), 1, 60); + SwingUtil.fixTableColumnWidth(view.getTable(), 2, 80); + SwingUtil.fixTableColumnWidth(view.getTable(), 4, 50); + initializationComplete = true; updateAllEntries(); updateSoldStatus(); @@ -240,13 +243,9 @@ public class AccountViewerViewHandler { if (fiscalPeriod != null) { LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(fiscalPeriod); LetteringFilter actualPeriodFilter = computeActualPeriodFilter(fiscalPeriod); - setPreviousSold(previousPeriodFilter); - setActualSold(fiscalPeriod, actualPeriodFilter); - - // no previous sold to add if selected starting date is same as fiscal period one - if (!DateUtils.isSameDay(filter.getDateStart(), previousPeriodFilter.getDateStart()) && CollectionUtils.isNotEmpty(entries)) { - entriesAndResume.add(getFirstLinePreviousSoldEntry(entries, previousPeriodFilter)); - } + addPreviousSoldToModel(previousPeriodFilter); + addPreviousSoldEntryToEntries(entriesAndResume, entries, previousPeriodFilter); + addActualSoldToModel(fiscalPeriod, actualPeriodFilter); } } entriesAndResume.addAll(entries); @@ -256,6 +255,13 @@ public class AccountViewerViewHandler { onBalanceChanged(null); } + protected void addPreviousSoldEntryToEntries(List<Entry> entriesAndResume, List<Entry> entries, LetteringFilter previousPeriodFilter) { + // no previous sold to add if selected starting date is same as fiscal period one + if (!DateUtils.isSameDay(filter.getDateStart(), previousPeriodFilter.getDateStart()) && CollectionUtils.isNotEmpty(entries)) { + entriesAndResume.add(getFirstLinePreviousSoldEntry(entries, previousPeriodFilter)); + } + } + protected void addFiscalPeriodBeginDate(FiscalPeriod fiscalPeriod) { if (fiscalPeriod != null) { editModel.setFiscalPeriodBeginDate(fiscalPeriod.getBeginDate()); @@ -279,7 +285,7 @@ public class AccountViewerViewHandler { return resumeEntry; } - protected void setPreviousSold(LetteringFilter previousPeriodFilter) { + protected void addPreviousSoldToModel(LetteringFilter previousPeriodFilter) { BigDecimal previousSold; if (previousPeriodFilter == null) { previousSold = BigDecimal.ZERO; @@ -291,7 +297,7 @@ public class AccountViewerViewHandler { view.getTableModel().setPreviousPeriodSold(previousSold); } - protected void setActualSold(FiscalPeriod fiscalPeriod, LetteringFilter actualPeriodFilter) { + protected void addActualSoldToModel(FiscalPeriod fiscalPeriod, LetteringFilter actualPeriodFilter) { addFiscalPeriodBeginDate(fiscalPeriod); List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(actualPeriodFilter); DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); @@ -478,7 +484,7 @@ public class AccountViewerViewHandler { public void onSelectionModeChanged(SelectionMode selectionMode) { switch (selectionMode) { - case BALANCED: + case LETTERED: view.getAccountViewerSelectionModel().setBalancedSelectionMode(true); break; case MANUAL: diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/SelectionMode.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/SelectionMode.java index 8d69868..e2f112f 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/SelectionMode.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/SelectionMode.java @@ -7,7 +7,7 @@ import static org.nuiton.i18n.I18n.t; */ public enum SelectionMode { - BALANCED, MANUAL; + LETTERED, MANUAL; @Override public String toString() { @@ -18,8 +18,8 @@ public enum SelectionMode { case MANUAL: result = t("lima.filter.condition.selectionMode.manual"); break; - case BALANCED: - result = t("lima.filter.condition.selectionMode.balanced"); + case LETTERED: + result = t("lima.filter.condition.selectionMode.lettered"); break; } 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 2b0a17d..588228c 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 @@ -14,7 +14,7 @@ lima.account.remove.confirm.title=Delete account lima.account.remove.error.usedAccount=There are financial statement on this account lima.account.update.error.invalidAccountNumber=Invalid account number\: %1$s lima.account.update.form=Update account -lima.accountViewer.previousSold=Solde au %s +lima.accountViewer.previousSold=<html><b>On %s the sold was</b></html> lima.accounts=Accounts lima.action.commandline.help=Show help in console lima.balance=Balance @@ -227,7 +227,7 @@ lima.filter.account=Add account filter lima.filter.condition.all=Valid all criteria lima.filter.condition.one=Valid at least one criteria lima.filter.condition.selectionMode=Balance entry selection -lima.filter.condition.selectionMode.balanced=Balanced +lima.filter.condition.selectionMode.lettered=Lettered lima.filter.condition.selectionMode.manual=Manual lima.filter.credit=Add filter on credit lima.filter.date.interval=Filter on date range @@ -454,7 +454,7 @@ lima.lettering.account=Accounts lima.lettering.account.aAll=All lima.lettering.account.back=← lima.lettering.account.next=→ -lima.lettering.accountViewerBalanceStatus=<html>From %s to %s\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> - Selected entries\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> +lima.lettering.accountViewerBalanceStatus=<html>From %s to %s\: Sold is\: <b>%s - %s \= %s</b> - Selected entries sold\: <b>%s - %s \= %s</b> lima.lettering.balanceStatus= lima.lettering.balanceStatus=<html>Debit\: <b>%s</b> - Credit\: <b>%s</b> - Sold\: <b>%s</b>. Selected entries\: Debit\: <b>%s</b> - Credit\: <b>%s</b> - Sold\: <b>%s</b> lima.lettering.checkAll=All 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 44e6249..ec5b825 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 @@ -236,8 +236,8 @@ lima.filter.account=Ajouter un filtre sur les comptes lima.filter.condition.all=Valide toutes les conditions lima.filter.condition.delete=Supprimer la condition lima.filter.condition.one=Valide au moins une condition -lima.filter.condition.selectionMode=Sélection des écritures balancées -lima.filter.condition.selectionMode.balanced=Balancée +lima.filter.condition.selectionMode=Sélection des écritures lettrées +lima.filter.condition.selectionMode.lettered=Lettré lima.filter.condition.selectionMode.manual=Manuelle lima.filter.credit=Ajouter un filtre sur les crédits lima.filter.date=Ajouter un filtre sur les dates @@ -466,6 +466,8 @@ lima.lettering.account=Comptes lima.lettering.account.aAll=TOUS lima.lettering.account.back=← lima.lettering.account.next=→ +lima.lettering.accountViewerBalanceStatus=<html>Période du <b>%s</b> au <b>%s</b>\: solde \=<b>%s - %s \= %s</b> - Pour la sélection le solde est\: <b>%s - %s \= %s</b> +lima.lettering.balanceStatus=<html>Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b> lima.lettering.accountViewerBalanceStatus=<html>Pour la période du %s au %s\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> - Pour la sélection\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> lima.lettering.balanceStatus=<html>Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b>. Entrées sélectionnées\: Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b> lima.lettering.checkAll=Toutes diff --git a/lima-swing/src/main/resources/icons/action-fiscalPeriod-close.png b/lima-swing/src/main/resources/icons/action-fiscalPeriod-close.png index 08f2493..ac2fd6f 100644 Binary files a/lima-swing/src/main/resources/icons/action-fiscalPeriod-close.png and b/lima-swing/src/main/resources/icons/action-fiscalPeriod-close.png differ -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit e5bd1d96303a655ba46310d52eaae2212465f4d4 Author: dcosse <cosse@codelutin.com> Date: Sun Sep 20 00:38:53 2015 +0200 refs #1293 Ajout de la possibilité de choisir une consultation de compte pour un exercice, une période financière ou un interval de dates --- .../accountViewer/AccountViewerSelectionModel.java | 12 +- .../lima/ui/accountViewer/AccountViewerView.css | 24 +- .../lima/ui/accountViewer/AccountViewerView.jaxx | 168 +++++----- .../ui/accountViewer/AccountViewerViewHandler.java | 350 +++++++++++++-------- .../accountViewer/FinancialPeriodListRenderer.java | 68 ++++ .../chorem/lima/ui/accountViewer/PeriodChoice.java | 34 ++ .../ui/combobox/FiscalPeriodComboBoxModel.java | 2 +- .../lima/ui/common/FiscalPeriodComboBoxModel.java | 12 + .../resources/i18n/lima-swing_en_GB.properties | 3 + .../resources/i18n/lima-swing_fr_FR.properties | 3 + 10 files changed, 466 insertions(+), 210 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java index 5199a0b..4a24d0c 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerSelectionModel.java @@ -38,7 +38,7 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ protected Entry entry; protected int lineSelected; - protected boolean balancedSelectionMode; + protected boolean letteredSelectionMode; protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); public AccountViewerSelectionModel(AccountViewerTableModel letteringTableModel){ @@ -52,7 +52,7 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ @Override public void setSelectionInterval(int row, int column) { - if (balancedSelectionMode) { + if (letteredSelectionMode) { if (!letteringNotExist(row)) { //lettred entries @@ -151,12 +151,12 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ firePropertyChange(propertyName, null, newValue); } - public void setBalancedSelectionMode(boolean balancedSelectionMode) { - this.balancedSelectionMode = balancedSelectionMode; + public void setLetteredSelectionMode(boolean letteredSelectionMode) { + this.letteredSelectionMode = letteredSelectionMode; clearSelection(); } - public boolean getBalancedSelectionMode() { - return balancedSelectionMode; + public boolean getLetteredSelectionMode() { + return letteredSelectionMode; } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css index f0bd618..07b91f7 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css @@ -48,15 +48,37 @@ } #beginPeriodLabel { + visible : {PeriodChoice.DATE.equals(periodChoice)}; text : "lima.lettering.period.begin"; labelFor : {beginPeriodPicker}; } +#beginPeriodPicker { + visible : {PeriodChoice.DATE.equals(periodChoice)}; +} + #endPeriodLabel { + visible : {PeriodChoice.DATE.equals(periodChoice)}; text : "lima.lettering.period.end"; labelFor : {endPeriodPicker}; } +#endPeriodPicker { + visible : {PeriodChoice.DATE.equals(periodChoice)}; +} + +#fiscalPeriodComboBox { + visible : {PeriodChoice.FISCAL_PERIOD.equals(periodChoice)}; + toolTipText : "lima.entries.fiscalYear"; + renderer : "{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"; +} + +#financialPeriodComboBox { + preferredSize : {new Dimension(200, 22)}; + toolTipText : "lima.entries.financialPeriod"; + renderer : "{new org.chorem.lima.ui.accountViewer.FinancialPeriodListRenderer()}"; +} + #refresh { toolTipText : "lima.lettering.refresh"; actionIcon : "refresh"; @@ -69,5 +91,5 @@ #balanceStatusLabel { horizontalTextPosition:{JLabel.RIGHT}; - border: {BorderFactory.createEmptyBorder(0, 0, 0, 20)} + border: {BorderFactory.createEmptyBorder(0, 0, 0, 20)}; } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx index 8b46423..e615d60 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx @@ -20,83 +20,103 @@ <JPanel layout="{new BorderLayout()}"> - <import> - java.awt.Dimension - org.chorem.lima.util.WrapToolBarLayout - org.chorem.lima.ui.common.FinancialPeriodComboBoxModel - org.chorem.lima.util.BigDecimalToString - org.chorem.lima.ui.lettering.TypeEntry - org.chorem.lima.entity.Account - javax.swing.ListSelectionModel - org.jdesktop.swingx.JXDatePicker - static org.nuiton.i18n.I18n.t - org.chorem.lima.ui.combobox.AccountComboBox - </import> - - <AccountViewerViewHandler id="handler" constructorParams="this"/> - - <AccountViewerEditModel id='editModel'/> - - <script> - <![CDATA[ + <import> + java.awt.Dimension + org.chorem.lima.util.WrapToolBarLayout + org.chorem.lima.ui.common.FinancialPeriodComboBoxModel + org.chorem.lima.util.BigDecimalToString + org.chorem.lima.ui.lettering.TypeEntry + org.chorem.lima.entity.Account + javax.swing.ListSelectionModel + org.jdesktop.swingx.JXDatePicker + static org.nuiton.i18n.I18n.t + org.chorem.lima.ui.combobox.AccountComboBox + org.chorem.lima.ui.LimaRendererUtil + org.chorem.lima.entity.FinancialPeriod + </import> + + <AccountViewerViewHandler id="handler" constructorParams="this"/> + + <AccountViewerEditModel id='editModel'/> + + <script> + <![CDATA[ void $afterCompleteSetup() { handler.init(); } ]]> - </script> - - <JToolBar styleClass="toolbar" - constraints="BorderLayout.PAGE_START" - layout="{new WrapToolBarLayout()}"> - - <JLabel id="accountLabel"/> - <AccountComboBox id="accountComboBox" - constraints="BorderLayout.CENTER" - onPropertyChange="{getHandler().accountComboBoxChange(event);}"/> - <JButton id="back" - onActionPerformed="handler.back(accountComboBox)"/> - <JButton id="next" - onActionPerformed="handler.next(accountComboBox)"/> - - <JToolBar.Separator/> - - <JLabel id="beginPeriodLabel"/> - <JAXXDatePicker id="beginPeriodPicker" - constructorParams="handler.getLocale()" - formats="{handler.getDateFormat()}" - onPropertyChange="handler.setDateStart(beginPeriodPicker.getDate())"/> - - <JLabel id="endPeriodLabel"/> - <JAXXDatePicker id="endPeriodPicker" - constructorParams="handler.getLocale()" - formats="{handler.getDateFormat()}" - onPropertyChange="handler.setDateEnd(endPeriodPicker.getDate())"/> - - <JToolBar.Separator/> - - <JLabel id='balancedSelectionModeLabel' actionIcon='selection-mode'/> - <EnumEditor id='balancedSelectionMode' - genericType='SelectionMode' - constructorParams='SelectionMode.class' - onItemStateChanged="handler.onSelectionModeChanged(balancedSelectionMode.getSelectedItem())" /> - - <JButton id="refresh" - onActionPerformed="handler.updateAllEntries()"/> - - </JToolBar> - <JScrollPane constraints="BorderLayout.CENTER"> - <AccountViewerTableModel id="tableModel"/> - <AccountViewerSelectionModel id='accountViewerSelectionModel' constructorParams='tableModel' - onValueChanged="handler.balanceAndActions()"/> - - <AccountViewerTable id="table" - constructorParams="handler" - model="{tableModel}" - selectionModel="{accountViewerSelectionModel}"/> - </JScrollPane> - - <JPanel constraints="BorderLayout.SOUTH" layout="{new BorderLayout()}"> - <JLabel id='balanceStatusLabel' constraints="BorderLayout.EAST"/> - </JPanel> + </script> + + <JToolBar styleClass="toolbar" + constraints="BorderLayout.PAGE_START" + layout="{new WrapToolBarLayout()}"> + + <JLabel id="accountLabel"/> + <AccountComboBox id="accountComboBox" + constraints="BorderLayout.CENTER" + onPropertyChange="handler.onAccountChange(event)"/> + + <JButton id="back" + onActionPerformed="handler.onBackChange(accountComboBox)"/> + <JButton id="next" + onActionPerformed="handler.onNextChange(accountComboBox)"/> + + <JToolBar.Separator/> + + <JLabel id='periodChoiceLabel' actionIcon='choose-fiscal-year'/> + <EnumEditor id='periodChoice' + genericType='PeriodChoice' + constructorParams='PeriodChoice.class' + onItemStateChanged="handler.onPeriodChoiceChanged(periodChoice.getSelectedItem())"/> + + <JLabel id="beginPeriodLabel"/> + + <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> + <JComboBox id="fiscalPeriodComboBox" + model="{fiscalPeriodComboBoxModel}" + onItemStateChanged="handler.onFiscalPeriodChange(event)"/> + + <org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodComboBoxModel"/> + <JComboBox id="financialPeriodComboBox" + model="{financialPeriodComboBoxModel}" + onItemStateChanged="handler.onFinancialPeriodChange(event)"/> + + <JAXXDatePicker id="beginPeriodPicker" + constructorParams="handler.getLocale()" + formats="{handler.getDateFormat()}" + onPropertyChange="handler.onDateStartChange(beginPeriodPicker.getDate())"/> + + <JLabel id="endPeriodLabel"/> + + <JAXXDatePicker id="endPeriodPicker" + constructorParams="handler.getLocale()" + formats="{handler.getDateFormat()}" + onPropertyChange="handler.onDateEndChange(endPeriodPicker.getDate())"/> + <JToolBar.Separator/> + + <JLabel id='selectionModeLabel' actionIcon='selection-mode'/> + <EnumEditor id='letteredSelectionMode' + genericType='SelectionMode' + constructorParams='SelectionMode.class' + onItemStateChanged="handler.onSelectionModeChanged(letteredSelectionMode.getSelectedItem())"/> + + <JButton id="refresh" + onActionPerformed="handler.updateAllEntries(null)"/> + + </JToolBar> + <JScrollPane constraints="BorderLayout.CENTER"> + <AccountViewerTableModel id="tableModel"/> + <AccountViewerSelectionModel id='accountViewerSelectionModel' constructorParams='tableModel' + onValueChanged="handler.balanceAndActions()"/> + + <AccountViewerTable id="table" + constructorParams="handler" + model="{tableModel}" + selectionModel="{accountViewerSelectionModel}"/> + </JScrollPane> + + <JPanel constraints="BorderLayout.SOUTH" layout="{new BorderLayout()}"> + <JLabel id='balanceStatusLabel' constraints="BorderLayout.EAST"/> + </JPanel> </JPanel> \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index f74ba39..50a17a0 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -40,6 +40,7 @@ import org.chorem.lima.business.api.FiscalPeriodService; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryImpl; +import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.entity.FiscalPeriod; @@ -58,7 +59,9 @@ import java.beans.PropertyChangeListener; import java.math.BigDecimal; import java.text.DateFormat; import java.util.Calendar; +import java.util.Collection; import java.util.Date; +import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -116,7 +119,7 @@ public class AccountViewerViewHandler { public void init() { filter = new LetteringFilterImpl(); editModel = view.getEditModel(); - loadComboAndRows(); + initViewWithDefaultFinancialPeriod(); editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { @Override @@ -154,27 +157,10 @@ public class AccountViewerViewHandler { SwingUtil.fixTableColumnWidth(view.getTable(), 4, 50); initializationComplete = true; - updateAllEntries(); + updateAllEntries(null); updateSoldStatus(); } - public void updateSoldStatus() { - if (initializationComplete) { - view.getBalanceStatusLabel().setText(t("lima.lettering.accountViewerBalanceStatus", - getDateFormat().format(editModel.getFiscalPeriodBeginDate()), - getDateFormat().format(filter.getDateEnd()), - - BigDecimalToString.format(editModel.getGlobalDebit()), - BigDecimalToString.format(editModel.getGlobalCredit()), - BigDecimalToString.format(editModel.getGlobalSold()), - - BigDecimalToString.format(editModel.getDebit()), - BigDecimalToString.format(editModel.getCredit()), - BigDecimalToString.format(editModel.getSold()))); - } - } - - protected void initShortCuts() { InputMap inputMap= view.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); @@ -193,40 +179,160 @@ public class AccountViewerViewHandler { @Override public void actionPerformed(ActionEvent e) { - updateAllEntries(); + updateAllEntries(null); } }); } - public void loadComboAndRows(){ + public void onAccountChange(PropertyChangeEvent event) { + if (initializationComplete) { + if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM) && event.getNewValue() != null && event.getNewValue() instanceof Account) { + setAccount((Account) event.getNewValue()); + } + } + } - //By default, we have the beginning of the fiscal period (Or of current - //date if no fiscal period) and the end of the current fiscal period - FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); - Date defaultDateBegFiscalPeriod, defaultDateEndCurrent; + protected void onPeriodChoiceChanged(PeriodChoice periodChoice) { + if (initializationComplete) { + switch (periodChoice) { + case FINANCIAL_PERIOD: + view.getFiscalPeriodComboBox().setVisible(false); + view.getFinancialPeriodComboBox().setVisible(true); + view.getBeginPeriodPicker().setVisible(false); + view.getEndPeriodPicker().setVisible(false); + initViewWithDefaultFinancialPeriod(); + break; + case FISCAL_PERIOD: + view.getFiscalPeriodComboBox().setVisible(true); + view.getFinancialPeriodComboBox().setVisible(false); + view.getBeginPeriodPicker().setVisible(false); + view.getEndPeriodPicker().setVisible(false); + initFiscalPeriodModel(); + break; + case DATE: + view.getFiscalPeriodComboBox().setVisible(false); + view.getFinancialPeriodComboBox().setVisible(false); + view.getBeginPeriodPicker().setVisible(true); + view.getEndPeriodPicker().setVisible(true); + break; + } + updateAllEntries(null); + } + } - Calendar calendar = Calendar.getInstance(); - int lastCurrentMonthDay = calendar.getActualMaximum(Calendar.DATE); - int firstCurrentMonthDay = calendar.getActualMinimum(Calendar.DATE); + /** + * Select previous value in combo box. + * + * @param accountComboBox account combo box + */ + public void onBackChange(AccountComboBox accountComboBox) { + if (initializationComplete) { + JComboBox comboBox = accountComboBox.getCombobox(); + int row = comboBox.getSelectedIndex(); - if (fiscalPeriod != null){ - defaultDateBegFiscalPeriod = fiscalPeriod.getBeginDate(); - defaultDateEndCurrent = fiscalPeriod.getEndDate(); - } else{ - defaultDateBegFiscalPeriod = DateUtils.setDays(new Date(), firstCurrentMonthDay); - defaultDateEndCurrent = DateUtils.setDays(new Date(), lastCurrentMonthDay); + if (row > 0) { + comboBox.setSelectedIndex(row - 1); + } + view.getAccountViewerSelectionModel().clearSelection(); } + } - view.getBeginPeriodPicker().setDate(defaultDateBegFiscalPeriod); - view.getEndPeriodPicker().setDate(defaultDateEndCurrent); + /** + * Select next value in combo box. + * + * @param accountComboBox combo box + */ + public void onNextChange(AccountComboBox accountComboBox) { + if (initializationComplete) { + JComboBox comboBox = accountComboBox.getCombobox(); + int size = comboBox.getItemCount(); + int row = comboBox.getSelectedIndex(); - editModel.setFiscalPeriodBeginDate(defaultDateBegFiscalPeriod); + if (row < size - 1) { + comboBox.setSelectedIndex(row + 1); + } + view.getAccountViewerSelectionModel().clearSelection(); + } + } - filter.setDateStart(defaultDateBegFiscalPeriod); - filter.setDateEnd(defaultDateEndCurrent); + protected void onFiscalPeriodChange(java.awt.event.ItemEvent event) { + if (initializationComplete) { + FiscalPeriod fiscalPeriod = (FiscalPeriod) event.getItem(); + updateAllEntriesForFiscalPeriodChange(fiscalPeriod); + } } - public void updateAllEntries() { + + protected void onFinancialPeriodChange(java.awt.event.ItemEvent event) { + if (initializationComplete) { + FinancialPeriod financialPeriod = (FinancialPeriod) event.getItem(); + updateAllEntriesForFinancialPeriodChange(financialPeriod); + } + } + + public void onDateStartChange(Date date) { + if (initializationComplete) { + filter.setDateStart(date); + updateAllEntriesForDateChange(); + } + } + + public void onDateEndChange(Date date) { + if (initializationComplete) { + filter.setDateEnd(date); + updateAllEntriesForDateChange(); + } + } + + public void onSelectionModeChanged(SelectionMode selectionMode) { + + switch (selectionMode) { + case LETTERED: + view.getAccountViewerSelectionModel().setLetteredSelectionMode(true); + break; + case MANUAL: + view.getAccountViewerSelectionModel().setLetteredSelectionMode(false); + break; + default: + view.getAccountViewerSelectionModel().setLetteredSelectionMode(true); + } + } + + public void updateSoldStatus() { + if (initializationComplete) { + view.getBalanceStatusLabel().setText(t("lima.lettering.accountViewerBalanceStatus", + getDateFormat().format(editModel.getFiscalPeriodBeginDate()), + getDateFormat().format(filter.getDateEnd()), + + BigDecimalToString.format(editModel.getGlobalDebit()), + BigDecimalToString.format(editModel.getGlobalCredit()), + BigDecimalToString.format(editModel.getGlobalSold()), + + BigDecimalToString.format(editModel.getDebit()), + BigDecimalToString.format(editModel.getCredit()), + BigDecimalToString.format(editModel.getSold()))); + } + } + + + public void updateAllEntriesForFiscalPeriodChange(FiscalPeriod fiscalPeriod) { + filter.setDateStart(fiscalPeriod.getBeginDate()); + filter.setDateEnd(fiscalPeriod.getEndDate()); + + updateAllEntries(fiscalPeriod); + } + + public void updateAllEntriesForFinancialPeriodChange(FinancialPeriod financialPeriod) { + filter.setDateStart(financialPeriod.getBeginDate()); + filter.setDateEnd(financialPeriod.getEndDate()); + updateAllEntries(null); + } + + public void updateAllEntriesForDateChange() { + updateAllEntries(null); + } + + public void updateAllEntries(FiscalPeriod fiscalPeriod) { if (initializationComplete && filter.getAccount() != null @@ -236,7 +342,7 @@ public class AccountViewerViewHandler { List<Entry> entriesAndResume = Lists.newArrayList(); List<Entry> entries = financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); - FiscalPeriod fiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()); + fiscalPeriod = fiscalPeriod == null ? fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()) : fiscalPeriod; if (CollectionUtils.isNotEmpty(entries)) { // can be null if there are no fiscal period for the begin date @@ -255,6 +361,58 @@ public class AccountViewerViewHandler { onBalanceChanged(null); } + public void initFiscalPeriodModel() { + FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); + if (fiscalPeriod != null) { + view.getFiscalPeriodComboBox().setSelectedItem(fiscalPeriod); + view.getBeginPeriodPicker().setDate(fiscalPeriod.getBeginDate()); + view.getEndPeriodPicker().setDate(fiscalPeriod.getEndDate()); + } + } + + public void initViewWithDefaultFinancialPeriod() { + List<FinancialPeriod> financialPeriods = financialPeriodService.getAllFinancialPeriods(); + view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); + + FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); + + FinancialPeriod defaultFinancialPeriod = getDefaultFinancialPeriod(financialPeriods, fiscalPeriod); + + Calendar calendar = Calendar.getInstance(); + int lastCurrentMonthDay = calendar.getActualMaximum(Calendar.DATE); + int firstCurrentMonthDay = calendar.getActualMinimum(Calendar.DATE); + + Date defaultDateBeginFinancialPeriod, defaultDateEndCurrent; + defaultDateBeginFinancialPeriod = defaultFinancialPeriod == null ? DateUtils.setDays(new Date(), firstCurrentMonthDay) : defaultFinancialPeriod.getBeginDate(); + defaultDateEndCurrent = defaultFinancialPeriod == null ? DateUtils.setDays(new Date(), lastCurrentMonthDay) : defaultFinancialPeriod.getEndDate(); + + view.getFinancialPeriodComboBoxModel().setSelectedItem(defaultFinancialPeriod); + + view.getBeginPeriodPicker().setDate(defaultDateBeginFinancialPeriod); + view.getEndPeriodPicker().setDate(defaultDateEndCurrent); + + filter.setDateStart(defaultDateBeginFinancialPeriod); + filter.setDateEnd(defaultDateEndCurrent); + + editModel.setFiscalPeriodBeginDate(fiscalPeriod != null ? fiscalPeriod.getBeginDate() : defaultDateBeginFinancialPeriod); + } + + protected FinancialPeriod getDefaultFinancialPeriod(List<FinancialPeriod> financialPeriods, FiscalPeriod fiscalPeriod) { + FinancialPeriod defaultFinancialPeriod = null; + + if ((fiscalPeriod != null && fiscalPeriod.getFinancialPeriod() != null)) { + + Collection<FinancialPeriod> fiscalPeriodFinancialPeriods = financialPeriodService.getFinancialPeriods(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); + Iterator<FinancialPeriod> financialPeriodIterator = fiscalPeriodFinancialPeriods.iterator(); + if (financialPeriodIterator.hasNext()) { + defaultFinancialPeriod = financialPeriodIterator.next(); + } + } + + defaultFinancialPeriod = defaultFinancialPeriod != null ? defaultFinancialPeriod : CollectionUtils.isNotEmpty(financialPeriods) ? financialPeriods.get(0) : null; + return defaultFinancialPeriod; + } + protected void addPreviousSoldEntryToEntries(List<Entry> entriesAndResume, List<Entry> entries, LetteringFilter previousPeriodFilter) { // no previous sold to add if selected starting date is same as fiscal period one if (!DateUtils.isSameDay(filter.getDateStart(), previousPeriodFilter.getDateStart()) && CollectionUtils.isNotEmpty(entries)) { @@ -382,13 +540,6 @@ public class AccountViewerViewHandler { } } - protected Calendar getDayMinus1Calendar(LetteringFilter previousPeriodFilter) { - Calendar cal = Calendar.getInstance(); - cal.setTime(previousPeriodFilter.getDateEnd()); - cal.add(Calendar.DATE, -1); - return cal; - } - protected LetteringFilter computePreviousPeriodFilter(FiscalPeriod fiscalPeriod) { LetteringFilter previousPeriodFilter = null; @@ -415,86 +566,6 @@ public class AccountViewerViewHandler { return actualPeriodFilter; } - public void accountComboBoxChange(PropertyChangeEvent event) { - if (event.getPropertyName().equals(AccountComboBox.PROPERTY_SELECTED_ITEM) && event.getNewValue() != null && event.getNewValue() instanceof Account) { - setAccount((Account) event.getNewValue()); - } - } - - /** - * Select previous value in combo box. - * - * @param accountComboBox account combo box - */ - public void back(AccountComboBox accountComboBox) { - JComboBox comboBox = accountComboBox.getCombobox(); - int row = comboBox.getSelectedIndex(); - - if (row > 0) { - comboBox.setSelectedIndex(row - 1); - } - view.getAccountViewerSelectionModel().clearSelection(); - } - - /** - * Select next value in combo box. - * - * @param accountComboBox combo box - */ - public void next(AccountComboBox accountComboBox) { - JComboBox comboBox = accountComboBox.getCombobox(); - int size = comboBox.getItemCount(); - int row = comboBox.getSelectedIndex(); - - if (row < size - 1) { - comboBox.setSelectedIndex(row + 1); - } - view.getAccountViewerSelectionModel().clearSelection(); - } - - public void setDateStart(Date date) { - if (initializationComplete) { - filter.setDateStart(date); - updateAllEntries(); - } - } - - public void setDateEnd(Date date) { - if (initializationComplete) { - filter.setDateEnd(date); - updateAllEntries(); - } - } - - public void setAccount(Account account) { - if (filter != null) { - filter.setAccount(account); - updateAllEntries(); - } - } - - public Account getAccount() { - Account account = null; - if (filter != null) { - account = filter.getAccount(); - } - return account; - } - - public void onSelectionModeChanged(SelectionMode selectionMode) { - - switch (selectionMode) { - case LETTERED: - view.getAccountViewerSelectionModel().setBalancedSelectionMode(true); - break; - case MANUAL: - view.getAccountViewerSelectionModel().setBalancedSelectionMode(false); - break; - default: - view.getAccountViewerSelectionModel().setBalancedSelectionMode(true); - } - } - protected class DebitCreditSold { private BigDecimal debit; private BigDecimal credit; @@ -535,6 +606,29 @@ public class AccountViewerViewHandler { } } + public void setAccount(Account account) { + if (filter != null) { + filter.setAccount(account); + updateAllEntries(null); + } + } + + public Account getAccount() { + Account account = null; + if (filter != null) { + account = filter.getAccount(); + } + return account; + } + + protected Calendar getDayMinus1Calendar(LetteringFilter previousPeriodFilter) { + Calendar cal = Calendar.getInstance(); + cal.setTime(previousPeriodFilter.getDateEnd()); + cal.add(Calendar.DATE, -1); + return cal; + } + + protected DateFormat getDateFormat() { Locale locale = LimaSwingConfig.getInstance().getLocale(); DateFormat result = DateFormat.getDateInstance(DateFormat.SHORT, locale); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/FinancialPeriodListRenderer.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/FinancialPeriodListRenderer.java new file mode 100644 index 0000000..cb1498c --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/FinancialPeriodListRenderer.java @@ -0,0 +1,68 @@ +/* + * #%L + * Lima :: Swing + * %% + * Copyright (C) 2012 Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.accountViewer; + +import org.chorem.lima.LimaSwingConfig; +import org.chorem.lima.entity.FinancialPeriod; + +import javax.swing.*; +import java.awt.*; +import java.text.DateFormat; +import java.util.Locale; + +/** + * Financial period list renderer. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FinancialPeriodListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -1L; + + // afiche le mois en lettre et le numero de la période, pour eviter les confusions entre deux mois identique pour des exercice de plus de 12 mois + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + FinancialPeriod financialPeriod = (FinancialPeriod)value; + Object newValue = financialPeriod; + if (financialPeriod != null) { + newValue = String.format("%s - %s", getDateFormat().format(financialPeriod.getBeginDate()), getDateFormat().format(financialPeriod.getEndDate())); + } + return super.getListCellRendererComponent(list, newValue, index, isSelected, + cellHasFocus); + } + + protected DateFormat getDateFormat() { + Locale locale = LimaSwingConfig.getInstance().getLocale(); + DateFormat result = DateFormat.getDateInstance(DateFormat.SHORT, locale); + return result; + } + +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/PeriodChoice.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/PeriodChoice.java new file mode 100644 index 0000000..cc8ade3 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/PeriodChoice.java @@ -0,0 +1,34 @@ +package org.chorem.lima.ui.accountViewer; + +import static org.nuiton.i18n.I18n.t; + +/** + * Created by davidcosse on 15/09/15. + */ +public enum PeriodChoice { + + FINANCIAL_PERIOD, FISCAL_PERIOD, DATE; + + @Override + public String toString() { + + String result; + + switch (this) { + case FINANCIAL_PERIOD: + result = t("lima.filter.condition.periodChoice.financialPeriod"); + break; + case FISCAL_PERIOD: + result = t("lima.filter.condition.periodChoice.fiscalPeriod"); + break; + case DATE: + result = t("lima.filter.condition.periodChoice.date"); + break; + default: + result = t("lima.filter.condition.periodChoice.financialPeriod"); + } + + return result; + + } +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java index 9a2a118..36986d0 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java @@ -86,7 +86,7 @@ public class FiscalPeriodComboBoxModel extends AbstractListModel implements Comb return selectedFiscalPeriod; } - //get unblocked fiscal periods data list + //get unblocked fiscal periods data list public List<FiscalPeriod> getDataList() { List<FiscalPeriod> result = fiscalPeriodService.getAllUnblockedFiscalPeriods(); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java index d0ff510..27c38f2 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java @@ -38,4 +38,16 @@ public class FiscalPeriodComboBoxModel extends GenericComboBoxModel<FiscalPeriod /** serialVersionUID. */ private static final long serialVersionUID = 3017195549616278980L; + /*By default, selection of the first financial period (Because a +* transaction concern one financial period) +*/ + @Override + public Object getElementAt(int index) { + if (getSelectedItem() == null){ + setSelectedItem(objects.get(0)); + return objects.get(0); + } + return objects.get(index); + } + } 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 588228c..9ad9420 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 @@ -226,6 +226,9 @@ lima.filter=Filter lima.filter.account=Add account filter lima.filter.condition.all=Valid all criteria lima.filter.condition.one=Valid at least one criteria +lima.filter.condition.periodChoice.date= +lima.filter.condition.periodChoice.financialPeriod= +lima.filter.condition.periodChoice.fiscalPeriod= lima.filter.condition.selectionMode=Balance entry selection lima.filter.condition.selectionMode.lettered=Lettered lima.filter.condition.selectionMode.manual=Manual 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 ec5b825..906e4aa 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 @@ -236,6 +236,9 @@ lima.filter.account=Ajouter un filtre sur les comptes lima.filter.condition.all=Valide toutes les conditions lima.filter.condition.delete=Supprimer la condition lima.filter.condition.one=Valide au moins une condition +lima.filter.condition.periodChoice.date=Dates +lima.filter.condition.periodChoice.financialPeriod=Périodes fiscales +lima.filter.condition.periodChoice.fiscalPeriod=Execrices lima.filter.condition.selectionMode=Sélection des écritures lettrées lima.filter.condition.selectionMode.lettered=Lettré lima.filter.condition.selectionMode.manual=Manuelle -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 397fdb36c23d6c371f7198eb4036ea8ce66d7577 Author: dcosse <cosse@codelutin.com> Date: Sun Sep 20 00:49:12 2015 +0200 refs #1293 correction i18n --- lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties | 6 +++--- lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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 9ad9420..da2a007 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 @@ -226,9 +226,9 @@ lima.filter=Filter lima.filter.account=Add account filter lima.filter.condition.all=Valid all criteria lima.filter.condition.one=Valid at least one criteria -lima.filter.condition.periodChoice.date= -lima.filter.condition.periodChoice.financialPeriod= -lima.filter.condition.periodChoice.fiscalPeriod= +lima.filter.condition.periodChoice.date=Date interval +lima.filter.condition.periodChoice.financialPeriod=Financial period +lima.filter.condition.periodChoice.fiscalPeriod=Fiscal period lima.filter.condition.selectionMode=Balance entry selection lima.filter.condition.selectionMode.lettered=Lettered lima.filter.condition.selectionMode.manual=Manual 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 906e4aa..fbd0d0d 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 @@ -236,9 +236,9 @@ lima.filter.account=Ajouter un filtre sur les comptes lima.filter.condition.all=Valide toutes les conditions lima.filter.condition.delete=Supprimer la condition lima.filter.condition.one=Valide au moins une condition -lima.filter.condition.periodChoice.date=Dates -lima.filter.condition.periodChoice.financialPeriod=Périodes fiscales -lima.filter.condition.periodChoice.fiscalPeriod=Execrices +lima.filter.condition.periodChoice.date=Interval de Dates +lima.filter.condition.periodChoice.financialPeriod=Période Financière +lima.filter.condition.periodChoice.fiscalPeriod=Execrice lima.filter.condition.selectionMode=Sélection des écritures lettrées lima.filter.condition.selectionMode.lettered=Lettré lima.filter.condition.selectionMode.manual=Manuelle -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 754b9ae84e41668e2392e2fcb21abb878f149106 Author: dcosse <cosse@codelutin.com> Date: Tue Sep 22 17:58:13 2015 +0200 refs #1293 modification concernnt l'affichage des infos résumées --- .../lima/business/api/FinancialPeriodService.java | 6 +- .../business/ejb/FinancialPeriodServiceImpl.java | 13 +- .../lima/business/ejb/ReportServiceImpl.java | 2 +- .../report/GeneralEntryBookReportServiceImpl.java | 2 +- .../ProvisionalEntryBookReportServiceImpl.java | 2 +- .../lima/entity/FinancialPeriodTopiaDao.java | 10 +- .../lima/business/FiscalPeriodServiceImplTest.java | 4 +- .../lima/ui/accountViewer/AccountViewerFilter.java | 41 +++ .../ui/accountViewer/AccountViewerTableModel.java | 10 - .../lima/ui/accountViewer/AccountViewerView.css | 77 ++++- .../lima/ui/accountViewer/AccountViewerView.jaxx | 106 +++++-- .../ui/accountViewer/AccountViewerViewHandler.java | 322 ++++++++++----------- .../accountViewer/FinancialPeriodListRenderer.java | 68 ----- .../FinancialTransactionViewHandler.java | 4 +- .../resources/i18n/lima-swing_en_GB.properties | 2 + .../resources/i18n/lima-swing_fr_FR.properties | 6 +- 16 files changed, 387 insertions(+), 288 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java index 3b078dd..4ed0a10 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java @@ -58,6 +58,8 @@ public interface FinancialPeriodService { List<FinancialPeriod> getAllFinancialPeriods(); - List<FinancialPeriod> getFinancialPeriods(Date beginDate, - Date endDate); + FinancialPeriod getFinancialForDate(Date date); + + List<FinancialPeriod> getFinancialPeriodsWithBeginDateWithin(Date beginDateFirst, + Date endDateLast); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java index cabbf73..02c2df2 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java @@ -62,12 +62,21 @@ public class FinancialPeriodServiceImpl extends AbstractLimaService implements F return result; } + @Override + public FinancialPeriod getFinancialForDate(Date date) { + + FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao(); + FinancialPeriod result = financialPeriodTopiaDao.findByDate(date); + + return result; + } + /** @return all financial period from a fiscal period */ @Override - public List<FinancialPeriod> getFinancialPeriods(Date beginDate, Date endDate) { + public List<FinancialPeriod> getFinancialPeriodsWithBeginDateWithin(Date beginDateFirst, Date endDateLast) { FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao(); - List<FinancialPeriod> result = financialPeriodTopiaDao.findByDates(beginDate, endDate); + List<FinancialPeriod> result = financialPeriodTopiaDao.findForBeginDateBetween(beginDateFirst, endDateLast); return result; } diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java index 04031f4..ce9e57e 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java @@ -406,7 +406,7 @@ public class ReportServiceImpl extends AbstractLimaService implements ReportServ AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao(); List<Account> accountsList; //gets all financial periods from the fiscal period - List<FinancialPeriod> financialPeriod = financialPeriodService.getFinancialPeriods( + List<FinancialPeriod> financialPeriod = financialPeriodService.getFinancialPeriodsWithBeginDateWithin( fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); for (FinancialPeriod fp : financialPeriod) { list.add(fp); diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/GeneralEntryBookReportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/GeneralEntryBookReportServiceImpl.java index bf4bd1e..0e843c3 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/GeneralEntryBookReportServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/GeneralEntryBookReportServiceImpl.java @@ -106,7 +106,7 @@ public class GeneralEntryBookReportServiceImpl extends AbstractLimaService imple try { if (beginDate != null && endDate != null) { - List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriods(beginDate, endDate); + List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(beginDate, endDate); BigDecimal amountDebit = BigDecimal.ZERO; BigDecimal amountCredit = BigDecimal.ZERO; diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/ProvisionalEntryBookReportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/ProvisionalEntryBookReportServiceImpl.java index 206f478..c8a10f8 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/report/ProvisionalEntryBookReportServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/report/ProvisionalEntryBookReportServiceImpl.java @@ -102,7 +102,7 @@ public class ProvisionalEntryBookReportServiceImpl implements ProvisionalEntryBo BigDecimal documentReportDebit = BigDecimal.ZERO; BigDecimal documentReportCredit = BigDecimal.ZERO; - List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriods(beginDate, endDate); + List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(beginDate, endDate); List<EntryBook> entryBooks; diff --git a/lima-business/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java b/lima-business/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java index e951ade..9d9a77d 100644 --- a/lima-business/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java +++ b/lima-business/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java @@ -49,15 +49,15 @@ public class FinancialPeriodTopiaDao extends AbstractFinancialPeriodTopiaDao<Fin /** * Return all FinancialPeriod with begin date between two given dates. * - * @param beginDate period begin date - * @param endDate period end date + * @param beginDateFirst period begin date + * @param beginDateLast period end date * @return FinancialPeriod for {@code date} */ - public List<FinancialPeriod> findByDates(Date beginDate, Date endDate) { + public List<FinancialPeriod> findForBeginDateBetween(Date beginDateFirst, Date beginDateLast) { HqlAndParametersBuilder<FinancialPeriod> builder = newHqlAndParametersBuilder(); - builder.addGreaterOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, beginDate); - builder.addLowerOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, endDate); + builder.addGreaterOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, beginDateFirst); + builder.addLowerOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, beginDateLast); builder.setOrderByArguments(FinancialPeriod.PROPERTY_BEGIN_DATE); List<FinancialPeriod> financialPeriod = findAll(builder.getHql(), builder.getHqlParameters()); diff --git a/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java b/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java index 7a74550..08168f9 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java @@ -293,7 +293,7 @@ public class FiscalPeriodServiceImplTest extends AbstractLimaTest { Assert.assertEquals(1, unblockedFiscalPeriods.size()); Assert.assertEquals(true, unblockedFiscalPeriods.contains(periodSave2)); - for (FinancialPeriod financialPeriod : financialPeriodService.getFinancialPeriods(periodSave1.getBeginDate(), periodSave1.getEndDate())) { + for (FinancialPeriod financialPeriod : financialPeriodService.getFinancialPeriodsWithBeginDateWithin(periodSave1.getBeginDate(), periodSave1.getEndDate())) { Assert.assertEquals(true, financialPeriod.isLocked()); for (EntryBook entryBook : entryBookService.getAllEntryBooks()) { ClosedPeriodicEntryBook closedPeriodicEntryBook = @@ -509,7 +509,7 @@ public class FiscalPeriodServiceImplTest extends AbstractLimaTest { Assert.assertEquals(1, unblockedFiscalPeriods.size()); Assert.assertEquals(true, unblockedFiscalPeriods.contains(periodSave2)); - for (FinancialPeriod financialPeriod : financialPeriodService.getFinancialPeriods(periodSave1.getBeginDate(), periodSave1.getEndDate())) { + for (FinancialPeriod financialPeriod : financialPeriodService.getFinancialPeriodsWithBeginDateWithin(periodSave1.getBeginDate(), periodSave1.getEndDate())) { Assert.assertEquals(true, financialPeriod.isLocked()); for (EntryBook entryBook : entryBookService.getAllEntryBooks()) { ClosedPeriodicEntryBook closedPeriodicEntryBook = diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerFilter.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerFilter.java new file mode 100644 index 0000000..362cf69 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerFilter.java @@ -0,0 +1,41 @@ +package org.chorem.lima.ui.accountViewer; + +import org.chorem.lima.beans.LetteringFilterImpl; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FiscalPeriod; + +/** + * Created by davidcosse on 21/09/15. + */ +public class AccountViewerFilter extends LetteringFilterImpl { + + protected PeriodChoice periodChoice = PeriodChoice.FINANCIAL_PERIOD; + + protected FinancialPeriod financialPeriod; + + protected FiscalPeriod fiscalPeriod; + + public PeriodChoice getPeriodChoice() { + return periodChoice; + } + + public void setPeriodChoice(PeriodChoice periodChoice) { + this.periodChoice = periodChoice; + } + + public FinancialPeriod getFinancialPeriod() { + return financialPeriod; + } + + public void setFinancialPeriod(FinancialPeriod financialPeriod) { + this.financialPeriod = financialPeriod; + } + + public FiscalPeriod getFiscalPeriod() { + return fiscalPeriod; + } + + public void setFiscalPeriod(FiscalPeriod fiscalPeriod) { + this.fiscalPeriod = fiscalPeriod; + } +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java index 3180fbf..767d234 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerTableModel.java @@ -43,12 +43,6 @@ public class AccountViewerTableModel extends AbstractLimaTableModel<Entry> { /** serialVersionUID. */ private static final long serialVersionUID = 1L; - public BigDecimal getPreviousPeriodSold() { - return previousPeriodSold; - } - - protected BigDecimal previousPeriodSold; - @Override protected void initColumn() { addColumn(new AbstractColumn<AccountViewerTableModel>(Date.class, t("lima.table.date"), false) { @@ -127,8 +121,4 @@ public class AccountViewerTableModel extends AbstractLimaTableModel<Entry> { }); } - - public void setPreviousPeriodSold(BigDecimal previousPeriodSold) { - this.previousPeriodSold = previousPeriodSold; - } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css index 07b91f7..9682494 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.css @@ -68,7 +68,7 @@ } #fiscalPeriodComboBox { - visible : {PeriodChoice.FISCAL_PERIOD.equals(periodChoice)}; + visible : {PeriodChoice.FISCAL_PERIOD.equals(periodChoice) || PeriodChoice.FINANCIAL_PERIOD.equals(periodChoice)}; toolTipText : "lima.entries.fiscalYear"; renderer : "{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"; } @@ -76,7 +76,7 @@ #financialPeriodComboBox { preferredSize : {new Dimension(200, 22)}; toolTipText : "lima.entries.financialPeriod"; - renderer : "{new org.chorem.lima.ui.accountViewer.FinancialPeriodListRenderer()}"; + renderer : "{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}"; } #refresh { @@ -84,12 +84,79 @@ actionIcon : "refresh"; } +#beginDebitLabel { + text : "lima.table.debit"; +} + +#beginDebit { + editable : false; +} + +#beginCreditLabel { + text : "lima.table.credit"; +} + +#beginCredit { + editable : false; +} + +#beginSoldLabel { + text : "lima.table.balance"; +} + +#beginSold { + editable : false; +} + #table { sortable : false; rowHeight : 22; } -#balanceStatusLabel { - horizontalTextPosition:{JLabel.RIGHT}; - border: {BorderFactory.createEmptyBorder(0, 0, 0, 20)}; +#endDebitLabel { + text : "lima.table.debit"; +} + +#endDebit { + editable : false; +} + +#endCreditLabel { + text : "lima.table.credit"; } + +#endCredit { + editable : false; +} + +#endSoldLabel { + text : "lima.table.balance"; +} + +#endSold { + editable : false; +} + +#selectionDebitLabel { + text : "lima.table.debit"; +} + +#selectionDebit { + editable : false; +} + +#selectionCreditLabel { + text : "lima.table.credit"; +} + +#selectionCredit { + editable : false; +} + +#selectionSoldLabel { + text : "lima.table.balance"; +} + +#selectionSold { + editable : false; +} \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx index e615d60..e394d6c 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx @@ -21,6 +21,7 @@ <JPanel layout="{new BorderLayout()}"> <import> + java.awt.FlowLayout java.awt.Dimension org.chorem.lima.util.WrapToolBarLayout org.chorem.lima.ui.common.FinancialPeriodComboBoxModel @@ -41,10 +42,10 @@ <script> <![CDATA[ - void $afterCompleteSetup() { - handler.init(); - } - ]]> + void $afterCompleteSetup() { + handler.init(); + } + ]]> </script> <JToolBar styleClass="toolbar" @@ -71,7 +72,7 @@ <JLabel id="beginPeriodLabel"/> - <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> + <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodComboBoxModel}" onItemStateChanged="handler.onFiscalPeriodChange(event)"/> @@ -102,21 +103,88 @@ <JButton id="refresh" onActionPerformed="handler.updateAllEntries(null)"/> - </JToolBar> - <JScrollPane constraints="BorderLayout.CENTER"> - <AccountViewerTableModel id="tableModel"/> - <AccountViewerSelectionModel id='accountViewerSelectionModel' constructorParams='tableModel' - onValueChanged="handler.balanceAndActions()"/> - - <AccountViewerTable id="table" - constructorParams="handler" - model="{tableModel}" - selectionModel="{accountViewerSelectionModel}"/> - </JScrollPane> - - <JPanel constraints="BorderLayout.SOUTH" layout="{new BorderLayout()}"> - <JLabel id='balanceStatusLabel' constraints="BorderLayout.EAST"/> + + <JPanel layout="{new BorderLayout()}" + constraints="BorderLayout.CENTER"> + + <JPanel constraints="BorderLayout.NORTH" layout="{new FlowLayout(FlowLayout.RIGHT)}" id="beginBalanceStatus"> + <JLabel id="beginPeriodSummary" /> + <JLabel id="beginDebitLabel" /> + <JTextField id="beginDebit"/> + <JLabel id="beginCreditLabel" /> + <JTextField id="beginCredit"/> + <JLabel id="beginSoldLabel" /> + <JTextField id="beginSold"/> + </JPanel> + + <JScrollPane constraints="BorderLayout.CENTER"> + <AccountViewerTableModel id="tableModel"/> + <AccountViewerSelectionModel id='accountViewerSelectionModel' constructorParams='tableModel' + onValueChanged="handler.balanceAndActions()"/> + + <AccountViewerTable id="table" + constructorParams="handler" + model="{tableModel}" + selectionModel="{accountViewerSelectionModel}"/> + </JScrollPane> + + <JPanel constraints="BorderLayout.SOUTH" layout="{new BorderLayout()}"> + <Table id='endBalanceStatus' constraints="BorderLayout.EAST"> + <row> + <cell anchor="east"> + <JLabel id="endPeriodSummary" /> + </cell> + + <cell anchor="east"> + <JLabel id="endDebitLabel" /> + </cell> + <cell anchor="west"> + <JTextField id="endDebit"/> + </cell> + + <cell anchor="east"> + <JLabel id="endCreditLabel" /> + </cell> + <cell anchor="west"> + <JTextField id="endCredit"/> + </cell> + + <cell anchor="east"> + <JLabel id="endSoldLabel" /> + </cell> + <cell anchor="west"> + <JTextField id="endSold"/> + </cell> + </row> + <row> + <cell anchor="east"> + <JLabel id="selectionDescription" /> + </cell> + + <cell anchor="east"> + <JLabel id="selectionDebitLabel" /> + </cell> + <cell anchor="west"> + <JTextField id="selectionDebit"/> + </cell> + + <cell anchor="east"> + <JLabel id="selectionCreditLabel" /> + </cell> + <cell anchor="west"> + <JTextField id="selectionCredit"/> + </cell> + + <cell anchor="east"> + <JLabel id="selectionSoldLabel" /> + </cell> + <cell anchor="west"> + <JTextField id="selectionSold"/> + </cell> + </row> + </Table> + </JPanel> </JPanel> </JPanel> \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index 50a17a0..f1450f5 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -22,7 +22,6 @@ package org.chorem.lima.ui.accountViewer; -import com.google.common.collect.Lists; import jaxx.runtime.SwingUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.time.DateUtils; @@ -39,16 +38,11 @@ import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; -import org.chorem.lima.entity.EntryImpl; import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.entity.FinancialTransaction; -import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.ui.combobox.AccountComboBox; import org.chorem.lima.util.BigDecimalToString; import org.chorem.lima.util.ErrorHelper; -import org.nuiton.util.beans.Binder; -import org.nuiton.util.beans.BinderFactory; import javax.swing.*; import java.awt.event.ActionEvent; @@ -59,9 +53,7 @@ import java.beans.PropertyChangeListener; import java.math.BigDecimal; import java.text.DateFormat; import java.util.Calendar; -import java.util.Collection; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -87,7 +79,7 @@ public class AccountViewerViewHandler { protected FinancialTransactionService financialTransactionService; protected FiscalPeriodService fiscalPeriodService; - protected LetteringFilterImpl filter; + protected AccountViewerFilter filter; protected AccountViewerEditModel editModel; @@ -100,6 +92,7 @@ public class AccountViewerViewHandler { protected boolean initializationComplete; public AccountViewerViewHandler(AccountViewerView view) { + initializationComplete = false; this.view = view; initShortCuts(); @@ -117,9 +110,11 @@ public class AccountViewerViewHandler { * Init all combo box in view. */ public void init() { - filter = new LetteringFilterImpl(); + filter = new AccountViewerFilter(); editModel = view.getEditModel(); - initViewWithDefaultFinancialPeriod(); + initFiscalPeriodView(); + initDefaultFinancialPeriodView(); + initSoldPeriodView(); editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { @Override @@ -157,7 +152,6 @@ public class AccountViewerViewHandler { SwingUtil.fixTableColumnWidth(view.getTable(), 4, 50); initializationComplete = true; - updateAllEntries(null); updateSoldStatus(); } @@ -170,7 +164,6 @@ public class AccountViewerViewHandler { //To block reaction of the dual key 'ctrl+a' (Selection of all lines) inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK), "none"); - // refresh binding = "refresh"; inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), binding); @@ -193,28 +186,30 @@ public class AccountViewerViewHandler { } protected void onPeriodChoiceChanged(PeriodChoice periodChoice) { - if (initializationComplete) { - switch (periodChoice) { - case FINANCIAL_PERIOD: - view.getFiscalPeriodComboBox().setVisible(false); - view.getFinancialPeriodComboBox().setVisible(true); - view.getBeginPeriodPicker().setVisible(false); - view.getEndPeriodPicker().setVisible(false); - initViewWithDefaultFinancialPeriod(); - break; - case FISCAL_PERIOD: - view.getFiscalPeriodComboBox().setVisible(true); - view.getFinancialPeriodComboBox().setVisible(false); - view.getBeginPeriodPicker().setVisible(false); - view.getEndPeriodPicker().setVisible(false); - initFiscalPeriodModel(); - break; - case DATE: - view.getFiscalPeriodComboBox().setVisible(false); - view.getFinancialPeriodComboBox().setVisible(false); - view.getBeginPeriodPicker().setVisible(true); - view.getEndPeriodPicker().setVisible(true); - break; + if (initializationComplete && !filter.getPeriodChoice().equals(periodChoice)) { + filter.setPeriodChoice(periodChoice); + switch (periodChoice) { + case FINANCIAL_PERIOD: + view.getFiscalPeriodComboBox().setVisible(true); + view.getFinancialPeriodComboBox().setVisible(true); + view.getBeginPeriodPicker().setVisible(false); + view.getEndPeriodPicker().setVisible(false); + initDefaultFinancialPeriodView(); + break; + case FISCAL_PERIOD: + view.getFiscalPeriodComboBox().setVisible(true); + view.getFinancialPeriodComboBox().setVisible(false); + view.getBeginPeriodPicker().setVisible(false); + view.getEndPeriodPicker().setVisible(false); + initFiscalPeriodView(); + break; + case DATE: + view.getFiscalPeriodComboBox().setVisible(false); + view.getFinancialPeriodComboBox().setVisible(false); + view.getBeginPeriodPicker().setVisible(true); + view.getEndPeriodPicker().setVisible(true); + initDateIntervalView(); + break; } updateAllEntries(null); } @@ -256,31 +251,48 @@ public class AccountViewerViewHandler { } protected void onFiscalPeriodChange(java.awt.event.ItemEvent event) { - if (initializationComplete) { - FiscalPeriod fiscalPeriod = (FiscalPeriod) event.getItem(); - updateAllEntriesForFiscalPeriodChange(fiscalPeriod); + FiscalPeriod fiscalPeriod = (FiscalPeriod) event.getItem(); + if (initializationComplete && filter.getFiscalPeriod() != fiscalPeriod) { + filter.setFiscalPeriod(fiscalPeriod); + + //FISCAL_PERIOD + if (PeriodChoice.FISCAL_PERIOD.equals(view.getPeriodChoice().getSelectedItem())) { + updateAllEntriesForFiscalPeriodChange(fiscalPeriod); + } else { + //FINANCIAL_PERIOD + initDefaultFinancialPeriodView(); + } } } protected void onFinancialPeriodChange(java.awt.event.ItemEvent event) { - if (initializationComplete) { - FinancialPeriod financialPeriod = (FinancialPeriod) event.getItem(); + FinancialPeriod financialPeriod = (FinancialPeriod) event.getItem(); + if (initializationComplete && filter.getFinancialPeriod() != financialPeriod) { + filter.setFinancialPeriod(financialPeriod); updateAllEntriesForFinancialPeriodChange(financialPeriod); } } public void onDateStartChange(Date date) { if (initializationComplete) { - filter.setDateStart(date); - updateAllEntriesForDateChange(); + if (date != null && !DateUtils.isSameDay(date, filter.getDateStart())) { + filter.setDateStart(date); + if (filter.getDateEnd().before(date)) { + filter.setDateEnd(filter.getDateEnd().before(date) ? date : filter.getDateEnd()); + view.getEndPeriodPicker().setDate(filter.getDateEnd()); + } + updateAllEntriesForDateChange(); + } } } public void onDateEndChange(Date date) { if (initializationComplete) { - filter.setDateEnd(date); - updateAllEntriesForDateChange(); + if (date != null && !DateUtils.isSameDay(date, filter.getDateEnd())) { + filter.setDateEnd(date); + updateAllEntriesForDateChange(); + } } } @@ -300,32 +312,32 @@ public class AccountViewerViewHandler { public void updateSoldStatus() { if (initializationComplete) { - view.getBalanceStatusLabel().setText(t("lima.lettering.accountViewerBalanceStatus", - getDateFormat().format(editModel.getFiscalPeriodBeginDate()), - getDateFormat().format(filter.getDateEnd()), - - BigDecimalToString.format(editModel.getGlobalDebit()), - BigDecimalToString.format(editModel.getGlobalCredit()), - BigDecimalToString.format(editModel.getGlobalSold()), - - BigDecimalToString.format(editModel.getDebit()), - BigDecimalToString.format(editModel.getCredit()), - BigDecimalToString.format(editModel.getSold()))); + view.getSelectionDescription().setText(t("lima.accountViewer.selectionDescription")); + view.getSelectionDebit().setText(BigDecimalToString.format(editModel.getDebit())); + view.getSelectionCredit().setText(BigDecimalToString.format(editModel.getCredit())); + view.getSelectionSold().setText(BigDecimalToString.format(editModel.getSold())); } } public void updateAllEntriesForFiscalPeriodChange(FiscalPeriod fiscalPeriod) { - filter.setDateStart(fiscalPeriod.getBeginDate()); - filter.setDateEnd(fiscalPeriod.getEndDate()); + if (!DateUtils.isSameDay(fiscalPeriod.getBeginDate(), filter.getDateStart()) || + !DateUtils.isSameDay(fiscalPeriod.getEndDate(), filter.getDateEnd())) { + filter.setDateStart(fiscalPeriod.getBeginDate()); + filter.setDateEnd(fiscalPeriod.getEndDate()); - updateAllEntries(fiscalPeriod); + updateAllEntries(fiscalPeriod); + } } public void updateAllEntriesForFinancialPeriodChange(FinancialPeriod financialPeriod) { - filter.setDateStart(financialPeriod.getBeginDate()); - filter.setDateEnd(financialPeriod.getEndDate()); - updateAllEntries(null); + if (!DateUtils.isSameDay(financialPeriod.getBeginDate(), filter.getDateStart()) || + !DateUtils.isSameDay(financialPeriod.getEndDate(), filter.getDateEnd())) { + filter.setDateStart(financialPeriod.getBeginDate()); + filter.setDateEnd(financialPeriod.getEndDate()); + + updateAllEntries(null); + } } public void updateAllEntriesForDateChange() { @@ -333,91 +345,95 @@ public class AccountViewerViewHandler { } public void updateAllEntries(FiscalPeriod fiscalPeriod) { - if (initializationComplete && filter.getAccount() != null && filter.getDateStart() != null && filter.getDateEnd() != null) { - - List<Entry> entriesAndResume = Lists.newArrayList(); - List<Entry> entries = financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); fiscalPeriod = fiscalPeriod == null ? fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()) : fiscalPeriod; + LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(fiscalPeriod); + LetteringFilter actualPeriodFilter = computeActualPeriodFilter(fiscalPeriod); + setViewPreviousSold(previousPeriodFilter); + setViewActualSold(fiscalPeriod, actualPeriodFilter); - if (CollectionUtils.isNotEmpty(entries)) { - // can be null if there are no fiscal period for the begin date - if (fiscalPeriod != null) { - LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(fiscalPeriod); - LetteringFilter actualPeriodFilter = computeActualPeriodFilter(fiscalPeriod); - addPreviousSoldToModel(previousPeriodFilter); - addPreviousSoldEntryToEntries(entriesAndResume, entries, previousPeriodFilter); - addActualSoldToModel(fiscalPeriod, actualPeriodFilter); - } - } - entriesAndResume.addAll(entries); - view.getTableModel().setValues(entriesAndResume); + view.getTableModel().setValues(entries); } onBalanceChanged(null); } - public void initFiscalPeriodModel() { + public void initFiscalPeriodView() { + List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods(); + view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); if (fiscalPeriod != null) { + filter.setFiscalPeriod(fiscalPeriod); + filter.setDateStart(fiscalPeriod.getBeginDate()); + filter.setDateEnd(fiscalPeriod.getEndDate()); view.getFiscalPeriodComboBox().setSelectedItem(fiscalPeriod); - view.getBeginPeriodPicker().setDate(fiscalPeriod.getBeginDate()); - view.getEndPeriodPicker().setDate(fiscalPeriod.getEndDate()); + view.getFiscalPeriodComboBox().setVisible(true); } } - public void initViewWithDefaultFinancialPeriod() { - List<FinancialPeriod> financialPeriods = financialPeriodService.getAllFinancialPeriods(); - view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); - - FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); - - FinancialPeriod defaultFinancialPeriod = getDefaultFinancialPeriod(financialPeriods, fiscalPeriod); - - Calendar calendar = Calendar.getInstance(); - int lastCurrentMonthDay = calendar.getActualMaximum(Calendar.DATE); - int firstCurrentMonthDay = calendar.getActualMinimum(Calendar.DATE); - - Date defaultDateBeginFinancialPeriod, defaultDateEndCurrent; - defaultDateBeginFinancialPeriod = defaultFinancialPeriod == null ? DateUtils.setDays(new Date(), firstCurrentMonthDay) : defaultFinancialPeriod.getBeginDate(); - defaultDateEndCurrent = defaultFinancialPeriod == null ? DateUtils.setDays(new Date(), lastCurrentMonthDay) : defaultFinancialPeriod.getEndDate(); - - view.getFinancialPeriodComboBoxModel().setSelectedItem(defaultFinancialPeriod); - - view.getBeginPeriodPicker().setDate(defaultDateBeginFinancialPeriod); - view.getEndPeriodPicker().setDate(defaultDateEndCurrent); - - filter.setDateStart(defaultDateBeginFinancialPeriod); - filter.setDateEnd(defaultDateEndCurrent); + public void initDateIntervalView() { + FiscalPeriod fiscalPeriod = (FiscalPeriod) view.getFiscalPeriodComboBox().getSelectedItem(); + FinancialPeriod defaultFinancialPeriod; + if (fiscalPeriod != null) { + Date today = new Date(); + defaultFinancialPeriod = financialPeriodService.getFinancialForDate(today); - editModel.setFiscalPeriodBeginDate(fiscalPeriod != null ? fiscalPeriod.getBeginDate() : defaultDateBeginFinancialPeriod); + if (defaultFinancialPeriod == null) { + defaultFinancialPeriod = financialPeriodService.getFinancialForDate(fiscalPeriod.getEndDate()); + } + filter.setDateStart(defaultFinancialPeriod.getBeginDate()); + filter.setDateEnd(defaultFinancialPeriod.getEndDate()); + view.getBeginPeriodPicker().setDate(defaultFinancialPeriod.getBeginDate()); + view.getEndPeriodPicker().setDate(defaultFinancialPeriod.getEndDate()); + } } - protected FinancialPeriod getDefaultFinancialPeriod(List<FinancialPeriod> financialPeriods, FiscalPeriod fiscalPeriod) { - FinancialPeriod defaultFinancialPeriod = null; + public void initDefaultFinancialPeriodView() { + FiscalPeriod fiscalPeriod = (FiscalPeriod) view.getFiscalPeriodComboBox().getSelectedItem(); - if ((fiscalPeriod != null && fiscalPeriod.getFinancialPeriod() != null)) { - - Collection<FinancialPeriod> fiscalPeriodFinancialPeriods = financialPeriodService.getFinancialPeriods(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); - Iterator<FinancialPeriod> financialPeriodIterator = fiscalPeriodFinancialPeriods.iterator(); - if (financialPeriodIterator.hasNext()) { - defaultFinancialPeriod = financialPeriodIterator.next(); + FinancialPeriod defaultFinancialPeriod = null; + if (fiscalPeriod != null) { + List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); + view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); + + boolean isCurrentDatePartOfSelectedFiscalPeriod; + Date today = new Date(); + isCurrentDatePartOfSelectedFiscalPeriod = fiscalPeriod.getBeginDate().before(today) && (fiscalPeriod.getEndDate().after(today)); + if (isCurrentDatePartOfSelectedFiscalPeriod) { + defaultFinancialPeriod = financialPeriodService.getFinancialForDate(today); + } else if (!financialPeriods.isEmpty()) { + defaultFinancialPeriod = financialPeriods.get(financialPeriods.size() - 1); } + view.getFinancialPeriodComboBoxModel().setSelectedItem(defaultFinancialPeriod); } - defaultFinancialPeriod = defaultFinancialPeriod != null ? defaultFinancialPeriod : CollectionUtils.isNotEmpty(financialPeriods) ? financialPeriods.get(0) : null; - return defaultFinancialPeriod; + Date defaultDateBegin, defaultDateEnd; + Calendar calendar = Calendar.getInstance(); + int firstCurrentMonthDay = calendar.getActualMinimum(Calendar.DATE); + int lastCurrentMonthDay = calendar.getActualMaximum(Calendar.DATE); + defaultDateBegin = defaultFinancialPeriod == null ? DateUtils.setDays(new Date(), firstCurrentMonthDay) : defaultFinancialPeriod.getBeginDate(); + defaultDateEnd = defaultFinancialPeriod == null ? DateUtils.setDays(new Date(), lastCurrentMonthDay) : defaultFinancialPeriod.getEndDate(); + + filter.setDateStart(defaultDateBegin); + filter.setDateEnd(defaultDateEnd); + + editModel.setFiscalPeriodBeginDate(defaultFinancialPeriod != null ? defaultFinancialPeriod.getBeginDate() : defaultDateBegin); } - protected void addPreviousSoldEntryToEntries(List<Entry> entriesAndResume, List<Entry> entries, LetteringFilter previousPeriodFilter) { - // no previous sold to add if selected starting date is same as fiscal period one - if (!DateUtils.isSameDay(filter.getDateStart(), previousPeriodFilter.getDateStart()) && CollectionUtils.isNotEmpty(entries)) { - entriesAndResume.add(getFirstLinePreviousSoldEntry(entries, previousPeriodFilter)); - } + protected void initSoldPeriodView() { + view.getBeginPeriodSummary().setText(String.format("Pour la période du %s au %s,", getDateFormat().format(editModel.getFiscalPeriodBeginDate()), getDateFormat().format(filter.getDateEnd()))); + view.getBeginDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); + view.getBeginCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); + view.getBeginSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); + view.getEndPeriodSummary().setText(String.format("Pour la période du %s au %s,", getDateFormat().format(editModel.getFiscalPeriodBeginDate()), getDateFormat().format(filter.getDateEnd()))); + view.getEndDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); + view.getEndCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); + view.getEndSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); } protected void addFiscalPeriodBeginDate(FiscalPeriod fiscalPeriod) { @@ -426,45 +442,25 @@ public class AccountViewerViewHandler { } } - protected Entry getFirstLinePreviousSoldEntry(List<Entry> entries, LetteringFilter previousPeriodFilter) { - Entry firstEntry = entries.get(0); - FinancialTransaction firstTransaction = firstEntry.getFinancialTransaction(); - FinancialTransaction firstLineTransaction = new FinancialTransactionImpl(); - Binder<FinancialTransaction, FinancialTransaction> binder = BinderFactory.newBinder(FinancialTransaction.class); - binder.copyExcluding(firstTransaction, firstLineTransaction, FinancialTransaction.PROPERTY_TOPIA_ID); - Date previousSoldEndDate = getDayMinus1Calendar(previousPeriodFilter).getTime(); - firstLineTransaction.setTransactionDate(previousSoldEndDate); - - Entry resumeEntry = new EntryImpl(); - resumeEntry.setDescription(String.format(t("lima.accountViewer.previousSold"), getDateFormat().format(previousSoldEndDate))); - resumeEntry.setAmount(view.getTableModel().getPreviousPeriodSold().abs()); - resumeEntry.setDebit(BigDecimal.ZERO.compareTo(view.getTableModel().getPreviousPeriodSold()) < 0); - resumeEntry.setFinancialTransaction(firstLineTransaction); - return resumeEntry; - } - - protected void addPreviousSoldToModel(LetteringFilter previousPeriodFilter) { - BigDecimal previousSold; - if (previousPeriodFilter == null) { - previousSold = BigDecimal.ZERO; - } else { - List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(previousPeriodFilter); - DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); - previousSold = debitCreditSold.getSold(); - } - view.getTableModel().setPreviousPeriodSold(previousSold); + protected void setViewPreviousSold(LetteringFilter previousPeriodFilter) { + List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(previousPeriodFilter); + DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); + view.getBeginPeriodSummary().setText(String.format("Pour la période du %s au %s,", getDateFormat().format(previousPeriodFilter.getDateStart()), getDateFormat().format(previousPeriodFilter.getDateEnd()))); + view.getBeginDebit().setText(BigDecimalToString.format(debitCreditSold.getDebit())); + view.getBeginCredit().setText(BigDecimalToString.format(debitCreditSold.getCredit())); + view.getBeginSold().setText(BigDecimalToString.format(debitCreditSold.getSold())); } - protected void addActualSoldToModel(FiscalPeriod fiscalPeriod, LetteringFilter actualPeriodFilter) { + protected void setViewActualSold(FiscalPeriod fiscalPeriod, LetteringFilter actualPeriodFilter) { addFiscalPeriodBeginDate(fiscalPeriod); List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(actualPeriodFilter); DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); - editModel.setGlobalDebit(debitCreditSold.getDebit()); - editModel.setGlobalCredit(debitCreditSold.getCredit()); - editModel.setGlobalSold(debitCreditSold.getSold()); + view.getEndPeriodSummary().setText(String.format("Pour la période du %s au %s,", getDateFormat().format(actualPeriodFilter.getDateStart()), getDateFormat().format(actualPeriodFilter.getDateEnd()))); + view.getEndDebit().setText(BigDecimalToString.format(debitCreditSold.getDebit())); + view.getEndCredit().setText(BigDecimalToString.format(debitCreditSold.getCredit())); + view.getEndSold().setText(BigDecimalToString.format(debitCreditSold.getSold())); } - public void balanceAndActions() { if (log.isDebugEnabled()) { log.debug("balanceAndActions"); @@ -541,27 +537,19 @@ public class AccountViewerViewHandler { } protected LetteringFilter computePreviousPeriodFilter(FiscalPeriod fiscalPeriod) { - LetteringFilter previousPeriodFilter = null; - - if (fiscalPeriod != null) { - previousPeriodFilter = new LetteringFilterImpl(); - previousPeriodFilter.setDateStart(fiscalPeriod.getBeginDate()); - previousPeriodFilter.setDateEnd(filter.getDateStart()); - previousPeriodFilter.setAccount(filter.getAccount()); - } + LetteringFilter previousPeriodFilter = new LetteringFilterImpl(); + previousPeriodFilter.setDateStart(fiscalPeriod == null ? filter.getDateStart() : fiscalPeriod.getBeginDate()); + previousPeriodFilter.setDateEnd(filter.getDateStart()); + previousPeriodFilter.setAccount(filter.getAccount()); return previousPeriodFilter; } private LetteringFilter computeActualPeriodFilter(FiscalPeriod fiscalPeriod) { - LetteringFilter actualPeriodFilter = null; - - if (fiscalPeriod != null) { - actualPeriodFilter = new LetteringFilterImpl(); - actualPeriodFilter.setDateStart(fiscalPeriod.getBeginDate()); - actualPeriodFilter.setDateEnd(filter.getDateEnd()); - actualPeriodFilter.setAccount(filter.getAccount()); - } + LetteringFilter actualPeriodFilter = new LetteringFilterImpl(); + actualPeriodFilter.setDateStart(fiscalPeriod == null ? filter.getDateStart() : fiscalPeriod.getBeginDate()); + actualPeriodFilter.setDateEnd(filter.getDateEnd()); + actualPeriodFilter.setAccount(filter.getAccount()); return actualPeriodFilter; } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/FinancialPeriodListRenderer.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/FinancialPeriodListRenderer.java deleted file mode 100644 index cb1498c..0000000 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/FinancialPeriodListRenderer.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * #%L - * Lima :: Swing - * %% - * Copyright (C) 2012 Codelutin, Chatellier Eric - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -package org.chorem.lima.ui.accountViewer; - -import org.chorem.lima.LimaSwingConfig; -import org.chorem.lima.entity.FinancialPeriod; - -import javax.swing.*; -import java.awt.*; -import java.text.DateFormat; -import java.util.Locale; - -/** - * Financial period list renderer. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class FinancialPeriodListRenderer extends DefaultListCellRenderer { - - /** serialVersionUID. */ - private static final long serialVersionUID = -1L; - - // afiche le mois en lettre et le numero de la période, pour eviter les confusions entre deux mois identique pour des exercice de plus de 12 mois - - @Override - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - - FinancialPeriod financialPeriod = (FinancialPeriod)value; - Object newValue = financialPeriod; - if (financialPeriod != null) { - newValue = String.format("%s - %s", getDateFormat().format(financialPeriod.getBeginDate()), getDateFormat().format(financialPeriod.getEndDate())); - } - return super.getListCellRendererComponent(list, newValue, index, isSelected, - cellHasFocus); - } - - protected DateFormat getDateFormat() { - Locale locale = LimaSwingConfig.getInstance().getLocale(); - DateFormat result = DateFormat.getDateInstance(DateFormat.SHORT, locale); - return result; - } - -} 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 e3b02d4..ab9621e 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 @@ -307,8 +307,8 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo if ( event.getStateChange() == ItemEvent.SELECTED ) { FiscalPeriod selectedFiscalPeriod = (FiscalPeriod) event.getItem(); - List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), - selectedFiscalPeriod.getEndDate()); + List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(selectedFiscalPeriod.getBeginDate(), + selectedFiscalPeriod.getEndDate()); if (log.isDebugEnabled()) { log.debug(String.format("Loaded %d financial periods", financialPeriods.size())); 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 da2a007..d35494e 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 @@ -15,6 +15,7 @@ lima.account.remove.error.usedAccount=There are financial statement on this acco lima.account.update.error.invalidAccountNumber=Invalid account number\: %1$s lima.account.update.form=Update account lima.accountViewer.previousSold=<html><b>On %s the sold was</b></html> +lima.accountViewer.selectionDescription=For selected entries, lima.accounts=Accounts lima.action.commandline.help=Show help in console lima.balance=Balance @@ -533,6 +534,7 @@ lima.table.letter=Letter lima.table.locked=Loked lima.table.number=Account Number lima.table.provisionDeprecation=Provision Deprecation +lima.table.sold= lima.table.voucher=Voucher lima.title=Lutin Invoice Monitoring and Accounting lima.transaction=Transaction 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 fbd0d0d..26c6e40 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 @@ -17,7 +17,8 @@ lima.account.remove.confirm.title=Suppression d'un compte lima.account.remove.error.usedAccount=Il exist des transactions sur ce compte lima.account.update.error.invalidAccountNumber=Le numéro du compte %1$s n'est pas valide lima.account.update.form=Modification d'un compte -lima.accountViewer.previousSold=Solde au %s +lima.accountViewer.previousSold=<html><b>Solde au %s</b></html> +lima.accountViewer.selectionDescription=Pour la sélection, lima.accounts=Comptes lima.action.commandline.help=Afficher l'aide en console lima.balance=Équilibrer @@ -469,8 +470,6 @@ lima.lettering.account=Comptes lima.lettering.account.aAll=TOUS lima.lettering.account.back=← lima.lettering.account.next=→ -lima.lettering.accountViewerBalanceStatus=<html>Période du <b>%s</b> au <b>%s</b>\: solde \=<b>%s - %s \= %s</b> - Pour la sélection le solde est\: <b>%s - %s \= %s</b> -lima.lettering.balanceStatus=<html>Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b> lima.lettering.accountViewerBalanceStatus=<html>Pour la période du %s au %s\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> - Pour la sélection\: D\: <b>%s</b> - C\: <b>%s</b> - S\: <b>%s</b> lima.lettering.balanceStatus=<html>Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b>. Entrées sélectionnées\: Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b> lima.lettering.checkAll=Toutes @@ -541,6 +540,7 @@ lima.table.letter=Lettre lima.table.locked=Clos lima.table.number=Numéro de compte lima.table.provisionDeprecation=Amortissements et provisions +lima.table.sold= lima.table.voucher=Pièce comptable lima.title=Lutin Invoice Monitoring and Accounting lima.transaction=Transaction -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit e2bbeb7daca042477bb1b8136fb52e2067ba1f12 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 23 22:05:15 2015 +0200 refs #1293 refactoring et modification du calcul du sold précédent à l'année fiscale --- .../lima/business/api/FiscalPeriodService.java | 6 + .../lima/business/ejb/FiscalPeriodServiceImpl.java | 10 + .../ui/accountViewer/AccountViewerEditModel.java | 43 +-- .../lima/ui/accountViewer/AccountViewerView.jaxx | 2 +- .../ui/accountViewer/AccountViewerViewHandler.java | 311 +++++++++++++-------- .../resources/i18n/lima-swing_en_GB.properties | 1 + .../resources/i18n/lima-swing_fr_FR.properties | 1 + 7 files changed, 221 insertions(+), 153 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java index 4e0c812..0ba0865 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/FiscalPeriodService.java @@ -78,6 +78,12 @@ public interface FiscalPeriodService { /** * + * @return first fiscal Period + */ + FiscalPeriod getFirstFiscalPeriod(); + + /** + * * @return last fiscal period */ FiscalPeriod getLastFiscalPeriod(); diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java index 40504d6..ff04a1c 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java @@ -212,6 +212,16 @@ public class FiscalPeriodServiceImpl extends AbstractLimaService implements Fisc } @Override + public FiscalPeriod getFirstFiscalPeriod() { + + FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); + //get the last fiscal period + FiscalPeriod result = fiscalPeriodTopiaDao.forAll().setOrderByArguments(FiscalPeriod.PROPERTY_BEGIN_DATE + " ASC").findFirstOrNull(); + + return result; + } + + @Override public FiscalPeriod getLastFiscalPeriod() { FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java index 57accc3..3399584 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java @@ -25,7 +25,6 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.Serializable; import java.math.BigDecimal; -import java.util.Date; /** * @author sletellier <letellier@codelutin.com> @@ -48,12 +47,6 @@ public class AccountViewerEditModel implements Serializable { protected BigDecimal credit = BigDecimal.ZERO; protected BigDecimal sold = BigDecimal.ZERO; - protected BigDecimal globalDebit = BigDecimal.ZERO; - protected BigDecimal globalCredit = BigDecimal.ZERO; - protected BigDecimal globalSold = BigDecimal.ZERO; - - protected Date fiscalPeriodBeginDate; - public BigDecimal getDebit() { return debit; } @@ -106,33 +99,6 @@ public class AccountViewerEditModel implements Serializable { firePropertyChange(PROPERTY_SOLD, oldSold, this.sold); } - public BigDecimal getGlobalSold() { - return globalSold; - } - - public void setGlobalSold(BigDecimal globalSold) { - BigDecimal oldSold = getGlobalSold(); - - this.globalSold = globalSold; - firePropertyChange(PROPERTY_GLOBAL_SOLD, oldSold, this.globalSold); - } - - public BigDecimal getGlobalDebit() { - return globalDebit; - } - - public void setGlobalDebit(BigDecimal globalDebit) { - this.globalDebit = globalDebit; - } - - public BigDecimal getGlobalCredit() { - return globalCredit; - } - - public void setGlobalCredit(BigDecimal globalCredit) { - this.globalCredit = globalCredit; - } - public void addPropertyChangeListener(PropertyChangeListener listener) { pcs.addPropertyChangeListener(listener); } @@ -156,12 +122,5 @@ public class AccountViewerEditModel implements Serializable { protected void firePropertyChange(String propertyName, Object newValue) { firePropertyChange(propertyName, null, newValue); } - - public Date getFiscalPeriodBeginDate() { - return fiscalPeriodBeginDate; - } - - public void setFiscalPeriodBeginDate(Date fiscalPeriodStartingDate) { - this.fiscalPeriodBeginDate = fiscalPeriodStartingDate; - } } + diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx index e394d6c..d03a614 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx @@ -102,7 +102,7 @@ onItemStateChanged="handler.onSelectionModeChanged(letteredSelectionMode.getSelectedItem())"/> <JButton id="refresh" - onActionPerformed="handler.updateAllEntries(null)"/> + onActionPerformed="handler.updateAllEntries()"/> </JToolBar> <JPanel layout="{new BorderLayout()}" diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index f1450f5..2c120dd 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -47,6 +47,7 @@ import org.chorem.lima.util.ErrorHelper; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; +import java.awt.event.ItemEvent; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -54,6 +55,7 @@ import java.math.BigDecimal; import java.text.DateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -112,8 +114,7 @@ public class AccountViewerViewHandler { public void init() { filter = new AccountViewerFilter(); editModel = view.getEditModel(); - initFiscalPeriodView(); - initDefaultFinancialPeriodView(); + updateFinancialPeriodView(null); initSoldPeriodView(); editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { @@ -172,7 +173,7 @@ public class AccountViewerViewHandler { @Override public void actionPerformed(ActionEvent e) { - updateAllEntries(null); + updateAllEntries(); } }); } @@ -190,31 +191,43 @@ public class AccountViewerViewHandler { filter.setPeriodChoice(periodChoice); switch (periodChoice) { case FINANCIAL_PERIOD: - view.getFiscalPeriodComboBox().setVisible(true); - view.getFinancialPeriodComboBox().setVisible(true); - view.getBeginPeriodPicker().setVisible(false); - view.getEndPeriodPicker().setVisible(false); - initDefaultFinancialPeriodView(); + initViewForPeriodChoiceChange(true, true, false); + updateAllEntriesForFinancialPeriodChoice(); break; case FISCAL_PERIOD: - view.getFiscalPeriodComboBox().setVisible(true); - view.getFinancialPeriodComboBox().setVisible(false); - view.getBeginPeriodPicker().setVisible(false); - view.getEndPeriodPicker().setVisible(false); - initFiscalPeriodView(); + initViewForPeriodChoiceChange(true, false, false); + updateAllEntriesForFiscalPeriodChoice(); break; case DATE: - view.getFiscalPeriodComboBox().setVisible(false); - view.getFinancialPeriodComboBox().setVisible(false); - view.getBeginPeriodPicker().setVisible(true); - view.getEndPeriodPicker().setVisible(true); - initDateIntervalView(); + initViewForPeriodChoiceChange(false, false, true); + updateAllEntriesForDateIntervalChoice(); break; } - updateAllEntries(null); } } + private void initViewForPeriodChoiceChange(boolean isFiscalPeriodComboBoxVisible, boolean isFinancialPeriodComboBoxVisible, boolean isPeriodPickersVisible) { + view.getFiscalPeriodComboBox().setVisible(isFiscalPeriodComboBoxVisible); + view.getFinancialPeriodComboBox().setVisible(isFinancialPeriodComboBoxVisible); + view.getBeginPeriodPicker().setVisible(isPeriodPickersVisible); + view.getEndPeriodPicker().setVisible(isPeriodPickersVisible); + } + + private void updateAllEntriesForDateIntervalChoice() { + initDateIntervalView(); + updateAllEntries(); + } + + private void updateAllEntriesForFiscalPeriodChoice() { + initFiscalPeriodView(); + updateAllEntriesForFiscalPeriodChoice(fiscalPeriodService.getLastFiscalPeriod()); + } + + private void updateAllEntriesForFinancialPeriodChoice() { + updateFinancialPeriodView(filter.getFiscalPeriod()); + updateAllEntries(); + } + /** * Select previous value in combo box. * @@ -250,27 +263,29 @@ public class AccountViewerViewHandler { } } - protected void onFiscalPeriodChange(java.awt.event.ItemEvent event) { - FiscalPeriod fiscalPeriod = (FiscalPeriod) event.getItem(); - if (initializationComplete && filter.getFiscalPeriod() != fiscalPeriod) { - filter.setFiscalPeriod(fiscalPeriod); + protected void onFiscalPeriodChange(ItemEvent event) { + FiscalPeriod selectedFiscalPeriod = event != null && event.getItem() != null ? (FiscalPeriod) event.getItem() : null; + if (initializationComplete && selectedFiscalPeriod != null && !selectedFiscalPeriod.equals(filter.getFiscalPeriod())) { - //FISCAL_PERIOD - if (PeriodChoice.FISCAL_PERIOD.equals(view.getPeriodChoice().getSelectedItem())) { - updateAllEntriesForFiscalPeriodChange(fiscalPeriod); - } else { - //FINANCIAL_PERIOD - initDefaultFinancialPeriodView(); - } + List<FinancialPeriod> periods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); + FinancialPeriod selectedFinancialPeriod = periods.get(0); + view.getFinancialPeriodComboBoxModel().setObjects(periods); + view.getFinancialPeriodComboBoxModel().setSelectedItem(selectedFinancialPeriod); + + filter.setDateStart(selectedFinancialPeriod.getBeginDate()); + filter.setDateEnd(selectedFinancialPeriod.getEndDate()); + filter.setFiscalPeriod(selectedFiscalPeriod); + filter.setFinancialPeriod(selectedFinancialPeriod); + filter.setPeriodChoice(PeriodChoice.FINANCIAL_PERIOD); + updateAllEntries(); } } - protected void onFinancialPeriodChange(java.awt.event.ItemEvent event) { FinancialPeriod financialPeriod = (FinancialPeriod) event.getItem(); - if (initializationComplete && filter.getFinancialPeriod() != financialPeriod) { + if (initializationComplete && !filter.getFinancialPeriod().equals(financialPeriod)) { filter.setFinancialPeriod(financialPeriod); - updateAllEntriesForFinancialPeriodChange(financialPeriod); + updateAllEntriesForFinancialPeriodChoice(financialPeriod); } } @@ -278,9 +293,10 @@ public class AccountViewerViewHandler { if (initializationComplete) { if (date != null && !DateUtils.isSameDay(date, filter.getDateStart())) { filter.setDateStart(date); + if (filter.getDateEnd().before(date)) { - filter.setDateEnd(filter.getDateEnd().before(date) ? date : filter.getDateEnd()); - view.getEndPeriodPicker().setDate(filter.getDateEnd()); + filter.setDateEnd(date); + view.getEndPeriodPicker().setDate(date); } updateAllEntriesForDateChange(); } @@ -291,6 +307,10 @@ public class AccountViewerViewHandler { if (initializationComplete) { if (date != null && !DateUtils.isSameDay(date, filter.getDateEnd())) { filter.setDateEnd(date); + if (filter.getDateStart().after(date)) { + filter.setDateStart(date); + view.getBeginPeriodPicker().setDate(date); + } updateAllEntriesForDateChange(); } } @@ -320,52 +340,132 @@ public class AccountViewerViewHandler { } - public void updateAllEntriesForFiscalPeriodChange(FiscalPeriod fiscalPeriod) { - if (!DateUtils.isSameDay(fiscalPeriod.getBeginDate(), filter.getDateStart()) || - !DateUtils.isSameDay(fiscalPeriod.getEndDate(), filter.getDateEnd())) { - filter.setDateStart(fiscalPeriod.getBeginDate()); - filter.setDateEnd(fiscalPeriod.getEndDate()); - - updateAllEntries(fiscalPeriod); - } + public void updateAllEntriesForFiscalPeriodChoice(FiscalPeriod fiscalPeriod) { + filter.setFiscalPeriod(fiscalPeriod); + filter.setDateStart(fiscalPeriod.getBeginDate()); + filter.setDateEnd(fiscalPeriod.getEndDate()); + filter.setPeriodChoice(PeriodChoice.FISCAL_PERIOD); + updateAllEntries(); } - public void updateAllEntriesForFinancialPeriodChange(FinancialPeriod financialPeriod) { - if (!DateUtils.isSameDay(financialPeriod.getBeginDate(), filter.getDateStart()) || - !DateUtils.isSameDay(financialPeriod.getEndDate(), filter.getDateEnd())) { - filter.setDateStart(financialPeriod.getBeginDate()); - filter.setDateEnd(financialPeriod.getEndDate()); + public void updateAllEntriesForFinancialPeriodChoice(FinancialPeriod financialPeriod) { + filter.setDateStart(financialPeriod.getBeginDate()); + filter.setDateEnd(financialPeriod.getEndDate()); + filter.setPeriodChoice(PeriodChoice.FINANCIAL_PERIOD); + updateAllEntries(); - updateAllEntries(null); - } } public void updateAllEntriesForDateChange() { - updateAllEntries(null); + filter.setPeriodChoice(PeriodChoice.DATE); + filter.setFiscalPeriod(fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart())); + updateAllEntries(); } - public void updateAllEntries(FiscalPeriod fiscalPeriod) { + public void updateAllEntries() { if (initializationComplete && filter.getAccount() != null && filter.getDateStart() != null && filter.getDateEnd() != null) { List<Entry> entries = financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); - fiscalPeriod = fiscalPeriod == null ? fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()) : fiscalPeriod; - LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(fiscalPeriod); - LetteringFilter actualPeriodFilter = computeActualPeriodFilter(fiscalPeriod); - setViewPreviousSold(previousPeriodFilter); - setViewActualSold(fiscalPeriod, actualPeriodFilter); - view.getTableModel().setValues(entries); + + updateSummary(); } onBalanceChanged(null); } + protected void updateSummary() { + PeriodChoice periodChoice = filter.getPeriodChoice(); + LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(periodChoice); + LetteringFilter actualPeriodFilter = computeActualPeriodFilter(periodChoice); + setViewPreviousSold(previousPeriodFilter); + setViewActualSold(actualPeriodFilter); + } + + protected LetteringFilter computePreviousPeriodFilter(PeriodChoice periodChoice) { + LetteringFilter previousPeriodFilter = null; + FiscalPeriod previousFiscalPeriod; + Date dateStart = null, dateEnd = null; + switch (periodChoice) { + case FINANCIAL_PERIOD: + Date financialPeriodDate = filter.getFinancialPeriod().getBeginDate(); + FiscalPeriod fiscalPeriodFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(financialPeriodDate); + dateStart = fiscalPeriodFiscalPeriod.getBeginDate(); + dateEnd = getDayMinus1Calendar(financialPeriodDate).getTime(); + break; + case FISCAL_PERIOD: + previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(getDayMinus1Calendar(filter.getFiscalPeriod().getBeginDate()).getTime()); + if (previousFiscalPeriod != null) { + dateStart = previousFiscalPeriod.getBeginDate(); + dateEnd = previousFiscalPeriod.getEndDate(); + } + break; + case DATE: + previousFiscalPeriod = filter.getFiscalPeriod(); + + if (previousFiscalPeriod != null && DateUtils.isSameDay(previousFiscalPeriod.getBeginDate(), filter.getDateStart())) { + previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(getDayMinus1Calendar(filter.getDateStart()).getTime()); + } + + if (previousFiscalPeriod == null) { + FiscalPeriod lastFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); + previousFiscalPeriod = lastFiscalPeriod != null && lastFiscalPeriod.getEndDate().before(filter.getDateStart()) ? lastFiscalPeriod : null; + } + + if (previousFiscalPeriod != null) { + dateStart = previousFiscalPeriod.getBeginDate(); + dateEnd = getDayMinus1Calendar(filter.getDateStart()).getTime(); + } + break; + } + + if (dateStart != null && dateEnd != null) { + previousPeriodFilter = new LetteringFilterImpl(); + previousPeriodFilter.setDateStart(dateStart); + previousPeriodFilter.setDateEnd(dateEnd); + previousPeriodFilter.setAccount(filter.getAccount()); + } + + return previousPeriodFilter; + } + + private LetteringFilter computeActualPeriodFilter(PeriodChoice choice) { + LetteringFilter actualPeriodFilter = null; + Date dateStart = null, dateEnd = null; + switch (choice) { + case FINANCIAL_PERIOD: + if (filter.getFinancialPeriod() != null) { + Date financialPeriodDate = filter.getFinancialPeriod().getBeginDate(); + FiscalPeriod fiscalPeriodFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(financialPeriodDate); + dateStart = fiscalPeriodFiscalPeriod.getBeginDate(); + dateEnd = filter.getFinancialPeriod().getEndDate(); + } + break; + case FISCAL_PERIOD: + dateStart = filter.getFiscalPeriod() == null ? null : filter.getFiscalPeriod().getBeginDate(); + dateEnd = filter.getFiscalPeriod() == null ? null : filter.getFiscalPeriod().getEndDate(); + break; + case DATE: + dateStart = filter.getFiscalPeriod() == null ? filter.getDateStart() : filter.getFiscalPeriod().getBeginDate(); + dateEnd = filter.getDateEnd(); + break; + } + if (dateStart != null && dateEnd != null) { + actualPeriodFilter = new LetteringFilterImpl(); + actualPeriodFilter.setDateStart(dateStart); + actualPeriodFilter.setDateEnd(dateEnd); + actualPeriodFilter.setAccount(filter.getAccount()); + } + return actualPeriodFilter; + } + public void initFiscalPeriodView() { List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods(); view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + filter.setPeriodChoice(PeriodChoice.FISCAL_PERIOD); FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); if (fiscalPeriod != null) { filter.setFiscalPeriod(fiscalPeriod); @@ -393,23 +493,24 @@ public class AccountViewerViewHandler { } } - public void initDefaultFinancialPeriodView() { - FiscalPeriod fiscalPeriod = (FiscalPeriod) view.getFiscalPeriodComboBox().getSelectedItem(); + public void updateFinancialPeriodView(FiscalPeriod fiscalPeriodO) { + FiscalPeriod fiscalPeriod = fiscalPeriodO == null ? fiscalPeriodService.getLastFiscalPeriod() : fiscalPeriodO; FinancialPeriod defaultFinancialPeriod = null; if (fiscalPeriod != null) { List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); - - boolean isCurrentDatePartOfSelectedFiscalPeriod; Date today = new Date(); - isCurrentDatePartOfSelectedFiscalPeriod = fiscalPeriod.getBeginDate().before(today) && (fiscalPeriod.getEndDate().after(today)); - if (isCurrentDatePartOfSelectedFiscalPeriod) { - defaultFinancialPeriod = financialPeriodService.getFinancialForDate(today); - } else if (!financialPeriods.isEmpty()) { - defaultFinancialPeriod = financialPeriods.get(financialPeriods.size() - 1); + + Iterator<FinancialPeriod> financialPeriodIterator = financialPeriods.iterator(); + while (financialPeriodIterator.hasNext() && defaultFinancialPeriod == null) { + FinancialPeriod financialPeriod = financialPeriodIterator.next(); + defaultFinancialPeriod = financialPeriod.getBeginDate().before(today) && financialPeriod.getEndDate().after(today) ? financialPeriod : null; } + defaultFinancialPeriod = defaultFinancialPeriod != null ? defaultFinancialPeriod : financialPeriods.get(financialPeriods.size() - 1); view.getFinancialPeriodComboBoxModel().setSelectedItem(defaultFinancialPeriod); + + initFiscalPeriodCombo(); } Date defaultDateBegin, defaultDateEnd; @@ -421,41 +522,50 @@ public class AccountViewerViewHandler { filter.setDateStart(defaultDateBegin); filter.setDateEnd(defaultDateEnd); + filter.setFiscalPeriod(fiscalPeriod); + filter.setFinancialPeriod(defaultFinancialPeriod); + filter.setPeriodChoice(PeriodChoice.FINANCIAL_PERIOD); + } - editModel.setFiscalPeriodBeginDate(defaultFinancialPeriod != null ? defaultFinancialPeriod.getBeginDate() : defaultDateBegin); + protected void initFiscalPeriodCombo() { + List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods(); + view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + view.getFiscalPeriodComboBox().setSelectedItem(fiscalPeriods.get(fiscalPeriods.size()-1)); + view.getFiscalPeriodComboBox().setVisible(true); } protected void initSoldPeriodView() { - view.getBeginPeriodSummary().setText(String.format("Pour la période du %s au %s,", getDateFormat().format(editModel.getFiscalPeriodBeginDate()), getDateFormat().format(filter.getDateEnd()))); + view.getBeginPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(filter.getFiscalPeriod().getBeginDate()), getDateFormat().format(getDayMinus1Calendar(filter.getFinancialPeriod().getBeginDate()).getTime()))); view.getBeginDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); - view.getEndPeriodSummary().setText(String.format("Pour la période du %s au %s,", getDateFormat().format(editModel.getFiscalPeriodBeginDate()), getDateFormat().format(filter.getDateEnd()))); + view.getEndPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(filter.getFiscalPeriod().getBeginDate()), getDateFormat().format(filter.getFinancialPeriod().getEndDate()))); view.getEndDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getEndCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getEndSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); } - protected void addFiscalPeriodBeginDate(FiscalPeriod fiscalPeriod) { - if (fiscalPeriod != null) { - editModel.setFiscalPeriodBeginDate(fiscalPeriod.getBeginDate()); + protected void setViewPreviousSold(LetteringFilter previousPeriodFilter) { + if (previousPeriodFilter != null) { + List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(previousPeriodFilter); + DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); + view.getBeginPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(previousPeriodFilter.getDateStart()), getDateFormat().format(previousPeriodFilter.getDateEnd()))); + view.getBeginDebit().setText(BigDecimalToString.format(debitCreditSold.getDebit())); + view.getBeginCredit().setText(BigDecimalToString.format(debitCreditSold.getCredit())); + view.getBeginSold().setText(BigDecimalToString.format(debitCreditSold.getSold())); + } else { + view.getBeginPeriodSummary().setText("Pas de période précédente,"); + view.getBeginDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); + view.getBeginCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); + view.getBeginSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); } - } - protected void setViewPreviousSold(LetteringFilter previousPeriodFilter) { - List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(previousPeriodFilter); - DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); - view.getBeginPeriodSummary().setText(String.format("Pour la période du %s au %s,", getDateFormat().format(previousPeriodFilter.getDateStart()), getDateFormat().format(previousPeriodFilter.getDateEnd()))); - view.getBeginDebit().setText(BigDecimalToString.format(debitCreditSold.getDebit())); - view.getBeginCredit().setText(BigDecimalToString.format(debitCreditSold.getCredit())); - view.getBeginSold().setText(BigDecimalToString.format(debitCreditSold.getSold())); } - protected void setViewActualSold(FiscalPeriod fiscalPeriod, LetteringFilter actualPeriodFilter) { - addFiscalPeriodBeginDate(fiscalPeriod); + protected void setViewActualSold(LetteringFilter actualPeriodFilter) { List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(actualPeriodFilter); DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); - view.getEndPeriodSummary().setText(String.format("Pour la période du %s au %s,", getDateFormat().format(actualPeriodFilter.getDateStart()), getDateFormat().format(actualPeriodFilter.getDateEnd()))); + view.getEndPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(actualPeriodFilter.getDateStart()), getDateFormat().format(actualPeriodFilter.getDateEnd()))); view.getEndDebit().setText(BigDecimalToString.format(debitCreditSold.getDebit())); view.getEndCredit().setText(BigDecimalToString.format(debitCreditSold.getCredit())); view.getEndSold().setText(BigDecimalToString.format(debitCreditSold.getSold())); @@ -504,7 +614,7 @@ public class AccountViewerViewHandler { editModel.setDebit(BigDecimal.ZERO); editModel.setSold(BigDecimal.ZERO, false); } else { - balanceCalculation(balance.getAmount(), balance.isDebit()); + selectedEntriesBalanceCalculation(balance.getAmount(), balance.isDebit()); } } @@ -512,7 +622,7 @@ public class AccountViewerViewHandler { * @param amount debit or credit * @param debit it indicate if amount is debit or not * */ - public void balanceCalculation(BigDecimal amount, boolean debit){ + public void selectedEntriesBalanceCalculation(BigDecimal amount, boolean debit){ BigDecimal debitVal = debit ? amount : BigDecimal.ZERO; BigDecimal creditVal = debit ? BigDecimal.ZERO : amount; @@ -524,36 +634,17 @@ public class AccountViewerViewHandler { if (debitVal.equals(BigDecimal.ZERO)){ if (!creditVal.equals(BigDecimal.ZERO)){ - editModel.setCredit(creditVal); editModel.setSold(creditVal, true); } - }else if (creditVal.equals(BigDecimal.ZERO)){ + } else if (creditVal.equals(BigDecimal.ZERO)){ editModel.setDebit(debitVal); editModel.setSold(debitVal, false); - }else{ + } else{ onBalanceChanged(null); } } - protected LetteringFilter computePreviousPeriodFilter(FiscalPeriod fiscalPeriod) { - LetteringFilter previousPeriodFilter = new LetteringFilterImpl(); - previousPeriodFilter.setDateStart(fiscalPeriod == null ? filter.getDateStart() : fiscalPeriod.getBeginDate()); - previousPeriodFilter.setDateEnd(filter.getDateStart()); - previousPeriodFilter.setAccount(filter.getAccount()); - - return previousPeriodFilter; - } - - private LetteringFilter computeActualPeriodFilter(FiscalPeriod fiscalPeriod) { - LetteringFilter actualPeriodFilter = new LetteringFilterImpl(); - actualPeriodFilter.setDateStart(fiscalPeriod == null ? filter.getDateStart() : fiscalPeriod.getBeginDate()); - actualPeriodFilter.setDateEnd(filter.getDateEnd()); - actualPeriodFilter.setAccount(filter.getAccount()); - - return actualPeriodFilter; - } - protected class DebitCreditSold { private BigDecimal debit; private BigDecimal credit; @@ -597,7 +688,7 @@ public class AccountViewerViewHandler { public void setAccount(Account account) { if (filter != null) { filter.setAccount(account); - updateAllEntries(null); + updateAllEntries(); } } @@ -609,9 +700,9 @@ public class AccountViewerViewHandler { return account; } - protected Calendar getDayMinus1Calendar(LetteringFilter previousPeriodFilter) { + protected Calendar getDayMinus1Calendar(Date date) { Calendar cal = Calendar.getInstance(); - cal.setTime(previousPeriodFilter.getDateEnd()); + cal.setTime(date); cal.add(Calendar.DATE, -1); return cal; } 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 d35494e..3e2bafa 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 @@ -16,6 +16,7 @@ lima.account.update.error.invalidAccountNumber=Invalid account number\: %1$s lima.account.update.form=Update account lima.accountViewer.previousSold=<html><b>On %s the sold was</b></html> lima.accountViewer.selectionDescription=For selected entries, +lima.accountingView.summaryLabel=Period from %s to %s, lima.accounts=Accounts lima.action.commandline.help=Show help in console lima.balance=Balance 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 26c6e40..d8ac590 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 @@ -19,6 +19,7 @@ lima.account.update.error.invalidAccountNumber=Le numéro du compte %1$s n'est p lima.account.update.form=Modification d'un compte lima.accountViewer.previousSold=<html><b>Solde au %s</b></html> lima.accountViewer.selectionDescription=Pour la sélection, +lima.accountingView.summaryLabel=Pour la période du %s au %s, lima.accounts=Comptes lima.action.commandline.help=Afficher l'aide en console lima.balance=Équilibrer -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 94833f16f8726df63a24abf9703799def4e28a2c Author: dcosse <cosse@codelutin.com> Date: Thu Sep 24 12:54:04 2015 +0200 refs #1293 corrections et refactoring --- .../ui/accountViewer/AccountViewerViewHandler.java | 137 ++++++++++++--------- .../resources/i18n/lima-swing_en_GB.properties | 3 + .../resources/i18n/lima-swing_fr_FR.properties | 3 + 3 files changed, 87 insertions(+), 56 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index 2c120dd..fd53279 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -53,6 +53,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.math.BigDecimal; import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Iterator; @@ -92,6 +93,7 @@ public class AccountViewerViewHandler { private static final Log log = LogFactory.getLog(AccountViewerViewHandler.class); protected boolean initializationComplete; + public static final SimpleDateFormat YYYY = new SimpleDateFormat("yyyy"); public AccountViewerViewHandler(AccountViewerView view) { @@ -114,7 +116,7 @@ public class AccountViewerViewHandler { public void init() { filter = new AccountViewerFilter(); editModel = view.getEditModel(); - updateFinancialPeriodView(null); + updateFinancialPeriodView(); initSoldPeriodView(); editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { @@ -224,7 +226,7 @@ public class AccountViewerViewHandler { } private void updateAllEntriesForFinancialPeriodChoice() { - updateFinancialPeriodView(filter.getFiscalPeriod()); + updateFinancialPeriodView(); updateAllEntries(); } @@ -266,25 +268,23 @@ public class AccountViewerViewHandler { protected void onFiscalPeriodChange(ItemEvent event) { FiscalPeriod selectedFiscalPeriod = event != null && event.getItem() != null ? (FiscalPeriod) event.getItem() : null; if (initializationComplete && selectedFiscalPeriod != null && !selectedFiscalPeriod.equals(filter.getFiscalPeriod())) { - - List<FinancialPeriod> periods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); - FinancialPeriod selectedFinancialPeriod = periods.get(0); - view.getFinancialPeriodComboBoxModel().setObjects(periods); - view.getFinancialPeriodComboBoxModel().setSelectedItem(selectedFinancialPeriod); - - filter.setDateStart(selectedFinancialPeriod.getBeginDate()); - filter.setDateEnd(selectedFinancialPeriod.getEndDate()); - filter.setFiscalPeriod(selectedFiscalPeriod); - filter.setFinancialPeriod(selectedFinancialPeriod); - filter.setPeriodChoice(PeriodChoice.FINANCIAL_PERIOD); + if (PeriodChoice.FINANCIAL_PERIOD.equals(filter.getPeriodChoice())) { + List<FinancialPeriod> periods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); + FinancialPeriod selectedFinancialPeriod = periods.get(0); + view.getFinancialPeriodComboBoxModel().setObjects(periods); + view.getFinancialPeriodComboBoxModel().setSelectedItem(selectedFinancialPeriod); + + setFilter(selectedFiscalPeriod, selectedFinancialPeriod, selectedFinancialPeriod.getBeginDate(), selectedFinancialPeriod.getEndDate(), PeriodChoice.FINANCIAL_PERIOD); + } else { + setFilter(selectedFiscalPeriod, null, selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate(), PeriodChoice.FISCAL_PERIOD); + } updateAllEntries(); } } protected void onFinancialPeriodChange(java.awt.event.ItemEvent event) { FinancialPeriod financialPeriod = (FinancialPeriod) event.getItem(); - if (initializationComplete && !filter.getFinancialPeriod().equals(financialPeriod)) { - filter.setFinancialPeriod(financialPeriod); + if (initializationComplete && filter.getFinancialPeriod() == null || !filter.getFinancialPeriod().equals(financialPeriod)) { updateAllEntriesForFinancialPeriodChoice(financialPeriod); } } @@ -341,24 +341,25 @@ public class AccountViewerViewHandler { public void updateAllEntriesForFiscalPeriodChoice(FiscalPeriod fiscalPeriod) { - filter.setFiscalPeriod(fiscalPeriod); - filter.setDateStart(fiscalPeriod.getBeginDate()); - filter.setDateEnd(fiscalPeriod.getEndDate()); - filter.setPeriodChoice(PeriodChoice.FISCAL_PERIOD); + setFilter(fiscalPeriod, null, fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), PeriodChoice.FISCAL_PERIOD); updateAllEntries(); } public void updateAllEntriesForFinancialPeriodChoice(FinancialPeriod financialPeriod) { - filter.setDateStart(financialPeriod.getBeginDate()); - filter.setDateEnd(financialPeriod.getEndDate()); - filter.setPeriodChoice(PeriodChoice.FINANCIAL_PERIOD); + setFilter(null, financialPeriod, financialPeriod.getBeginDate(), financialPeriod.getEndDate(), PeriodChoice.FINANCIAL_PERIOD); updateAllEntries(); + } + protected void setFilter(FiscalPeriod fiscalPeriod, FinancialPeriod financialPeriod, Date dateStart, Date dateEnd, PeriodChoice periodChoice) { + filter.setFiscalPeriod(fiscalPeriod); + filter.setFinancialPeriod(financialPeriod); + filter.setDateStart(dateStart); + filter.setDateEnd(dateEnd); + filter.setPeriodChoice(periodChoice); } public void updateAllEntriesForDateChange() { filter.setPeriodChoice(PeriodChoice.DATE); - filter.setFiscalPeriod(fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart())); updateAllEntries(); } @@ -377,22 +378,26 @@ public class AccountViewerViewHandler { } protected void updateSummary() { - PeriodChoice periodChoice = filter.getPeriodChoice(); - LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(periodChoice); - LetteringFilter actualPeriodFilter = computeActualPeriodFilter(periodChoice); + LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(); + LetteringFilter actualPeriodFilter = computeActualPeriodFilter(); setViewPreviousSold(previousPeriodFilter); setViewActualSold(actualPeriodFilter); } - protected LetteringFilter computePreviousPeriodFilter(PeriodChoice periodChoice) { + protected LetteringFilter computePreviousPeriodFilter() { LetteringFilter previousPeriodFilter = null; FiscalPeriod previousFiscalPeriod; Date dateStart = null, dateEnd = null; - switch (periodChoice) { + switch (filter.getPeriodChoice()) { case FINANCIAL_PERIOD: Date financialPeriodDate = filter.getFinancialPeriod().getBeginDate(); FiscalPeriod fiscalPeriodFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(financialPeriodDate); - dateStart = fiscalPeriodFiscalPeriod.getBeginDate(); + + if (DateUtils.isSameDay(financialPeriodDate, fiscalPeriodFiscalPeriod.getBeginDate())) { + fiscalPeriodFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(getDayMinus1Calendar(financialPeriodDate).getTime()); + } + + dateStart = fiscalPeriodFiscalPeriod != null ? fiscalPeriodFiscalPeriod.getBeginDate() : null; dateEnd = getDayMinus1Calendar(financialPeriodDate).getTime(); break; case FISCAL_PERIOD: @@ -403,12 +408,14 @@ public class AccountViewerViewHandler { } break; case DATE: - previousFiscalPeriod = filter.getFiscalPeriod(); + previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()); + // case of starting date is same as current fiscal period one, so we look for previous fiscal period if (previousFiscalPeriod != null && DateUtils.isSameDay(previousFiscalPeriod.getBeginDate(), filter.getDateStart())) { previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(getDayMinus1Calendar(filter.getDateStart()).getTime()); } + // case of selected date is upper the last fiscal period we look for the last fiscal period if (previousFiscalPeriod == null) { FiscalPeriod lastFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); previousFiscalPeriod = lastFiscalPeriod != null && lastFiscalPeriod.getEndDate().before(filter.getDateStart()) ? lastFiscalPeriod : null; @@ -431,10 +438,10 @@ public class AccountViewerViewHandler { return previousPeriodFilter; } - private LetteringFilter computeActualPeriodFilter(PeriodChoice choice) { + private LetteringFilter computeActualPeriodFilter() { LetteringFilter actualPeriodFilter = null; Date dateStart = null, dateEnd = null; - switch (choice) { + switch (filter.getPeriodChoice()) { case FINANCIAL_PERIOD: if (filter.getFinancialPeriod() != null) { Date financialPeriodDate = filter.getFinancialPeriod().getBeginDate(); @@ -465,13 +472,10 @@ public class AccountViewerViewHandler { List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods(); view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); - filter.setPeriodChoice(PeriodChoice.FISCAL_PERIOD); FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); if (fiscalPeriod != null) { - filter.setFiscalPeriod(fiscalPeriod); - filter.setDateStart(fiscalPeriod.getBeginDate()); - filter.setDateEnd(fiscalPeriod.getEndDate()); - view.getFiscalPeriodComboBox().setSelectedItem(fiscalPeriod); + setFilter(fiscalPeriod, null, fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), PeriodChoice.FINANCIAL_PERIOD); + view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriod); view.getFiscalPeriodComboBox().setVisible(true); } } @@ -486,31 +490,30 @@ public class AccountViewerViewHandler { if (defaultFinancialPeriod == null) { defaultFinancialPeriod = financialPeriodService.getFinancialForDate(fiscalPeriod.getEndDate()); } - filter.setDateStart(defaultFinancialPeriod.getBeginDate()); - filter.setDateEnd(defaultFinancialPeriod.getEndDate()); + setFilter(null, null, defaultFinancialPeriod.getBeginDate(), defaultFinancialPeriod.getEndDate(), PeriodChoice.DATE); view.getBeginPeriodPicker().setDate(defaultFinancialPeriod.getBeginDate()); view.getEndPeriodPicker().setDate(defaultFinancialPeriod.getEndDate()); } } - public void updateFinancialPeriodView(FiscalPeriod fiscalPeriodO) { - FiscalPeriod fiscalPeriod = fiscalPeriodO == null ? fiscalPeriodService.getLastFiscalPeriod() : fiscalPeriodO; - + public void updateFinancialPeriodView() { + FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); FinancialPeriod defaultFinancialPeriod = null; + List<FinancialPeriod> financialPeriods = null; if (fiscalPeriod != null) { - List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); - view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); - Date today = new Date(); + view.getFinancialPeriodComboBoxModel().removeAllElements(); + + financialPeriods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); + Date today = new Date(); Iterator<FinancialPeriod> financialPeriodIterator = financialPeriods.iterator(); while (financialPeriodIterator.hasNext() && defaultFinancialPeriod == null) { FinancialPeriod financialPeriod = financialPeriodIterator.next(); defaultFinancialPeriod = financialPeriod.getBeginDate().before(today) && financialPeriod.getEndDate().after(today) ? financialPeriod : null; } + defaultFinancialPeriod = defaultFinancialPeriod != null ? defaultFinancialPeriod : financialPeriods.get(financialPeriods.size() - 1); - view.getFinancialPeriodComboBoxModel().setSelectedItem(defaultFinancialPeriod); - initFiscalPeriodCombo(); } Date defaultDateBegin, defaultDateEnd; @@ -520,17 +523,24 @@ public class AccountViewerViewHandler { defaultDateBegin = defaultFinancialPeriod == null ? DateUtils.setDays(new Date(), firstCurrentMonthDay) : defaultFinancialPeriod.getBeginDate(); defaultDateEnd = defaultFinancialPeriod == null ? DateUtils.setDays(new Date(), lastCurrentMonthDay) : defaultFinancialPeriod.getEndDate(); - filter.setDateStart(defaultDateBegin); - filter.setDateEnd(defaultDateEnd); - filter.setFiscalPeriod(fiscalPeriod); - filter.setFinancialPeriod(defaultFinancialPeriod); - filter.setPeriodChoice(PeriodChoice.FINANCIAL_PERIOD); + setFilter(fiscalPeriod, defaultFinancialPeriod, defaultDateBegin, defaultDateEnd, PeriodChoice.FINANCIAL_PERIOD); + + initFiscalPeriodCombo(); + updateFinancialPeriodCombo(defaultFinancialPeriod, financialPeriods); + + } + + protected void updateFinancialPeriodCombo(FinancialPeriod defaultFinancialPeriod, List<FinancialPeriod> financialPeriods) { + view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); + if (defaultFinancialPeriod != null) { + view.getFinancialPeriodComboBoxModel().setSelectedItem(defaultFinancialPeriod); + } } protected void initFiscalPeriodCombo() { List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods(); view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); - view.getFiscalPeriodComboBox().setSelectedItem(fiscalPeriods.get(fiscalPeriods.size()-1)); + view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(fiscalPeriods.size() - 1)); view.getFiscalPeriodComboBox().setVisible(true); } @@ -547,14 +557,22 @@ public class AccountViewerViewHandler { protected void setViewPreviousSold(LetteringFilter previousPeriodFilter) { if (previousPeriodFilter != null) { + if (filter.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD)) { + String summaryLabel = t("lima.accountingView.summaryFiscalPeriodLabel"); + view.getBeginPeriodSummary().setText(String.format(t(summaryLabel), YYYY.format(previousPeriodFilter.getDateStart()))); + } else { + String summaryLabel = t("lima.accountingView.summaryLabel"); + view.getBeginPeriodSummary().setText(String.format(t(summaryLabel), getDateFormat().format(previousPeriodFilter.getDateStart()), getDateFormat().format(getDayMinus1Calendar(previousPeriodFilter.getDateEnd()).getTime()))); + } + List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToExcludingPeriod(previousPeriodFilter); DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); - view.getBeginPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(previousPeriodFilter.getDateStart()), getDateFormat().format(previousPeriodFilter.getDateEnd()))); view.getBeginDebit().setText(BigDecimalToString.format(debitCreditSold.getDebit())); view.getBeginCredit().setText(BigDecimalToString.format(debitCreditSold.getCredit())); view.getBeginSold().setText(BigDecimalToString.format(debitCreditSold.getSold())); } else { - view.getBeginPeriodSummary().setText("Pas de période précédente,"); + String summaryLabel = filter.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD) ? t("lima.accountingView.summaryNoFiscalPeriodLabel") : t("lima.accountingView.summaryNoPeriodLabel"); + view.getBeginPeriodSummary().setText(summaryLabel); view.getBeginDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); @@ -563,9 +581,16 @@ public class AccountViewerViewHandler { } protected void setViewActualSold(LetteringFilter actualPeriodFilter) { + if (filter.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD)) { + String summaryLabel = t("lima.accountingView.summaryFiscalPeriodLabel"); + view.getEndPeriodSummary().setText(String.format(t(summaryLabel), YYYY.format(actualPeriodFilter.getDateEnd()))); + } else { + String summaryLabel = t("lima.accountingView.summaryLabel"); + view.getEndPeriodSummary().setText(String.format(t(summaryLabel), getDateFormat().format(actualPeriodFilter.getDateStart()), getDateFormat().format(actualPeriodFilter.getDateEnd()))); + } + List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(actualPeriodFilter); DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); - view.getEndPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(actualPeriodFilter.getDateStart()), getDateFormat().format(actualPeriodFilter.getDateEnd()))); view.getEndDebit().setText(BigDecimalToString.format(debitCreditSold.getDebit())); view.getEndCredit().setText(BigDecimalToString.format(debitCreditSold.getCredit())); view.getEndSold().setText(BigDecimalToString.format(debitCreditSold.getSold())); 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 3e2bafa..bef1571 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 @@ -16,7 +16,10 @@ lima.account.update.error.invalidAccountNumber=Invalid account number\: %1$s lima.account.update.form=Update account lima.accountViewer.previousSold=<html><b>On %s the sold was</b></html> lima.accountViewer.selectionDescription=For selected entries, +lima.accountingView.summaryFiscalPeriodLabel=For %s fiscal period, lima.accountingView.summaryLabel=Period from %s to %s, +lima.accountingView.summaryNoFiscalPeriodLabel=No previous fiscal period, +lima.accountingView.summaryNoPeriodLabel=No previous period, lima.accounts=Accounts lima.action.commandline.help=Show help in console lima.balance=Balance 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 d8ac590..5481e90 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 @@ -19,7 +19,10 @@ lima.account.update.error.invalidAccountNumber=Le numéro du compte %1$s n'est p lima.account.update.form=Modification d'un compte lima.accountViewer.previousSold=<html><b>Solde au %s</b></html> lima.accountViewer.selectionDescription=Pour la sélection, +lima.accountingView.summaryFiscalPeriodLabel=Pour l'exercice %s, lima.accountingView.summaryLabel=Pour la période du %s au %s, +lima.accountingView.summaryNoFiscalPeriodLabel=Pas d'exercice précédent, +lima.accountingView.summaryNoPeriodLabel=Pas de période précédente, lima.accounts=Comptes lima.action.commandline.help=Afficher l'aide en console lima.balance=Équilibrer -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 8373b3460d6f4d3da372ed7a005e8e6b5fdbdad9 Author: dcosse <cosse@codelutin.com> Date: Thu Sep 24 14:19:40 2015 +0200 refs #1293 corrections pour le cas ou aucune données existe dans Lima --- .../ui/accountViewer/AccountViewerViewHandler.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index fd53279..be14b20 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -341,8 +341,10 @@ public class AccountViewerViewHandler { public void updateAllEntriesForFiscalPeriodChoice(FiscalPeriod fiscalPeriod) { - setFilter(fiscalPeriod, null, fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), PeriodChoice.FISCAL_PERIOD); - updateAllEntries(); + if (fiscalPeriod != null) { + setFilter(fiscalPeriod, null, fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), PeriodChoice.FISCAL_PERIOD); + updateAllEntries(); + } } public void updateAllEntriesForFinancialPeriodChoice(FinancialPeriod financialPeriod) { @@ -531,8 +533,8 @@ public class AccountViewerViewHandler { } protected void updateFinancialPeriodCombo(FinancialPeriod defaultFinancialPeriod, List<FinancialPeriod> financialPeriods) { - view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); - if (defaultFinancialPeriod != null) { + if (CollectionUtils.isNotEmpty(financialPeriods)) { + view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); view.getFinancialPeriodComboBoxModel().setSelectedItem(defaultFinancialPeriod); } } @@ -540,16 +542,22 @@ public class AccountViewerViewHandler { protected void initFiscalPeriodCombo() { List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods(); view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); - view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(fiscalPeriods.size() - 1)); + if (CollectionUtils.isNotEmpty(fiscalPeriods)) { + view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(fiscalPeriods.size() - 1)); + } view.getFiscalPeriodComboBox().setVisible(true); } protected void initSoldPeriodView() { - view.getBeginPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(filter.getFiscalPeriod().getBeginDate()), getDateFormat().format(getDayMinus1Calendar(filter.getFinancialPeriod().getBeginDate()).getTime()))); + Date ppbd = filter.getFiscalPeriod() != null ? filter.getFiscalPeriod().getBeginDate() : new Date(); + Date pped = filter.getFinancialPeriod() != null ? getDayMinus1Calendar(filter.getFinancialPeriod().getBeginDate()).getTime() : new Date(); + view.getBeginPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(ppbd), getDateFormat().format(pped))); view.getBeginDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); - view.getEndPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(filter.getFiscalPeriod().getBeginDate()), getDateFormat().format(filter.getFinancialPeriod().getEndDate()))); + + Date aped = filter.getFinancialPeriod() != null ? filter.getFinancialPeriod().getEndDate() : new Date(); + view.getEndPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(ppbd), getDateFormat().format(aped))); view.getEndDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getEndCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getEndSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 8ac5089a81041bf740453bcdca499227acd61e0d Author: dcosse <cosse@codelutin.com> Date: Fri Sep 25 13:05:56 2015 +0200 refs #1293 corrige exception dans le cas ou aucune periode financière existe avec la date choisie --- .../org/chorem/lima/business/api/FinancialPeriodService.java | 2 ++ .../chorem/lima/business/ejb/FinancialPeriodServiceImpl.java | 8 ++++++++ .../java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java | 10 ++++++++++ .../chorem/lima/ui/accountViewer/AccountViewerViewHandler.java | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java index 4ed0a10..d164f4e 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java @@ -60,6 +60,8 @@ public interface FinancialPeriodService { FinancialPeriod getFinancialForDate(Date date); + FinancialPeriod getFinancialPeriodIfExistsByDate(Date date); + List<FinancialPeriod> getFinancialPeriodsWithBeginDateWithin(Date beginDateFirst, Date endDateLast); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java index 02c2df2..86551c9 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java @@ -71,6 +71,14 @@ public class FinancialPeriodServiceImpl extends AbstractLimaService implements F return result; } + @Override + public FinancialPeriod getFinancialPeriodIfExistsByDate(Date date) { + FinancialPeriodTopiaDao financialPeriodTopiaDao = getDaoHelper().getFinancialPeriodDao(); + FinancialPeriod result = financialPeriodTopiaDao.findByDateIfExists(date); + + return result; + } + /** @return all financial period from a fiscal period */ @Override public List<FinancialPeriod> getFinancialPeriodsWithBeginDateWithin(Date beginDateFirst, Date endDateLast) { diff --git a/lima-business/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java b/lima-business/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java index 9d9a77d..f2139bb 100644 --- a/lima-business/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java +++ b/lima-business/src/main/java/org/chorem/lima/entity/FinancialPeriodTopiaDao.java @@ -45,6 +45,16 @@ public class FinancialPeriodTopiaDao extends AbstractFinancialPeriodTopiaDao<Fin FinancialPeriod financialPeriod = findUnique(builder.getHql(), builder.getHqlParameters()); return financialPeriod; } + + public FinancialPeriod findByDateIfExists(Date date) { + + HqlAndParametersBuilder<FinancialPeriod> builder = newHqlAndParametersBuilder(); + builder.addLowerOrEquals(FinancialPeriod.PROPERTY_BEGIN_DATE, date); + builder.addGreaterOrEquals(FinancialPeriod.PROPERTY_END_DATE, date); + + FinancialPeriod financialPeriod = findUniqueOrNull(builder.getHql(), builder.getHqlParameters()); + return financialPeriod; + } /** * Return all FinancialPeriod with begin date between two given dates. diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index be14b20..c425164 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -487,7 +487,7 @@ public class AccountViewerViewHandler { FinancialPeriod defaultFinancialPeriod; if (fiscalPeriod != null) { Date today = new Date(); - defaultFinancialPeriod = financialPeriodService.getFinancialForDate(today); + defaultFinancialPeriod = financialPeriodService.getFinancialPeriodIfExistsByDate(today); if (defaultFinancialPeriod == null) { defaultFinancialPeriod = financialPeriodService.getFinancialForDate(fiscalPeriod.getEndDate()); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 6b7523e723a1bd264e043b84b5bcabdf65a0e591 Author: dcosse <cosse@codelutin.com> Date: Fri Sep 25 13:08:29 2015 +0200 refs #1293 Correction i18n --- lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5481e90..c16da55 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 @@ -243,7 +243,7 @@ lima.filter.condition.delete=Supprimer la condition lima.filter.condition.one=Valide au moins une condition lima.filter.condition.periodChoice.date=Interval de Dates lima.filter.condition.periodChoice.financialPeriod=Période Financière -lima.filter.condition.periodChoice.fiscalPeriod=Execrice +lima.filter.condition.periodChoice.fiscalPeriod=Exercice lima.filter.condition.selectionMode=Sélection des écritures lettrées lima.filter.condition.selectionMode.lettered=Lettré lima.filter.condition.selectionMode.manual=Manuelle -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 358093cc17895cd3dfd9aae8dca31d33743e7b07 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 30 14:49:39 2015 +0200 refs #1268 déplacement des models du jaxx au handler --- .../lima/ui/accountViewer/AccountViewerView.jaxx | 22 +--- .../ui/accountViewer/AccountViewerViewHandler.java | 120 +++++++++++++++------ 2 files changed, 89 insertions(+), 53 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx index d03a614..a1c21f0 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerView.jaxx @@ -24,22 +24,12 @@ java.awt.FlowLayout java.awt.Dimension org.chorem.lima.util.WrapToolBarLayout - org.chorem.lima.ui.common.FinancialPeriodComboBoxModel - org.chorem.lima.util.BigDecimalToString - org.chorem.lima.ui.lettering.TypeEntry - org.chorem.lima.entity.Account - javax.swing.ListSelectionModel - org.jdesktop.swingx.JXDatePicker static org.nuiton.i18n.I18n.t org.chorem.lima.ui.combobox.AccountComboBox - org.chorem.lima.ui.LimaRendererUtil - org.chorem.lima.entity.FinancialPeriod </import> <AccountViewerViewHandler id="handler" constructorParams="this"/> - <AccountViewerEditModel id='editModel'/> - <script> <![CDATA[ void $afterCompleteSetup() { @@ -72,14 +62,10 @@ <JLabel id="beginPeriodLabel"/> - <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> <JComboBox id="fiscalPeriodComboBox" - model="{fiscalPeriodComboBoxModel}" onItemStateChanged="handler.onFiscalPeriodChange(event)"/> - <org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodComboBoxModel"/> <JComboBox id="financialPeriodComboBox" - model="{financialPeriodComboBoxModel}" onItemStateChanged="handler.onFinancialPeriodChange(event)"/> <JAXXDatePicker id="beginPeriodPicker" @@ -119,14 +105,8 @@ </JPanel> <JScrollPane constraints="BorderLayout.CENTER"> - <AccountViewerTableModel id="tableModel"/> - <AccountViewerSelectionModel id='accountViewerSelectionModel' constructorParams='tableModel' - onValueChanged="handler.balanceAndActions()"/> - <AccountViewerTable id="table" - constructorParams="handler" - model="{tableModel}" - selectionModel="{accountViewerSelectionModel}"/> + constructorParams="handler"/> </JScrollPane> <JPanel constraints="BorderLayout.SOUTH" layout="{new BorderLayout()}"> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index c425164..d79fbdc 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -41,10 +41,14 @@ import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.ui.combobox.AccountComboBox; +import org.chorem.lima.ui.common.FinancialPeriodComboBoxModel; +import org.chorem.lima.ui.common.FiscalPeriodComboBoxModel; import org.chorem.lima.util.BigDecimalToString; import org.chorem.lima.util.ErrorHelper; import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.ItemEvent; @@ -84,7 +88,11 @@ public class AccountViewerViewHandler { protected AccountViewerFilter filter; + protected AccountViewerTableModel accountViewerTableModel; + protected AccountViewerSelectionModel accountViewerSelectionModel; protected AccountViewerEditModel editModel; + protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel; + protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel; protected ErrorHelper errorHelper; @@ -115,10 +123,50 @@ public class AccountViewerViewHandler { */ public void init() { filter = new AccountViewerFilter(); - editModel = view.getEditModel(); - updateFinancialPeriodView(); + + createComponentsModels(); + + addModelsToComponents(); + + initAccountTableView(); + + addListeners(); + + initFinancialPeriodDefaultComponent(); + initSoldPeriodView(); + initializationComplete = true; + + updateSoldStatus(); + } + + protected void createComponentsModels() { + editModel = new AccountViewerEditModel(); + financialPeriodComboBoxModel = new FinancialPeriodComboBoxModel(); + fiscalPeriodComboBoxModel = new FiscalPeriodComboBoxModel(); + accountViewerTableModel = new AccountViewerTableModel(); + accountViewerSelectionModel = new AccountViewerSelectionModel(accountViewerTableModel); + } + + protected void addModelsToComponents() { + view.getFinancialPeriodComboBox().setModel(financialPeriodComboBoxModel); + view.getFiscalPeriodComboBox().setModel(fiscalPeriodComboBoxModel); + AccountViewerTable accountViewerTable = view.getTable(); + accountViewerTable.setModel(accountViewerTableModel); + accountViewerTable.setSelectionModel(accountViewerSelectionModel); + } + + protected void addListeners() { + accountViewerSelectionModel.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + if (!e.getValueIsAdjusting()) { + view.getHandler().balanceAndActions(); + } + } + }); + editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { @@ -146,16 +194,19 @@ public class AccountViewerViewHandler { updateSoldStatus(); } }); + } - onSelectionModeChanged(selectionMode); - - SwingUtil.fixTableColumnWidth(view.getTable(), 0, 100); - SwingUtil.fixTableColumnWidth(view.getTable(), 1, 60); - SwingUtil.fixTableColumnWidth(view.getTable(), 2, 80); - SwingUtil.fixTableColumnWidth(view.getTable(), 4, 50); + protected void initAccountTableView() { + AccountViewerTable accountViewerTable = view.getTable(); + SwingUtil.fixTableColumnWidth(accountViewerTable, 0, 100); + SwingUtil.fixTableColumnWidth(accountViewerTable, 1, 60); + SwingUtil.fixTableColumnWidth(accountViewerTable, 2, 80); + SwingUtil.fixTableColumnWidth(accountViewerTable, 4, 50); + } - initializationComplete = true; - updateSoldStatus(); + protected void initFinancialPeriodDefaultComponent() { + updateFinancialPeriodView(); + onSelectionModeChanged(selectionMode); } protected void initShortCuts() { @@ -243,7 +294,7 @@ public class AccountViewerViewHandler { if (row > 0) { comboBox.setSelectedIndex(row - 1); } - view.getAccountViewerSelectionModel().clearSelection(); + view.getTable().getSelectionModel().clearSelection(); } } @@ -261,7 +312,7 @@ public class AccountViewerViewHandler { if (row < size - 1) { comboBox.setSelectedIndex(row + 1); } - view.getAccountViewerSelectionModel().clearSelection(); + view.getTable().getSelectionModel().clearSelection(); } } @@ -271,8 +322,8 @@ public class AccountViewerViewHandler { if (PeriodChoice.FINANCIAL_PERIOD.equals(filter.getPeriodChoice())) { List<FinancialPeriod> periods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); FinancialPeriod selectedFinancialPeriod = periods.get(0); - view.getFinancialPeriodComboBoxModel().setObjects(periods); - view.getFinancialPeriodComboBoxModel().setSelectedItem(selectedFinancialPeriod); + financialPeriodComboBoxModel.setObjects(periods); + financialPeriodComboBoxModel.setSelectedItem(selectedFinancialPeriod); setFilter(selectedFiscalPeriod, selectedFinancialPeriod, selectedFinancialPeriod.getBeginDate(), selectedFinancialPeriod.getEndDate(), PeriodChoice.FINANCIAL_PERIOD); } else { @@ -282,7 +333,7 @@ public class AccountViewerViewHandler { } } - protected void onFinancialPeriodChange(java.awt.event.ItemEvent event) { + protected void onFinancialPeriodChange(ItemEvent event) { FinancialPeriod financialPeriod = (FinancialPeriod) event.getItem(); if (initializationComplete && filter.getFinancialPeriod() == null || !filter.getFinancialPeriod().equals(financialPeriod)) { updateAllEntriesForFinancialPeriodChoice(financialPeriod); @@ -317,16 +368,17 @@ public class AccountViewerViewHandler { } public void onSelectionModeChanged(SelectionMode selectionMode) { + AccountViewerSelectionModel accountViewerSelectionModel = (AccountViewerSelectionModel) view.getTable().getSelectionModel(); switch (selectionMode) { case LETTERED: - view.getAccountViewerSelectionModel().setLetteredSelectionMode(true); + accountViewerSelectionModel.setLetteredSelectionMode(true); break; case MANUAL: - view.getAccountViewerSelectionModel().setLetteredSelectionMode(false); + accountViewerSelectionModel.setLetteredSelectionMode(false); break; default: - view.getAccountViewerSelectionModel().setLetteredSelectionMode(true); + accountViewerSelectionModel.setLetteredSelectionMode(true); } } @@ -371,7 +423,8 @@ public class AccountViewerViewHandler { && filter.getDateStart() != null && filter.getDateEnd() != null) { List<Entry> entries = financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); - view.getTableModel().setValues(entries); + AccountViewerTableModel accountViewerTableModel = (AccountViewerTableModel) view.getTable().getModel(); + accountViewerTableModel.setValues(entries); updateSummary(); } @@ -472,12 +525,12 @@ public class AccountViewerViewHandler { public void initFiscalPeriodView() { List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods(); - view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + fiscalPeriodComboBoxModel.setObjects(fiscalPeriods); FiscalPeriod fiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); if (fiscalPeriod != null) { setFilter(fiscalPeriod, null, fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), PeriodChoice.FINANCIAL_PERIOD); - view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriod); + fiscalPeriodComboBoxModel.setSelectedItem(fiscalPeriod); view.getFiscalPeriodComboBox().setVisible(true); } } @@ -503,7 +556,7 @@ public class AccountViewerViewHandler { FinancialPeriod defaultFinancialPeriod = null; List<FinancialPeriod> financialPeriods = null; if (fiscalPeriod != null) { - view.getFinancialPeriodComboBoxModel().removeAllElements(); + financialPeriodComboBoxModel.removeAllElements(); financialPeriods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate()); @@ -534,16 +587,16 @@ public class AccountViewerViewHandler { protected void updateFinancialPeriodCombo(FinancialPeriod defaultFinancialPeriod, List<FinancialPeriod> financialPeriods) { if (CollectionUtils.isNotEmpty(financialPeriods)) { - view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); - view.getFinancialPeriodComboBoxModel().setSelectedItem(defaultFinancialPeriod); + financialPeriodComboBoxModel.setObjects(financialPeriods); + financialPeriodComboBoxModel.setSelectedItem(defaultFinancialPeriod); } } protected void initFiscalPeriodCombo() { List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllFiscalPeriods(); - view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + fiscalPeriodComboBoxModel.setObjects(fiscalPeriods); if (CollectionUtils.isNotEmpty(fiscalPeriods)) { - view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(fiscalPeriods.size() - 1)); + fiscalPeriodComboBoxModel.setSelectedItem(fiscalPeriods.get(fiscalPeriods.size() - 1)); } view.getFiscalPeriodComboBox().setVisible(true); } @@ -609,8 +662,9 @@ public class AccountViewerViewHandler { log.debug("balanceAndActions"); } onBalanceChanged(null); + AccountViewerSelectionModel accountViewerSelectionModel = (AccountViewerSelectionModel) view.getTable().getSelectionModel(); if (view.getTable().getSelectedRows().length > 0 && !letteringNotExist(view.getTable().getSelectedRow()) || - view.getTable().getSelectedRows().length > 0 && !view.getAccountViewerSelectionModel().isSelectionEmpty()) { + view.getTable().getSelectedRows().length > 0 && !accountViewerSelectionModel.isSelectionEmpty()) { setValuesForSelectedEntries(); } } @@ -622,7 +676,8 @@ public class AccountViewerViewHandler { public boolean letteringNotExist(int row){ boolean emptyOrNull = false; if (row != -1) { - Entry entry = view.getTableModel().get(row); + AccountViewerTableModel accountViewerTableModel = (AccountViewerTableModel) view.getTable().getModel(); + Entry entry = accountViewerTableModel.get(row); String lettering = entry.getLettering(); emptyOrNull = (lettering==null||lettering.isEmpty()); } @@ -631,10 +686,11 @@ public class AccountViewerViewHandler { public void setValuesForSelectedEntries() { Entry selectedEntry; - AccountViewerTableModel tableModel = view.getTableModel(); - for (int i = 0; i < tableModel.getRowCount(); i ++){ - if (view.getAccountViewerSelectionModel().isSelectedIndex(i)){ - selectedEntry = tableModel.get(i); + AccountViewerTableModel accountViewerTableModel = (AccountViewerTableModel) view.getTable().getModel(); + AccountViewerSelectionModel accountViewerSelectionModel = (AccountViewerSelectionModel) view.getTable().getSelectionModel(); + for (int i = 0; i < accountViewerTableModel.getRowCount(); i ++){ + if (accountViewerSelectionModel.isSelectedIndex(i)){ + selectedEntry = accountViewerTableModel.get(i); //Set values for calculation (By AccountViewerEditModel) of balance onBalanceChanged(selectedEntry); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 7824a86c725617cd2db11fa6caed3b64ec91310a Author: dcosse <cosse@codelutin.com> Date: Wed Sep 30 15:30:48 2015 +0200 refs #1268 déplacement de donnés liées au model de l'handler au model et suppression de listener innutils --- .../ui/accountViewer/AccountViewerEditModel.java | 68 +++++++-- .../lima/ui/accountViewer/AccountViewerFilter.java | 41 ------ .../ui/accountViewer/AccountViewerViewHandler.java | 163 +++++++++------------ 3 files changed, 120 insertions(+), 152 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java index 3399584..239c34c 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java @@ -21,10 +21,14 @@ */ package org.chorem.lima.ui.accountViewer; -import java.beans.PropertyChangeListener; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FiscalPeriod; + import java.beans.PropertyChangeSupport; import java.io.Serializable; import java.math.BigDecimal; +import java.util.Date; /** * @author sletellier <letellier@codelutin.com> @@ -32,12 +36,15 @@ import java.math.BigDecimal; public class AccountViewerEditModel implements Serializable { public static final String PROPERTY_DEBIT = "debit"; - public static final String PROPERTY_CREDIT = "credit"; - public static final String PROPERTY_SOLD = "sold"; - public static final String PROPERTY_GLOBAL_SOLD = "globalSold"; + protected PeriodChoice periodChoice = PeriodChoice.FINANCIAL_PERIOD; + protected FinancialPeriod financialPeriod; + protected FiscalPeriod fiscalPeriod; + protected Account account; + protected Date dateStart; + protected Date dateEnd; protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); @@ -99,28 +106,57 @@ public class AccountViewerEditModel implements Serializable { firePropertyChange(PROPERTY_SOLD, oldSold, this.sold); } - public void addPropertyChangeListener(PropertyChangeListener listener) { - pcs.addPropertyChangeListener(listener); + + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + pcs.firePropertyChange(propertyName, oldValue, newValue); } - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.addPropertyChangeListener(propertyName, listener); + public PeriodChoice getPeriodChoice() { + return periodChoice; } - public void removePropertyChangeListener(PropertyChangeListener listener) { - pcs.removePropertyChangeListener(listener); + public void setPeriodChoice(PeriodChoice periodChoice) { + this.periodChoice = periodChoice; } - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.removePropertyChangeListener(propertyName, listener); + public FinancialPeriod getFinancialPeriod() { + return financialPeriod; } - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); + public void setFinancialPeriod(FinancialPeriod financialPeriod) { + this.financialPeriod = financialPeriod; + } + + public FiscalPeriod getFiscalPeriod() { + return fiscalPeriod; + } + + public void setFiscalPeriod(FiscalPeriod fiscalPeriod) { + this.fiscalPeriod = fiscalPeriod; + } + + public Account getAccount() { + return account; + } + + public void setAccount(Account account) { + this.account = account; + } + + public Date getDateStart() { + return dateStart; + } + + public void setDateStart(Date dateStart) { + this.dateStart = dateStart; + } + + public Date getDateEnd() { + return dateEnd; } - protected void firePropertyChange(String propertyName, Object newValue) { - firePropertyChange(propertyName, null, newValue); + public void setDateEnd(Date dateEnd) { + this.dateEnd = dateEnd; } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerFilter.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerFilter.java deleted file mode 100644 index 362cf69..0000000 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerFilter.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.chorem.lima.ui.accountViewer; - -import org.chorem.lima.beans.LetteringFilterImpl; -import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.entity.FiscalPeriod; - -/** - * Created by davidcosse on 21/09/15. - */ -public class AccountViewerFilter extends LetteringFilterImpl { - - protected PeriodChoice periodChoice = PeriodChoice.FINANCIAL_PERIOD; - - protected FinancialPeriod financialPeriod; - - protected FiscalPeriod fiscalPeriod; - - public PeriodChoice getPeriodChoice() { - return periodChoice; - } - - public void setPeriodChoice(PeriodChoice periodChoice) { - this.periodChoice = periodChoice; - } - - public FinancialPeriod getFinancialPeriod() { - return financialPeriod; - } - - public void setFinancialPeriod(FinancialPeriod financialPeriod) { - this.financialPeriod = financialPeriod; - } - - public FiscalPeriod getFiscalPeriod() { - return fiscalPeriod; - } - - public void setFiscalPeriod(FiscalPeriod fiscalPeriod) { - this.fiscalPeriod = fiscalPeriod; - } -} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java index d79fbdc..a281089 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerViewHandler.java @@ -54,7 +54,6 @@ import java.awt.event.InputEvent; import java.awt.event.ItemEvent; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -86,8 +85,6 @@ public class AccountViewerViewHandler { protected FinancialTransactionService financialTransactionService; protected FiscalPeriodService fiscalPeriodService; - protected AccountViewerFilter filter; - protected AccountViewerTableModel accountViewerTableModel; protected AccountViewerSelectionModel accountViewerSelectionModel; protected AccountViewerEditModel editModel; @@ -122,7 +119,6 @@ public class AccountViewerViewHandler { * Init all combo box in view. */ public void init() { - filter = new AccountViewerFilter(); createComponentsModels(); @@ -163,37 +159,10 @@ public class AccountViewerViewHandler { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { view.getHandler().balanceAndActions(); + updateSoldStatus(); } } }); - - editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - updateSoldStatus(); - } - }); - - editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_CREDIT, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - updateSoldStatus(); - } - }); - - editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_SOLD, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - updateSoldStatus(); - } - }); - - editModel.addPropertyChangeListener(AccountViewerEditModel.PROPERTY_GLOBAL_SOLD, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - updateSoldStatus(); - } - }); } protected void initAccountTableView() { @@ -240,21 +209,21 @@ public class AccountViewerViewHandler { } protected void onPeriodChoiceChanged(PeriodChoice periodChoice) { - if (initializationComplete && !filter.getPeriodChoice().equals(periodChoice)) { - filter.setPeriodChoice(periodChoice); - switch (periodChoice) { - case FINANCIAL_PERIOD: - initViewForPeriodChoiceChange(true, true, false); - updateAllEntriesForFinancialPeriodChoice(); - break; - case FISCAL_PERIOD: - initViewForPeriodChoiceChange(true, false, false); - updateAllEntriesForFiscalPeriodChoice(); - break; - case DATE: - initViewForPeriodChoiceChange(false, false, true); - updateAllEntriesForDateIntervalChoice(); - break; + if (initializationComplete && !editModel.getPeriodChoice().equals(periodChoice)) { + editModel.setPeriodChoice(periodChoice); + switch (periodChoice) { + case FINANCIAL_PERIOD: + initViewForPeriodChoiceChange(true, true, false); + updateAllEntriesForFinancialPeriodChoice(); + break; + case FISCAL_PERIOD: + initViewForPeriodChoiceChange(true, false, false); + updateAllEntriesForFiscalPeriodChoice(); + break; + case DATE: + initViewForPeriodChoiceChange(false, false, true); + updateAllEntriesForDateIntervalChoice(); + break; } } } @@ -318,8 +287,8 @@ public class AccountViewerViewHandler { protected void onFiscalPeriodChange(ItemEvent event) { FiscalPeriod selectedFiscalPeriod = event != null && event.getItem() != null ? (FiscalPeriod) event.getItem() : null; - if (initializationComplete && selectedFiscalPeriod != null && !selectedFiscalPeriod.equals(filter.getFiscalPeriod())) { - if (PeriodChoice.FINANCIAL_PERIOD.equals(filter.getPeriodChoice())) { + if (initializationComplete && selectedFiscalPeriod != null && !selectedFiscalPeriod.equals(editModel.getFiscalPeriod())) { + if (PeriodChoice.FINANCIAL_PERIOD.equals(editModel.getPeriodChoice())) { List<FinancialPeriod> periods = financialPeriodService.getFinancialPeriodsWithBeginDateWithin(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); FinancialPeriod selectedFinancialPeriod = periods.get(0); financialPeriodComboBoxModel.setObjects(periods); @@ -335,18 +304,18 @@ public class AccountViewerViewHandler { protected void onFinancialPeriodChange(ItemEvent event) { FinancialPeriod financialPeriod = (FinancialPeriod) event.getItem(); - if (initializationComplete && filter.getFinancialPeriod() == null || !filter.getFinancialPeriod().equals(financialPeriod)) { + if (initializationComplete && editModel.getFinancialPeriod() == null || !editModel.getFinancialPeriod().equals(financialPeriod)) { updateAllEntriesForFinancialPeriodChoice(financialPeriod); } } public void onDateStartChange(Date date) { if (initializationComplete) { - if (date != null && !DateUtils.isSameDay(date, filter.getDateStart())) { - filter.setDateStart(date); + if (date != null && !DateUtils.isSameDay(date, editModel.getDateStart())) { + editModel.setDateStart(date); - if (filter.getDateEnd().before(date)) { - filter.setDateEnd(date); + if (editModel.getDateEnd().before(date)) { + editModel.setDateEnd(date); view.getEndPeriodPicker().setDate(date); } updateAllEntriesForDateChange(); @@ -356,10 +325,10 @@ public class AccountViewerViewHandler { public void onDateEndChange(Date date) { if (initializationComplete) { - if (date != null && !DateUtils.isSameDay(date, filter.getDateEnd())) { - filter.setDateEnd(date); - if (filter.getDateStart().after(date)) { - filter.setDateStart(date); + if (date != null && !DateUtils.isSameDay(date, editModel.getDateEnd())) { + editModel.setDateEnd(date); + if (editModel.getDateStart().after(date)) { + editModel.setDateStart(date); view.getBeginPeriodPicker().setDate(date); } updateAllEntriesForDateChange(); @@ -405,23 +374,27 @@ public class AccountViewerViewHandler { } protected void setFilter(FiscalPeriod fiscalPeriod, FinancialPeriod financialPeriod, Date dateStart, Date dateEnd, PeriodChoice periodChoice) { - filter.setFiscalPeriod(fiscalPeriod); - filter.setFinancialPeriod(financialPeriod); - filter.setDateStart(dateStart); - filter.setDateEnd(dateEnd); - filter.setPeriodChoice(periodChoice); + editModel.setFiscalPeriod(fiscalPeriod); + editModel.setFinancialPeriod(financialPeriod); + editModel.setDateStart(dateStart); + editModel.setDateEnd(dateEnd); + editModel.setPeriodChoice(periodChoice); } public void updateAllEntriesForDateChange() { - filter.setPeriodChoice(PeriodChoice.DATE); + editModel.setPeriodChoice(PeriodChoice.DATE); updateAllEntries(); } public void updateAllEntries() { if (initializationComplete - && filter.getAccount() != null - && filter.getDateStart() != null - && filter.getDateEnd() != null) { + && editModel.getAccount() != null + && editModel.getDateStart() != null + && editModel.getDateEnd() != null) { + LetteringFilter filter = new LetteringFilterImpl(); + filter.setAccount(editModel.getAccount()); + filter.setDateStart(editModel.getDateStart()); + filter.setDateEnd(editModel.getDateEnd()); List<Entry> entries = financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); AccountViewerTableModel accountViewerTableModel = (AccountViewerTableModel) view.getTable().getModel(); accountViewerTableModel.setValues(entries); @@ -443,9 +416,9 @@ public class AccountViewerViewHandler { LetteringFilter previousPeriodFilter = null; FiscalPeriod previousFiscalPeriod; Date dateStart = null, dateEnd = null; - switch (filter.getPeriodChoice()) { + switch (editModel.getPeriodChoice()) { case FINANCIAL_PERIOD: - Date financialPeriodDate = filter.getFinancialPeriod().getBeginDate(); + Date financialPeriodDate = editModel.getFinancialPeriod().getBeginDate(); FiscalPeriod fiscalPeriodFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(financialPeriodDate); if (DateUtils.isSameDay(financialPeriodDate, fiscalPeriodFiscalPeriod.getBeginDate())) { @@ -456,29 +429,29 @@ public class AccountViewerViewHandler { dateEnd = getDayMinus1Calendar(financialPeriodDate).getTime(); break; case FISCAL_PERIOD: - previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(getDayMinus1Calendar(filter.getFiscalPeriod().getBeginDate()).getTime()); + previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(getDayMinus1Calendar(editModel.getFiscalPeriod().getBeginDate()).getTime()); if (previousFiscalPeriod != null) { dateStart = previousFiscalPeriod.getBeginDate(); dateEnd = previousFiscalPeriod.getEndDate(); } break; case DATE: - previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()); + previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(editModel.getDateStart()); // case of starting date is same as current fiscal period one, so we look for previous fiscal period - if (previousFiscalPeriod != null && DateUtils.isSameDay(previousFiscalPeriod.getBeginDate(), filter.getDateStart())) { - previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(getDayMinus1Calendar(filter.getDateStart()).getTime()); + if (previousFiscalPeriod != null && DateUtils.isSameDay(previousFiscalPeriod.getBeginDate(), editModel.getDateStart())) { + previousFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(getDayMinus1Calendar(editModel.getDateStart()).getTime()); } // case of selected date is upper the last fiscal period we look for the last fiscal period if (previousFiscalPeriod == null) { FiscalPeriod lastFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod(); - previousFiscalPeriod = lastFiscalPeriod != null && lastFiscalPeriod.getEndDate().before(filter.getDateStart()) ? lastFiscalPeriod : null; + previousFiscalPeriod = lastFiscalPeriod != null && lastFiscalPeriod.getEndDate().before(editModel.getDateStart()) ? lastFiscalPeriod : null; } if (previousFiscalPeriod != null) { dateStart = previousFiscalPeriod.getBeginDate(); - dateEnd = getDayMinus1Calendar(filter.getDateStart()).getTime(); + dateEnd = getDayMinus1Calendar(editModel.getDateStart()).getTime(); } break; } @@ -487,7 +460,7 @@ public class AccountViewerViewHandler { previousPeriodFilter = new LetteringFilterImpl(); previousPeriodFilter.setDateStart(dateStart); previousPeriodFilter.setDateEnd(dateEnd); - previousPeriodFilter.setAccount(filter.getAccount()); + previousPeriodFilter.setAccount(editModel.getAccount()); } return previousPeriodFilter; @@ -496,29 +469,29 @@ public class AccountViewerViewHandler { private LetteringFilter computeActualPeriodFilter() { LetteringFilter actualPeriodFilter = null; Date dateStart = null, dateEnd = null; - switch (filter.getPeriodChoice()) { + switch (editModel.getPeriodChoice()) { case FINANCIAL_PERIOD: - if (filter.getFinancialPeriod() != null) { - Date financialPeriodDate = filter.getFinancialPeriod().getBeginDate(); + if (editModel.getFinancialPeriod() != null) { + Date financialPeriodDate = editModel.getFinancialPeriod().getBeginDate(); FiscalPeriod fiscalPeriodFiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(financialPeriodDate); dateStart = fiscalPeriodFiscalPeriod.getBeginDate(); - dateEnd = filter.getFinancialPeriod().getEndDate(); + dateEnd = editModel.getFinancialPeriod().getEndDate(); } break; case FISCAL_PERIOD: - dateStart = filter.getFiscalPeriod() == null ? null : filter.getFiscalPeriod().getBeginDate(); - dateEnd = filter.getFiscalPeriod() == null ? null : filter.getFiscalPeriod().getEndDate(); + dateStart = editModel.getFiscalPeriod() == null ? null : editModel.getFiscalPeriod().getBeginDate(); + dateEnd = editModel.getFiscalPeriod() == null ? null : editModel.getFiscalPeriod().getEndDate(); break; case DATE: - dateStart = filter.getFiscalPeriod() == null ? filter.getDateStart() : filter.getFiscalPeriod().getBeginDate(); - dateEnd = filter.getDateEnd(); + dateStart = editModel.getFiscalPeriod() == null ? editModel.getDateStart() : editModel.getFiscalPeriod().getBeginDate(); + dateEnd = editModel.getDateEnd(); break; } if (dateStart != null && dateEnd != null) { actualPeriodFilter = new LetteringFilterImpl(); actualPeriodFilter.setDateStart(dateStart); actualPeriodFilter.setDateEnd(dateEnd); - actualPeriodFilter.setAccount(filter.getAccount()); + actualPeriodFilter.setAccount(editModel.getAccount()); } return actualPeriodFilter; } @@ -602,14 +575,14 @@ public class AccountViewerViewHandler { } protected void initSoldPeriodView() { - Date ppbd = filter.getFiscalPeriod() != null ? filter.getFiscalPeriod().getBeginDate() : new Date(); - Date pped = filter.getFinancialPeriod() != null ? getDayMinus1Calendar(filter.getFinancialPeriod().getBeginDate()).getTime() : new Date(); + Date ppbd = editModel.getFiscalPeriod() != null ? editModel.getFiscalPeriod().getBeginDate() : new Date(); + Date pped = editModel.getFinancialPeriod() != null ? getDayMinus1Calendar(editModel.getFinancialPeriod().getBeginDate()).getTime() : new Date(); view.getBeginPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(ppbd), getDateFormat().format(pped))); view.getBeginDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginSold().setText(BigDecimalToString.format(BigDecimal.ZERO)); - Date aped = filter.getFinancialPeriod() != null ? filter.getFinancialPeriod().getEndDate() : new Date(); + Date aped = editModel.getFinancialPeriod() != null ? editModel.getFinancialPeriod().getEndDate() : new Date(); view.getEndPeriodSummary().setText(String.format(t("lima.accountingView.summaryLabel"), getDateFormat().format(ppbd), getDateFormat().format(aped))); view.getEndDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getEndCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); @@ -618,7 +591,7 @@ public class AccountViewerViewHandler { protected void setViewPreviousSold(LetteringFilter previousPeriodFilter) { if (previousPeriodFilter != null) { - if (filter.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD)) { + if (editModel.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD)) { String summaryLabel = t("lima.accountingView.summaryFiscalPeriodLabel"); view.getBeginPeriodSummary().setText(String.format(t(summaryLabel), YYYY.format(previousPeriodFilter.getDateStart()))); } else { @@ -632,7 +605,7 @@ public class AccountViewerViewHandler { view.getBeginCredit().setText(BigDecimalToString.format(debitCreditSold.getCredit())); view.getBeginSold().setText(BigDecimalToString.format(debitCreditSold.getSold())); } else { - String summaryLabel = filter.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD) ? t("lima.accountingView.summaryNoFiscalPeriodLabel") : t("lima.accountingView.summaryNoPeriodLabel"); + String summaryLabel = editModel.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD) ? t("lima.accountingView.summaryNoFiscalPeriodLabel") : t("lima.accountingView.summaryNoPeriodLabel"); view.getBeginPeriodSummary().setText(summaryLabel); view.getBeginDebit().setText(BigDecimalToString.format(BigDecimal.ZERO)); view.getBeginCredit().setText(BigDecimalToString.format(BigDecimal.ZERO)); @@ -642,7 +615,7 @@ public class AccountViewerViewHandler { } protected void setViewActualSold(LetteringFilter actualPeriodFilter) { - if (filter.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD)) { + if (editModel.getPeriodChoice().equals(PeriodChoice.FISCAL_PERIOD)) { String summaryLabel = t("lima.accountingView.summaryFiscalPeriodLabel"); view.getEndPeriodSummary().setText(String.format(t(summaryLabel), YYYY.format(actualPeriodFilter.getDateEnd()))); } else { @@ -775,16 +748,16 @@ public class AccountViewerViewHandler { } public void setAccount(Account account) { - if (filter != null) { - filter.setAccount(account); + if (editModel != null) { + editModel.setAccount(account); updateAllEntries(); } } public Account getAccount() { Account account = null; - if (filter != null) { - account = filter.getAccount(); + if (editModel != null) { + account = editModel.getAccount(); } return account; } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit 21a91b5fc02617d25eaecb9fe29428bdc0d8e58c Author: dcosse <cosse@codelutin.com> Date: Mon Nov 30 14:13:39 2015 +0100 refs #1293 correction traductions --- lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties | 1 - 1 file changed, 1 deletion(-) 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 bef1571..29d8443 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 @@ -463,7 +463,6 @@ lima.lettering.account.aAll=All lima.lettering.account.back=← lima.lettering.account.next=→ lima.lettering.accountViewerBalanceStatus=<html>From %s to %s\: Sold is\: <b>%s - %s \= %s</b> - Selected entries sold\: <b>%s - %s \= %s</b> -lima.lettering.balanceStatus= lima.lettering.balanceStatus=<html>Debit\: <b>%s</b> - Credit\: <b>%s</b> - Sold\: <b>%s</b>. Selected entries\: Debit\: <b>%s</b> - Credit\: <b>%s</b> - Sold\: <b>%s</b> lima.lettering.checkAll=All lima.lettering.checkLettredEntry=Lettered -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1293-addAccountViewerTab in repository lima. See http://git.chorem.org/lima.git commit a383d34f0a1142d74b97e75f8ad363087d796b45 Author: dcosse <cosse@codelutin.com> Date: Mon Nov 30 16:06:14 2015 +0100 refs #1293 correction de merge --- .../src/main/java/org/chorem/lima/ui/lettering/LetteringView.css | 7 ------- .../java/org/chorem/lima/ui/lettering/LetteringViewHandler.java | 2 -- 2 files changed, 9 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css index 520059d..4cf931b 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css @@ -70,18 +70,11 @@ labelFor : {beginPeriodPicker}; } -#beginPeriodPicker { - patternLayout: {handler.DATE_FORMAT}; -} - #endPeriodLabel { text : "lima.lettering.period.end"; labelFor : {endPeriodPicker}; } -#endPeriodPicker { - patternLayout: {handler.DATE_FORMAT}; -} #letteredEntryLabel { actionIcon : "choose-entry"; diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java index 67abdc7..66bf038 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java @@ -80,8 +80,6 @@ import static org.nuiton.i18n.I18n.t; */ public class LetteringViewHandler{ - protected static String DATE_FORMAT = t("lima.ui.dateFormat"); - protected LetteringView view; /** Transaction service. */ -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm