Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 1853 discussions
r3568 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/financialtransaction resources
by mallon@users.chorem.org 06 Aug '12
by mallon@users.chorem.org 06 Aug '12
06 Aug '12
Author: mallon
Date: 2012-08-06 18:03:49 +0200 (Mon, 06 Aug 2012)
New Revision: 3568
Url: http://chorem.org/repositories/revision/lima/3568
Log:
fixes #705 Desormais, la limitation du nombre de decimales portent tant sur l affichage que sur l edition elle-meme (Arrondis superieur, sur deux decimales, apres edition.).
L entree dans l edition de la cellule se fait des selection de celle-ci (Il n est donc plus necessaire de saisir deux fois un chiffre pour declencher l edition.).
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2012-08-06 10:46:10 UTC (rev 3567)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2012-08-06 16:03:49 UTC (rev 3568)
@@ -24,8 +24,6 @@
*/
import jaxx.runtime.swing.editor.cell.NumberCellEditor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import javax.swing.JTable;
@@ -33,42 +31,47 @@
import java.awt.Component;
import java.awt.event.FocusEvent;
import java.math.BigDecimal;
+import java.math.RoundingMode;
/**
* @author sletellier <letellier(a)codelutin.com>
*/
-public class BigDecimalTableCellEditor extends NumberCellEditor<BigDecimal>{
+public class BigDecimalTableCellEditor extends NumberCellEditor<BigDecimal> {
protected int row;
- static private Log log = LogFactory.getLog(BigDecimalTableCellEditor.class);
-
public BigDecimalTableCellEditor() {
super(BigDecimal.class, false);
}
@Override
public void focusGained(FocusEvent e) {
+ //super.getNumberEditor().getTextField().setText(super.getCellEditorValue().toString());
+ runEdition();
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ this.row = row;
+ return super.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+
+ public void runEdition() {
String comportmentEditingCell = LimaConfig.getInstance().getComportmentEditingCell();
- if (log.isDebugEnabled()) {
- log.debug("comportmentEditingCell : " + comportmentEditingCell);
- }
JTextField numberEditorTextField = super.getNumberEditor().getTextField();
if (comportmentEditingCell.equals("ALL")) {
numberEditorTextField.selectAll();
} else {
int textFieldSize = numberEditorTextField.getText().length();
- if (log.isDebugEnabled()) {
- log.debug("textFieldSize : " + textFieldSize);
- }
numberEditorTextField.select(textFieldSize, textFieldSize);
}
}
@Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- this.row = row;
- return super.getTableCellEditorComponent(table, value, isSelected, row, column);
+ public BigDecimal getCellEditorValue() {
+ if (super.getCellEditorValue() != BigDecimal.ZERO) {
+ return super.getCellEditorValue().setScale(2, RoundingMode.HALF_UP);
+ }
+ return super.getCellEditorValue();
}
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-08-06 10:46:10 UTC (rev 3567)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-08-06 16:03:49 UTC (rev 3568)
@@ -26,6 +26,8 @@
package org.chorem.lima.ui.financialtransaction;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FinancialTransaction;
@@ -79,6 +81,8 @@
addMouseListener(new MyMouseAdapter());
+ //addListSelectionListener();
+
//Get new date editor
setDefaultEditor(Date.class, new DateTableCellEditor());
@@ -161,7 +165,24 @@
FinancialTransactionTable table = FinancialTransactionTable.this;
@Override
+ public void keyTyped(KeyEvent e) {
+ if ( (getSelectedColumn() == 4 || getSelectedColumn() == 5) ) {
+ editCellAt(getSelectedRow(), getSelectedColumn());
+ }
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if ( (getSelectedColumn() == 4 || getSelectedColumn() == 5) ) {
+ editCellAt(getSelectedRow(), getSelectedColumn());
+ }
+ }
+
+ @Override
public void keyPressed(KeyEvent e) {
+ if ( (getSelectedColumn() == 4 || getSelectedColumn() == 5) ) {
+ editCellAt(getSelectedRow(), getSelectedColumn());
+ }
final FinancialTransactionViewHandler handler = getHandler();
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-06 10:46:10 UTC (rev 3567)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-06 16:03:49 UTC (rev 3568)
@@ -45,4 +45,5 @@
log4j.logger.org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel=DEBUG
log4j.logger.org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor=DEBUG
log4j.logger.org.chorem.lima.business.accountingrules.DefaultAccountingRules=DEBUG
-log4j.logger.org.chorem.lima.business.ejb.FinancialTransactionServiceImpl=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.business.ejb.FinancialTransactionServiceImpl=DEBUG
+log4j.logger.org.chorem.lima.business.ui.celleditor.BigDecimalTableCellEditor=DEBUG
\ No newline at end of file
1
0
r3567 - in trunk: . lima-business/src/main/java/org/chorem/lima/business/utils lima-business/src/test/java/org/chorem/lima/business lima-callao lima-swing lima-swing/src/main/java/org/chorem/lima/ui/lettering
by echatellier@users.chorem.org 06 Aug '12
by echatellier@users.chorem.org 06 Aug '12
06 Aug '12
Author: echatellier
Date: 2012-08-06 12:46:10 +0200 (Mon, 06 Aug 2012)
New Revision: 3567
Url: http://chorem.org/repositories/revision/lima/3567
Log:
Udpate libs.
Fix build.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java
trunk/lima-business/src/test/java/org/chorem/lima/business/LetteringComparatorTest.java
trunk/lima-callao/pom.xml
trunk/lima-swing/pom.xml
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
trunk/pom.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java 2012-08-03 16:05:58 UTC (rev 3566)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java 2012-08-06 10:46:10 UTC (rev 3567)
@@ -1,4 +1,27 @@
package org.chorem.lima.business.utils;
+/*
+ * #%L
+ * Lima :: business
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * 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 java.io.Serializable;
import java.util.Comparator;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/LetteringComparatorTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/LetteringComparatorTest.java 2012-08-03 16:05:58 UTC (rev 3566)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/LetteringComparatorTest.java 2012-08-06 10:46:10 UTC (rev 3567)
@@ -1,4 +1,27 @@
package org.chorem.lima.business;
+/*
+ * #%L
+ * Lima :: business
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * 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.chorem.lima.business.utils.LetteringComparator;
import org.junit.Assert;
Modified: trunk/lima-callao/pom.xml
===================================================================
--- trunk/lima-callao/pom.xml 2012-08-03 16:05:58 UTC (rev 3566)
+++ trunk/lima-callao/pom.xml 2012-08-06 10:46:10 UTC (rev 3567)
@@ -28,10 +28,6 @@
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
<groupId>org.nuiton.topia</groupId>
<artifactId>topia-persistence</artifactId>
</dependency>
Modified: trunk/lima-swing/pom.xml
===================================================================
--- trunk/lima-swing/pom.xml 2012-08-03 16:05:58 UTC (rev 3566)
+++ trunk/lima-swing/pom.xml 2012-08-06 10:46:10 UTC (rev 3567)
@@ -71,9 +71,17 @@
</dependency>
<dependency>
- <groupId>org.swinglabs</groupId>
+ <groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.swinglabs.swingx</groupId>
+ <artifactId>swingx-autocomplete</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.swinglabs.swingx</groupId>
+ <artifactId>swingx-painters</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-03 16:05:58 UTC (rev 3566)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-06 10:46:10 UTC (rev 3567)
@@ -9,15 +9,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-03 16:05:58 UTC (rev 3566)
+++ trunk/pom.xml 2012-08-06 10:46:10 UTC (rev 3567)
@@ -109,7 +109,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.3.167</version>
+ <version>1.3.168</version>
<scope>runtime</scope>
</dependency>
@@ -162,13 +162,27 @@
<!-- autres libraires -->
<dependency>
- <groupId>org.swinglabs</groupId>
+ <groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-core</artifactId>
- <version>1.6.2-2</version>
+ <version>${swingxVersion}</version>
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>org.swinglabs.swingx</groupId>
+ <artifactId>swingx-autocomplete</artifactId>
+ <version>${swingxVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.swinglabs.swingx</groupId>
+ <artifactId>swingx-painters</artifactId>
+ <version>${swingxVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
@@ -214,26 +228,26 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
- <version>8.1.4.v20120524</version>
+ <version>8.1.5.v20120716</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
- <version>8.1.4.v20120524</version>
+ <version>8.1.5.v20120716</version>
</dependency>
<!-- pdfbox to create pdf document -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
- <version>1.7.0</version>
+ <version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-examples</artifactId>
- <version>1.7.0</version>
+ <version>1.7.1</version>
</dependency>
<dependency>
@@ -342,13 +356,14 @@
<projectId>lima</projectId>
<!-- customized libs version -->
- <nuitonUtilsVersion>2.5.2-SNAPSHOT</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.5.3-SNAPSHOT</nuitonUtilsVersion>
<eugenePluginVersion>2.4.2</eugenePluginVersion>
<topiaVersion>2.6.11</topiaVersion>
- <jaxxVersion>2.5.4-SNAPSHOT</jaxxVersion>
+ <jaxxVersion>2.5.3</jaxxVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<openEjbVersion>4.0.0</openEjbVersion>
<slf4jVersion>1.6.6</slf4jVersion>
+ <swingxVersion>1.6.4</swingxVersion>
<!-- license to use -->
<license.licenseName>gpl_v3</license.licenseName>
1
0
r3566 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction
by mallon@users.chorem.org 03 Aug '12
by mallon@users.chorem.org 03 Aug '12
03 Aug '12
Author: mallon
Date: 2012-08-03 18:05:58 +0200 (Fri, 03 Aug 2012)
New Revision: 3566
Url: http://chorem.org/repositories/revision/lima/3566
Log:
fixes #729 Pour plus de visibilite, modification de la couleur surlignant une transaction lorsque celle-ci possede un solde different de 0.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-08-03 15:55:10 UTC (rev 3565)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-08-03 16:05:58 UTC (rev 3566)
@@ -130,7 +130,7 @@
//To color in red entry with debit and credit equals to zero
colorTransaction =
- new ColorHighlighter(predicate, new Color(255, 198, 209), null);
+ new ColorHighlighter(predicate, new Color(255, 0, 0), null);
addHighlighter(colorTransaction);
HighlightPredicate debitCreditZero = new HighlightPredicate() {
1
0
r3565 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business-api/src/main/java/org/chorem/lima/business/api lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 03 Aug '12
by mallon@users.chorem.org 03 Aug '12
03 Aug '12
Author: mallon
Date: 2012-08-03 17:55:10 +0200 (Fri, 03 Aug 2012)
New Revision: 3565
Url: http://chorem.org/repositories/revision/lima/3565
Log:
fixes #726 Deplacement de code du handler du lettrage dans le service adequat
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-03 15:02:44 UTC (rev 3564)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-03 15:55:10 UTC (rev 3565)
@@ -32,6 +32,7 @@
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+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;
@@ -43,6 +44,7 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionDAO;
@@ -59,6 +61,8 @@
import java.util.Date;
import java.util.List;
+import static org.nuiton.i18n.I18n._;
+
/**
* Cette classe permet la création d'une transaction comptable dans l'application.
* Toute action sur une transaction entraîne automatiquement une création de log.
@@ -83,6 +87,9 @@
protected EntryBookService entryBookService;
@EJB
+ protected AccountService accountService;
+
+ @EJB
protected OptionsService optionsService;
protected static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
@@ -186,6 +193,117 @@
return nextLetters;
}
+ @Override
+ public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws LimaException{
+
+ Entry newSameAccountEntry = null;
+ Entry newCostOrProductEntry = null;
+ BigDecimal firstSelectedEntryAmount = FirstEntrySelected.getAmount();
+ BigDecimal secondSelectedEntryAmount = SecondEntrySelected.getAmount();
+
+ if ( (firstSelectedEntryAmount.compareTo(BigDecimal.ZERO) != 0 && secondSelectedEntryAmount.compareTo(BigDecimal.ZERO) != 0)
+ && !firstSelectedEntryAmount.equals(secondSelectedEntryAmount)) {
+
+ /*Calculation of result with it
+ * Tab : 0 : debit
+ * 1 : credit*/
+ BigDecimal[] firstEntryDebitCredit = debitCreditCalculation(FirstEntrySelected);
+ BigDecimal[] secondEntryDebitCredit = debitCreditCalculation(SecondEntrySelected);
+
+ /*Subtraction between debit and credit of first and second selected line*/
+ BigDecimal firstEntryDebitSubtract = firstEntryDebitCredit[0].subtract(secondEntryDebitCredit[1]);
+ BigDecimal secondEntryDebitSubtract = secondEntryDebitCredit[0].subtract(firstEntryDebitCredit[1]);
+
+ /*Create handles of new futures entries*/
+ Entry sameAccountEntry;
+ Entry costOrProductEntry;
+
+ /*Set result in the amount of the new entries*/
+ if (firstEntryDebitSubtract.compareTo(BigDecimal.ZERO) != 0) {
+ sameAccountEntry = copyEntryWithoutAmount(FirstEntrySelected);
+ costOrProductEntry = copyEntryWithoutAmount(FirstEntrySelected);
+ amountsCalculation(firstEntryDebitSubtract, sameAccountEntry, costOrProductEntry);
+ } else {
+ sameAccountEntry = copyEntryWithoutAmount(SecondEntrySelected);
+ costOrProductEntry = copyEntryWithoutAmount(SecondEntrySelected);
+ amountsCalculation(secondEntryDebitSubtract, sameAccountEntry, costOrProductEntry);
+ }
+
+ String accountRegularization = _("lima.ui.lettering.accountRegularization");
+
+ if (log.isDebugEnabled()) {
+ log.debug("accountRegularization : " + accountRegularization);
+ }
+
+ sameAccountEntry.setDescription(accountRegularization);
+ costOrProductEntry.setDescription(accountRegularization);
+
+ /*Save in the DB the new entries*/
+ newSameAccountEntry = createEntry(sameAccountEntry);
+ newCostOrProductEntry = createEntry(costOrProductEntry);
+
+ }
+
+ Entry [] entries = {newSameAccountEntry, newCostOrProductEntry};
+ return entries;
+ }
+
+ /**Debit and credit calculation for one entry, with its amount
+ * @param entry Entry for calculation
+ * @return table of two big decimal, representing respectively debit and credit
+ * */
+ protected BigDecimal[] debitCreditCalculation(Entry entry) {
+
+ boolean firstEntryDebit = entry.getDebit();
+ BigDecimal firstEntryAmount = entry.getAmount();
+
+ BigDecimal debitVal = firstEntryDebit ? firstEntryAmount : BigDecimal.ZERO;
+ BigDecimal creditVal = firstEntryDebit ? BigDecimal.ZERO : firstEntryAmount;
+
+ BigDecimal[] debitCredit = {debitVal, creditVal};
+
+ return debitCredit;
+ }
+
+ /**Copy parametrised entry, without amount*/
+ protected Entry copyEntryWithoutAmount(Entry entryToCopy) {
+ Entry copiedEntry = new EntryImpl();
+
+ copiedEntry.setAccount(entryToCopy.getAccount());
+ copiedEntry.setDescription(entryToCopy.getDescription());
+ copiedEntry.setDetail(entryToCopy.getDetail());
+ copiedEntry.setFinancialTransaction(entryToCopy.getFinancialTransaction());
+ copiedEntry.setVoucher(entryToCopy.getVoucher());
+
+ return copiedEntry;
+ }
+
+ /**
+ *Calculation of amount for the new entries created
+ * and determine for the second if account is in costs (658)
+ * or products (758)
+ * @param resultOfFirstSecondEntrySubtraction difference between the two old entries
+ * @param sameAccountEntry first new entry created with the same account
+ * @param costOrProductEntry second new entry created with account 658 or 758
+ * */
+ protected void amountsCalculation( BigDecimal resultOfFirstSecondEntrySubtraction, Entry sameAccountEntry, Entry costOrProductEntry) {
+ sameAccountEntry.setAmount(resultOfFirstSecondEntrySubtraction.abs());
+ costOrProductEntry.setAmount(resultOfFirstSecondEntrySubtraction.abs());
+ Account costOrProductAccount;
+
+ /*-1 for less than 0 : credit*/
+ if (resultOfFirstSecondEntrySubtraction.compareTo(BigDecimal.ZERO) == -1) {
+ sameAccountEntry.setDebit(true);
+ costOrProductEntry.setDebit(false);
+ costOrProductAccount = accountService.getAccountByNumber("758");
+ } else { /*Greater than 0 : debit*/
+ sameAccountEntry.setDebit(false);
+ costOrProductEntry.setDebit(true);
+ costOrProductAccount = accountService.getAccountByNumber("658");
+ }
+ costOrProductEntry.setAccount(costOrProductAccount);
+ }
+
protected String getCharsA(int numberOfA) {
String charsA="";
for (int j = 0; j < numberOfA; j++) {
@@ -353,13 +471,6 @@
Date financialTransactionOldDate = financialTransactionOld.getTransactionDate();
Date financialTransactionDate = financialTransaction.getTransactionDate();
- if (log.isDebugEnabled()) {
- log.debug("Date de la transaction (Old) : " + financialTransactionOldDate);
- }
- if (log.isDebugEnabled()) {
- log.debug("Date de la transaction (New) : " + financialTransactionDate);
- }
-
financialTransactionOld.setEntryBook(financialTransaction.getEntryBook());
financialTransactionOld.setTransactionDate(financialTransactionDate);
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-08-03 15:02:44 UTC (rev 3564)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-08-03 15:55:10 UTC (rev 3565)
@@ -79,10 +79,20 @@
String getNextLetters() throws LimaException;
/**
- * Retourne toutes les entrées d'une transaction
- * 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
- * @throws org.nuiton.topia.TopiaException
- * */
+ * From to selected entries, create one with same account and
+ * difference between the amounts, and another one with
+ * account 658 or 758 and an amount conversely of the first created
+ * @param FirstEntrySelected first entry selected
+ * @param SecondEntrySelected second entry selected
+ * @return table of the two new entries
+ * */
+ Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws LimaException;
+
+ /**
+ * Retourne toutes les entrées d'une transaction
+ * 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
+ * @throws LimaException
+ * */
List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) throws LimaException;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-08-03 15:02:44 UTC (rev 3564)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-08-03 15:55:10 UTC (rev 3565)
@@ -27,8 +27,6 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryImpl;
-
import javax.swing.table.AbstractTableModel;
import java.math.BigDecimal;
import java.util.Date;
@@ -243,7 +241,7 @@
}
/**Copy parametrised entry, without amount*/
- public Entry copyEntryWithoutAmount(Entry entryToCopy) {
+ /*public Entry copyEntryWithoutAmount(Entry entryToCopy) {
Entry copiedEntry = new EntryImpl();
copiedEntry.setAccount(entryToCopy.getAccount());
@@ -253,5 +251,5 @@
copiedEntry.setVoucher(entryToCopy.getVoucher());
return copiedEntry;
- }
+ }*/
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-03 15:02:44 UTC (rev 3564)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-03 15:55:10 UTC (rev 3565)
@@ -201,23 +201,6 @@
editModel.setUnLettred(false);
editModel.setEqualized(false);
}
-
- /*if (mode.equals(buttonMode.DELETTRED)) {
- editModel.setLettred(false);
- editModel.setUnLettred(true);
- } else if (mode.equals("lettrer")) {
- if (log.isDebugEnabled()) {
- log.debug("Lettred entry");
- }
- editModel.setUnLettred(false);
- editModel.setLettred(true);
- }else if (mode.equals("equalized")) {
- editModel.setEqualized(true);
- } else {
- editModel.setLettred(false);
- editModel.setUnLettred(false);
- editModel.setEqualized(false);
- }*/
}
public void setValuesForSelectedEntries() {
@@ -340,112 +323,25 @@
int[] selectedRows = view.getTable().getSelectedRows();
if (selectedRows.length == 2) {
-
/*Treatment only if one of values contains decimals*/
Entry firstSelectedEntry = tableModel.getEntryAt(selectedRows[0]);
Entry secondSelectedEntry = tableModel.getEntryAt(selectedRows[1]);
- BigDecimal firstSelectedEntryAmount = firstSelectedEntry.getAmount();
- BigDecimal secondSelectedEntryAmount = secondSelectedEntry.getAmount();
+ Entry[] newEntriesFormEqualizing = financialTransactionService.getEntriesFromEqualizing(firstSelectedEntry, secondSelectedEntry);
+ /*Add new entries to the model and the table*/
+ Entry newSameAccountEntry = newEntriesFormEqualizing[0];
+ Entry newCostOrProductEntry = newEntriesFormEqualizing[1];
+ tableModel.addEntry(newSameAccountEntry, newSameAccountEntry.getFinancialTransaction().getTransactionDate());
+ tableModel.addEntry(newCostOrProductEntry, newCostOrProductEntry.getFinancialTransaction().getTransactionDate());
-
- if ( (firstSelectedEntryAmount.compareTo(BigDecimal.ZERO) != 0 && secondSelectedEntryAmount.compareTo(BigDecimal.ZERO) != 0)
- && !firstSelectedEntryAmount.equals(secondSelectedEntryAmount)) {
-
- /*Calculation of result with it
- * Tab : 0 : debit
- * 1 : credit*/
- BigDecimal[] firstEntryDebitCredit = debitCreditCalculation(firstSelectedEntry);
- BigDecimal[] secondEntryDebitCredit = debitCreditCalculation(secondSelectedEntry);
-
- /*Subtraction between debit and credit of first and second selected line*/
- BigDecimal firstEntryDebitSubtract = firstEntryDebitCredit[0].subtract(secondEntryDebitCredit[1]);
- BigDecimal secondEntryDebitSubtract = secondEntryDebitCredit[0].subtract(firstEntryDebitCredit[1]);
-
- /*Create handles of new futures entries*/
- Entry sameAccountEntry;
- Entry costOrProductEntry;
-
- /*Set result in the amount of the new entries*/
- if (firstEntryDebitSubtract.compareTo(BigDecimal.ZERO) != 0) {
- sameAccountEntry = tableModel.copyEntryWithoutAmount(firstSelectedEntry);
- costOrProductEntry = tableModel.copyEntryWithoutAmount(firstSelectedEntry);
- amountsCalculation(firstEntryDebitSubtract, sameAccountEntry, costOrProductEntry);
- } else { //firstEntryDebitSubtract == 0
- sameAccountEntry = tableModel.copyEntryWithoutAmount(secondSelectedEntry);
- costOrProductEntry = tableModel.copyEntryWithoutAmount(secondSelectedEntry);
- amountsCalculation(secondEntryDebitSubtract, sameAccountEntry, costOrProductEntry);
- }
-
- String accountRegularization = _("lima.ui.lettering.accountRegularization");
-
- if (log.isDebugEnabled()) {
- log.debug("accountRegularization : " + accountRegularization);
- }
-
- sameAccountEntry.setDescription(accountRegularization);
- costOrProductEntry.setDescription(accountRegularization);
-
- /*Save in the DB the new entries*/
- Entry newSameAccountEntry = financialTransactionService.createEntry(sameAccountEntry);
- Entry newCostOrProductEntry = financialTransactionService.createEntry(costOrProductEntry);
-
- /*Add new entries to the model and the table*/
- tableModel.addEntry(newSameAccountEntry, newSameAccountEntry.getFinancialTransaction().getTransactionDate());
- tableModel.addEntry(newCostOrProductEntry, newCostOrProductEntry.getFinancialTransaction().getTransactionDate());
-
- /*Re-select the two entries (firstSelectedEntry and secondSelectedEntry)
- * and the new sameAccountEntry
- * */
- view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry);
- }
+ /*Re-select the two entries (firstSelectedEntry and secondSelectedEntry)
+ * and the new sameAccountEntry
+ * */
+ view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry);
}
}
- /**Debit and credit calculation for one entry, with its amount
- * @param entry Entry for calculation
- * @return table of two big decimal, representing respectively debit and credit
- * */
- protected BigDecimal[] debitCreditCalculation(Entry entry) {
-
- boolean firstEntryDebit = entry.getDebit();
- BigDecimal firstEntryAmount = entry.getAmount();
-
- BigDecimal debitVal = firstEntryDebit ? firstEntryAmount : BigDecimal.ZERO;
- BigDecimal creditVal = firstEntryDebit ? BigDecimal.ZERO : firstEntryAmount;
-
- BigDecimal[] debitCredit = {debitVal, creditVal};
-
- return debitCredit;
- }
-
- /**
- *Calculation of amount for the new entries created
- * and determine for the second if account is in costs (658)
- * or products (758)
- * @param resultOfFirstSecondEntrySubtraction difference between the two old entries
- * @param sameAccountEntry first new entry created with the same account
- * @param costOrProductEntry second new entry created with account 658 or 758
- * */
- protected void amountsCalculation( BigDecimal resultOfFirstSecondEntrySubtraction, Entry sameAccountEntry, Entry costOrProductEntry) {
- sameAccountEntry.setAmount(resultOfFirstSecondEntrySubtraction.abs());
- costOrProductEntry.setAmount(resultOfFirstSecondEntrySubtraction.abs());
- Account costOrProductAccount;
-
- /*-1 for less than 0 : credit*/
- if (resultOfFirstSecondEntrySubtraction.compareTo(BigDecimal.ZERO) == -1) {
- sameAccountEntry.setDebit(true);
- costOrProductEntry.setDebit(false);
- costOrProductAccount = accountService.getAccountByNumber("758");
- } else { /*Greater than 0 : debit*/
- sameAccountEntry.setDebit(false);
- costOrProductEntry.setDebit(true);
- costOrProductAccount = accountService.getAccountByNumber("658");
- }
- costOrProductEntry.setAccount(costOrProductAccount);
- }
-
/**To test if the filter contain an account and a period
* @return true if filter is valid
* */
1
0
r3564 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/utils lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 03 Aug '12
by mallon@users.chorem.org 03 Aug '12
03 Aug '12
Author: mallon
Date: 2012-08-03 17:02:44 +0200 (Fri, 03 Aug 2012)
New Revision: 3564
Url: http://chorem.org/repositories/revision/lima/3564
Log:
fixes #735 Correction permettant une meilleure incr?\195?\169mentation du lettrage.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-02 17:06:11 UTC (rev 3563)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-03 15:02:44 UTC (rev 3564)
@@ -25,6 +25,8 @@
package org.chorem.lima.business.ejb;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.FinancialTransactionSearch;
import org.chorem.lima.beans.LetteringFilter;
import org.chorem.lima.business.AccountingRules;
@@ -83,6 +85,8 @@
@EJB
protected OptionsService optionsService;
+ protected static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
+
@Override
public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction)
throws LimaException {
@@ -126,6 +130,7 @@
@Override
public String getNextLetters() throws LimaException {
String lastActualLetters;
+ String nextLetters = "";
try {
EntryDAO entryDAO = getDaoHelper().getEntryDAO();
@@ -137,14 +142,58 @@
}
/**Increment letter alphabetically*/
- if (lastActualLetters.charAt(0) != 'Z') {
- String finLastActualLetters = lastActualLetters.substring(1, lastActualLetters.length());
- return String.valueOf( (char) (lastActualLetters.charAt(0) + 1)) + finLastActualLetters;
+ int indexCharToIncrement = 0;
+ int lastActualLettersLength = lastActualLetters.length();
+ String findLastLetters;
+ String findFirstLetters ="";
+ int numberOfA;
+
+ /*Searching which letter is 'Z', and so must be incremented*/
+ for (int i = 0; i < lastActualLettersLength; i++) {
+ if (lastActualLetters.charAt(i) != 'Z') {
+ indexCharToIncrement = i;
+ }
+ }
+
+ /*When no letter, just set 'A'*/
+ if (lastActualLettersLength != 0) {
+
+ /*Get first letter(s), only if we have more of one letter (One letter = letter to increment)*/
+ String firstPartActualLetters = lastActualLetters.substring(0, indexCharToIncrement);
+ if (firstPartActualLetters.length() > 1) {
+ findFirstLetters = firstPartActualLetters;
+ }
+
+ /*Get the letters after the correct letter to increment and
+ *increment it (Using 'indexCharToIncrement')
+ * */
+ findLastLetters = lastActualLetters.substring(indexCharToIncrement+1, lastActualLettersLength);
+ if (lastActualLetters.charAt(indexCharToIncrement) != 'Z') {
+ /*Last letters transform to x 'A' (x = Number of 'Z'), if they are 'Z'*/
+ if (findLastLetters.length() > 0) {
+ if (findLastLetters.charAt(0) == 'Z') {
+ numberOfA = findLastLetters.length();
+ findLastLetters=getCharsA(numberOfA);
+ }
+ }
+ nextLetters = findFirstLetters + String.valueOf( (char) (lastActualLetters.charAt(indexCharToIncrement) + 1)) + findLastLetters;
+ }
+
} else {
- return "A" + lastActualLetters;
+ numberOfA = lastActualLettersLength +1;
+ nextLetters = getCharsA(numberOfA);
}
+ return nextLetters;
}
+ protected String getCharsA(int numberOfA) {
+ String charsA="";
+ for (int j = 0; j < numberOfA; j++) {
+ charsA = charsA+"A";
+ }
+ return charsA;
+ }
+
public String findLastLetter(List<String> letters) {
String result;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java 2012-08-02 17:06:11 UTC (rev 3563)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java 2012-08-03 15:02:44 UTC (rev 3564)
@@ -3,13 +3,6 @@
import java.io.Serializable;
import java.util.Comparator;
-/**
- * Created with IntelliJ IDEA.
- * User: mallon
- * Date: 24/07/12
- * Time: 15:39
- * To change this template use File | Settings | File Templates.
- */
public class LetteringComparator implements Serializable , Comparator<String> {
private static final long serialVersionUID = 1L;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-02 17:06:11 UTC (rev 3563)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-03 15:02:44 UTC (rev 3564)
@@ -134,21 +134,13 @@
Entry firstSelectedEntry = tableModel.getEntryAt(selectedRows[0]);
Entry secondSelectedEntry = tableModel.getEntryAt(selectedRows[1]);
- BigDecimal [] amountFirstEntry = debitCreditCalculation(firstSelectedEntry);
- BigDecimal amountFirst = amountFirstEntry[0].equals(BigDecimal.ZERO)?amountFirstEntry[1]:amountFirstEntry[0];
- BigDecimal [] amountSecondEntry = debitCreditCalculation(secondSelectedEntry);
- BigDecimal amountSecond = amountSecondEntry[0].equals(BigDecimal.ZERO)?amountSecondEntry[1]:amountSecondEntry[0];
+ /*Get decimals*/
+ BigDecimal firstSelectedEntryAmount = firstSelectedEntry.getAmount();
+ BigDecimal secondSelectedEntryAmount = secondSelectedEntry.getAmount();
- if (log.isDebugEnabled()) {
- log.debug(amountFirst + " - " + amountSecond);
- }
-
- /*String decimalFirstEntrySelected = (firstSelectedEntry.getAmount().toString().split("\\."))[1];
- String decimalSecondSelectedEntry = (secondSelectedEntry.getAmount().toString().split("\\."))[1];*/
- if ( /*(!decimalFirstEntrySelected.equals("00") || !decimalSecondSelectedEntry.equals("00"))*/
- !amountFirst.equals(BigDecimal.ZERO) && !amountSecond.equals(BigDecimal.ZERO)
- && secondSelectedEntry.getDebit() != firstSelectedEntry.getDebit()
- && !amountFirst.equals(amountSecond)) {
+ if ( secondSelectedEntry.getDebit() != firstSelectedEntry.getDebit()
+ && firstSelectedEntryAmount.subtract(secondSelectedEntryAmount).abs().compareTo(BigDecimal.ZERO) >=0
+ && firstSelectedEntryAmount.subtract(secondSelectedEntryAmount).abs().compareTo(BigDecimal.ONE) <=0) {
onButtonModeChanged(buttonMode.EQUALIZED);
}
}else {
@@ -353,9 +345,14 @@
Entry firstSelectedEntry = tableModel.getEntryAt(selectedRows[0]);
Entry secondSelectedEntry = tableModel.getEntryAt(selectedRows[1]);
- if ( (firstSelectedEntry.getAmount().compareTo(BigDecimal.ZERO) != 0 && secondSelectedEntry.getAmount().compareTo(BigDecimal.ZERO) != 0)
- && !firstSelectedEntry.getAmount().equals(secondSelectedEntry.getAmount())) {
+ BigDecimal firstSelectedEntryAmount = firstSelectedEntry.getAmount();
+ BigDecimal secondSelectedEntryAmount = secondSelectedEntry.getAmount();
+
+
+ if ( (firstSelectedEntryAmount.compareTo(BigDecimal.ZERO) != 0 && secondSelectedEntryAmount.compareTo(BigDecimal.ZERO) != 0)
+ && !firstSelectedEntryAmount.equals(secondSelectedEntryAmount)) {
+
/*Calculation of result with it
* Tab : 0 : debit
* 1 : credit*/
1
0
r3563 - in trunk: lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/lettering lima-swing/src/main/resources lima-swing/src/main/resources/i18n
by mallon@users.chorem.org 02 Aug '12
by mallon@users.chorem.org 02 Aug '12
02 Aug '12
Author: mallon
Date: 2012-08-02 19:06:11 +0200 (Thu, 02 Aug 2012)
New Revision: 3563
Url: http://chorem.org/repositories/revision/lima/3563
Log:
refs #726 Correction permettant d ajouter une entree avec la difference entre les deux selectionnees, et portant le meme numero de compte que ces deux dernieres. Une autre entree est aussi ajoutee, en credit / debit, en 658 / 758. Un enum a aussi ete ajoute pour les modes correspondant aux boutons, pour plus de clarte - Reste a repartir le code ne devant pas etre dans le handler dans un service.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-08-02 09:45:20 UTC (rev 3562)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-08-02 17:06:11 UTC (rev 3563)
@@ -258,17 +258,24 @@
try {
+ if (log.isDebugEnabled()) {
+ log.debug("entry : " + entry);
+ log.debug("entryOld : " + entryOld);
+ }
+
FinancialPeriodDAO financialPeriodDAO = getDaoHelper().getFinancialPeriodDAO();
FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(entry.getFinancialTransaction().getTransactionDate());
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = getDaoHelper().getClosedPeriodicEntryBookDAO();
- //second case
- ClosedPeriodicEntryBook closedPeriodicEntryBook =
- closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
- entryOld.getFinancialTransaction().getEntryBook(), financialPeriod);
- if (closedPeriodicEntryBook.getLocked()) {
- throw new LimaBusinessException(_("lima-Business.defaultaccountingrules.updateentryerror"));
+ if (entryOld != null) {
+ //second case
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
+ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
+ entryOld.getFinancialTransaction().getEntryBook(), financialPeriod);
+ if (closedPeriodicEntryBook.getLocked()) {
+ throw new LimaBusinessException(_("lima-Business.defaultaccountingrules.updateentryerror"));
+ }
}
//third case
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-02 09:45:20 UTC (rev 3562)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-02 17:06:11 UTC (rev 3563)
@@ -370,7 +370,6 @@
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
try {
-
EntryDAO entryDAO = getDaoHelper().getEntryDAO();
Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId());
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-08-02 09:45:20 UTC (rev 3562)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-08-02 17:06:11 UTC (rev 3563)
@@ -237,13 +237,15 @@
public void updateLettersSelectedEntries(int[] entries, String letters) {
for (int rowEntry : entries){
getEntryAt(rowEntry).setLettering(letters);
+ fireTableRowsUpdated(rowEntry, rowEntry);
}
- fireTableDataChanged();
+// fireTableDataChanged();
}
/**Copy parametrised entry, without amount*/
public Entry copyEntryWithoutAmount(Entry entryToCopy) {
Entry copiedEntry = new EntryImpl();
+
copiedEntry.setAccount(entryToCopy.getAccount());
copiedEntry.setDescription(entryToCopy.getDescription());
copiedEntry.setDetail(entryToCopy.getDetail());
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-02 09:45:20 UTC (rev 3562)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-02 17:06:11 UTC (rev 3563)
@@ -34,6 +34,7 @@
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.business.ejb.FinancialTransactionServiceImpl;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FiscalPeriod;
@@ -48,6 +49,8 @@
import java.util.Date;
import java.util.List;
+import static org.nuiton.i18n.I18n._;
+
/**
* Handler associated with financial transaction view.
*
@@ -76,6 +79,7 @@
protected BigDecimal solde = BigDecimal.ZERO;
protected LettringSelectionModel lettringSelectionModel;
protected LetteringEditModel editModel;
+ protected enum buttonMode {DELETTRED, LETTRED, EQUALIZED, ALL}
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
public LetteringViewHandler(LetteringView view) {
@@ -107,7 +111,7 @@
public void balanceAndActions() {
if (view.getTable().getSelectedRows().length == 0) {
- onButtonModeChanged("all");
+ onButtonModeChanged(buttonMode.ALL);
} else if (!letteringNotExist(view.getTable().getSelectedRow())) {
//lettred entries
@@ -115,7 +119,7 @@
setValuesForSelectedEntries();
//For U.I. buttons (Lettering and unlettering)
- onButtonModeChanged("delettrer");
+ onButtonModeChanged(buttonMode.DELETTRED);
} else {
if (log.isDebugEnabled()) {
log.debug("unlettred entries");
@@ -145,13 +149,13 @@
!amountFirst.equals(BigDecimal.ZERO) && !amountSecond.equals(BigDecimal.ZERO)
&& secondSelectedEntry.getDebit() != firstSelectedEntry.getDebit()
&& !amountFirst.equals(amountSecond)) {
- onButtonModeChanged("equalized");
+ onButtonModeChanged(buttonMode.EQUALIZED);
}
}else {
if (log.isDebugEnabled()) {
log.debug("!2 rows selected");
}
- onButtonModeChanged("all");
+ onButtonModeChanged(buttonMode.ALL);
}
//Unlettred entries
@@ -162,12 +166,12 @@
log.debug("Rows selected");
}
setValuesForSelectedEntries();
- onButtonModeChanged("lettrer");
+ onButtonModeChanged(buttonMode.LETTRED);
} else {
if (log.isDebugEnabled()) {
log.debug("No Rows selected");
}
- onButtonModeChanged("all");
+ onButtonModeChanged(buttonMode.ALL);
}
}
}
@@ -186,8 +190,27 @@
return emptyOrNull;
}
- public void onButtonModeChanged(String mode) {
- if (mode.equals("delettrer")) {
+ 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);
+ }
+
+ /*if (mode.equals(buttonMode.DELETTRED)) {
editModel.setLettred(false);
editModel.setUnLettred(true);
} else if (mode.equals("lettrer")) {
@@ -202,7 +225,7 @@
editModel.setLettred(false);
editModel.setUnLettred(false);
editModel.setEqualized(false);
- }
+ }*/
}
public void setValuesForSelectedEntries() {
@@ -313,7 +336,6 @@
view.getTableModel().updateEntries(entries, datesEntree, journalEntrees);
}
onBalanceChanged(null);
- //view.getLettringSelectionModel().clearSelection();
}
/**To make the difference between two selected entries and
@@ -344,28 +366,42 @@
BigDecimal firstEntryDebitSubtract = firstEntryDebitCredit[0].subtract(secondEntryDebitCredit[1]);
BigDecimal secondEntryDebitSubtract = secondEntryDebitCredit[0].subtract(firstEntryDebitCredit[1]);
- /*Create handle of new future entry*/
- Entry entry;
+ /*Create handles of new futures entries*/
+ Entry sameAccountEntry;
+ Entry costOrProductEntry;
- /*Set result in the amount of the new entry*/
+ /*Set result in the amount of the new entries*/
if (firstEntryDebitSubtract.compareTo(BigDecimal.ZERO) != 0) {
- entry = tableModel.copyEntryWithoutAmount(firstSelectedEntry);
- amountsCalculation(firstSelectedEntry, secondSelectedEntry, firstEntryDebitSubtract, entry);
+ sameAccountEntry = tableModel.copyEntryWithoutAmount(firstSelectedEntry);
+ costOrProductEntry = tableModel.copyEntryWithoutAmount(firstSelectedEntry);
+ amountsCalculation(firstEntryDebitSubtract, sameAccountEntry, costOrProductEntry);
} else { //firstEntryDebitSubtract == 0
- entry = tableModel.copyEntryWithoutAmount(secondSelectedEntry);
- amountsCalculation(firstSelectedEntry, secondSelectedEntry, secondEntryDebitSubtract, entry);
+ sameAccountEntry = tableModel.copyEntryWithoutAmount(secondSelectedEntry);
+ costOrProductEntry = tableModel.copyEntryWithoutAmount(secondSelectedEntry);
+ amountsCalculation(secondEntryDebitSubtract, sameAccountEntry, costOrProductEntry);
}
- /*Add new entry to the model and the table*/
- tableModel.addEntry(entry, entry.getFinancialTransaction().getTransactionDate());
+ String accountRegularization = _("lima.ui.lettering.accountRegularization");
- /*Save in DB the new entry*/
- financialTransactionService.createEntry(entry);
+ if (log.isDebugEnabled()) {
+ log.debug("accountRegularization : " + accountRegularization);
+ }
+ sameAccountEntry.setDescription(accountRegularization);
+ costOrProductEntry.setDescription(accountRegularization);
+
+ /*Save in the DB the new entries*/
+ Entry newSameAccountEntry = financialTransactionService.createEntry(sameAccountEntry);
+ Entry newCostOrProductEntry = financialTransactionService.createEntry(costOrProductEntry);
+
+ /*Add new entries to the model and the table*/
+ tableModel.addEntry(newSameAccountEntry, newSameAccountEntry.getFinancialTransaction().getTransactionDate());
+ tableModel.addEntry(newCostOrProductEntry, newCostOrProductEntry.getFinancialTransaction().getTransactionDate());
+
/*Re-select the two entries (firstSelectedEntry and secondSelectedEntry)
- * and the new entry
+ * and the new sameAccountEntry
* */
- view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], entry);
+ view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry);
}
}
}
@@ -388,31 +424,29 @@
}
/**
- *Calculation of amount for the new entry created and one of the two old entries
- * @param firstSelectedEntry first selected entry
- * @param secondSelectedEntry second selected entry
+ *Calculation of amount for the new entries created
+ * and determine for the second if account is in costs (658)
+ * or products (758)
* @param resultOfFirstSecondEntrySubtraction difference between the two old entries
- * @param newEntry new entry created
+ * @param sameAccountEntry first new entry created with the same account
+ * @param costOrProductEntry second new entry created with account 658 or 758
* */
- protected void amountsCalculation(Entry firstSelectedEntry, Entry secondSelectedEntry, BigDecimal resultOfFirstSecondEntrySubtraction, Entry newEntry) {
- BigDecimal newDebitOrCredit;
- if (secondSelectedEntry.getAmount().compareTo(firstSelectedEntry.getAmount())>0) {
- newDebitOrCredit = secondSelectedEntry.getAmount().subtract(resultOfFirstSecondEntrySubtraction.abs());
- secondSelectedEntry.setAmount(newDebitOrCredit);
- financialTransactionService.updateEntry(secondSelectedEntry);
- } else {
- newDebitOrCredit = firstSelectedEntry.getAmount().subtract(resultOfFirstSecondEntrySubtraction.abs());
- firstSelectedEntry.setAmount(newDebitOrCredit);
- financialTransactionService.updateEntry(firstSelectedEntry);
- }
- newEntry.setAmount(resultOfFirstSecondEntrySubtraction.abs());
+ protected void amountsCalculation( BigDecimal resultOfFirstSecondEntrySubtraction, Entry sameAccountEntry, Entry costOrProductEntry) {
+ sameAccountEntry.setAmount(resultOfFirstSecondEntrySubtraction.abs());
+ costOrProductEntry.setAmount(resultOfFirstSecondEntrySubtraction.abs());
+ Account costOrProductAccount;
/*-1 for less than 0 : credit*/
if (resultOfFirstSecondEntrySubtraction.compareTo(BigDecimal.ZERO) == -1) {
- newEntry.setDebit(false);
+ sameAccountEntry.setDebit(true);
+ costOrProductEntry.setDebit(false);
+ costOrProductAccount = accountService.getAccountByNumber("758");
} else { /*Greater than 0 : debit*/
- newEntry.setDebit(true);
+ sameAccountEntry.setDebit(false);
+ costOrProductEntry.setDebit(true);
+ costOrProductAccount = accountService.getAccountByNumber("658");
}
+ costOrProductEntry.setAccount(costOrProductAccount);
}
/**To test if the filter contain an account and a period
@@ -461,22 +495,24 @@
public void addLetter() {
String newLetters = financialTransactionService.getNextLetters();
changeLetter(newLetters);
+ onButtonModeChanged(buttonMode.DELETTRED);
}
/**Remove a group of three letters to n entries*/
public void removeLetter() {
changeLetter(null);
+ onButtonModeChanged(buttonMode.LETTRED);
}
/**Add or remove a group of three letters to n entries*/
protected void changeLetter(String newLetters) {
+
int[] entrieSelected = view.getTable().getSelectedRows();
view.getTableModel().updateLettersSelectedEntries(entrieSelected, newLetters);
for (int indexEntry : entrieSelected){
financialTransactionService.updateEntry(view.getTableModel().getEntryAt(indexEntry));
- view.getTable().addRowSelectionInterval(indexEntry, indexEntry);
}
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-02 09:45:20 UTC (rev 3562)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-08-02 17:06:11 UTC (rev 3563)
@@ -326,6 +326,7 @@
lima.ui.importexport.wait=Job in progress…
lima.ui.importexport.waittitle=
lima.ui.lettering.account=Accounts
+lima.ui.lettering.accountRegularization=Lettering regularization
lima.ui.lettering.actions=Actions
lima.ui.lettering.beginFinancialPeriod=From
lima.ui.lettering.buttonAuto=Auto
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-02 09:45:20 UTC (rev 3562)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-08-02 17:06:11 UTC (rev 3563)
@@ -326,6 +326,7 @@
lima.ui.importexport.wait=Traitement en cours…
lima.ui.importexport.waittitle=Traitement en cours
lima.ui.lettering.account=Comptes
+lima.ui.lettering.accountRegularization=Régularisation lettrage
lima.ui.lettering.actions=Actions
lima.ui.lettering.beginFinancialPeriod=De
lima.ui.lettering.buttonAuto=Auto
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-02 09:45:20 UTC (rev 3562)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-02 17:06:11 UTC (rev 3563)
@@ -43,4 +43,6 @@
log4j.logger.org.chorem.lima.ui.lettering.LettringSelectionModel=DEBUG
log4j.logger.org.chorem.lima.ui.lettering.LetteringEditModel=DEBUG
log4j.logger.org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel=DEBUG
-log4j.logger.org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor=DEBUG
+log4j.logger.org.chorem.lima.business.accountingrules.DefaultAccountingRules=DEBUG
+log4j.logger.org.chorem.lima.business.ejb.FinancialTransactionServiceImpl=DEBUG
\ No newline at end of file
1
0
r3562 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 02 Aug '12
by mallon@users.chorem.org 02 Aug '12
02 Aug '12
Author: mallon
Date: 2012-08-02 11:45:20 +0200 (Thu, 02 Aug 2012)
New Revision: 3562
Url: http://chorem.org/repositories/revision/lima/3562
Log:
fixes #725 Correction permettant de re-de / lettrer un ensemble d'?\195?\169critures, juste apr?\195?\168s leur de / lettrage. I.e., les boutons lettrer / delettrer sont d?\195?\169sormais correctement activ?\195?\169s.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-02 09:18:58 UTC (rev 3561)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-02 09:45:20 UTC (rev 3562)
@@ -461,13 +461,11 @@
public void addLetter() {
String newLetters = financialTransactionService.getNextLetters();
changeLetter(newLetters);
- //onBalanceChanged(null);
}
/**Remove a group of three letters to n entries*/
public void removeLetter() {
changeLetter(null);
- //onBalanceChanged(null);
}
/**Add or remove a group of three letters to n entries*/
@@ -480,8 +478,6 @@
financialTransactionService.updateEntry(view.getTableModel().getEntryAt(indexEntry));
view.getTable().addRowSelectionInterval(indexEntry, indexEntry);
}
- editModel.setLettred(false);
- editModel.setUnLettred(false);
}
}
1
0
r3561 - in trunk/lima-swing/src/main/java/org/chorem/lima: . ui/lettering
by mallon@users.chorem.org 02 Aug '12
by mallon@users.chorem.org 02 Aug '12
02 Aug '12
Author: mallon
Date: 2012-08-02 11:18:58 +0200 (Thu, 02 Aug 2012)
New Revision: 3561
Url: http://chorem.org/repositories/revision/lima/3561
Log:
fixes #724 Correction concernant la normalisation des clefs de la configuration.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2012-08-01 16:23:35 UTC (rev 3560)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2012-08-02 09:18:58 UTC (rev 3561)
@@ -417,21 +417,21 @@
DATA_DIR("lima.data.dir", n_("lima.config.data.dir.description"), "${user.home}/.lima", File.class, false, false),
RESOURCES_DIRECTORY("lima.resources.dir", n_("lima.config.resources.dir.description"), "${lima.data.dir}/resources-${application.version}", String.class, false, false),
I18N_DIRECTORY("lima.i18n.dir", n_("lima.config.i18n.dir.description"), "${lima.resources.dir}/i18n", String.class, false, false),
- LOCALE("locale", n_("lima.config.locale.description"), "fr_FR", Locale.class, false, false),
- DECIMAL_SEPARATOR("lima.config.decimalseparator", n_("lima.config.decimalseparator.description"), ",", String.class, false, false),
- SCALE("scale", n_("lima.config.scale.description"), "2", Integer.class, false, false),
- THOUSAND_SEPARATOR("thousandSeparator", n_("limma.config.thousandseparator.description"), " ", String.class, false, false),
- CURRENCY("currency", n_("lima.config.currency.description"), "none", Boolean.class, false, false),
+ LOCALE("lima.ui.locale", n_("lima.config.locale.description"), "fr_FR", Locale.class, false, false),
+ DECIMAL_SEPARATOR("lima.data.bigDecimal.decimalSeparator", n_("lima.config.decimalseparator.description"), ",", String.class, false, false),
+ SCALE("lima.data.bigDecimal.scale", n_("lima.config.scale.description"), "2", Integer.class, false, false),
+ THOUSAND_SEPARATOR("lima.thousandSeparator", n_("limma.config.thousandseparator.description"), " ", String.class, false, false),
+ CURRENCY("lima.config.currency", n_("lima.config.currency.description"), "none", Boolean.class, false, false),
FULL_SCREEN("lima.ui.fullscreen", n_("lima.config.ui.fullscreen.description"), "false", Boolean.class, false, false),
LAUNCH_UI("lima.ui.launchui", n_("lima.config.ui.flaunchui.description"), "true", Boolean.class, true, true),
SUPPORT_EMAIL("lima.misc.supportemail", n_("lima.misc.supportemail.description"), "support(a)codelutin.com", String.class, false, false),
OPENEJB_REMOTEMODE("lima.openejb.remotemode", n_("lima.openejb.remotemode.description"), "false", String.class, false, false),
LIMA_HOST_ADDRESS("lima.host.address", n_("lima.config.host.adress"), "localhost", String.class, false, false),
- LIMA_STATE_FILE("lima.state.file", n_("lima.config.state.file"), "${lima.data.dir}/limaState.xml", String.class, false, false),
- COLOR_SELECTION_FOCUS("colorselectionfocus", _("lima.config.colorselectionfocus"), "#000000", Color.class, false, false),
- COMPORTMENT_EDITING_CELL("comportmenteditingcell", _("lima.config.comportmenteditingcell"), "ALL", comportmentEditingCellEnum.class, false, false);
+ LIMA_STATE_FILE("lima.ui.state.file", n_("lima.config.state.file"), "${lima.data.dir}/limaState.xml", String.class, false, false),
+ COLOR_SELECTION_FOCUS("lima.ui.table.cell.colorSelectionFocus", _("lima.config.colorselectionfocus"), "#000000", Color.class, false, false),
+ COMPORTMENT_EDITING_CELL("lima.ui.table.cell.comportmentEditingCell", _("lima.config.comportmenteditingcell"), "ALL", comportmentEditingCellEnum.class, false, false);
- public enum comportmentEditingCellEnum {ALL, NOTHING};
+ public enum comportmentEditingCellEnum {ALL, NOTHING}
public final String key;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-01 16:23:35 UTC (rev 3560)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-02 09:18:58 UTC (rev 3561)
@@ -130,10 +130,21 @@
Entry firstSelectedEntry = tableModel.getEntryAt(selectedRows[0]);
Entry secondSelectedEntry = tableModel.getEntryAt(selectedRows[1]);
- String decimalFirstEntrySelected = (firstSelectedEntry.getAmount().toString().split("\\."))[1];
- String decimalSecondSelectedEntry = (secondSelectedEntry.getAmount().toString().split("\\."))[1];
- if ( !decimalFirstEntrySelected.equals("00") || !decimalSecondSelectedEntry.equals("00")
- && secondSelectedEntry.getDebit() != firstSelectedEntry.getDebit()) {
+ BigDecimal [] amountFirstEntry = debitCreditCalculation(firstSelectedEntry);
+ BigDecimal amountFirst = amountFirstEntry[0].equals(BigDecimal.ZERO)?amountFirstEntry[1]:amountFirstEntry[0];
+ BigDecimal [] amountSecondEntry = debitCreditCalculation(secondSelectedEntry);
+ BigDecimal amountSecond = amountSecondEntry[0].equals(BigDecimal.ZERO)?amountSecondEntry[1]:amountSecondEntry[0];
+
+ if (log.isDebugEnabled()) {
+ log.debug(amountFirst + " - " + amountSecond);
+ }
+
+ /*String decimalFirstEntrySelected = (firstSelectedEntry.getAmount().toString().split("\\."))[1];
+ String decimalSecondSelectedEntry = (secondSelectedEntry.getAmount().toString().split("\\."))[1];*/
+ if ( /*(!decimalFirstEntrySelected.equals("00") || !decimalSecondSelectedEntry.equals("00"))*/
+ !amountFirst.equals(BigDecimal.ZERO) && !amountSecond.equals(BigDecimal.ZERO)
+ && secondSelectedEntry.getDebit() != firstSelectedEntry.getDebit()
+ && !amountFirst.equals(amountSecond)) {
onButtonModeChanged("equalized");
}
}else {
1
0
r3560 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 01 Aug '12
by mallon@users.chorem.org 01 Aug '12
01 Aug '12
Author: mallon
Date: 2012-08-01 18:23:35 +0200 (Wed, 01 Aug 2012)
New Revision: 3560
Url: http://chorem.org/repositories/revision/lima/3560
Log:
fixes #711 Correction permettant de ne pas avoir de d?\195?\169s?\195?\169lection lors du d?\195?\169 / lettrage.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-08-01 12:27:37 UTC (rev 3559)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-08-01 16:23:35 UTC (rev 3560)
@@ -1,7 +1,7 @@
<!--
#%L
Lima Swing
-
+
$Id$
$HeadURL$
%%
@@ -23,167 +23,167 @@
#L%
-->
-<Table constraints='BorderLayout.NORTH'>
+<Table >
- <import>
- org.chorem.lima.ui.common.AccountComboBoxModel
- org.chorem.lima.ui.common.FinancialPeriodComboBoxModel
- org.chorem.lima.entity.Account
- javax.swing.ListSelectionModel
- org.jdesktop.swingx.JXDatePicker
- org.chorem.lima.beans.LetteringFilter
- org.chorem.lima.beans.LetteringFilterImpl
- </import>
+ <import>
+ org.chorem.lima.ui.common.AccountComboBoxModel
+ org.chorem.lima.ui.common.FinancialPeriodComboBoxModel
+ org.chorem.lima.entity.Account
+ javax.swing.ListSelectionModel
+ org.jdesktop.swingx.JXDatePicker
+ org.chorem.lima.beans.LetteringFilter
+ org.chorem.lima.beans.LetteringFilterImpl
+ </import>
- <LetteringViewHandler id="handler" constructorParams="this"/>
- <LetteringTableModel id="tableModel"/>
+ <LetteringViewHandler id="handler" constructorParams="this"/>
+ <LetteringTableModel id="tableModel"/>
- <LetteringFilterImpl id='filterModel' initializer='new LetteringFilterImpl()'/>
- <LetteringEditModel id='editModel'/>
+ <LetteringFilterImpl id='filterModel' initializer='new LetteringFilterImpl()'/>
+ <LetteringEditModel id='editModel'/>
- <LettringSelectionModel id='lettringSelectionModel' constructorParams=' tableModel'
- onValueChanged="handler.balanceAndActions()"/>
+ <LettringSelectionModel id='lettringSelectionModel' constructorParams=' tableModel'
+ onValueChanged="handler.balanceAndActions()"/>
- <script>
- <![CDATA[
+ <script>
+ <![CDATA[
void $afterCompleteSetup() {
handler.init();
}
]]>
- </script>
+ </script>
- <row>
- <cell>
- <JPanel layout='{new BorderLayout()}' id="panelAccountComboBox" border='{new TitledBorder(_("lima.ui.lettering.account"))}'>
- <org.chorem.lima.ui.common.AccountComboBoxModel id="accountComboBoxModel"/>
- <JComboBox id="accountComboBox" model="{accountComboBoxModel}"
- renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}"
- onActionPerformed="filterModel.setAccount((Account)accountComboBoxModel.getSelectedItem())"
- constraints='BorderLayout.WEST'/>
- <JButton id="backCount" text="lima.ui.account.buttonback"
- onActionPerformed="handler.back(accountComboBox)"
- constraints='BorderLayout.CENTER'/>
- <JButton id="nextCount" text="lima.ui.account.buttonnext"
- onActionPerformed="handler.next(accountComboBox)"
- constraints='BorderLayout.EAST'/>
- </JPanel>
- </cell>
- <cell>
- <JPanel id="panelFinancialPeriodComboBox" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.period"))}'>
- <Table constraints='BorderLayout.NORTH'>
- <row>
- <cell>
- <JLabel text="lima.ui.lettering.beginFinancialPeriod"/>
- </cell>
- <cell>
- <JXDatePicker id="pickerDebut"
- onActionPerformed="filterModel.setDateStart(pickerDebut.getDate())"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.ui.lettering.endFinancialPeriod"/>
- </cell>
- <cell>
- <JXDatePicker id="pickerFin"
- onActionPerformed="filterModel.setDateEnd(pickerFin.getDate())"/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell anchor="center" weightx="1">
- <JPanel id="entryPanel" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.entry"))}'>
- <Table constraints='BorderLayout.NORTH'>
- <row>
- <cell>
- <JRadioButton id="lettredEntryCheckBox" buttonGroup="letteredCheckGroup"
- onActionPerformed="filterModel.setDisplayLettered(true) ; filterModel.setDisplayUnlettred(false)"/>
- </cell>
- <cell>
- <JLabel text="lima.ui.lettering.checkLettredEntry"/>
- </cell>
- </row>
- <row>
- <cell>
- <JRadioButton id="noLettredEntryCheckBox" selected="true" buttonGroup="letteredCheckGroup"
- onActionPerformed="filterModel.setDisplayUnlettred(true); filterModel.setDisplayLettered(false)"/>
- </cell>
- <cell>
- <JLabel text="lima.ui.lettering.checkNoLettredEntry"/>
- </cell>
- </row>
- <row>
- <cell>
- <JRadioButton id="allCheckBox" buttonGroup="letteredCheckGroup"
- onActionPerformed="filterModel.setDisplayLettered(false) ; filterModel.setDisplayUnlettred(false)"/>
- </cell>
- <cell>
- <JLabel text="lima.ui.lettering.checkAll"/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell fill="horizontal" columns="4">
- <JPanel id="selectedEntry" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.selectEntry"))}'>
- <Table constraints='BorderLayout.NORTH'>
- <row>
- <cell anchor="center" weightx="0.6">
- <JLabel text="lima.ui.lettering.selectDebit" labelFor='{debitTexttField}'/>
- </cell>
- <cell fill="horizontal" weightx="0.6">
- <JTextField id="debitTexttField" editable="false" text="{editModel.getDebit().toString()}"
- focusable="false"/>
- </cell>
- <cell anchor="center" weightx="0.6">
- <JLabel text="lima.ui.lettering.selectCredit" labelFor='{creditTextField}'/>
- </cell>
- <cell fill="horizontal" weightx="0.6">
- <JTextField id="creditTextField" editable="false" text="{editModel.getCredit().toString()}"
- focusable="false"/>
- </cell>
- <cell anchor="center" weightx="0.6">
- <JLabel text="lima.ui.lettering.selectSolde" labelFor='{soldeTextField}'/>
- </cell>
- <cell fill="horizontal" weightx="0.6">
- <JTextField id="soldeTextField" editable="false" text="{editModel.getSolde().toString()}"
- focusable="false"/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell anchor="center" columns='4'>
- <JPanel id="actionsPanel">
- <JButton id="lettered" text="lima.ui.lettering.buttonLettered"
- enabled="{editModel.isLettred()}"
- onActionPerformed="handler.addLetter()"/>
- <JButton id="noLettered" text="lima.ui.lettering.buttonNoLettered"
- enabled="{editModel.isUnLettred()}"
- onActionPerformed="handler.removeLetter()"/>
- <JButton id="refresh" text="lima.ui.lettering.buttonRefresh"
- enabled="true"
- onActionPerformed="handler.updateAllEntries()"/>
- <JButton id="round" text="lima.ui.lettering.buttonEqualize"
- enabled="{editModel.isEqualized()}"
- onActionPerformed="handler.roundAndCreateEntry()"/>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell fill="both" weightx="1" weighty="1" columns="4">
- <JScrollPane>
- <LetteringTable
- id="table" sortable="false" rowHeight="22"
- constructorParams="getTableModel()"
- selectionModel="{lettringSelectionModel}"
- />
- </JScrollPane>
- </cell>
- </row>
+ <row>
+ <cell>
+ <JPanel layout='{new BorderLayout()}' id="panelAccountComboBox" border='{new TitledBorder(_("lima.ui.lettering.account"))}'>
+ <org.chorem.lima.ui.common.AccountComboBoxModel id="accountComboBoxModel"/>
+ <JComboBox id="accountComboBox" model="{accountComboBoxModel}"
+ renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}"
+ onActionPerformed="filterModel.setAccount((Account)accountComboBoxModel.getSelectedItem())"
+ constraints='BorderLayout.WEST'/>
+ <JButton id="backCount" text="lima.ui.account.buttonback"
+ onActionPerformed="handler.back(accountComboBox)"
+ constraints='BorderLayout.CENTER'/>
+ <JButton id="nextCount" text="lima.ui.account.buttonnext"
+ onActionPerformed="handler.next(accountComboBox)"
+ constraints='BorderLayout.EAST'/>
+ </JPanel>
+ </cell>
+ <cell>
+ <JPanel id="panelFinancialPeriodComboBox" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.period"))}'>
+ <Table constraints='BorderLayout.NORTH'>
+ <row>
+ <cell>
+ <JLabel text="lima.ui.lettering.beginFinancialPeriod"/>
+ </cell>
+ <cell>
+ <JXDatePicker id="pickerDebut"
+ onActionPerformed="filterModel.setDateStart(pickerDebut.getDate())"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.ui.lettering.endFinancialPeriod"/>
+ </cell>
+ <cell>
+ <JXDatePicker id="pickerFin"
+ onActionPerformed="filterModel.setDateEnd(pickerFin.getDate())"/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell>
+ <JPanel id="entryPanel" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.entry"))}'>
+ <Table constraints='BorderLayout.NORTH'>
+ <row>
+ <cell>
+ <JRadioButton id="lettredEntryCheckBox" buttonGroup="letteredCheckGroup"
+ onActionPerformed="filterModel.setDisplayLettered(true) ; filterModel.setDisplayUnlettred(false)"/>
+ </cell>
+ <cell>
+ <JLabel text="lima.ui.lettering.checkLettredEntry"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JRadioButton id="noLettredEntryCheckBox" selected="true" buttonGroup="letteredCheckGroup"
+ onActionPerformed="filterModel.setDisplayUnlettred(true); filterModel.setDisplayLettered(false)"/>
+ </cell>
+ <cell>
+ <JLabel text="lima.ui.lettering.checkNoLettredEntry"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JRadioButton id="allCheckBox" buttonGroup="letteredCheckGroup"
+ onActionPerformed="filterModel.setDisplayLettered(false) ; filterModel.setDisplayUnlettred(false)"/>
+ </cell>
+ <cell>
+ <JLabel text="lima.ui.lettering.checkAll"/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal" columns="4">
+ <JPanel id="selectedEntry" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.selectEntry"))}'>
+ <Table constraints='BorderLayout.NORTH'>
+ <row>
+ <cell anchor="center" weightx="0.6">
+ <JLabel text="lima.ui.lettering.selectDebit" labelFor='{debitTexttField}'/>
+ </cell>
+ <cell fill="horizontal" weightx="0.6">
+ <JTextField id="debitTexttField" editable="false" text="{editModel.getDebit().toString()}"
+ focusable="false"/>
+ </cell>
+ <cell anchor="center" weightx="0.6">
+ <JLabel text="lima.ui.lettering.selectCredit" labelFor='{creditTextField}'/>
+ </cell>
+ <cell fill="horizontal" weightx="0.6">
+ <JTextField id="creditTextField" editable="false" text="{editModel.getCredit().toString()}"
+ focusable="false"/>
+ </cell>
+ <cell anchor="center" weightx="0.6">
+ <JLabel text="lima.ui.lettering.selectSolde" labelFor='{soldeTextField}'/>
+ </cell>
+ <cell fill="horizontal" weightx="0.6">
+ <JTextField id="soldeTextField" editable="false" text="{editModel.getSolde().toString()}"
+ focusable="false"/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell anchor="center" columns='4'>
+ <JPanel id="actionsPanel">
+ <JButton id="lettered" text="lima.ui.lettering.buttonLettered"
+ enabled="{editModel.isLettred()}"
+ onActionPerformed="handler.addLetter()"/>
+ <JButton id="noLettered" text="lima.ui.lettering.buttonNoLettered"
+ enabled="{editModel.isUnLettred()}"
+ onActionPerformed="handler.removeLetter()"/>
+ <JButton id="refresh" text="lima.ui.lettering.buttonRefresh"
+ enabled="true"
+ onActionPerformed="handler.updateAllEntries()"/>
+ <JButton id="round" text="lima.ui.lettering.buttonEqualize"
+ enabled="{editModel.isEqualized()}"
+ onActionPerformed="handler.roundAndCreateEntry()"/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1" weighty="1" columns="4">
+ <JScrollPane>
+ <LetteringTable
+ id="table" sortable="false" rowHeight="22"
+ constructorParams="getTableModel()"
+ selectionModel="{lettringSelectionModel}"
+ />
+ </JScrollPane>
+ </cell>
+ </row>
</Table>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-01 12:27:37 UTC (rev 3559)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-01 16:23:35 UTC (rev 3560)
@@ -117,9 +117,14 @@
//For U.I. buttons (Lettering and unlettering)
onButtonModeChanged("delettrer");
} 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*/
LetteringTableModel tableModel = view.getTableModel();
Entry firstSelectedEntry = tableModel.getEntryAt(selectedRows[0]);
@@ -132,6 +137,9 @@
onButtonModeChanged("equalized");
}
}else {
+ if (log.isDebugEnabled()) {
+ log.debug("!2 rows selected");
+ }
onButtonModeChanged("all");
}
@@ -139,9 +147,15 @@
onBalanceChanged(null);
//treatment unuseful if no rows are selected
if (!view.getLettringSelectionModel().isSelectionEmpty()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Rows selected");
+ }
setValuesForSelectedEntries();
onButtonModeChanged("lettrer");
} else {
+ if (log.isDebugEnabled()) {
+ log.debug("No Rows selected");
+ }
onButtonModeChanged("all");
}
}
@@ -288,7 +302,7 @@
view.getTableModel().updateEntries(entries, datesEntree, journalEntrees);
}
onBalanceChanged(null);
- view.getLettringSelectionModel().clearSelection();
+ //view.getLettringSelectionModel().clearSelection();
}
/**To make the difference between two selected entries and
@@ -436,13 +450,13 @@
public void addLetter() {
String newLetters = financialTransactionService.getNextLetters();
changeLetter(newLetters);
- onBalanceChanged(null);
+ //onBalanceChanged(null);
}
/**Remove a group of three letters to n entries*/
public void removeLetter() {
changeLetter(null);
- onBalanceChanged(null);
+ //onBalanceChanged(null);
}
/**Add or remove a group of three letters to n entries*/
@@ -453,6 +467,7 @@
for (int indexEntry : entrieSelected){
financialTransactionService.updateEntry(view.getTableModel().getEntryAt(indexEntry));
+ view.getTable().addRowSelectionInterval(indexEntry, indexEntry);
}
editModel.setLettred(false);
editModel.setUnLettred(false);
1
0
r3559 - in trunk/lima-swing/src/main: java/org/chorem/lima java/org/chorem/lima/ui/celleditor resources
by mallon@users.chorem.org 01 Aug '12
by mallon@users.chorem.org 01 Aug '12
01 Aug '12
Author: mallon
Date: 2012-08-01 14:27:37 +0200 (Wed, 01 Aug 2012)
New Revision: 3559
Url: http://chorem.org/repositories/revision/lima/3559
Log:
Correction d un probleme d instance dans le context Lima.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2012-08-01 11:27:51 UTC (rev 3558)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2012-08-01 12:27:37 UTC (rev 3559)
@@ -83,7 +83,7 @@
}
instance = new LimaContext();
instance.setContextValue(new MainViewHandler());
- CONFIG_DEF.setContextValue(instance, new LimaConfig());
+ CONFIG_DEF.setContextValue(instance, LimaConfig.getInstance());
DECORATOR_PROVIDER_DEF.setContextValue(instance, new LimaDecoratorProvider());
return instance;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2012-08-01 11:27:51 UTC (rev 3558)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2012-08-01 12:27:37 UTC (rev 3559)
@@ -24,6 +24,8 @@
*/
import jaxx.runtime.swing.editor.cell.NumberCellEditor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import javax.swing.JTable;
@@ -39,6 +41,8 @@
protected int row;
+ static private Log log = LogFactory.getLog(BigDecimalTableCellEditor.class);
+
public BigDecimalTableCellEditor() {
super(BigDecimal.class, false);
}
@@ -46,11 +50,17 @@
@Override
public void focusGained(FocusEvent e) {
String comportmentEditingCell = LimaConfig.getInstance().getComportmentEditingCell();
+ if (log.isDebugEnabled()) {
+ log.debug("comportmentEditingCell : " + comportmentEditingCell);
+ }
JTextField numberEditorTextField = super.getNumberEditor().getTextField();
if (comportmentEditingCell.equals("ALL")) {
numberEditorTextField.selectAll();
} else {
int textFieldSize = numberEditorTextField.getText().length();
+ if (log.isDebugEnabled()) {
+ log.debug("textFieldSize : " + textFieldSize);
+ }
numberEditorTextField.select(textFieldSize, textFieldSize);
}
}
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-08-01 11:27:51 UTC (rev 3558)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-08-01 12:27:37 UTC (rev 3559)
@@ -42,4 +42,5 @@
log4j.logger.org.chorem.lima.ui.lettering.LetteringViewHandler=DEBUG
log4j.logger.org.chorem.lima.ui.lettering.LettringSelectionModel=DEBUG
log4j.logger.org.chorem.lima.ui.lettering.LetteringEditModel=DEBUG
-log4j.logger.org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel=DEBUG
+log4j.logger.org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor=DEBUG
\ No newline at end of file
1
0