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
Author: tchemit
Date: 2010-04-20 16:05:38 +0200 (Tue, 20 Apr 2010)
New Revision: 2868
Log:
Utilisation de mavenpom4redmine 2.1.2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-19 16:51:59 UTC (rev 2867)
+++ trunk/pom.xml 2010-04-20 14:05:38 UTC (rev 2868)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.0.7</version>
+ <version>2.1.2</version>
</parent>
<groupId>org.chorem</groupId>
1
0
r2867 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/resources/i18n
by jpepin@users.chorem.org 19 Apr '10
by jpepin@users.chorem.org 19 Apr '10
19 Apr '10
Author: jpepin
Date: 2010-04-19 18:51:59 +0200 (Mon, 19 Apr 2010)
New Revision: 2867
Log:
Ajout formulaire cr?\195?\169ation compte de tiers
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 15:15:40 UTC (rev 2866)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 16:51:59 UTC (rev 2867)
@@ -25,8 +25,6 @@
import java.util.List;
import java.util.ListIterator;
-import javassist.bytecode.Descriptor.Iterator;
-
import javax.ejb.Stateless;
import org.apache.commons.collections.CollectionUtils;
@@ -126,20 +124,9 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- // test si le numero de compte existe deja
-
-
-
-
+ // test si le numero de compte existe deja
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
-
-
-
- /* Suggestion Florian qui marche pas
- * List<Account> existingAccounts =
- accountDAO.findAllByAccountNumber(account.getAccountNumber());
- if (CollectionUtils.isNotEmpty(existingAccounts))*/
Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber());
if (existAccount != null) {
@@ -186,9 +173,8 @@
// test si le numero de compte existe deja
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> existingAccounts =
- accountDAO.findAllByAccountNumber(account.getAccountNumber());
- if (CollectionUtils.isNotEmpty(existingAccounts)) {
+ Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber());
+ if (existAccount != null) {
throw new LimaBusinessException(_(
"An account already exists with this number : %s",
account.getAccountNumber()));
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-19 15:15:40 UTC (rev 2866)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-19 16:51:59 UTC (rev 2867)
@@ -17,13 +17,16 @@
<JDialog defaultCloseOperation="dispose_on_close" modal="true">
+ <org.chorem.lima.entity.Identity id="identity" javaBean='null'/>
<org.chorem.lima.entity.Account id="account" javaBean='null'/>
+
<Boolean id="addState" javaBean='true'/>
<script>
<![CDATA[
protected void performCancel() {
setAccount(null);
+ setIdentity(null);
dispose();
}
]]>
@@ -61,8 +64,129 @@
selectedItem="{getAccount().getType()}"
onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/>
</cell>
+ </row>
+ <!-- NAME CONTACT-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.name"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="nameIdentityTextField" text="{getIdentity().getName()}"/>
+ <javax.swing.text.Document javaBean="getNameIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setName(getNameIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setName(getNameIdentityTextField().getText())' />
+ </cell>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.contact"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="contactIdentityTextField" text="{getIdentity().getContact()}"/>
+ <javax.swing.text.Document javaBean="getContactIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setContact(getContactIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setContact(getContactIdentityTextField().getText())' />
+ </cell>
</row>
+ <!-- SIRET-->
<row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.siret"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="SiretIdentityTextField" text="{getIdentity().getSiret()}"/>
+ <javax.swing.text.Document javaBean="getSiretIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setSiret(getZIPCodeIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setSiret(getZIPCodeIdentityTextField().getText())' />
+ </cell>
+ </row>
+ <!-- ADDRESS -->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.address"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="addressIdentityTextField" text="{getIdentity().getAddress()}"/>
+ <javax.swing.text.Document javaBean="getAddressIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())' />
+ </cell>
+ </row>
+ <!-- ZIPCODE CITY-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.zipcode"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="ZIPCodeIdentityTextField" text="{getIdentity().getZIPCode()}"/>
+ <javax.swing.text.Document javaBean="getZIPCodeIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setZIPCode(getZIPCodeIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setZIPCode(getZIPCodeIdentityTextField().getText())' />
+ </cell>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.city"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="cityIdentityTextField" text="{getIdentity().getCity()}"/>
+ <javax.swing.text.Document javaBean="getCityIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setCity(getCityIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setCity(getCityIdentityTextField().getText())' />
+ </cell>
+ </row>
+ <!-- COUNTRY-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.country"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="CountryIdentityTextField" text="{getIdentity().getCountry()}"/>
+ <javax.swing.text.Document javaBean="getCountryIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setCountry(getZIPCodeIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setCountry(getZIPCodeIdentityTextField().getText())' />
+ </cell>
+ </row>
+ <!-- PHONE FAX-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.phone"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="phoneIdentityTextField" text="{getIdentity().getPhone()}"/>
+ <javax.swing.text.Document javaBean="getPhoneIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())' />
+ </cell>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.fax"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="faxIdentityTextField" text="{getIdentity().getFax()}"/>
+ <javax.swing.text.Document javaBean="getFaxIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())' />
+ </cell>
+ </row>
+ <!-- fin fiche identite EMAIL WEBSITE-->
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.email"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="emailIdentityTextField" text="{getIdentity().getEmail()}"/>
+ <javax.swing.text.Document javaBean="getEmailIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())' />
+ </cell>
+ <cell fill="horizontal">
+ <JLabel text="lima.identity.website"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="websiteIdentityTextField" text="{getIdentity().getWebsite()}"/>
+ <javax.swing.text.Document javaBean="getWebsiteIdentityTextField().getDocument()"
+ onInsertUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())'
+ onRemoveUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())' />
+ </cell>
+ </row>
+ <!-- fin fiche identite -->
+ <row>
<cell fill="none">
<JButton text="lima.common.ok" onActionPerformed="dispose()"/>
</cell>
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 2010-04-19 15:15:40 UTC (rev 2866)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-19 16:51:59 UTC (rev 2867)
@@ -143,6 +143,18 @@
lima.fiscalyear.listclosed=
lima.grand.livre=General Ledger
lima.home=Home - TODO
+lima.identity.address=
+lima.identity.adress=
+lima.identity.city=
+lima.identity.contact=
+lima.identity.country=
+lima.identity.email=
+lima.identity.fax=
+lima.identity.name=
+lima.identity.phone=
+lima.identity.siret=
+lima.identity.website=
+lima.identity.zipcode=
lima.import=Import
lima.import.account=Import PCG
lima.import.all=Import all datas
@@ -233,9 +245,9 @@
lima.progressBar.load.etape4=Loading periods
lima.progressBar.load.etape5=Loading transactions
lima.question=Question
+lima.question.confirmremove.account=This account have subaccounts, do you want remove this account ?
lima.question.load.accounts=There is no existing accounts in Lima. Do you want to load default accounts ?
lima.question.remove.account=Do you want to remove this account ?
-lima.question.confirmremove.account=This account have subaccounts, do you want remove this account ?
lima.question.remove.entry=Do you want to remove this entry ?
lima.question.remove.journal=Do you want to remove this journal ?
lima.question.remove.transaction=Do you want to remove this transaction ?
@@ -262,6 +274,8 @@
lima.status.tr.wip=Work in progress
lima.subledger.accountnumber=
lima.subledger.code=Code
+lima.subledger.label=
+lima.subledger.type=
lima.success=Success
lima.tab.account=Account
lima.tab.balance=Balance
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 2010-04-19 15:15:40 UTC (rev 2866)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-19 16:51:59 UTC (rev 2867)
@@ -142,6 +142,17 @@
lima.fiscalyear.listclosed=Voir toutes les cl\u00F4tures
lima.grand.livre=Grand-Livre
lima.home=Page d'accueil - TODO
+lima.identity.address=Adresse
+lima.identity.city=Ville
+lima.identity.contact=Contact
+lima.identity.country=Pays
+lima.identity.email=eMail
+lima.identity.fax=Fax
+lima.identity.name=Nom
+lima.identity.phone=Tel
+lima.identity.siret=Siret
+lima.identity.website=Site Web
+lima.identity.zipcode=Code Postal
lima.import=Import
lima.import.account=Importer le PCG
lima.import.all=Importer une nouvelle base (XML)
@@ -226,9 +237,9 @@
lima.progressBar.load.etape4=Chargement des p\u00E9riodes
lima.progressBar.load.etape5=Chargement des transactions
lima.question=Question
+lima.question.confirmremove.account=Ce compte poss\u00E8de des sous comptes, voulez-vous supprimer ce compte ?
lima.question.load.accounts=Il n'y a aucun plan comptable existant dans Lima. Voulez-vous en charger un par d\u00E9faut ?
lima.question.remove.account=Voulez-vous supprimer ce compte?
-lima.question.confirmremove.account=Ce compte poss\u00E8de des sous comptes, voulez-vous supprimer ce compte ?
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
lima.question.remove.journal=Voulez-vous supprimer ce journal?
lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
@@ -252,7 +263,10 @@
lima.status.tr.balanced=Equilibr\u00E9e
lima.status.tr.finalized=Valid\u00E9e
lima.status.tr.wip=En cours
+lima.subledger.accountnumber=
lima.subledger.code=Code
+lima.subledger.label=
+lima.subledger.type=
lima.success=Succ\u00E8s
lima.tab.account=Plan Comptable
lima.tab.balance=Balance
1
0
r2866 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/ui/account/model lima-swing/src/main/resources/i18n
by jpepin@users.chorem.org 19 Apr '10
by jpepin@users.chorem.org 19 Apr '10
19 Apr '10
Author: jpepin
Date: 2010-04-19 17:15:40 +0200 (Mon, 19 Apr 2010)
New Revision: 2866
Log:
Ajout m?\195?\169thode de suppression r?\195?\169cursive des sous-comptes contenus dans un compte
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.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
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-19 15:15:40 UTC (rev 2866)
@@ -50,8 +50,10 @@
void updateAccount(Account account) throws LimaException;
- void removeAccount(Account account) throws LimaException;
+ int removeAccount(Account account) throws LimaException;
+ void removeAccountwithSubAccounts(Account account) throws LimaException;
+
Account getAccountNumber(String numAccount) throws LimaException;
List<Account> getChildrenAccounts(Account masterAccount) throws LimaException;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 15:15:40 UTC (rev 2866)
@@ -23,7 +23,10 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.ListIterator;
+import javassist.bytecode.Descriptor.Iterator;
+
import javax.ejb.Stateless;
import org.apache.commons.collections.CollectionUtils;
@@ -124,12 +127,25 @@
transaction = rootContext.beginTransaction();
// test si le numero de compte existe deja
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> existingAccounts =
+
+
+
+
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
+
+
+
+ /* Suggestion Florian qui marche pas
+ * List<Account> existingAccounts =
accountDAO.findAllByAccountNumber(account.getAccountNumber());
- if (CollectionUtils.isNotEmpty(existingAccounts)) {
+ if (CollectionUtils.isNotEmpty(existingAccounts))*/
+
+ Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber());
+ if (existAccount != null) {
throw new LimaBusinessException(_(
- "An account already exists with this number : %s", account.getAccountNumber()));
+ "An account already exists with this number : %s",
+ account.getAccountNumber()));
}
accountDAO.create(account);
@@ -179,8 +195,9 @@
}
//test si le parent ne contient pas de subaccount
- List<Account> existingSubAccounts = masterAccount.getSubAccounts();
- if (CollectionUtils.isNotEmpty(existingSubAccounts)){
+ if (masterAccount.getSubAccounts().size() > 0)
+ /*List<Account> existingSubAccounts = masterAccount.getSubAccounts();
+ if (CollectionUtils.isNotEmpty(existingSubAccounts))*/{
throw new LimaBusinessException(
"Subledger must create on a account whithout subaccount : ");
@@ -479,7 +496,8 @@
try {
transaction = rootContext.beginTransaction();
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
List<Account> accounts = accountDAO.findAll();
accountsList.addAll(accounts);
}
@@ -535,7 +553,8 @@
try {
transaction = rootContext.beginTransaction();
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
TopiaQuery query = accountDAO.createQuery();
@@ -544,7 +563,8 @@
query.add("generalLedger", TopiaQuery.Op.EQ, null);
}
else {
- query.add("masterAccount = :value or generalLedger = :value").addParam("value", masterAccount);
+ query.add("masterAccount = :value or generalLedger = :value")
+ .addParam("value", masterAccount);
}
// TODO Erreur Lazy TopiaQuery
/*if (log.isDebugEnabled()) {
@@ -587,11 +607,12 @@
* ATTENTION : si il existe une entrée comptable associée au numéro de
* compte, il est alors impossible de supprimer le compte.
*
+ * Si un compte contient des sous comptes la fonction retourne -1
* @param account
* @throws LimaException
*/
@Override
- public void removeAccount(Account account) throws LimaException {
+ public int removeAccount(Account account) throws LimaException {
/*String result = ServiceHelper.RESPOND_ERROR;
Account deleteAccount = searchAccount(accountNumber);
// Si le compte n'existe pas
@@ -667,12 +688,12 @@
}
}
return result;*/
-
+ int result = 0;
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- // Vérifie si une entrée ne possède pas ce numéro de compte.
+ //Check if an account has not his number
// FIXME !IMPORTANT! check that subaccounts have no entries too
EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
Entry firstEntry = entryDAO.findByAccount(account);
@@ -681,12 +702,19 @@
throw new LimaBusinessException("Can't delete account with entries");
}
+ //Check if the account is not empty, return -1
+ List<Account> existingSubAccounts = getChildrenAccounts(account);
+ if (CollectionUtils.isNotEmpty(existingSubAccounts)){
+ result =-1;
+ }
+ else {
// remove account
- // FIXME !IMPORTANT! check that subaccounts are also deleted
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
accountDAO.delete(account);
// commit
transaction.commitTransaction();
+ }
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -694,7 +722,38 @@
finally {
doFinally(transaction, log);
}
+ return result;
}
+
+ /**
+ * Delete an account and all his subaccounts
+ * @param account
+ * @throws LimaException
+ */
+ public void removeAccountwithSubAccounts(Account account) throws LimaException{
+ TopiaContext transaction = null;
+ try{
+ transaction = rootContext.beginTransaction();
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> existingSubAccounts = getChildrenAccounts(account);
+ ListIterator itr = existingSubAccounts.listIterator();
+ while(itr.hasNext()){
+ Account subaccount = (Account) itr.next();
+ removeAccountwithSubAccounts(subaccount);
+ }
+ // remove account
+ accountDAO.delete(account);
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+ }
/*
* Permet d'effacer un compte à partir d'un compte DTO. Il appelle la
@@ -767,38 +826,18 @@
transaction = rootContext.beginTransaction();
// update account
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
accountDAO.update(account);
// commit
transaction.commitTransaction();
}
catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
if (log.isErrorEnabled()) {
log.error("Error during create account", ex);
}
throw new LimaException("Can't update account", ex);
}
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't update account", ex);
- }
- }
- }
}
@Override
@@ -809,36 +848,16 @@
transaction = rootContext.beginTransaction();
// get account from his number
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
account = accountDAO.findByAccountNumber(numAccount);
}
catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
if (log.isErrorEnabled()) {
log.error("Error during get account from his number", ex);
}
throw new LimaException("Can't get account from his number", ex);
}
- finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't get account from his number", ex);
- }
- }
- }
return account;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-19 15:15:40 UTC (rev 2866)
@@ -201,7 +201,25 @@
TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
Account account = (Account) treePath.getLastPathComponent();
try {
- accountsTreeTableModel.removeAccount(treePath, account);
+ int result = accountsTreeTableModel.removeAccount(treePath, account);
+ if (result ==-1){
+ int n2 = JOptionPane.showConfirmDialog(view,
+ _("lima.question.confirmremove.account"),
+ _("lima.question"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ if (n2 == JOptionPane.YES_OPTION) {
+ // update view of treetable
+ try {
+ accountsTreeTableModel.removeAccountwithSubAccounts(treePath, account);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't delete account", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't delete account", ex);
+ }
+ }
+ }
} catch (LimaException ex) {
if (log.isErrorEnabled()) {
log.error("Can't delete account", ex);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-19 15:15:40 UTC (rev 2866)
@@ -253,11 +253,21 @@
* @param account
* @throws LimaException
*/
- public void removeAccount(TreePath path, Account account) throws LimaException {
+ public int removeAccount(TreePath path, Account account) throws LimaException {
// Calling account service
int index = getIndexOfChild(
path.getParentPath().getLastPathComponent(), account);
- accountService.removeAccount(account);
+ int result = accountService.removeAccount(account);
+ if (result==0){
+ modelSupport.fireChildRemoved(path.getParentPath(), index, account);
+ }
+ return result;
+ }
+
+ public void removeAccountwithSubAccounts(TreePath path, Account account) throws LimaException {
+ int index = getIndexOfChild(
+ path.getParentPath().getLastPathComponent(), account);
+ accountService.removeAccountwithSubAccounts(account);
modelSupport.fireChildRemoved(path.getParentPath(), index, account);
}
}
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 2010-04-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-19 15:15:40 UTC (rev 2866)
@@ -235,6 +235,7 @@
lima.question=Question
lima.question.load.accounts=There is no existing accounts in Lima. Do you want to load default accounts ?
lima.question.remove.account=Do you want to remove this account ?
+lima.question.confirmremove.account=This account have subaccounts, do you want remove this account ?
lima.question.remove.entry=Do you want to remove this entry ?
lima.question.remove.journal=Do you want to remove this journal ?
lima.question.remove.transaction=Do you want to remove this transaction ?
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 2010-04-19 13:19:30 UTC (rev 2865)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-19 15:15:40 UTC (rev 2866)
@@ -228,6 +228,7 @@
lima.question=Question
lima.question.load.accounts=Il n'y a aucun plan comptable existant dans Lima. Voulez-vous en charger un par d\u00E9faut ?
lima.question.remove.account=Voulez-vous supprimer ce compte?
+lima.question.confirmremove.account=Ce compte poss\u00E8de des sous comptes, voulez-vous supprimer ce compte ?
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
lima.question.remove.journal=Voulez-vous supprimer ce journal?
lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
1
0
Author: jpepin
Date: 2010-04-19 15:19:30 +0200 (Mon, 19 Apr 2010)
New Revision: 2865
Log:
Ajout creation/affichage de comptes tiers
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/SubLedgerTableModel.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -46,9 +46,13 @@
*/
void createAccount(Account masterAccount, Account account) throws LimaException;
+ void createSubLedger(Account masterAccount, Account account) throws LimaException;
+
void updateAccount(Account account) throws LimaException;
void removeAccount(Account account) throws LimaException;
+ Account getAccountNumber(String numAccount) throws LimaException;
+
List<Account> getChildrenAccounts(Account masterAccount) throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -125,7 +125,8 @@
// test si le numero de compte existe deja
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> existingAccounts = accountDAO.findAllByAccountNumber(account.getAccountNumber());
+ List<Account> existingAccounts =
+ accountDAO.findAllByAccountNumber(account.getAccountNumber());
if (CollectionUtils.isNotEmpty(existingAccounts)) {
throw new LimaBusinessException(_(
"An account already exists with this number : %s", account.getAccountNumber()));
@@ -150,6 +151,61 @@
}
}
+
+ @Override
+ public void createSubLedger(Account masterAccount, Account account)
+ throws LimaException {
+ // TODO Auto-generated method stub
+ // test la validite du numero de compte
+ if (StringUtils.isBlank(account.getAccountNumber())) {
+ throw new LimaBusinessException("Invalid AccountNumber : "
+ + account.getAccountNumber());
+ }
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si le numero de compte existe deja
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> existingAccounts =
+ accountDAO.findAllByAccountNumber(account.getAccountNumber());
+ if (CollectionUtils.isNotEmpty(existingAccounts)) {
+ throw new LimaBusinessException(_(
+ "An account already exists with this number : %s",
+ account.getAccountNumber()));
+ }
+
+ //test si le parent ne contient pas de subaccount
+ List<Account> existingSubAccounts = masterAccount.getSubAccounts();
+ if (CollectionUtils.isNotEmpty(existingSubAccounts)){
+ throw new LimaBusinessException(
+ "Subledger must create on a account whithout subaccount : ");
+
+ }
+
+ accountDAO.create(account);
+
+ // test si le compte parent existe;
+ if (masterAccount != null) {
+ masterAccount.addSubLedgers(account);
+ accountDAO.update(masterAccount);
+ }
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ }
+
/*public String createAccount (String accountNumber, String label,Account masterAccount,String type)
{
String result = ServiceHelper.RESPOND_ERROR;
@@ -482,14 +538,19 @@
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
TopiaQuery query = accountDAO.createQuery();
- // masterAccount is not visible, but column "masterAccount"
- // exist in Account table
- query.add("masterAccount", masterAccount);
- if (log.isDebugEnabled()) {
+ if (masterAccount == null){
+ query.add("masterAccount", masterAccount);
+ query.add("generalLedger", TopiaQuery.Op.EQ, null);
+ }
+ else {
+ query.add("masterAccount = :value or generalLedger = :value").addParam("value", masterAccount);
+ }
+ // TODO Erreur Lazy TopiaQuery
+ /*if (log.isDebugEnabled()) {
log.debug("getChildrenAccounts query : " + query);
- }
-
+ }*/
+
accountsList.addAll(accountDAO.findAllByQuery(query));
}
catch (TopiaException ex) {
@@ -740,6 +801,47 @@
}
}
+ @Override
+ public Account getAccountNumber(String numAccount) throws LimaException {
+ Account account = null;
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ // get account from his number
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
+ account = accountDAO.findByAccountNumber(numAccount);
+ }
+ catch (TopiaException ex) {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Error during get account from his number", ex);
+ }
+ throw new LimaException("Can't get account from his number", ex);
+ }
+ finally {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", ex);
+ }
+ throw new LimaException("Can't get account from his number", ex);
+ }
+ }
+ }
+ return account;
+ }
+
/*
* Permet de modifier un compte sur son label et son compte père.
* Il recherche le compte père avec le numéro de compte fourni. Appel ensuite
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-19 13:19:30 UTC (rev 2865)
@@ -1,6 +1,7 @@
# Precise l'entete de l'ensemble des fichiers generes
model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */
-#org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
+org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
+org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false
org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false
#model.tagvalue.dbSchema=Callao
model.tagvalue.String=text
\ No newline at end of file
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -336,6 +336,7 @@
AccountView accountView = new AccountView(mainView);
mainView.showTab(_("lima.tab.account"), accountView);
}
+
public void showTransactionView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-19 13:19:30 UTC (rev 2865)
@@ -27,7 +27,7 @@
</script>
<row>
- <cell fill="both" weightx="1" weighty="1" rows='3'>
+ <cell fill="both" weightx="1" weighty="1" rows='4'>
<JScrollPane>
<org.jdesktop.swingx.JXTreeTable id="accountsTreeTable" selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
treeTableModel="{new org.chorem.lima.ui.account.model.AccountTreeTableModel()}"
@@ -40,6 +40,12 @@
<JButton id="addButton" text="lima.common.add" onActionPerformed="getHandler().addAccount()"/>
</cell>
</row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="addSubLedger" text="lima.common.addSubLedger" onActionPerformed="getHandler().addSubLedger()"
+ enabled="{isSelectedRow()}"/>
+ </cell>
+ </row>
<row>
<cell fill="horizontal">
<JButton id="updateButton" text="lima.common.update" onActionPerformed="getHandler().updateAccount()"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -32,6 +32,7 @@
import org.chorem.lima.ui.account.model.AccountTreeTableModel;
import org.chorem.lima.ui.account.AccountForm;
import org.chorem.lima.ui.account.AccountView;
+import org.chorem.lima.ui.account.SubLedgerForm;
import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTreeTable;
@@ -100,7 +101,44 @@
}
}
};
+
+ public void addSubLedger(){
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+ Account newAccount = new AccountImpl();
+ SubLedgerForm subledgerForm = new SubLedgerForm(view);
+ subledgerForm.setAccount(newAccount);
+ // jaxx constructor don't call super() ?
+ subledgerForm.setLocationRelativeTo(view);
+ subledgerForm.setVisible(true);
+ newAccount=subledgerForm.getAccount();
+
+ // null == cancel action
+ if (newAccount != null) {
+ // get current selection path
+ TreePath treePath = null;
+ int selectedRow = view.getAccountsTreeTable().getSelectedRow();
+ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ // add it
+ try {
+ accountsTreeTableModel.addSubLedger(treePath, newAccount);
+ } catch (LimaBusinessException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add subledger", ex);
+ }
+ ErrorHelper.showErrorDialog(ex.getMessage(), ex);
+ }
+
+ catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add subledger", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add subledger", ex);
+ }
+ }
+ }
+
/**
* Open account form with selected account.
*/
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-19 13:19:30 UTC (rev 2865)
@@ -0,0 +1,74 @@
+<!-- ##% 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 2
+ 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<JDialog defaultCloseOperation="dispose_on_close" modal="true">
+
+ <org.chorem.lima.entity.Account id="account" javaBean='null'/>
+ <Boolean id="addState" javaBean='true'/>
+
+ <script>
+ <![CDATA[
+ protected void performCancel() {
+ setAccount(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.subledger.code"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="numberTextField" editable='{isAddState()}' text="{getAccount().getAccountNumber()}"/>
+ <javax.swing.text.Document javaBean="getNumberTextField().getDocument()"
+ onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())'
+ onRemoveUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.label"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="descriptionTextField" text="{getAccount().getLabel()}"/>
+ <javax.swing.text.Document javaBean="getDescriptionTextField().getDocument()"
+ onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())'
+ onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.type"/>
+ </cell>
+ <cell fill="horizontal">
+ <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.account.model.AccountTypeListModel()}'
+ selectedItem="{getAccount().getType()}"
+ onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="none">
+ <JButton text="lima.common.ok" onActionPerformed="dispose()"/>
+ </cell>
+ <cell fill="none">
+ <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -97,7 +97,8 @@
else {
Account parentAccount = (Account) node;
try {
- List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
result = subaccounts.size();
} catch (LimaException e) {
//FIXME
@@ -113,7 +114,8 @@
Object result = null;
if (parent == getRoot()) {
try {
- List<Account> allAccounts = accountService.getChildrenAccounts(null);
+ List<Account> allAccounts =
+ accountService.getChildrenAccounts(null);
result = allAccounts.get(index);
} catch (LimaException e) {
//FIXME
@@ -125,7 +127,8 @@
// FIXME sub account is a collection ?
try {
- List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
result = subaccounts.get(index);
} catch (LimaException e) {
//FIXME
@@ -143,7 +146,8 @@
if (parent == getRoot()) {
try {
- List<Account> allAccounts = accountService.getChildrenAccounts(null);
+ List<Account> allAccounts =
+ accountService.getChildrenAccounts(null);
result = allAccounts.indexOf(child);
} catch (LimaException e) {
//FIXME
@@ -153,7 +157,8 @@
else {
// FIXME sub account is a collection ?
try {
- List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
result = subaccounts.indexOf(childAccount);
} catch (LimaException e) {
//FIXME
@@ -210,6 +215,24 @@
}
/**
+ * Add account (path can be null).
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void addSubLedger(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ Account parentAccount = (Account)path.getLastPathComponent();
+ if (parentAccount == getRoot()) {
+ parentAccount = null;
+ }
+ accountService.createSubLedger(parentAccount, account);
+ int index = getIndexOfChild(path.getLastPathComponent(), account);
+ modelSupport.fireChildAdded(path, index, account);
+ }
+
+ /**
* Update account.
*
* @param path
@@ -232,7 +255,8 @@
*/
public void removeAccount(TreePath path, Account account) throws LimaException {
// Calling account service
- int index = getIndexOfChild(path.getParentPath().getLastPathComponent(), account);
+ int index = getIndexOfChild(
+ path.getParentPath().getLastPathComponent(), account);
accountService.removeAccount(account);
modelSupport.fireChildRemoved(path.getParentPath(), index, account);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -89,13 +89,13 @@
String res = "n/a";
switch (column) {
case 0:
- res = _("lima.entrybook.label");
+ res = _("lima.entrybook.code");
break;
case 1:
- res = _("lima.entrybook.description");
+ res = _("lima.entrybook.label");
break;
case 2:
- res = _("lima.entrybook.prefix");
+ res = _("lima.entrybook.type");
break;
}
return res;
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/SubLedgerTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/SubLedgerTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/SubLedgerTableModel.java 2010-04-19 13:19:30 UTC (rev 2865)
@@ -0,0 +1,196 @@
+package org.chorem.lima.ui.subledger.model;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * Entry book table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision: 2864 $
+ *
+ * Last update : $Date: 2010-04-16 12:26:55 +0200 (ven. 16 avril 2010) $
+ * By : $Author: jpepin $
+ */
+public class SubLedgerTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 7578692417919755647L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(SubLedgerTableModel.class);
+
+ /** Services. */
+ protected AccountService subledgerService;
+
+ /**
+ * Constructor.
+ */
+ public SubLedgerTableModel() {
+ subledgerService = LimaServiceFactory.getInstance().getAccountService();
+ }
+
+ /*
+ * @return
+ *
+ public List<JournalDTO> getData() {
+ return data;
+ }*/
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ try {
+ result = subledgerService.getAllAccounts().size();
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 3;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = "n/a";
+ switch (column) {
+ case 0:
+ res = _("lima.subledger.accountnumber");
+ break;
+ case 1:
+ res = _("lima.subledger.label");
+ break;
+ case 2:
+ res = _("lima.subledger.type");
+ break;
+ }
+ return res;
+ }
+
+ public Account getSubLedgerAtRow(int row) throws LimaException {
+ Account subledger = null;
+ subledger = subledgerService.getAllAccounts().get(row);
+ return subledger;
+ }
+
+ /*
+ * @param row
+ * @return
+ *
+ @Override
+ public Object getRow(int row) {
+ return data.get(row);
+ }*/
+
+ @Override
+ public Object getValueAt(int row, int column) {
+
+ Object result = null;
+ try {
+ Account subledger = getSubLedgerAtRow(row);
+
+ switch (column) {
+ case 0:
+ result = subledger.getAccountNumber();
+ break;
+ case 1:
+ result = subledger.getLabel();
+ break;
+ case 2:
+ result = subledger.getType();
+ break;
+ }
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+
+
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+
+ try {
+ Account subledger = getSubLedgerAtRow(row);
+
+ switch (column) {
+ case 0:
+ subledger.setAccountNumber((String)value);
+ break;
+ case 1:
+ subledger.setLabel((String)value);
+ break;
+ case 2:
+ subledger.setType((String)value);
+ break;
+ }
+
+ // update on remote service
+ subledgerService.updateAccount(subledger);
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // TODO why false ?
+ return false;
+ }
+
+ /**
+ * @param subledger
+ * @throws LimaException
+ */
+ public void addSubLedger(Account subledger, String numMasterAccount) throws LimaException {
+ /* Calling journal service */
+ Account masterAccount = subledgerService.getAccountNumber(numMasterAccount);
+ subledgerService.createAccount(masterAccount, subledger);
+ int row = subledgerService.getAllAccounts().indexOf(subledger);
+ fireTableRowsInserted(row, row);
+ }
+
+ /**
+ *
+ * @param subledger
+ * @throws LimaException
+ */
+ public void updateSubLedger(Account subledger) throws LimaException {
+ /* Calling journal service */
+ subledgerService.updateAccount(subledger);
+ int row = subledgerService.getAllAccounts().indexOf(subledger);
+ fireTableRowsUpdated(row, row);
+ }
+
+ /**
+ *
+ * @param subledger
+ * @throws LimaException
+ */
+ public void removeSubLedger(Account subledger) throws LimaException {
+ /* Calling journal service */
+ int row = subledgerService.getAllAccounts().indexOf(subledger);
+ subledgerService.removeAccount(subledger);
+ fireTableRowsDeleted(row, row);
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-19 13:19:30 UTC (rev 2865)
@@ -16,7 +16,7 @@
##% -->
<Table>
- <TransactionViewHandler id="handler" javaBean="new TransactionViewHandler(this)" />
+ <FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" />
<Boolean id="selectedRow" javaBean="false" />
<script>
@@ -62,15 +62,15 @@
<row>
<cell fill="both" weightx="1" weighty="1" rows="3" columns="4">
<JScrollPane>
- <org.chorem.lima.ui.transaction.table.TransactionTableModel
- id="transactionTableModel" />
- <org.chorem.lima.ui.transaction.table.TransactionTable
- id="transactionTable" sortable="false" rowHeight="22"
- constructorParams="getHandler()" model="{getTransactionTableModel()}"
+ <org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel
+ id="financialTransactionTableModel" />
+ <org.chorem.lima.ui.transaction.table.FinancialTransactionTable
+ id="financialTransactionTable" sortable="false" rowHeight="22"
+ constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" />
- <javax.swing.ListSelectionModel javaBean="getTransactionTable().getSelectionModel()"
- onValueChanged="setSelectedRow(transactionTable.getSelectedRow() != -1)"/>
+ <javax.swing.ListSelectionModel javaBean="getFinancialTransactionTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
<cell>
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 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-19 13:19:30 UTC (rev 2865)
@@ -7,8 +7,8 @@
Loading\ accounting...=
lima.about.message=
lima.account=Account
-lima.account.label=
-lima.account.number=
+lima.account.label=Label
+lima.account.number=Number
lima.account.type=Account type
lima.accountplan=Plan de comptes
lima.actif=Asset
@@ -47,9 +47,11 @@
lima.chartofaccounts=
lima.chartofaccounts.journal=
lima.chartofaccounts.management=
+lima.chartofaccounts.subledgers=
lima.closure.period.begin=Period from
lima.closure.timespan.warning=Warning\: when the period is blocked, it is possible to add, edit and delete entries on the accounting period.
lima.common.add=
+lima.common.addSubLedger=
lima.common.all=
lima.common.cancel=
lima.common.ok=
@@ -257,6 +259,8 @@
lima.status.tr.balanced=Balanced
lima.status.tr.finalized=Finalized
lima.status.tr.wip=Work in progress
+lima.subledger.accountnumber=
+lima.subledger.code=Code
lima.success=Success
lima.tab.account=Account
lima.tab.balance=Balance
@@ -269,6 +273,7 @@
lima.tab.reports=Reports
lima.tab.result=Result
lima.tab.search.result=Search result
+lima.tab.subledgers=
lima.tab.transaction=Transaction
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=About Lima...
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 2010-04-16 10:26:55 UTC (rev 2864)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-19 13:19:30 UTC (rev 2865)
@@ -10,6 +10,7 @@
lima.account.label=Libell\u00E9
lima.account.menu=Plan de comptes
lima.account.number=Num\u00E9ro du compte
+lima.account.parentnumber=
lima.account.type=Type de compte
lima.actif=Actif
lima.action.commandline.disable.main.ui=Ne pas lancer l'ui
@@ -42,12 +43,14 @@
lima.bilan.total=Total
lima.block=Bloquer
lima.charge=Charge
-lima.chartofaccounts=Plan des comptes
-lima.chartofaccounts.journal=Journal
-lima.chartofaccounts.management=Gestion du plan
+lima.chartofaccounts=Structure
+lima.chartofaccounts.journal=Journaux
+lima.chartofaccounts.management=Plan comptable
+lima.chartofaccounts.subledgers=Plan tiers
lima.closure.period.begin=P\u00E9riode de
lima.closure.timespan.warning=Attention \: lorsque la p\u00E9riode est bloqu\u00E9e, il n'est plus possible d'ajouter, modifier et supprimer les entr\u00E9es comptables sur cette p\u00E9riode.
-lima.common.add=Ajout
+lima.common.add=Ajout Compte G\u00E9n\u00E9ral
+lima.common.addSubLedger=Ajouter Compte Tiers
lima.common.cancel=Annuler
lima.common.ok=OK
lima.common.print=
@@ -248,8 +251,9 @@
lima.status.tr.balanced=Equilibr\u00E9e
lima.status.tr.finalized=Valid\u00E9e
lima.status.tr.wip=En cours
+lima.subledger.code=Code
lima.success=Succ\u00E8s
-lima.tab.account=Compte
+lima.tab.account=Plan Comptable
lima.tab.balance=Balance
lima.tab.bilan=Bilan
lima.tab.home=Accueil
@@ -259,6 +263,7 @@
lima.tab.reports=Rapports
lima.tab.result=Compte de r\u00E9sultat
lima.tab.search.result=Recherche
+lima.tab.subledgers=Plan Tiers
lima.tab.transaction=Ecriture
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=A propos de Lima...
1
0
Author: jpepin
Date: 2010-04-16 12:26:55 +0200 (Fri, 16 Apr 2010)
New Revision: 2864
Log:
Modification du mod?\195?\168le et ajout de classe. Classe Transaction chang?\195?\169 en FinancialTransaction
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/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/transaction/FinancialTransactionHelper.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.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
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java (from rev 2863, trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,71 @@
+/* *##% Lima Business
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.util.List;
+
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialTransaction;
+
+/**
+ * Transaction service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface FinancialTransactionService {
+
+ /**
+ * Find all transaction (use carefully, can return a lot of results).
+ *
+ * @return all transaction
+ * @throws LimaException
+ */
+ List<FinancialTransaction> getAllFinancialTransactions() throws LimaException;
+
+ /**
+ * Find all transaction for an entry book.
+ *
+ * @param entryBook entry book
+ * @return all transaction for entry book
+ * @throws LimaException
+ */
+ List<FinancialTransaction> getAllFinancialTransactionsForEntryBook(EntryBook entryBook) throws LimaException;
+
+ /**
+ * Find all transaction for an entry book and a financial period.
+ *
+ * @param entryBook entry book
+ * @param period financial period
+ * @return all transaction for entry book and period
+ * @throws LimaException
+ */
+ List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException;
+
+ void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+
+ void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+
+ void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,71 +0,0 @@
-/* *##% Lima Business
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*
- */
-
-package org.chorem.lima.business;
-
-import java.util.List;
-
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.Transaction;
-
-/**
- * Transaction service.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public interface TransactionService {
-
- /**
- * Find all transaction (use carefully, can return a lot of results).
- *
- * @return all transaction
- * @throws LimaException
- */
- List<Transaction> getAllTransactions() throws LimaException;
-
- /**
- * Find all transaction for an entry book.
- *
- * @param entryBook entry book
- * @return all transaction for entry book
- * @throws LimaException
- */
- List<Transaction> getAllTransactionsForEntryBook(EntryBook entryBook) throws LimaException;
-
- /**
- * Find all transaction for an entry book and a financial period.
- *
- * @param entryBook entry book
- * @param period financial period
- * @return all transaction for entry book and period
- * @throws LimaException
- */
- List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException;
-
- Transaction createTransaction() throws LimaException;
-
- void updateTransaction(Transaction transaction) throws LimaException;
-
- void removeTransaction(Transaction transaction) throws LimaException;
-}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -35,7 +35,7 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.Transaction;
+import org.chorem.lima.entity.FinancialTransaction;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -54,7 +54,7 @@
private TopiaContext rootContext;
- protected TransactionServiceImpl transactionService = new TransactionServiceImpl();
+ protected FinancialTransactionServiceImpl financialTransactionService = new FinancialTransactionServiceImpl();
//private ConvertEntryBook convertEntryBook = new ConvertEntryBook();
@@ -361,8 +361,8 @@
topiaTransaction = rootContext.beginTransaction();
// Vérifie si une transaction n'appartient pas à ce EntryBook.
- Transaction transaction = transactionService.findByEntryBook(topiaTransaction, entryBook);
- if (transaction != null) {
+ FinancialTransaction financialtransaction = financialTransactionService.findByEntryBook(topiaTransaction, entryBook);
+ if (financialtransaction != null) {
throw new LimaBusinessException("Can't delete EntryBook with transactions");
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -46,7 +46,7 @@
private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
// TODO A revoir car transaction a besoin de entry et vice versa
- private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+ private static FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl();
private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -57,7 +57,7 @@
private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
- private TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+ private FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl();
/**
* Cete méthode permet d'exporter des données de Callao vers un fichier au
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -50,7 +50,7 @@
private TopiaContext rootContext;
- private static TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl();
+ private static FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl();
public FinancialPeriodServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java (from rev 2863, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,676 @@
+/* *##% Lima Business
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.FinancialTransactionService;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionDAO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.framework.TopiaQuery;
+
+/**
+ * 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.
+ * Une transaction est composée d'entrées comptables.
+ * Les actions sur les transactions sont soumises au statut de celle-ci, si elle
+ * est dans une période bloquée ou non.
+ *
+ * @author Rémi Chapelet
+ */
+@Stateless
+public class FinancialTransactionServiceImpl extends AbstractLimaService implements FinancialTransactionService {
+
+ private static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ //private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
+
+ //private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
+
+ //private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
+
+ public FinancialTransactionServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ /**
+ * Permet de créer une transaction comptable. Pour ajouter une transaction,
+ * le timeSpan doit être non bloqué.
+ * @param entryDate
+ * @param voucherRef
+ * @param description
+ * @param timespan
+ * @param journal
+ * @return
+ * @throws LimaException
+ */
+ @Override
+ public void createFinancialTransaction(FinancialTransaction financialtransaction/*Date entryDate, String voucherRef,
+ String description, TimeSpan timeSpan, Journal journal*/) throws LimaException {
+
+
+ TopiaContext topiaContext = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ topiaContext = rootContext.beginTransaction();
+
+ FinancialTransactionDAO financialtransactionDAO = LimaCallaoDAOHelper
+ .getFinancialTransactionDAO(topiaContext);
+
+ financialtransactionDAO.create(financialtransaction);
+
+ // commit
+ topiaContext.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+
+ /*String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ String isCorrectTransaction = isCorrectTransaction(timeSpan,
+ journal);
+ if (isCorrectTransaction.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Creation de la transaction
+ Transaction newtransaction = transactionDAO.create();
+ newtransaction.setTransDate(entryDate);
+ newtransaction.setVoucherRef(voucherRef);
+ newtransaction.setDescription(description);
+ newtransaction.setTimeSpan(timeSpan);
+ newtransaction.setJournal(journal);
+ // Création BDD
+ topiaContext.commitTransaction();
+ if (log.isInfoEnabled()) {
+ log.info("Ajout avec succes de la transaction");
+ }
+
+ // Il renvoie soit l'identifiant topiaId ou SUCCESS.
+ result = newtransaction.getTopiaId();
+ //result = ServiceHelper.RESPOND_SUCCESS;
+ } else {
+ result = isCorrectTransaction;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;*/
+ }
+
+ /*
+ * Permet de créer une transaction à partir d'une transaction DTO.
+ * ATTENTION : si le journal ou timespan n'existe pas, l'ajout ne peut se
+ * faire. Si on souhaite, on peut créer le journal automatiquement lors de
+ * l'ajout de la transaction si il n'existe pas. Pour le timeSpan, il n'est
+ * pas cohérent qu'il n'existe pas. On ne peut travailler que sur une période
+ * comptable existante, et par conséquent il ne faut pas le créer.
+ * @param transactionDTO
+ * @return
+ *
+ public String createTransaction(TransactionDTO transactionDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Vérifie que transactionDTO possède un journalDTO et un timeSpanDTO
+ if (transactionDTO.getJournalDTO() == null
+ || transactionDTO.getTimeSpanDTO() == null) {
+ if (log.isErrorEnabled()) {
+ log.error("L'objet transactionDTO ne possède pas de timeSpan ET/OU de journal.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ } else {
+ // Recherche du journal
+ JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
+ Journal journal = journalServiceImpl
+ .searchJournalWithLabel(transactionDTO.getJournalDTO()
+ .getLabel());
+ // Recherche du timeSpan
+ TimeSpan timeSpan = timeSpanServiceImpl
+ .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
+ .getBeginTimeSpan());
+
+ // Vérification si timeSpan et Journal existe bien
+ if (journal == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le journal "
+ + transactionDTO.getJournalDTO().getLabel()
+ + " n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ } else {
+ if (timeSpan == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le timeSpan "
+ + transactionDTO.getTimeSpanDTO().toString()
+ + " n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
+ } else {
+ result = createTransaction(transactionDTO.getEntryDate(),
+ transactionDTO.getVoucherRef(), transactionDTO
+ .getDescription(), timeSpan, journal);
+ }
+ }
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une transaction. Cette dernière est identifiée par la
+ * clé topiaId.
+ * @param topiaId
+ * @param entryDate
+ * @param voucherRef
+ * @param description
+ * @param timespan
+ * @param journal
+ * @return
+ *
+ public String modifyTransaction(String topiaId, Date entryDate,
+ String voucherRef, String description, TimeSpan timeSpan,
+ Journal journal) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Vérification que la transaction existe bien
+ Transaction transaction = transactionDAO.findByTopiaId(topiaId);
+ if (transaction == null) {
+ if (log.isInfoEnabled()) {
+ log.info("La transaction " + voucherRef
+ + " n'existe pas. (identifiant " + topiaId + ")");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_EXIST;
+ } else {
+ // Vérification si la transaction possède de bons paramètres
+ String correct = isCorrectTransaction(timeSpan, journal);
+ // Si la transaction est correcte
+ if (correct.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Modification
+ transaction.setTransDate(entryDate);
+ transaction.setVoucherRef(voucherRef);
+ transaction.setDescription(description);
+ transaction.setTimeSpan(timeSpan);
+ transaction.setJournal(journal);
+ transaction.update();
+ // Création BDD
+ topiaContext.commitTransaction();
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /**
+ * Permet de retrouver la premiere transaction associée au journal.
+ *
+ * Utilisé par entrybook service pour savoir si un journal a des transactions
+ * associées et empecher la suppression.
+ *
+ * @param topiaTransaction context à utiliser
+ * @param entryBook journal
+ * @throws TopiaException
+ */
+ protected FinancialTransaction findByEntryBook(TopiaContext topiaTransaction, EntryBook entryBook) throws TopiaException {
+
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+
+ TopiaQuery query = transactionDAO.createQuery();
+ // entryBook is not visible, but column "entryBook"
+ // exist in transaction table
+ query.add("entryBook", entryBook);
+
+ FinancialTransaction result = transactionDAO.findByQuery(query);
+
+ return result;
+ }
+
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactions() throws LimaException {
+
+ // find all with null entry book filter
+
+ return getAllFinancialTransactionsForEntryBook(null);
+ }
+
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactionsForEntryBook(EntryBook entryBook) throws LimaException {
+
+ // find all with null period filter
+
+ return getAllFinancialTransactionsForEntryBookAndFinancialPeriod(entryBook, null);
+ }
+
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException {
+
+ List<FinancialTransaction> transactions = null;
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+
+ // filter with topia query
+ TopiaQuery query = transactionDAO.createQuery();
+
+ if (entryBook != null) {
+ query.add("entryBook", entryBook);
+ }
+
+ if (financialPeriod != null) {
+ query.add("financialPeriod", financialPeriod);
+ }
+
+ transactions = transactionDAO.findAllByQuery(query);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ return transactions;
+ }
+
+ /*
+ * Recherche toutes les transactions appartenant à un même journal donné
+ * en paramètre.
+ * @param journal
+ * @return
+ *
+ public List<Transaction> searchListTransactionWithJournal(Journal journal) {
+ List<Transaction> listTransaction = null;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ listTransaction = transactionDAO.findAllByJournal(journal);
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTransaction;
+ }*/
+
+ /*
+ * Permet de rechercher toutes les transactions dans la base de données,
+ * avec en retour une liste de transactions au format DTO.
+ * @return
+ *
+ public List<TransactionDTO> getAllTransactionDTO() {
+ List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ List<Transaction> listTransaction = transactionDAO.findAll();
+ // Converti la transaction en DTO
+ convertTransaction.setTransaction(rootContext);
+ for (Transaction transaction : listTransaction) {
+ TransactionDTO transactionDTO = convertTransaction
+ .transactionEntityToDto(transaction);
+ listTransactionDTO.add(transactionDTO);
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return listTransactionDTO;
+ }*/
+
+ /*
+ * Cette méthode permet de vérifier si une transaction possède des paramètres
+ * corrects.
+ * Un journal doit exister.
+ * Un timeSpan doit exister et être non bloqué.
+ * @param timeSpan
+ * @param journal
+ * @return
+ *
+ public String isCorrectTransaction(TimeSpan timeSpan, Journal journal) {
+ String result = ServiceHelper.RESPOND_SUCCESS;
+ // Vérification si timeSpan et Journal existe bien
+ if (journal == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le journal n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
+ }
+ if (timeSpan == null) {
+ if (log.isErrorEnabled()) {
+ log.error("Création transaction : Le timeSpan n'existe pas.");
+ }
+ result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
+ } else {
+ // Vérifie si le timeSpan est bloqué
+ if (timeSpan.getLocked()) {
+ if (log.isErrorEnabled()) {
+ log.error("Le timeSpan est bloqué ! Il est donc impossible"
+ + " d'ajouter une transaction sur cette période. ("
+ + "Période du " + timeSpan + ")");
+ }
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ }
+ return result;
+ }*/
+
+ @Override
+ public void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
+
+ // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
+
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ transactionDAO.update(financialtransaction);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ }
+
+ @Override
+ public void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
+
+ // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
+
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ transactionDAO.delete(financialtransaction);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ }
+
+ /*
+ * Permet d'ajouter une entrée comptable pour une transaction donnée.
+ * ATTENTION : la transaction doit être NON bloquée.
+ *
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @return
+ *
+ public String addEntry(String description, String amount, boolean debit,
+ String lettering, String detail, Transaction transaction,
+ Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Si la transaction est non bloquée
+ if (!isTransactionBlocked(transaction)) {
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+ result = entryServiceImpl.createEntry(description, amount, debit,
+ lettering, detail, transaction, account);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'ajouter une entrée comptable pour une transaction donnée.
+ * L'entrée est sous format DTO.
+ *
+ * @param entryDTO
+ * @return
+ *
+ public String addEntry(EntryDTO entryDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
+ // Si la transaction est non bloquée
+ if (!isTransactionBlocked(transaction)) {
+
+ // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
+ result = entryServiceImpl.createEntry(entryDTO);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée comptable.
+ * ATTENTION : la transaction doit être NON bloquée.
+ *
+ * @param topiaId
+ * @param description
+ * @param amount
+ * @param debit
+ * @param lettering
+ * @param detail
+ * @param transaction
+ * @param account
+ * @return
+ *
+ public String modifyEntry(String topiaId, String description,
+ String amount, boolean debit, String lettering, String detail,
+ Transaction transaction, Account account) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ if (!isTransactionBlocked(transaction)) {
+ result = entryServiceImpl.modifyEntry(topiaId, description, amount,
+ debit, lettering, detail, account);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de modifier une entrée.
+ * @param entryDTO
+ * @return
+ *
+ public String modifyEntry(EntryDTO entryDTO) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ // Recherche TransactionDTO
+ TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
+ Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
+ if (!isTransactionBlocked(transaction)) {
+ result = entryServiceImpl.modifyEntry(entryDTO);
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet d'effacer une entrée comptable. Elle est identifiée par son identifiant
+ * topiaID. Une entrée peut être supprimée seulement si elle est non bloquée.
+ * @param topiaId
+ * @return
+ *
+ public String removeEntry(String topiaId) {
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ // Recherche de l'entry
+ Entry entryDelete = entryDAO.findByTopiaId(topiaId);
+ // Entry doit exister
+ if (entryDelete != null) {
+ // Prend la transaction dont appartient entry
+ Transaction transaction = entryDelete.getTransaction();
+ // Vérifie si la transaction est non bloquée.
+ if (!isTransactionBlocked(transaction)) {
+ // Création d'un log DTO
+ LogDTO logDTO = new LogDTO("", new Date(),
+ ServiceHelper.LOG_REMOVE, transaction
+ .getTransDate(), transaction
+ .getVoucherRef(), transaction
+ .getDescription(), entryDelete
+ .getDescription(), entryDelete.getAmount(),
+ entryDelete.getDebit(), entryDelete.getLettering());
+ // Appel pour supprimer l'entrée
+ result = entryServiceImpl.removeEntry(topiaId);
+ // Si la suppression s'est bien déroulée, création log
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ // Ajout du log
+ logServiceImpl.addLog(logDTO);
+ }
+ } else {
+ result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
+ }
+ } else {
+ result = ServiceHelper.ENTRY_NOT_EXIST;
+ }
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return result;
+ }*/
+
+ /*
+ * Permet de supprimer une entrée à partir d'un DTO.
+ * @param entryDTO
+ * @return
+ *
+ public String removeEntry(EntryDTO entryDTO) {
+ String result = removeEntry(entryDTO.getId());
+ return result;
+ }*/
+
+ /*
+ * Permet de vérifier si une transaction est dans une période bloquée ou non
+ * @param transaction
+ * @return
+ *
+ public boolean isTransactionBlocked(Transaction transaction) {
+ boolean isTransactionBlocked = true;
+ try {
+ // Acces BDD
+ TopiaContext topiaContext = rootContext.beginTransaction();
+ // Chargement du DAO
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+ // Recherche
+ Transaction transactionSearch = transactionDAO
+ .findByTopiaId(transaction.getTopiaId());
+ isTransactionBlocked = timeSpanServiceImpl
+ .isTimeSpanBlocked(transactionSearch.getTimeSpan());
+ // Fermeture BDD
+ topiaContext.closeContext();
+ } catch (TopiaException e) {
+ log.error(e);
+ }
+ return isTransactionBlocked;
+ }*/
+
+ /*
+ * Permet de vérifier si une transaction est équilibrée.
+ * @param transaction
+ * @return
+ *
+ public boolean isTransactionBalanced(Transaction transaction) {
+ List<EntryDTO> ListEntryDTO = entryServiceImpl
+ .searchEntryDTOWithTransaction(transaction);
+ float debit = 0;
+ float credit = 0;
+ // Pour toutes les entrées comptables trouvées
+ for (EntryDTO entryDTO : ListEntryDTO) {
+ // Si entrée au debit
+ if (entryDTO.isDebit()) {
+ debit = debit
+ + Float.parseFloat(entryDTO.getAmount().replaceFirst(
+ ",", "."));
+ } else {
+ credit = credit
+ + Float.parseFloat(entryDTO.getAmount().replaceFirst(
+ ",", "."));
+ }
+ }
+ // Vérifie si le debit == credit
+ boolean isTransactionBalanced = debit == credit;
+ return isTransactionBalanced;
+ }*/
+}
\ No newline at end of file
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,676 +0,0 @@
-/* *##% Lima Business
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*
- */
-
-package org.chorem.lima.business.ejb;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
-import javax.ejb.Stateless;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.TransactionService;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.AccountDAO;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.entity.TransactionDAO;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.framework.TopiaQuery;
-
-/**
- * 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.
- * Une transaction est composée d'entrées comptables.
- * Les actions sur les transactions sont soumises au statut de celle-ci, si elle
- * est dans une période bloquée ou non.
- *
- * @author Rémi Chapelet
- */
-@Stateless
-public class TransactionServiceImpl extends AbstractLimaService implements TransactionService {
-
- private static final Log log = LogFactory.getLog(TransactionServiceImpl.class);
-
- private TopiaContext rootContext;
-
- //private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
-
- //private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
-
- //private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
-
- public TransactionServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- /**
- * Permet de créer une transaction comptable. Pour ajouter une transaction,
- * le timeSpan doit être non bloqué.
- * @param entryDate
- * @param voucherRef
- * @param description
- * @param timespan
- * @param journal
- * @return
- * @throws LimaException
- */
- @Override
- public void createTransaction(Transaction transaction/*Date entryDate, String voucherRef,
- String description, TimeSpan timeSpan, Journal journal*/) throws LimaException {
-
-
- TopiaContext topiaContext = null;
- try {
- // basic check done, make check in database
- // TODO move it into JTA
- topiaContext = rootContext.beginTransaction();
-
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
-
- transactionDAO.create(transaction);
-
- // commit
- topiaContext.commitTransaction();
- }
- catch (TopiaException ex) {
- doCatch(topiaContext, ex, log);
- }
- finally {
- doFinally(topiaContext, log);
- }
-
- /*String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- String isCorrectTransaction = isCorrectTransaction(timeSpan,
- journal);
- if (isCorrectTransaction.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Creation de la transaction
- Transaction newtransaction = transactionDAO.create();
- newtransaction.setTransDate(entryDate);
- newtransaction.setVoucherRef(voucherRef);
- newtransaction.setDescription(description);
- newtransaction.setTimeSpan(timeSpan);
- newtransaction.setJournal(journal);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Ajout avec succes de la transaction");
- }
-
- // Il renvoie soit l'identifiant topiaId ou SUCCESS.
- result = newtransaction.getTopiaId();
- //result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- result = isCorrectTransaction;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;*/
- }
-
- /*
- * Permet de créer une transaction à partir d'une transaction DTO.
- * ATTENTION : si le journal ou timespan n'existe pas, l'ajout ne peut se
- * faire. Si on souhaite, on peut créer le journal automatiquement lors de
- * l'ajout de la transaction si il n'existe pas. Pour le timeSpan, il n'est
- * pas cohérent qu'il n'existe pas. On ne peut travailler que sur une période
- * comptable existante, et par conséquent il ne faut pas le créer.
- * @param transactionDTO
- * @return
- *
- public String createTransaction(TransactionDTO transactionDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Vérifie que transactionDTO possède un journalDTO et un timeSpanDTO
- if (transactionDTO.getJournalDTO() == null
- || transactionDTO.getTimeSpanDTO() == null) {
- if (log.isErrorEnabled()) {
- log.error("L'objet transactionDTO ne possède pas de timeSpan ET/OU de journal.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- } else {
- // Recherche du journal
- JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
- Journal journal = journalServiceImpl
- .searchJournalWithLabel(transactionDTO.getJournalDTO()
- .getLabel());
- // Recherche du timeSpan
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
- .getBeginTimeSpan());
-
- // Vérification si timeSpan et Journal existe bien
- if (journal == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le journal "
- + transactionDTO.getJournalDTO().getLabel()
- + " n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- } else {
- if (timeSpan == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le timeSpan "
- + transactionDTO.getTimeSpanDTO().toString()
- + " n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
- } else {
- result = createTransaction(transactionDTO.getEntryDate(),
- transactionDTO.getVoucherRef(), transactionDTO
- .getDescription(), timeSpan, journal);
- }
- }
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une transaction. Cette dernière est identifiée par la
- * clé topiaId.
- * @param topiaId
- * @param entryDate
- * @param voucherRef
- * @param description
- * @param timespan
- * @param journal
- * @return
- *
- public String modifyTransaction(String topiaId, Date entryDate,
- String voucherRef, String description, TimeSpan timeSpan,
- Journal journal) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Vérification que la transaction existe bien
- Transaction transaction = transactionDAO.findByTopiaId(topiaId);
- if (transaction == null) {
- if (log.isInfoEnabled()) {
- log.info("La transaction " + voucherRef
- + " n'existe pas. (identifiant " + topiaId + ")");
- }
- result = ServiceHelper.TRANSACTION_NOT_EXIST;
- } else {
- // Vérification si la transaction possède de bons paramètres
- String correct = isCorrectTransaction(timeSpan, journal);
- // Si la transaction est correcte
- if (correct.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Modification
- transaction.setTransDate(entryDate);
- transaction.setVoucherRef(voucherRef);
- transaction.setDescription(description);
- transaction.setTimeSpan(timeSpan);
- transaction.setJournal(journal);
- transaction.update();
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /**
- * Permet de retrouver la premiere transaction associée au journal.
- *
- * Utilisé par entrybook service pour savoir si un journal a des transactions
- * associées et empecher la suppression.
- *
- * @param topiaTransaction context à utiliser
- * @param entryBook journal
- * @throws TopiaException
- */
- protected Transaction findByEntryBook(TopiaContext topiaTransaction, EntryBook entryBook) throws TopiaException {
-
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
-
- TopiaQuery query = transactionDAO.createQuery();
- // entryBook is not visible, but column "entryBook"
- // exist in transaction table
- query.add("entryBook", entryBook);
-
- Transaction result = transactionDAO.findByQuery(query);
-
- return result;
- }
-
- @Override
- public List<Transaction> getAllTransactions() throws LimaException {
-
- // find all with null entry book filter
-
- return getAllTransactionsForEntryBook(null);
- }
-
- @Override
- public List<Transaction> getAllTransactionsForEntryBook(EntryBook entryBook) throws LimaException {
-
- // find all with null period filter
-
- return getAllTransactionsForEntryBookAndFinancialPeriod(entryBook, null);
- }
-
- @Override
- public List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException {
-
- List<Transaction> transactions = null;
- TopiaContext topiaTransaction = null;
- try {
- topiaTransaction = rootContext.beginTransaction();
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
-
- // filter with topia query
- TopiaQuery query = transactionDAO.createQuery();
-
- if (entryBook != null) {
- query.add("entryBook", entryBook);
- }
-
- if (financialPeriod != null) {
- query.add("financialPeriod", financialPeriod);
- }
-
- transactions = transactionDAO.findAllByQuery(query);
- }
- catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
- }
- finally {
- doFinally(topiaTransaction, log);
- }
-
- return transactions;
- }
-
- /*
- * Recherche toutes les transactions appartenant à un même journal donné
- * en paramètre.
- * @param journal
- * @return
- *
- public List<Transaction> searchListTransactionWithJournal(Journal journal) {
- List<Transaction> listTransaction = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- listTransaction = transactionDAO.findAllByJournal(journal);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listTransaction;
- }*/
-
- /*
- * Permet de rechercher toutes les transactions dans la base de données,
- * avec en retour une liste de transactions au format DTO.
- * @return
- *
- public List<TransactionDTO> getAllTransactionDTO() {
- List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- List<Transaction> listTransaction = transactionDAO.findAll();
- // Converti la transaction en DTO
- convertTransaction.setTransaction(rootContext);
- for (Transaction transaction : listTransaction) {
- TransactionDTO transactionDTO = convertTransaction
- .transactionEntityToDto(transaction);
- listTransactionDTO.add(transactionDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listTransactionDTO;
- }*/
-
- /*
- * Cette méthode permet de vérifier si une transaction possède des paramètres
- * corrects.
- * Un journal doit exister.
- * Un timeSpan doit exister et être non bloqué.
- * @param timeSpan
- * @param journal
- * @return
- *
- public String isCorrectTransaction(TimeSpan timeSpan, Journal journal) {
- String result = ServiceHelper.RESPOND_SUCCESS;
- // Vérification si timeSpan et Journal existe bien
- if (journal == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le journal n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_JOURNAL;
- }
- if (timeSpan == null) {
- if (log.isErrorEnabled()) {
- log.error("Création transaction : Le timeSpan n'existe pas.");
- }
- result = ServiceHelper.TRANSACTION_NOT_TIMESPAN;
- } else {
- // Vérifie si le timeSpan est bloqué
- if (timeSpan.getLocked()) {
- if (log.isErrorEnabled()) {
- log.error("Le timeSpan est bloqué ! Il est donc impossible"
- + " d'ajouter une transaction sur cette période. ("
- + "Période du " + timeSpan + ")");
- }
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- }
- return result;
- }*/
-
- @Override
- public void updateTransaction(Transaction transaction) throws LimaException {
-
- // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
-
- TopiaContext topiaTransaction = null;
- try {
- topiaTransaction = rootContext.beginTransaction();
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
- transactionDAO.update(transaction);
- }
- catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
- }
- finally {
- doFinally(topiaTransaction, log);
- }
-
- }
-
- @Override
- public void removeTransaction(Transaction transaction) throws LimaException {
-
- // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
-
- TopiaContext topiaTransaction = null;
- try {
- topiaTransaction = rootContext.beginTransaction();
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
- transactionDAO.delete(transaction);
- }
- catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
- }
- finally {
- doFinally(topiaTransaction, log);
- }
-
- }
-
- /*
- * Permet d'ajouter une entrée comptable pour une transaction donnée.
- * ATTENTION : la transaction doit être NON bloquée.
- *
- * @param description
- * @param amount
- * @param debit
- * @param lettering
- * @param detail
- * @param transaction
- * @return
- *
- public String addEntry(String description, String amount, boolean debit,
- String lettering, String detail, Transaction transaction,
- Account account) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si la transaction est non bloquée
- if (!isTransactionBlocked(transaction)) {
- // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
- result = entryServiceImpl.createEntry(description, amount, debit,
- lettering, detail, transaction, account);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet d'ajouter une entrée comptable pour une transaction donnée.
- * L'entrée est sous format DTO.
- *
- * @param entryDTO
- * @return
- *
- public String addEntry(EntryDTO entryDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Recherche TransactionDTO
- TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
- Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
- // Si la transaction est non bloquée
- if (!isTransactionBlocked(transaction)) {
-
- // Si il renvoie succes et non l'identifiant (à commenter dans la classe correspondante)
- result = entryServiceImpl.createEntry(entryDTO);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une entrée comptable.
- * ATTENTION : la transaction doit être NON bloquée.
- *
- * @param topiaId
- * @param description
- * @param amount
- * @param debit
- * @param lettering
- * @param detail
- * @param transaction
- * @param account
- * @return
- *
- public String modifyEntry(String topiaId, String description,
- String amount, boolean debit, String lettering, String detail,
- Transaction transaction, Account account) {
- String result = ServiceHelper.RESPOND_ERROR;
- if (!isTransactionBlocked(transaction)) {
- result = entryServiceImpl.modifyEntry(topiaId, description, amount,
- debit, lettering, detail, account);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet de modifier une entrée.
- * @param entryDTO
- * @return
- *
- public String modifyEntry(EntryDTO entryDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Recherche TransactionDTO
- TransactionDTO transactonDTO = entryDTO.getTransactionDTO();
- Transaction transaction = searchTransactionWithTopiaId(transactonDTO);
- if (!isTransactionBlocked(transaction)) {
- result = entryServiceImpl.modifyEntry(entryDTO);
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- return result;
- }*/
-
- /*
- * Permet d'effacer une entrée comptable. Elle est identifiée par son identifiant
- * topiaID. Une entrée peut être supprimée seulement si elle est non bloquée.
- * @param topiaId
- * @return
- *
- public String removeEntry(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- // Recherche de l'entry
- Entry entryDelete = entryDAO.findByTopiaId(topiaId);
- // Entry doit exister
- if (entryDelete != null) {
- // Prend la transaction dont appartient entry
- Transaction transaction = entryDelete.getTransaction();
- // Vérifie si la transaction est non bloquée.
- if (!isTransactionBlocked(transaction)) {
- // Création d'un log DTO
- LogDTO logDTO = new LogDTO("", new Date(),
- ServiceHelper.LOG_REMOVE, transaction
- .getTransDate(), transaction
- .getVoucherRef(), transaction
- .getDescription(), entryDelete
- .getDescription(), entryDelete.getAmount(),
- entryDelete.getDebit(), entryDelete.getLettering());
- // Appel pour supprimer l'entrée
- result = entryServiceImpl.removeEntry(topiaId);
- // Si la suppression s'est bien déroulée, création log
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- // Ajout du log
- logServiceImpl.addLog(logDTO);
- }
- } else {
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- } else {
- result = ServiceHelper.ENTRY_NOT_EXIST;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de supprimer une entrée à partir d'un DTO.
- * @param entryDTO
- * @return
- *
- public String removeEntry(EntryDTO entryDTO) {
- String result = removeEntry(entryDTO.getId());
- return result;
- }*/
-
- /*
- * Permet de vérifier si une transaction est dans une période bloquée ou non
- * @param transaction
- * @return
- *
- public boolean isTransactionBlocked(Transaction transaction) {
- boolean isTransactionBlocked = true;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- Transaction transactionSearch = transactionDAO
- .findByTopiaId(transaction.getTopiaId());
- isTransactionBlocked = timeSpanServiceImpl
- .isTimeSpanBlocked(transactionSearch.getTimeSpan());
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return isTransactionBlocked;
- }*/
-
- /*
- * Permet de vérifier si une transaction est équilibrée.
- * @param transaction
- * @return
- *
- public boolean isTransactionBalanced(Transaction transaction) {
- List<EntryDTO> ListEntryDTO = entryServiceImpl
- .searchEntryDTOWithTransaction(transaction);
- float debit = 0;
- float credit = 0;
- // Pour toutes les entrées comptables trouvées
- for (EntryDTO entryDTO : ListEntryDTO) {
- // Si entrée au debit
- if (entryDTO.isDebit()) {
- debit = debit
- + Float.parseFloat(entryDTO.getAmount().replaceFirst(
- ",", "."));
- } else {
- credit = credit
- + Float.parseFloat(entryDTO.getAmount().replaceFirst(
- ",", "."));
- }
- }
- // Vérifie si le debit == credit
- boolean isTransactionBalanced = debit == credit;
- return isTransactionBalanced;
- }*/
-}
\ No newline at end of file
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.User;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaNotFoundException;
@@ -61,8 +60,9 @@
* @param name new user name
* @throws LimaException
*/
- public void addUser(User user/*String name*/) throws LimaException {
- /*// Attention doublon utilisateur
+ /*
+ public void addUser(User user/*String name) throws LimaException {
+ // Attention doublon utilisateur
try {
// Acces BDD
TopiaContext topiaContext = rootContext.beginTransaction();
@@ -83,8 +83,8 @@
throw new LimaException("Can't create user", ex);
}
- }*/
- }
+ }
+ }*/
/**
* Find user with name.
@@ -92,7 +92,7 @@
* @param name
* @throws LimaException
*/
- public void findUser(String name) throws LimaException {
+ /*public void findUser(String name) throws LimaException {
/*try {
// Acces BDD
TopiaContext topiaContext = rootContext.beginTransaction();
@@ -110,6 +110,6 @@
log.error("Can't find user", ex);
throw new LimaException("Can't find user", ex);
}
- }*/
- }
+ }
+ }*/
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -5,7 +5,7 @@
import org.chorem.lima.business.ejb.EntryBookServiceImpl;
import org.chorem.lima.business.ejb.FiscalPeriodServiceImpl;
import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
-import org.chorem.lima.business.ejb.TransactionServiceImpl;
+import org.chorem.lima.business.ejb.FinancialTransactionServiceImpl;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -19,7 +19,7 @@
/** log. */
private static final org.apache.commons.logging.Log log = LogFactory.getLog(TransactionServiceImplTest.class);
- private static TransactionServiceImpl instanceTransaction;
+ private static FinancialTransactionServiceImpl instanceTransaction;
private static FiscalPeriodServiceImpl instancePeriod;
private static FinancialPeriodServiceImpl instanceTimespan;
private static EntryBookServiceImpl instanceJournal;
@@ -34,7 +34,7 @@
@Before
public void setUp() {
- instanceTransaction = new TransactionServiceImpl();
+ instanceTransaction = new FinancialTransactionServiceImpl();
instancePeriod = new FiscalPeriodServiceImpl();
instanceTimespan = new FinancialPeriodServiceImpl();
instanceJournal = new EntryBookServiceImpl();
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,6 +1,6 @@
# Precise l'entete de l'ensemble des fichiers generes
model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */
#org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
-org.chorem.lima.entity.Transaction.attribute.entry.tagvalue.lazy=false
+org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false
#model.tagvalue.dbSchema=Callao
model.tagvalue.String=text
\ No newline at end of file
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -36,7 +36,7 @@
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.RecordService;
-import org.chorem.lima.business.TransactionService;
+import org.chorem.lima.business.FinancialTransactionService;
/**
* Is class is a service factory based on embedded openejb container.
@@ -195,14 +195,14 @@
*
* @return transaction service proxy
*/
- public TransactionService getTransactionService() {
+ public FinancialTransactionService getTransactionService() {
// TODO EC-20100410 put lookup name in configuration
// name should be fully configurable due to custom implementation used
String lookupName = "TransactionServiceImplLocal";
- TransactionService ejbHome = null;
+ FinancialTransactionService ejbHome = null;
try {
- ejbHome = (TransactionService)ctx.lookup(lookupName);
+ ejbHome = (FinancialTransactionService)ctx.lookup(lookupName);
} catch (NamingException eee) {
if (log.isErrorEnabled()) {
log.error("Can't lookup for service : " + lookupName, eee);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionDataTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -52,7 +52,7 @@
/**
* Services
*/
- private final transient TransactionService transServ;
+ private final transient FinancialTransactionService transServ;
private final List<TransactionDTO> data;
private boolean editable = true;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFilteredTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -57,7 +57,7 @@
/**
* Services
*/
- protected final transient TransactionService transactionServ;
+ protected final transient FinancialTransactionService transactionServ;
private boolean filtered = false;
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionFlattenTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -60,7 +60,7 @@
* Services
*/
protected final EntryService entryServ;
- protected final TransactionService transactionServ;
+ protected final FinancialTransactionService transactionServ;
/**
* @return
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/table/model/TransactionSortedTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -65,7 +65,7 @@
* Services
*/
protected final EntryService entryServ;
- protected final TransactionService transactionServ;
+ protected final FinancialTransactionService transactionServ;
/**
* @param model
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-04-16 10:26:55 UTC (rev 2864)
@@ -32,6 +32,17 @@
<Table>
<row>
<cell>
+ <JLabel text="lima.entrybook.code"/>
+ </cell>
+ <cell>
+ <JTextField id="entryBookCodeField" text="{getEntryBook().getCode()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookCodeField().getDocument()"
+ onInsertUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())'
+ onRemoveUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell>
<JLabel text="lima.entrybook.label"/>
</cell>
<cell>
@@ -43,28 +54,17 @@
</row>
<row>
<cell>
- <JLabel text="lima.entrybook.description"/>
+ <JLabel text="lima.entrybook.type"/>
</cell>
<cell>
- <JTextField id="entryBookDescriptionField" text="{getEntryBook().getDescription()}"/>
- <javax.swing.text.Document javaBean="getEntryBookDescriptionField().getDocument()"
- onInsertUpdate='getEntryBook().setDescription(getEntryBookDescriptionField().getText())'
- onRemoveUpdate='getEntryBook().setDescription(getEntryBookDescriptionField().getText())' />
+ <JTextField id="entryBookTypeField" text="{getEntryBook().getType()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookTypeField().getDocument()"
+ onInsertUpdate='getEntryBook().setType(getEntryBookTypeField().getText())'
+ onRemoveUpdate='getEntryBook().setType(getEntryBookTypeField().getText())' />
</cell>
</row>
<row>
<cell>
- <JLabel text="lima.entrybook.prefix"/>
- </cell>
- <cell>
- <JTextField id="entryBookPrefixField" text="{getEntryBook().getPrefix()}"/>
- <javax.swing.text.Document javaBean="getEntryBookPrefixField().getDocument()"
- onInsertUpdate='getEntryBook().setPrefix(getEntryBookPrefixField().getText())'
- onRemoveUpdate='getEntryBook().setPrefix(getEntryBookPrefixField().getText())' />
- </cell>
- </row>
- <row>
- <cell>
<JButton id="okButton" text="lima.common.ok" onActionPerformed="dispose()"/>
</cell>
<cell>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -126,13 +126,13 @@
switch (column) {
case 0:
- result = entryBook.getLabel();
+ result = entryBook.getCode();
break;
case 1:
- result = entryBook.getDescription();
+ result = entryBook.getLabel();
break;
case 2:
- result = entryBook.getPrefix();
+ result = entryBook.getType();
break;
}
} catch (LimaException e) {
@@ -153,13 +153,13 @@
switch (column) {
case 0:
- entryBook.setLabel((String)value);
+ entryBook.setCode((String)value);
break;
case 1:
- entryBook.setDescription((String)value);
+ entryBook.setLabel((String)value);
break;
case 2:
- entryBook.setPrefix((String)value);
+ entryBook.setType((String)value);
break;
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,79 @@
+/* *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.FinancialTransaction;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionHelper {
+
+ /**
+ * Get total credit for a transaction.
+ *
+ * @param transaction transaction to get credit
+ * @return total credit
+ */
+ public static double getCredit(FinancialTransaction financialtransaction) {
+ double credit = 0;
+ for (Entry entry : financialtransaction.getEntry()) {
+ // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
+ if (!entry.getDebit()) {
+ credit += entry.getAmount();
+ }
+ }
+ return credit;
+ }
+
+ /**
+ * Get total debit for a transaction.
+ *
+ * @param transaction transaction to get debit
+ * @return total debit
+ */
+ public static double getDebit(FinancialTransaction financialtransaction) {
+ double debit = 0;
+ for (Entry entry : financialtransaction.getEntry()) {
+ // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
+ if (entry.getDebit()) {
+ debit += entry.getAmount();
+ }
+ }
+ return debit;
+ }
+
+ /**
+ * Return true if transaction is balanced (credit == debit).
+ *
+ * @param transaction transaction to test
+ * @return {@code true} if transaction is balanced
+ */
+ public static boolean isBalanced(FinancialTransaction financialtransaction) {
+ boolean balanced = getDebit(financialtransaction) == getCredit(financialtransaction);
+ return balanced;
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java (from rev 2861, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,156 @@
+/* *##% 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.transaction;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionImpl;
+import org.chorem.lima.ui.entrybook.EntryBookForm;
+import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
+import org.chorem.lima.ui.transaction.table.FinancialTransactionTable;
+import org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel;
+import org.chorem.lima.util.ErrorHelper;
+import org.jdesktop.swingx.JXTable;
+
+
+/**
+ * Handler associated with account view.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionViewHandler {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(FinancialTransactionViewHandler.class);
+
+ protected TransactionView view;
+
+ protected FinancialTransactionViewHandler(TransactionView view) {
+ this.view = view;
+ }
+
+ //add a new transaction
+ protected void addFinancialTransaction() {
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+
+ try {
+ model.addFinancialTransaction();
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add transaction", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add transaction", ex);
+ }
+ }
+
+ //implement new transaction button
+ //add a new entry to the selected transaction
+ public void addEmptyEntry(){
+
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+ Object selectedValue = model.getElementAt(indexSelectedRow);
+ model.addEmptyEntry(selectedValue, indexSelectedRow);
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call addentry selected transaction without selection");
+ }
+ }
+ }
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @throws LimaException
+ */
+ public void deleteSelectedRow(){
+
+ FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable();
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+
+ Object selectedValue = model.getElementAt(indexSelectedRow);
+ String message = null;
+ if (selectedValue instanceof FinancialTransaction) {
+ message = _("lima.question.remove.transaction");
+ }
+ else {
+ message = _("lima.question.remove.entry");
+ }
+
+ int response = JOptionPane.showConfirmDialog(view, message,
+ _("lima.transaction.confirmdelete"), JOptionPane.YES_NO_OPTION);
+
+ if (response == JOptionPane.YES_OPTION) {
+
+ try {
+ model.removeObject(selectedValue, indexSelectedRow);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove transaction or entry", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't remove transaction or entry", ex);
+ }
+
+ /*
+ if (selectedValue instanceof Transaction) {
+ // TODO EC-20100409 implements this
+ if (log.isWarnEnabled()) {
+ log.warn("TODO implement Transaction deletion");
+ model.removeTransaction(selectedValue);
+ }
+ }
+ else if (selectedValue instanceof Entry) {
+ // TODO EC-20100409 implements this
+ if (log.isWarnEnabled()) {
+ log.warn("TODO implement Entry deletion");
+ }
+ }*/
+ }
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call delete selected row without selection");
+ }
+ }
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,79 +0,0 @@
-/* *##% Lima Main
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.transaction;
-
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.Transaction;
-
-/**
- * TODO add comment here.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class TransactionHelper {
-
- /**
- * Get total credit for a transaction.
- *
- * @param transaction transaction to get credit
- * @return total credit
- */
- public static double getCredit(Transaction transaction) {
- double credit = 0;
- for (Entry entry : transaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (!entry.getDebit()) {
- credit += entry.getAmount();
- }
- }
- return credit;
- }
-
- /**
- * Get total debit for a transaction.
- *
- * @param transaction transaction to get debit
- * @return total debit
- */
- public static double getDebit(Transaction transaction) {
- double debit = 0;
- for (Entry entry : transaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (entry.getDebit()) {
- debit += entry.getAmount();
- }
- }
- return debit;
- }
-
- /**
- * Return true if transaction is balanced (credit == debit).
- *
- * @param transaction transaction to test
- * @return {@code true} if transaction is balanced
- */
- public static boolean isBalanced(Transaction transaction) {
- boolean balanced = getDebit(transaction) == getCredit(transaction);
- return balanced;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,156 +0,0 @@
-/* *##% 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.transaction;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
-import javax.swing.JOptionPane;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryBookImpl;
-import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.entity.TransactionImpl;
-import org.chorem.lima.ui.entrybook.EntryBookForm;
-import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
-import org.chorem.lima.ui.transaction.table.TransactionTable;
-import org.chorem.lima.ui.transaction.table.TransactionTableModel;
-import org.chorem.lima.util.ErrorHelper;
-import org.jdesktop.swingx.JXTable;
-
-
-/**
- * Handler associated with account view.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class TransactionViewHandler {
-
- /** log. */
- private static final Log log = LogFactory.getLog(TransactionViewHandler.class);
-
- protected TransactionView view;
-
- protected TransactionViewHandler(TransactionView view) {
- this.view = view;
- }
-
- //add a new transaction
- protected void addEmptyTransaction() {
- TransactionTable table = (TransactionTable)view.getTransactionTable();
- TransactionTableModel model = (TransactionTableModel)table.getModel();
-
- try {
- model.addEmptyTransaction();
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add transaction", ex);
- }
- ErrorHelper.showErrorDialog("Can't add transaction", ex);
- }
- }
-
- //implement new transaction button
- //add a new entry to the selected transaction
- public void addEmptyEntry(){
-
- TransactionTable table = (TransactionTable)view.getTransactionTable();
- TransactionTableModel model = (TransactionTableModel)table.getModel();
-
- int indexSelectedRow = table.getSelectedRow();
- if (indexSelectedRow != -1) {
- Object selectedValue = model.getElementAt(indexSelectedRow);
- model.addEmptyEntry(selectedValue, indexSelectedRow);
- }
- else {
- if (log.isWarnEnabled()) {
- log.warn("Call addentry selected transaction without selection");
- }
- }
- }
-
- /**
- * Delete selected row in table (could be transaction or entry).
- *
- * Called by model.
- * @throws LimaException
- */
- public void deleteSelectedRow(){
-
- TransactionTable table = (TransactionTable)view.getTransactionTable();
- TransactionTableModel model = (TransactionTableModel)table.getModel();
-
- int indexSelectedRow = table.getSelectedRow();
- if (indexSelectedRow != -1) {
-
- Object selectedValue = model.getElementAt(indexSelectedRow);
- String message = null;
- if (selectedValue instanceof Transaction) {
- message = _("lima.question.remove.transaction");
- }
- else {
- message = _("lima.question.remove.entry");
- }
-
- int response = JOptionPane.showConfirmDialog(view, message,
- _("lima.transaction.confirmdelete"), JOptionPane.YES_NO_OPTION);
-
- if (response == JOptionPane.YES_OPTION) {
-
- try {
- model.removeObject(selectedValue, indexSelectedRow);
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove transaction or entry", ex);
- }
- ErrorHelper.showErrorDialog("Can't remove transaction or entry", ex);
- }
-
- /*
- if (selectedValue instanceof Transaction) {
- // TODO EC-20100409 implements this
- if (log.isWarnEnabled()) {
- log.warn("TODO implement Transaction deletion");
- model.removeTransaction(selectedValue);
- }
- }
- else if (selectedValue instanceof Entry) {
- // TODO EC-20100409 implements this
- if (log.isWarnEnabled()) {
- log.warn("TODO implement Entry deletion");
- }
- }*/
- }
- }
- else {
- if (log.isWarnEnabled()) {
- log.warn("Call delete selected row without selection");
- }
- }
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java (from rev 2861, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,374 @@
+/* *##% 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.transaction.table;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.util.Date;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.listener.EmptyLineSelectionListener;
+import org.chorem.lima.table.editor.DateTableCellEditor;
+import org.chorem.lima.ui.transaction.FinancialTransactionViewHandler;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+
+
+/**
+ * Table des transaction qui ajoute des comportement (keys).
+ *
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class FinancialTransactionTable extends JXTable implements KeyListener {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
+
+ protected FinancialTransactionViewHandler handler;
+
+ private ColorHighlighter colorEmptyLine;
+
+ private ColorHighlighter colorTransaction;
+
+ private ColorHighlighter colorBalance;
+
+ private EmptyLineSelectionListener emptyLineSelectionListener;
+
+ /**
+ */
+ public FinancialTransactionTable(FinancialTransactionViewHandler handler/*,
+ TransactionTableModel model,
+ TransactionSortedTableColumnModel columnModel*/) {
+ //super(model, columnModel);
+
+ this.handler = handler;
+
+ /*
+ * New Table Header
+ */
+ // header renderer getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
+ //getTableHeader().addMouseListener(new TransactionHeaderListener(this));
+
+ /*
+ * Mod : il est possible d'activer cette option.
+ * Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
+ * automatiquement une nouvelle ligne (une entrée comptable)
+ */
+ //addMouseListener(getEmptyLineSelectionListener());
+
+ /*
+ * Mod : il est possible d'activer cette option.
+ * Lorsque l'utilisateur appuie sur une touche "insert" ou autres, le
+ * programme insère une ligne comptable.
+ */
+ addKeyListener(this);
+
+ // cell rendering
+ /*TableColumnModel tcm = getColumnModel();
+ tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellRenderer(DateTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellRenderer(AccountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellRenderer(JournalTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellRenderer(PeriodTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.STATUS.ordinal()).setCellRenderer(StatusTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.BALANCE.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
+
+ // cell editoring
+ tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellEditor(DateTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellEditor(AccountTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellEditor(JournalTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());*/
+
+ setDefaultEditor(Date.class, new DateTableCellEditor());
+
+
+ // Color transactions
+ // addColorTransaction();
+ // addColorNonBalancedTransaction();
+ }
+
+ /**
+ *
+ */
+ public void addColorEmptyLine() {
+
+ // Renvoie une couleur jaune pour chaque nouvelle ligne créée
+ /*removeColorEmptyLine();
+ if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
+ final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
+ HighlightPredicate predicate = new HighlightPredicate() {
+
+ @Override
+ public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ return adapter.row == posNext;
+ }
+ };
+ colorEmptyLine = new ColorHighlighter(predicate, new Color(248,255,136), Color.BLACK,new Color(248,255,136), Color.BLACK);
+ addHighlighter(colorEmptyLine);
+ }*/
+ }
+
+ /**
+ *
+ */
+ public void removeColorEmptyLine() {
+ if (colorEmptyLine != null) {
+ removeHighlighter(colorEmptyLine);
+ }
+ }
+
+ /**
+ * Cette méthode permet de colorer toutes les transactions dans le tableau
+ * afin de bien distinguer les transactions et entrées comptables.
+ */
+ /* protected void addColorTransaction() {
+ if (colorTransaction != null) {
+ removeHighlighter(colorTransaction);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ return getModel().getElementAt(adapter.row) instanceof Transaction;
+ }
+ };
+ colorTransaction = new ColorHighlighter(predicate, new Color(222, 222,
+ 222), null, null, null);
+ addHighlighter(colorTransaction);
+ }*/
+
+ /**
+ * Permet de surligner une transaction dans le tableau lorsque cette dernière
+ * n'est pas équilibrée.
+ */
+/* protected void addColorNonBalancedTransaction() {
+ if (colorBalance != null) {
+ removeHighlighter(colorBalance);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ boolean isHighlighted = false;
+ Object value = getModel().getElementAt(adapter.row);
+ if (value instanceof Transaction) {
+ Transaction currentTransaction = (Transaction) value;
+ if (!TransactionHelper.isBalanced(currentTransaction)) {
+ isHighlighted = true;
+ }
+ }
+ return isHighlighted;
+ }
+ };
+ colorTransaction = new ColorHighlighter(predicate, new Color(255, 198,
+ 209), null, null, null);
+ addHighlighter(colorTransaction);
+ }*/
+
+ /* @Override
+ public TransactionTableModel getModel() {
+ return (TransactionTableModel) this.dataModel;
+ }
+
+ @Override
+ public TransactionSortedTableColumnModel getColumnModel() {
+ return (TransactionSortedTableColumnModel) this.columnModel;
+ }
+
+*/
+ /*
+ public EmptyLineSelectionListener getEmptyLineSelectionListener() {
+ if (emptyLineSelectionListener == null) {
+ return new EmptyLineSelectionListener();
+ }
+ return emptyLineSelectionListener;
+ }
+*/
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ // VK_DELETE suppression de la transaction en cours
+ // ou de l'entree
+ if (e.getKeyCode() == KeyEvent.VK_DELETE) {
+ // handler.deleteSelectedRow();
+ }
+
+ // Touche : insert ou ctrl+I
+ // Ajoute une transaction
+ if ((e.getKeyCode() == KeyEvent.VK_INSERT)
+ || (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+
+ // TODO EC 20100408 String result = table.getModel().addEmptyTransaction();
+ }
+
+ // Touche '+' OU 'ctrl+Entr'
+ // Ajoute une entrée comptable ou transaction
+ if (e.getKeyCode() == KeyEvent.VK_PLUS
+ || (e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+ /*int max_y = table.getRowCount();
+ addLine(table);
+ table.setColumnSelectionInterval(0, 0);
+ table.setRowSelectionInterval(max_y, max_y);*/
+ }
+
+ /**
+ * Touche tab
+ * Ajoute une entrée comptable ou transaction seulement si tab est sur
+ * la dernière cellule.
+ */
+ if (e.getKeyChar() == KeyEvent.VK_TAB) {
+ // Vérifie si la cellule sélectionnée est la dernière
+ /*int x = table.getSelectedColumn();
+ int y = table.getSelectedRow();
+ int max_x = table.getColumnCount() - 1;
+ int max_y = table.getRowCount() - 1;
+ if (x == max_x && y == max_y) {
+ boolean result = addLine(table);
+ // positionne la sélection sur la nouvelle ligne créée
+ if (result) {
+ table.setColumnSelectionInterval(0, 0);
+ table.setRowSelectionInterval(max_y + 1, max_y + 1);
+ }
+ }*/
+ }
+
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyReleased(KeyEvent e) {
+
+ }
+
+ /**
+ * Permet d'ajouter une nouvelle ligne : transaction ou entrée
+ * @param table la table
+ * @return
+ */
+ /*private boolean addLine(TransactionJXTable table) {
+ if (TransactionFlattenTableModel.isFlattenModel(table.getModel())) {
+ // Vérifie si le tableau est vide, alors ajout d'une transaction
+ if (table.getRowCount() == 0) {
+ String result = table.getModel().addEmptyTransaction();
+ ErrorMessage.showMessage(result);
+ return true;
+ }
+ TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table
+ .getModel();
+ int selectedRow = 0;
+ // Vérifie si une ligne est sélectionnée ou non
+ if (table.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ selectedRow = table.getRowCount() - 1;
+ } else {
+ // Line selected
+ selectedRow = table.getSelectedRow();
+ }
+ // Récupère la position de la transaction rattachée
+ int parentIndex = flattenModel.getParentIndex(selectedRow);
+
+ // Is transaction editable ?
+ Object o = flattenModel.getElementAt(parentIndex);
+ if (DTOHelper.isTransaction(o)) {
+ // Transaction n'est pas éditable
+ if (!ServiceHelper.isEditable((TransactionDTO) o)) {
+ return false;
+ }
+ } else {
+ //Entry n'est pas éditable
+ if (!ServiceHelper.isEditable((EntryDTO) o)) {
+ return false;
+ }
+ }
+
+ // Vérifie si la transaction est équilibrée ou non (et qu'elle posséde des entrées)
+ TransactionDTO transaction = (TransactionDTO) flattenModel
+ .getElementAt(parentIndex);
+ if (DTOHelper.isBalanced(transaction)
+ && !transaction.getEntries().isEmpty()) {
+ String result = table.getModel().addEmptyTransaction();
+ ErrorMessage.showMessage(result);
+ return true;
+ }
+
+ // Vérifie si une ligne est sélectionnée ou non
+ if (table.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = selectedRow + 1;
+ flattenModel.createEmptyLine();
+ flattenModel.addEmptyLine(posNext);
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+
+ // New Line Color
+ table.addColorEmptyLine();
+ } else {
+ // Line selected
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = flattenModel
+ .emptyLineNextPosition(selectedRow);
+
+ // Once traitement for transaction
+ if (flattenModel.isEmptyLineEmpty()) {
+ flattenModel.createEmptyLine();
+ } else {
+ flattenModel.removeEmptyLine();
+ selectedRow = table.getSelectedRow();
+ parentIndex = flattenModel.getParentIndex(selectedRow);
+ posNext = flattenModel
+ .emptyLineNextPosition(selectedRow);
+ flattenModel.createEmptyLine();
+ }
+ flattenModel.addEmptyLine(posNext);
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+
+ // New Line Color
+ table.addColorEmptyLine();
+ }
+ return true;
+ }
+ return false;
+ }*/
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java (from rev 2863, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -0,0 +1,506 @@
+/* *##% 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.transaction.table;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.RecordService;
+import org.chorem.lima.business.FinancialTransactionService;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.transaction.FinancialTransactionHelper;
+import org.chorem.lima.util.ErrorHelper;
+import org.nuiton.topia.TopiaContextFactory;
+
+/**
+ * Basic transaction table model.
+ *
+ * Le modele est filtré sur {@link #selectedEntryBook} et
+ * {@link #selectedFinancialPeriod} (montée en charge !).
+ *
+ * TODO EC20100408 revoir le modele, avoir des transactions et des entries
+ * c'est pas gérables.
+ * Le mieux serait d'avoir un "mega component transaction par ligne" et
+ * que ce composant puisse editer les entries.
+ * Ou autre chose.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3914954536809622358L;
+
+ /** log. */
+ private static final Log log = LogFactory
+ .getLog(FinancialTransactionTableModel.class);
+
+ /** Transaction service. */
+ protected final FinancialTransactionService transactionService;
+ /** Record service. */
+ protected final RecordService recordService;
+
+ protected EntryBook selectedEntryBook;
+
+ protected FinancialPeriod selectedFinancialPeriod;
+
+ /**
+ * Model constructor.
+ *
+ * Just init service proxies.
+ */
+ public FinancialTransactionTableModel() {
+ /* Services */
+ recordService = LimaServiceFactory.getInstance().getRecordService();
+ transactionService = LimaServiceFactory.getInstance()
+ .getTransactionService();
+ }
+
+ /**
+ * Le model est une combinaison de Transaction/Entries.
+ *
+ * TODO EC20100408 c'est pas evident a manipuler via une table
+ *
+ * @return
+ */
+ protected List<Object> getDataList() {
+
+ log.debug("getDatalist");
+
+ List<Object> results = new ArrayList<Object>();
+ try {
+
+ List<FinancialTransaction> financialtransactions =
+ transactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
+
+ for (FinancialTransaction financialtransaction : financialtransactions) {
+ results.add(financialtransaction);
+ // TODO EC20100408 warn about lazy exception here
+ // TODO EC20100408 warn about non ordonned transaction.getEntry()
+ results.addAll(financialtransaction.getEntry());
+ }
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ }
+
+ return results;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 10;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+
+ Class<?> result = null;
+
+ switch (column) {
+ case 0:
+ result = Date.class;
+ break;
+ case 1:
+ result = Account.class;
+ break;
+ case 2:
+ result = EntryBook.class;
+ break;
+ case 3:
+ result = FinancialPeriod.class;
+ break;
+ case 4:
+ result = String.class;
+ break;
+ case 5:
+ result = Double.class;
+ break;
+ case 6:
+ result = Double.class;
+ break;
+ case 7:
+ result = String.class;
+ break;
+ case 8:
+ result = String.class;
+ break;
+ case 9:
+ result = String.class;
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String result = "n/a";
+
+ switch (column) {
+ case 0:
+ result = _("lima.transaction.column.date");
+ break;
+ case 1:
+ result = _("lima.transaction.column.account");
+ break;
+ case 2:
+ result = _("lima.transaction.column.entrybook");
+ break;
+ case 3:
+ result = _("lima.transaction.column.period");
+ break;
+ case 4:
+ result = _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = _("lima.transaction.column.debit");
+ break;
+ case 6:
+ result = _("lima.transaction.column.credit");
+ break;
+ case 7:
+ result = _("lima.transaction.column.balance");
+ break;
+ case 8:
+ result = _("lima.transaction.column.description");
+ break;
+ case 9:
+ result = _("lima.transaction.column.document");
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ List<Object> datas = getDataList();
+ result = datas.size();
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ Object result = null;
+
+ // just prevent too much result
+ System.out.println("OK2");
+ if (selectedEntryBook != null) {
+ // TODO EC-20100407 remove this ugly code
+ List<Object> datas = getDataList();
+ result = datas.get(row);
+
+ if (result instanceof FinancialTransaction) {
+ FinancialTransaction currentRow = (FinancialTransaction)result;
+ switch (column) {
+ case 0:
+ result = currentRow.getTransactionDate();
+ break;
+ case 1:
+ result = null; // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = FinancialTransactionHelper.getDebit(currentRow);
+ break;
+ case 6:
+ result = FinancialTransactionHelper.getCredit(currentRow);
+ break;
+ case 7:
+ result = FinancialTransactionHelper.getDebit(currentRow) - FinancialTransactionHelper.getCredit(currentRow);
+ break;
+ case 8:
+ result = currentRow.getDescription();
+ break;
+ case 9:
+ result = currentRow.getVoucherRef();
+ break;
+ }
+ }
+ else if (result instanceof Entry) {
+ Entry currentEntry = (Entry)result;
+ switch (column) {
+ case 0:
+ result = null; // date
+ break;
+ case 1:
+ result = currentEntry.getAccount(); // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
+ break;
+ case 6:
+ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
+ break;
+ case 7:
+ result = null;
+ break;
+ case 8:
+ result = currentEntry.getDescription();
+ break;
+ case 9:
+ result = null;
+ break;
+ }
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+
+ public void setEntryBook(EntryBook entryBook){
+
+ System.out.println("OK");
+ selectedEntryBook = entryBook;
+ fireTableDataChanged();
+ }
+
+ /**
+ * @throws LimaException
+ */
+ public void addFinancialTransaction() throws LimaException{
+ /* Calling transaction service */
+ //TODO transaction = currentdate, current periode, current journal
+ FinancialTransaction financialtransaction =null;
+ financialtransaction.setFinancialPeriod(selectedFinancialPeriod);
+ financialtransaction.setEntryBook(selectedEntryBook);
+ //financialransaction.setDescription(description);
+ transactionService.createFinancialTransaction(financialtransaction);
+ int row = getDataList().indexOf(financialtransaction);
+ //int row = transactionService.getAllTransactions().indexOf(transaction);
+ log.debug(row);
+ fireTableRowsInserted(row, row);
+ }
+
+
+
+ /**
+ * @throws LimaException
+ */
+ public void addEmptyEntry(Object value, int row) {
+ /* Calling transaction service */
+ //TODO transaction = currentdate, current periode, current journal
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+ Entry entry=null;
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentTransaction = (FinancialTransaction)currentRow;
+ currentTransaction.addEntry(entry);
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //TODO recuperer l'entrée parente, ajouter entrée
+ }
+ fireTableRowsUpdated(row, row);
+ }
+
+
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ // TODO EC-20100407 remove this ugly code
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentFinancialTransaction =
+ (FinancialTransaction)currentRow;
+ switch (column) {
+ case 0:
+ currentFinancialTransaction.setTransactionDate((Date)value);
+ break;
+ /*case 1:
+ result = null; // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = TransactionHelper.getDebit(currentRow);
+ break;
+ case 6:
+ result = TransactionHelper.getCredit(currentRow);
+ break;
+ case 7:
+ result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow);
+ break;*/
+ case 8:
+ currentFinancialTransaction.setDescription((String)value);
+ break;
+ case 9:
+ currentFinancialTransaction.setVoucherRef((String)value);
+ break;
+ }
+
+ // notify service for modification
+ try {
+ transactionService.updateFinancialTransaction(currentFinancialTransaction);
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //fireTableRowsUpdated(row, row); // to update what ???
+
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ switch (column) {
+ /*case 0:
+ result = null; // date
+ break;*/
+ case 1:
+ currentEntry.setAccount((Account)value); // account ?
+ break;
+ /*case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;*/
+ case 5:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(true);
+ break;
+ case 6:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(false);
+ break;
+ /*case 7:
+ result = null;
+ break;*/
+ case 8:
+ currentEntry.setDescription((String)value);
+ break;
+ /*case 9:
+ result = null;
+ break;*/
+ }
+
+ //transactionService.updateEntry(currentEntry);
+ // fire modification of all transaction
+ // see here, table is not adapted :)
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+ }
+
+ public Object getElementAt(int row){
+
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+ return currentRow;
+ }
+
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @param Object, int
+ * @throws LimaException
+ */
+ public void removeObject(Object object, int row) throws LimaException {
+ /* Calling journal service */
+
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentTransaction = (FinancialTransaction)currentRow;
+ transactionService.removeFinancialTransaction(currentTransaction);
+ fireTableRowsDeleted(row, row);
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //TODO supprimer l'entrée
+ }
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,383 +0,0 @@
-/* *##% 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.transaction.table;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.util.Date;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.listener.EmptyLineSelectionListener;
-import org.chorem.lima.table.editor.DateTableCellEditor;
-import org.chorem.lima.table.model.TransactionSortedTableColumnModel;
-import org.chorem.lima.table.model.TransactionTableModel;
-import org.chorem.lima.ui.transaction.TransactionHelper;
-import org.chorem.lima.ui.transaction.TransactionViewHandler;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.ColorHighlighter;
-import org.jdesktop.swingx.decorator.ComponentAdapter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-
-/**
- * Table des transaction qui ajoute des comportement (keys).
- *
- * @author ore
- * @author Rémi Chapelet
- */
-public class TransactionTable extends JXTable implements KeyListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3133690382049594727L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(TransactionTable.class);
-
- protected TransactionViewHandler handler;
-
- private ColorHighlighter colorEmptyLine;
-
- private ColorHighlighter colorTransaction;
-
- private ColorHighlighter colorBalance;
-
- private EmptyLineSelectionListener emptyLineSelectionListener;
-
- /**
- */
- public TransactionTable(TransactionViewHandler handler/*,
- TransactionTableModel model,
- TransactionSortedTableColumnModel columnModel*/) {
- //super(model, columnModel);
-
- this.handler = handler;
-
- /*
- * New Table Header
- */
- // header renderer getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
- //getTableHeader().addMouseListener(new TransactionHeaderListener(this));
-
- /*
- * Mod : il est possible d'activer cette option.
- * Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
- * automatiquement une nouvelle ligne (une entrée comptable)
- */
- //addMouseListener(getEmptyLineSelectionListener());
-
- /*
- * Mod : il est possible d'activer cette option.
- * Lorsque l'utilisateur appuie sur une touche "insert" ou autres, le
- * programme insère une ligne comptable.
- */
- addKeyListener(this);
-
- // cell rendering
- /*TableColumnModel tcm = getColumnModel();
- tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellRenderer(DateTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellRenderer(AccountTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellRenderer(JournalTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellRenderer(PeriodTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.STATUS.ordinal()).setCellRenderer(StatusTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.BALANCE.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
- tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
-
- // cell editoring
- tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellEditor(DateTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellEditor(AccountTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellEditor(JournalTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());*/
-
- setDefaultEditor(Date.class, new DateTableCellEditor());
-
-
- // Color transactions
- // addColorTransaction();
- // addColorNonBalancedTransaction();
- }
-
- /**
- *
- */
- public void addColorEmptyLine() {
-
- // Renvoie une couleur jaune pour chaque nouvelle ligne créée
- /*removeColorEmptyLine();
- if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
- final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
- HighlightPredicate predicate = new HighlightPredicate() {
-
- @Override
- public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
- return adapter.row == posNext;
- }
- };
- colorEmptyLine = new ColorHighlighter(predicate, new Color(248,255,136), Color.BLACK,new Color(248,255,136), Color.BLACK);
- addHighlighter(colorEmptyLine);
- }*/
- }
-
- /**
- *
- */
- public void removeColorEmptyLine() {
- if (colorEmptyLine != null) {
- removeHighlighter(colorEmptyLine);
- }
- }
-
- /**
- * Cette méthode permet de colorer toutes les transactions dans le tableau
- * afin de bien distinguer les transactions et entrées comptables.
- */
- /* protected void addColorTransaction() {
- if (colorTransaction != null) {
- removeHighlighter(colorTransaction);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- return getModel().getElementAt(adapter.row) instanceof Transaction;
- }
- };
- colorTransaction = new ColorHighlighter(predicate, new Color(222, 222,
- 222), null, null, null);
- addHighlighter(colorTransaction);
- }*/
-
- /**
- * Permet de surligner une transaction dans le tableau lorsque cette dernière
- * n'est pas équilibrée.
- */
-/* protected void addColorNonBalancedTransaction() {
- if (colorBalance != null) {
- removeHighlighter(colorBalance);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- boolean isHighlighted = false;
- Object value = getModel().getElementAt(adapter.row);
- if (value instanceof Transaction) {
- Transaction currentTransaction = (Transaction) value;
- if (!TransactionHelper.isBalanced(currentTransaction)) {
- isHighlighted = true;
- }
- }
- return isHighlighted;
- }
- };
- colorTransaction = new ColorHighlighter(predicate, new Color(255, 198,
- 209), null, null, null);
- addHighlighter(colorTransaction);
- }*/
-
- /* @Override
- public TransactionTableModel getModel() {
- return (TransactionTableModel) this.dataModel;
- }
-
- @Override
- public TransactionSortedTableColumnModel getColumnModel() {
- return (TransactionSortedTableColumnModel) this.columnModel;
- }
-
-*/
- /*
- public EmptyLineSelectionListener getEmptyLineSelectionListener() {
- if (emptyLineSelectionListener == null) {
- return new EmptyLineSelectionListener();
- }
- return emptyLineSelectionListener;
- }
-*/
- @Override
- public void keyPressed(KeyEvent e) {
-
- // VK_DELETE suppression de la transaction en cours
- // ou de l'entree
- if (e.getKeyCode() == KeyEvent.VK_DELETE) {
- // handler.deleteSelectedRow();
- }
-
- // Touche : insert ou ctrl+I
- // Ajoute une transaction
- if ((e.getKeyCode() == KeyEvent.VK_INSERT)
- || (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK)) {
-
- // TODO EC 20100408 String result = table.getModel().addEmptyTransaction();
- }
-
- // Touche '+' OU 'ctrl+Entr'
- // Ajoute une entrée comptable ou transaction
- if (e.getKeyCode() == KeyEvent.VK_PLUS
- || (e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == KeyEvent.CTRL_MASK)) {
- /*int max_y = table.getRowCount();
- addLine(table);
- table.setColumnSelectionInterval(0, 0);
- table.setRowSelectionInterval(max_y, max_y);*/
- }
-
- /**
- * Touche tab
- * Ajoute une entrée comptable ou transaction seulement si tab est sur
- * la dernière cellule.
- */
- if (e.getKeyChar() == KeyEvent.VK_TAB) {
- // Vérifie si la cellule sélectionnée est la dernière
- /*int x = table.getSelectedColumn();
- int y = table.getSelectedRow();
- int max_x = table.getColumnCount() - 1;
- int max_y = table.getRowCount() - 1;
- if (x == max_x && y == max_y) {
- boolean result = addLine(table);
- // positionne la sélection sur la nouvelle ligne créée
- if (result) {
- table.setColumnSelectionInterval(0, 0);
- table.setRowSelectionInterval(max_y + 1, max_y + 1);
- }
- }*/
- }
-
- }
-
- /*
- * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
- */
- @Override
- public void keyTyped(KeyEvent e) {
-
- }
-
- /*
- * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
- */
- @Override
- public void keyReleased(KeyEvent e) {
-
- }
-
- /**
- * Permet d'ajouter une nouvelle ligne : transaction ou entrée
- * @param table la table
- * @return
- */
- /*private boolean addLine(TransactionJXTable table) {
- if (TransactionFlattenTableModel.isFlattenModel(table.getModel())) {
- // Vérifie si le tableau est vide, alors ajout d'une transaction
- if (table.getRowCount() == 0) {
- String result = table.getModel().addEmptyTransaction();
- ErrorMessage.showMessage(result);
- return true;
- }
- TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table
- .getModel();
- int selectedRow = 0;
- // Vérifie si une ligne est sélectionnée ou non
- if (table.getSelectionModel().isSelectionEmpty()) {
- // Not line selected
- selectedRow = table.getRowCount() - 1;
- } else {
- // Line selected
- selectedRow = table.getSelectedRow();
- }
- // Récupère la position de la transaction rattachée
- int parentIndex = flattenModel.getParentIndex(selectedRow);
-
- // Is transaction editable ?
- Object o = flattenModel.getElementAt(parentIndex);
- if (DTOHelper.isTransaction(o)) {
- // Transaction n'est pas éditable
- if (!ServiceHelper.isEditable((TransactionDTO) o)) {
- return false;
- }
- } else {
- //Entry n'est pas éditable
- if (!ServiceHelper.isEditable((EntryDTO) o)) {
- return false;
- }
- }
-
- // Vérifie si la transaction est équilibrée ou non (et qu'elle posséde des entrées)
- TransactionDTO transaction = (TransactionDTO) flattenModel
- .getElementAt(parentIndex);
- if (DTOHelper.isBalanced(transaction)
- && !transaction.getEntries().isEmpty()) {
- String result = table.getModel().addEmptyTransaction();
- ErrorMessage.showMessage(result);
- return true;
- }
-
- // Vérifie si une ligne est sélectionnée ou non
- if (table.getSelectionModel().isSelectionEmpty()) {
- // Not line selected
- // Click in not current transaction
- if (flattenModel.getCurrentParentIndex() != parentIndex) {
- int posNext = selectedRow + 1;
- flattenModel.createEmptyLine();
- flattenModel.addEmptyLine(posNext);
- // To end
- flattenModel.setCurrentParentIndex(parentIndex);
- }
-
- // New Line Color
- table.addColorEmptyLine();
- } else {
- // Line selected
- // Click in not current transaction
- if (flattenModel.getCurrentParentIndex() != parentIndex) {
- int posNext = flattenModel
- .emptyLineNextPosition(selectedRow);
-
- // Once traitement for transaction
- if (flattenModel.isEmptyLineEmpty()) {
- flattenModel.createEmptyLine();
- } else {
- flattenModel.removeEmptyLine();
- selectedRow = table.getSelectedRow();
- parentIndex = flattenModel.getParentIndex(selectedRow);
- posNext = flattenModel
- .emptyLineNextPosition(selectedRow);
- flattenModel.createEmptyLine();
- }
- flattenModel.addEmptyLine(posNext);
- // To end
- flattenModel.setCurrentParentIndex(parentIndex);
- }
-
- // New Line Color
- table.addColorEmptyLine();
- }
- return true;
- }
- return false;
- }*/
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-16 10:26:55 UTC (rev 2864)
@@ -1,505 +0,0 @@
-/* *##% 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.transaction.table;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.RecordService;
-import org.chorem.lima.business.TransactionService;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.transaction.TransactionHelper;
-import org.chorem.lima.util.ErrorHelper;
-import org.nuiton.topia.TopiaContextFactory;
-
-/**
- * Basic transaction table model.
- *
- * Le modele est filtré sur {@link #selectedEntryBook} et
- * {@link #selectedFinancialPeriod} (montée en charge !).
- *
- * TODO EC20100408 revoir le modele, avoir des transactions et des entries
- * c'est pas gérables.
- * Le mieux serait d'avoir un "mega component transaction par ligne" et
- * que ce composant puisse editer les entries.
- * Ou autre chose.
- *
- * @author ore
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class TransactionTableModel extends AbstractTableModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3914954536809622358L;
-
- /** log. */
- private static final Log log = LogFactory
- .getLog(TransactionTableModel.class);
-
- /** Transaction service. */
- protected final TransactionService transactionService;
- /** Record service. */
- protected final RecordService recordService;
-
- protected EntryBook selectedEntryBook;
-
- protected FinancialPeriod selectedFinancialPeriod;
-
- /**
- * Model constructor.
- *
- * Just init service proxies.
- */
- public TransactionTableModel() {
- /* Services */
- recordService = LimaServiceFactory.getInstance().getRecordService();
- transactionService = LimaServiceFactory.getInstance()
- .getTransactionService();
- }
-
- /**
- * Le model est une combinaison de Transaction/Entries.
- *
- * TODO EC20100408 c'est pas evident a manipuler via une table
- *
- * @return
- */
- protected List<Object> getDataList() {
-
- log.debug("getDatalist");
-
- List<Object> results = new ArrayList<Object>();
- try {
-
- List<Transaction> transactions =
- transactionService.getAllTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
-
- for (Transaction transaction : transactions) {
- results.add(transaction);
- // TODO EC20100408 warn about lazy exception here
- // TODO EC20100408 warn about non ordonned transaction.getEntry()
- results.addAll(transaction.getEntry());
- }
- }
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
- }
-
- ErrorHelper.showErrorDialog("Can't get transaction list", eee);
- }
-
- return results;
- }
-
- @Override
- public int getColumnCount() {
- return 10;
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
-
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Date.class;
- break;
- case 1:
- result = Account.class;
- break;
- case 2:
- result = EntryBook.class;
- break;
- case 3:
- result = FinancialPeriod.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = Double.class;
- break;
- case 6:
- result = Double.class;
- break;
- case 7:
- result = String.class;
- break;
- case 8:
- result = String.class;
- break;
- case 9:
- result = String.class;
- break;
- }
-
- return result;
- }
-
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
-
- switch (column) {
- case 0:
- result = _("lima.transaction.column.date");
- break;
- case 1:
- result = _("lima.transaction.column.account");
- break;
- case 2:
- result = _("lima.transaction.column.entrybook");
- break;
- case 3:
- result = _("lima.transaction.column.period");
- break;
- case 4:
- result = _("lima.transaction.column.status");
- break;
- case 5:
- result = _("lima.transaction.column.debit");
- break;
- case 6:
- result = _("lima.transaction.column.credit");
- break;
- case 7:
- result = _("lima.transaction.column.balance");
- break;
- case 8:
- result = _("lima.transaction.column.description");
- break;
- case 9:
- result = _("lima.transaction.column.document");
- break;
- }
-
- return result;
- }
-
- @Override
- public int getRowCount() {
- int result = 0;
-
- // just prevent too much result
- if (selectedEntryBook != null) {
- List<Object> datas = getDataList();
- result = datas.size();
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
- }
- }
-
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
-
- // just prevent too much result
- System.out.println("OK2");
- if (selectedEntryBook != null) {
- // TODO EC-20100407 remove this ugly code
- List<Object> datas = getDataList();
- result = datas.get(row);
-
- if (result instanceof Transaction) {
- Transaction currentRow = (Transaction)result;
- switch (column) {
- case 0:
- result = currentRow.getTransactionDate();
- break;
- case 1:
- result = null; // account ?
- break;
- case 2:
- result = null; // entry book
- break;
- case 3:
- result = null; //currentRow.getFinancialPeriod();
- break;
- case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
- break;
- case 5:
- result = TransactionHelper.getDebit(currentRow);
- break;
- case 6:
- result = TransactionHelper.getCredit(currentRow);
- break;
- case 7:
- result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow);
- break;
- case 8:
- result = currentRow.getDescription();
- break;
- case 9:
- result = currentRow.getVoucherRef();
- break;
- }
- }
- else if (result instanceof Entry) {
- Entry currentEntry = (Entry)result;
- switch (column) {
- case 0:
- result = null; // date
- break;
- case 1:
- result = currentEntry.getAccount(); // account ?
- break;
- case 2:
- result = null; // entry book
- break;
- case 3:
- result = null; //currentRow.getFinancialPeriod();
- break;
- case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
- break;
- case 5:
- result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
- break;
- case 6:
- result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
- break;
- case 7:
- result = null;
- break;
- case 8:
- result = currentEntry.getDescription();
- break;
- case 9:
- result = null;
- break;
- }
- }
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
- }
- }
-
- return result;
- }
-
-
- public void setEntryBook(EntryBook entryBook){
-
- System.out.println("OK");
- selectedEntryBook = entryBook;
- fireTableDataChanged();
- }
-
- /**
- * @throws LimaException
- */
- public void addTransaction() throws LimaException{
- /* Calling transaction service */
- //TODO transaction = currentdate, current periode, current journal
- Transaction transaction =null;
- transaction.setFinancialPeriod(selectedFinancialPeriod);
- transaction.setEntryBook(selectedEntryBook);
- transaction.setDescription(description);
- transactionService.createTransaction(transaction);
- int row = getDataList().indexOf(transaction);
- //int row = transactionService.getAllTransactions().indexOf(transaction);
- log.debug(row);
- fireTableRowsInserted(row, row);
- }
-
-
-
- /**
- * @throws LimaException
- */
- public void addEmptyEntry(Object value, int row) {
- /* Calling transaction service */
- //TODO transaction = currentdate, current periode, current journal
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
- Entry entry=null;
- if (currentRow instanceof Transaction) {
- Transaction currentTransaction = (Transaction)currentRow;
- currentTransaction.addEntry(entry);
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- //TODO recuperer l'entrée parente, ajouter entrée
- }
- fireTableRowsUpdated(row, row);
- }
-
-
- @Override
- public void setValueAt(Object value, int row, int column) {
-
- // just prevent too much result
- if (selectedEntryBook != null) {
- // TODO EC-20100407 remove this ugly code
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
-
- if (currentRow instanceof Transaction) {
- Transaction currentTransaction = (Transaction)currentRow;
- switch (column) {
- case 0:
- currentTransaction.setTransactionDate((Date)value);
- break;
- /*case 1:
- result = null; // account ?
- break;
- case 2:
- result = null; // entry book
- break;
- case 3:
- result = null; //currentRow.getFinancialPeriod();
- break;
- case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
- break;
- case 5:
- result = TransactionHelper.getDebit(currentRow);
- break;
- case 6:
- result = TransactionHelper.getCredit(currentRow);
- break;
- case 7:
- result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow);
- break;*/
- case 8:
- currentTransaction.setDescription((String)value);
- break;
- case 9:
- currentTransaction.setVoucherRef((String)value);
- break;
- }
-
- // notify service for modification
- try {
- transactionService.updateTransaction(currentTransaction);
- } catch (LimaException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //fireTableRowsUpdated(row, row); // to update what ???
-
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- switch (column) {
- /*case 0:
- result = null; // date
- break;*/
- case 1:
- currentEntry.setAccount((Account)value); // account ?
- break;
- /*case 2:
- result = null; // entry book
- break;
- case 3:
- result = null; //currentRow.getFinancialPeriod();
- break;
- case 4:
- result = null; // what is status ? _("lima.transaction.column.status");
- break;*/
- case 5:
- currentEntry.setAmount((Double)value);
- currentEntry.setDebit(true);
- break;
- case 6:
- currentEntry.setAmount((Double)value);
- currentEntry.setDebit(false);
- break;
- /*case 7:
- result = null;
- break;*/
- case 8:
- currentEntry.setDescription((String)value);
- break;
- /*case 9:
- result = null;
- break;*/
- }
-
- //transactionService.updateEntry(currentEntry);
- // fire modification of all transaction
- // see here, table is not adapted :)
- }
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No entry book selected skip table model update");
- }
- }
- }
-
- public Object getElementAt(int row){
-
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
- return currentRow;
- }
-
-
- /**
- * Delete selected row in table (could be transaction or entry).
- *
- * Called by model.
- * @param Object, int
- * @throws LimaException
- */
- public void removeObject(Object object, int row) throws LimaException {
- /* Calling journal service */
-
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
- if (currentRow instanceof Transaction) {
- Transaction currentTransaction = (Transaction)currentRow;
- transactionService.removeTransaction(currentTransaction);
- fireTableRowsDeleted(row, row);
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- //TODO supprimer l'entrée
- }
- }
-}
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 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-16 10:26:55 UTC (rev 2864)
@@ -89,9 +89,9 @@
lima.entries.addtransaction=
lima.entries.lettering=
lima.entries.searchtransaction=
-lima.entrybook.description=
+lima.entrybook.code=
lima.entrybook.label=
-lima.entrybook.prefix=
+lima.entrybook.type=
lima.error=Error
lima.error.account.double=It exists an account with a same number
lima.error.account.not.exist=This account doesn't exist
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 2010-04-15 15:30:01 UTC (rev 2863)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-16 10:26:55 UTC (rev 2864)
@@ -87,9 +87,9 @@
lima.entries.addtransaction=Ajouter une transaction
lima.entries.lettering=Ajouter une lettre
lima.entries.searchtransaction=Recherche les transactions
-lima.entrybook.description=Description
+lima.entrybook.code=Code
lima.entrybook.label=Libelle
-lima.entrybook.prefix=Pr\u00E9fixe
+lima.entrybook.type=Type
lima.error=Erreur
lima.error.account.double=Il existe un compte avec ce m\u00EAme num\u00E9ro de compte
lima.error.account.not.exist=Ce num\u00E9ro de compte n'existe pas
1
0
r2863 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/transaction lima-swing/src/main/java/org/chorem/lima/ui/transaction/table lima-swing/src/main/resources
by jpepin@users.chorem.org 15 Apr '10
by jpepin@users.chorem.org 15 Apr '10
15 Apr '10
Author: jpepin
Date: 2010-04-15 17:30:01 +0200 (Thu, 15 Apr 2010)
New Revision: 2863
Log:
Modification du mod?\195?\168le, UI d'?\195?\169criture
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-15 15:30:01 UTC (rev 2863)
@@ -63,7 +63,7 @@
*/
List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException;
- void createTransaction(Transaction transaction) throws LimaException;
+ Transaction createTransaction() throws LimaException;
void updateTransaction(Transaction transaction) throws LimaException;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863)
@@ -19,15 +19,21 @@
package org.chorem.lima.business.ejb;
+import static org.nuiton.i18n.I18n._;
+
import java.util.List;
import javax.ejb.Stateless;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.TransactionService;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -81,10 +87,34 @@
* @param timespan
* @param journal
* @return
+ * @throws LimaException
*/
@Override
- public void createTransaction(Transaction transaction /*Date entryDate, String voucherRef,
- String description, TimeSpan timeSpan, Journal journal*/) {
+ public void createTransaction(Transaction transaction/*Date entryDate, String voucherRef,
+ String description, TimeSpan timeSpan, Journal journal*/) throws LimaException {
+
+
+ TopiaContext topiaContext = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ topiaContext = rootContext.beginTransaction();
+
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper
+ .getTransactionDAO(topiaContext);
+
+ transactionDAO.create(transaction);
+
+ // commit
+ topiaContext.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+
/*String result = ServiceHelper.RESPOND_ERROR;
try {
// Acces BDD
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-15 15:30:01 UTC (rev 2863)
@@ -22,6 +22,8 @@
<script>
<![CDATA[
+ import org.chorem.lima.entity.EntryBook;
+
]]>
</script>
@@ -42,7 +44,8 @@
<JComboBox id="entryBookComboBox"
model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}"
renderer="{new org.chorem.lima.ui.transaction.model.EntryBookRenderer()}"
- />
+ onItemStateChanged="getTransactionTableModel().setEntryBook((EntryBook) event.getItem())"
+ editable="false"/>
</cell>
<cell>
<JLabel id="periodLabel" text="lima.transaction.period"
@@ -51,7 +54,9 @@
<cell>
<JComboBox id="financialPeriodComboBox"
model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}"
- renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodRenderer()}" />
+ renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodRenderer()}"
+ editable="false"
+ />
</cell>
</row>
<row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-15 15:30:01 UTC (rev 2863)
@@ -35,10 +35,12 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.Transaction;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.transaction.TransactionHelper;
import org.chorem.lima.util.ErrorHelper;
+import org.nuiton.topia.TopiaContextFactory;
/**
* Basic transaction table model.
@@ -97,9 +99,12 @@
* @return
*/
protected List<Object> getDataList() {
-
+
+ log.debug("getDatalist");
+
List<Object> results = new ArrayList<Object>();
try {
+
List<Transaction> transactions =
transactionService.getAllTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
@@ -230,6 +235,7 @@
Object result = null;
// just prevent too much result
+ System.out.println("OK2");
if (selectedEntryBook != null) {
// TODO EC-20100407 remove this ugly code
List<Object> datas = getDataList();
@@ -315,15 +321,28 @@
return result;
}
+
+ public void setEntryBook(EntryBook entryBook){
+
+ System.out.println("OK");
+ selectedEntryBook = entryBook;
+ fireTableDataChanged();
+ }
+
/**
* @throws LimaException
*/
- public void addEmptyTransaction() throws LimaException{
+ public void addTransaction() throws LimaException{
/* Calling transaction service */
//TODO transaction = currentdate, current periode, current journal
- Transaction transaction=null;
+ Transaction transaction =null;
+ transaction.setFinancialPeriod(selectedFinancialPeriod);
+ transaction.setEntryBook(selectedEntryBook);
+ transaction.setDescription(description);
transactionService.createTransaction(transaction);
- int row = transactionService.getAllTransactions().indexOf(transaction);
+ int row = getDataList().indexOf(transaction);
+ //int row = transactionService.getAllTransactions().indexOf(transaction);
+ log.debug(row);
fireTableRowsInserted(row, row);
}
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2010-04-14 15:46:15 UTC (rev 2862)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2010-04-15 15:30:01 UTC (rev 2863)
@@ -13,4 +13,4 @@
log4j.appender.file.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
# package level
-log4j.logger.org.chorem.lima=INFO
\ No newline at end of file
+log4j.logger.org.chorem.lima=DEBUG
\ No newline at end of file
1
0
r2862 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model
by jpepin@users.chorem.org 14 Apr '10
by jpepin@users.chorem.org 14 Apr '10
14 Apr '10
Author: jpepin
Date: 2010-04-14 17:46:15 +0200 (Wed, 14 Apr 2010)
New Revision: 2862
Log:
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java 2010-04-14 15:46:15 UTC (rev 2862)
@@ -0,0 +1,34 @@
+package org.chorem.lima.ui.transaction.model;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import org.chorem.lima.entity.EntryBook;
+
+
+
+public class EntryBookRenderer extends DefaultListCellRenderer {
+
+ @Override
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
+ // TODO Auto-generated method stub
+
+ JLabel label = new JLabel();
+ EntryBook entrybook = (EntryBook) value;
+ if (entrybook != null){
+ label.setText(entrybook.getLabel());
+ }
+ return label;
+
+ }
+
+
+
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java 2010-04-14 15:46:15 UTC (rev 2862)
@@ -0,0 +1,36 @@
+package org.chorem.lima.ui.transaction.model;
+
+import java.awt.Component;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import org.chorem.lima.entity.FinancialPeriod;
+
+
+public class FinancialPeriodRenderer extends DefaultListCellRenderer {
+
+ @Override
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
+ // TODO Auto-generated method stub
+
+ JLabel label = new JLabel();
+ FinancialPeriod financialperiod = (FinancialPeriod) value;
+ if (financialperiod != null){
+ //Date d = financialperiod.getBeginDate();
+ //String date = d.getMonth() + " " + (d.getYear() + 1900);
+ //label.setText(date);
+ label.setText(financialperiod.getBeginDate().toString());
+ }
+ return label;
+ }
+
+
+}
\ No newline at end of file
1
0
r2861 - in trunk: lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/account/model lima-swing/src/main/java/org/chorem/lima/ui/transaction lima-swing/src/main/java/org/chorem/lima/ui/transaction/table lima-swing/src/main/resources/i18n
by jpepin@users.chorem.org 14 Apr '10
by jpepin@users.chorem.org 14 Apr '10
14 Apr '10
Author: jpepin
Date: 2010-04-14 17:44:00 +0200 (Wed, 14 Apr 2010)
New Revision: 2861
Log:
modification ui transaction, model zargo
Modified:
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.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
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-13 19:56:51 UTC (rev 2860)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-14 15:44:00 UTC (rev 2861)
@@ -1,5 +1,6 @@
# Precise l'entete de l'ensemble des fichiers generes
model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */
-org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
+#org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
+org.chorem.lima.entity.Transaction.attribute.entry.tagvalue.lazy=false
#model.tagvalue.dbSchema=Callao
model.tagvalue.String=text
\ No newline at end of file
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-13 19:56:51 UTC (rev 2860)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-14 15:44:00 UTC (rev 2861)
@@ -219,9 +219,7 @@
public void updateAccount(TreePath path, Account account) throws LimaException {
// Calling account service
accountService.updateAccount(account);
- int index = getIndexOfChild(path.getParentPath().getLastPathComponent(), account);
- // TODO maybe not working if order change
- // modelSupport.fireChildChanged(path.getParentPath(), index, account);
+ //refresh the tree of the node
modelSupport.fireTreeStructureChanged(path.getParentPath());
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-13 19:56:51 UTC (rev 2860)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-14 15:44:00 UTC (rev 2861)
@@ -33,20 +33,25 @@
<JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/>
<JMenuItem text="lima.print"/>
</JPopupMenu> -->
+
<row fill="horizontal" weightx="1" weighty="0" anchor="center">
<cell>
<JLabel id="entryBookLabel" text="lima.transaction.entrybook"/>
</cell>
<cell>
<JComboBox id="entryBookComboBox"
- model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}" />
+ model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}"
+ renderer="{new org.chorem.lima.ui.transaction.model.EntryBookRenderer()}"
+ />
</cell>
<cell>
- <JLabel id="periodLabel" text="lima.transaction.period"/>
+ <JLabel id="periodLabel" text="lima.transaction.period"
+ />
</cell>
<cell>
- <JComboBox id="financialPeriodPanel"
- model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}" />
+ <JComboBox id="financialPeriodComboBox"
+ model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}"
+ renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodRenderer()}" />
</cell>
</row>
<row>
@@ -61,7 +66,7 @@
highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" />
<javax.swing.ListSelectionModel javaBean="getTransactionTable().getSelectionModel()"
onValueChanged="setSelectedRow(transactionTable.getSelectedRow() != -1)"/>
- </JScrollPane>
+ </JScrollPane>
</cell>
<cell>
<JButton text="lima.add.transaction"
@@ -70,9 +75,14 @@
</row>
<row>
<cell>
+ <!--
<JButton text="lima.remove.transaction"
onActionPerformed="getHandler().removeTransaction()"
enabled="{isSelectedRow()}"/>
+ -->
+ <JButton text="lima.remove.transaction"
+ onActionPerformed="getHandler().deleteSelectedRow()"
+ enabled="{isSelectedRow()}"/>
</cell>
</row>
<row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java 2010-04-13 19:56:51 UTC (rev 2860)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java 2010-04-14 15:44:00 UTC (rev 2861)
@@ -20,15 +20,26 @@
import static org.nuiton.i18n.I18n._;
+import java.util.List;
+
import javax.swing.JOptionPane;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookImpl;
import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.table.model.TransactionTableModel;
+import org.chorem.lima.entity.TransactionImpl;
+import org.chorem.lima.ui.entrybook.EntryBookForm;
+import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
import org.chorem.lima.ui.transaction.table.TransactionTable;
+import org.chorem.lima.ui.transaction.table.TransactionTableModel;
+import org.chorem.lima.util.ErrorHelper;
+import org.jdesktop.swingx.JXTable;
+
/**
* Handler associated with account view.
*
@@ -47,35 +58,57 @@
protected TransactionViewHandler(TransactionView view) {
this.view = view;
- }
+ }
+
+ //add a new transaction
+ protected void addEmptyTransaction() {
+ TransactionTable table = (TransactionTable)view.getTransactionTable();
+ TransactionTableModel model = (TransactionTableModel)table.getModel();
- public void addEmptyTransaction() {
-
+ try {
+ model.addEmptyTransaction();
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add transaction", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add transaction", ex);
+ }
}
- public void removeTransaction() {
+ //implement new transaction button
+ //add a new entry to the selected transaction
+ public void addEmptyEntry(){
+ TransactionTable table = (TransactionTable)view.getTransactionTable();
+ TransactionTableModel model = (TransactionTableModel)table.getModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+ Object selectedValue = model.getElementAt(indexSelectedRow);
+ model.addEmptyEntry(selectedValue, indexSelectedRow);
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call addentry selected transaction without selection");
+ }
+ }
}
- public void addEmptyEntry() {
-
- }
-
/**
* Delete selected row in table (could be transaction or entry).
*
* Called by model.
+ * @throws LimaException
*/
- public void deleteSelectedRow() {
+ public void deleteSelectedRow(){
TransactionTable table = (TransactionTable)view.getTransactionTable();
- TransactionTableModel model = table.getModel();
+ TransactionTableModel model = (TransactionTableModel)table.getModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
Object selectedValue = model.getElementAt(indexSelectedRow);
-
String message = null;
if (selectedValue instanceof Transaction) {
message = _("lima.question.remove.transaction");
@@ -88,11 +121,22 @@
_("lima.transaction.confirmdelete"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
-
+
+ try {
+ model.removeObject(selectedValue, indexSelectedRow);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove transaction or entry", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't remove transaction or entry", ex);
+ }
+
+ /*
if (selectedValue instanceof Transaction) {
// TODO EC-20100409 implements this
if (log.isWarnEnabled()) {
log.warn("TODO implement Transaction deletion");
+ model.removeTransaction(selectedValue);
}
}
else if (selectedValue instanceof Entry) {
@@ -100,7 +144,7 @@
if (log.isWarnEnabled()) {
log.warn("TODO implement Entry deletion");
}
- }
+ }*/
}
}
else {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-13 19:56:51 UTC (rev 2860)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-14 15:44:00 UTC (rev 2861)
@@ -82,7 +82,7 @@
* Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
* automatiquement une nouvelle ligne (une entrée comptable)
*/
- addMouseListener(getEmptyLineSelectionListener());
+ //addMouseListener(getEmptyLineSelectionListener());
/*
* Mod : il est possible d'activer cette option.
@@ -118,10 +118,10 @@
// Color transactions
- addColorTransaction();
- addColorNonBalancedTransaction();
+ // addColorTransaction();
+ // addColorNonBalancedTransaction();
}
-
+
/**
*
*/
@@ -156,7 +156,7 @@
* Cette méthode permet de colorer toutes les transactions dans le tableau
* afin de bien distinguer les transactions et entrées comptables.
*/
- protected void addColorTransaction() {
+ /* protected void addColorTransaction() {
if (colorTransaction != null) {
removeHighlighter(colorTransaction);
}
@@ -170,13 +170,13 @@
colorTransaction = new ColorHighlighter(predicate, new Color(222, 222,
222), null, null, null);
addHighlighter(colorTransaction);
- }
+ }*/
/**
* Permet de surligner une transaction dans le tableau lorsque cette dernière
* n'est pas équilibrée.
*/
- protected void addColorNonBalancedTransaction() {
+/* protected void addColorNonBalancedTransaction() {
if (colorBalance != null) {
removeHighlighter(colorBalance);
}
@@ -198,9 +198,9 @@
colorTransaction = new ColorHighlighter(predicate, new Color(255, 198,
209), null, null, null);
addHighlighter(colorTransaction);
- }
+ }*/
- @Override
+ /* @Override
public TransactionTableModel getModel() {
return (TransactionTableModel) this.dataModel;
}
@@ -210,20 +210,22 @@
return (TransactionSortedTableColumnModel) this.columnModel;
}
+*/
+ /*
public EmptyLineSelectionListener getEmptyLineSelectionListener() {
if (emptyLineSelectionListener == null) {
return new EmptyLineSelectionListener();
}
return emptyLineSelectionListener;
}
-
+*/
@Override
public void keyPressed(KeyEvent e) {
// VK_DELETE suppression de la transaction en cours
// ou de l'entree
if (e.getKeyCode() == KeyEvent.VK_DELETE) {
- handler.deleteSelectedRow();
+ // handler.deleteSelectedRow();
}
// Touche : insert ou ctrl+I
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-13 19:56:51 UTC (rev 2860)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-14 15:44:00 UTC (rev 2861)
@@ -315,6 +315,41 @@
return result;
}
+ /**
+ * @throws LimaException
+ */
+ public void addEmptyTransaction() throws LimaException{
+ /* Calling transaction service */
+ //TODO transaction = currentdate, current periode, current journal
+ Transaction transaction=null;
+ transactionService.createTransaction(transaction);
+ int row = transactionService.getAllTransactions().indexOf(transaction);
+ fireTableRowsInserted(row, row);
+ }
+
+
+
+ /**
+ * @throws LimaException
+ */
+ public void addEmptyEntry(Object value, int row) {
+ /* Calling transaction service */
+ //TODO transaction = currentdate, current periode, current journal
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+ Entry entry=null;
+ if (currentRow instanceof Transaction) {
+ Transaction currentTransaction = (Transaction)currentRow;
+ currentTransaction.addEntry(entry);
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //TODO recuperer l'entrée parente, ajouter entrée
+ }
+ fireTableRowsUpdated(row, row);
+ }
+
+
@Override
public void setValueAt(Object value, int row, int column) {
@@ -417,4 +452,35 @@
}
}
}
+
+ public Object getElementAt(int row){
+
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+ return currentRow;
+ }
+
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @param Object, int
+ * @throws LimaException
+ */
+ public void removeObject(Object object, int row) throws LimaException {
+ /* Calling journal service */
+
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+ if (currentRow instanceof Transaction) {
+ Transaction currentTransaction = (Transaction)currentRow;
+ transactionService.removeTransaction(currentTransaction);
+ fireTableRowsDeleted(row, row);
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //TODO supprimer l'entrée
+ }
+ }
}
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 2010-04-13 19:56:51 UTC (rev 2860)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-14 15:44:00 UTC (rev 2861)
@@ -265,7 +265,7 @@
lima.tab.home=Home
lima.tab.journal=Journal
lima.tab.lettering=Lettering
-lima.tab.period=
+lima.tab.period=Period
lima.tab.reports=Reports
lima.tab.result=Result
lima.tab.search.result=Search result
@@ -273,19 +273,19 @@
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=About Lima...
lima.to=To
-lima.transaction.column.account=
-lima.transaction.column.balance=
-lima.transaction.column.credit=
-lima.transaction.column.date=
-lima.transaction.column.debit=
-lima.transaction.column.description=
-lima.transaction.column.document=
-lima.transaction.column.entrybook=
-lima.transaction.column.period=
-lima.transaction.column.status=
+lima.transaction.column.account=Account
+lima.transaction.column.balance=Balance
+lima.transaction.column.credit=Credit
+lima.transaction.column.date=Date
+lima.transaction.column.debit=Debit
+lima.transaction.column.description=Description
+lima.transaction.column.document=Voucher
+lima.transaction.column.entrybook=Entrybook
+lima.transaction.column.period=Period
+lima.transaction.column.status=Status
lima.transaction.confirmdelete=
lima.transaction.entrybook=
-lima.transaction.period=
+lima.transaction.period=Period
lima.ui.add.account=Add account
lima.ui.add.journal=Add journal
lima.ui.block.timespan=Block period
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 2010-04-13 19:56:51 UTC (rev 2860)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-14 15:44:00 UTC (rev 2861)
@@ -20,7 +20,7 @@
lima.action.normalscreen.tip=Revenir en \u00E9cran normal
lima.add.entry=Ajouter une entr\u00E9e
lima.add.lettering=
-lima.add.transaction=
+lima.add.transaction=Ajouter une transaction
lima.all=Tous
lima.all.criteria=Tous les crit\u00E8res correspondent
lima.amount=Montant
@@ -83,7 +83,7 @@
lima.description=Description
lima.edit=Editer
lima.edit.transaction=Editer une transaction
-lima.entries=
+lima.entries=Entr\u00E9es comptable
lima.entries.addtransaction=Ajouter une transaction
lima.entries.lettering=Ajouter une lettre
lima.entries.searchtransaction=Recherche les transactions
@@ -263,19 +263,19 @@
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=A propos de Lima...
lima.to=A
-lima.transaction.column.account=
-lima.transaction.column.balance=
-lima.transaction.column.credit=
-lima.transaction.column.date=
-lima.transaction.column.debit=
-lima.transaction.column.description=
-lima.transaction.column.document=
-lima.transaction.column.entrybook=
-lima.transaction.column.period=
-lima.transaction.column.status=
+lima.transaction.column.account=Compte
+lima.transaction.column.balance=Balance
+lima.transaction.column.credit=Cr\u00E9dit
+lima.transaction.column.date=Date
+lima.transaction.column.debit=D\u00E9bit
+lima.transaction.column.description=Description
+lima.transaction.column.document=Document
+lima.transaction.column.entrybook=Journal
+lima.transaction.column.period=P\u00E9riode
+lima.transaction.column.status=Statut
lima.transaction.confirmdelete=
lima.transaction.entrybook=Journal
-lima.transaction.period=
+lima.transaction.period=P\u00E9riode
lima.ui.add.account=Ajouter un compte
lima.ui.add.journal=Ajouter un journal
lima.ui.block.timespan=Bloquer une p\u00E9riode mensuelle
1
0
r2860 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/account/model
by jpepin@users.chorem.org 13 Apr '10
by jpepin@users.chorem.org 13 Apr '10
13 Apr '10
Author: jpepin
Date: 2010-04-13 21:56:51 +0200 (Tue, 13 Apr 2010)
New Revision: 2860
Log:
resolution bug rafraichissement ui plan des comptes apres modification
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-12 15:46:09 UTC (rev 2859)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-13 19:56:51 UTC (rev 2860)
@@ -87,30 +87,34 @@
*/
@Override
public void createAccount(Account masterAccount, Account account) throws LimaException {
-
-
-
// test la validite du numero de compte
if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber());
+ throw new LimaBusinessException("Invalid AccountNumber : "
+ + account.getAccountNumber());
}
// test que le numero de compte est de type numeric
if (!StringUtils.isNumeric(account.getAccountNumber())){
- throw new LimaBusinessException("AccountNumber is not numeric : " + account.getAccountNumber());
+ throw new LimaBusinessException("AccountNumber is not numeric : "
+ + account.getAccountNumber());
}
- // TODO verifier que le numero de compte du fils commence par celui du pere
+ // test que le numero de compte du fils commence par celui du pere
// (peut etre trop specific à la compta francaise)
- if (masterAccount!=null && !account.getAccountNumber().startsWith(masterAccount.getAccountNumber())){
+ if (masterAccount!=null && !account.getAccountNumber().startsWith(
+ masterAccount.getAccountNumber())){
- throw new LimaBusinessException("Account Number not begin with the number account master :" + account.getAccountNumber());
+ throw new LimaBusinessException("" +
+ "Account Number not begin with the number account master :"
+ + account.getAccountNumber());
}
// Test que le compte master crée a un numéro entre 1 a 8
if (masterAccount==null && !account.getAccountNumber().matches("[1-8]")){
- throw new LimaBusinessException("Master account is not a digit between 1 to 8 :" + account.getAccountNumber());
+ throw new LimaBusinessException(
+ "Master account is not a digit between 1 to 8 :"
+ + account.getAccountNumber());
}
TopiaContext transaction = null;
@@ -123,7 +127,8 @@
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
List<Account> existingAccounts = accountDAO.findAllByAccountNumber(account.getAccountNumber());
if (CollectionUtils.isNotEmpty(existingAccounts)) {
- throw new LimaBusinessException(_("An account already exists with this number : %s", account.getAccountNumber()));
+ throw new LimaBusinessException(_(
+ "An account already exists with this number : %s", account.getAccountNumber()));
}
accountDAO.create(account);
@@ -619,6 +624,8 @@
// FIXME !IMPORTANT! check that subaccounts are also deleted
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
accountDAO.delete(account);
+ // commit
+ transaction.commitTransaction();
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -701,6 +708,8 @@
// update account
AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction);
accountDAO.update(account);
+ // commit
+ transaction.commitTransaction();
}
catch (TopiaException ex) {
if (transaction != null) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-12 15:46:09 UTC (rev 2859)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-13 19:56:51 UTC (rev 2860)
@@ -221,7 +221,8 @@
accountService.updateAccount(account);
int index = getIndexOfChild(path.getParentPath().getLastPathComponent(), account);
// TODO maybe not working if order change
- modelSupport.fireChildChanged(path.getParentPath(), index, account);
+ // modelSupport.fireChildChanged(path.getParentPath(), index, account);
+ modelSupport.fireTreeStructureChanged(path.getParentPath());
}
/**
1
0
r2859 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/account
by jpepin@users.chorem.org 12 Apr '10
by jpepin@users.chorem.org 12 Apr '10
12 Apr '10
Author: jpepin
Date: 2010-04-12 17:46:09 +0200 (Mon, 12 Apr 2010)
New Revision: 2859
Log:
tests metier de creation de compte ajouter
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-12 13:53:23 UTC (rev 2858)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-12 15:46:09 UTC (rev 2859)
@@ -88,14 +88,31 @@
@Override
public void createAccount(Account masterAccount, Account account) throws LimaException {
+
+
+
// test la validite du numero de compte
if (StringUtils.isBlank(account.getAccountNumber())) {
throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber());
}
+ // test que le numero de compte est de type numeric
+ if (!StringUtils.isNumeric(account.getAccountNumber())){
+ throw new LimaBusinessException("AccountNumber is not numeric : " + account.getAccountNumber());
+ }
+
// TODO verifier que le numero de compte du fils commence par celui du pere
// (peut etre trop specific à la compta francaise)
-
+ if (masterAccount!=null && !account.getAccountNumber().startsWith(masterAccount.getAccountNumber())){
+
+ throw new LimaBusinessException("Account Number not begin with the number account master :" + account.getAccountNumber());
+ }
+
+ // Test que le compte master crée a un numéro entre 1 a 8
+ if (masterAccount==null && !account.getAccountNumber().matches("[1-8]")){
+ throw new LimaBusinessException("Master account is not a digit between 1 to 8 :" + account.getAccountNumber());
+ }
+
TopiaContext transaction = null;
try {
// basic check done, make check in database
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-12 13:53:23 UTC (rev 2858)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-12 15:46:09 UTC (rev 2859)
@@ -25,6 +25,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
@@ -84,10 +85,17 @@
// add it
try {
accountsTreeTableModel.addAccount(treePath, newAccount);
- } catch (LimaException ex) {
+ } catch (LimaBusinessException ex) {
if (log.isErrorEnabled()) {
log.error("Can't add account", ex);
}
+ ErrorHelper.showErrorDialog(ex.getMessage(), ex);
+ }
+
+ catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add account", ex);
+ }
ErrorHelper.showErrorDialog("Can't add account", ex);
}
}
1
0