branch feature/1293-addAccountViewerTabWithCloseColumnAndDTO updated (71ed649 -> 0eeda16)
This is an automated email from the git hooks/post-receive script. New change to branch feature/1293-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git discards 71ed649 refs #1293 Ajout d'une colone Clos, est utilisation d'un DTO à la place de Entry discards ed78c68 refs #1293 Traduction des dates pickers discards 9031da6 refs #1293 Correction sur les dates pickers et la recherche de compte appliquée égallement à l'onglet Lettering discards 0c85b1a refs #1293 Correction d'une exception survenant si un nom de compte est saisie est que aucun compte ne correspond discards 447fbd0 refs #1293 la validation des dates des date pickers est possible au Tab discards e3a30fd refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) discards 47dd7c3 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 47945fb refs #1241 Ajout d'un oglet consultation de compte, travail en cours adds 0112481 refs #1290 A la création d'une transaction si aucune n'a été créée lors de la même session est qu'une transaction est sélectionnée alors la nouvelle trasaction prend la date de celle-ci adds d100451 refs #1289 calcul de la colonne Solde dans l'onglet recherche des entrées adds acefd82 refs #1289refactoring adds 32aa3f8 refs #1289 Le solde est positif si le solde est débiteur adds 13b9893 Merge branch 'feature/1289-SearchEntriescomputeSold' into develop adds 26111c4 refs #1293 "Onglet Saisie des écritures" La saisie dans le champ jour est dirrectement prise en compte adds 54e25dd refs #1293 Auto selection du compte si un seul compte correspond à la recherche adds 785fc80 refs #1295 Même objet sélectionné entre la combobox et le model adds c51843f Merge branch 'feature/1295-improveEditEntryView' into develop adds 2d2c8a4 refs #1241 ordonne les entrée par date adds 8ef9bf6 refs #1286 Regrouppement des entrées par pièces comptable dans la saisie d'écriture adds bce1075 refs #1286 La solution adopter n'est pas idéale, il faudra revoir le model pour ordonnée les entrée d'une transaction voir ref #1207 adds 4bbfd4d Merge branch 'feature/1286-ordered-entries' into develop adds 636a5ba refs #1242 verifivation que l'on filtre bien sur un compte adds ae8502c fixes #1243 la sortie du champ date ou le clic sur une autre action entraine bien la prise en compte des dates saisies adds 2dc6345 refs #1242 Modification pour plus de lisibilité suite à revue de code Kevin adds 79ebf7d refs #1242 Refactoring pour plus de lisibilité adds 4d8ac91 refs #1242 correction de merge adds 7288ae1 Merge branch 'feature/1242-no-account-research-exception' into develop adds 9fd0c2f refs #1297correction pour ne pas remonter les entitées ayant une date > à celle indiquée dans la période adds bde8128 refs #1298 corrige NPE dans le cas ou aucune donnée existe adds e3d95f9 refs #1242 ordre des traductions revu adds d9b4a7d Merge branch 'feature/1298-FixNPE' into develop adds 959bbc3 refs #1268 l'interface de saisie d'un plan de TVA est de nouveau fonctionnelle adds 6b2e99c refs #1268 utilisation de JXTreeTable à la place de VatChartTreeTable adds 73a9813 refs #1268 déplacement du ListSelectionModel dans le handler adds b44dada Merge branch 'feature/1268-vat-statement-usable' into develop adds 635828d refs #1242 correction sur refactoring adds a0857b1 Mise à jour de la déclaration de licences adds d5f467a refs #1295 Le tableau de la saisie des écritures n'est pas éditable si la période est cloturé pour le journal sélectionné adds 4a1b1d5 refs #1158 Ajout de commentaires + désactivation du boutton de création d'une transaction adds 253998b refs #1158 Sur l'onglet lettrage il n'est pas possible de modifier une selection comportant une entrée vérouillée. Ajout d'une colonne 'clos' indiquant les entrées vérouillées. adds 9957610 Merge branch 'feature/1158-NotEditableTableForClose' into develop adds b4b645f refs #1158 : recupération du ClosedPeriodEntryBook et stockage dans un map pour le cache. adds b119160 import manquant adds 7cd3ef3 correction suite au merge adds fd35125 Merge branch 'feature/1158' into develop adds f0e4f29 refs #1241 gérération des rapport de compte avec Jasper adds 03e84c6 refs #1241 gérération des rapport de compte avec Jasper adds 4c16fcb refs #1241 ne pas afficher les lignes ne comportant aucun montant de renseigné adds e9c8126 refs #1241 modification de l'affichage des infos adds ce734ff refs #1241 factorisation du code source Jasper, utilisation de style adds 643e3a5 refs #1241 correction sur nom de police adds 9afd18d refs #1241 refactoring adds b019126 refs #1241 refactoring général sur les rapports, renommage variable, utilisation de style dans les rapports adds 8b18d5e refs #1241 réactivation de l'impression de la TVA, avec mise à jour des données adds dedb5b9 refs #1241 mise à jour du plan de TVA adds 9a297ab refs #1268 permet la saisie des informations concernant le trésor public et affichage de ses infos lors de l'export TVA adds f56fee1 refs #1241 placement correcte des champs dans la fenêtre de saisie de l'identité adds cfd3f21 refs #1241 correction sur le formulaire concernant le trésor public. Renommage du boutton OK en Valider adds 797522f refs #1241 pas de changement dans l'interface de configuration du premier lancement adds 9c2a471 refs #1241 modificaction des écans de 1er configuration afin de prendre en compte les changements sur l'identité. adds 6c63783 refs #1241 ajout de l'icon de sauvegarde présente sur le 1er écran au 1er lancement de lima adds 7cc39ee refs #1241 progression sur internationalisation des rapports, ajout de l'entête avec l'identité sur tous les rapports adds b4373cd refs #1241mise à jour du plan de tva adds 21cbf77 refs #1241 minor adds e8e622e refs #1241 internationalisation sur le rapport de compte adds 5a144b5 refs #1241 internationalisation sur le rapport de compte adds 887373c refs #1241 ajout possibilité de créer des rapports de balance globale ou générale (le dernier par défaut centralise les comptes 401 avec ses sous comptes idem pour 411) adds b8a6ceb refs #1241 monté de version je Jasper report adds 6f487bf refs #1241 refactoring de code adds 1179c09 refs #1241 modification sur en tête du rapport et correction pour appeler la bonne méthode. adds 4e94d24 refs #1241 modification sur en tête du rapport et correction pour appeler la bonne méthode. adds 0919fa5 refs #1241 Ajout de traductions adds 7f54c9e refs #1298 corrige la génération de rapport pour les comptes si aucun compte n'existe adds 5655683 correction suite au merge adds 3d5a336 Merge branch 'feature/1241-account-report' into develop adds a200c71 refs #1287 ajout du montant total pour à l'onglet Lettrage adds 746e8ce refs #1287 import manquant adds 07988ba Merge branch 'feature/1287-compute-summary-on-lettering' into develop adds 1977c6c refs #686 Redémarrage complet de lima pour que l'internationalisation soit complète adds a47f485 refs #1182 Ajout de traductions adds 98ca966 refs #1182 Traduction des dates pickers adds e9ea36e refs #1182 rétablit le fonctionnement des datepicker sur interval adds 25b8310 Merge branch 'feature/1182-translation' into develop new bf20017 refs #1241 Ajout d'un oglet consultation de compte, travail en cours new a1f129f 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 683a07f refs #1241 Ajout de la possibilité de choisir entre deux modes de sélection des entrées (Manuelle ou Balancée) new da346ae refs #1293 la validation des dates des date pickers est possible au Tab new 52dd5bc refs #1293 Correction d'une exception survenant si un nom de compte est saisie est que aucun compte ne correspond new 80ba3fc refs #1293 Correction sur les dates pickers et la recherche de compte appliquée égallement à l'onglet Lettering new 4e8479a refs #1293 Traduction des dates pickers new 0eeda16 refs #1293 Ajout d'une colone Clos, est utilisation d'un DTO à la place de Entry 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 (71ed649) \ N -- N -- N refs/heads/feature/1293-addAccountViewerTabWithCloseColumnAndDTO (0eeda16) 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 8 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 0eeda163f72109f06c459c2adf9d77ef45a6bde9 Author: dcosse <cosse@codelutin.com> Date: Thu Sep 17 19:03:11 2015 +0200 refs #1293 Ajout d'une colone Clos, est utilisation d'un DTO à la place de Entry commit 4e8479a339cb48650cfda64fd51c8ff9a3e37056 Author: dcosse <cosse@codelutin.com> Date: Wed Sep 16 22:11:13 2015 +0200 refs #1293 Traduction des dates pickers commit 80ba3fccdcc3f207c6071fd32c6c2b581bde0c07 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 52dd5bc051e9cc25cbeae81dcd00ebb3cf93e0b5 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 da346aef9256d5bba016a507c13971c6279e2c73 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 683a07fccd1843dd9d16bf87fd13725cd80b4639 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 a1f129fad9f499f08bbe6435a9087f93375df5ac 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 bf200178fba154769bc81b73da6ed3dfe94ce623 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: .../org/chorem/lima/business/ServiceListener.java | 2 +- .../chorem/lima/business/api/AccountService.java | 6 + .../api/ClosedPeriodicEntryBookService.java | 3 + .../chorem/lima/business/api/EntryBookService.java | 6 + .../business/api/FinancialTransactionService.java | 7 + .../chorem/lima/business/api/ImportService.java | 11 + .../chorem/lima/business/api/OptionsService.java | 3 + .../chorem/lima/business/api/TreasuryService.java | 13 + .../lima/business/api/VatStatementService.java | 5 +- ...eportService.java => AccountReportService.java} | 14 +- .../business/api/report/BalanceReportService.java | 19 +- ...on.java => AlreadyAffectedVatBoxException.java} | 14 +- ...lException.java => RequiredFieldException.java} | 14 +- .../chorem/lima/business/LimaBusinessConfig.java | 22 +- .../lima/business/ejb/AccountServiceImpl.java | 16 +- .../ejb/ClosedPeriodicEntryBookServiceImpl.java | 11 + .../lima/business/ejb/EntryBookServiceImpl.java | 7 + .../ejb/FinancialTransactionServiceImpl.java | 12 + .../lima/business/ejb/ImportServiceImpl.java | 34 +- .../lima/business/ejb/OptionsServiceImpl.java | 6 + .../lima/business/ejb/TreasuryServiceImpl.java | 69 +++ .../lima/business/ejb/VatStatementServiceImpl.java | 74 +++- .../business/ejb/csv/FiscalControlExportModel.java | 2 +- .../lima/business/ejb/csv/IdentityModel.java | 4 +- .../ejb/report/AccountReportServiceImpl.java | 125 ++++++ .../ejb/report/BalanceReportServiceImpl.java | 325 ++++++++++---- .../business/ejb/report/CommonsDocumentReport.java | 57 +++ .../report/GeneralEntryBookReportServiceImpl.java | 43 +- .../ejb/report/LedgerReportServiceImpl.java | 41 +- .../ProvisionalEntryBookReportServiceImpl.java | 64 +-- .../entity/ClosedPeriodicEntryBookTopiaDao.java | 23 + .../java/org/chorem/lima/entity/EntryTopiaDao.java | 44 +- .../resources/i18n/lima-business_en_GB.properties | 56 +++ .../resources/i18n/lima-business_fr_FR.properties | 56 +++ .../org/chorem/lima/beans/BalanceAccountImpl.java | 23 +- ...ql => V0_8_6_0__1241_create_table_TREASURY.sql} | 52 ++- .../src/main/xmi/lima-callao-model.properties | 2 +- lima-callao/src/main/xmi/lima-callao-model.zargo | Bin 57316 -> 61665 bytes lima-report/pom.xml | 10 +- .../chorem/lima/report/DocumentReportTypes.java | 1 + .../java/org/chorem/lima/report/DocumentsEnum.java | 4 +- .../org/chorem/lima/report/LimaReportConfig.java | 60 ++- .../lima/report/service/DocumentService.java | 321 ++++++-------- .../chorem/lima/report/service/JasperReports.java | 10 + .../AccountEntry.jrxml} | 170 ++++---- .../jasperreports/account/DocumentReport.jrxml | 266 ++++++++++++ .../balance/BalanceReportAccountReport.jrxml | 18 +- .../balance/BalanceSubAccountsReport.jrxml | 54 ++- .../jasperreports/balance/DocumentReport.jrxml | 387 ++++++++++------- .../jasperreports/entryBook/DocumentReport.jrxml | 394 ++++++++--------- .../jasperreports/entryBook/EntryBookReport.jrxml | 77 +--- .../entryBook/FinancialPeriodReport.jrxml | 191 ++------ .../entryBook/TransactionReport.jrxml | 222 +++------- .../generalEntryBook/DocumentReport.jrxml | 478 ++++++++++----------- .../generalEntryBook/EntryBookPeriodReport.jrxml | 54 +-- .../GeneralEntryBookEntryReport.jrxml | 11 +- .../generalLedger/DocumentReport.jrxml | 406 +++++++++-------- .../generalLedger/GeneralLedgerEntryReport.jrxml | 204 +++------ .../generalLedger/GeneralLedgerReport.jrxml | 113 ++--- .../src/main/resources/reports/vat_form_fr.pdf | Bin 222623 -> 244238 bytes .../org/chorem/lima/report/action/ReportTest.java | 2 +- .../org/chorem/lima/server/HttpServerService.java | 41 +- lima-swing/src/license/THIRD-PARTY.properties | 1 + .../main/java/org/chorem/lima/LimaSwingConfig.java | 1 + .../chorem/lima/enums/VatStatementsChartEnum.java | 5 +- .../AccountCondition/AccountConditionHandler.java | 6 +- .../Filter/dateCondition/DateConditionHandler.java | 19 +- .../ui/Filter/dateCondition/DateConditionView.jaxx | 3 +- .../DateIntervalConditionHandler.java | 19 +- .../DateIntervalConditionView.jaxx | 13 +- .../java/org/chorem/lima/ui/MainViewHandler.java | 28 +- .../chorem/lima/ui/account/AccountViewHandler.java | 3 +- .../lima/ui/celleditor/AccountTableCellEditor.java | 28 +- .../ui/celleditor/DateLimaTableCellRenderer.java | 4 +- .../lima/ui/celleditor/DateTableCellEditor.java | 154 ------- .../lima/ui/celleditor/DayTableCellEditor.java | 30 +- .../lima/ui/combobox/EntryBookComboBoxModel.java | 4 +- .../ui/combobox/FiscalPeriodComboBoxModel.java | 4 +- .../chorem/lima/ui/common/AbstractLimaTable.java | 2 - .../ui/common/FinancialTransactionTableModel.java | 111 ++++- .../lima/ui/entrybook/EntryBookViewHandler.java | 8 +- .../ui/financialtransaction/AccountColumn.java | 48 ++- .../ui/financialtransaction/BalanceColumn.java | 35 +- .../lima/ui/financialtransaction/DayColumn.java | 6 +- .../FinancialTransactionView.css | 15 +- .../FinancialTransactionView.jaxx | 2 +- .../FinancialTransactionViewHandler.java | 109 +++-- .../FinancialTransactionSearchTableModel.java | 12 +- .../FiscalControlExportViewHandler.java | 2 +- .../ui/fiscalperiod/FiscalPeriodViewHandler.java | 4 +- .../java/org/chorem/lima/ui/home/AccountsPane.java | 6 +- .../org/chorem/lima/ui/home/EntryBooksPane.java | 8 +- .../lima/ui/home/FinancialTransactionsPane.java | 6 +- .../org/chorem/lima/ui/home/FiscalYearsPane.java | 10 +- .../org/chorem/lima/ui/identity/IdentityForm.css | 161 +++++-- .../org/chorem/lima/ui/identity/IdentityForm.jaxx | 281 +++++++----- .../chorem/lima/ui/identity/IdentityHandler.java | 45 +- .../chorem/lima/ui/importexport/ImportExport.java | 8 + .../lima/ui/lettering/LetteringEditModel.java | 96 +++-- ...tionModel.java => LetteringSelectionModel.java} | 31 +- .../lima/ui/lettering/LetteringTableModel.java | 38 ++ .../org/chorem/lima/ui/lettering/LetteringView.css | 6 +- .../chorem/lima/ui/lettering/LetteringView.jaxx | 11 +- .../lima/ui/lettering/LetteringViewHandler.java | 186 +++++--- .../BackupPanel.css} | 10 +- ...{CreateEntryBookPanel.jaxx => BackupPanel.jaxx} | 8 +- .../{OpeningView.css => BackupPanelHandler.java} | 42 +- .../chorem/lima/ui/opening/CreateIdentityPanel.css | 10 +- .../lima/ui/opening/CreateIdentityPanel.jaxx | 64 ++- .../ui/opening/CreateIdentityPanelHandler.java | 1 - .../org/chorem/lima/ui/opening/OpeningView.css | 11 +- .../org/chorem/lima/ui/opening/OpeningView.jaxx | 28 +- .../chorem/lima/ui/opening/OpeningViewHandler.java | 195 ++++++--- .../lima/ui/vatchart/VatChartMovementForm.css | 2 + .../lima/ui/vatchart/VatChartMovementForm.jaxx | 19 +- .../chorem/lima/ui/vatchart/VatChartTreeTable.java | 134 ------ .../lima/ui/vatchart/VatChartTreeTableModel.java | 226 ---------- .../org/chorem/lima/ui/vatchart/VatChartView.jaxx | 26 +- .../lima/ui/vatchart/VatChartViewHandler.java | 401 ++++++++++------- .../chorem/lima/ui/vatchart/VatChartViewModel.java | 191 ++++++++ .../resources/i18n/lima-swing_en_GB.properties | 70 ++- .../resources/i18n/lima-swing_fr_FR.properties | 53 ++- lima-swing/src/main/resources/icons/backup.png | Bin 0 -> 4803 bytes lima-swing/src/main/resources/import/vat_base.csv | 114 ++--- .../src/main/resources/import/vat_default.csv | 111 ++--- .../src/main/resources/import/vat_developed.csv | 56 --- .../src/main/resources/import/vat_shortened.csv | 56 --- lima-swing/src/main/resources/log4j.properties | 2 +- pom.xml | 10 +- 129 files changed, 4622 insertions(+), 3566 deletions(-) create mode 100644 lima-business-api/src/main/java/org/chorem/lima/business/api/TreasuryService.java copy lima-business-api/src/main/java/org/chorem/lima/business/api/report/{BalanceReportService.java => AccountReportService.java} (63%) copy lima-business-api/src/main/java/org/chorem/lima/business/exceptions/{NotAllowedLabelException.java => AlreadyAffectedVatBoxException.java} (74%) copy lima-business-api/src/main/java/org/chorem/lima/business/exceptions/{NotAllowedLabelException.java => RequiredFieldException.java} (74%) create mode 100644 lima-business/src/main/java/org/chorem/lima/business/ejb/TreasuryServiceImpl.java create mode 100644 lima-business/src/main/java/org/chorem/lima/business/ejb/report/AccountReportServiceImpl.java create mode 100644 lima-business/src/main/java/org/chorem/lima/business/ejb/report/CommonsDocumentReport.java copy lima-callao/src/main/resources/db/migration/{V0_6_0_0__migration2.sql => V0_8_6_0__1241_create_table_TREASURY.sql} (50%) copy lima-report/src/main/resources/jasperreports/{generalLedger/GeneralLedgerEntryReport.jrxml => account/AccountEntry.jrxml} (69%) create mode 100644 lima-report/src/main/resources/jasperreports/account/DocumentReport.jrxml delete mode 100644 lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java copy lima-business-api/src/main/java/org/chorem/lima/LimaTechnicalException.java => lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DayTableCellEditor.java (64%) rename lima-swing/src/main/java/org/chorem/lima/ui/lettering/{LettringSelectionModel.java => LetteringSelectionModel.java} (82%) copy lima-swing/src/main/java/org/chorem/lima/ui/{fiscalperiod/RetainedEarningsWait.css => opening/BackupPanel.css} (88%) copy lima-swing/src/main/java/org/chorem/lima/ui/opening/{CreateEntryBookPanel.jaxx => BackupPanel.jaxx} (80%) copy lima-swing/src/main/java/org/chorem/lima/ui/opening/{OpeningView.css => BackupPanelHandler.java} (61%) delete mode 100644 lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTable.java delete mode 100644 lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java create mode 100644 lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewModel.java create mode 100644 lima-swing/src/main/resources/icons/backup.png delete mode 100644 lima-swing/src/main/resources/import/vat_developed.csv delete mode 100644 lima-swing/src/main/resources/import/vat_shortened.csv -- 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-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git commit bf200178fba154769bc81b73da6ed3dfe94ce623 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 + .../ui/accountViewer/AccountViewerEditModel.java | 205 +++++++ .../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 +++++++++++++++++++++ .../resources/i18n/lima-swing_en_GB.properties | 3 + .../resources/i18n/lima-swing_fr_FR.properties | 4 + 18 files changed, 1437 insertions(+), 1 deletion(-) 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/accountViewer/AccountViewerEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java new file mode 100644 index 0000000..0c9b98c --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEditModel.java @@ -0,0 +1,205 @@ +/* + * #%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% + */ +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 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"; + + 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; + + protected BigDecimal globalDebit = BigDecimal.ZERO; + protected BigDecimal globalCredit = BigDecimal.ZERO; + protected BigDecimal globalSold = BigDecimal.ZERO; + + 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; + } + + public void setDebit(BigDecimal debit) { + BigDecimal oldDebit = getDebit(); + + if (!BigDecimal.ZERO.equals(debit)){ + this.debit = debit.add(oldDebit); + }else{ + this.debit = BigDecimal.ZERO; + } + + firePropertyChange(PROPERTY_DEBIT, oldDebit, this.debit); + } + + public BigDecimal getCredit() { + return credit; + } + + public void setCredit(BigDecimal credit) { + BigDecimal oldCredit = getCredit(); + + if (!BigDecimal.ZERO.equals(credit)){ + this.credit = credit.add(oldCredit); + }else{ + this.credit=BigDecimal.ZERO; + } + + firePropertyChange(PROPERTY_CREDIT, oldCredit, this.credit); + } + + public BigDecimal getSold() { + return sold; + } + + public void setSold(BigDecimal sold, boolean credit) { + BigDecimal oldSold = getSold(); + + if (!BigDecimal.ZERO.equals(sold)){ + if (credit){ + this.sold = oldSold.subtract(sold); + }else{ + this.sold = oldSold.add(sold); + } + }else{ + this.sold =BigDecimal.ZERO; + } + + 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); + } + + 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); + } + + 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/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/resources/i18n/lima-swing_en_GB.properties b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties index 76d6b08..a95a8a9 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 @@ -450,6 +452,7 @@ lima.lettering.account.aAll=All lima.lettering.account.back=← lima.lettering.account.next=→ 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.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.checkAll=All lima.lettering.checkLettredEntry=Lettered lima.lettering.checkNoLettredEntry=Not 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 133a4af..c831c59 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. @@ -462,6 +464,8 @@ lima.lettering.account.aAll=TOUS lima.lettering.account.back=← lima.lettering.account.next=→ 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.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> lima.lettering.checkAll=Toutes lima.lettering.checkLettredEntry=Lettrées lima.lettering.checkNoLettredEntry=Non-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-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git commit a1f129fad9f499f08bbe6435a9087f93375df5ac 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-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git commit 683a07fccd1843dd9d16bf87fd13725cd80b4639 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 a95a8a9..580a3f3 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 @@ -541,6 +544,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 c831c59..f69d8f9 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 @@ -537,6 +540,7 @@ lima.table.provisionDeprecation=Amortissements et provisions lima.table.voucher=Pièce comptable lima.title=Lutin Invoice Monitoring and Accounting lima.transaction=Transaction +lima.ui.dateFormat=dd/MM/yyy lima.treasury=Trésor Public lima.treasury.address=Adresse lima.treasury.address2=Adresse (suite) 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-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git commit da346aef9256d5bba016a507c13971c6279e2c73 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-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git commit 52dd5bc051e9cc25cbeae81dcd00ebb3cf93e0b5 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 dedc44d..8c9a4d1 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 @@ -531,7 +531,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-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git commit 80ba3fccdcc3f207c6071fd32c6c2b581bde0c07 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 ++++++++ .../org/chorem/lima/ui/lettering/LetteringViewHandler.java | 14 ++++++++++---- 3 files changed, 20 insertions(+), 8 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 8c9a4d1..3e2e0e2 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 @@ -441,13 +441,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) { @@ -666,4 +670,6 @@ public class LetteringViewHandler{ 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-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git commit 4e8479a339cb48650cfda64fd51c8ff9a3e37056 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-addAccountViewerTabWithCloseColumnAndDTO in repository lima. See http://git.chorem.org/lima.git commit 0eeda163f72109f06c459c2adf9d77ef45a6bde9 Author: dcosse <cosse@codelutin.com> Date: Thu Sep 17 19:03:11 2015 +0200 refs #1293 Ajout d'une colone Clos, est utilisation d'un DTO à la place de Entry --- .../api/ClosedPeriodicEntryBookService.java | 2 + .../business/api/FinancialTransactionService.java | 2 +- .../ejb/ClosedPeriodicEntryBookServiceImpl.java | 7 + .../ejb/FinancialTransactionServiceImpl.java | 2 +- .../entity/ClosedPeriodicEntryBookTopiaDao.java | 14 ++ .../ui/accountViewer/AccountViewerEntryDto.java | 133 +++++++++++++++++ .../accountViewer/AccountViewerSelectionModel.java | 11 +- .../ui/accountViewer/AccountViewerTableModel.java | 77 +++++----- .../ui/accountViewer/AccountViewerViewHandler.java | 162 ++++++++++++--------- .../lima/ui/accountViewer/SelectionMode.java | 6 +- .../ui/fiscalperiod/FiscalPeriodTableModel.java | 2 +- .../lima/ui/lettering/LetteringViewHandler.java | 22 ++- .../resources/i18n/lima-swing_en_GB.properties | 5 +- .../resources/i18n/lima-swing_fr_FR.properties | 6 +- .../resources/icons/action-fiscalPeriod-close.png | Bin 715 -> 452 bytes 15 files changed, 325 insertions(+), 126 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/ClosedPeriodicEntryBookService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/ClosedPeriodicEntryBookService.java index 1cb6954..dd7b498 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/ClosedPeriodicEntryBookService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/ClosedPeriodicEntryBookService.java @@ -38,6 +38,8 @@ public interface ClosedPeriodicEntryBookService { List<ClosedPeriodicEntryBook> getAllByDates(Date beginDate, Date endDate); + List<String> getAllLockedEntryBookIdsFrom(Date beginDate); + List<ClosedPeriodicEntryBook> getAllByEntryBookAndDates(EntryBook entryBook, Date beginDate, Date endDate); ClosedPeriodicEntryBook getByEntryBookAndFinancialPeriod(EntryBook entryBook, Date date); 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 d653bc8..f548b76 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 @@ -123,7 +123,7 @@ public interface FinancialTransactionService { * pour un compte et la présence d'un lettrage ou (xor) non * @param filter filtre sur les entrees, selon le compte, les dates de debut et de fin, et le lettrage * */ - List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter); + List<Entry> getAllEntriesByDatesAndAccountAndLettering(LetteringFilter filter); /** * diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java index 352d51e..4db8561 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/ClosedPeriodicEntryBookServiceImpl.java @@ -60,6 +60,13 @@ public class ClosedPeriodicEntryBookServiceImpl extends AbstractLimaService impl } @Override + public List<String> getAllLockedEntryBookIdsFrom(Date beginDate) { + ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao(); + List<String> result = closedPeriodicEntryBookTopiaDao.findAllLockedEntryBookIdsFrom(beginDate); + return result; + } + + @Override public List<ClosedPeriodicEntryBook> getAllByEntryBookAndDates(EntryBook entryBook, Date beginDate, Date endDate) { ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao(); List<ClosedPeriodicEntryBook> result = 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 71f5d0d..a3f18a5 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 @@ -461,7 +461,7 @@ public class FinancialTransactionServiceImpl extends AbstractLimaService impleme } @Override - public List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) { + public List<Entry> getAllEntriesByDatesAndAccountAndLettering(LetteringFilter filter) { EntryTopiaDao entryTopiaDao = getDaoHelper().getEntryDao(); List<Entry> entries = entryTopiaDao.findAllEntryByFilter(filter); diff --git a/lima-business/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java b/lima-business/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java index e539043..a7fe86a 100644 --- a/lima-business/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java +++ b/lima-business/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookTopiaDao.java @@ -23,6 +23,7 @@ package org.chorem.lima.entity; import org.nuiton.topia.persistence.HqlAndParametersBuilder; +import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep; import java.util.Date; @@ -202,4 +203,17 @@ public class ClosedPeriodicEntryBookTopiaDao extends AbstractClosedPeriodicEntry return closedPeriodicEntryBooks; } + + public List<String> findAllLockedEntryBookIdsFrom(Date beginDate) { + + HqlAndParametersBuilder<ClosedPeriodicEntryBook> builder = newHqlAndParametersBuilder(); + builder.addGreaterOrEquals(PROPERTY_BEGIN_DATE, beginDate); + builder.addEquals(ClosedPeriodicEntryBook.PROPERTY_LOCKED, true); + + String query = "SELECT DISTINCT " + builder.getAlias() + "." + ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK + "." + TopiaEntity.PROPERTY_TOPIA_ID + " " + + builder.getHql(); + + List<String> closedPeriodicEntryBooks = findAll(query, builder.getHqlParameters()); + return closedPeriodicEntryBooks; + } } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEntryDto.java b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEntryDto.java new file mode 100644 index 0000000..69ebdf8 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/accountViewer/AccountViewerEntryDto.java @@ -0,0 +1,133 @@ +package org.chorem.lima.ui.accountViewer; + +import org.chorem.lima.entity.Entry; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * Created by davidcosse on 17/09/15. + */ +public class AccountViewerEntryDto{ + protected boolean isInitialSold; + protected boolean isGlobalSold; + + protected boolean locked; + protected Date transactionDate; + protected String entryBookCode; + protected String voucher; + protected String description; + protected String lettering; + protected BigDecimal debit; + protected BigDecimal credit; + protected BigDecimal sold; + + public AccountViewerEntryDto() { + } + + public AccountViewerEntryDto(Entry entry, BigDecimal previousSold, boolean locked) { + setEntry(entry, previousSold, locked); + } + + public void setEntry (Entry entry, BigDecimal previousSold, boolean locked) { + transactionDate = entry.getFinancialTransaction().getTransactionDate(); + entryBookCode = entry.getFinancialTransaction().getEntryBook().getCode(); + voucher = entry.getVoucher(); + description = entry.getDescription(); + lettering = entry.getLettering(); + debit = entry.isDebit() ? entry.getAmount().abs() : BigDecimal.ZERO; + credit = entry.isDebit() ? BigDecimal.ZERO : entry.getAmount().abs(); + previousSold = previousSold.add(debit); + previousSold = previousSold.subtract(credit); + sold = previousSold; + this.locked = locked; + } + + public boolean isInitialSold() { + return isInitialSold; + } + + public void setIsInitialSold(boolean isInitialSold) { + this.isInitialSold = isInitialSold; + } + + public boolean isGlobalSold() { + return isGlobalSold; + } + + public void setIsGlobalSold(boolean isGlobalSold) { + this.isGlobalSold = isGlobalSold; + } + + public boolean isLocked() { + return locked; + } + + public void setIsLocked(boolean isLocked) { + this.locked = isLocked; + } + + public Date getTransactionDate() { + return transactionDate; + } + + public void setTransactionDate(Date transactionDate) { + this.transactionDate = transactionDate; + } + + public String getEntryBookCode() { + return entryBookCode; + } + + public void setEntryBookCode(String entryBookCode) { + this.entryBookCode = entryBookCode; + } + + public String getVoucher() { + return voucher; + } + + public void setVoucher(String voucher) { + this.voucher = voucher; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getLettering() { + return lettering; + } + + public void setLettering(String lettering) { + this.lettering = lettering; + } + + public BigDecimal getDebit() { + return debit; + } + + public void setDebit(BigDecimal debit) { + this.debit = debit; + } + + public BigDecimal getCredit() { + return credit; + } + + public void setCredit(BigDecimal credit) { + this.credit = credit; + } + + public BigDecimal getSold() { + return sold; + } + + public void setSold(BigDecimal sold) { + this.sold = sold; + } +} 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..3d31858 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 @@ -22,7 +22,6 @@ package org.chorem.lima.ui.accountViewer; */ import org.apache.commons.lang3.StringUtils; -import org.chorem.lima.entity.Entry; import javax.swing.*; import java.beans.PropertyChangeListener; @@ -35,7 +34,7 @@ import java.util.List; public class AccountViewerSelectionModel extends DefaultListSelectionModel{ protected AccountViewerTableModel letteringTableModel; - protected Entry entry; + protected AccountViewerEntryDto entry; protected int lineSelected; protected boolean balancedSelectionMode; @@ -62,7 +61,7 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ String currentLettring = getCurrentLettring(); //select entries with the same letter of the selected entry - for(Entry entry : getEntries()){ + for(AccountViewerEntryDto entry : getEntries()){ if (StringUtils.isNotBlank(entry.getLettering())){ if (entry.getLettering().equals(currentLettring)){ int entryToSelect = letteringTableModel.indexOf(entry); @@ -76,7 +75,7 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ //unlettred entries //To clear the selection when it changes from lettered entry to unlettered - for(Entry entry : getEntries()){ + for(AccountViewerEntryDto entry : getEntries()){ if (!StringUtils.isBlank(entry.getLettering())) { int entryToSelect = letteringTableModel.indexOf(entry); super.removeSelectionInterval(entryToSelect, entryToSelect); @@ -114,7 +113,7 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ return emptyOrNull; } - public List<Entry> getEntries(){ + public List<AccountViewerEntryDto> getEntries(){ return letteringTableModel.getValues(); } @@ -122,7 +121,7 @@ public class AccountViewerSelectionModel extends DefaultListSelectionModel{ return getCurrentEntrySelected().getLettering(); } - public Entry getCurrentEntrySelected(){ + public AccountViewerEntryDto getCurrentEntrySelected(){ return letteringTableModel.get(lineSelected); } 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..0a17692 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,12 +22,14 @@ 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 javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.io.IOException; +import java.io.InputStream; import java.math.BigDecimal; import java.util.Date; @@ -40,47 +42,44 @@ import static org.nuiton.i18n.I18n.t; * @author ore * @author chatellier */ -public class AccountViewerTableModel extends AbstractLimaTableModel<Entry> { +public class AccountViewerTableModel extends AbstractLimaTableModel<AccountViewerEntryDto> { /** serialVersionUID. */ private static final long serialVersionUID = 1L; - public BigDecimal getPreviousPeriodSold() { - return previousPeriodSold; - } - - protected BigDecimal previousPeriodSold; + protected ImageIcon lockedImageIcon; @Override protected void initColumn() { - addColumn(new AbstractColumn<AccountViewerTableModel>(Date.class, t("lima.table.date"), false) { + addColumn(new AbstractColumn<AccountViewerTableModel>(ImageIcon.class, t("lima.table.locked"), false) { @Override public Object getValueAt(int row) { - Entry entry = tableModel.get(row); - return entry.getFinancialTransaction().getTransactionDate(); + AccountViewerEntryDto entry = tableModel.get(row); + ImageIcon imageIcon = entry.isLocked() ? getLockedImageIcon() : null; + return imageIcon; } }); - addColumn(new AbstractColumn<AccountViewerTableModel>(EntryBook.class, t("lima.table.entryBook"), false) { + 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().getEntryBook(); + AccountViewerEntryDto entry = tableModel.get(row); + return entry.getTransactionDate(); } }); - addColumn(new AbstractColumn<AccountViewerTableModel>(Account.class, t("lima.table.account"), 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.getAccount(); + AccountViewerEntryDto entry = tableModel.get(row); + return entry.getEntryBookCode(); } }); addColumn(new AbstractColumn<AccountViewerTableModel>(String.class, t("lima.table.voucher"), false) { @Override public Object getValueAt(int row) { - Entry entry = tableModel.get(row); + AccountViewerEntryDto entry = tableModel.get(row); return entry.getVoucher(); } }); @@ -88,7 +87,7 @@ public class AccountViewerTableModel extends AbstractLimaTableModel<Entry> { addColumn(new AbstractColumn<AccountViewerTableModel>(String.class, t("lima.table.description"), false) { @Override public Object getValueAt(int row) { - Entry entry = tableModel.get(row); + AccountViewerEntryDto entry = tableModel.get(row); return entry.getDescription(); } }); @@ -96,7 +95,7 @@ public class AccountViewerTableModel extends AbstractLimaTableModel<Entry> { addColumn(new AbstractColumn<AccountViewerTableModel>(String.class, t("lima.table.letter"), false) { @Override public Object getValueAt(int row) { - Entry entry = tableModel.get(row); + AccountViewerEntryDto entry = tableModel.get(row); return entry.getLettering(); } }); @@ -104,41 +103,41 @@ public class AccountViewerTableModel extends AbstractLimaTableModel<Entry> { 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; + AccountViewerEntryDto entry = tableModel.get(row); + return entry.getDebit(); } }); 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(); + AccountViewerEntryDto entry = tableModel.get(row); + return entry.getCredit(); } }); 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++; - } - - } + AccountViewerEntryDto currentEntry = tableModel.get(row); + BigDecimal result = currentEntry.getSold(); return result; } }); } - public void setPreviousPeriodSold(BigDecimal previousPeriodSold) { - this.previousPeriodSold = previousPeriodSold; + protected ImageIcon getLockedImageIcon() { + if (lockedImageIcon == null) { + InputStream stream = AccountViewerTableModel.class.getResourceAsStream("/icons/action-financialPeriod-close.png"); + Image lockedIcon; + try { + lockedIcon = ImageIO.read(stream); + lockedImageIcon = new ImageIcon(lockedIcon); + } catch (IOException e) { + e.printStackTrace(); + } + } + return lockedImageIcon; } } 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..a72fca3 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; @@ -32,21 +33,17 @@ 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.ClosedPeriodicEntryBookService; 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; @@ -75,17 +72,14 @@ 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 ClosedPeriodicEntryBookService closedPeriodicEntryBookService; protected EntryBookService entryBookService; + protected FinancialPeriodService financialPeriodService; + protected FinancialTransactionService financialTransactionService; + protected FiscalPeriodService fiscalPeriodService; protected LetteringFilterImpl filter; @@ -93,22 +87,24 @@ 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); + closedPeriodicEntryBookService = LimaServiceFactory.getService(ClosedPeriodicEntryBookService.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 +146,10 @@ public class AccountViewerViewHandler { onSelectionModeChanged(selectionMode); + SwingUtil.fixTableColumnWidth(view.getTable(), 0, 50); + SwingUtil.fixTableColumnWidth(view.getTable(), 2, 50); + SwingUtil.fixTableColumnWidth(view.getTable(), 5, 50); + initializationComplete = true; updateAllEntries(); updateSoldStatus(); @@ -230,56 +230,83 @@ public class AccountViewerViewHandler { && filter.getDateStart() != null && filter.getDateEnd() != null) { - List<Entry> entriesAndResume = Lists.newArrayList(); - - List<Entry> entries = financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); - FiscalPeriod fiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()); + List<Entry> entries = financialTransactionService.getAllEntriesByDatesAndAccountAndLettering(filter); + List<AccountViewerEntryDto> result = Lists.newArrayListWithExpectedSize(entries.size()); 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)); - } - } + + FiscalPeriod fiscalPeriod = fiscalPeriodService.getFiscalPeriodForDate(filter.getDateStart()); + + addActualFiscalPeriodSoldInfo(fiscalPeriod); + + addPreviousFiscalPeriodSoldInfo(fiscalPeriod, result); + + transformEntryToDto(entries, result, fiscalPeriod); } - entriesAndResume.addAll(entries); - view.getTableModel().setValues(entriesAndResume); + view.getTableModel().setValues(result); } onBalanceChanged(null); } - protected void addFiscalPeriodBeginDate(FiscalPeriod fiscalPeriod) { + protected void transformEntryToDto(List<Entry> entries, List<AccountViewerEntryDto> result, FiscalPeriod fiscalPeriod) { + List<String> entryBookLockedStatus = getLockedEntryBookIds(fiscalPeriod); + + BigDecimal previousSold = result.isEmpty() ? BigDecimal.ZERO : result.get(0).getSold(); + + for (Entry entry : entries) { + boolean isLocked = entryBookLockedStatus.contains(entry.getFinancialTransaction().getEntryBook().getTopiaId()); + + AccountViewerEntryDto accountViewerEntryDto = new AccountViewerEntryDto(entry, previousSold, isLocked); + + result.add(accountViewerEntryDto); + + previousSold = accountViewerEntryDto.getSold(); + } + } + + protected List<String> getLockedEntryBookIds(FiscalPeriod fiscalPeriod) { + Date periodStart = (fiscalPeriod == null ? filter.getDateStart() : (filter.getDateStart().before(fiscalPeriod.getBeginDate()) ? filter.getDateStart() : fiscalPeriod.getBeginDate())); + return closedPeriodicEntryBookService.getAllLockedEntryBookIdsFrom(periodStart); + } + + protected void addActualFiscalPeriodSoldInfo(FiscalPeriod fiscalPeriod) { + if (fiscalPeriod != null) { + LetteringFilter actualPeriodFilter = computeActualPeriodFilter(fiscalPeriod); + addGlobalActualInfoToModel(fiscalPeriod, actualPeriodFilter); + } + } + + protected void addPreviousFiscalPeriodSoldInfo(FiscalPeriod fiscalPeriod, List<AccountViewerEntryDto> entriesDtos) { + AccountViewerEntryDto result; if (fiscalPeriod != null) { - editModel.setFiscalPeriodBeginDate(fiscalPeriod.getBeginDate()); + LetteringFilter previousPeriodFilter = computePreviousPeriodFilter(fiscalPeriod); + // no previous sold to add if selected starting date is same as fiscal period one + if (!DateUtils.isSameDay(filter.getDateStart(), previousPeriodFilter.getDateStart())) { + BigDecimal previousSold = getPreviousSold(previousPeriodFilter); + result = getFirstLinePreviousSoldEntry(previousPeriodFilter, previousSold); + entriesDtos.add(result); + } } } - 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); + protected AccountViewerEntryDto getFirstLinePreviousSoldEntry(LetteringFilter previousPeriodFilter, BigDecimal previousSold) { + Date previousSoldEndDate = getDayMinus1Calendar(previousPeriodFilter.getDateEnd()).getTime(); + AccountViewerEntryDto result = new AccountViewerEntryDto(); + result.setTransactionDate(previousSoldEndDate); + result.setDescription(String.format(t("lima.accountViewer.previousSold"), getDateFormat().format(previousSoldEndDate))); + + boolean isDebit = BigDecimal.ZERO.compareTo(previousSold) < 0; + result.setDebit(isDebit ? previousSold : BigDecimal.ZERO); + result.setCredit(isDebit ? BigDecimal.ZERO : previousSold); + result.setSold(previousSold); + + result.setIsInitialSold(true); - 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; + return result; } - protected void setPreviousSold(LetteringFilter previousPeriodFilter) { + protected BigDecimal getPreviousSold(LetteringFilter previousPeriodFilter) { BigDecimal previousSold; if (previousPeriodFilter == null) { previousSold = BigDecimal.ZERO; @@ -288,16 +315,16 @@ public class AccountViewerViewHandler { DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); previousSold = debitCreditSold.getSold(); } - view.getTableModel().setPreviousPeriodSold(previousSold); + return previousSold; } - protected void setActualSold(FiscalPeriod fiscalPeriod, LetteringFilter actualPeriodFilter) { - addFiscalPeriodBeginDate(fiscalPeriod); + protected void addGlobalActualInfoToModel(FiscalPeriod fiscalPeriod, LetteringFilter actualPeriodFilter) { List<Object[]> initialDebitCredit = financialTransactionService.getAccountEntriesDebitCreditFromIncludingToIncludingPeriod(actualPeriodFilter); DebitCreditSold debitCreditSold = new DebitCreditSold().invoke(initialDebitCredit); editModel.setGlobalDebit(debitCreditSold.getDebit()); editModel.setGlobalCredit(debitCreditSold.getCredit()); editModel.setGlobalSold(debitCreditSold.getSold()); + editModel.setFiscalPeriodBeginDate(fiscalPeriod.getBeginDate()); } @@ -319,15 +346,15 @@ public class AccountViewerViewHandler { public boolean letteringNotExist(int row){ boolean emptyOrNull = false; if (row != -1) { - Entry entry = view.getTableModel().get(row); + AccountViewerEntryDto entry = view.getTableModel().get(row); String lettering = entry.getLettering(); - emptyOrNull = (lettering==null||lettering.isEmpty()); + emptyOrNull = (lettering == null || lettering.isEmpty()); } return emptyOrNull; } public void setValuesForSelectedEntries() { - Entry selectedEntry; + AccountViewerEntryDto selectedEntry; AccountViewerTableModel tableModel = view.getTableModel(); for (int i = 0; i < tableModel.getRowCount(); i ++){ if (view.getAccountViewerSelectionModel().isSelectedIndex(i)){ @@ -338,25 +365,20 @@ public class AccountViewerViewHandler { } } - public void onBalanceChanged(Entry balance) { + public void onBalanceChanged(AccountViewerEntryDto balance) { if (balance == null) { editModel.setCredit(BigDecimal.ZERO); editModel.setDebit(BigDecimal.ZERO); editModel.setSold(BigDecimal.ZERO, false); } else { - balanceCalculation(balance.getAmount(), balance.isDebit()); + balanceCalculation(balance.getDebit(), balance.getCredit()); } } /**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; - + public void balanceCalculation(BigDecimal debitVal, BigDecimal creditVal) + { if (log.isDebugEnabled()) { log.debug("balance calculation"); } @@ -376,9 +398,9 @@ public class AccountViewerViewHandler { } } - 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; } @@ -478,7 +500,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/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java index 60887dd..3cdcea3 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java @@ -73,7 +73,7 @@ public class FiscalPeriodTableModel extends AbstractLimaTableModel<FiscalPeriod> FiscalPeriod fiscalPeriod = tableModel.get(row); String status = t("lima.fiscalPeriod.open"); if (fiscalPeriod.isLocked()) { - status = t("lima.fiscalPeriod.closed"); + status = t("lima.fiscalPeriod.locked"); } return status; } 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 3e2e0e2..10e148c 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 @@ -670,6 +670,26 @@ public class LetteringViewHandler{ Locale locale = LimaSwingConfig.getInstance().getLocale(); return locale; } - + + 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(); + } } 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 580a3f3..3aeaf9e 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 @@ -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 @@ -366,6 +366,7 @@ lima.fiscalPeriod.error.lockedFinancialPeriod= lima.fiscalPeriod.error.moreOneUnlockFiscalPeriod= lima.fiscalPeriod.error.notBeginNextDayOfLastFiscalPeriod= lima.fiscalPeriod.form=Fiscal period +lima.fiscalPeriod.locked=Locked lima.fiscalPeriod.open=Open lima.fiscalPeriod.status=Status lima.fiscalPeriod.update=Update ending date (Ctrl+M) @@ -526,7 +527,7 @@ lima.table.description=Description lima.table.entryBook=Entry book lima.table.label=Label lima.table.letter=Letter -lima.table.locked=Loked +lima.table.locked=Locked lima.table.number=Account Number lima.table.provisionDeprecation=Provision Deprecation lima.table.voucher=Voucher 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 f69d8f9..07b9572 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,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.accountViewer.previousSold=<html><b>Solde au %s</b></html> lima.accounts=Comptes lima.action.commandline.help=Afficher l'aide en console lima.balance=Équilibrer @@ -237,7 +237,7 @@ 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.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 @@ -377,6 +377,7 @@ lima.fiscalPeriod.error.lockedFinancialPeriod=La période financière est bloqu lima.fiscalPeriod.error.moreOneUnlockFiscalPeriod=Le nombre maximal d'exercices ouverts est déjà ateint\: periode fiscale concernée du %1$te/%1$tm/%1$tY au %1$te/%1$tm/%1$tY. lima.fiscalPeriod.error.notBeginNextDayOfLastFiscalPeriod=La nouvelle période fiscale doit suivre la précédente\: periode fiscale concernée du %1$te/%1$tm/%1$tY au %1$te/%1$tm/%1$tY. lima.fiscalPeriod.form=Exercice +lima.fiscalPeriod.locked=Cloturé lima.fiscalPeriod.open=Ouvert lima.fiscalPeriod.status=Statut lima.fiscalPeriod.update=Modifier la date de fin de l'exercice (Ctrl+M) @@ -468,6 +469,7 @@ lima.lettering.account.back=← lima.lettering.account.next=→ 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.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.accountViewerBalanceStatus=<html>Pour la période du %s au %s le solde est\:<b>%s</b> - <b>%s</b> \= <b>%s</b> - Pour la sélection le solde est\: <b>%s</b> - <b>%s</b> \= <b>%s</b> lima.lettering.balanceStatus=<html>Débit\: <b>%s</b> - Crédit\: <b>%s</b> - Solde\: <b>%s</b> lima.lettering.checkAll=Toutes lima.lettering.checkLettredEntry=Lettrées 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>.
participants (1)
-
chorem.org scm