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
May 2010
- 2 participants
- 37 discussions
r2888 - 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/account lima-swing/src/main/java/org/chorem/lima/ui/account/model lima-swing/src/main/java/org/chorem/lima/ui/accountsreports
by jpepin@users.chorem.org 07 May '10
by jpepin@users.chorem.org 07 May '10
07 May '10
Author: jpepin
Date: 2010-05-07 20:27:12 +0200 (Fri, 07 May 2010)
New Revision: 2888
Url: http://chorem.org/repositories/revision/lima/2888
Log:
Suppression de la fiche d'identit?\195?\169 pour les comptes de tiers, am?\195?\169lioration visualisation des comptes
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-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
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-05-07 16:27:07 UTC (rev 2887)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-05-07 18:27:12 UTC (rev 2888)
@@ -22,7 +22,6 @@
import java.util.List;
import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Identity;
/**
* Account service.
@@ -47,7 +46,7 @@
*/
void createAccount(Account masterAccount, Account account) throws LimaException;
- void createSubLedger(Account masterAccount, Account account, Identity identity) throws LimaException;
+ void createSubLedger(Account masterAccount, Account account) throws LimaException;
void updateAccount(Account account) 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-05-07 16:27:07 UTC (rev 2887)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-05-07 18:27:12 UTC (rev 2888)
@@ -38,8 +38,6 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.EntryDAO;
-import org.chorem.lima.entity.Identity;
-import org.chorem.lima.entity.IdentityDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
@@ -135,7 +133,7 @@
* Permet de créer des comptes tiers
*/
@Override
- public void createSubLedger(Account masterAccount, Account account, Identity identity)
+ public void createSubLedger(Account masterAccount, Account account)
throws LimaException {
//check rules before create the account
@@ -160,11 +158,6 @@
accountDAO.create(account);
- IdentityDAO identityDAO =
- LimaCallaoDAOHelper.getIdentityDAO(transaction);
- identityDAO.create(identity);
- account.setIdentity(identity);
-
// check if the masteraccount exist;
if (masterAccount != null) {
masterAccount.addSubLedgers(account);
@@ -344,14 +337,6 @@
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- //Check if the account is a subledger
- Identity existIdentity = account.getIdentity();
- if (existIdentity != null) {
- // update identity
- IdentityDAO identityDAO =
- LimaCallaoDAOHelper.getIdentityDAO(transaction);
- identityDAO.update(existIdentity);
- }
// update account
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-07 16:27:07 UTC (rev 2887)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-07 18:27:12 UTC (rev 2888)
@@ -379,18 +379,20 @@
try {
topiaTransaction = rootContext.beginTransaction();
EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
-
- if (beginDate != null && endDate != null && account != null) {
+ TopiaQuery query = entryDAO.createQuery();
+
+ if (account != null) {
+ query
+ .add(Entry.ACCOUNT, account);
+ }
+ if (beginDate != null && endDate != null){
String transactionDateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE);
- TopiaQuery query = entryDAO.createQuery("E");
- query
- .add(Entry.ACCOUNT, account)
- .add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
+ query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
.addParam("beginDate", beginDate)
.addParam("endDate", endDate);
- entries=entryDAO.findAllByQuery(query);
}
-
+ entries=entryDAO.findAllByQuery(query);
+
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
for (Entry entry : entries) {
entry.getEntryBook();
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
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-05-07 16:27:07 UTC (rev 2887)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-05-07 18:27:12 UTC (rev 2888)
@@ -30,9 +30,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
-import org.chorem.lima.entity.Identity;
-import org.chorem.lima.entity.IdentityDAO;
-import org.chorem.lima.entity.IdentityImpl;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.ui.account.model.AccountTreeTableModel;
import org.chorem.lima.ui.account.AccountForm;
@@ -130,13 +127,10 @@
Account newAccount = new AccountImpl();
SubLedgerForm subledgerForm = new SubLedgerForm(view);
subledgerForm.setAccount(newAccount);
- Identity newIdentity = new IdentityImpl();
- subledgerForm.setIdentity(newIdentity);
// jaxx constructor don't call super() ?
subledgerForm.setLocationRelativeTo(view);
subledgerForm.setVisible(true);
newAccount=subledgerForm.getAccount();
- newIdentity=subledgerForm.getIdentity();
// null == cancel action
if (newAccount != null) {
@@ -147,7 +141,7 @@
// add it
try {
accountsTreeTableModel.
- addSubLedger(treePath, newAccount, newIdentity);
+ addSubLedger(treePath, newAccount);
} catch (LimaBusinessException ex) {
if (log.isErrorEnabled()) {
log.error("Can't add subledger", ex);
@@ -177,7 +171,7 @@
int selectedRow = view.getAccountsTreeTable().getSelectedRow();
TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // not null
Account selectedObject = (Account)treePath.getLastPathComponent();
- //TODO update Account or update SubLedger
+ //update Account or update SubLedger
if (selectedObject != null) {
// get current selection path
if ( selectedRow != -1) {
@@ -185,43 +179,42 @@
} else {
treePath = new TreePath(accountsTreeTableModel.getRoot());
}
- //test if selectedrow is account or ledger
- Identity existIdentity = selectedObject.getIdentity();
- // if is an account or subaccount
- if (existIdentity == null) {
- AccountForm accountForm = new AccountForm(view);
- accountForm.setAccount(selectedObject);
- // jaxx constructor don't call super() ?
- accountForm.setLocationRelativeTo(view);
- accountForm.setVisible(true);
- // null == cancel action
- selectedObject = accountForm.getAccount();
+ //test if selectedrow is account or ledger
+
+ if (selectedObject.getGeneralLedger()==null){
+ //TODO pepin 20100507
+ AccountForm accountForm = new AccountForm(view);
+ accountForm.setAccount(selectedObject);
+ // jaxx constructor don't call super() ?
+ accountForm.setLocationRelativeTo(view);
+ accountForm.setVisible(true);
+ // null == cancel action
+ selectedObject = accountForm.getAccount();
}
- // else is a subledger
- else{
- SubLedgerForm subLedgerForm = new SubLedgerForm(view);
- subLedgerForm.setAccount(selectedObject);
- subLedgerForm.setIdentity(existIdentity);
- // jaxx constructor don't call super() ?
- subLedgerForm.setLocationRelativeTo(view);
- subLedgerForm.setVisible(true);
- // null == cancel action
- selectedObject = subLedgerForm.getAccount();
- }
- //if action confirmed
- if (selectedObject != null){
- // update it
- try {
-
- accountsTreeTableModel.
- updateAccount(treePath, selectedObject);
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add update", ex);
- }
- ErrorHelper.showErrorDialog("Can't add update", ex);
- }
+ // else is a subledger
+ else{
+ SubLedgerForm subLedgerForm = new SubLedgerForm(view);
+ subLedgerForm.setAccount(selectedObject);
+ // jaxx constructor don't call super() ?
+ subLedgerForm.setLocationRelativeTo(view);
+ subLedgerForm.setVisible(true);
+ // null == cancel action
+ selectedObject = subLedgerForm.getAccount();
+ }
+ //if action confirmed
+ if (selectedObject != null){
+ // update it
+ try {
+
+ accountsTreeTableModel.
+ updateAccount(treePath, selectedObject);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add update", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add update", ex);
}
+ }
}
}
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-05-07 16:27:07 UTC (rev 2887)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-05-07 18:27:12 UTC (rev 2888)
@@ -18,7 +18,6 @@
<JDialog defaultCloseOperation="dispose_on_close" modal="true">
<org.chorem.lima.entity.Account id="account" javaBean='null'/>
- <org.chorem.lima.entity.Identity id="identity" javaBean='null'/>
<Boolean id="addState" javaBean='true'/>
@@ -66,128 +65,19 @@
onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/>
</cell>
</row>
- <!-- NAME CONTACT-->
+ <!-- Lien Fiche 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())' />
+ <JTextField id="thirdPartyTextField" text="{getAccount().getThirdParty()}"/>
+ <javax.swing.text.Document javaBean="getThirdPartyTextField().getDocument()"
+ onInsertUpdate='getAccount().setThirdParty(getThirdPartyTextField().getText())'
+ onRemoveUpdate='getAccount().setThirdParty(getThirdPartyTextField().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(getSiretIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setSiret(getSiretIdentityTextField().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(getCountryIdentityTextField().getText())'
- onRemoveUpdate='getIdentity().setCountry(getCountryIdentityTextField().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/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-05-07 16:27:07 UTC (rev 2887)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-05-07 18:27:12 UTC (rev 2888)
@@ -31,7 +31,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
-import org.chorem.lima.entity.Identity;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.account.AccountViewHandler;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
@@ -231,13 +230,13 @@
* @param account
* @throws LimaException
*/
- public void addSubLedger(TreePath path, Account account, Identity identity) 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, identity);
+ accountService.createSubLedger(parentAccount, account);
int index = getIndexOfChild(path.getLastPathComponent(), account);
modelSupport.fireChildAdded(path, index, account);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-07 16:27:07 UTC (rev 2887)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-07 18:27:12 UTC (rev 2888)
@@ -178,31 +178,33 @@
public void setBeginDate(Date date){
selectedBeginDate = date;
- log.debug(date);
- }
+ cacheDataList=getDataList();
+ fireTableDataChanged(); }
public void setEndDate(Date date){
selectedEndDate = date;
- log.debug(date);
+ cacheDataList=getDataList();
+ fireTableDataChanged();
}
- /**
- * @param entryBook
- * @throws LimaException
- */
+
public void setAccount(Account account) {
- if (account != null){
- selectedAccount = account;
- try {
- log.debug(selectedAccount);
- cacheDataList = financialTransactionService.getAllEntriesForAccount(selectedAccount, selectedBeginDate, selectedEndDate);
+ selectedAccount = account;
+ cacheDataList=getDataList();
+ fireTableDataChanged();
+ }
+
+ public List<Entry> getDataList(){
+ List<Entry> results = new ArrayList<Entry>();
+ try {
+ results = financialTransactionService.getAllEntriesForAccount(selectedAccount, selectedBeginDate, selectedEndDate);
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
}
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
- }
- ErrorHelper.showErrorDialog("Can't get entries list", eee);
- }
+ ErrorHelper.showErrorDialog("Can't get entries list", eee);
}
+ return results;
}
}
1
0
r2887 - 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/accountsreports lima-swing/src/main/resources/i18n
by jpepin@users.chorem.org 07 May '10
by jpepin@users.chorem.org 07 May '10
07 May '10
Author: jpepin
Date: 2010-05-07 18:27:07 +0200 (Fri, 07 May 2010)
New Revision: 2887
Url: http://chorem.org/repositories/revision/lima/2887
Log:
recherches des entr?\195?\169es d'un compte via une p?\195?\169riode d?\195?\169finie par deux dates
Modified:
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/accountsreports/AccountsReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-06 16:48:20 UTC (rev 2886)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-07 16:27:07 UTC (rev 2887)
@@ -19,6 +19,7 @@
package org.chorem.lima.business;
+import java.util.Date;
import java.util.List;
import org.chorem.lima.entity.Account;
@@ -89,5 +90,8 @@
void removeEntry(Entry entry) throws LimaException;
List<Entry> getAllEntriesForAccount(Account account) throws LimaException;
+
+ List<Entry> getAllEntriesForAccount(Account account, Date beginDate, Date endDate) throws LimaException;
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-06 16:48:20 UTC (rev 2886)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-07 16:27:07 UTC (rev 2887)
@@ -21,6 +21,7 @@
import static org.nuiton.i18n.I18n._;
+import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
@@ -367,16 +368,29 @@
@Override
public List<Entry> getAllEntriesForAccount(Account account) throws LimaException {
+
+ return getAllEntriesForAccount(account, null, null);
+ }
+
+ @Override
+ public List<Entry> getAllEntriesForAccount(Account account, Date beginDate, Date endDate) throws LimaException {
List<Entry> entries = null;
- TopiaContext topiaContext = null;
+ TopiaContext topiaTransaction = null;
try {
- // basic check done, make check in database
- // TODO move it into JTA
- topiaContext = rootContext.beginTransaction();
+ topiaTransaction = rootContext.beginTransaction();
+ EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
+
+ if (beginDate != null && endDate != null && account != null) {
+ String transactionDateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE);
+ TopiaQuery query = entryDAO.createQuery("E");
+ query
+ .add(Entry.ACCOUNT, account)
+ .add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
+ .addParam("beginDate", beginDate)
+ .addParam("endDate", endDate);
+ entries=entryDAO.findAllByQuery(query);
+ }
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- entries = entryDAO.findAllByAccount(account);
-
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
for (Entry entry : entries) {
entry.getEntryBook();
@@ -384,13 +398,13 @@
}
// commit
- topiaContext.commitTransaction();
+ topiaTransaction.commitTransaction();
}
catch (TopiaException ex) {
- doCatch(topiaContext, ex, log);
+ doCatch(topiaTransaction, ex, log);
}
finally {
- doFinally(topiaContext, log);
+ doFinally(topiaTransaction, log);
}
return entries;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-06 16:48:20 UTC (rev 2886)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-07 16:27:07 UTC (rev 2887)
@@ -63,6 +63,12 @@
/** Account. */
protected Account selectedAccount;
+ /** Begin Date. */
+ protected Date selectedBeginDate;
+
+ /** EndDate. */
+ protected Date selectedEndDate;
+
/** data cache */
protected List<Entry> cacheDataList;
@@ -121,36 +127,7 @@
}
return res;
}
-
- @Override
- public Class<?> getColumnClass(int column) {
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Date.class;
- break;
- case 1:
- result = EntryBook.class;
- break;
- case 2:
- result = String.class;
- break;
- case 3:
- result = String.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = String.class;
- break;
- }
-
- return result;
- }
-
@Override
public Object getValueAt(int row, int column) {
Object result = null;
@@ -199,6 +176,16 @@
return false;
}
+ public void setBeginDate(Date date){
+ selectedBeginDate = date;
+ log.debug(date);
+ }
+
+ public void setEndDate(Date date){
+ selectedEndDate = date;
+ log.debug(date);
+ }
+
/**
* @param entryBook
* @throws LimaException
@@ -208,7 +195,7 @@
selectedAccount = account;
try {
log.debug(selectedAccount);
- cacheDataList = financialTransactionService.getAllEntriesForAccount(selectedAccount);
+ cacheDataList = financialTransactionService.getAllEntriesForAccount(selectedAccount, selectedBeginDate, selectedEndDate);
}
catch (LimaException eee) {
if (log.isErrorEnabled()) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-05-06 16:48:20 UTC (rev 2886)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-05-07 16:27:07 UTC (rev 2887)
@@ -32,13 +32,15 @@
<JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/>
</cell>
<cell>
- <JLabel text="TODO begincalendarPanel"/>
+ <org.jdesktop.swingx.JXDatePicker id="beginDatePicker"
+ onActionPerformed="getModelAccountsReportsTable().setBeginDate(beginDatePicker.getDate())" />
</cell>
<cell>
<JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/>
</cell>
<cell>
- <JLabel text="TODO endcalendarPanel"/>
+ <org.jdesktop.swingx.JXDatePicker id="endDatePicker"
+ onActionPerformed="getModelAccountsReportsTable().setEndDate(endDatePicker.getDate())"/>
</cell>
<cell>
<JLabel id="accountSelectorLabel" text="lima.account"/>
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-05-06 16:48:20 UTC (rev 2886)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-05-07 16:27:07 UTC (rev 2887)
@@ -21,8 +21,8 @@
lima.account.type3=Produit
lima.account.type4=Charge
lima.accounts=
-lima.accountsreports.begincalendar=
-lima.accountsreports.endcalendar=
+lima.accountsreports.begincalendar=Date d\u00E9but
+lima.accountsreports.endcalendar=Date fin
lima.actif=Actif
lima.action.commandline.disable.main.ui=Ne pas lancer l'ui
lima.action.commandline.help=Afficher l'aide en console
1
0
06 May '10
Author: jpepin
Date: 2010-05-06 18:48:20 +0200 (Thu, 06 May 2010)
New Revision: 2886
Url: http://chorem.org/repositories/revision/lima/2886
Log:
Visualisation des comptes
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
Modified:
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/MainView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.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
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/FinancialTransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-06 16:48:20 UTC (rev 2886)
@@ -21,6 +21,7 @@
import java.util.List;
+import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
@@ -86,5 +87,7 @@
void updateEntry(Entry entry) throws LimaException;
void removeEntry(Entry entry) throws LimaException;
+
+ List<Entry> getAllEntriesForAccount(Account account) throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-06 16:48:20 UTC (rev 2886)
@@ -364,4 +364,35 @@
doFinally(topiaContext, log);
}
}
+
+ @Override
+ public List<Entry> getAllEntriesForAccount(Account account) throws LimaException {
+ List<Entry> entries = null;
+ TopiaContext topiaContext = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ topiaContext = rootContext.beginTransaction();
+
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ entries = entryDAO.findAllByAccount(account);
+
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ for (Entry entry : entries) {
+ entry.getEntryBook();
+ entry.getFinancialTransaction().getTransactionDate();
+ }
+
+ // commit
+ topiaContext.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+
+ return entries;
+ }
}
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-05-06 16:48:20 UTC (rev 2886)
@@ -131,13 +131,15 @@
<JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)'
actionIcon='lettering'/>
</JMenu>
+ <!--
<JMenu text="lima.view">
<JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten"
onItemStateChanged='getHandler().onChangeView(this)'
selected="false" actionIcon='view'/>
</JMenu>
-
+ -->
<JMenu text="lima.reports">
+ <JMenuItem text="lima.accounts" onActionPerformed='getHandler().showAccountReports(this)'/>
<JMenuItem text="lima.reports" onActionPerformed='getHandler().showReportsView(this)' actionIcon='rapport'/>
<JMenuItem text="lima.balance" onActionPerformed='getHandler().showBalanceView(this)'/>
<JMenuItem text="lima.bilan" onActionPerformed='getHandler().showBilanView(this)'/>
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-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-05-06 16:48:20 UTC (rev 2886)
@@ -36,6 +36,7 @@
import org.chorem.lima.LimaConfig;
import org.chorem.lima.LimaContext;
import org.chorem.lima.ui.account.AccountView;
+import org.chorem.lima.ui.accountsreports.AccountsReportsView;
import org.chorem.lima.ui.entrybook.EntryBookView;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
import org.chorem.lima.ui.transaction.FinancialTransactionView;
@@ -271,7 +272,56 @@
HomeView homeView = new HomeView(mainView);
mainView.showTab(_("lima.tab.home"), homeView, false);
}
+
+ /**
+ * Show fiscal period view to create or block a period
+ * @param rootContext
+ */
+ public void showFiscalPeriodView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView);
+ mainView.showTab(_("lima.tab.fiscalperiod"), fiscalPeriodView);
+ }
+ /**
+ * Show account tree table view to create or modify accounts
+ * @param rootContext
+ */
+ public void showAccountView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ AccountView accountView = new AccountView(mainView);
+ mainView.showTab(_("lima.tab.account"), accountView);
+ }
+
+ /**
+ * Show account table report to view an account on a period
+ * @param rootContext
+ */
+ public void showAccountReports(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ AccountsReportsView accountsReportsView = new AccountsReportsView(mainView);
+ mainView.showTab(_("lima.tab.accounts"), accountsReportsView);
+ }
+
+ /**
+ * Show financial transactions view to create entries
+ * @param rootContext
+ */
+ public void showTransactionView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ FinancialTransactionView transactionView = new FinancialTransactionView(mainView);
+ mainView.showTab(_("lima.tab.transaction"), transactionView);
+ }
+ /**
+ * Show EntryBook view to create entry book
+ * @param rootContext
+ */
+ public void showJournalView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ EntryBookView entryBookView = new EntryBookView(mainView);
+ mainView.showTab(_("lima.tab.journal"), entryBookView);
+ }
+
public void showBilanView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
// BilanView bilanView = new BilanView(mainView);
@@ -284,12 +334,6 @@
// mainView.showTab(_("lima.tab.balance"), balanceView);
}
- public void showFiscalPeriodView(JAXXContext rootContext) {
- MainView mainView = getUI(rootContext);
- FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView);
- mainView.showTab(_("lima.tab.fiscalperiod"), fiscalPeriodView);
- }
-
public void showClosureTimeSpanView(JAXXContext rootContext) {
//getClosureView().initBlockForm();
}
@@ -318,25 +362,6 @@
mainView.showTab(_("lima.tab.search.result"), searchResultView);*/
}
- public void showAccountView(JAXXContext rootContext) {
- MainView mainView = getUI(rootContext);
- AccountView accountView = new AccountView(mainView);
- mainView.showTab(_("lima.tab.account"), accountView);
- }
-
-
- public void showTransactionView(JAXXContext rootContext) {
- MainView mainView = getUI(rootContext);
- FinancialTransactionView transactionView = new FinancialTransactionView(mainView);
- mainView.showTab(_("lima.tab.transaction"), transactionView);
- }
-
- public void showJournalView(JAXXContext rootContext) {
- MainView mainView = getUI(rootContext);
- EntryBookView entryBookView = new EntryBookView(mainView);
- mainView.showTab(_("lima.tab.journal"), entryBookView);
- }
-
public void showSearchView(JAXXContext rootContext) {
/*if (!getSearchView().isEnabled()) {
getSearchView().setEnabled(true);
@@ -355,38 +380,5 @@
//ResultView resultView = new ResultView(mainView);
// mainView.showTab(_("lima.tab.result"), resultView);
}
-
- /**
- * Called by menuitem "Vue a plat".
- *
- * Mais le fonctionnement est a revoir, car un peu trop de code...
- *
- * @param rootContext
- */
- protected void onChangeView(JAXXContext rootContext) {
- /*if (log.isDebugEnabled()) {
- log.debug("onChangeView : ");
- }
- transactionView = getTransactionView();
- searchResultView = getSearchResultView();
- if (viewFlatten.getState()) {
- // View not flatten
- if (log.isDebugEnabled()) {
- log.debug("onChangeView : setModel : getSortedModel");
- }
- transactionView.getTransactionTable().setModel(transactionView.getSortedModel());
- searchResultView.getTransactionTable().setModel(searchResultView.getSortedModel());
- } else {
- // View Flatten
- if (log.isDebugEnabled()) {
- log.debug("onChangeView : setModel : getFlattenModel");
- }
- transactionView.getTransactionTable().setModel(transactionView.getFlattenModel());
- searchResultView.getTransactionTable().setModel(searchResultView.getFlattenModel());
- }
- // Pack all columns
- transactionView.getTransactionTable().packAll();
- searchResultView.getTransactionTable().packAll();*/
- }
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-06 16:48:20 UTC (rev 2886)
@@ -0,0 +1,221 @@
+/*
+ * *##% 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.accountsreports;
+
+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.EntryBookService;
+import org.chorem.lima.business.FinancialTransactionService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * Entry book table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision: 2865 $
+ *
+ * Last update : $Date: 2010-04-19 15:19:30 +0200 (lun. 19 avril 2010) $
+ * By : $Author: jpepin $
+ */
+public class AccountsReportsTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 7578692417919755647L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class);
+
+ /** Services. */
+ protected FinancialTransactionService financialTransactionService;
+
+ /** Account. */
+ protected Account selectedAccount;
+
+ /** data cache */
+ protected List<Entry> cacheDataList;
+
+ /**
+ * Constructor.
+ */
+ public AccountsReportsTableModel() {
+
+ financialTransactionService = LimaServiceFactory.getInstance().getTransactionService();
+ }
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ // just prevent too much result
+ if (selectedAccount != null) {
+ result = cacheDataList.size();
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No account selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 6;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = "n/a";
+ switch (column) {
+ case 0:
+ res = _("lima.transaction.column.date"); //Date
+ break;
+ case 1:
+ res = _("lima.transaction.column.entrybook"); //EntryBook
+ break;
+ case 2:
+ res = _("lima.transaction.column.voucher"); // Voucher
+ break;
+ case 3:
+ res = _("lima.transaction.column.description"); //Description
+ break;
+ case 4:
+ res = _("lima.transaction.column.debit"); //Debit
+ break;
+ case 5:
+ res = _("lima.transaction.column.credit"); //Credit
+ break;
+ }
+ return res;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+
+ Class<?> result = null;
+
+ switch (column) {
+ case 0:
+ result = Date.class;
+ break;
+ case 1:
+ result = EntryBook.class;
+ break;
+ case 2:
+ result = String.class;
+ break;
+ case 3:
+ result = String.class;
+ break;
+ case 4:
+ result = String.class;
+ break;
+ case 5:
+ result = String.class;
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ Object result = null;
+ if(selectedAccount != null) {
+ Entry currentRow = cacheDataList.get(row);
+
+ switch (column) {
+ case 0:
+ result = currentRow.getFinancialTransaction().getTransactionDate();
+ break;
+ case 1:
+ if (currentRow.getEntryBook() != null){
+ result = currentRow.getEntryBook().getCode();
+ }
+ else {
+ result = null;
+ }
+ break;
+ case 2:
+ result = currentRow.getVoucher();
+ break;
+ case 3:
+ result = currentRow.getDescription();
+ break;
+ case 4:
+ result = currentRow.getDebit() ? currentRow.getAmount() : 0;
+ break;
+ case 5:
+ result = currentRow.getDebit() ? 0 : currentRow.getAmount();
+ break;
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No Account selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // Just read, no write
+ return false;
+ }
+
+ /**
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void setAccount(Account account) {
+ if (account != null){
+ selectedAccount = account;
+ try {
+ log.debug(selectedAccount);
+ cacheDataList = financialTransactionService.getAllEntriesForAccount(selectedAccount);
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+ ErrorHelper.showErrorDialog("Can't get entries list", eee);
+ }
+ }
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-05-06 16:48:20 UTC (rev 2886)
@@ -0,0 +1,68 @@
+<!-- ##% 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.
+ ##% -->
+
+<Table>
+ <AccountsReportsViewHandler id="handler" javaBean="new AccountsReportsViewHandler(this)" />
+ <Boolean id="selectedRow" javaBean="false" />
+ <org.chorem.lima.ui.transaction.model.AccountComboBoxModel id="modelAccounts"/>
+ <org.chorem.lima.ui.accountsreports.AccountsReportsTableModel id="modelAccountsReportsTable"/>
+ <script>
+ <![CDATA[
+
+ import org.chorem.lima.entity.Account;
+
+ ]]>
+ </script>
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell>
+ <JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/>
+ </cell>
+ <cell>
+ <JLabel text="TODO begincalendarPanel"/>
+ </cell>
+ <cell>
+ <JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/>
+ </cell>
+ <cell>
+ <JLabel text="TODO endcalendarPanel"/>
+ </cell>
+ <cell>
+ <JLabel id="accountSelectorLabel" text="lima.account"/>
+ </cell>
+ <cell>
+ <JComboBox id="accountSelectorComboBox"
+ model="{getModelAccounts()}"
+ renderer="{new org.chorem.lima.ui.transaction.model.AccountRenderer()}"
+ onItemStateChanged="getModelAccountsReportsTable().setAccount((Account) event.getItem())"
+ editable="false"
+ />
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1" weighty="1" rows="3" columns="7">
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="accountsReportsTable" rowHeight="24"
+ model="{getModelAccountsReportsTable()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ columnControlVisible="true"/>
+ <javax.swing.ListSelectionModel javaBean="getAccountsReportsTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(accountsReportsTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-05-06 16:48:20 UTC (rev 2886)
@@ -0,0 +1,54 @@
+/* *##% 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.accountsreports;
+
+import static org.nuiton.i18n.I18n._;
+
+
+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.FinancialTransaction;
+import org.chorem.lima.ui.transaction.table.FinancialTransactionTable;
+import org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * Handler associated with accounts reports view.
+ *
+ * @author chatellier
+ * @version $Revision: 2884 $
+ *
+ * Last update : $Date: 2010-05-06 11:57:19 +0200 (jeu. 06 mai 2010) $
+ * By : $Author: jpepin $
+ */
+public class AccountsReportsViewHandler {
+
+ /** log. */
+ private static final Log log =
+ LogFactory.getLog(AccountsReportsViewHandler.class);
+
+ protected AccountsReportsView view;
+
+ protected AccountsReportsViewHandler(AccountsReportsView view) {
+ this.view = view;
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-05-06 16:48:20 UTC (rev 2886)
@@ -32,7 +32,7 @@
import org.chorem.lima.util.ErrorHelper;
/**
- * Handler associated with account view.
+ * Handler associated with financial transaction view.
*
* @author chatellier
* @version $Revision$
Modified: 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/FinancialTransactionTable.java 2010-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-05-06 16:48:20 UTC (rev 2886)
@@ -62,83 +62,26 @@
/**
*/
- public FinancialTransactionTable(FinancialTransactionViewHandler handler/*
- TransactionSortedTableColumnModel columnModel*/) {
- //super(model, columnModel);
+ public FinancialTransactionTable(FinancialTransactionViewHandler handler) {
this.handler = handler;
- /*
- * New Table Header
- */
- //header renderer getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
- //getTableHeader().addMouseListener(new TransactionHeaderListener(this));
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());*/
-
+
//Get new date editor
setDefaultEditor(Date.class, new DateTableCellEditor());
//Get new entry book editor
setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
//Get new account editor
setDefaultEditor(Account.class, new AccountTableCellEditor());
-
+
//highlight financial financial transactions
addColorTransaction();
// highlight unbalanced financial transactions
- addColorNonBalancedTransaction();
+ 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.
* On récupère la première cellule, on vérifie que c'est une date
@@ -191,24 +134,6 @@
addHighlighter(colorTransaction);
}
- /* @Override
- public FinancialTransactionTableModel getModel() {
- return (FinancialTransactionTableModel) this.dataModel;
- }*/
-
- /* @Override
- public TransactionSortedTableColumnModel getColumnModel() {
- return (TransactionSortedTableColumnModel) this.columnModel;
- }*/
-
- /*
- public EmptyLineSelectionListener getEmptyLineSelectionListener() {
- if (emptyLineSelectionListener == null) {
- return new EmptyLineSelectionListener();
- }
- return emptyLineSelectionListener;
- }
-*/
/**
* for each action combination key are think
* for extend keyboard and laptop keyboard
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-06 16:48:20 UTC (rev 2886)
@@ -120,7 +120,6 @@
List<Object> results = new ArrayList<Object>();
try {
- log.debug("CHARGE DEBUT");
List<FinancialTransaction> financialtransactions =
transactionService.getAllFinancialTransactionsForFinancialPeriod(
selectedFinancialPeriod);
@@ -128,8 +127,6 @@
results.add(financialtransaction);
results.addAll(financialtransaction.getEntry());
}
- log.debug("CHARGE £FIN");
-
}
catch (LimaException eee) {
if (log.isErrorEnabled()) {
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-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-05-06 16:48:20 UTC (rev 2886)
@@ -7,6 +7,9 @@
Exercice=
Global\ lima\ exception=
Loading\ accounting...=
+TODO\ begincalendarPanel=
+TODO\ endcalendarPanel=
+calendarPanel\ TODO=
lima.about.message=
lima.account=Account
lima.account.label=Label
@@ -17,6 +20,9 @@
lima.account.type3=
lima.account.type4=
lima.accountplan=Plan de comptes
+lima.accounts=
+lima.accountsreports.begincalendar=
+lima.accountsreports.endcalendar=
lima.actif=Asset
lima.action.commandline.disable.main.ui=Do not launch main ui
lima.action.commandline.help=Show help in console
@@ -295,6 +301,7 @@
lima.subledger.type=
lima.success=Success
lima.tab.account=Account
+lima.tab.accounts=
lima.tab.balance=Balance
lima.tab.bilan=Results
lima.tab.closure=Closure
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-05-06 10:23:43 UTC (rev 2885)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-05-06 16:48:20 UTC (rev 2886)
@@ -6,6 +6,9 @@
Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
Global\ lima\ exception=
Loading\ accounting...=
+TODO\ begincalendarPanel=
+TODO\ endcalendarPanel=
+calendarPanel\ TODO=
lima.about.message=\u00C0 propos de Lima
lima.account=Compte
lima.account.label=Libell\u00E9
@@ -17,6 +20,9 @@
lima.account.type2=Passif
lima.account.type3=Produit
lima.account.type4=Charge
+lima.accounts=
+lima.accountsreports.begincalendar=
+lima.accountsreports.endcalendar=
lima.actif=Actif
lima.action.commandline.disable.main.ui=Ne pas lancer l'ui
lima.action.commandline.help=Afficher l'aide en console
@@ -279,6 +285,7 @@
lima.subledger.type=
lima.success=Succ\u00E8s
lima.tab.account=Plan Comptable
+lima.tab.accounts=
lima.tab.balance=Balance
lima.tab.bilan=Bilan
lima.tab.blocked=Block\u00E9
1
0
r2885 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table
by jpepin@users.chorem.org 06 May '10
by jpepin@users.chorem.org 06 May '10
06 May '10
Author: jpepin
Date: 2010-05-06 12:23:43 +0200 (Thu, 06 May 2010)
New Revision: 2885
Url: http://chorem.org/repositories/revision/lima/2885
Log:
Syst?\195?\168me de cache sur la liste des entr?\195?\169es et transactions
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-06 09:57:19 UTC (rev 2884)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-06 10:23:43 UTC (rev 2885)
@@ -120,6 +120,7 @@
List<Object> results = new ArrayList<Object>();
try {
+ log.debug("CHARGE DEBUT");
List<FinancialTransaction> financialtransactions =
transactionService.getAllFinancialTransactionsForFinancialPeriod(
selectedFinancialPeriod);
@@ -127,6 +128,8 @@
results.add(financialtransaction);
results.addAll(financialtransaction.getEntry());
}
+ log.debug("CHARGE £FIN");
+
}
catch (LimaException eee) {
if (log.isErrorEnabled()) {
@@ -225,7 +228,7 @@
// just prevent too much result
if (selectedFinancialPeriod != null) {
- cacheDataList = getDataList();
+ //cacheDataList = getDataList();
result = cacheDataList.size();
}
else {
@@ -334,8 +337,9 @@
public void setFinancialPeriod(FinancialPeriod financialPeriod){
-
+
selectedFinancialPeriod = financialPeriod;
+ cacheDataList = getDataList();
fireTableDataChanged();
}
@@ -379,6 +383,8 @@
financialTransaction.setTransactionDate(transactionDate);
// create it
transactionService.createFinancialTransaction(financialTransaction);
+ //on recharge la liste
+ cacheDataList = getDataList();
int row = getDataList().indexOf(financialTransaction);
fireTableRowsInserted(row, row);
//fireTableDataChanged();
@@ -409,6 +415,8 @@
//create it
entry.setFinancialTransaction(currentTransaction);
transactionService.createEntry(entry);
+ //on recharge la liste
+ cacheDataList = getDataList();
fireTableDataChanged();
}
@@ -480,8 +488,6 @@
log.debug("Can't update financial transaction", e);
}
}
- //update the financial transaction row
- //fireTableRowsUpdated(row, row);
}
else if (currentRow instanceof Entry) {
Entry currentEntry = (Entry)currentRow;
@@ -522,6 +528,8 @@
int financialTransactionRow =
getDataList().indexOf(((Entry) currentRow).
getFinancialTransaction());
+ //on recharge la liste
+ cacheDataList = getDataList();
fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
}
else {
@@ -556,6 +564,8 @@
Entry currentEntry = (Entry)currentRow;
transactionService.removeEntry(currentEntry);
}
+ //on recharge la liste
+ cacheDataList = getDataList();
fireTableRowsDeleted(row, getRowCount());
}
1
0
Author: jpepin
Date: 2010-05-06 11:57:19 +0200 (Thu, 06 May 2010)
New Revision: 2884
Url: http://chorem.org/repositories/revision/lima/2884
Log:
Coloration des transactions financieres, ajout de comportements au clavier, resolution bug suppression d'une transaction financiere contenant des entr?\195?\169es, ajout r?\195?\168gles de v?\195?\169rification
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/bilan/
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/
trunk/lima-swing/src/main/java/org/chorem/lima/listener/
trunk/lima-swing/src/main/java/org/chorem/lima/table/
trunk/lima-swing/src/main/java/org/chorem/lima/tree/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/pom.xml
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/entrybook/EntryBookView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx
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
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -19,7 +19,9 @@
package org.chorem.lima.business;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.nuiton.topia.TopiaContext;
@@ -36,5 +38,6 @@
public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException;
public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException;
public void removeEntryBookRules(EntryBook entryBook, TopiaContext topiaTransaction) throws LimaException;
-
+ public void checkFinancialPeriodBlockedWithEntry(Entry entry) throws LimaException;
+ public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -27,8 +27,10 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ejb.AccountServiceImpl;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
@@ -137,6 +139,26 @@
}
/**
+ * check if financial period of an entry is blocked
+ */
+ @Override
+ public void checkFinancialPeriodBlockedWithEntry(Entry entry) throws LimaException {
+ if (entry.getFinancialTransaction().getFinancialPeriod().getLocked()){
+ throw new LimaBusinessException("The financial period is blocked");
+ }
+ }
+
+ /**
+ * check if financial period of a financial transaction is blocked
+ */
+ @Override
+ public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException {
+ if (financialTransaction.getFinancialPeriod().getLocked()){
+ throw new LimaBusinessException("The financial period is blocked");
+ }
+ }
+
+ /**
* Generic code used to rollback a transaction.
*
* TODO : replace this by JTA
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -157,6 +157,7 @@
}
}
+
/**
* Generic code used to rollback a transaction.
*
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -27,16 +27,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountingRules;
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.Entry;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionDAO;
@@ -45,7 +44,6 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
/**
* Cette classe permet la création d'une transaction comptable dans l'application.
@@ -63,6 +61,8 @@
LogFactory.getLog(FinancialTransactionServiceImpl.class);
private TopiaContext rootContext;
+
+ protected AccountingRules accountingRules;
public FinancialTransactionServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -73,6 +73,7 @@
log.error("Can't init topia context", ex);
}
}
+ accountingRules = config.getAccountingRules();
}
/**
@@ -82,7 +83,9 @@
@Override
public void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
-
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
+
TopiaContext topiaContext = null;
try {
// basic check done, make check in database
@@ -216,6 +219,7 @@
entry.getEntryBook();
entry.getAccount();
entry.getFinancialTransaction();
+ entry.getFinancialTransaction().getFinancialPeriod();
}
}
}
@@ -233,7 +237,8 @@
@Override
public void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
- // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
TopiaContext topiaTransaction = null;
try {
@@ -255,13 +260,15 @@
@Override
public void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
- // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
-
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
+
TopiaContext topiaTransaction = null;
try {
topiaTransaction = rootContext.beginTransaction();
FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
- transactionDAO.delete(financialtransaction);
+ FinancialTransaction financialTransaction2 = transactionDAO.findByTopiaId(financialtransaction.getTopiaId());
+ transactionDAO.delete(financialTransaction2);
// commit
topiaTransaction.commitTransaction();
}
@@ -278,6 +285,10 @@
@Override
public void removeEntry(Entry entry) throws LimaException {
+
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithEntry(entry);
+
TopiaContext topiaContext = null;
try {
// basic check done, make check in database
@@ -299,6 +310,10 @@
@Override
public void updateEntry(Entry entry) throws LimaException {
+
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithEntry(entry);
+
TopiaContext topiaContext = null;
try {
// TODO move it into JTA
@@ -325,50 +340,10 @@
*/
@Override
- public void createEntry(Entry entry /*String description, String amount, boolean debit,
- String lettering, String detail, Transaction transaction,
- Account account*/) throws LimaException {
- /*String result = isCorrectEntry(transaction, account);
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryDAO entryDAO = LimaCallaoDAOHelper
- .getEntryDAO(topiaContext);
- // Creation de l'entrée comptable
- Entry newEntry = entryDAO.create();
- newEntry.setDescription(description);
- // On formate le nombre
- newEntry.setAmount(numberUtil.format(amount));
- newEntry.setDebit(debit);
- newEntry.setLettering(lettering);
- newEntry.setDetail(detail);
- newEntry.setTransaction(transaction);
- newEntry.setAccount(account);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Ajout avec succes de l'entrée comptable.");
- }
- // Création du log
- Date logDate = new Date();
- logServiceImpl.addLog(logDate, transaction.getTransDate(),
- ServiceHelper.LOG_ADD, transaction.getVoucherRef(),
- transaction.getDescription(), detail, amount, debit,
- lettering);
-
- // Il renvoie soit l'identifiant topiaId ou SUCCESS.
- result = newEntry.getTopiaId();
- //result = ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;*/
+ public void createEntry(Entry entry) throws LimaException {
+
+ //check if the financial period is blocked
+ accountingRules.checkFinancialPeriodBlockedWithEntry(entry);
TopiaContext topiaContext = null;
try {
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/pom.xml
===================================================================
--- trunk/lima-swing/pom.xml 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/pom.xml 2010-05-06 09:57:19 UTC (rev 2884)
@@ -114,7 +114,6 @@
</includes>
</resource>
</resources>
-
<plugins>
<plugin>
<groupId>org.nuiton.jaxx</groupId>
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-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -38,12 +38,8 @@
import org.chorem.lima.ui.account.AccountView;
import org.chorem.lima.ui.entrybook.EntryBookView;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
-import org.chorem.lima.ui.report.BalanceView;
-import org.chorem.lima.ui.report.BilanView;
-import org.chorem.lima.ui.report.ReportsView;
-import org.chorem.lima.ui.report.ResultView;
+import org.chorem.lima.ui.transaction.FinancialTransactionView;
import org.chorem.lima.ui.transaction.LetteringView;
-import org.chorem.lima.ui.transaction.TransactionView;
import org.chorem.lima.util.ErrorHelper;
/**
@@ -278,14 +274,14 @@
public void showBilanView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- BilanView bilanView = new BilanView(mainView);
- mainView.showTab(_("lima.tab.bilan"), bilanView);
+ // BilanView bilanView = new BilanView(mainView);
+ // mainView.showTab(_("lima.tab.bilan"), bilanView);
}
public void showBalanceView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- BalanceView balanceView = new BalanceView(mainView);
- mainView.showTab(_("lima.tab.balance"), balanceView);
+ // BalanceView balanceView = new BalanceView(mainView);
+ // mainView.showTab(_("lima.tab.balance"), balanceView);
}
public void showFiscalPeriodView(JAXXContext rootContext) {
@@ -331,7 +327,7 @@
public void showTransactionView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- TransactionView transactionView = new TransactionView(mainView);
+ FinancialTransactionView transactionView = new FinancialTransactionView(mainView);
mainView.showTab(_("lima.tab.transaction"), transactionView);
}
@@ -350,14 +346,14 @@
public void showReportsView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- ReportsView reportsView = new ReportsView(mainView);
- mainView.showTab(_("lima.tab.reports"), reportsView);
+ //ReportsView reportsView = new ReportsView(mainView);
+ // mainView.showTab(_("lima.tab.reports"), reportsView);
}
public void showResultView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- ResultView resultView = new ResultView(mainView);
- mainView.showTab(_("lima.tab.result"), resultView);
+ //ResultView resultView = new ResultView(mainView);
+ // mainView.showTab(_("lima.tab.result"), resultView);
}
/**
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-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-05-06 09:57:19 UTC (rev 2884)
@@ -32,7 +32,7 @@
<org.jdesktop.swingx.JXTreeTable id="accountsTreeTable"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
treeTableModel="{new org.chorem.lima.ui.account.model.AccountTreeTableModel()}"
- highlighters='{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}' />
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" />
<javax.swing.ListSelectionModel
javaBean="getAccountsTreeTable().getSelectionModel()"
onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-05-06 09:57:19 UTC (rev 2884)
@@ -31,7 +31,7 @@
<JScrollPane>
<org.jdesktop.swingx.JXTable id="entryBooksTable" rowHeight="24"
model="{new org.chorem.lima.ui.entrybook.model.EntryBookTableModel()}"
- highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
columnControlVisible="true"/>
<javax.swing.ListSelectionModel javaBean="getEntryBooksTable().getSelectionModel()"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-05-06 09:57:19 UTC (rev 2884)
@@ -40,7 +40,7 @@
<JScrollPane>
<org.jdesktop.swingx.JXTable id="fiscalPeriodTable"
model="{new org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel()}"
- highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
rowHeight="24"
selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
columnControlVisible="true" />
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -24,15 +24,12 @@
import java.util.Date;
import java.util.List;
-import javax.swing.JLabel;
import javax.swing.table.AbstractTableModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -128,13 +125,11 @@
Object result = "n/a";
- // a refaire, c'est pas optimisé
List<FiscalPeriod> periods;
try {
periods = fiscalPeriodService.getAllFiscalPeriods();
FiscalPeriod fiscalPeriod = periods.get(rowIndex);
-
String[] monthName = {_("lima.date.january"), _("lima.date.february"),
_("lima.date.march"), _("lima.date.april"), _("lima.date.may"),
_("lima.date.june"), _("lima.date.july"), _("lima.date.august"),
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx 2010-05-06 09:57:19 UTC (rev 2884)
@@ -81,8 +81,7 @@
<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))}" />
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}" />
<javax.swing.ListSelectionModel javaBean="getFinancialTransactionTable().getSelectionModel()"
onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/>
</JScrollPane>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -46,14 +46,14 @@
private static final Log log =
LogFactory.getLog(FinancialTransactionViewHandler.class);
- protected TransactionView view;
+ protected FinancialTransactionView view;
- protected FinancialTransactionViewHandler(TransactionView view) {
+ protected FinancialTransactionViewHandler(FinancialTransactionView view) {
this.view = view;
}
//add a new transaction
- protected void addFinancialTransaction() {
+ public void addFinancialTransaction() {
FinancialTransactionTable table =
(FinancialTransactionTable)view.getFinancialTransactionTable();
FinancialTransactionTableModel model =
Modified: 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/FinancialTransactionTable.java 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -18,16 +18,24 @@
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.Account;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.ui.transaction.FinancialTransactionHelper;
import org.chorem.lima.ui.transaction.FinancialTransactionViewHandler;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
/**
@@ -45,40 +53,26 @@
private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
protected FinancialTransactionViewHandler handler;
-
+
private ColorHighlighter colorEmptyLine;
- private ColorHighlighter colorTransaction;
+ private Highlighter colorTransaction;
private ColorHighlighter colorBalance;
/**
*/
- public FinancialTransactionTable(FinancialTransactionViewHandler handler/*,
- TransactionTableModel model,
+ public FinancialTransactionTable(FinancialTransactionViewHandler handler/*
TransactionSortedTableColumnModel columnModel*/) {
//super(model, columnModel);
this.handler = handler;
-
/*
* New Table Header
*/
- // header renderer getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
+ //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
@@ -110,20 +104,18 @@
setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
//Get new account editor
setDefaultEditor(Account.class, new AccountTableCellEditor());
-
- // Color transactions
- // addColorTransaction();
- // addColorNonBalancedTransaction();
+
+ //highlight financial financial transactions
+ addColorTransaction();
+ // highlight unbalanced financial transactions
+ addColorNonBalancedTransaction();
}
- /**
- *
- */
public void addColorEmptyLine() {
// Renvoie une couleur jaune pour chaque nouvelle ligne créée
- /*removeColorEmptyLine();
- if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
+ //removeColorEmptyLine();
+ /* if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
HighlightPredicate predicate = new HighlightPredicate() {
@@ -149,28 +141,33 @@
/**
* Cette méthode permet de colorer toutes les transactions dans le tableau
* afin de bien distinguer les transactions et entrées comptables.
+ * On récupère la première cellule, on vérifie que c'est une date
*/
- /* 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);
+ protected void addColorTransaction() {
+ if (colorTransaction != null) {
+ removeHighlighter(colorTransaction);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ return adapter.getValueAt(adapter.row, 0) instanceof Date;
+ }
+ };
+ colorTransaction =
+ new ColorHighlighter(predicate, new Color(222,222,222), null);
addHighlighter(colorTransaction);
- }*/
+ }
+
+
/**
- * Permet de surligner une transaction dans le tableau lorsque cette dernière
- * n'est pas équilibrée.
+ * Permet de surligner une transaction dans le tableau lorsque
+ * cette dernière n'est pas équilibrée.
+ * On récupère la dernière cellule de la ligne
+ * et on vérifie si la valeur est différente de 0
*/
-/* protected void addColorNonBalancedTransaction() {
+ protected void addColorNonBalancedTransaction() {
if (colorBalance != null) {
removeHighlighter(colorBalance);
}
@@ -179,32 +176,31 @@
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)) {
+ Object value = adapter.getValueAt(adapter.row, 8);
+ if (value instanceof Double) {
+ Double currentBalance = (Double) value;
+ if (currentBalance != 0) {
isHighlighted = true;
}
}
return isHighlighted;
}
};
- colorTransaction = new ColorHighlighter(predicate, new Color(255, 198,
- 209), null, null, null);
+ colorTransaction =
+ new ColorHighlighter(predicate, new Color(255, 198, 209), null);
addHighlighter(colorTransaction);
- }*/
-
- /* @Override
- public TransactionTableModel getModel() {
- return (TransactionTableModel) this.dataModel;
}
- @Override
+ /* @Override
+ public FinancialTransactionTableModel getModel() {
+ return (FinancialTransactionTableModel) this.dataModel;
+ }*/
+
+ /* @Override
public TransactionSortedTableColumnModel getColumnModel() {
return (TransactionSortedTableColumnModel) this.columnModel;
- }
+ }*/
-*/
/*
public EmptyLineSelectionListener getEmptyLineSelectionListener() {
if (emptyLineSelectionListener == null) {
@@ -213,52 +209,52 @@
return emptyLineSelectionListener;
}
*/
+ /**
+ * for each action combination key are think
+ * for extend keyboard and laptop keyboard
+ */
@Override
public void keyPressed(KeyEvent e) {
- // VK_DELETE suppression de la transaction en cours
+ // delete selected row with the key : delete or ctrl clear
// ou de l'entree
- if (e.getKeyCode() == KeyEvent.VK_DELETE) {
- // handler.deleteSelectedRow();
+ if ((e.getKeyCode() == KeyEvent.VK_DELETE )
+ || (e.getKeyCode() == KeyEvent.VK_CLEAR
+ && e.getModifiers() == KeyEvent.CTRL_MASK)){
+ 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();
+ // add entry with the key combination : insert or ctrl + enter
+ if ((e.getKeyCode() == KeyEvent.VK_INSERT )
+ || (e.getKeyCode() == KeyEvent.VK_ENTER
+ && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+ handler.addEmptyEntry();
}
-
- // 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);*/
+
+ // add financial transaction with the key combination : ctrl + tab
+ if (e.getKeyCode() == KeyEvent.VK_TAB
+ && e.getModifiers() == KeyEvent.CTRL_MASK) {
+ handler.addFinancialTransaction();
}
/**
* Touche tab
- * Ajoute une entrée comptable ou transaction seulement si tab est sur
+ * Ajoute une entrée comptable 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;
+
+ int x = this.getSelectedColumn();
+ int y = this.getSelectedRow();
+ int max_x = this.getColumnCount() - 1;
+ int max_y = this.getRowCount() - 1;
if (x == max_x && y == max_y) {
- boolean result = addLine(table);
+ handler.addEmptyEntry();
// positionne la sélection sur la nouvelle ligne créée
- if (result) {
- table.setColumnSelectionInterval(0, 0);
- table.setRowSelectionInterval(max_y + 1, max_y + 1);
- }
- }*/
+ this.setColumnSelectionInterval(0, 0);
+ this.setRowSelectionInterval(max_y + 1, max_y + 1);
+ }
}
}
@@ -278,100 +274,4 @@
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;
- }*/
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-04 13:44:56 UTC (rev 2883)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-06 09:57:19 UTC (rev 2884)
@@ -84,8 +84,15 @@
/** FinancialPeriod service. */
protected final FinancialPeriodService financialPeriodService;
+ /** selected financial period */
protected FinancialPeriod selectedFinancialPeriod;
+ /** data cache */
+ protected List<Object> cacheDataList;
+
+ /** collection
+
+
/**
* Model constructor.
*
@@ -113,11 +120,9 @@
List<Object> results = new ArrayList<Object>();
try {
-
List<FinancialTransaction> financialtransactions =
transactionService.getAllFinancialTransactionsForFinancialPeriod(
selectedFinancialPeriod);
-
for (FinancialTransaction financialtransaction : financialtransactions) {
results.add(financialtransaction);
results.addAll(financialtransaction.getEntry());
@@ -220,8 +225,8 @@
// just prevent too much result
if (selectedFinancialPeriod != null) {
- List<Object> datas = getDataList();
- result = datas.size();
+ cacheDataList = getDataList();
+ result = cacheDataList.size();
}
else {
if (log.isDebugEnabled()) {
@@ -239,8 +244,7 @@
// just prevent too much result
if (selectedFinancialPeriod != null) {
// TODO EC-20100407 remove this ugly code
- List<Object> datas = getDataList();
- result = datas.get(row);
+ result = cacheDataList.get(row);
if (result instanceof FinancialTransaction) {
FinancialTransaction currentRow = (FinancialTransaction)result;
@@ -342,8 +346,7 @@
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
boolean editableCell=false;
- List<Object> datas = getDataList();
- Object currentRow = datas.get(rowIndex);
+ Object currentRow = cacheDataList.get(rowIndex);
// cells editable for the entry row, all cells exclude the date
if ((currentRow instanceof Entry) && !(columnIndex==0)) {
editableCell=true;
@@ -377,8 +380,8 @@
// create it
transactionService.createFinancialTransaction(financialTransaction);
int row = getDataList().indexOf(financialTransaction);
- //FIXME Invalid range
- fireTableRowsInserted(row, row);
+ fireTableRowsInserted(row, row);
+ //fireTableDataChanged();
}
else {
throw new LimaBusinessException("No financial period selected");
@@ -392,8 +395,7 @@
*/
public void addEmptyEntry(Object value, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
+ Object currentRow = cacheDataList.get(row);
Entry entry = new EntryImpl();
//check if current row is a transaction or an entry
if (currentRow instanceof FinancialTransaction) {
@@ -407,7 +409,7 @@
//create it
entry.setFinancialTransaction(currentTransaction);
transactionService.createEntry(entry);
- fireTableRowsUpdated(row, row);
+ fireTableDataChanged();
}
@@ -420,8 +422,7 @@
// just prevent too much result
if (selectedFinancialPeriod != null) {
// TODO EC-20100407 remove this ugly code
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
+ Object currentRow = cacheDataList.get(row);
if (currentRow instanceof FinancialTransaction) {
FinancialTransaction currentFinancialTransaction =
(FinancialTransaction)currentRow;
@@ -516,13 +517,12 @@
log.debug("Can't update entry", e);
}
}
- //update the financial transaction in entire
- int financialTransactionRow =
- getDataList().indexOf(((Entry) currentRow).
- getFinancialTransaction());
- fireTableRowsUpdated(financialTransactionRow,
- financialTransactionRow);
}
+ //update the financial transaction in entire
+ int financialTransactionRow =
+ getDataList().indexOf(((Entry) currentRow).
+ getFinancialTransaction());
+ fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
}
else {
if (log.isDebugEnabled()) {
@@ -533,8 +533,7 @@
public Object getElementAt(int row){
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
+ Object currentRow = cacheDataList.get(row);
return currentRow;
}
@@ -547,8 +546,7 @@
* @throws LimaException
*/
public void removeObject(Object object, int row) throws LimaException {
- List<Object> datas = getDataList();
- Object currentRow = datas.get(row);
+ Object currentRow = cacheDataList.get(row);
if (currentRow instanceof FinancialTransaction) {
FinancialTransaction currentTransaction =
(FinancialTransaction)currentRow;
@@ -558,6 +556,7 @@
Entry currentEntry = (Entry)currentRow;
transactionService.removeEntry(currentEntry);
}
- fireTableRowsDeleted(row, row);
+ fireTableRowsDeleted(row, getRowCount());
}
+
}
1
0
04 May '10
Author: jpepin
Date: 2010-05-04 15:44:56 +0200 (Tue, 04 May 2010)
New Revision: 2883
Url: http://chorem.org/repositories/revision/lima/2883
Log:
Externalisation des r?\195?\168gles m?\195?\169tiers (Account Rules) pour quelles soient localisables. V?\195?\169rification dans l'UI lors de la modification de la date d'une transaction que cette derni?\195?\168re est valide.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/subledger/model/
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.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/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/resources/lima.properties
trunk/lima-callao/pom.xml
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
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-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -54,6 +54,6 @@
void removeAccount(Account account) throws LimaException;
void removeAccountwithSubAccounts(Account account) throws LimaException;
-
+
List<Account> getChildrenAccounts(Account masterAccount) throws LimaException;
}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -0,0 +1,40 @@
+/* *##% 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 org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * Service for localized rules
+ * @author joe
+ *
+ */
+public interface AccountingRules {
+
+ public void createAccountRules(Account masterAccount, Account account) throws LimaException;
+ public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException;
+ public void createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException;
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException;
+ public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException;
+ public void removeEntryBookRules(EntryBook entryBook, TopiaContext topiaTransaction) throws LimaException;
+
+}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -19,10 +19,10 @@
package org.chorem.lima.business;
+import java.util.Date;
import java.util.List;
import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
/**
* Financial period service.
@@ -40,8 +40,7 @@
List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException;
void createFinancialPeriod(FinancialPeriod financialPeriod) throws LimaException;
-
- //void updateFiscalPeriod(FinancialPeriod financialPeriod) throws LimaException;
- //void removeFiscalPeriod(FinancialPeriod financialPeriod) throws LimaException;
+ FinancialPeriod getFinancialPeriodWithDate(Date date) throws LimaException;
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java 2010-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -41,8 +41,6 @@
void createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
-
- //void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
void removeAllFiscalPeriods() throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -19,8 +19,11 @@
package org.chorem.lima.business;
+import static org.nuiton.i18n.I18n._;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.accountingrules.DefaultAccountingRules;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
@@ -44,22 +47,24 @@
private static final String configFile = "lima.properties";
- public static LimaConfig getInstance() {
- /*
- if (instance == null) {
- instance = new LimaConfig();
- instance.setConfigFileName("lima.properties");
- try {
- instance.parse(new String[0]);
- } catch (ArgumentsParserException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't read configuration", ex);
- }
+ protected AccountingRules accountingRules;
+
+ public LimaConfig(){
+ // set defaut option (included configuration file name : important)
+ for (Option o : Option.values()) {
+ setDefaultOption(o.key, o.defaultValue);
+ }
+
+ /* // set action alias
+ for (Action a : Action.values()) {
+ for (String alias : a.aliases) {
+ addActionAlias(alias, a.action);
}
-
- // FIXME put this in another place
- instance.setOption("topia.persistence.classes", LimaCallaoDAOHelper.getImplementationClassesAsString());
}*/
+
+ }
+
+ public static LimaConfig getInstance() {
if (instance == null) {
instance = new LimaConfig();
instance.loadConfiguration(configFile);
@@ -67,6 +72,34 @@
return instance;
}
+ /**
+ *
+ * @return
+ */
+ public AccountingRules getAccountingRules(){
+ //TODO PEPIN 20100503 instancier la bonne classe de nationalite en fonction du fichier de configuration
+
+ if (accountingRules == null){
+ Class accountingRulesClass = getOptionAsClass(Option.RULES_NATIONALTY.key);
+ if (accountingRulesClass == null){
+ accountingRules = new DefaultAccountingRules();
+ }
+ else {
+ try {
+ accountingRules = (AccountingRules) accountingRulesClass.newInstance();
+ } catch (InstantiationException e) {
+ log.error("Can't instantiate accounting rules", e);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return accountingRules;
+ }
+
+
+
protected void loadConfiguration(String configFileName){
instance.setConfigFileName(configFileName);
@@ -79,5 +112,65 @@
}
instance.setOption("topia.persistence.classes", LimaCallaoDAOHelper.getImplementationClassesAsString());
}
+
+ /**
+ * Lima option definition.
+ *
+ * Contains all lima configuration key, with defaut value and
+ * information for jaxx configuration frame ({@link #type},
+ * {@link #_transient}, {@link #_final}...)
+ */
+ public static enum Option implements OptionDef {
+
+ CONFIG_FILE(CONFIG_FILE_NAME, _("lima.config.configFileName.description"), "lima-config.properties", String.class, true, true),
+ RULES_NATIONALTY("lima.rules",_("lima.config.rulesnationality"),"default", String.class, false, false);
+
+ public final String key;
+ public final String description;
+ public final String defaultValue;
+ public final Class<?> type;
+ public final boolean _transient;
+ public final boolean _final;
+
+ private Option(String key, String description, String defaultValue,
+ Class<?> type, boolean _transient, boolean _final) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this._final = _final;
+ this._transient = _transient;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return _final;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
+ }
}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -0,0 +1,161 @@
+/* *##% 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.accountingrules;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountingRules;
+import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ejb.AccountServiceImpl;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+/**
+ * Defaults rules, if no localized rules classes is instantiated
+ * this default class contain the strict minimum rules to check the data integrity
+ * @author joe
+ *
+ */
+public class DefaultAccountingRules implements AccountingRules {
+
+ protected static final Log log =
+ LogFactory.getLog(DefaultAccountingRules.class);
+
+ /**
+ * Rules to check before create accounts
+ */
+ @Override
+ public void createAccountRules(Account masterAccount, Account account) throws LimaException {
+ // Check if the numberaccount is not blank
+ if (StringUtils.isBlank(account.getAccountNumber())) {
+ throw new LimaBusinessException("Invalid AccountNumber : "
+ + account.getAccountNumber());
+ }
+ }
+
+ /**
+ * Rules to check before create subledger
+ */
+ @Override
+ public void createSubLedgerRules(Account masterAccount, Account account)
+ throws LimaException {
+ // check the number account is not empty
+ if (StringUtils.isBlank(account.getAccountNumber())) {
+ log.debug("TEST");
+ throw new LimaBusinessException("Invalid AccountNumber : "
+ + account.getAccountNumber());
+ }
+ //check if parentaccount have no subaccount
+ if (masterAccount.getSubAccounts().size() > 0){
+ throw new LimaBusinessException(
+ "Subledger must create on a account whithout subaccount : ");
+ }
+ }
+
+ /**
+ * Rules to check before create fiscals periods
+ */
+ @Override
+ public void createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
+ //check if the enddate period is after the begindate period
+ if (fiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())){
+ throw new LimaBusinessException(
+ "The enddate is before the begindate");
+ }
+ }
+
+ /**
+ * Rules to check before block fiscals periods
+ */
+ @Override
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
+
+ }
+
+ /**
+ * Rules to check if an account and all his subaccount is not used
+ * Recursive function
+ */
+ @Override
+ public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException {
+ try{
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
+ // Check if account have entries
+ int nbentries = entryDAO.findAllByAccount(account).size();
+ if (nbentries != 0) {
+ throw new LimaBusinessException("Can't delete Account with entries");
+ }
+ //check if subaccount have entries
+ AccountServiceImpl accountService = new AccountServiceImpl();
+ for (Account childrenAccounts : accountService.getChildrenAccounts(account)) {
+ removeAccountRules(childrenAccounts, transaction);
+ }
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ }
+
+ @Override
+ public void removeEntryBookRules(EntryBook entryBook, TopiaContext topiaTransaction) throws LimaException {
+ try {
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
+ // Check if entrybook have entries
+ int nbentries = entryDAO.findAllByEntryBook(entryBook).size();
+ log.debug(entryDAO.findAllByEntryBook(entryBook).size());
+ if (nbentries != 0) {
+ throw new LimaBusinessException("Can't delete entryBook with entries");
+ }
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+
+ }
+
+ /**
+ * Generic code used to rollback a transaction.
+ *
+ * TODO : replace this by JTA
+ * @throws LimaException
+ */
+ protected void doCatch(TopiaContext transaction, Exception cause, Log log) throws LimaException {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", eee);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Exception during query", cause);
+ }
+ throw new LimaException("Exception during query", cause);
+ }
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -0,0 +1,201 @@
+package org.chorem.lima.business.accountingrules;
+
+import java.util.Date;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+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.business.ejb.FinancialPeriodServiceImpl;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.FiscalPeriodDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+
+public class FranceAccountingRules extends DefaultAccountingRules {
+ protected static final Log log = LogFactory.getLog(DefaultAccountingRules.class);
+
+ private FinancialPeriodServiceImpl financialPeriodService =
+ new FinancialPeriodServiceImpl();
+
+ /**
+ * Règles de vérification de la création du PCG, appliquées à la comptabilité française
+ *
+ */
+ public void createAccountRules(Account masterAccount, Account account) throws LimaException {
+ super.createAccountRules(masterAccount, account);
+
+ // Check if the number account is type numeric
+ if (!StringUtils.isNumeric(account.getAccountNumber())){
+ throw new LimaBusinessException("AccountNumber is not numeric : "
+ + account.getAccountNumber());
+ }
+
+ // Check if the number account start with the number of the master account
+ if (masterAccount!=null && !account.getAccountNumber().startsWith(
+ masterAccount.getAccountNumber())){
+
+ throw new LimaBusinessException(
+ "Account Number not begin with the number account master : "
+ + account.getAccountNumber());
+ }
+
+ // Check if master account have a number between 1 to 8
+ if (masterAccount==null && !account.getAccountNumber().matches("[1-8]")){
+ throw new LimaBusinessException(
+ "Master account is not a digit between 1 to 8 :"
+ + account.getAccountNumber());
+ }
+
+ }
+
+ /**
+ * Règles de vérification d'ouverture d'un exercice, appliquées à la comptabilité française
+ *
+ * Permet de créer un exercice.
+ *
+ * Elle a une durée de un an, composées de 12 périodes mensuelles.
+ * Elle peut aussi être plus courte ou plus longue si l'entreprise
+ * se constitu ou entre en liquidation ou que l'entreprise decide
+ * de changer
+ *
+ * Elle correspond à l'exercice comptable.
+ * Pas plus de deux exercices fiscaux ne peuvent-être ouvert en même temps
+ *
+ */
+ public void createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
+ super.createFiscalPeriodRules(fiscalPeriod, transaction);
+ try {
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+
+ //Checks if is not the first fiscalperiod to create
+ if (fiscalPeriodDAO.findAll().size()!=0){
+
+ TopiaQuery query = fiscalPeriodDAO.createQuery();
+ fiscalPeriodDAO.findAllByQuery(query);
+ query.addOrderDesc(FiscalPeriod.END_DATE);
+
+ //get the last fiscal period
+ FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.findByQuery(query);
+ log.debug("lastFiscalPeriod : "+lastFiscalPeriod);
+
+ //check the new fiscal period adjoining the last
+ Date dateLastFiscalPeriod=lastFiscalPeriod.getEndDate();
+ dateLastFiscalPeriod = DateUtils.
+ addMilliseconds(dateLastFiscalPeriod, 1);
+ Date dateFiscalPeriod=fiscalPeriod.getBeginDate();
+ if(dateLastFiscalPeriod.compareTo(dateFiscalPeriod)!=0){
+ throw new LimaBusinessException(
+ "The new fiscalperiod must adjoining the last");
+ }
+
+ //We can create a new fiscal period meantime the last fiscal period was not locked
+ //But not the ante periodfiscal
+ int unblockedFiscalPeriod =
+ fiscalPeriodDAO.findAllByLocked(false).size();
+ log.debug(unblockedFiscalPeriod);
+ if (unblockedFiscalPeriod>1){
+ throw new LimaBusinessException(
+ "The ante fiscal period is not locked");
+ }
+ }
+
+ Date beginDate = fiscalPeriod.getBeginDate();
+ Date endDate = fiscalPeriod.getEndDate();
+
+ // FinancialPeriod of 1 month are created
+ Date loopDate = beginDate;
+ while (loopDate.compareTo(endDate) <= 0) {
+ Date loopUpperDate = DateUtils.addMonths(loopDate, 1);
+ Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1);
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ financialPeriod.setBeginDate(loopDate);
+ financialPeriod.setEndDate(periodEndDate);
+ fiscalPeriod.addFinancialPeriod(financialPeriod);
+ loopDate = loopUpperDate;
+ log.debug("financialPeriod : "+financialPeriod);
+ financialPeriodService.createFinancialPeriod(financialPeriod);
+ }
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ }
+
+ /**
+ * Règles de vérification de fermeture d'un exercice, appliquées à la comptabilité française
+ */
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException {
+ try{
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+
+ TopiaQuery query = fiscalPeriodDAO.createQuery();
+ fiscalPeriodDAO.findAllByQuery(query);
+ query.add(FiscalPeriod.LOCKED, Op.EQ, false);
+ query.addOrder(FiscalPeriod.END_DATE);
+
+ FiscalPeriod oldestUnBlockedFiscalPeriod =
+ fiscalPeriodDAO.findByQuery(query);
+
+ //Check if the fiscal period to block is the oldest
+ if (!oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)){
+ throw new LimaBusinessException(
+ "The ante fiscal period must be blocked before this.");
+ }
+ } catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ }
+
+ /**
+ * Generic code used to rollback a transaction.
+ *
+ * TODO : replace this by JTA
+ * @throws LimaException
+ */
+ protected void doCatch(TopiaContext transaction, Exception cause, Log log) throws LimaException {
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during rollback context", eee);
+ }
+ }
+ }
+ if (log.isErrorEnabled()) {
+ log.error("Exception during query", cause);
+ }
+ throw new LimaException("Exception during query", cause);
+ }
+
+ /**
+ * Generic code used too close a transaction.
+ *
+ * @param transaction transaction to close
+ * @param log log (can be null)
+ * @throws LimaException
+ */
+ protected void doFinally(TopiaContext transaction, Log log) throws LimaException {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException ex) {
+ if (log != null && log.isErrorEnabled()) {
+ log.error("Can't close transaction", ex);
+ }
+ throw new LimaException("Can't close transaction", ex);
+ }
+ }
+ }
+}
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-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -24,22 +24,20 @@
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
+import java.util.Properties;
import javax.ejb.Stateless;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
-import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryDAO;
-import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.IdentityDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -64,10 +62,11 @@
private TopiaContext rootContext;
- protected FinancialTransactionServiceImpl financialTransactionService = new FinancialTransactionServiceImpl();
+ protected FinancialTransactionServiceImpl financialTransactionService =
+ new FinancialTransactionServiceImpl();
- //private ConvertAccount convertAccount = new ConvertAccount();
-
+ protected AccountingRules accountingRules;
+
public AccountServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
try {
@@ -77,13 +76,11 @@
log.error("Can't init topia context", ex);
}
}
+ accountingRules = config.getAccountingRules();
}
/**
* Permet de créer un nouveau compte dans le PCG de l'application.
- * Il ne peut exister deux numéros identiques. Pour chaque nouveau compte,
- * il est vérifié si il n'existe pas un compte avec le numéro donné. Dans ce
- * cas présent, le compte n'est pas créé.
* ATTENTION : le compte masterAccount, c'est à dire le compte père, doit
* exister, sinon le compte n'est pas créé. Si le compte n'a pas de père, alors
* mettre masterAccount à null.
@@ -94,35 +91,9 @@
@Override
public void createAccount(Account masterAccount, Account account) throws LimaException {
- // Check if the numberaccount is not blank
- if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new LimaBusinessException("Invalid AccountNumber : "
- + account.getAccountNumber());
- }
-
- // Check if the number account is type numeric
- if (!StringUtils.isNumeric(account.getAccountNumber())){
- throw new LimaBusinessException("AccountNumber is not numeric : "
- + account.getAccountNumber());
- }
+ //check rules before create the account
+ accountingRules.createAccountRules(masterAccount, account);
- // Check if the number account start with the number of the master account
- // (specific to the french accountancy)
- if (masterAccount!=null && !account.getAccountNumber().startsWith(
- masterAccount.getAccountNumber())){
-
- throw new LimaBusinessException("" +
- "Account Number not begin with the number account master :"
- + account.getAccountNumber());
- }
-
- // Check if master account have a number between 1 to 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
@@ -160,16 +131,16 @@
}
}
-
+ /**
+ * Permet de créer des comptes tiers
+ */
@Override
public void createSubLedger(Account masterAccount, Account account, Identity identity)
throws LimaException {
- // check the number account is not empty
- if (StringUtils.isBlank(account.getAccountNumber())) {
- throw new LimaBusinessException("Invalid AccountNumber : "
- + account.getAccountNumber());
- }
+ //check rules before create the account
+ accountingRules.createSubLedgerRules(masterAccount, account);
+
TopiaContext transaction = null;
try {
// basic check done, make check in database
@@ -185,16 +156,9 @@
throw new LimaBusinessException(_(
"An account already exists with this number : %s",
account.getAccountNumber()));
- }
-
- //check if parentaccount have no subaccount
- if (masterAccount.getSubAccounts().size() > 0){
- throw new LimaBusinessException(
- "Subledger must create on a account whithout subaccount : ");
- }
+ }
accountDAO.create(account);
-
IdentityDAO identityDAO =
LimaCallaoDAOHelper.getIdentityDAO(transaction);
@@ -218,239 +182,8 @@
}
}
-
- /*public String createAccount (String accountNumber, String label,Account masterAccount,String type)
- {
- String result = ServiceHelper.RESPOND_ERROR;
- // Détermine si le compte existe déjà ou non
- boolean existAccount = existAccount(accountNumber);
- // Si le numéro de compte existe
- if (existAccount)
- {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro "+accountNumber+" existe deja !");
- }
- result = ServiceHelper.ACCOUNT_DOUBLE;
- } else {
- // Création du compte
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
- //Le compte a un père
- if ( masterAccount != null )
- {
- // Vérification que le compte père existe dans la base de données
- boolean existMasterAccount = existAccount(masterAccount.getAccountNumber());
- // Si le compte père n'existe pas
- if (!existMasterAccount)
- {
- if (log.isWarnEnabled()) {
- log.warn("Le compte père numéro "+accountNumber+" n'existe pas !");
- }
- result = ServiceHelper.ACCOUNT_NOT_MASTER;
- } else {
- // Creation du compte
- Account newAccount = accountDAO.create();
- newAccount.setAccountNumber(accountNumber);
- newAccount.setLabel(label);
- newAccount.setMasterAccount(masterAccount);
- newAccount.setType(type);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- } else {
- // Le compte n'a pas de père
- // Creation du compte
- Account newAccount = accountDAO.create();
- newAccount.setAccountNumber(accountNumber);
- newAccount.setLabel(label);
- newAccount.setType(type);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- }catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
-
- /*
- * Permet de créer un compte à partir du numéro de compte père. Il appelle
- * ensuite createAccount avec le compte père.
- * @param accountNumber numéro du compte à créer
- * @param label label pour le compte
- * @param maserAccountNumber numéro du compte père, si il en a pas, mettre 0.
- * @return
- *
- public String createAccount(String accountNumber, String label,
- String masterAccountNumber, String type) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Recherche le compte Master
- Account masterAccount = searchAccount(masterAccountNumber);
- // Si le compte père n'existe pas
- if (masterAccount == null && !masterAccountNumber.equals("0")) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte père numéro " + masterAccountNumber
- + " n'existe pas !");
- }
- result = ServiceHelper.ACCOUNT_NOT_MASTER;
- } else {
- // Création du compte
- result = createAccount(accountNumber, label, masterAccount, type);
- }
- return result;
- }*/
-
- /*
- * Permet de creer un compte à partir d'un objet DTO
- * @param accountDTO compte au format DTO
- * @return
- *
- public String createAccount(AccountDTO accountDTO) {
- String result;
- String result_final;
- boolean error = false; // Si il y a eu une erreur pour créer les enfants
-
- // Création du compte père
- result = createAccount(accountDTO.getAccountNumber(), accountDTO
- .getLabel(), accountDTO.getMasterAccount(), accountDTO
- .getType());
- // Création des comptes enfants
-
- // Pour chaque enfant
- for (AccountDTO accountChildDTO : accountDTO.getAccountChildDTO()) {
- // Création de l'enfant
- result = createAccount(accountChildDTO);
- // Si il y a eu une erreur
- if (!result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro " + accountChildDTO.getLabel()
- + " n'a pu être créé !");
- }
- error = true;
- result_final = result;
- }
- }
- // Si il y a eu une erreur lors de la création d'un enfant, il est envoyé une erreur.
- if (error) {
- result = ServiceHelper.RESPOND_ERROR;
- }
- return result;
- }*/
-
- /*
- * Recherche un compte DTO. Il est recherché dans la base de données et est
- * converti avec ConvertAccount. ConvertAccount recherche dans la liste de
- * ses enfants pour les convertir également, et ainsi de suite.
- * @param accountNumber numéro du compte qu'on souhait rechercher
- * @return
- *
- public AccountDTO searchAccountDTO(String accountNumber) {
- AccountDTO accountDTO = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche du compte
- Account account = accountDAO.findByAccountNumber(accountNumber);
- // Converti entity en DTO
- convertAccount.setTransaction(topiaContext);
- accountDTO = convertAccount.accountEntityToDto(account, null);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return accountDTO;
- }*/
-
- /*
- * Permet de rechercher un compte à partir d'un numéro de compte.
- * @param accountNumber numéro du compte à rechercher
- * @return
- *
- public Account searchAccount(String accountNumber) {
- Account accountResult = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche du compte
- accountResult = accountDAO.findByAccountNumber(accountNumber);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return accountResult;
- }*/
-
- /*
- * Permet de renvoyer tous les enfants du compte.
- * Cette fonction permet de renvoyer les enfants, mais PAS les enfants des
- * enfants (et ainsi de suite). Cette méthode descend donc uniquement d'un
- * niveau sur la hiérarchie.
- * @param account compte dont on souhaite obtenir ses enfants.
- * @return
- *
- public List<Account> searchListChildAccount(Account account) {
- List<Account> ListAccount = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche des comptes enfants
- ListAccount = accountDAO.findAllByMasterAccount(account);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return ListAccount;
- }*/
-
- /*
- * Permet de renvoyer tous les enfants du compte. Elle se base sur la fonction
- * searchListChildAccount(Account account).
- * Cette fonction permet de renvoyer les enfants, mais PAS les enfants des
- * enfants (et ainsi de suite). Cette méthode descend donc uniquement d'un
- * niveau sur la hiérarchie.
- * @param account numéro de compte dont on souhaite obtenir ses enfants.
- * @return
- *
- public List<Account> searchListChildAccount(String accountNumber) {
- List<Account> ListAccount = null;
- // Recherche le compte
- Account account = searchAccount(accountNumber);
- // Si le compte n'existe pas
- if (account == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro " + accountNumber
- + " n'existe pas !");
- }
- } else {
- // Recherche des comptes enfants
- ListAccount = searchListChildAccount(account);
- }
- return ListAccount;
- }*/
-
/**
* Permet de convertir tous les comptes.
*
@@ -470,11 +203,6 @@
LimaCallaoDAOHelper.getAccountDAO(transaction);
List<Account> accounts = accountDAO.findAll();
accountsList.addAll(accounts);
- for (Account account : accounts) {
- for (Account subaccount : getChildrenAccounts(account)) {
-
- }
- }
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -495,32 +223,6 @@
*/
@Override
public List<Account> getChildrenAccounts(Account masterAccount) throws LimaException {
- /*ArrayList<AccountDTO> listAccountDTO = new ArrayList<AccountDTO>();
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche des comptes enfants
- List<Account> listAccount = accountDAO.findAll();
- // Pour chaque compte
- // Converti entity en DTO
- convertAccount.setTransaction(topiaContext);
- for (Account account : listAccount) {
- // Pour les comptes sans père
- if (account.getMasterAccount() == null) {
- AccountDTO accountDTO = convertAccount.accountEntityToDto(
- account, null);
- listAccountDTO.add(accountDTO);
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listAccountDTO;*/
List<Account> accountsList = new ArrayList<Account>();
@@ -540,10 +242,6 @@
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));
}
@@ -556,6 +254,7 @@
return accountsList;
}
+
/**
* Permet d'effacer un compte dans la base de données.
@@ -569,30 +268,17 @@
*/
@Override
public void removeAccount(Account account) throws LimaException {
- int result = 0;
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- //Check if an account has not his number
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
- Entry firstEntry = entryDAO.findByAccount(account);
+ // Check rules
+ accountingRules.removeAccountRules(account, transaction);
- if (firstEntry != null) {
- throw new LimaBusinessException("Can't delete account with entries");
+ //Check if the account have subaccount
+ if (account.getSubAccounts().size() > 0){
+ removeAccountwithSubAccounts(account);
}
-
- // Vérifie si une transaction n'appartient pas à ce compte.
- //FIXME fonctionne pas
- Entry entry = financialTransactionService.findByAccount(transaction, account);
- if (entry != null) {
- throw new LimaBusinessException("Can't delete Account with entries");
- }
-
- //Check if the account is not empty
- if (account.getSubAccounts().size() > 0){
- throw new LimaBusinessException("Account not empty");
- }
else {
// remove account
AccountDAO accountDAO =
@@ -630,7 +316,7 @@
// remove account
accountDAO.delete(account);
// commit
- transaction.commitTransaction();
+ transaction.commitTransaction();
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -654,44 +340,6 @@
*/
@Override
public void updateAccount(Account account) throws LimaException {
- /*String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche du compte
- Account modifyAccount = accountDAO
- .findByAccountNumber(accountNumber);
- // Si le compte n'existe pas
- if (modifyAccount == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le compte numéro " + accountNumber
- + " n'existe pas !");
- }
- result = ServiceHelper.ACCOUNT_NOT_EXIST;
- } else {
-
- // Modifie le compte
- modifyAccount.setLabel(label);
- modifyAccount.setType(type);
- // Recherche du compte père
- // Si il possède un compte père
- if (masterAccount != null) {
- modifyAccount.setMasterAccount(masterAccount);
- }
- modifyAccount.update();
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;*/
TopiaContext transaction = null;
try {
@@ -718,97 +366,4 @@
throw new LimaException("Can't update account", ex);
}
}
-
- /*
- * 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
- * la méthode modifyAccount avec pour paramètre le compte père trouvé.
- * @param accountNumber numéro de compte à modifier
- * @param label label à modifier
- * @param masterAccountNumber le numéro du compte père
- * @return
- *
- public String modifyAccount(String accountNumber, String label,
- String type, String masterAccountNumber) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
-
- // Modifie le compte
- // Recherche du compte père
- Account masterAccount = accountDAO
- .findByAccountNumber(masterAccountNumber);
- result = modifyAccount(accountNumber, label, type, masterAccount);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de modifier un compte à partir d'un compte DTO.
- * @param accountDTO compte au format DTO qu'on souhaire modifier.
- * @return
- *
- public String modifyAccount(AccountDTO accountDTO) {
- String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- AccountDAO accountDAO = LimaCallaoDAOHelper
- .getAccountDAO(topiaContext);
- // Recherche du compte père
- Account masterAccount = accountDAO.findByAccountNumber(accountDTO
- .getMasterAccount());
- result = modifyAccount(accountDTO.getAccountNumber(), accountDTO
- .getLabel(), accountDTO.getType(), masterAccount);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;
- }*/
-
- /*
- * Permet de mettre à jour le compte DTO ainsi que tous ses fils.
- * Cette méthode permet d'ajouter, modifier, et supprimer un compte et
- * ses enfants (et ainsi de suite).
- * @param accountDTO
- * @return
- *
- public String updateDTO(AccountDTO accountDTO) {
- String result;
- // Si le compte DTO père existe
- if (existAccount(accountDTO.getAccountNumber())) {
- // Modification du compte père
- result = modifyAccount(accountDTO);
- } else {
- // Création du compte père
- result = createAccount(accountDTO);
- }
- // Pour chaque enfant on lance l'update
- for (AccountDTO accountChildDTO : accountDTO.getAccountChildDTO()) {
- updateDTO(accountChildDTO);
- }
-
- // On recherche les comptes DTO effacés
- List<Account> listAccountChild = searchListChildAccount(accountDTO
- .getAccountNumber());
- for (Account account : listAccountChild) {
- // Si le compte n'est pas dans la liste, alors on efface
- if (!accountDTO.existAccountChild(account.getAccountNumber())) {
- result = removeAccount(account.getAccountNumber());
- }
- }
- return result;
- }*/
-
}
\ No newline at end of file
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-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -28,6 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.EntryBookService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
@@ -59,8 +60,9 @@
protected FinancialTransactionServiceImpl financialTransactionService = new FinancialTransactionServiceImpl();
- //private ConvertEntryBook convertEntryBook = new ConvertEntryBook();
+ protected AccountingRules accountingRules;
+
public EntryBookServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
try {
@@ -70,6 +72,7 @@
log.error("Can't init topia context", ex);
}
}
+ accountingRules = config.getAccountingRules();
}
/**
@@ -79,40 +82,6 @@
* @throws LimaException
*/
public void createEntryBook(EntryBook entryBook) throws LimaException {
- /*String result = ServiceHelper.RESPOND_ERROR;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
-
- // Si on souhaite avoir un EntryBook unique avec son label
-
- EntryBook EntryBook = searchEntryBookWithLabel(label);
- // Si un EntryBook existe déjà avec ce label
- if (EntryBook != null) {
- if (log.isWarnEnabled()) {
- log.warn("Un EntryBook avec le label " + label
- + " existe déjà !");
- }
- result = ServiceHelper.EntryBook_DOUBLE;
- } else {
- // Creation du EntryBook
- EntryBook newEntryBook = EntryBookDAO.create();
- newEntryBook.setLabel(label);
- newEntryBook.setPrefix(prefix);
- newEntryBook.setDescription(description);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result;*/
TopiaContext transaction = null;
try {
@@ -120,11 +89,15 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- // test si un EntryBook de ce nom existe deja
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
- EntryBook existingEntryBook = entryBookDAO.findByLabel(entryBook.getLabel());
+ // check if entrybook with is name already exist
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ EntryBook existingEntryBook =
+ entryBookDAO.findByLabel(entryBook.getLabel());
if (existingEntryBook != null) {
- throw new LimaBusinessException(_("An EntryBook already exists with this label : %s", entryBook.getLabel()));
+ throw new LimaBusinessException(
+ _("An EntryBook already exists with this label : %s",
+ entryBook.getLabel()));
}
// creation du EntryBook
@@ -141,31 +114,10 @@
}
}
+ /**
+ * return all entrybook
+ */
public List<EntryBook> getAllEntryBooks() throws LimaException {
- /*List<EntryBookDTO> listEntryBookDTO = new ArrayList<EntryBookDTO>();
-
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
- // Creation du EntryBook
- List<EntryBook> listEntryBook = EntryBookDAO.findAll();
- // Pour chaque EntryBook, on le transforme en DTO
- for (EntryBook EntryBook : listEntryBook) {
- // Converti en DTO
- EntryBookDTO EntryBookDTO = convertEntryBook
- .EntryBookEntityToDto(EntryBook);
- // Ajoute à la liste
- listEntryBookDTO.add(EntryBookDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listEntryBookDTO;*/
List<EntryBook> EntryBooksList = new ArrayList<EntryBook>();
TopiaContext transaction = null;
@@ -174,7 +126,7 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- // test si un EntryBook de ce nom existe deja
+ // check if entrybook with is name already exist
EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
List<EntryBook> EntryBooks = EntryBookDAO.findAll();
EntryBooksList.addAll(EntryBooks);
@@ -192,78 +144,6 @@
return EntryBooksList;
}
- /*
- * Permet de rechercher un EntryBook existant à partir de son label.
- * ATTENTION : il est possible que plusieurs journaux existent avec ce
- * même label. La méthode renvoie le premier trouvé.
- * @param prefix préfixe du EntryBook recherché
- * @return
- *
- public EntryBook searchEntryBookWithLabel(String label) {
- EntryBook EntryBookResult = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
- // Creation du EntryBook
- EntryBookResult = EntryBookDAO.findByLabel(label);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return EntryBookResult;
- }*/
-
- /*
- * Permet de rechercher un EntryBook existant à partir du label.
- * Le EntryBook recherché est converti automatiquement en format DTO.
- * @param prefix préfixe du EntryBook recherché
- * @return
- *
- public EntryBookDTO searchEntryBookDTOWithLabel(String label) {
- EntryBook EntryBook = searchEntryBookWithLabel(label);
- EntryBookDTO EntryBookDTO = convertEntryBook.EntryBookEntityToDto(EntryBook);
- return EntryBookDTO;
- }*/
-
- /*
- * Permet de rechercher un EntryBook unique identifé par son topiaId.
- * @param topiaId identifiant du EntryBook recherché
- * @return
- *
- public EntryBook searchEntryBookWithTopiaId(String topiaId) {
- EntryBook EntryBookResult = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
- // Creation du EntryBook
- EntryBookResult = EntryBookDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return EntryBookResult;
- }*/
-
- /*
- * Permet de rechercher un EntryBook existant à partir du topiaId.
- * Le EntryBook recherché est converti automatiquement en format DTO.
- * @param prefix préfixe du EntryBook recherché
- * @return
- *
- public EntryBookDTO searchEntryBookDTOWithTopiaId(String topiaId) {
- EntryBook EntryBook = searchEntryBookWithTopiaId(topiaId);
- EntryBookDTO EntryBookDTO = convertEntryBook.EntryBookEntityToDto(EntryBook);
- return EntryBookDTO;
- }*/
-
/**
* Permet de modifier un journal.
*
@@ -296,11 +176,10 @@
/**
* Permet d'effacer un EntryBook dans la base de données.
*
- * ATTENTION : si un EntryBook est associé avec des transactions, il est alors
+ * ATTENTION : si un EntryBook est associé avec des entrées, il est alors
* impossible de supprimer celui-ci.
*
* @param prefix préfixe du EntryBook à supprimer
- * @return
* @throws LimaException
*/
public void removeEntryBook(EntryBook entryBook) throws LimaException {
@@ -311,13 +190,10 @@
// TODO move it into JTA
topiaTransaction = rootContext.beginTransaction();
- // Vérifie si une transaction n'appartient pas à ce EntryBook.
- FinancialTransaction financialtransaction = financialTransactionService.findByEntryBook(topiaTransaction, entryBook);
- if (financialtransaction != null) {
- throw new LimaBusinessException("Can't delete EntryBook with transactions");
- }
-
- // test si un EntryBook de ce nom existe deja
+ //check
+ accountingRules.removeEntryBookRules(entryBook, topiaTransaction);
+
+ //delete
EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction);
EntryBookDAO.delete(entryBook);
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-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -19,6 +19,8 @@
package org.chorem.lima.business.ejb;
+import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
import org.apache.commons.logging.Log;
@@ -26,13 +28,17 @@
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
+import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
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;
/**
@@ -45,7 +51,8 @@
public class FinancialPeriodServiceImpl extends AbstractLimaService implements FinancialPeriodService {
/** log */
- private static final Log log = LogFactory.getLog(FinancialPeriodServiceImpl.class);
+ private static final Log log =
+ LogFactory.getLog(FinancialPeriodServiceImpl.class);
private TopiaContext rootContext;
@@ -62,53 +69,11 @@
/**
* Création d'une période timeSpan mensuelle avec une date de début et de fin. Une période
- * peut être bloquée ou non.
- * @param beginTimeSpan date de début de période
- * @param endTimeSpan date de fin de période
- * @param locked est à vrai si la période doit être bloquée.
+ * peut être bloquée ou non
* @return
*/
@Override
- public void createFinancialPeriod(FinancialPeriod financialPeriod /*Date beginTimeSpan, Date endTimeSpan,
- Period period, boolean locked*/) throws LimaException {
-/*
- // timeSpan correspond à une période mensuelle.
- // La fonction va donc prendre seulement pour date de référence la
- // date beginTimeSpan. Elle calcule automatiquement la date de fin
- // suivant le mois.
- DateUtil dateutil = new DateUtil();
- // Initialise la date de début au premier du mois
- beginTimeSpan = dateutil.InitDateFirstDayMonth(beginTimeSpan);
- // Initialise la date de fin au dernier du mois
- endTimeSpan = dateutil.InitDateEndDayMonth(beginTimeSpan);
- if (log.isInfoEnabled()) {
- log.info("Nouveau timeSpan du " + beginTimeSpan.toString() + " au "
- + endTimeSpan.toString());
- }
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Creation du timespan
- TimeSpan newtimeSpan = timeSpanDAO.create();
- newtimeSpan.setBeginTimeSpan(beginTimeSpan);
- newtimeSpan.setEndTimeSpan(endTimeSpan);
- newtimeSpan.setLocked(locked);
- newtimeSpan.setPeriod(period);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Ajout avec succes du timeSpan");
- }
- return ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- return ServiceHelper.RESPOND_ERROR;
- }*/
+ public void createFinancialPeriod(FinancialPeriod financialPeriod) throws LimaException {
TopiaContext transaction = null;
try {
@@ -116,7 +81,9 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- createFinancialPeriod(transaction, financialPeriod);
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
+ financialPeriodDAO.create(financialPeriod);
// commit
transaction.commitTransaction();
@@ -130,19 +97,8 @@
}
/**
- * Create a financial period with an opened transaction.
- *
- * @param transaction opened transaction
- * @param financialPeriod financial period
- * @throws TopiaException
+ * Return all financial periods
*/
- protected void createFinancialPeriod(TopiaContext transaction, FinancialPeriod financialPeriod) throws TopiaException {
-
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
- financialPeriodDAO.create(financialPeriod);
-
- }
-
@Override
public List<FinancialPeriod> getAllFinancialPeriods() throws LimaException {
@@ -154,7 +110,8 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
+ FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.
+ getFinancialPeriodDAO(transaction);
result = financialPeriodDAO.findAll();
// commit
@@ -170,6 +127,9 @@
return result;
}
+ /**
+ * Return all unblocked financial period
+ */
@Override
public List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException {
@@ -181,7 +141,8 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
+ FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.
+ getFinancialPeriodDAO(transaction);
result = financialPeriodDAO.findAllByLocked(false);
// commit
@@ -196,433 +157,34 @@
return result;
}
-
- /*
- * Permet de trouver un timespan directement avec une date. La date peut
- * être quelconque. Exemple : d = 17 sept 2000, renvoie la période du
- * 1 sept au 30 sept 2000.
- * @param d
- * @return
- *
- public TimeSpan searchTimeSpanByDate(Date d) {
- TimeSpan timeSpan = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Par précaution, on initialise la date au debut du mois
- DateUtil dateutil = new DateUtil();
- // Recherche du timeSpan
- Date searchDate = dateutil.InitDateFirstDayMonth(d);
- timeSpan = timeSpanDAO.findByBeginTimeSpan(searchDate);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return timeSpan;
- }*/
- /*
- * Recherche un timeSpan précis, avec sa date de création.
- * @param timeSpanDTO timeSpan au format DTO qu'on recherche
- * @return
- *
- public TimeSpan searchTimeSpanByDate(TimeSpanDTO timeSpanDTO) {
- TimeSpan timeSpan = searchTimeSpanByDate(timeSpanDTO.getBeginTimeSpan());
- return timeSpan;
- }*/
+ @Override
+ public FinancialPeriod getFinancialPeriodWithDate(Date date) throws LimaException {
- /*
- * Recherche un timeSpan UNIQUE. Celui est identifié par son topiaId.
- * @param topiaId Identifiant du timeSpan recherché
- * @return
- *
- public TimeSpan searchTimeSpanWithTopiaId(String topiaId) {
- TimeSpan timeSpan = null;
+ FinancialPeriod financialPeriod= new FinancialPeriodImpl();
+
+ TopiaContext transaction = null;
try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche du timeSpan
- timeSpan = timeSpanDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return timeSpan;
- }*/
+ transaction = rootContext.beginTransaction();
- /*
- * Permet de rechercher un timeSpan à l'aide d'une date. Il fait appel
- * à la méthode searchTimeSpanByDate.
- * La méthode renvoie un objet DTO.
- * @param d
- * @return
- *
- public TimeSpanDTO searchTimeSpanDTOByDate(Date d) {
- TimeSpan timeSpan = searchTimeSpanByDate(d);
- TimeSpanDTO timeSpanDTO = convertTimeSpan.timeSpanEntityToDto(timeSpan);
- return timeSpanDTO;
- }*/
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
- /*
- * Permet de faire une recherche de tous les timeSpans d'une période.
- * @param period
- * @return
- *
- public List<TimeSpan> searchListTimeSpan(Period period) {
- List<TimeSpan> listTimeSpan = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche les timeSpans avec cette période
- listTimeSpan = timeSpanDAO.findAllByPeriod(period);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listTimeSpan;
- }*/
-
- /*
- * Permet de rechercher tous les timeSpans suivant une période donnée.
- * Chaque timeSpan est converti ensuite en DTO.
- * @param period
- * @return
- *
- public List<TimeSpanDTO> searchListTimeSpanDTO(Period period) {
- List<TimeSpanDTO> listTimeSpanDTO = new ArrayList<TimeSpanDTO>();
- List<TimeSpan> listTimeSpan = searchListTimeSpan(period);
- for (TimeSpan timeSpan : listTimeSpan) {
- TimeSpanDTO timeSpanDTO = convertTimeSpan
- .timeSpanEntityToDto(timeSpan);
- listTimeSpanDTO.add(timeSpanDTO);
- }
- return listTimeSpanDTO;
- }*/
-
- /*
- * Permet de bloquer un timespan, celle-ci ne doit pas être bloquée.
- * La fonction doit s'assurer que les timeSpans précédents doivent être
- * bloqués.
- * Les transactions doivent être équilibrées
- * @param timespan période qui doit être fermée
- * @param period période (12 smois)
- *
- public String blockTimeSpan(TimeSpan timespan) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si la période n'est pas déjà fermée.
- if (timespan.getLocked()) {
- if (log.isInfoEnabled()) {
- log.info("Timespan deja bloqué !");
+ TopiaQuery query = financialPeriodDAO.createQuery();
+ if (date != null){
+ query.add("beginDate = :value").addParam("value", date);
}
- } else {
- Period period = getPeriodWithTimeSpan(timespan);
- if (period.getLocked()) {
- if (log.isErrorEnabled()) {
- log.error("La période du timespan est bloquée !");
- }
- } else {
- // Vérifie si tous les timeSpans précédents sont bloqués
- boolean AllTimeSpanBlock = alltimeSpanBlocked(timespan, period);
- if (AllTimeSpanBlock) {
- // Enregistrement dans la base de données
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext
- .beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
-
- // Vérifie si les transactons sont équilibrées
- List<Transaction> listTransaction = transactionServiceImpl
- .searchListTransactionWithTimeSpan(timespan);
- boolean isTransactionBalanced = true;
- boolean existTransactionNotBalanced = false;
- for (Transaction transaction : listTransaction) {
- isTransactionBalanced = transactionServiceImpl
- .isTransactionBalanced(transaction);
- if (!isTransactionBalanced) {
- if (log.isInfoEnabled()) {
- log.info("La transaction n'est pas bloquée.");
- }
- existTransactionNotBalanced = true;
- }
- }
- if (!existTransactionNotBalanced) {
- // Bloque la période
- timespan.setLocked(true);
- // Mise à jour de timespan dans la BDD
- timeSpanDAO.update(timespan);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Timespan bloqué avec succès");
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- result = ServiceHelper.TRANSACTION_NOT_BALANCED;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- } else {
- if (log.isErrorEnabled()) {
- log.error("Il existe un ou plusieurs timespans précédents"
- + " non bloqués.");
- }
- result = ServiceHelper.TIMESPAN_PREC_NOT_BLOCK;
- }
- }
+ financialPeriod = financialPeriodDAO.findByQuery(query);
}
- return result;
- }*/
-
- /*
- * Permet de bloquer une période au format DTO.
- *
- * @param timespanDTO
- * @return
- *
- public String blockTimeSpan(TimeSpanDTO timespanDTO) {
- return blockTimeSpan(searchTimeSpanByDate(timespanDTO));
- }*/
-
- /*
- * Permet de débloquer un timespan, à condition que les timespans suivants
- * celui-ci soient bien débloqués.
- * @param timespan
- * @param period
- * @return
- *
- public String unblockTimeSpan(TimeSpan timespan) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si le timspan n'est pas bloqué
- if (!timespan.getLocked()) {
- if (log.isWarnEnabled()) {
- log.warn("Timespan non bloqué !");
- }
- } else {
- Period period = getPeriodWithTimeSpan(timespan);
- if (period.getLocked()) {
- if (log.isErrorEnabled()) {
- log.error("La période du timespan est bloquée !");
- }
- } else {
- boolean NextTimeSpanUnblock = nextTimeSpanUnblock(timespan,
- period);
- // Si aucun timespan suivant bloqué
- if (NextTimeSpanUnblock) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext
- .beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // débloque la période
- timespan.setLocked(false);
- // Mise à jour de timespan dans la BDD
- timeSpanDAO.update(timespan);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Timespan débloqué avec succès");
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- } else {
- result = ServiceHelper.TIMESPAN_NEXT_NOT_BLOCK;
- }
- }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
}
- return result;
- }*/
-
- /*
- * Permet de bloquer une période au format DTO.
- *
- * @param timespanDTO
- * @return
- *
- public String unblockTimeSpan(TimeSpanDTO timespanDTO) {
- return unblockTimeSpan(searchTimeSpanByDate(timespanDTO));
- }*/
-
- /*
- * Cette méthode va rechercher tous les timeSpans non bloqués après
- * le timeSpan renseigné en paramètre.
- * Si elle trouve au moins un timeSpan NON bloqué, elle renvoie alors faux.
- * Cette méthode permet essentiellement de définir si il est possible
- * ou non de bloquer un timeSpan. A savoir, un timeSpan ne peut être bloqué,
- * si il existe des timeSpans suivant (dans le calendrier) qui sont non
- * bloqués.
- * @param timespan
- * @param period
- * @return
- *
- private boolean nextTimeSpanUnblock(TimeSpan timespan, Period period) {
- boolean NextTimeSpanUnblock = false;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche des TimeSpans avec la même période.
- // (on doit récupérer normalement 12 timeSpans)
- List<TimeSpan> listeTimeSpanOfPeriod = timeSpanDAO
- .findAllByPeriod(period);
- NextTimeSpanUnblock = true;
- for (TimeSpan timeSpanNext : listeTimeSpanOfPeriod) {
- // Si le timespan est après celui qu'on souhaite bloquer ET est non bloqué
- if (timeSpanNext.getBeginTimeSpan().compareTo(
- timespan.getBeginTimeSpan()) == 1
- && timeSpanNext.getLocked()) {
- NextTimeSpanUnblock = false;
- if (log.isInfoEnabled()) {
- log.info("Timespan " + timeSpanNext.toString()
- + " est bloqué");
- }
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
+ finally {
+ doFinally(transaction, log);
}
- return NextTimeSpanUnblock;
- }*/
-
- /*
- * Permet de renvoyer une période dont appartient le timeSpan.
- * @param timeSpan timeSpan dont on souhaite retourner la période
- * @return
- *
- private Period getPeriodWithTimeSpan(TimeSpan timeSpan) {
- PeriodServiceImpl periodServiceImpl = new PeriodServiceImpl();
- Date beginTimeSpan = timeSpan.getBeginTimeSpan();
- Period period = periodServiceImpl.searchPeriodWithDate(beginTimeSpan);
- return period;
- }*/
-
- /*
- * Cette méthode renvoie vrai lorsque tous les timespans de la période
- * précédent au timespan en paramètre sont bloqués.
- * @param timespan
- * @param period le paramètre period est important, en effet un timespan ne
- * peut être indépendant.
- * @return
- *
- private boolean alltimeSpanBlocked(TimeSpan timespan, Period period) {
- boolean AllTimeSpanBlock = false;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche des TimeSpans avec la même période.
- // (on doit récupérer normalement 12 timeSpans)
- List<TimeSpan> listeTimeSpanOfPeriod = timeSpanDAO
- .findAllByPeriod(period);
- // Fermeture BDD
- topiaContext.closeContext();
- // On contrôle que les timeSpans précédents sont bloqués.
- AllTimeSpanBlock = true;
- for (TimeSpan timeSpanPrev : listeTimeSpanOfPeriod) {
- // Si la période est avant celle qu'on souhaite bloquer ET est non bloquée
- if (timeSpanPrev.getBeginTimeSpan().compareTo(
- timespan.getBeginTimeSpan()) == -1
- && !timeSpanPrev.getLocked()) {
- AllTimeSpanBlock = false;
- if (log.isInfoEnabled()) {
- log.info("Timespan " + timeSpanPrev.toString()
- + " non bloqué");
- }
- }
- }
- } catch (TopiaException e) {
- log.error(e);
+
+ return financialPeriod;
}
- return AllTimeSpanBlock;
- }*/
-
- /*
- * Permet d'effacer un timeSpan. Ce dernier ne doit pas être bloqué.
- * @param timeSpan
- * @return
- *
- public String removeTimeSpan(TimeSpan timeSpan) {
- String result = ServiceHelper.RESPOND_ERROR;
- // Si le timspan est bloqué
- if (timeSpan.getLocked()) {
- if (log.isWarnEnabled()) {
- log.warn("Timespan bloqué !");
- }
- } else {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Mise à jour de timespan dans la BDD
- timeSpanDAO.delete(timeSpan);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Timespan supprimé avec succès");
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Vérifie si le timeSpan donné en paramètre est bloqué ou non.
- * @param timeSpan
- * @return
- *
- public boolean isTimeSpanBlocked(TimeSpan timeSpan) {
- boolean isTimeSpanBlocked = true;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Mise à jour de timespan dans la BDD
- TimeSpan timeSpanSearch = timeSpanDAO.findByTopiaId(timeSpan
- .getTopiaId());
- isTimeSpanBlocked = timeSpanSearch.getLocked();
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return isTimeSpanBlocked;
- }*/
+
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -21,25 +21,21 @@
import static org.nuiton.i18n.I18n._;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
+import java.util.Collection;
import java.util.List;
-import java.util.ListIterator;
import javax.ejb.Stateless;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.AccountDAO;
+
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
-import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -47,12 +43,8 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.framework.TopiaContextImpl;
-import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.apache.commons.lang.time.DateUtils;
/**
* Gestion des exercices.
@@ -69,6 +61,8 @@
private FinancialPeriodServiceImpl financialPeriodService =
new FinancialPeriodServiceImpl();
+
+ protected AccountingRules accountingRules;
public FiscalPeriodServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -79,169 +73,28 @@
log.error("Can't init topia context", ex);
}
}
+ accountingRules = config.getAccountingRules();
}
/**
- * Permet de créer un exercice.
- *
- * Elle a une durée de un an, composées de 12 périodes mensuelles.
- * Elle peut aussi être plus courte ou plus longue si l'entreprise
- * se constitu ou entre en liquidation ou que l'entreprise decide
- * de changer
- *
- * Elle correspond à l'exercice comptable.
- * Pour créer une nouvelle période, la précédente doit être obligatoirement clôturée.
- *
- * @param beginTimeSpan date début de période
- * @param endTimeSpan date fin de période
- * @param lock Vrai si la période est bloquée
- * @return
+ * To create a fiscalperiod
+ * Check localized rules before create
*/
@Override
- public void createFiscalPeriod(FiscalPeriod fiscalPeriod /*Date beginTimeSpan, Date endTimeSpan, boolean lock*/) throws LimaException {
-
- /*// Par défaut lock est à false
- lock = false;
- String result = ServiceHelper.RESPOND_ERROR;
-
- try {
- boolean correctPeriod = false;
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Creation de la periodDate
- PeriodDates newPeriod = new PeriodDates(beginTimeSpan, endTimeSpan);
-
- // Creation de la période
- Period period = periodDAO.create();
- period.setBeginPeriod(newPeriod.getFromDate());
- period.setEndPeriod(newPeriod.getThruDate());
- period.setLocked(lock);
- // Vérification si la période est correcte
- correctPeriod = isCorrectPeriod(period);
- if (correctPeriod) {
- // Si elle est correcte : Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("Ajout exercice du " + beginTimeSpan.toString()
- + " au " + endTimeSpan.toString());
- }
-
- //Ajout des timeSpans mensuels
- //Par défaut, il prend seulement la date beginTimeSpan, et calcule
- //la date de fin, c'est pourquoi il est laissé deux fois "beginTimeSpan"
- TimeSpanServiceImpl timeSpanImpl = new TimeSpanServiceImpl();
- boolean stop = false; // En cas d'erreur lors de la création d'un timeSpan.
-
- List<Date> monthList = newPeriod.getMonths();
-
- int max = monthList.size();
- log.debug("la periode fait:" + max);
- for (int i = 0; i < max; i++) {
- // Création timeSpan
- result = timeSpanImpl.createTimeSpan(monthList.get(i),
- monthList.get(i), period, false);
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- stop = true;
- if (log.isErrorEnabled()) {
- log.error("Erreur lors de la création des " + max
- + " timeSpans");
- }
- result = ServiceHelper.PERIOD_CREATE_TIMESPANS;
- }
- // Supprimer la periode si stop = true
- }
- if (stop == false) {
- result = ServiceHelper.RESPOND_SUCCESS;
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return result; */
-
- // un exercice ne peut pas faire plus de 24 mois dans tous les cas
-
- // un exercice doit faire au moins une période
- /*if ( fiscalPeriod.getFinancialPeriod() == null ||
- fiscalPeriod.getFinancialPeriod().isEmpty()) {
- throw new LimaBusinessException(_("A fiscal period must have at least one financial period !"));
- }*/
-
- // un exercice doit être collé au precedent
-
- // un exercice ne peut être crée que si l'ante precedent est fermé
- // on peut creer un exercice si le precedent n'est pas fermé
- boolean valid=false;
+ public void createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+
TopiaContext transaction = null;
try {
-
// basic check done, make check in database
// TODO move it into JTA
transaction = rootContext.beginTransaction();
+
+ //check rules before create the account
+ accountingRules.createFiscalPeriodRules(fiscalPeriod, transaction);
+
FiscalPeriodDAO fiscalPeriodDAO =
LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
- //check if the enddate period is after the begindate period
- if (fiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())){
- //TODO Exception
- throw new LimaBusinessException(
- "The enddate is before the begindate");
- }
-
- //Checks if is not the first fiscalperiod to create
- if (fiscalPeriodDAO.findAll().size()!=0){
-
- TopiaQuery query = fiscalPeriodDAO.createQuery();
- fiscalPeriodDAO.findAllByQuery(query);
- query.addOrderDesc(FiscalPeriod.END_DATE);
-
- //get the last fiscal period
- FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.findByQuery(query);
- log.debug("lastFiscalPeriod : "+lastFiscalPeriod);
-
- //check the new fiscal period adjoining the last
- Date dateLastFiscalPeriod=lastFiscalPeriod.getEndDate();
- dateLastFiscalPeriod = DateUtils.
- addMilliseconds(dateLastFiscalPeriod, 1);
- Date dateFiscalPeriod=fiscalPeriod.getBeginDate();
- if(dateLastFiscalPeriod.compareTo(dateFiscalPeriod)!=0){
- throw new LimaBusinessException(
- "The new fiscalperiod must adjoining the last");
- }
-
-
- //We can create a new fiscal period meantime the last fiscal period was not locked
- //But not the ante periodfiscal
- int unblockedFiscalPeriod =
- fiscalPeriodDAO.findAllByLocked(false).size();
- log.debug(unblockedFiscalPeriod);
- if (unblockedFiscalPeriod>1){
- throw new LimaBusinessException(
- "The ante fiscal period is not locked");
- }
- }
-
- Date beginDate = fiscalPeriod.getBeginDate();
- Date endDate = fiscalPeriod.getEndDate();
-
- // FinancialPeriod of 1 month are created
- Date loopDate = beginDate;
- while (loopDate.compareTo(endDate) <= 0) {
- Date loopUpperDate = DateUtils.addMonths(loopDate, 1);
- Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1);
- FinancialPeriod financialPeriod = new FinancialPeriodImpl();
- financialPeriod.setBeginDate(loopDate);
- financialPeriod.setEndDate(periodEndDate);
- fiscalPeriod.addFinancialPeriod(financialPeriod);
- loopDate = loopUpperDate;
- log.debug("financialPeriod : "+financialPeriod);
- financialPeriodService.createFinancialPeriod(financialPeriod);
- }
//create
fiscalPeriodDAO.create(fiscalPeriod);
@@ -257,6 +110,9 @@
}
+ /**
+ * return all fiscal period
+ */
public List<FiscalPeriod> getAllFiscalPeriods() throws LimaException {
List<FiscalPeriod> result = null;
@@ -284,6 +140,9 @@
return result;
}
+ /**
+ * return all unblocked fiscal periods
+ */
public List<FiscalPeriod> getAllUnblockedFiscalPeriods() throws LimaException {
List<FiscalPeriod> result = null;
@@ -300,7 +159,8 @@
//IMPORTANT : LOADING FINANCIAL PERIOD FOR NO LAZY EXCEPTION
for (FiscalPeriod fiscalPeriod : result) {
- //FIXME besoin d'appeler une lecture bidon de toutes les financialperiod sinon il pete tout de même une lazy exception
+ //FIXME besoin d'appeler une lecture bidon de toutes les financialperiod
+ //sinon il pete tout de même une lazy exception
for (FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()) {
}
}
@@ -318,48 +178,53 @@
return result;
}
+ /**
+ * to block a fiscal period
+ *
+ * check localized rules before block it
+ *
+ * Two transaction are necessary for no object conflict
+ * FIXME can found best solution ?!
+ */
@Override
public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
TopiaContext transaction = null;
+
+ //open transaction for check
try {
transaction = rootContext.beginTransaction();
if (fiscalPeriod.getLocked()==true){
throw new LimaBusinessException("Fiscal Period already blocked");
}
+ //check rules
+ accountingRules.blockFiscalPeriodRules(fiscalPeriod, transaction);
- //TODO verifier que les exercices anterieur a l'exerice à bloquer sont bloqués
- FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ } catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
- TopiaQuery query = fiscalPeriodDAO.createQuery();
- fiscalPeriodDAO.findAllByQuery(query);
- query.add(FiscalPeriod.LOCKED, Op.EQ, false);
- query.addOrder(FiscalPeriod.END_DATE);
- // query.add(TopiaEntity.TOPIA_ID, fiscalPeriod.getTopiaId());
- //int oldestblocked = query.executeCount();
+ //open transaction for update
+ try {
+ transaction = rootContext.beginTransaction();
- FiscalPeriod oldestUnBlockedFiscalPeriod = fiscalPeriodDAO.findByQuery(query);
- //log.debug("oldestUnBlockedFiscalPeriod : "+oldestUnBlockedFiscalPeriod);
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
- //Check if the fiscal period to block is the oldest
- if (!oldestUnBlockedFiscalPeriod.equals(fiscalPeriod)){
- throw new LimaBusinessException("The ante fiscal period must be blocked before this.");
- }
-
- oldestUnBlockedFiscalPeriod.setLocked(true);
-
+ // lock fiscalperiod
+ fiscalPeriod.setLocked(true);
// locked all financialperiod of the fiscalperiod
- for ( FinancialPeriod financialPeriod : oldestUnBlockedFiscalPeriod.getFinancialPeriod()) {
+ for ( FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()) {
+ log.debug(financialPeriod);
financialPeriod.setLocked(true);
+ log.debug(financialPeriod);
}
+ fiscalPeriodDAO.update(fiscalPeriod);
- /* //FIXME JP 23/04/2010 code à changer pour ne pas dépendre de l'impl
- TopiaContextImpl topiaContextImpl = (TopiaContextImpl) transaction;
- topiaContextImpl.getHibernate().evict(oldestUnBlockedFiscalPeriod);*/
- // update account
- fiscalPeriodDAO.update(oldestUnBlockedFiscalPeriod);
-
// commit
transaction.commitTransaction();
@@ -371,6 +236,10 @@
}
}
+ /**
+ * just for debug, this method must delete
+ * Unauthorized action for user !!!
+ */
public void removeAllFiscalPeriods() throws LimaException{
TopiaContext transaction = null;
try {
@@ -397,378 +266,4 @@
doFinally(transaction, log);
}
}
-
- /*
- * Permet de créer une période à partir d'une période DTO.
- * @param periodDTO période à créer au format DTO.
- * @return
- *
- public String createPeriod(PeriodDTO periodDTO) {
- String result = createPeriod(periodDTO.getBeginPeriod(), periodDTO
- .getEndPeriod(), false);
- // Tous les timeSpans sont automatiquement créés avec la méthode createPeriod
- return result;
- }*/
-
- /*
- * Permet de vérifier si la période est correcte (aucun chevauchement avec
- * les autres périodes, période(s) précédente(s) bloquée(s), formée de 1 à 24
- * mois).
- * @param period période à tester si elle est correcte
- * @return
- *
- private boolean isCorrectPeriod(Period period) {
- // Calcul du nombre de mois pour que la période soit valide (12 mois)
- int number_months = dateUtil.numberOfMonths(period.getBeginPeriod(),
- period.getEndPeriod());
- boolean result = true;
-
- if (number_months == 0 && number_months >= 24) // Periode de 1mois a 24 mois
- {
- if (log.isErrorEnabled()) {
- log.error("Période du "
- + period.getBeginPeriod()
- + " au "
- + period.getEndPeriod()
- + " : L'exercice doit faire au minimum 1 mois et au maximum 24 mois");
- }
- result = false;
- } else {
- // Période(s) précédente(s) bloquée(s).
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Recherche les périodes qui ne sont pas bloquées.
- List<Period> listePeriod = periodDAO.findAllByLocked(false);
- // Recherche la dernière période, les dates doivent se suivre
- Date date_search = period.getBeginPeriod();
- Period previousPeriod = periodDAO.findByEndPeriod(dateUtil
- .previousDay(date_search));
- // Nombre de périodes dans la base
- int number_period = periodDAO.findAll().size();
- // Fermeture BDD
- topiaContext.closeContext();
- // Si il y a au moins une période trouvée
- if (!(listePeriod.isEmpty())) {
- if (log.isErrorEnabled()) {
- log.error("Il existe au moins une période précédente non bloquée !");
- }
- result = false;
- }
- // Si la période précédente correspond au jour précédent
- // et vérifie si ce n'est pas la première période
- if (previousPeriod == null && number_period != 0) {
- if (log.isErrorEnabled()) {
- log.error("Votre période doit être collée "
- + "aux autres périodes !"
- + date_search.toString() + " PPP "
- + dateUtil.previousDay(date_search).toString());
- }
- result = false;
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Cette méthode permet de bloquer une période. Elle doit vérifier que
- * tous les timeSpans mensuels sont bloqués.
- * @param
- * @return
- *
- public String blockPeriod(Period period) {
- String result = ServiceHelper.RESPOND_ERROR;
- // La période ne doit pas être nulle
- if (period != null) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TimeSpanDAO timeSpanDAO = LimaCallaoDAOHelper
- .getTimeSpanDAO(topiaContext);
- // Recherche tous les timeSpans de la période non bloquées
- List<TimeSpan> listeTimeSpan = timeSpanDAO
- .findAllByPeriod(period);
- boolean existTimeSpanNotBlock = false;
- for (TimeSpan timeSpan : listeTimeSpan) {
- // Si timeSpan non bloqué
- if (!timeSpan.getLocked()) {
- existTimeSpanNotBlock = true;
- if (log.isErrorEnabled()) {
- log.error("Le timeSpan du "
- + timeSpan.getBeginTimeSpan().toString()
- + " au "
- + timeSpan.getEndTimeSpan().toString()
- + " non bloqué !");
- }
- result = ServiceHelper.PERIOD_TIMESPAN_NOT_BLOCK;
- }
- }
- // Si il n'existe pas de timeSpan non bloqué
- if (!(existTimeSpanNotBlock)) {
- // Bloque la période
- period.setLocked(true);
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- periodDAO.update(period);
- // Création BDD
- topiaContext.commitTransaction();
- result = ServiceHelper.RESPOND_SUCCESS;
- if (log.isInfoEnabled()) {
- log.info("Période "
- + period.getBeginPeriod().toString() + " au "
- + period.getEndPeriod().toString()
- + " bloquée avec succès.");
- }
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Permet de bloquer une période. Avec la périodeDTO passée en paramètre, on
- * effectue une recherche avec la date de début pour récupérer la période
- * dans la base de données. Il est possible de l'identifier avec son topiaId,
- * mais il y a plus de risque que cette mentien ne soit pas renseignée dans
- * l'objet periodDTO.
- * @param periodDTO
- * @return
- *
- public String blockPeriod(PeriodDTO periodDTO) {
- // Recherche de la période
- Period period = searchPeriodWithDate(periodDTO.getBeginPeriod());
- String result = blockPeriod(period);
- return result;
- }*/
-
- /*
- * Permet de bloquer TOUS les timeSpans de la période
- * @param period
- * @return
- *
- public String blockAllTimeSpanOfPeriod(Period period) {
- String result = ServiceHelper.RESPOND_ERROR;
- if (period == null) {
- if (log.isErrorEnabled()) {
- log.error("La période ne peut bloquer ses périodes mensuelles, "
- + "il faut une période en entrée.");
- }
- } else {
- // On bloque chaque timeSpan
- boolean ErrorBlockTimeSpan = false;
- List<TimeSpanDTO> listTimeSpanDTO = timeSpanServiceImpl
- .searchListTimeSpanDTO(period);
- // tri la liste des timeSpans dans l'ordre croissant des dates
- Collections.sort(listTimeSpanDTO);
- for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
- result = timeSpanServiceImpl.blockTimeSpan(timeSpanDTO);
- if (result.equals(ServiceHelper.RESPOND_ERROR)) {
- ErrorBlockTimeSpan = true;
- }
- }
- // Si il n'y a pas eu d'erreurs pour bloquer les timespans
- if (!ErrorBlockTimeSpan) {
- result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- if (log.isErrorEnabled()) {
- log.error("Impossible de bloquer tous les timeSpans.");
- }
- result = ServiceHelper.PERIOD_ALL_TIMESPAN;
- }
- }
- return result;
- }*/
-
- /*
- * Cette méthode est semblable à searchPeriodWithDateFirst. Elle permet
- * de rechercher une période sans forcément connaître la date de départ. On
- * donne une date quelconque, et elle retourne la période correspondante.
- * @param d
- * @return
- *
- public Period searchPeriodWithDate(Date d) {
- Period period = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Recherche de toutes les périodes
- List<Period> listePeriod = periodDAO.findAll();
- // Fermeture BDD
- topiaContext.closeContext();
- // Recherche de la période
- for (Period periodSearch : listePeriod) {
- // Recherche si la date d est entre la date de début et fin de la période
- boolean periodBetweenDate = dateUtil.betweenDate(d,
- periodSearch.getBeginPeriod(), periodSearch
- .getEndPeriod());
- // Si la date est comprise dans les limites de la période
- if (periodBetweenDate) {
- period = periodSearch;
- }
- }
- } catch (TopiaException e) {
- log.error(e);
- }
- return period;
- }*/
-
- /*
- * Permet de rechercher une période au format DTO avec une date. Cette date
- * peut être quelconque (pas obligatoire d'être le premier jour de la période
- * par exemple).
- * @param d date comprise dans la période qu'on souhaite rechercher
- * @return
- *
- public PeriodDTO searchPeriodDTOWithDate(Date d) {
- Period period = searchPeriodWithDate(d);
- // Converti la période en PeriodDTO
- PeriodDTO periodDTO = convertPeriod.periodEntityToDto(period);
- return periodDTO;
- }*/
-
- /*
- * Permet de renvoyer tous les périodes en format DTO, avec tous les timeSpans
- * en format DTO également.
- * @return
- *
- public List<PeriodDTO> getAllPeriod() {
- ArrayList<PeriodDTO> listAllPeriodDTO = new ArrayList<PeriodDTO>();
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Recherche de toutes les périodes
- List<Period> listePeriod = periodDAO.findAll();
- // Transforme les périodes en DTO
- for (Period period : listePeriod) {
- PeriodDTO periodDTO = convertPeriod.periodEntityToDto(period);
- listAllPeriodDTO.add(periodDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return listAllPeriodDTO;
- }*/
-
- /*
- * Recherche une période précise, avec son identifiant topiaId.
- * @param topiaId identifiant de la période
- * @return
- *
- public Period searchPeriodWithTopiaId(String topiaId) {
- Period periodSearch = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Creation du journal
- periodSearch = periodDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return periodSearch;
- }*/
-
-
- /*
- * Efface une période dans la base de données. Tous les timeSpans sont
- * également effacés. Cette méthode est uniquement utilisée pour les tests
- * unitaires.
- * @param period
- * @return
- *
- public String removePeriod(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
- Period periodDelete = searchPeriodWithTopiaId(topiaId);
- // Si la période n'existe pas
- if (periodDelete == null) {
- if (log.isWarnEnabled()) {
- log.warn("La période " + topiaId + " n'existe pas !");
- }
- result = ServiceHelper.PERIOD_NOT_EXIST;
- } else // Sinon on efface la période
- {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- PeriodDAO periodDAO = LimaCallaoDAOHelper
- .getPeriodDAO(topiaContext);
- // Débloque la période
- periodDelete.setLocked(false);
- // Mise à jour dans la bdd
- periodDAO.update(periodDelete);
- // Création BDD
- topiaContext.commitTransaction();
-
- // Supprime les timeSpans de la période
- List<TimeSpanDTO> listTimeSpanDTO = timeSpanServiceImpl
- .searchListTimeSpanDTO(periodDelete);
- // tri la liste des timeSpans dans l'ordre décroissant des dates
- Collections.sort(listTimeSpanDTO, Collections.reverseOrder());
- // Débloque les timeSpans
- for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(timeSpanDTO);
- // Si le timeSpan est bloqué
- if (timeSpanDTO.isLocked()) {
- // débloque le timeSpan
- timeSpanServiceImpl.unblockTimeSpan(timeSpan);
- }
- }
- // Efface les timeSpans
- for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) {
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(timeSpanDTO);
- // efface le timeSpan
- timeSpanServiceImpl.removeTimeSpan(timeSpan);
- }
-
-
- //Supprime la période
- periodDAO.delete(periodDelete);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return result;
- }*/
-
- /*
- * Permet d'effacer une période au format DTO.
- * @param periodDTO la période à supprimer
- * @return
- *
- public String removePeriod(PeriodDTO periodDTO) {
- String result = removePeriod(periodDTO.getId());
- return result;
- }*/
}
Modified: trunk/lima-business/src/main/resources/lima.properties
===================================================================
--- trunk/lima-business/src/main/resources/lima.properties 2010-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-business/src/main/resources/lima.properties 2010-05-04 13:44:56 UTC (rev 2883)
@@ -6,4 +6,6 @@
hibernate.connection.username=sa
hibernate.connection.password=
hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:~/.lima/limadb
\ No newline at end of file
+hibernate.connection.url=jdbc:h2:file:~/.lima/limadb
+
+lima.rules=org.chorem.lima.business.accountingrules.FranceAccountingRules
\ No newline at end of file
Modified: trunk/lima-callao/pom.xml
===================================================================
--- trunk/lima-callao/pom.xml 2010-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-callao/pom.xml 2010-05-04 13:44:56 UTC (rev 2883)
@@ -86,3 +86,4 @@
</build>
</project>
+
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-05-04 13:44:56 UTC (rev 2883)
@@ -1,8 +1,9 @@
# 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.subLedgers.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.Account.attribute.identity.tagvalue.lazy=false
+org.chorem.lima.entity.FiscalPeriod.attribute.financialPeriod.tagvalue.lazy=false
-org.chorem.lima.entity.Account.attribute.identity.tagvalue.lazy=false
#model.tagvalue.dbSchema=Callao
model.tagvalue.String=text
\ No newline at end of file
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-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -251,21 +251,7 @@
Account account = (Account) treePath.getLastPathComponent();
try{
- try {
- accountsTreeTableModel.removeAccount(treePath, account);
- }
- catch(LimaBusinessException ex){
- 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
- accountsTreeTableModel.
- removeAccountwithSubAccounts(treePath, account);
- }
- }
+ accountsTreeTableModel.removeAccount(treePath, account);
} catch (LimaException ex) {
if (log.isErrorEnabled()) {
log.error("Can't delete account", ex);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-04 13:22:41 UTC (rev 2882)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-04 13:44:56 UTC (rev 2883)
@@ -31,6 +31,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.FinancialTransactionService;
@@ -39,6 +40,7 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
@@ -79,6 +81,9 @@
/** EntryBook service. */
protected final EntryBookService entryBookService;
+ /** FinancialPeriod service. */
+ protected final FinancialPeriodService financialPeriodService;
+
protected FinancialPeriod selectedFinancialPeriod;
/**
@@ -93,6 +98,8 @@
.getTransactionService();
entryBookService = LimaServiceFactory.getInstance().
getEntryBookService();
+ financialPeriodService = LimaServiceFactory.getInstance().
+ getFinancialPeriodService();
}
/**
@@ -370,7 +377,8 @@
// create it
transactionService.createFinancialTransaction(financialTransaction);
int row = getDataList().indexOf(financialTransaction);
- fireTableRowsInserted(row, row);
+ //FIXME Invalid range
+ fireTableRowsInserted(row, row);
}
else {
throw new LimaBusinessException("No financial period selected");
@@ -419,7 +427,47 @@
(FinancialTransaction)currentRow;
switch (column) {
case 0:
- currentFinancialTransaction.setTransactionDate((Date)value);
+ // Truncate the date - format 01-MM-YYYY
+ Date dateCurrentFinancialTransaction = ((Date)value);
+ dateCurrentFinancialTransaction =
+ DateUtils.truncate(
+ dateCurrentFinancialTransaction, Calendar.MONTH);
+
+ // Return the begin date of the current financial period
+ Date dateCurrentFinancialPeriod =
+ selectedFinancialPeriod.getBeginDate();
+
+ // Compare to the begindate of the current financial period
+ if (!dateCurrentFinancialPeriod.equals(dateCurrentFinancialTransaction)){
+ //methode get financialperiod dans le service
+ FinancialPeriod newFinancialPeriod =
+ new FinancialPeriodImpl();
+ try {
+ newFinancialPeriod =
+ financialPeriodService.getFinancialPeriodWithDate(
+ dateCurrentFinancialTransaction);
+ } catch (LimaException e) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't get new financialPeriodService");
+ }
+ }
+ //if the changed financial period is unlocked
+ if (newFinancialPeriod != null){
+ if (newFinancialPeriod.getLocked() == false){
+ //update
+ currentFinancialTransaction.
+ setTransactionDate((Date)value);
+ currentFinancialTransaction.
+ setFinancialPeriod(newFinancialPeriod);
+ }
+ }
+ else {
+ if (log.isDebugEnabled()){
+ log.debug("Can't update on the new date");
+ }
+ }
+ }
+
break;
}
// notify service for modification
@@ -432,7 +480,7 @@
}
}
//update the financial transaction row
- fireTableRowsUpdated(row, row);
+ //fireTableRowsUpdated(row, row);
}
else if (currentRow instanceof Entry) {
Entry currentEntry = (Entry)currentRow;
@@ -470,8 +518,10 @@
}
//update the financial transaction in entire
int financialTransactionRow =
- getDataList().indexOf(((Entry) currentRow).getFinancialTransaction());
- fireTableRowsUpdated(financialTransactionRow, financialTransactionRow);
+ getDataList().indexOf(((Entry) currentRow).
+ getFinancialTransaction());
+ fireTableRowsUpdated(financialTransactionRow,
+ financialTransactionRow);
}
}
else {
1
0
04 May '10
Author: echatellier
Date: 2010-05-04 15:22:41 +0200 (Tue, 04 May 2010)
New Revision: 2882
Url: http://chorem.org/repositories/revision/lima/2882
Log:
Always call super();
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-04-30 11:21:57 UTC (rev 2881)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-05-04 13:22:41 UTC (rev 2882)
@@ -78,6 +78,8 @@
*/
public LimaConfig() {
+ super();
+
// set defaut option (included configuration file name : important)
for (Option o : Option.values()) {
setDefaultOption(o.key, o.defaultValue);
1
0