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
r2908 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
by jpepin@users.chorem.org 26 May '10
by jpepin@users.chorem.org 26 May '10
26 May '10
Author: jpepin
Date: 2010-05-26 14:59:22 +0200 (Wed, 26 May 2010)
New Revision: 2908
Url: http://chorem.org/repositories/revision/lima/2908
Log:
Optimisation req?\195?\187ete calcul montant et soldes. Calcul des montants et affichage des entr?\195?\169es d'un regrouprement de compte
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-05-25 16:24:52 UTC (rev 2907)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-05-26 12:59:22 UTC (rev 2908)
@@ -87,69 +87,44 @@
return reportsDatas;
}
-
+ /**
+ * List entries for a period and an account
+ * Calculate the amounts
+ * Two case:
+ * - for subaccount
+ * - for a foldaccounts, contains many accounts
+ */
public ReportsDatas generateAccountReportsWithTransaction (Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException{
ReportsDatas reportsDatas = new ReportsDatasImpl();
double credit = 0, debit = 0, solde = 0;
+ List<Object[]> results = new ArrayList<Object[]>();
String queryAlias = "E";
if (account != null){
- try {
- EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- reportsDatas.setListEntry(entryDAO.findAllByQuery(
- createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias)));
- /*
- TopiaQuery debitQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- debitQuery.add(Entry.DEBIT, Boolean.TRUE).setSelect(Entry.AMOUNT);
- //List<Object[]> debitObject = debitQuery.execute();
- //log.debug(debitObject);
-
- TopiaQuery creditQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- creditQuery.add(Entry.DEBIT, Boolean.FALSE).setSelect(Entry.AMOUNT);
- //List<Object[]> creditObject = creditQuery.execute();
- //log.debug(creditObject);
-
- TopiaQuery soldeQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
- soldeQuery.setSelect("SUM(" + debitQuery.fullQuery() + ") as debit")
- .addParams(debitQuery.getParams())
- .addSelect("SUM(" + creditQuery.fullQuery() + ") as credit")
- .addParams(creditQuery.getParams())
- .addSelect("(debit - credit) as solde");
- log.debug(soldeQuery);
- List<Object[]> soldeObject = soldeQuery.execute();
- log.debug(soldeObject);
-
- */
-
- /*query.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
- query.addGroup("E."+Entry.DEBIT);
- List<Object[]> results = query.execute();
- for (Object[] result : results) {
- if ((Boolean)result[0]){
- debit += (Double)result[1];
- }
- else {
- credit += (Double)result[1];
- }
- }
- // set the amounts and solde
- solde = debit - credit;
- if (solde > 0){
- reportsDatas.setSoldeDebit(true);
- }
- solde = Math.abs(solde);*/
-
+ // First subaccount
+ List<Account> accounts = account.getSubAccounts();
+ if (accounts.size() == 0){
+ reportsDatas = generateSubAccountReportsWithTransaction(account, beginDate, endDate, topiaContext);
+ }
+ //Second many account
+ else {
+ List<Entry> entries = new ArrayList<Entry>();
+ for (Account subAccount : accounts) {
+ ReportsDatas subReportsDatas = generateAccountReportsWithTransaction(subAccount, beginDate, endDate, topiaContext);
+ debit += subReportsDatas.getAmountDebit();
+ credit += subReportsDatas.getAmountCredit();
+ entries.addAll(subReportsDatas.getListEntry());
+ }
+ solde = debit - credit;
+ if (solde > 0){
+ reportsDatas.setSoldeDebit(true);
+ }
+ solde = Math.abs(solde);
reportsDatas.setAmountCredit(credit);
reportsDatas.setAmountDebit(debit);
reportsDatas.setAmountSolde(solde);
-
- // commit
- topiaContext.commitTransaction();
+ reportsDatas.setListEntry(entries);
}
- catch (TopiaException ex) {
- doCatch(topiaContext, ex, log);
- }
}
-
return reportsDatas;
}
@@ -163,13 +138,63 @@
query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
.addParam("beginDate", beginDate)
.addParam("endDate", endDate)
- .add(Entry.ACCOUNT, account)
- //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- .addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION);
+ .add(Entry.ACCOUNT, account);
return query;
}
+ public ReportsDatas generateSubAccountReportsWithTransaction(Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException {
+ ReportsDatas reportsDatas = new ReportsDatasImpl();
+ double credit = 0, debit = 0, solde = 0;
+ List<Object[]> results = new ArrayList<Object[]>();
+ String queryAlias = "E";
+ try {
+ EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ TopiaQuery entriesQuery =
+ createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ entriesQuery.addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION);
+ reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery));
+
+ TopiaQuery amountsQuery =
+ createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
+ amountsQuery.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
+ amountsQuery.addGroup("E."+Entry.DEBIT);
+ results = amountsQuery.execute();
+ int nbAmount = results.size();
+ if(nbAmount==2){
+ debit = (Double)results.get(0)[1];
+ credit = (Double)results.get(1)[1];
+ }
+ if (nbAmount==1){
+ if ((Boolean)results.get(0)[0]){
+ debit = (Double)results.get(0)[1];
+ }
+ else {
+ credit = (Double)results.get(0)[1];
+ }
+ }
+
+ // set the amounts and solde
+ solde = debit - credit;
+ if (solde > 0){
+ reportsDatas.setSoldeDebit(true);
+ }
+ solde = Math.abs(solde);
+
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
+ // commit
+ topiaContext.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ return reportsDatas;
+ }
+
/**
* Get all entry from an entrybook and a begin-end dates order by financial transaction date
*
1
0
r2907 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/combobox
by jpepin@users.chorem.org 25 May '10
by jpepin@users.chorem.org 25 May '10
25 May '10
Author: jpepin
Date: 2010-05-25 18:24:52 +0200 (Tue, 25 May 2010)
New Revision: 2907
Url: http://chorem.org/repositories/revision/lima/2907
Log:
Optimisation affichage des combobox, optimisation requ?\195?\170te des totaux soldes en cours.
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/ReportServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
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-25 13:52:22 UTC (rev 2906)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-25 16:24:52 UTC (rev 2907)
@@ -33,6 +33,7 @@
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
+import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.FinancialPeriod;
@@ -310,6 +311,11 @@
//Get closedperiodicentrybook from unlocked fiscalperiod
TopiaQuery query = closedPeriodicEntryBookDAO.createQuery("E");
+ //IMPORTANT : LOADING ClosedPeriodicEntryBook AND IS COLUMN FOR NO LAZY EXCEPTION
+ String loadEntryBookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.ENTRY_BOOK, EntryBook.LABEL);
+ query.addLoad(loadEntryBookProperty);
+ String loadFinancialPeriodProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE);
+ query.addLoad(loadFinancialPeriodProperty);
query.addFrom(FiscalPeriod.class, "F")
.addInElements("E." + ClosedPeriodicEntryBook.FINANCIAL_PERIOD,
"F."+FiscalPeriod.FINANCIAL_PERIOD)
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-05-25 13:52:22 UTC (rev 2906)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-05-25 16:24:52 UTC (rev 2907)
@@ -91,60 +91,85 @@
public ReportsDatas generateAccountReportsWithTransaction (Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException{
ReportsDatas reportsDatas = new ReportsDatasImpl();
double credit = 0, debit = 0, solde = 0;
-
- try {
- EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- TopiaQuery query = entryDAO.createQuery("E");
-
- if (beginDate != null && endDate != null){
- String transactionDateProperty =
- TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
- FinancialTransaction.TRANSACTION_DATE);
- query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
- .addParam("beginDate", beginDate)
- .addParam("endDate", endDate);
- }
-
- if (account != null) {
- query
- .add(Entry.ACCOUNT, account)
- //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- .addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION);
- reportsDatas.setListEntry(entryDAO.findAllByQuery(query));
+ String queryAlias = "E";
+ if (account != null){
+ try {
+ EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ reportsDatas.setListEntry(entryDAO.findAllByQuery(
+ createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias)));
+ /*
+ TopiaQuery debitQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
+ debitQuery.add(Entry.DEBIT, Boolean.TRUE).setSelect(Entry.AMOUNT);
+ //List<Object[]> debitObject = debitQuery.execute();
+ //log.debug(debitObject);
- query.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
- query.addGroup("E."+Entry.DEBIT);
- List<Object[]> results = query.execute();
- for (Object[] result : results) {
- if ((Boolean)result[0]){
- debit += (Double)result[1];
- }
- else {
- credit += (Double)result[1];
- }
- }
- // set the amounts and solde
- solde = debit - credit;
- if (solde > 0){
- reportsDatas.setSoldeDebit(true);
- }
- solde = Math.abs(solde);
+ TopiaQuery creditQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
+ creditQuery.add(Entry.DEBIT, Boolean.FALSE).setSelect(Entry.AMOUNT);
+ //List<Object[]> creditObject = creditQuery.execute();
+ //log.debug(creditObject);
+
+ TopiaQuery soldeQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
+ soldeQuery.setSelect("SUM(" + debitQuery.fullQuery() + ") as debit")
+ .addParams(debitQuery.getParams())
+ .addSelect("SUM(" + creditQuery.fullQuery() + ") as credit")
+ .addParams(creditQuery.getParams())
+ .addSelect("(debit - credit) as solde");
+ log.debug(soldeQuery);
+ List<Object[]> soldeObject = soldeQuery.execute();
+ log.debug(soldeObject);
+
+ */
+
+ /*query.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
+ query.addGroup("E."+Entry.DEBIT);
+ List<Object[]> results = query.execute();
+ for (Object[] result : results) {
+ if ((Boolean)result[0]){
+ debit += (Double)result[1];
+ }
+ else {
+ credit += (Double)result[1];
+ }
+ }
+ // set the amounts and solde
+ solde = debit - credit;
+ if (solde > 0){
+ reportsDatas.setSoldeDebit(true);
+ }
+ solde = Math.abs(solde);*/
+
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
+ // commit
+ topiaContext.commitTransaction();
}
-
- reportsDatas.setAmountCredit(credit);
- reportsDatas.setAmountDebit(debit);
- reportsDatas.setAmountSolde(solde);
-
- // commit
- topiaContext.commitTransaction();
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
}
- catch (TopiaException ex) {
- doCatch(topiaContext, ex, log);
- }
return reportsDatas;
}
+
+ public TopiaQuery createEntryQuery(Account account, Date beginDate, Date endDate, EntryDAO entryDAO, String queryAlias) throws LimaException{
+ TopiaQuery query = entryDAO.createQuery(queryAlias);
+
+ String transactionDateProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.TRANSACTION_DATE);
+ query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
+ .addParam("beginDate", beginDate)
+ .addParam("endDate", endDate)
+ .add(Entry.ACCOUNT, account)
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ .addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION);
+
+ return query;
+ }
+
/**
* Get all entry from an entrybook and a begin-end dates order by financial transaction date
*
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-05-25 13:52:22 UTC (rev 2906)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-05-25 16:24:52 UTC (rev 2907)
@@ -2,11 +2,8 @@
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.identity.tagvalue.lazy=false
org.chorem.lima.entity.FinancialTransaction.attribute.financialPeriod.tagvalue.lazy=false
org.chorem.lima.entity.FiscalPeriod.attribute.financialPeriod.tagvalue.lazy=false
-org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.financialPeriod.tagvalue.lazy=false
-org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.entryBook.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/combobox/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-25 13:52:22 UTC (rev 2906)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-25 16:24:52 UTC (rev 2907)
@@ -43,10 +43,13 @@
protected Object selectedAccount;
+ protected List<Account> datasCache;
+
protected AccountService accountService;
public AccountComboBoxModel() {
accountService = LimaServiceFactory.getInstance().getAccountService();
+ datasCache = getDataList();
}
@Override
@@ -67,12 +70,12 @@
@Override
public Object getElementAt(int index) {
- return getDataList().get(index);
+ return datasCache.get(index);
}
@Override
public int getSize() {
- return getDataList().size();
+ return datasCache.size();
}
@Override
@@ -82,7 +85,7 @@
}
public List<Account> getDataList(){
- List<Account> result = new ArrayList<Account>();
+ List<Account> result = null;
try {
result = accountService.getAllAccounts();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-05-25 13:52:22 UTC (rev 2906)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-05-25 16:24:52 UTC (rev 2907)
@@ -49,8 +49,11 @@
protected EntryBookService entryBookService;
+ protected List<EntryBook> cacheDatas;
+
public EntryBookComboBoxModel() {
entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
+ cacheDatas = getDataList();
}
/*
@@ -58,7 +61,7 @@
*/
@Override
public int getSize() {
- return getDataList().size();
+ return cacheDatas.size();
}
/*
@@ -66,7 +69,7 @@
*/
@Override
public Object getElementAt(int index) {
- return getDataList().get(index);
+ return cacheDatas.get(index);
}
/*
@@ -105,7 +108,7 @@
* get the accounts list
*/
public List<EntryBook> getDataList(){
- List<EntryBook> result = new ArrayList<EntryBook>();
+ List<EntryBook> result = null;
try {
result = entryBookService.getAllEntryBooks();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-05-25 13:52:22 UTC (rev 2906)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-05-25 16:24:52 UTC (rev 2907)
@@ -18,16 +18,20 @@
package org.chorem.lima.ui.combobox;
-import java.util.Collection;
+import java.util.List;
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
/**
* Opened financial period combo box model.
@@ -39,19 +43,26 @@
* By : $Author$
*/
public class FinancialPeriodComboBoxModel implements ComboBoxModel {
+
+ private static final Log log =
+ LogFactory.getLog(FinancialPeriodTableModel.class);
protected Object selectedFinancialPeriod;
+ protected List<FinancialPeriod> datasCache;
+
protected FinancialPeriodService financialPeriodService;
protected FiscalPeriod selectedFiscalPeriod;
public FinancialPeriodComboBoxModel() {
financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
+ datasCache=getDataList();
}
public void setFiscalPeriod(FiscalPeriod fiscalPeriod){
selectedFiscalPeriod=fiscalPeriod;
+ datasCache=getDataList();
}
/*
@@ -59,23 +70,7 @@
*/
@Override
public int getSize() {
- int result = 0;
- // TODO add cache
- try {
- if (selectedFiscalPeriod != null){
-
- result = selectedFiscalPeriod.getFinancialPeriod().size();
- }
- else {
- result = financialPeriodService.
- getUnblockedFinancialPeriods().size();
- }
- }
- catch (LimaException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- return result;
+ return datasCache.size();
}
/*
@@ -83,22 +78,7 @@
*/
@Override
public Object getElementAt(int index) {
- Object result = null;
- // TODO add cache
- try {
- if (selectedFiscalPeriod != null){
- result = CollectionUtils.get(selectedFiscalPeriod.getFinancialPeriod(), index);
- }
- else {
- result = financialPeriodService.getUnblockedFinancialPeriods().
- get(index);
- }
- }
- catch (LimaException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- return result;
+ return datasCache.get(index);
}
/*
@@ -132,4 +112,23 @@
public Object getSelectedItem() {
return selectedFinancialPeriod;
}
+
+ public List<FinancialPeriod> getDataList(){
+ List<FinancialPeriod> result = null;
+ try {
+ if (selectedFiscalPeriod != null){
+ result = (List<FinancialPeriod>) selectedFiscalPeriod.getFinancialPeriod();
+ }
+ else {
+ result = financialPeriodService.getUnblockedFinancialPeriods();
+ }
+ }
+ catch (LimaException ex) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't get Financial Period list",ex);
+ }
+ }
+ return result;
+
+ }
}
1
0
r2906 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
by jpepin@users.chorem.org 25 May '10
by jpepin@users.chorem.org 25 May '10
25 May '10
Author: jpepin
Date: 2010-05-25 15:52:22 +0200 (Tue, 25 May 2010)
New Revision: 2906
Url: http://chorem.org/repositories/revision/lima/2906
Log:
Optimisation requ?\195?\170te calcul totaux des comptes
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/ReportServiceImpl.java
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-25 10:07:39 UTC (rev 2905)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-25 13:52:22 UTC (rev 2906)
@@ -297,7 +297,7 @@
@Override
public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException {
- List<ClosedPeriodicEntryBook> result = new ArrayList<ClosedPeriodicEntryBook>();
+ List<ClosedPeriodicEntryBook> result = null;
TopiaContext transaction = null;
try {
@@ -315,9 +315,9 @@
"F."+FiscalPeriod.FINANCIAL_PERIOD)
.add("F."+FiscalPeriod.LOCKED, Boolean.FALSE)
.addOrder(FiscalPeriod.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE);
- result.
- addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
+ result = closedPeriodicEntryBookDAO.findAllByQuery(query);
+
// commit
transaction.commitTransaction();
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-05-25 10:07:39 UTC (rev 2905)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-05-25 13:52:22 UTC (rev 2906)
@@ -94,12 +94,8 @@
try {
EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- TopiaQuery query = entryDAO.createQuery();
+ TopiaQuery query = entryDAO.createQuery("E");
- if (account != null) {
- query
- .add(Entry.ACCOUNT, account);
- }
if (beginDate != null && endDate != null){
String transactionDateProperty =
TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
@@ -108,27 +104,33 @@
.addParam("beginDate", beginDate)
.addParam("endDate", endDate);
}
- reportsDatas.setListEntry(entryDAO.findAllByQuery(query));
-
- for (Entry entry : reportsDatas.getListEntry()) {
+
+ if (account != null) {
+ query
+ .add(Entry.ACCOUNT, account)
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- entry.getEntryBook();
- entry.getFinancialTransaction().getTransactionDate();
- //calulate the amounts
- if (entry.getDebit()) {
- debit += entry.getAmount();
+ .addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION);
+ reportsDatas.setListEntry(entryDAO.findAllByQuery(query));
+
+ query.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
+ query.addGroup("E."+Entry.DEBIT);
+ List<Object[]> results = query.execute();
+ for (Object[] result : results) {
+ if ((Boolean)result[0]){
+ debit += (Double)result[1];
+ }
+ else {
+ credit += (Double)result[1];
+ }
}
- else {
- credit += entry.getAmount();
+ // set the amounts and solde
+ solde = debit - credit;
+ if (solde > 0){
+ reportsDatas.setSoldeDebit(true);
}
+ solde = Math.abs(solde);
}
- // set the amounts and solde
- solde = debit - credit;
- if (solde > 0){
- reportsDatas.setSoldeDebit(true);
- }
- solde = Math.abs(solde);
reportsDatas.setAmountCredit(credit);
reportsDatas.setAmountDebit(debit);
reportsDatas.setAmountSolde(solde);
1
0
r2905 - in trunk/lima-business/src/main/java/org/chorem/lima/business: ejb utils
by jpepin@users.chorem.org 25 May '10
by jpepin@users.chorem.org 25 May '10
25 May '10
Author: jpepin
Date: 2010-05-25 12:07:39 +0200 (Tue, 25 May 2010)
New Revision: 2905
Url: http://chorem.org/repositories/revision/lima/2905
Log:
Requ?\195?\170te affiche journaux/p?\195?\169riodefinanci?\195?\168re des exercices ouvert. Suppression comparateur inutile.
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ClosedPeriodicEntryBookComparator.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
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-21 17:13:09 UTC (rev 2904)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-25 10:07:39 UTC (rev 2905)
@@ -20,19 +20,16 @@
package org.chorem.lima.business.ejb;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
-import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.utils.ClosedPeriodicEntryBookComparator;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
@@ -41,9 +38,7 @@
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialPeriodImpl;
-import org.chorem.lima.entity.FinancialTransaction;
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.TopiaContextFactory;
@@ -313,11 +308,15 @@
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO
= LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
- //TODO Get closed periodicentrybook from unlocked fiscalperiod
- result = closedPeriodicEntryBookDAO.findAll();
- Collections.sort(result, new ClosedPeriodicEntryBookComparator());
-
- //log.debug(transaction.find("select FinancialPeriod"));
+ //Get closedperiodicentrybook from unlocked fiscalperiod
+ TopiaQuery query = closedPeriodicEntryBookDAO.createQuery("E");
+ query.addFrom(FiscalPeriod.class, "F")
+ .addInElements("E." + ClosedPeriodicEntryBook.FINANCIAL_PERIOD,
+ "F."+FiscalPeriod.FINANCIAL_PERIOD)
+ .add("F."+FiscalPeriod.LOCKED, Boolean.FALSE)
+ .addOrder(FiscalPeriod.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE);
+ result.
+ addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
// commit
transaction.commitTransaction();
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ClosedPeriodicEntryBookComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ClosedPeriodicEntryBookComparator.java 2010-05-21 17:13:09 UTC (rev 2904)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ClosedPeriodicEntryBookComparator.java 2010-05-25 10:07:39 UTC (rev 2905)
@@ -1,34 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.business.utils;
-
-import java.util.Comparator;
-
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-
-public class ClosedPeriodicEntryBookComparator implements Comparator<ClosedPeriodicEntryBook>{
-
- @Override
- public int compare(ClosedPeriodicEntryBook o1, ClosedPeriodicEntryBook o2) {
- return o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate());
-
- }
-
-}
1
0
Author: jpepin
Date: 2010-05-21 19:13:09 +0200 (Fri, 21 May 2010)
New Revision: 2904
Url: http://chorem.org/repositories/revision/lima/2904
Log:
Bug sur la classe association : retour ?\195?\160 modification de mod?\195?\168le ant?\195?\169rieur. Fonction liste des sous-comptes. R?\195?\169vision clot?\195?\187re d'une p?\195?\169riode financi?\195?\168re d'un journal.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ClosedPeriodicEntryBookComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java
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/accountingrules/FranceAccountingRules.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/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/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-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -36,6 +36,8 @@
List<Account> getAllAccounts() throws LimaException;
+ List<Account> getAllSubAccounts() throws LimaException;
+
/**
* Create new account. If {@code masterAccount} is not null, {@code account}
* is added in {@code masterAccount}'s subAccounts.
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-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -25,6 +25,7 @@
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
+import org.nuiton.topia.TopiaContext;
/**
* Financial period service.
@@ -43,6 +44,9 @@
void createFinancialPeriod(FinancialPeriod financialPeriod) throws LimaException;
+ void createFinancialPeriodWithTransaction(FinancialPeriod financialPeriod, TopiaContext topiaContext) throws LimaException;
+
+
FinancialPeriod getFinancialPeriodWithDate(Date date) throws LimaException;
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-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -21,6 +21,7 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionDAO;
@@ -133,6 +134,10 @@
Date endDate = fiscalPeriod.getEndDate();
FinancialPeriodService financialPeriodService = (FinancialPeriodService) map.get(FinancialPeriodService.class);
+ if (financialPeriodService == null){
+ financialPeriodService = new FinancialPeriodServiceImpl();
+ }
+
// FinancialPeriod of 1 month are created
Date loopDate = beginDate;
while (loopDate.compareTo(endDate) <= 0) {
@@ -143,7 +148,7 @@
financialPeriod.setEndDate(periodEndDate);
fiscalPeriod.addFinancialPeriod(financialPeriod);
loopDate = loopUpperDate;
- financialPeriodService.createFinancialPeriod(financialPeriod);
+ financialPeriodService.createFinancialPeriodWithTransaction(financialPeriod, transaction);
}
}
catch (TopiaException ex) {
@@ -200,8 +205,11 @@
Date endDate = closedPeriodicEntryBook.
getFinancialPeriod().getBeginDate();
endDate = DateUtils.addMonths(endDate, -1);
- Date beginDate = closedPeriodicEntryBook.
- getFinancialPeriod().getFiscalPeriod().getBeginDate();
+
+ FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaTransaction);
+ FiscalPeriod fiscalPeriod = fiscalPeriodDAO.findContainsFinancialPeriod(closedPeriodicEntryBook.getFinancialPeriod());
+ Date beginDate = fiscalPeriod.getBeginDate();
+
EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
@@ -244,7 +252,6 @@
/**
* 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 {
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-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -75,7 +75,7 @@
log.error("Can't init topia context", ex);
}
}
- accountingRules = config.getAccountingRules();
+ accountingRules = config.getAccountingRules();
}
/**
@@ -210,6 +210,38 @@
return accountsList;
}
+
+ @Override
+ public List<Account> getAllSubAccounts() throws LimaException {
+
+ List<Account> accountsList = new ArrayList<Account>();
+
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
+ List<Account> accounts = accountDAO.findAll();
+ for (Account account : accounts) {
+ //check if parentaccount have no subaccount
+ if (account.getSubAccounts().size() == 0){
+ accountsList.add(account);
+ }
+ }
+ Collections.sort(accountsList, new AccountComparator());
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ return accountsList;
+ }
+
+
/**
* Permet de recuperer la liste des comptes fils d'un compte en particulier.
*
@@ -355,5 +387,4 @@
throw new LimaException("Can't update account", ex);
}
}
-
}
\ No newline at end of file
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-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -20,15 +20,19 @@
package org.chorem.lima.business.ejb;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
+
+import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.ClosedPeriodicEntryBookComparator;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
@@ -39,6 +43,7 @@
import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FinancialTransaction;
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.TopiaContextFactory;
@@ -86,22 +91,40 @@
@Override
public void createFinancialPeriod(FinancialPeriod financialPeriod) throws LimaException {
- TopiaContext transaction = null;
+ TopiaContext topiaTransaction = null;
try {
// basic check done, make check in database
// TODO move it into JTA
- transaction = rootContext.beginTransaction();
+ topiaTransaction = rootContext.beginTransaction();
+ createFinancialPeriodWithTransaction(financialPeriod, topiaTransaction);
+
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ }
+
+
+ /**
+ * 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
+ * @return
+ */
+ @Override
+ public void createFinancialPeriodWithTransaction(FinancialPeriod financialPeriod, TopiaContext topiaContext) throws LimaException {
+
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
- //create financial period
- financialPeriodDAO.create(financialPeriod);
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
//create ClosedPeriodicEntryBook for all entrybook
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
+ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
for (EntryBook entryBook : entryBookDAO.findAll()) {
//new closed periodic entrybook
ClosedPeriodicEntryBook closedPeriodicEntryBook
@@ -113,16 +136,15 @@
// create it
closedPeriodicEntryBookDAO.create(closedPeriodicEntryBook);
}
+ //create financial period
+ financialPeriodDAO.create(financialPeriod);
// commit
- transaction.commitTransaction();
+ topiaContext.commitTransaction();
}
catch (TopiaException ex) {
- doCatch(transaction, ex, log);
+ doCatch(topiaContext, ex, log);
}
- finally {
- doFinally(transaction, log);
- }
}
/**
@@ -291,18 +313,11 @@
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO
= LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
- TopiaQuery query = closedPeriodicEntryBookDAO.createQuery();
- String closedPeriodicEntryBookProperty =
- TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD,
- FinancialPeriod.FISCAL_PERIOD, FiscalPeriod.LOCKED);
- query.add(closedPeriodicEntryBookProperty, Boolean.FALSE);
- query.addOrder(ClosedPeriodicEntryBook.FINANCIAL_PERIOD);
- result = closedPeriodicEntryBookDAO.findAllByQuery(query);
-
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : result) {
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
- closedPeriodicEntryBook.getFinancialPeriod().getFiscalPeriod().getBeginDate();
- }
+ //TODO Get closed periodicentrybook from unlocked fiscalperiod
+ result = closedPeriodicEntryBookDAO.findAll();
+ Collections.sort(result, new ClosedPeriodicEntryBookComparator());
+
+ //log.debug(transaction.find("select FinancialPeriod"));
// commit
transaction.commitTransaction();
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ClosedPeriodicEntryBookComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ClosedPeriodicEntryBookComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ClosedPeriodicEntryBookComparator.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -0,0 +1,34 @@
+/* *##% 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.business.utils;
+
+import java.util.Comparator;
+
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+
+public class ClosedPeriodicEntryBookComparator implements Comparator<ClosedPeriodicEntryBook>{
+
+ @Override
+ public int compare(ClosedPeriodicEntryBook o1, ClosedPeriodicEntryBook o2) {
+ return o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate());
+
+ }
+
+}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2010-05-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -26,7 +26,7 @@
@Override
public int compare(Entry o1, Entry o2) {
- return o1.getTopiaId().compareTo(o2.getTopiaId());
+ return o1.getTopiaCreateDate().compareTo(o2.getTopiaCreateDate());
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2010-05-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -1,5 +1,6 @@
package org.chorem.lima.business;
+import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ejb.EntryBookServiceImpl;
import org.junit.AfterClass;
@@ -18,8 +19,7 @@
public class EntryBookServiceImplTest {
/** log. */
- private static final org.apache.commons.logging.Log log = LogFactory
- .getLog(EntryBookServiceImplTest.class);
+ private static final Log log = LogFactory.getLog(EntryBookServiceImplTest.class);
private static EntryBookServiceImpl instance;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2010-05-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -1,6 +1,7 @@
package org.chorem.lima.business;
+import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
import org.junit.AfterClass;
@@ -23,8 +24,7 @@
public class FinancialPeriodServiceImplTest {
/** log. */
- private static final org.apache.commons.logging.Log log = LogFactory
- .getLog(FinancialPeriodServiceImplTest.class);
+ private static final Log log = LogFactory.getLog(FinancialPeriodServiceImplTest.class);
private static FinancialPeriodServiceImpl instance;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-05-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -17,7 +17,7 @@
public class GeneratorTest {
/** log. */
- private static final org.apache.commons.logging.Log log = LogFactory.getLog(TransactionServiceImplTest.class);
+ private static final org.apache.commons.logging.Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
private static FinancialTransactionServiceImpl instanceTransaction;
private static FiscalPeriodServiceImpl instancePeriod;
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -0,0 +1,100 @@
+/* *##% 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.combobox;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
+
+/**
+ * Account combo box model.
+ */
+
+public class SubAccountComboBoxModel implements ComboBoxModel {
+
+ private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+
+ protected Object selectedAccount;
+
+ protected AccountService accountService;
+
+ public SubAccountComboBoxModel() {
+ accountService = LimaServiceFactory.getInstance().getAccountService();
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ return selectedAccount;
+ }
+
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedAccount = anItem;
+ }
+
+ @Override
+ public void addListDataListener(ListDataListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object getElementAt(int index) {
+ return getDataList().get(index);
+ }
+
+ @Override
+ public int getSize() {
+ return getDataList().size();
+ }
+
+ @Override
+ public void removeListDataListener(ListDataListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List<Account> getDataList(){
+ List<Account> result = new ArrayList<Account>();
+ try {
+ result = accountService.getAllSubAccounts();
+ }
+ catch (LimaException eee) {
+ // TODO Auto-generated catch block
+ if (log.isDebugEnabled()){
+ log.debug("Can't get list subaccounts", eee);
+ }
+ }
+ return result;
+
+ }
+
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java 2010-05-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -30,8 +30,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
-import org.chorem.lima.ui.combobox.AccountComboBoxModel;
import org.chorem.lima.ui.combobox.AccountRenderer;
+import org.chorem.lima.ui.combobox.SubAccountComboBoxModel;
import org.chorem.lima.widgets.JWideComboBox;
public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor {
@@ -46,7 +46,7 @@
*/
public AccountTableCellEditor() {
comboBox = new JWideComboBox();
- AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel();
+ SubAccountComboBoxModel accountComboBoxModel = new SubAccountComboBoxModel();
comboBox.setModel(accountComboBoxModel);
AccountRenderer accountRenderer = new AccountRenderer();
comboBox.setRenderer(accountRenderer);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-05-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -139,6 +139,8 @@
@Override
public void keyPressed(KeyEvent e) {
+ //TODO combinaison de touches dans la config
+
// delete selected row with the key : delete or ctrl clear
// ou de l'entree
if ((e.getKeyCode() == KeyEvent.VK_DELETE )
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-05-20 15:12:37 UTC (rev 2903)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-05-21 17:13:09 UTC (rev 2904)
@@ -417,7 +417,7 @@
*/
@Override
public void setValueAt(Object value, int row, int column) {
-
+ int financialTransactionRow=0;
// just prevent too much result
if (selectedFinancialPeriod != null) {
Object currentRow = cacheDataList.get(row);
@@ -478,6 +478,9 @@
log.debug("Can't update financial transaction", e);
}
}
+ //update the financial transaction in entire
+ financialTransactionRow =
+ getDataList().indexOf(((FinancialTransaction) currentRow));
}
else if (currentRow instanceof Entry) {
Entry currentEntry = (Entry)currentRow;
@@ -513,11 +516,11 @@
log.debug("Can't update entry", e);
}
}
+ //update the financial transaction in entire
+ financialTransactionRow =
+ getDataList().indexOf(((Entry) currentRow).
+ getFinancialTransaction());
}
- //update the financial transaction in entire
- int financialTransactionRow =
- getDataList().indexOf(((Entry) currentRow).
- getFinancialTransaction());
//on recharge la liste
cacheDataList = getDataList();
fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
1
0
Author: jpepin
Date: 2010-05-20 17:12:37 +0200 (Thu, 20 May 2010)
New Revision: 2903
Url: http://chorem.org/repositories/revision/lima/2903
Log:
Tri des donn?\195?\169es plan des comptes en ordre lexicographique, tri des donn?\195?\169es sur tableau des entr?\195?\169es. Ajout r?\195?\168gle sur modification des entr?\195?\169es.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.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/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/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/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -68,7 +68,7 @@
* @param topiaTransaction
* @throws LimaException
*/
- public void updateEntryRules(Entry entry, TopiaContext topiaTransaction) throws LimaException;
+ public void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException;
/**
* Financialperiod/entrybook rules
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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -32,6 +32,7 @@
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ejb.AccountServiceImpl;
+import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
@@ -40,6 +41,7 @@
import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
@@ -107,26 +109,47 @@
}
}
+ /**
+ * Rules on update entry :
+ *
+ * Two case :
+ * - first, the entry belong to a blocked financialperiod
+ * - second, the actual entry belong to a blocked closedPeriodicEntryBook
+ * - third, the new choice entrybook belong to a blocked closedPeriodicEntryBook
+ */
@Override
- public void updateEntryRules(Entry entry, TopiaContext topiaTransaction) throws LimaException {
+ public void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException {
+ //first case
if (entry.getFinancialTransaction().getFinancialPeriod().getLocked()){
- throw new LimaBusinessException("The financial period is blocked");
+ throw new LimaBusinessException("1 - Can't update entry : The financial period is blocked");
}
- ClosedPeriodicEntryBook closedPeriodicEntryBook = null;
try {
- EntryBook entryBook = entry.getEntryBook();
+ //Get finacialperiodservice
+ FinancialPeriodService financialPeriodService =
+ (FinancialPeriodService) map.get(FinancialPeriodService.class);
+ if (financialPeriodService == null){
+ financialPeriodService = new FinancialPeriodServiceImpl();
+ }
+
FinancialPeriod financialPeriod =
entry.getFinancialTransaction().getFinancialPeriod();
- FinancialPeriodService financialPeriodService = (FinancialPeriodService) map.get(FinancialPeriodService.class);
+ //second case
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
+ financialPeriodService.getClosedPeriodicEntryBook(entryOld.getEntryBook(), financialPeriod);
+ if (closedPeriodicEntryBook.getLocked()){
+ throw new LimaBusinessException("2 - Can't update entry : financialperiod of this entrybook is closed");
+ }
- closedPeriodicEntryBook =
- financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod);
+ //third case
+ ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
+ financialPeriodService.getClosedPeriodicEntryBook(entry.getEntryBook(), financialPeriod);
- // Check if closedperiodicentrybook is locked
- if (closedPeriodicEntryBook.getLocked()){
- throw new LimaBusinessException("Can't update entry : financialperiod of this entrybook is closed");
+ // Check 2 & 3 cases
+ if (closedPeriodicEntryBook2.getLocked()){
+ throw new LimaBusinessException("3 - Can't update entry : financialperiod of this entrybook is closed");
}
+
}
catch (LimaException eee) {
doCatch(topiaTransaction, eee, log);
@@ -201,6 +224,9 @@
for (EntryBook entryBook : entryBooks) {
FinancialPeriodService financialPeriodService =
(FinancialPeriodService) map.get(FinancialPeriodService.class);
+ if (financialPeriodService == null){
+ financialPeriodService = new FinancialPeriodServiceImpl();
+ }
if(financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod).getLocked()){
closedEntryBooks.add(entryBook);
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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -197,9 +197,11 @@
try {
// Get all closedperiod between for the period and entrybook
- Date endDate = closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
+ Date endDate = closedPeriodicEntryBook.
+ getFinancialPeriod().getBeginDate();
endDate = DateUtils.addMonths(endDate, -1);
- Date beginDate = closedPeriodicEntryBook.getFinancialPeriod().getFiscalPeriod().getBeginDate();
+ Date beginDate = closedPeriodicEntryBook.
+ getFinancialPeriod().getFiscalPeriod().getBeginDate();
EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
@@ -208,33 +210,29 @@
String closedPeriodicEntryBookDateProperty =
TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD,
FinancialPeriod.BEGIN_DATE);
- query.add(closedPeriodicEntryBookDateProperty+" BETWEEN :beginDate AND :endDate")
+ query.add(closedPeriodicEntryBookDateProperty
+ +" BETWEEN :beginDate AND :endDate")
.add(ClosedPeriodicEntryBook.ENTRY_BOOK, entryBook)
.addParam("beginDate", beginDate)
.addParam("endDate", endDate);
- closedPeriodicEntryBooks.addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook2 : closedPeriodicEntryBooks) {
- log.debug(closedPeriodicEntryBook2.getEntryBook()+" "+closedPeriodicEntryBook2.getFinancialPeriod());
- }
+ closedPeriodicEntryBooks.
+ addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
int nbClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
- log.debug("nbBlockedClosedPeriodicEntryBooks "+nbClosedPeriodicEntryBooks);
// Get all closed between for the period, entrybook and are blocked
query.add(ClosedPeriodicEntryBook.LOCKED, true);
closedPeriodicEntryBooks.clear();
- closedPeriodicEntryBooks.addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook2 : closedPeriodicEntryBooks) {
- log.debug(closedPeriodicEntryBook2.getEntryBook()+" "+closedPeriodicEntryBook2.getFinancialPeriod());
- }
- int nbBlockedClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
- log.debug("nbBlockedClosedPeriodicEntryBooks "+nbBlockedClosedPeriodicEntryBooks);
+ closedPeriodicEntryBooks.
+ addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
+ int nbBlockedClosedPeriodicEntryBooks =
+ closedPeriodicEntryBooks.size();
//Check if the fiscal period to block is the oldest
if (nbClosedPeriodicEntryBooks != nbBlockedClosedPeriodicEntryBooks){
throw new LimaBusinessException(
- "The previous financial periods for this entrybook must be blocked before this.");
+ "The previous financial periods for this entrybook must be blocked before this.");
}
}
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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -22,6 +22,7 @@
import static org.nuiton.i18n.I18n._;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
@@ -34,6 +35,7 @@
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -195,6 +197,8 @@
LimaCallaoDAOHelper.getAccountDAO(transaction);
List<Account> accounts = accountDAO.findAll();
accountsList.addAll(accounts);
+ Collections.sort(accountsList, new AccountComparator());
+
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -234,8 +238,9 @@
query.add("masterAccount = :value or generalLedger = :value")
.addParam("value", masterAccount);
}
+ accountsList.addAll(accountDAO.findAllByQuery(query));
+ Collections.sort(accountsList, new AccountComparator());
- accountsList.addAll(accountDAO.findAllByQuery(query));
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -58,9 +58,11 @@
private TopiaContext rootContext;
- protected FinancialTransactionServiceImpl financialTransactionService = new FinancialTransactionServiceImpl();
+ protected FinancialTransactionServiceImpl financialTransactionService =
+ new FinancialTransactionServiceImpl();
- protected FinancialPeriodServiceImpl financialPeriodService = new FinancialPeriodServiceImpl();
+ protected FinancialPeriodServiceImpl financialPeriodService =
+ new FinancialPeriodServiceImpl();
protected AccountingRules accountingRules;
@@ -111,7 +113,8 @@
for (FinancialPeriod financialPeriod : financialPeriodService.getUnblockedFinancialPeriods()) {
//new closed periodic entrybook
- ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
+ new ClosedPeriodicEntryBookImpl();
// set entrybook
closedPeriodicEntryBook.setEntryBook(entryBook);
// set financial period
@@ -144,7 +147,8 @@
transaction = rootContext.beginTransaction();
// check if entrybook with is name already exist
- EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ EntryBookDAO EntryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(transaction);
List<EntryBook> EntryBooks = EntryBookDAO.findAll();
EntryBooksList.addAll(EntryBooks);
@@ -174,7 +178,8 @@
// TODO move it into JTA
transaction = rootContext.beginTransaction();
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(transaction);
// creation du EntryBook
entryBookDAO.update(entryBook);
@@ -211,7 +216,8 @@
accountingRules.removeEntryBookRules(entryBook, topiaTransaction);
//delete
- EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction);
+ EntryBookDAO EntryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction);
EntryBookDAO.delete(entryBook);
// commit
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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -21,7 +21,7 @@
import static org.nuiton.i18n.I18n._;
-import java.util.Date;
+import java.util.Collections;
import java.util.List;
import javax.ejb.Stateless;
@@ -29,10 +29,13 @@
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.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.FinancialTransactionService;
+import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
@@ -40,6 +43,7 @@
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionDAO;
+import org.hsqldb.lib.Sort;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -196,7 +200,7 @@
@Override
public List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException {
- List<FinancialTransaction> transactions = null;
+ List<FinancialTransaction> financialTransactions = null;
TopiaContext topiaTransaction = null;
try {
topiaTransaction = rootContext.beginTransaction();
@@ -213,10 +217,10 @@
if (financialPeriod != null) {
query.add("financialPeriod", financialPeriod);
}
- transactions = transactionDAO.findAllByQuery(query);
+ financialTransactions = transactionDAO.findAllByQuery(query);
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- for (FinancialTransaction financialTransaction : transactions) {
+ for (FinancialTransaction financialTransaction : financialTransactions) {
for (Entry entry : financialTransaction.getEntry()) {
entry.getEntryBook();
@@ -233,7 +237,7 @@
doFinally(topiaTransaction, log);
}
- return transactions;
+ return financialTransactions;
}
@@ -326,11 +330,25 @@
// TODO move it into JTA
topiaContext = rootContext.beginTransaction();
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+
+ Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId());
+
//check rules
- accountingRules.updateEntryRules(entry, topiaContext);
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- //delete
- entryDAO.update(entry);
+ accountingRules.updateEntryRules(entry, entryOld, topiaContext);
+
+ //TODO PEPIN 20100520 conflict object already instanciate
+ entryOld.setAccount(entry.getAccount());
+ entryOld.setAmount(entry.getAmount());
+ entryOld.setDebit(entry.getDebit());
+ entryOld.setDescription(entry.getDescription());
+ entryOld.setEntryBook(entry.getEntryBook());
+ entryOld.setFinancialTransaction(entry.getFinancialTransaction());
+ entryOld.setVoucher(entry.getVoucher());
+ entryOld.setPosition(entry.getPosition());
+ entryOld.setLettering(entry.getLettering());
+ //update
+ entryDAO.update(entryOld);
// commit
topiaContext.commitTransaction();
}
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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -21,7 +21,6 @@
import static org.nuiton.i18n.I18n._;
-import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless;
@@ -33,8 +32,6 @@
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-
-import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FiscalPeriod;
@@ -44,9 +41,8 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
+
/**
* Gestion des exercices.
* Un exercice ne peut être supprimée et débloquée après cloture.
@@ -59,9 +55,6 @@
private static final Log log = LogFactory.getLog(FiscalPeriodServiceImpl.class);
private static TopiaContext rootContext;
-
- private FinancialPeriodServiceImpl financialPeriodService =
- new FinancialPeriodServiceImpl();
protected AccountingRules accountingRules;
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -0,0 +1,32 @@
+/* *##% 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.business.utils;
+
+import java.util.Comparator;
+
+import org.chorem.lima.entity.Account;
+
+public class AccountComparator implements Comparator<Account>{
+
+ @Override
+ public int compare(Account o1, Account o2) {
+ return o1.getAccountNumber().compareTo(o2.getAccountNumber());
+ }
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -0,0 +1,32 @@
+/* *##% 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.business.utils;
+
+import java.util.Comparator;
+
+import org.chorem.lima.entity.Entry;
+
+public class EntryComparator implements Comparator<Entry>{
+
+ @Override
+ public int compare(Entry o1, Entry o2) {
+ return o1.getTopiaId().compareTo(o2.getTopiaId());
+ }
+
+}
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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -313,7 +313,7 @@
public void showFinancialPeriodView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
FinancialPeriodView financialPeriodView = new FinancialPeriodView(mainView);
- mainView.showTab(_("lima.financialperiod.management"), financialPeriodView);
+ mainView.showTab(_("lima.charts.financialperiod"), financialPeriodView);
}
/**
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-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -118,7 +118,6 @@
@Override
public Object getChild(Object parent, int index) {
- log.debug("GETCHILD_BEGIN");
Object result = null;
if (parent == getRoot()) {
try {
@@ -143,7 +142,6 @@
e.printStackTrace();
}
}
- log.debug("GETCHILD_END");
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -85,7 +85,6 @@
List<Account> result = new ArrayList<Account>();
try {
result = accountService.getAllAccounts();
- Collections.sort(result, new AccountComparator());
}
catch (LimaException eee) {
// TODO Auto-generated catch block
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java 2010-05-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -1,32 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.combobox;
-
-import java.util.Comparator;
-
-import org.chorem.lima.entity.Account;
-
-public class AccountComparator implements Comparator<Account>{
-
- @Override
- public int compare(Account o1, Account o2) {
- return o1.getAccountNumber().compareTo(o2.getAccountNumber());
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java 2010-05-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -1,40 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.financialperiod;
-
-import java.util.Comparator;
-
-import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-
-public class ClosedPeriodicEntryBookComparator implements Comparator<ClosedPeriodicEntryBook>{
-
- @Override
- public int compare(ClosedPeriodicEntryBook o1, ClosedPeriodicEntryBook o2) {
-
- if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == -1) {
- return -1;
- } else if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == 1) {
- return 1;
- } else {
- return 0;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -22,7 +22,6 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import javax.swing.table.AbstractTableModel;
@@ -53,7 +52,8 @@
/** serialVersionUID. */
private static final long serialVersionUID = 77027335135838258L;
- private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+ private static final Log log =
+ LogFactory.getLog(FinancialPeriodTableModel.class);
/** services */
protected FiscalPeriodService fiscalPeriodService;
@@ -64,9 +64,12 @@
protected List<ClosedPeriodicEntryBook> cacheDataList;
public FinancialPeriodTableModel() {
- fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
- entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
- financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
+ fiscalPeriodService =
+ LimaServiceFactory.getInstance().getFiscalPeriodService();
+ entryBookService =
+ LimaServiceFactory.getInstance().getEntryBookService();
+ financialPeriodService =
+ LimaServiceFactory.getInstance().getFinancialPeriodService();
}
@@ -137,7 +140,8 @@
if (closedPeriodicEntryBook != null){
EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
- FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod();
+ FinancialPeriod financialPeriod =
+ closedPeriodicEntryBook.getFinancialPeriod();
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat("MMMMM yyyy");
@@ -164,20 +168,22 @@
}
public void getDataList(){
- List<ClosedPeriodicEntryBook> results = new ArrayList<ClosedPeriodicEntryBook>();
+ List<ClosedPeriodicEntryBook> results =
+ new ArrayList<ClosedPeriodicEntryBook>();
try {
- results = financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
+ results = financialPeriodService.
+ getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
} catch (LimaException eee){
if (log.isDebugEnabled()){
log.debug("Can't get closedperiodicentrybook list", eee );
}
}
- //Collections.sort(results, new ClosedPeriodicEntryBookComparator());
cacheDataList=results;
}
public void blockFinancialPeriod(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
- financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ financialPeriodService.
+ blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
fireTableDataChanged();
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-05-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-05-20 15:12:37 UTC (rev 2903)
@@ -39,7 +39,7 @@
<row fill="horizontal" weightx="1" weighty="0" anchor="center">
<cell>
- <JLabel id="fiscalPeriodLabel" text="lima.fiscalyear.management"/>
+ <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/>
</cell>
<cell>
<JComboBox id="fiscalPeriodComboBox"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-05-19 16:38:02 UTC (rev 2902)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-05-20 15:12:37 UTC (rev 2903)
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -35,6 +36,7 @@
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.FinancialTransactionService;
+import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
@@ -70,7 +72,7 @@
.getLog(FinancialTransactionTableModel.class);
/** Transaction service. */
- protected final FinancialTransactionService transactionService;
+ protected final FinancialTransactionService financialTransactionService;
/** EntryBook service. */
protected final EntryBookService entryBookService;
@@ -94,8 +96,7 @@
*/
public FinancialTransactionTableModel() {
/* Services */
- // recordService = LimaServiceFactory.getInstance().getRecordService();
- transactionService = LimaServiceFactory.getInstance()
+ financialTransactionService = LimaServiceFactory.getInstance()
.getTransactionService();
entryBookService = LimaServiceFactory.getInstance().
getEntryBookService();
@@ -114,11 +115,13 @@
List<Object> results = new ArrayList<Object>();
try {
List<FinancialTransaction> financialtransactions =
- transactionService.getAllFinancialTransactionsForFinancialPeriod(
+ financialTransactionService.getAllFinancialTransactionsForFinancialPeriod(
selectedFinancialPeriod);
for (FinancialTransaction financialtransaction : financialtransactions) {
results.add(financialtransaction);
- results.addAll(financialtransaction.getEntry());
+ List<Entry> entries = (List<Entry>) financialtransaction.getEntry();
+ Collections.sort(entries, new EntryComparator());
+ results.addAll(entries);
}
}
catch (LimaException eee) {
@@ -371,7 +374,7 @@
// set date to the financial transaction
financialTransaction.setTransactionDate(transactionDate);
// create it
- transactionService.createFinancialTransaction(financialTransaction);
+ financialTransactionService.createFinancialTransaction(financialTransaction);
//on recharge la liste
cacheDataList = getDataList();
int row = getDataList().indexOf(financialTransaction);
@@ -403,7 +406,7 @@
}
//create it
entry.setFinancialTransaction(currentTransaction);
- transactionService.createEntry(entry);
+ financialTransactionService.createEntry(entry);
//on recharge la liste
cacheDataList = getDataList();
fireTableDataChanged();
@@ -468,7 +471,7 @@
}
// notify service for modification
try {
- transactionService.
+ financialTransactionService.
updateFinancialTransaction(currentFinancialTransaction);
} catch (LimaException e) {
if (log.isDebugEnabled()){
@@ -504,7 +507,7 @@
break;
}
try {
- transactionService.updateEntry(currentEntry);
+ financialTransactionService.updateEntry(currentEntry);
} catch (LimaException e) {
if (log.isDebugEnabled()){
log.debug("Can't update entry", e);
@@ -545,11 +548,11 @@
if (currentRow instanceof FinancialTransaction) {
FinancialTransaction currentTransaction =
(FinancialTransaction)currentRow;
- transactionService.removeFinancialTransaction(currentTransaction);
+ financialTransactionService.removeFinancialTransaction(currentTransaction);
}
else if (currentRow instanceof Entry) {
Entry currentEntry = (Entry)currentRow;
- transactionService.removeEntry(currentEntry);
+ financialTransactionService.removeEntry(currentEntry);
}
//on recharge la liste
cacheDataList = getDataList();
1
0
19 May '10
Author: jpepin
Date: 2010-05-19 18:38:02 +0200 (Wed, 19 May 2010)
New Revision: 2902
Url: http://chorem.org/repositories/revision/lima/2902
Log:
Ajout r?\195?\168gle de v?\195?\169rification cloture journal d'une p?\195?\169riode financi?\195?\168re
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.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/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-swing/src/main/java/org/chorem/lima/LimaMain.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/accountsreports/AccountsReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-05-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -19,10 +19,8 @@
package org.chorem.lima.business;
-import java.util.Date;
import java.util.List;
-import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.entity.Account;
/**
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -19,6 +19,7 @@
package org.chorem.lima.business;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialTransaction;
@@ -32,12 +33,49 @@
*/
public interface AccountingRules {
+ public void register(Class clazz, Object object);
+
+ /**
+ * Accounts rules
+ * @param masterAccount
+ * @param account
+ * @throws LimaException
+ */
public void createAccountRules(Account masterAccount, Account account) throws LimaException;
public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException;
+ public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException;
+
+ /**
+ * Entrybook rules
+ * @param entryBook
+ * @param topiaTransaction
+ * @throws LimaException
+ */
+ public void removeEntryBookRules(EntryBook entryBook, TopiaContext topiaTransaction) throws LimaException;
+
+ /**
+ * Fiscal Period rules
+ * @param fiscalPeriod
+ * @param transaction
+ * @throws LimaException
+ */
public void createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException;
+ public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException;
+
+ /**
+ * Entry rules
+ * @param entry
+ * @param topiaTransaction
+ * @throws LimaException
+ */
public void updateEntryRules(Entry entry, TopiaContext topiaTransaction) 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;
+
+ /**
+ * Financialperiod/entrybook rules
+ * @param financialTransaction
+ * @param topiaContext
+ * @throws LimaException
+ */
public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction, TopiaContext topiaContext) throws LimaException;
+ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaContext) throws LimaException;
}
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -19,11 +19,8 @@
package org.chorem.lima.business;
-import java.util.Date;
import java.util.List;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -54,14 +54,6 @@
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);
- }
- }*/
-
}
public static LimaConfig getInstance() {
@@ -73,11 +65,11 @@
}
/**
+ * instancie la bonne classe de nationalite en fonction du fichier de configuration
*
* @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);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java 2010-05-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -19,8 +19,6 @@
package org.chorem.lima.business;
-import java.util.List;
-
/**
* Fiscal period service.
*
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-05-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -25,8 +25,6 @@
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
/**
* Service de generation des rapports.
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -20,19 +20,20 @@
package org.chorem.lima.business.accountingrules;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
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.FinancialPeriodService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ejb.AccountServiceImpl;
-import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookDAO;
@@ -51,12 +52,19 @@
*/
public class DefaultAccountingRules implements AccountingRules {
+ private Map<Class, Object> map;
+
protected static final Log log =
LogFactory.getLog(DefaultAccountingRules.class);
-
- private FinancialPeriodServiceImpl financialPeriodService =
- new FinancialPeriodServiceImpl();
+ public DefaultAccountingRules() {
+ map = new HashMap<Class, Object>();
+ }
+
+ public void register(Class clazz, Object object){
+ map.put(clazz, object);
+ }
+
/**
* Rules to check before create accounts
*/
@@ -104,22 +112,25 @@
if (entry.getFinancialTransaction().getFinancialPeriod().getLocked()){
throw new LimaBusinessException("The financial period is blocked");
}
- ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = null;
try {
EntryBook entryBook = entry.getEntryBook();
FinancialPeriod financialPeriod =
entry.getFinancialTransaction().getFinancialPeriod();
+ FinancialPeriodService financialPeriodService = (FinancialPeriodService) map.get(FinancialPeriodService.class);
+
closedPeriodicEntryBook =
financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod);
+
+ // Check if closedperiodicentrybook is locked
+ if (closedPeriodicEntryBook.getLocked()){
+ throw new LimaBusinessException("Can't update entry : financialperiod of this entrybook is closed");
+ }
}
catch (LimaException eee) {
doCatch(topiaTransaction, eee, log);
}
- // Check if closedperiodicentrybook is locked
- if (closedPeriodicEntryBook.getLocked()){
- throw new LimaBusinessException("Can't update entry : financialperiod of this entrybook is closed");
- }
}
/**
@@ -188,17 +199,20 @@
FinancialPeriod financialPeriod = financialTransaction.getFinancialPeriod();
entryBooks = entryBookDAO.findAll();
for (EntryBook entryBook : entryBooks) {
+ FinancialPeriodService financialPeriodService =
+ (FinancialPeriodService) map.get(FinancialPeriodService.class);
+
if(financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod).getLocked()){
closedEntryBooks.add(entryBook);
}
}
+ if (entryBooks.size() == closedEntryBooks.size()){
+ throw new LimaBusinessException("All EntryBook of this financialperiod are closed");
+ }
}
catch (TopiaException eee) {
doCatch(topiaContext, eee, log);
}
- if (entryBooks.size() == closedEntryBooks.size()){
- throw new LimaBusinessException("All EntryBook of this financialperiod are closed");
- }
}
/**
@@ -222,5 +236,12 @@
}
throw new LimaException("Exception during query", cause);
}
+
+ @Override
+ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaContext)
+ throws LimaException {
+ // TODO Auto-generated method stub
+
+ }
}
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -1,17 +1,29 @@
package org.chorem.lima.business.accountingrules;
+import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
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.FinancialPeriodService;
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.ClosedPeriodicEntryBook;
+import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -21,11 +33,21 @@
import org.nuiton.topia.framework.TopiaQuery.Op;
public class FranceAccountingRules extends DefaultAccountingRules {
- protected static final Log log = LogFactory.getLog(DefaultAccountingRules.class);
+ protected static final Log log =
+ LogFactory.getLog(DefaultAccountingRules.class);
- private FinancialPeriodServiceImpl financialPeriodService =
- new FinancialPeriodServiceImpl();
+ private TopiaContext rootContext;
+
+ private Map<Class, Object> map;
+ public FranceAccountingRules() {
+ map = new HashMap<Class, Object>();
+ }
+
+ public void register(Class clazz, Object object){
+ map.put(clazz, object);
+ }
+
/**
* Règles de vérification de la création du PCG, appliquées à la comptabilité française
*
@@ -110,6 +132,7 @@
Date beginDate = fiscalPeriod.getBeginDate();
Date endDate = fiscalPeriod.getEndDate();
+ FinancialPeriodService financialPeriodService = (FinancialPeriodService) map.get(FinancialPeriodService.class);
// FinancialPeriod of 1 month are created
Date loopDate = beginDate;
while (loopDate.compareTo(endDate) <= 0) {
@@ -156,6 +179,71 @@
/**
+ * Check if old financialperiod for a an entrybook are closed before bock the asked closedperiodicentrybook
+ *
+ * get all closedperiodicentrybook between the first financial period of fiscalperiod
+ * and the last financial period of the closedperiodicentrybook in param
+ * return the number
+ *
+ * get all blocked closedperiodicentrybook while his same period, return the number
+ *
+ * compare there
+ */
+ public void blockClosedPeriodicEntryBookRules(ClosedPeriodicEntryBook closedPeriodicEntryBook, TopiaContext topiaTransaction)
+ throws LimaException {
+ closedPeriodicEntryBook.getFinancialPeriod();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = new ArrayList<ClosedPeriodicEntryBook>();
+
+ try {
+
+ // Get all closedperiod between for the period and entrybook
+ Date endDate = closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
+ endDate = DateUtils.addMonths(endDate, -1);
+ Date beginDate = closedPeriodicEntryBook.getFinancialPeriod().getFiscalPeriod().getBeginDate();
+ EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
+
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaTransaction);
+ TopiaQuery query = closedPeriodicEntryBookDAO.createQuery();
+ String closedPeriodicEntryBookDateProperty =
+ TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD,
+ FinancialPeriod.BEGIN_DATE);
+ query.add(closedPeriodicEntryBookDateProperty+" BETWEEN :beginDate AND :endDate")
+ .add(ClosedPeriodicEntryBook.ENTRY_BOOK, entryBook)
+ .addParam("beginDate", beginDate)
+ .addParam("endDate", endDate);
+
+ closedPeriodicEntryBooks.addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook2 : closedPeriodicEntryBooks) {
+ log.debug(closedPeriodicEntryBook2.getEntryBook()+" "+closedPeriodicEntryBook2.getFinancialPeriod());
+ }
+
+ int nbClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
+ log.debug("nbBlockedClosedPeriodicEntryBooks "+nbClosedPeriodicEntryBooks);
+
+ // Get all closed between for the period, entrybook and are blocked
+ query.add(ClosedPeriodicEntryBook.LOCKED, true);
+ closedPeriodicEntryBooks.clear();
+ closedPeriodicEntryBooks.addAll(closedPeriodicEntryBookDAO.findAllByQuery(query));
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook2 : closedPeriodicEntryBooks) {
+ log.debug(closedPeriodicEntryBook2.getEntryBook()+" "+closedPeriodicEntryBook2.getFinancialPeriod());
+ }
+ int nbBlockedClosedPeriodicEntryBooks = closedPeriodicEntryBooks.size();
+ log.debug("nbBlockedClosedPeriodicEntryBooks "+nbBlockedClosedPeriodicEntryBooks);
+
+ //Check if the fiscal period to block is the oldest
+ if (nbClosedPeriodicEntryBooks != nbBlockedClosedPeriodicEntryBooks){
+ throw new LimaBusinessException(
+ "The previous financial periods for this entrybook must be blocked before this.");
+ }
+
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ }
+
+ /**
* Generic code used to rollback a transaction.
*
* TODO : replace this by JTA
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -54,7 +54,8 @@
@Stateless
public class AccountServiceImpl extends AbstractLimaService implements AccountService {
- private static final Log log = LogFactory.getLog(AccountServiceImpl.class);
+ private static final Log log =
+ LogFactory.getLog(AccountServiceImpl.class);
private TopiaContext rootContext;
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -36,18 +36,14 @@
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
-import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.FinancialTransaction;
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;
/**
* Implémente la fonction multi-EntryBook. Il est possible de créer ici le
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -25,6 +25,7 @@
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.FinancialPeriodService;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
@@ -36,6 +37,7 @@
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
@@ -59,6 +61,8 @@
LogFactory.getLog(FinancialPeriodServiceImpl.class);
private TopiaContext rootContext;
+
+ protected AccountingRules accountingRules;
public FinancialPeriodServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -69,6 +73,9 @@
log.error("Can't init topia context", ex);
}
}
+
+ accountingRules = config.getAccountingRules();
+ accountingRules.register(FinancialPeriodService.class, this);
}
/**
@@ -246,12 +253,18 @@
try {
topiaContext = rootContext.beginTransaction();
+ //check rules before create the account
+ accountingRules.blockClosedPeriodicEntryBookRules(closedPeriodicEntryBook, topiaContext);
+
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
- closedPeriodicEntryBook.setLocked(true);
- closedPeriodicEntryBookDAO.update(closedPeriodicEntryBook);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
+ closedPeriodicEntryBookDAO.findByTopiaId(closedPeriodicEntryBook.getTopiaId());
+ closedPeriodicEntryBook2.setLocked(true);
+ closedPeriodicEntryBookDAO.update(closedPeriodicEntryBook2);
+
//commit
topiaContext.commitTransaction();
}
@@ -268,7 +281,7 @@
public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException {
List<ClosedPeriodicEntryBook> result = new ArrayList<ClosedPeriodicEntryBook>();
-
+
TopiaContext transaction = null;
try {
// basic check done, make check in database
@@ -286,6 +299,11 @@
query.addOrder(ClosedPeriodicEntryBook.FINANCIAL_PERIOD);
result = closedPeriodicEntryBookDAO.findAllByQuery(query);
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : result) {
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
+ closedPeriodicEntryBook.getFinancialPeriod().getFiscalPeriod().getBeginDate();
+ }
+
// commit
transaction.commitTransaction();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-05-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -176,6 +176,7 @@
// TODO EC-20100409 load accounts and test if there is an account plan defined
// if not, call #loadDefaultAccount()
splash.updateProgression(0.5, _("Loading accounting..."));
+
AccountService accountService = LimaServiceFactory.getInstance().getAccountService();
List<Account> account = accountService.getChildrenAccounts(null);
if (CollectionUtils.isEmpty(account)) {
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-05-19 16:38:02 UTC (rev 2902)
@@ -116,12 +116,12 @@
</JMenu>
<JMenu text="lima.structure">
- <JMenuItem text="lima.chartofaccounts.management" onActionPerformed='getHandler().showAccountView(this)'
+ <JMenuItem text="lima.charts.account" onActionPerformed='getHandler().showAccountView(this)'
actionIcon='account'/>
- <JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='getHandler().showEntryBookView(this)'
+ <JMenuItem text="lima.charts.entrybook" onActionPerformed='getHandler().showEntryBookView(this)'
actionIcon='journal'/>
- <JMenuItem text="lima.fiscalyear.management" onActionPerformed='getHandler().showFiscalPeriodView(this)'/>
- <JMenuItem text="lima.financialperiod.management" onActionPerformed='getHandler().showFinancialPeriodView(this)'/>
+ <JMenuItem text="lima.charts.fiscalyear" onActionPerformed='getHandler().showFiscalPeriodView(this)'/>
+ <JMenuItem text="lima.charts.financialperiod" onActionPerformed='getHandler().showFinancialPeriodView(this)'/>
</JMenu>
<JMenu text="lima.entries">
@@ -140,8 +140,8 @@
</JMenu>
-->
<JMenu text="lima.reports">
- <JMenuItem text="lima.accounts" onActionPerformed='getHandler().showAccountReports(this)'/>
- <JMenuItem text="lima.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)'/>
+ <JMenuItem text="lima.reports.accounts" onActionPerformed='getHandler().showAccountReports(this)'/>
+ <JMenuItem text="lima.reports.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)'/>
<JMenuItem text="lima.balance" onActionPerformed='getHandler().showBalanceView(this)'/>
<JMenuItem text="lima.reports" onActionPerformed='getHandler().showReportsView(this)' actionIcon='rapport'/>
<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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -323,7 +323,7 @@
public void showAccountReports(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
AccountsReportsView accountsReportsView = new AccountsReportsView(mainView);
- mainView.showTab(_("lima.accounts"), accountsReportsView);
+ mainView.showTab(_("lima.reports.accounts"), accountsReportsView);
}
/**
@@ -333,7 +333,7 @@
public void showEntryBookReports(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
EntryBooksReportsView entryBooksReportsView= new EntryBooksReportsView(mainView);
- mainView.showTab(_("lima.entrybooks"), entryBooksReportsView);
+ mainView.showTab(_("lima.reports.entrybooks"), entryBooksReportsView);
}
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -132,7 +132,7 @@
if(selectedAccount != null) {
Entry currentRow = cacheDataList.getListEntry().get(row);
SimpleDateFormat simpleDateFormat
- = new SimpleDateFormat("dd MMM yyyy");
+ = new SimpleDateFormat("dd MMMMM yyyy");
switch (column) {
case 0:
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-19 16:38:02 UTC (rev 2902)
@@ -66,7 +66,8 @@
if (log.isErrorEnabled()) {
log.error("Can't block financialperiod", ex);
}
- ErrorHelper.showErrorDialog("Can't block financialperiod", ex);
+ JOptionPane.showMessageDialog(view,
+ _("Can't block financialperiod"));
}
}
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-05-19 16:38:02 UTC (rev 2902)
@@ -1,5 +1,6 @@
Bloqu\u00E9e=
Can't\ add\ fiscal\ period=
+Can't\ block\ financialperiod=
Can't\ delete\ all\ fiscal\ period=
Confirmation=
DEBUG\ delete\ all=
@@ -58,9 +59,10 @@
lima.block=block
lima.cancel=Cancel
lima.charge=Expense
-lima.chartofaccounts.journal=
-lima.chartofaccounts.management=
-lima.chartofaccounts.subledgers=
+lima.charts.account=Accounts chart
+lima.charts.entrybook=EntryBooks chart
+lima.charts.financialperiod=Financial Periods
+lima.charts.fiscalyear=Fiscal Years
lima.close=Closed
lima.closure=Closure
lima.closure.period.begin=Period from
@@ -288,6 +290,8 @@
lima.remove.lettering=Remove a letter
lima.remove.transaction=Remove a transaction
lima.reports=Reports
+lima.reports.accounts=Edit account
+lima.reports.entrybooks=Edit entrybook
lima.response.no=No
lima.response.yes=Yes
lima.result=Result
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-19 10:52:43 UTC (rev 2901)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-05-19 16:38:02 UTC (rev 2902)
@@ -1,5 +1,6 @@
Bloqu\u00E9e=
Can't\ add\ fiscal\ period=
+Can't\ block\ financialperiod=
Can't\ delete\ all\ fiscal\ period=
Confirmation=
DEBUG\ delete\ all=
@@ -56,9 +57,10 @@
lima.bilan.total=Total
lima.block=Bloquer
lima.charge=Charge
-lima.chartofaccounts.journal=Journaux
-lima.chartofaccounts.management=Plan comptable
-lima.chartofaccounts.subledgers=Plan tiers
+lima.charts.account=Plan comptable
+lima.charts.entrybook=Journaux
+lima.charts.financialperiod=P\u00E9riodes comptables
+lima.charts.fiscalyear=Exercices
lima.close=Ferm\u00E9
lima.closure=Cloture
lima.closure.period.begin=P\u00E9riode de
@@ -157,7 +159,7 @@
lima.filter.not.contains=Ne contient pas
lima.filter.starts.with=Commence par
lima.financialperiod.block=Cloturer une p\u00E9riode
-lima.financialperiod.management=P\u00E9riodes comptables
+lima.financialperiod.management=
lima.find.transaction=Rechercher transaction
lima.fiscalperiod.addFiscalPeriod=Nouvel exercice
lima.fiscalperiod.block=Cloturer un exercice
@@ -166,7 +168,7 @@
lima.fiscalyear.closefiscalyear=Cl\u00F4turer l'exercice
lima.fiscalyear.closeperiod=Cl\u00F4turer une p\u00E9riode
lima.fiscalyear.listclosed=Voir toutes les cl\u00F4tures
-lima.fiscalyear.management=Exercices
+lima.fiscalyear.management=
lima.grand.livre=Grand-Livre
lima.home=Page d'accueil - TODO
lima.identity.address=Adresse
@@ -272,6 +274,8 @@
lima.remove.lettering=Supprimer la lettre
lima.remove.transaction=Supprimer une transaction
lima.reports=Rapports
+lima.reports.accounts=Edition compte
+lima.reports.entrybooks=Edition journal
lima.response.no=Non
lima.response.yes=Oui
lima.result=Compte de r\u00E9sultat
1
0
Author: jpepin
Date: 2010-05-19 12:52:43 +0200 (Wed, 19 May 2010)
New Revision: 2901
Url: http://chorem.org/repositories/revision/lima/2901
Log:
Migration du calcul des donn?\195?\169es, totaux et soldes dans ReportService.
Added:
trunk/.settings/
trunk/.settings/org.maven.ide.eclipse.prefs
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CriteriaWidget.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java
Removed:
trunk/lima-business/src/test/java/org/chorem/lima/business/utils/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.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/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.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/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.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/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.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/AccountsReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
trunk/pom.xml
Added: trunk/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- trunk/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ trunk/.settings/org.maven.ide.eclipse.prefs 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,9 @@
+#Wed May 19 12:27:54 CEST 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -19,8 +19,10 @@
package org.chorem.lima.business;
+import java.util.Date;
import java.util.List;
+import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.entity.Account;
/**
@@ -35,7 +37,7 @@
public interface AccountService {
List<Account> getAllAccounts() throws LimaException;
-
+
/**
* Create new account. If {@code masterAccount} is not null, {@code account}
* is added in {@code masterAccount}'s subAccounts.
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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -22,12 +22,12 @@
import java.util.Date;
import java.util.List;
+import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
-import org.nuiton.topia.TopiaException;
/**
* Transaction service.
@@ -88,9 +88,5 @@
void updateEntry(Entry entry) throws LimaException;
void removeEntry(Entry entry) throws LimaException;
-
- List<Entry> getAllEntriesForAccount(Account account, Date beginDate, Date endDate) throws LimaException;
- List<Entry> getAllEntriesForEntryBook(EntryBook entryBook, Date beginDate, Date endDate) throws LimaException;
-
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -19,8 +19,12 @@
package org.chorem.lima.business;
-import org.chorem.lima.beans.BalanceSheet;
+import java.util.Date;
+
import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
@@ -47,8 +51,8 @@
* @param fiscalPeriod exercice
* @return le bilan
* @throws LimaException
+ * BalanceSheet generateBalanceSheet(FiscalPeriod fiscalPeriod) throws LimaException;
*/
- BalanceSheet generateBalanceSheet(FiscalPeriod fiscalPeriod) throws LimaException;
/**
* Generation de la balance.
@@ -57,6 +61,16 @@
* @return la balance
* @throws LimaException
*/
- BalanceTrial generateBalanceTrial(FinancialPeriod financialPeriod) throws LimaException;
+ BalanceTrial generateBalanceTrial(Date beginDate, Date endDate) throws LimaException;
+ /**
+ * Generation du rapports des comptes
+ */
+ ReportsDatas generateAccountsReports(Account account, Date beginDate, Date endDate) throws LimaException;
+
+ /**
+ * Generation du rapports des journaux
+ */
+ ReportsDatas generateEntryBooksReports(EntryBook entryBook, Date beginDate, Date endDate) 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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -26,7 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
-import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ejb.AccountServiceImpl;
@@ -39,14 +38,11 @@
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.entity.FinancialTransactionDAO;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
/**
* Defaults rules, if no localized rules classes is instantiated
* this default class contain the strict minimum rules to check the data integrity
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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
-import java.util.Properties;
import javax.ejb.Stateless;
@@ -37,7 +36,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
-import org.chorem.lima.entity.EntryDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
@@ -351,4 +349,5 @@
throw new LimaException("Can't update account", ex);
}
}
+
}
\ No newline at end of file
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.utils.DateUtil;
import org.chorem.lima.entity.Account;
import org.jdom.Document;
import org.jdom.Element;
@@ -45,8 +44,6 @@
static org.jdom.Document document = new Document(racine);
- private static DateUtil dateUtil = new DateUtil();
-
private AccountServiceImpl accountServiceImpl = new AccountServiceImpl();
private EntryBookServiceImpl journalServiceImpl = new EntryBookServiceImpl();
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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -26,21 +26,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FinancialPeriodService;
-import org.chorem.lima.business.FiscalPeriodService;
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.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
-import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialPeriodImpl;
-import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
@@ -48,7 +43,6 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
/**
@@ -285,17 +279,12 @@
= LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
TopiaQuery query = closedPeriodicEntryBookDAO.createQuery();
- String closedPeriodicEntryBookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.FISCAL_PERIOD, FiscalPeriod.LOCKED);
+ String closedPeriodicEntryBookProperty =
+ TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD,
+ FinancialPeriod.FISCAL_PERIOD, FiscalPeriod.LOCKED);
query.add(closedPeriodicEntryBookProperty, Boolean.FALSE);
-
+ query.addOrder(ClosedPeriodicEntryBook.FINANCIAL_PERIOD);
result = closedPeriodicEntryBookDAO.findAllByQuery(query);
- log.debug(result);
-
- // FOR NO LAZY EXCEPTION
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : result) {
- closedPeriodicEntryBook.getEntryBook().getLabel();
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
- }
// commit
transaction.commitTransaction();
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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -29,7 +29,6 @@
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.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.FinancialTransactionService;
@@ -92,7 +91,8 @@
topiaContext = rootContext.beginTransaction();
//check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction, topiaContext);
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
+ financialtransaction, topiaContext);
FinancialTransactionDAO financialtransactionDAO = LimaCallaoDAOHelper
.getFinancialTransactionDAO(topiaContext);
@@ -122,7 +122,8 @@
*/
protected FinancialTransaction findByEntryBook(TopiaContext topiaTransaction, EntryBook entryBook) throws TopiaException {
- FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ FinancialTransactionDAO transactionDAO =
+ LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
TopiaQuery query = transactionDAO.createQuery();
// entryBook is not visible, but column "entryBook"
@@ -199,7 +200,8 @@
TopiaContext topiaTransaction = null;
try {
topiaTransaction = rootContext.beginTransaction();
- FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ FinancialTransactionDAO transactionDAO =
+ LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
// filter with topia query
TopiaQuery query = transactionDAO.createQuery();
@@ -211,7 +213,6 @@
if (financialPeriod != null) {
query.add("financialPeriod", financialPeriod);
}
-
transactions = transactionDAO.findAllByQuery(query);
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
@@ -247,7 +248,8 @@
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction, topiaTransaction);
- FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ FinancialTransactionDAO transactionDAO =
+ LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
transactionDAO.update(financialtransaction);
// commit
topiaTransaction.commitTransaction();
@@ -271,8 +273,10 @@
//check if the financial period is blocked
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction, topiaTransaction);
- FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
- FinancialTransaction financialTransaction2 = transactionDAO.findByTopiaId(financialtransaction.getTopiaId());
+ FinancialTransactionDAO transactionDAO =
+ LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction);
+ FinancialTransaction financialTransaction2 =
+ transactionDAO.findByTopiaId(financialtransaction.getTopiaId());
transactionDAO.delete(financialTransaction2);
// commit
topiaTransaction.commitTransaction();
@@ -371,84 +375,4 @@
doFinally(topiaContext, log);
}
}
-
- @Override
- public List<Entry> getAllEntriesForAccount(Account account, Date beginDate, Date endDate) throws LimaException {
- List<Entry> entries = null;
- TopiaContext topiaTransaction = null;
- try {
- topiaTransaction = rootContext.beginTransaction();
- EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
- 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);
- query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
- .addParam("beginDate", beginDate)
- .addParam("endDate", endDate);
- }
- entries=entryDAO.findAllByQuery(query);
-
- //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- for (Entry entry : entries) {
- entry.getEntryBook();
- entry.getFinancialTransaction().getTransactionDate();
- }
-
- // commit
- topiaTransaction.commitTransaction();
- }
- catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
- }
- finally {
- doFinally(topiaTransaction, log);
- }
-
- return entries;
- }
-
- @Override
- public List<Entry> getAllEntriesForEntryBook(EntryBook entryBook, Date beginDate, Date endDate) throws LimaException {
- List<Entry> entries = null;
- TopiaContext topiaTransaction = null;
- try {
- topiaTransaction = rootContext.beginTransaction();
- EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
- TopiaQuery query = entryDAO.createQuery();
-
- if (entryBook != null) {
- query
- .add(Entry.ENTRY_BOOK, entryBook);
- }
- if (beginDate != null && endDate != null){
- String transactionDateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE);
- query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
- .addParam("beginDate", beginDate)
- .addParam("endDate", endDate);
- }
- entries=entryDAO.findAllByQuery(query);
-
- //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- for (Entry entry : entries) {
- entry.getAccount();
- entry.getFinancialTransaction().getTransactionDate();
- }
-
- // commit
- topiaTransaction.commitTransaction();
- }
- catch (TopiaException ex) {
- doCatch(topiaTransaction, ex, log);
- }
- finally {
- doFinally(topiaTransaction, log);
- }
-
- return entries;
- }
}
\ No newline at end of file
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -19,45 +19,255 @@
package org.chorem.lima.business.ejb;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
import javax.ejb.Stateless;
-import org.chorem.lima.beans.BalanceSheet;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.beans.BalanceTrialImpl;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.beans.ReportsDatasImpl;
+import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ReportService;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
+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.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;
@Stateless
-public class ReportServiceImpl implements ReportService {
+public class ReportServiceImpl extends AbstractLimaService implements ReportService {
+
+ private static final Log log = LogFactory.getLog(AccountServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ public ReportServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ }
+
+ @Override
+ public ReportsDatas generateAccountsReports(Account account, Date beginDate, Date endDate) throws LimaException {
+ ReportsDatas reportsDatas = null;
+
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+
+ reportsDatas =
+ generateAccountReportsWithTransaction(account, beginDate,
+ endDate, topiaTransaction);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ return reportsDatas;
+ }
- public String generateAccount(String number, String amount, String label) {
- return null;
- }
+
+ public ReportsDatas generateAccountReportsWithTransaction (Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException{
+ ReportsDatas reportsDatas = new ReportsDatasImpl();
+ double credit = 0, debit = 0, solde = 0;
- public BalanceSheet generateBalanceSheet(FiscalPeriod fiscalPeriod) throws LimaException {
- // bilan
- return null;
- }
+ try {
+ EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ 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);
+ query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
+ .addParam("beginDate", beginDate)
+ .addParam("endDate", endDate);
+ }
+ reportsDatas.setListEntry(entryDAO.findAllByQuery(query));
+
+ for (Entry entry : reportsDatas.getListEntry()) {
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ entry.getEntryBook();
+ entry.getFinancialTransaction().getTransactionDate();
+ //calulate the amounts
+ if (entry.getDebit()) {
+ debit += entry.getAmount();
+ }
+ else {
+ credit += entry.getAmount();
+ }
+ }
+
+ // set the amounts and solde
+ solde = debit - credit;
+ if (solde > 0){
+ reportsDatas.setSoldeDebit(true);
+ }
+ solde = Math.abs(solde);
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
- public BalanceTrial generateBalanceTrial(FinancialPeriod financialPeriod) throws LimaException {
- // balance
- return null;
+ // commit
+ topiaContext.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+
+ return reportsDatas;
}
+
+ /**
+ * Get all entry from an entrybook and a begin-end dates order by financial transaction date
+ *
+ * Calculate the amounts and the solde
+ *
+ */
+ @Override
+ public ReportsDatas generateEntryBooksReports(EntryBook entryBook, Date beginDate, Date endDate) throws LimaException {
+ ReportsDatas reportsDatas = new ReportsDatasImpl();
+ double credit = 0, debit = 0, solde = 0;
+
+ // Get all entries with a topia query
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
+ TopiaQuery query = entryDAO.createQuery();
+
+ if (entryBook != null) {
+ query
+ .add(Entry.ENTRY_BOOK, entryBook);
+ }
+ if (beginDate != null && endDate != null){
+ String transactionDateProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.TRANSACTION_DATE);
+ query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
+ .addParam("beginDate", beginDate)
+ .addParam("endDate", endDate);
+ String orderProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.TRANSACTION_DATE);
+ query.addOrder(orderProperty);
+ }
+ reportsDatas.setListEntry(entryDAO.findAllByQuery(query));
+
+ for (Entry entry : reportsDatas.getListEntry()) {
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ entry.getAccount();
+ entry.getFinancialTransaction().getTransactionDate();
+ //calulate the amounts
+ if (entry.getDebit()) {
+ debit += entry.getAmount();
+ }
+ else {
+ credit += entry.getAmount();
+ }
+ }
+
+ // set the amounts and solde
+ solde = debit - credit;
+ if (solde > 0){
+ reportsDatas.setSoldeDebit(true);
+ }
+ solde = Math.abs(solde);
+ reportsDatas.setAmountCredit(credit);
+ reportsDatas.setAmountDebit(debit);
+ reportsDatas.setAmountSolde(solde);
+
+ // commit
+ topiaTransaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ return reportsDatas;
+ }
- public String generateCashFlowStatement(String period) {
- return null;
- }
-
- public String generateGeneralLedger(String period) {
- return null;
- }
-
- public String generateIncomeStatement(String period) {
- return null;
- }
-
- public String generateJournal(String type, String period) {
- return null;
- }
+ /**
+ * Get balance trial
+ *
+ * Calculate the amounts and the solde
+ */
+ @Override
+ public BalanceTrial generateBalanceTrial(Date beginDate, Date endDate) throws LimaException {
+ BalanceTrial balanceTrial = new BalanceTrialImpl();
+ balanceTrial.setReportsDatas(new ArrayList<ReportsDatas>());
+ double credit = 0, debit = 0, solde = 0;
+ List<Account> accountsList = new ArrayList<Account>();
+
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+
+ //Get All account
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(topiaTransaction);
+ List<Account> accounts = accountDAO.findAll();
+ accountsList.addAll(accounts);
+
+ //for each account create a balance sheet with a ReportsDatas
+ for (Account account : accounts) {
+ ReportsDatas reportsDatas =
+ generateAccountReportsWithTransaction(account, beginDate, endDate, topiaTransaction);
+ reportsDatas.setAccount(account);
+ // add balance sheet to balance trial
+ balanceTrial.addReportsDatas(reportsDatas);
+ if (reportsDatas.getSoldeDebit()) {
+ debit += reportsDatas.getAmountSolde();
+ }
+ else {
+ credit += reportsDatas.getAmountSolde();
+ }
+ }
+ // set the amounts and solde
+ solde = debit - credit;
+ if (solde > 0){
+ balanceTrial.setSoldeDebit(true);
+ }
+ solde = Math.abs(solde);
+ balanceTrial.setAmountCredit(credit);
+ balanceTrial.setAmountDebit(debit);
+ balanceTrial.setAmountSolde(solde);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ return balanceTrial;
+ }
}
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-05-19 10:52:43 UTC (rev 2901)
@@ -5,6 +5,8 @@
org.chorem.lima.entity.Account.attribute.identity.tagvalue.lazy=false
org.chorem.lima.entity.FinancialTransaction.attribute.financialPeriod.tagvalue.lazy=false
org.chorem.lima.entity.FiscalPeriod.attribute.financialPeriod.tagvalue.lazy=false
+org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.financialPeriod.tagvalue.lazy=false
+org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.entryBook.tagvalue.lazy=false
#model.tagvalue.dbSchema=Callao
model.tagvalue.String=text
\ No newline at end of file
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -37,6 +37,7 @@
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.RecordService;
import org.chorem.lima.business.FinancialTransactionService;
+import org.chorem.lima.business.ReportService;
/**
* Is class is a service factory based on embedded openejb container.
@@ -232,11 +233,33 @@
return ejbHome;
}
+
/**
* Get record service.
*
* @return record service proxy
*/
+ public ReportService getReportService() {
+
+ // TODO EC-20100410 put lookup name in configuration
+ // name should be fully configurable due to custom implementation used
+ String lookupName = "ReportServiceImplLocal";
+ ReportService ejbHome = null;
+ try {
+ ejbHome = (ReportService)ctx.lookup(lookupName);
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't lookup for service : " + lookupName, eee);
+ }
+ }
+ return ejbHome;
+ }
+
+ /**
+ * Get record service.
+ *
+ * @return record service proxy
+ */
public RecordService getRecordService() {
// TODO EC-20100410 put lookup name in configuration
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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -41,8 +41,8 @@
import org.chorem.lima.ui.entrybooksreports.EntryBooksReportsView;
import org.chorem.lima.ui.financialperiod.FinancialPeriodView;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
-import org.chorem.lima.ui.transaction.FinancialTransactionView;
-import org.chorem.lima.ui.transaction.LetteringView;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionView;
+import org.chorem.lima.ui.financialtransaction.LetteringView;
import org.chorem.lima.util.ErrorHelper;
/**
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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -22,22 +22,18 @@
import static org.nuiton.i18n.I18n._;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
import javax.swing.table.AbstractTableModel;
import org.apache.commons.lang.StringUtils;
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.beans.ReportsDatas;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ReportService;
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;
@@ -60,7 +56,7 @@
private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class);
/** Services. */
- protected FinancialTransactionService financialTransactionService;
+ protected ReportService reportService;
/** Account. */
protected Account selectedAccount;
@@ -72,15 +68,14 @@
protected Date selectedEndDate;
/** data cache */
- protected List<Entry> cacheDataList;
+ protected ReportsDatas cacheDataList;
/**
* Constructor.
*/
public AccountsReportsTableModel() {
- financialTransactionService =
- LimaServiceFactory.getInstance().getTransactionService();
+ reportService = LimaServiceFactory.getInstance().getReportService();
}
@Override
@@ -89,7 +84,7 @@
// just prevent too much result
if (selectedAccount != null) {
- result = cacheDataList.size();
+ result = cacheDataList.getListEntry().size();
}
else {
if (log.isDebugEnabled()) {
@@ -135,7 +130,7 @@
public Object getValueAt(int row, int column) {
Object result = null;
if(selectedAccount != null) {
- Entry currentRow = cacheDataList.get(row);
+ Entry currentRow = cacheDataList.getListEntry().get(row);
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat("dd MMM yyyy");
@@ -205,12 +200,11 @@
fireTableDataChanged();
}
- public List<Entry> getDataList(){
- List<Entry> results = new ArrayList<Entry>();
+ public ReportsDatas getDataList(){
+ ReportsDatas results = null;
try {
- results =
- financialTransactionService.getAllEntriesForAccount(
- selectedAccount, selectedBeginDate, selectedEndDate);
+ results = reportService.generateAccountsReports(selectedAccount,
+ selectedBeginDate, selectedEndDate);
}
catch (LimaException eee) {
if (log.isErrorEnabled()) {
Modified: 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 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -20,11 +20,9 @@
import static org.nuiton.i18n.I18n._;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
+import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.ui.ReportsHelper;
@@ -52,32 +50,36 @@
this.view = view;
}
+ /*
+ * set text and amounts of labels credit, debit, solde
+ */
public void updateFooterLabel(){
AccountsReportsTableModel tablemodel =
(AccountsReportsTableModel) view.getAccountsReportsTable().getModel();
- List<Entry> cacheDataList = tablemodel.getDataList();
+ ReportsDatas cacheDataList = tablemodel.cacheDataList;
- if (tablemodel.getDataList() != null){
- Double amountCredit = helper.getTotalCredit(cacheDataList);
- Double amountDebit = helper.getTotalDebit(cacheDataList);
- view.amountCreditLabel.setText(String.valueOf(amountCredit));
- view.amountDebitLabel.setText(String.valueOf(amountDebit));
- Double amountSolde = Math.abs(helper.getSolde(cacheDataList));
+ if (cacheDataList != null){
+ // set amounts credit and debit and solde
+ view.amountCreditLabel.setText(String.valueOf(cacheDataList.amountCredit));
+ view.amountDebitLabel.setText(String.valueOf(cacheDataList.amountDebit));
+ Double amountSolde = cacheDataList.amountSolde;
view.amountSoldeLabel.setText(String.valueOf(amountSolde));
- if (amountSolde <0){
- //solde debiteur
- view.soldeLabel.setText(_("lima.soldecredit"));
+
+
+ if (amountSolde == 0){
+ view.soldeLabel.setText(_("lima.solde"));
}
- else if(amountSolde > 0) {
- //solde créditeur
- view.soldeLabel.setText(_("lima.soldedebit"));
- }
else {
- //solde = 0
- view.soldeLabel.setText(_("lima.solde"));
+ // set label solde: credit or debit
+ if (cacheDataList.soldeDebit) {
+ view.soldeLabel.setText(_("lima.soldedebit"));
+ }
+ else {
+ view.soldeLabel.setText(_("lima.soldecredit"));
+ }
}
- }
+ }
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -21,7 +21,6 @@
import static org.nuiton.i18n.I18n._;
-import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -29,11 +28,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.AccountService;
-import org.chorem.lima.business.FinancialTransactionService;
+import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.beans.BalanceTrialImpl;
+import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ReportService;
import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.ReportsHelper;
import org.chorem.lima.util.ErrorHelper;
@@ -57,8 +57,7 @@
private static final Log log = LogFactory.getLog(BalanceTableModel.class);
/** Services. */
- protected AccountService accountService;
- protected FinancialTransactionService financialTransactionService;
+ protected ReportService reportService;
/** Helper */
protected ReportsHelper helper;
@@ -73,21 +72,18 @@
protected Date selectedEndDate;
/** data cache */
- protected List<Account> cacheDataList;
+ protected BalanceTrial cacheDataList;
/**
* Constructor.
*/
public BalanceTableModel() {
- accountService = LimaServiceFactory.getInstance().getAccountService();
- financialTransactionService =
- LimaServiceFactory.getInstance().getTransactionService();
-
+ reportService = LimaServiceFactory.getInstance().getReportService();
}
@Override
public int getRowCount() {
- return cacheDataList.size();
+ return cacheDataList.getReportsDatas().size();
}
@Override
@@ -124,39 +120,33 @@
@Override
public Object getValueAt(int row, int column) {
Object result = null;
- Account currentRow = cacheDataList.get(row);
+ ReportsDatas currentRow = ((List<ReportsDatas>) cacheDataList.getReportsDatas()).get(row);
//get entries for the period for the current row
try {
- List<Entry> entries =
- financialTransactionService.getAllEntriesForAccount(currentRow,
- selectedBeginDate, selectedEndDate);
- Double solde = helper.getSolde(entries);
- Double debit = helper.getTotalDebit(entries);
- Double credit = helper.getTotalCredit(entries);
switch (column) {
case 0:
- result = currentRow.getAccountNumber(); //account number
+ result = currentRow.account.getAccountNumber(); //account number
break;
case 1:
- result = currentRow.getLabel(); //account label
+ result = currentRow.account.getLabel(); //account label
break;
case 2:
- result = debit; // total debit
+ result = currentRow.getAmountDebit(); // total debit
break;
case 3:
- result = credit; // total crédit
+ result = currentRow.getAmountCredit(); // total crédit
break;
case 4: // solde debit
- if (solde>0){
- result = Math.abs(solde);
+ if (currentRow.getSoldeDebit()){
+ result = currentRow.getAmountSolde();
}
else {
result = 0;
}
break;
case 5: // solde credit
- if (solde<0){
- result = Math.abs(solde);
+ if (!currentRow.getSoldeDebit()){
+ result = currentRow.getAmountSolde();
}
else {
result = 0;
@@ -180,14 +170,12 @@
public void setBeginDate(Date date){
selectedBeginDate = date;
- log.debug(selectedBeginDate);
cacheDataList=getDataList();
fireTableDataChanged();
}
public void setEndDate(Date date){
selectedEndDate = date;
- log.debug(selectedEndDate);
cacheDataList=getDataList();
fireTableDataChanged();
}
@@ -196,11 +184,11 @@
* get all account fot the selected period
* @return
*/
- public List<Account> getDataList(){
- List<Account> results = new ArrayList<Account>();
+ public BalanceTrial getDataList(){
+ BalanceTrial results = new BalanceTrialImpl();
try {
- results = accountService.getAllAccounts();
+ results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate);
}
catch (LimaException eee) {
if (log.isErrorEnabled()) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -24,6 +24,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.FinancialTransactionService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
@@ -67,40 +69,29 @@
* get all entries for all accounts on the selected period
*/
public void updateFooterLabel(){
- Double totalCredit = 0.00, totalDebit = 0.00, solde = 0.00;
BalanceTableModel tablemodel =
(BalanceTableModel) view.getBalanceTable().getModel();
- try {
- for (Account account : tablemodel.cacheDataList) {
- List<Entry> entries;
- entries = financialTransactionService.
- getAllEntriesForAccount(account,
- tablemodel.selectedBeginDate,
- tablemodel.selectedEndDate);
- totalCredit += helper.getTotalCredit(entries);
- totalDebit += helper.getTotalDebit(entries);
- solde += helper.getSolde(entries);
- }
+ BalanceTrial cacheDataList = tablemodel.cacheDataList;
+
+ if (cacheDataList != null){
+ // set amounts credit, debit and solde
+ view.amountCreditLabel.setText(String.valueOf(cacheDataList.amountCredit));
+ view.amountDebitLabel.setText(String.valueOf(cacheDataList.amountDebit));
+ Double amountSolde = cacheDataList.amountSolde;
+ view.amountSoldeLabel.setText(String.valueOf(amountSolde));
- view.amountCreditLabel.setText(String.valueOf(totalCredit));
- view.amountDebitLabel.setText(String.valueOf(totalDebit));
- view.amountSoldeLabel.setText(String.valueOf(solde));
- if (solde <0){
- //solde debiteur
- view.soldeLabel.setText(_("lima.soldecredit"));
+
+ if (amountSolde == 0){
+ view.soldeLabel.setText(_("lima.solde"));
}
- else if(solde > 0) {
- //solde créditeur
- view.soldeLabel.setText(_("lima.soldedebit"));
- }
else {
- //solde = 0
- view.soldeLabel.setText(_("lima.solde"));
- }
- }
- catch (LimaException eee){
- if (log.isDebugEnabled()){
- log.debug("Can't update footer labels",eee);
+ // set label solde: credit or debit
+ if (cacheDataList.soldeDebit) {
+ view.soldeLabel.setText(_("lima.soldedebit"));
+ }
+ else {
+ view.soldeLabel.setText(_("lima.soldecredit"));
+ }
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -18,12 +18,20 @@
package org.chorem.lima.ui.combobox;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
/**
* Account combo box model.
@@ -31,6 +39,8 @@
public class AccountComboBoxModel implements ComboBoxModel {
+ private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+
protected Object selectedAccount;
protected AccountService accountService;
@@ -57,30 +67,12 @@
@Override
public Object getElementAt(int index) {
- Object result = null;
- // TODO add cache
- try {
- result = accountService.getAllAccounts().get(index);
- }
- catch (LimaException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- return result;
+ return getDataList().get(index);
}
@Override
public int getSize() {
- int result = 0;
- // TODO add cache
- try {
- result = accountService.getAllAccounts().size();
- }
- catch (LimaException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- return result;
+ return getDataList().size();
}
@Override
@@ -89,7 +81,21 @@
}
-
+ public List<Account> getDataList(){
+ List<Account> result = new ArrayList<Account>();
+ try {
+ result = accountService.getAllAccounts();
+ Collections.sort(result, new AccountComparator());
+ }
+ catch (LimaException eee) {
+ // TODO Auto-generated catch block
+ if (log.isDebugEnabled()){
+ log.debug("Can't get list accounts", eee);
+ }
+ }
+ return result;
+
+ }
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComparator.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,32 @@
+/* *##% 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.combobox;
+
+import java.util.Comparator;
+
+import org.chorem.lima.entity.Account;
+
+public class AccountComparator implements Comparator<Account>{
+
+ @Override
+ public int compare(Account o1, Account o2) {
+ return o1.getAccountNumber().compareTo(o2.getAccountNumber());
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -18,12 +18,19 @@
package org.chorem.lima.ui.combobox;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.EntryBookService;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
/**
* Opened financial period combo box model.
@@ -36,6 +43,8 @@
*/
public class EntryBookComboBoxModel implements ComboBoxModel {
+ private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+
protected Object selectedEntryBook;
protected EntryBookService entryBookService;
@@ -49,16 +58,7 @@
*/
@Override
public int getSize() {
- int result = 0;
- // TODO add cache
- try {
- result = entryBookService.getAllEntryBooks().size();
- }
- catch (LimaException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- return result;
+ return getDataList().size();
}
/*
@@ -66,16 +66,7 @@
*/
@Override
public Object getElementAt(int index) {
- Object result = null;
- // TODO add cache
- try {
- result = entryBookService.getAllEntryBooks().get(index);
- }
- catch (LimaException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- return result;
+ return getDataList().get(index);
}
/*
@@ -109,4 +100,21 @@
public Object getSelectedItem() {
return selectedEntryBook;
}
+
+ /*
+ * get the accounts list
+ */
+ public List<EntryBook> getDataList(){
+ List<EntryBook> result = new ArrayList<EntryBook>();
+ try {
+ result = entryBookService.getAllEntryBooks();
+ }
+ catch (LimaException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't get list accounts", eee);
+ }
+ }
+ return result;
+ }
+
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -21,6 +21,7 @@
import static org.nuiton.i18n.I18n._;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -29,9 +30,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.beans.ReportsDatasImpl;
import org.chorem.lima.business.EntryBookService;
import org.chorem.lima.business.FinancialTransactionService;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ReportService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
@@ -58,7 +62,7 @@
private static final Log log = LogFactory.getLog(EntryBooksReportsTableModel.class);
/** Services. */
- protected FinancialTransactionService financialTransactionService;
+ protected ReportService reportService;
/** Account. */
protected EntryBook selectedEntryBook;
@@ -70,15 +74,15 @@
protected Date selectedEndDate;
/** data cache */
- protected List<Entry> cacheDataList;
+ protected ReportsDatas cacheDataList;
/**
* Constructor.
*/
public EntryBooksReportsTableModel() {
- financialTransactionService =
- LimaServiceFactory.getInstance().getTransactionService();
+ reportService =
+ LimaServiceFactory.getInstance().getReportService();
}
@Override
@@ -87,7 +91,7 @@
// just prevent too much result
if (selectedEntryBook != null) {
- result = cacheDataList.size();
+ result = cacheDataList.listEntry.size();
}
else {
if (log.isDebugEnabled()) {
@@ -133,11 +137,14 @@
public Object getValueAt(int row, int column) {
Object result = null;
if(selectedEntryBook != null) {
- Entry currentRow = cacheDataList.get(row);
+ Entry currentRow = cacheDataList.listEntry.get(row);
+ SimpleDateFormat simpleDateFormat =
+ new SimpleDateFormat("dd MMMMM yyyy");
switch (column) {
case 0:
- result = currentRow.getFinancialTransaction().getTransactionDate();
+ result = simpleDateFormat.
+ format(currentRow.getFinancialTransaction().getTransactionDate());
break;
case 1:
if (currentRow.getAccount() != null){
@@ -200,12 +207,11 @@
fireTableDataChanged();
}
- public List<Entry> getDataList(){
- List<Entry> results = new ArrayList<Entry>();
+ public ReportsDatas getDataList(){
+ ReportsDatas results = new ReportsDatasImpl();
try {
results =
- financialTransactionService.getAllEntriesForEntryBook(
- selectedEntryBook, selectedBeginDate, selectedEndDate);
+ reportService.generateEntryBooksReports(selectedEntryBook, selectedBeginDate, selectedEndDate);
}
catch (LimaException eee) {
if (log.isErrorEnabled()) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -20,11 +20,9 @@
import static org.nuiton.i18n.I18n._;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
+import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.ui.ReportsHelper;
@@ -52,30 +50,35 @@
this.view = view;
}
+
+ /*
+ * set text and amounts of labels credit, debit, solde
+ */
public void updateFooterLabel(){
EntryBooksReportsTableModel tablemodel =
(EntryBooksReportsTableModel) view.getEntryBooksReportsTable().getModel();
- List<Entry> cacheDataList = tablemodel.getDataList();
+ ReportsDatas cacheDataList = tablemodel.cacheDataList;
- if (tablemodel.getDataList() != null){
- Double amountCredit = helper.getTotalCredit(cacheDataList);
- Double amountDebit = helper.getTotalDebit(cacheDataList);
- view.amountCreditLabel.setText(String.valueOf(amountCredit));
- view.amountDebitLabel.setText(String.valueOf(amountDebit));
- Double amountSolde = Math.abs(helper.getSolde(cacheDataList));
+ if (cacheDataList != null){
+ // set amounts credit, debit and solde
+ view.amountCreditLabel.setText(String.valueOf(cacheDataList.amountCredit));
+ view.amountDebitLabel.setText(String.valueOf(cacheDataList.amountDebit));
+ Double amountSolde = cacheDataList.amountSolde;
view.amountSoldeLabel.setText(String.valueOf(amountSolde));
- if (amountSolde <0){
- //solde debiteur
- view.soldeLabel.setText(_("lima.soldecredit"));
+
+
+ if (amountSolde == 0){
+ view.soldeLabel.setText(_("lima.solde"));
}
- else if(amountSolde > 0) {
- //solde créditeur
- view.soldeLabel.setText(_("lima.soldedebit"));
- }
else {
- //solde = 0
- view.soldeLabel.setText(_("lima.solde"));
+ // set label solde: credit or debit
+ if (cacheDataList.soldeDebit) {
+ view.soldeLabel.setText(_("lima.soldedebit"));
+ }
+ else {
+ view.soldeLabel.setText(_("lima.soldecredit"));
+ }
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -37,7 +37,8 @@
public class FinancialPeriodTable extends JXTable {
- private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+ private static final Log log =
+ LogFactory.getLog(FinancialPeriodTableModel.class);
protected FinancialPeriodViewHandler handler;
@@ -47,17 +48,24 @@
private Highlighter colorTransaction;
+ /*
+ * Constructor, call highlighter
+ */
public FinancialPeriodTable(FinancialPeriodViewHandler handler) {
this.handler = handler;
model = this.handler.getView().modelFinancialPeriodTable;
- financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
+ financialPeriodService =
+ LimaServiceFactory.getInstance().getFinancialPeriodService();
//highlight financial financial transactions
addMonthColor();
addBlockColor();
}
+ /*
+ * Color the background row in grey if the month number is even (pair in french)
+ */
protected void addMonthColor() {
HighlightPredicate predicate = new HighlightPredicate() {
@Override
@@ -65,8 +73,6 @@
ComponentAdapter adapter) {
ClosedPeriodicEntryBook closedPeriodicEntryBook
= (ClosedPeriodicEntryBook) model.getElementAt(adapter.row);
- // FinancialPeriodEntryBook financialPeriodEntryBook
- // = (FinancialPeriodEntryBook) model.getElementAt(adapter.row);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM");
int month = Integer.parseInt(simpleDateFormat.format(
closedPeriodicEntryBook.getFinancialPeriod().getBeginDate()));
@@ -80,16 +86,24 @@
addHighlighter(colorTransaction);
}
+ /*
+ * Color the font in red if period are closed
+ */
protected void addBlockColor() {
HighlightPredicate predicate = new HighlightPredicate() {
@Override
public boolean isHighlighted(Component renderer,
ComponentAdapter adapter) {
- ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
- ClosedPeriodicEntryBook selectedClosedPeriodicEntryBook = (ClosedPeriodicEntryBook) model.getElementAt(adapter.row);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
+ new ClosedPeriodicEntryBookImpl();
+ ClosedPeriodicEntryBook selectedClosedPeriodicEntryBook =
+ (ClosedPeriodicEntryBook) model.getElementAt(adapter.row);
// true if locked
try {
- closedPeriodicEntryBook = financialPeriodService.getClosedPeriodicEntryBook(selectedClosedPeriodicEntryBook.getEntryBook(), selectedClosedPeriodicEntryBook.getFinancialPeriod());
+ closedPeriodicEntryBook =
+ financialPeriodService.getClosedPeriodicEntryBook(
+ selectedClosedPeriodicEntryBook.getEntryBook(),
+ selectedClosedPeriodicEntryBook.getFinancialPeriod());
} catch (LimaException eee) {
log.debug("Can't get closePeriodicEntryBook",eee);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -36,6 +36,7 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.service.LimaServiceFactory;
/**
@@ -60,7 +61,6 @@
protected FinancialPeriodService financialPeriodService;
/** Datas cache */
- //protected List<FinancialPeriodEntryBook> cacheDataList;
protected List<ClosedPeriodicEntryBook> cacheDataList;
public FinancialPeriodTableModel() {
@@ -69,26 +69,20 @@
financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
}
- /*
- * @see javax.swing.table.TableModel#getRowCount()
- */
+
@Override
public int getRowCount() {
//cacheDataList=getDataList();
return cacheDataList.size();
}
- /*
- * @see javax.swing.table.TableModel#getColumnCount()
- */
+
@Override
public int getColumnCount() {
return 3;
}
- /*
- * @see javax.swing.table.TableModel#getColumnName(int)
- */
+
@Override
public String getColumnName(int columnIndex) {
@@ -109,18 +103,14 @@
return result;
}
- /*
- * @see javax.swing.table.TableModel#getColumnClass(int)
- */
+
@Override
public Class<?> getColumnClass(int columnIndex) {
// both String
return String.class;
}
- /*
- * @see javax.swing.table.TableModel#isCellEditable(int, int)
- */
+
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
@@ -137,9 +127,7 @@
return currentRow;
}
- /*
- * @see javax.swing.table.TableModel#getValueAt(int, int)
- */
+
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Object result = null;
@@ -149,6 +137,7 @@
if (closedPeriodicEntryBook != null){
EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
+ FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod();
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat("MMMMM yyyy");
@@ -156,7 +145,7 @@
switch (columnIndex) {
case 0:
result = StringUtils.capitalize(simpleDateFormat.
- format(closedPeriodicEntryBook.getFinancialPeriod().getBeginDate()));
+ format(financialPeriod.getBeginDate()));
break;
case 1:
result = entryBook.getCode()+" - "+entryBook.getLabel();
@@ -183,15 +172,11 @@
log.debug("Can't get closedperiodicentrybook list", eee );
}
}
- Collections.sort(results, new ClosedPeriodicEntryBookComparator());
+ //Collections.sort(results, new ClosedPeriodicEntryBookComparator());
cacheDataList=results;
}
public void blockFinancialPeriod(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
- /* ClosedPeriodicEntryBook closedPeriodicEntryBook =
- financialPeriodService.getClosedPeriodicEntryBook(
- financialPeriodEntryBook.entryBook,
- financialPeriodEntryBook.financialPeriod);*/
financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
fireTableDataChanged();
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CriteriaWidget.jaxx (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CriteriaWidget.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CriteriaWidget.jaxx 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,41 @@
+<!-- ##% 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 insets='5,5,5,5'>
+ <script>
+ protected void removeCriteriaWidget(){}
+ </script>
+ <row>
+ <cell>
+ <JAXXComboBox id="criteriaComboBox" width="200">
+ <item value='date' label='{_("lima.date")}' selected="true"/>
+ <item value='voucher' label='{_("lima.voucher")}'/>
+ <item value='account' label='{_("lima.account")}'/>
+ <item value='description' label='{_("lima.description")}'/>
+ <item value='debit' label='{_("lima.debit")}'/>
+ <item value='credit' label='{_("lima.credit")}'/>
+ <item value='amount' label='{_("lima.amount")}'/>
+ </JAXXComboBox>
+ </cell>
+ <cell weightx="0">
+ <JPanel id="criteriaPanel"/>
+ </cell>
+ <cell>
+ <JButton id="removeButton" text="lima.remove" onActionPerformed="removeCriteriaWidget()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java (from rev 2889, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,84 @@
+/* *##% 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.financialtransaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.ui.accountsreports.AccountsReportsTableModel;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionHelper {
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class);
+
+ /**
+ * Get total credit for a transaction.
+ *
+ * @param transaction transaction to get credit
+ * @return total credit
+ */
+ public static double getCredit(FinancialTransaction financialtransaction) {
+ double credit = 0;
+ for (Entry entry : financialtransaction.getEntry()) {
+ // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
+ if (!entry.getDebit()) {
+ credit += entry.getAmount();
+ }
+ }
+ return credit;
+ }
+
+ /**
+ * Get total debit for a transaction.
+ *
+ * @param transaction transaction to get debit
+ * @return total debit
+ */
+ public static double getDebit(FinancialTransaction financialtransaction) {
+ double debit = 0;
+ for (Entry entry : financialtransaction.getEntry()) {
+ // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
+ if (entry.getDebit()) {
+ debit += entry.getAmount();
+ }
+ }
+ return debit;
+ }
+
+ /**
+ * Return true if transaction is balanced (credit == debit).
+ *
+ * @param transaction transaction to test
+ * @return {@code true} if transaction is balanced
+ */
+ public static boolean isBalanced(FinancialTransaction financialtransaction) {
+ boolean balanced = getDebit(financialtransaction) == getCredit(financialtransaction);
+ return balanced;
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx (from rev 2890, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,90 @@
+<!-- ##% 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>
+ <FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" />
+ <Boolean id="selectedRow" javaBean="false" />
+ <org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/>
+ <script>
+ <![CDATA[
+
+ import org.chorem.lima.entity.FiscalPeriod;
+ import org.chorem.lima.entity.FinancialPeriod;
+
+ ]]>
+ </script>
+
+ <!-- <JPopupMenu id="MenuRightPanel">
+ <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/>
+ <JMenuItem text="lima.print"/>
+ </JPopupMenu>
+ <JPopupMenu id="MenuRightTransaction">
+ <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/>
+ <JMenuItem text="lima.print"/>
+ </JPopupMenu> -->
+
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell>
+ <JLabel id="fiscalPeriodLabel" text="lima.fiscalyear.management"/>
+ </cell>
+ <cell>
+ <JComboBox id="fiscalPeriodComboBox"
+ model="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel()}"
+ renderer="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer()}"
+ onItemStateChanged="getModelFinancialPeriod().setFiscalPeriod( (FiscalPeriod) event.getItem())"
+ editable="false"/>
+ </cell>
+ <cell>
+ <JLabel id="financialPeriodLabel" text="lima.transaction.period"
+ />
+ </cell>
+ <cell>
+ <JComboBox id="financialPeriodComboBox"
+ model="{getModelFinancialPeriod()}"
+ renderer="{new org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer()}"
+ onItemStateChanged="getFinancialTransactionTableModel().setFinancialPeriod((FinancialPeriod) event.getItem())"
+ editable="false"
+ />
+ </cell>
+ <cell>
+ <JButton text="lima.add.transaction"
+ onActionPerformed="getHandler().addFinancialTransaction()"/>
+ </cell>
+ <cell>
+ <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/>
+ </cell>
+ <cell>
+ <JButton text="lima.common.remove"
+ onActionPerformed="getHandler().deleteSelectedRow()"
+ enabled="{isSelectedRow()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1" weighty="1" rows="3" columns="7">
+ <JScrollPane>
+ <org.chorem.lima.ui.financialtransaction.table.FinancialTransactionTableModel
+ id="financialTransactionTableModel" />
+ <org.chorem.lima.ui.financialtransaction.table.FinancialTransactionTable
+ id="financialTransactionTable" sortable="false" rowHeight="22"
+ constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}" />
+ <javax.swing.ListSelectionModel javaBean="getFinancialTransactionTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java (from rev 2898, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,149 @@
+/* *##% 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.financialtransaction;
+
+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.financialtransaction.FinancialTransactionView;
+import org.chorem.lima.ui.financialtransaction.table.FinancialTransactionTable;
+import org.chorem.lima.ui.financialtransaction.table.FinancialTransactionTableModel;
+
+/**
+ * Handler associated with financial transaction view.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialTransactionViewHandler {
+
+ /** log. */
+ private static final Log log =
+ LogFactory.getLog(FinancialTransactionViewHandler.class);
+
+ protected FinancialTransactionView view;
+
+ protected FinancialTransactionViewHandler(FinancialTransactionView view) {
+ this.view = view;
+ }
+
+ //add a new transaction
+ public void addFinancialTransaction() {
+ FinancialTransactionTable table =
+ (FinancialTransactionTable)view.getFinancialTransactionTable();
+ FinancialTransactionTableModel model =
+ (FinancialTransactionTableModel)table.getModel();
+
+ try {
+ model.addFinancialTransaction();
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add financialtransaction", ex);
+ }
+ JOptionPane.showMessageDialog(view,
+ _("lima.warning.entrybookscloded"));
+ }
+ }
+
+ //implement new transaction button
+ //add a new entry to the selected transaction
+ public void addEmptyEntry(){
+
+ FinancialTransactionTable table =
+ (FinancialTransactionTable)view.getFinancialTransactionTable();
+ FinancialTransactionTableModel model =
+ (FinancialTransactionTableModel)table.getModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+ Object selectedValue = model.getElementAt(indexSelectedRow);
+ try {
+ model.addEmptyEntry(selectedValue, indexSelectedRow);
+ } catch (LimaException ex){
+ if (log.isErrorEnabled()) {
+ log.error("Can't add emptyentry", ex);
+ }
+ JOptionPane.showMessageDialog(view,
+ _("lima.warning.entrybookscloded"));
+ }
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call addentry selected transaction without selection");
+ }
+ }
+ }
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @throws LimaException
+ */
+ public void deleteSelectedRow(){
+
+ FinancialTransactionTable table =
+ (FinancialTransactionTable)view.getFinancialTransactionTable();
+ FinancialTransactionTableModel model =
+ (FinancialTransactionTableModel)table.getModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+
+ Object selectedValue = model.getElementAt(indexSelectedRow);
+ String message = null;
+ if (selectedValue instanceof FinancialTransaction) {
+ message = _("lima.question.remove.transaction");
+ }
+ else {
+ message = _("lima.question.remove.entry");
+ }
+
+ int response = JOptionPane.showConfirmDialog(view, message,
+ _("lima.transaction.confirmdelete"), JOptionPane.YES_NO_OPTION);
+
+ if (response == JOptionPane.YES_OPTION) {
+
+ try {
+ model.removeObject(selectedValue, indexSelectedRow);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove transaction or entry", ex);
+ }
+ JOptionPane.showMessageDialog(view,
+ _("lima.warning.entrybookscloded"));
+ }
+ }
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call delete selected row without selection");
+ }
+ }
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetteringView.jaxx (from rev 2890, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetteringView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetteringView.jaxx 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,122 @@
+<!-- ##% 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 fill="both">
+ <script>
+ <![CDATA[
+ import org.chorem.lima.entity.Account;
+ import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
+ import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+
+ // Swingx auto complete (for account) :
+ AutoCompleteDecorator.decorate(accountComboBox, new ObjectToStringConverter() {
+ @Override
+ public String getPreferredStringForItem(Object item) {
+ if (item == null) {
+ return "";
+ }
+ Account account = (Account) item;
+ return account.getAccountNumber() + " : " + account.getLabel();
+ }
+ });
+
+ protected void addLettering() {
+ // never been implemented :(
+ };
+ protected void removeLettering() {
+ // never been implemented :(
+ };
+ ]]>
+ </script>
+ <row>
+ <cell>
+ <Table>
+ <!-- account -->
+ <row fill="horizontal" weightx="1" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.account"/>
+ </cell>
+ <cell>
+ <org.chorem.lima.widgets.JWideComboBox id="accountComboBox"
+ model="{new org.chorem.lima.ui.combobox.AccountComboBoxModel()}" />
+ </cell>
+ </row>
+ <!-- from -->
+ <row fill="horizontal" weightx="1" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.lettering.from"/>
+ </cell>
+ <cell>
+ <org.chorem.lima.widgets.JWideComboBox id="fromPeriodComoboBox" />
+ </cell>
+ </row>
+ <!-- to -->
+ <row fill="horizontal" weightx="1" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.lettering.to"/>
+ </cell>
+ <cell>
+ <org.chorem.lima.widgets.JWideComboBox id="toPeriodComoboBox" />
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ <cell>
+ <!-- entries -->
+ <Table fill="both">
+ <row columns="3">
+ <cell>
+ <JLabel text="lima.lettering.entries"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.lettering.lettered'
+ value='{_("lima.lettering.lettered")}' selected='true'/>
+ </cell>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.lettering.notlettered'
+ value='{_("lima.lettering.notlettered")}'/>
+ </cell>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.lettering.letteredall'
+ value='{_("lima.lettering.letteredall")}'/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row columns="2" weightx="1" weighty="1" anchor="center" fill="both">
+ <cell>
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="letteringTable" />
+ </JScrollPane>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <!-- add lettering -->
+ <JButton id="addButton" text="lima.lettering.add"
+ onActionPerformed="addLettering()"/>
+ </cell>
+ <cell>
+ <!-- remove lettering -->
+ <JButton id="removeButton" text="lima.lettering.remove"
+ onActionPerformed="removeLettering()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,14 @@
+package org.chorem.lima.ui.financialtransaction;
+
+public class SearchFinancialTransactionViewHandler {
+
+
+ protected void addCriteriaWidget() {
+
+ }
+
+ protected void doSearch() {
+
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,60 @@
+<!-- ##% 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.
+ ##% -->
+
+<JFrame title="lima.search" width="620" height="300" locationRelativeTo="{null}"
+ onWindowClosing="windowClosing()"
+ defaultCloseOperation="do_nothing_on_close"
+ iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
+ <script>
+ protected void addCriteriaWidget() {};
+ protected void doSearch() {};
+ protected void windowClosing() {};
+ </script>
+ <JScrollPane>
+ <Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1">
+ <row>
+ <cell>
+ <JButton id="addButton" text="lima.common.add" width="100" onActionPerformed="addCriteriaWidget()"/>
+ </cell>
+ <cell>
+ <JLabel text="lima.search.items.where" width="200"/>
+ </cell>
+ <cell>
+ <JAXXComboBox id="criteriaAllAnyComboBox" width="200">
+ <item value='all' label='{_("lima.all.criteria")}' selected="true"/>
+ <item value='any' label='{_("lima.any.criteria")}'/>
+ </JAXXComboBox>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <VBox id="criteriaWidgetPanel"
+ border='{BorderFactory.createTitledBorder(_("lima.search.title.criteria.box"))}'
+ />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="okButton" onActionPerformed="doSearch()" text="lima.common.ok"/>
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="windowClosing()"/>
+ </cell>
+ </row>
+ </Table>
+ </JScrollPane>
+</JFrame>
\ No newline at end of file
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,81 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 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.financialtransaction.table;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.util.EventObject;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JTable;
+import javax.swing.table.TableCellEditor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.ui.combobox.AccountComboBoxModel;
+import org.chorem.lima.ui.combobox.AccountRenderer;
+import org.chorem.lima.widgets.JWideComboBox;
+
+public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
+ private final JWideComboBox comboBox;
+ private static final long serialVersionUID = 2580476608066111095L;
+ private static AccountTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public AccountTableCellEditor() {
+ comboBox = new JWideComboBox();
+ AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel();
+ comboBox.setModel(accountComboBoxModel);
+ AccountRenderer accountRenderer = new AccountRenderer();
+ comboBox.setRenderer(accountRenderer);
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof Account){
+ comboBox.setSelectedItem((Account) value);
+
+ }
+ return comboBox;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return comboBox.getSelectedItem();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static AccountTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new AccountTableCellEditor();
+ }
+ return editor;
+ }
+
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,72 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 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.financialtransaction.table;
+
+import org.chorem.lima.LimaContext;
+import org.jdesktop.swingx.JXDatePicker;
+
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.util.Date;
+import java.util.EventObject;
+
+/**
+ * @author ore
+ */
+public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ private final JXDatePicker datePicker;
+ private static final long serialVersionUID = -8455896587828255307L;
+ private static DateTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public DateTableCellEditor() {
+ datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale());
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof Date) {
+ datePicker.setDate((Date) value);
+ }
+ return datePicker;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return datePicker.getDate();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static DateTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new DateTableCellEditor();
+ }
+ return editor;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,86 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 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.financialtransaction.table;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.util.EventObject;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JTable;
+import javax.swing.table.TableCellEditor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
+import org.chorem.lima.ui.combobox.EntryBookRenderer;
+import org.chorem.lima.widgets.JWideComboBox;
+
+public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
+ private final JWideComboBox comboBox;
+ private static final long serialVersionUID = 2580476608066111095L;
+ private static EntryBookTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public EntryBookTableCellEditor() {
+ comboBox = new JWideComboBox();
+ EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel();
+ comboBox.setModel(entryBookComboBoxModel);
+ EntryBookRenderer entryBookRenderer = new EntryBookRenderer();
+ comboBox.setRenderer(entryBookRenderer);
+
+ /*// Property Change Listener
+ LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
+ comboBox.setModel(comboBoxModel);
+ // AutoCompletion
+ AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());*/
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof EntryBook){
+ comboBox.setSelectedItem((EntryBook) value);
+
+ }
+ return comboBox;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return comboBox.getSelectedItem();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static EntryBookTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new EntryBookTableCellEditor();
+ }
+ return editor;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,200 @@
+/* *##% 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.financialtransaction.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.financialtransaction.FinancialTransactionHelper;
+import org.chorem.lima.ui.financialtransaction.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;
+
+
+/**
+ * Table des transaction qui ajoute des comportement (keys).
+ *
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class FinancialTransactionTable extends JXTable implements KeyListener {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
+
+ protected FinancialTransactionViewHandler handler;
+
+ private Highlighter colorTransaction;
+
+ private ColorHighlighter colorBalance;
+
+ /**
+ */
+ public FinancialTransactionTable(FinancialTransactionViewHandler handler) {
+
+ this.handler = handler;
+
+ addKeyListener(this);
+
+ //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();
+ }
+
+ /**
+ * 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 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.
+ * 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() {
+ if (colorBalance != null) {
+ removeHighlighter(colorBalance);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ boolean isHighlighted = false;
+ 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);
+ addHighlighter(colorTransaction);
+ }
+
+ /**
+ * for each action combination key are think
+ * for extend keyboard and laptop keyboard
+ */
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ // delete selected row with the key : delete or ctrl clear
+ // ou de l'entree
+ if ((e.getKeyCode() == KeyEvent.VK_DELETE )
+ || (e.getKeyCode() == KeyEvent.VK_CLEAR
+ && e.getModifiers() == KeyEvent.CTRL_MASK)){
+ handler.deleteSelectedRow();
+ }
+
+ // 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();
+ }
+
+ // 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 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 = 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) {
+ handler.addEmptyEntry();
+ // positionne la sélection sur la nouvelle ligne créée
+ this.setColumnSelectionInterval(0, 0);
+ this.setRowSelectionInterval(max_y + 1, max_y + 1);
+ }
+ }
+
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyReleased(KeyEvent e) {
+
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -0,0 +1,559 @@
+/* *##% 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.financialtransaction.table;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.lang.time.DateUtils;
+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;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+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;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionHelper;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * Basic transaction table model.
+ *
+ * Le modele est filtré sur {@link #selectedEntryBook} et
+ * {@link #selectedFinancialPeriod} (montée en charge !).
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision: 2897 $
+ *
+ * Last update : $Date: 2010-05-14 13:22:26 +0200 (ven. 14 mai 2010) $
+ * By : $Author: jpepin $
+ */
+public class FinancialTransactionTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3914954536809622358L;
+
+ /** log. */
+ private static final Log log = LogFactory
+ .getLog(FinancialTransactionTableModel.class);
+
+ /** Transaction service. */
+ protected final FinancialTransactionService transactionService;
+
+ /** EntryBook service. */
+ protected final EntryBookService entryBookService;
+
+ /** FinancialPeriod service. */
+ protected final FinancialPeriodService financialPeriodService;
+
+ /** selected financial period */
+ protected FinancialPeriod selectedFinancialPeriod;
+
+ /** data cache */
+ protected List<Object> cacheDataList;
+
+ /** collection
+
+
+ /**
+ * Model constructor.
+ *
+ * Just init service proxies.
+ */
+ public FinancialTransactionTableModel() {
+ /* Services */
+ // recordService = LimaServiceFactory.getInstance().getRecordService();
+ transactionService = LimaServiceFactory.getInstance()
+ .getTransactionService();
+ entryBookService = LimaServiceFactory.getInstance().
+ getEntryBookService();
+ financialPeriodService = LimaServiceFactory.getInstance().
+ getFinancialPeriodService();
+ }
+
+ /**
+ * Le model est une combinaison de Transaction/Entries.
+ *
+ *
+ * @return
+ */
+ protected List<Object> getDataList() {
+
+ List<Object> results = new ArrayList<Object>();
+ try {
+ List<FinancialTransaction> financialtransactions =
+ transactionService.getAllFinancialTransactionsForFinancialPeriod(
+ selectedFinancialPeriod);
+ for (FinancialTransaction financialtransaction : financialtransactions) {
+ results.add(financialtransaction);
+ results.addAll(financialtransaction.getEntry());
+ }
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ }
+
+ return results;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 9;
+ }
+
+ @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 = Account.class;
+ break;
+ case 4:
+ result = String.class;
+ break;
+ case 5:
+ result = String.class;
+ break;
+ case 6:
+ result = Double.class;
+ break;
+ case 7:
+ result = Double.class;
+ break;
+ case 8:
+ result = Double.class;
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String result = "n/a";
+
+ switch (column) {
+ case 0:
+ result = _("lima.transaction.column.date");
+ break;
+ case 1:
+ result = _("lima.transaction.column.entrybook");
+ break;
+ case 2:
+ result = _("lima.transaction.column.voucher");
+ break;
+ case 3:
+ result = _("lima.transaction.column.account");
+ break;
+ case 4:
+ result = _("lima.transaction.column.description");
+ break;
+ case 5:
+ result = _("lima.transaction.column.position");
+ break;
+ case 6:
+ result = _("lima.transaction.column.debit");
+ break;
+ case 7:
+ result = _("lima.transaction.column.credit");
+ break;
+ case 8:
+ result = _("lima.transaction.column.balance");
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ // just prevent too much result
+ if (selectedFinancialPeriod != null) {
+ //cacheDataList = getDataList();
+ result = cacheDataList.size();
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No fiscalPeriod selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ Object result = null;
+
+ // just prevent too much result
+ if (selectedFinancialPeriod != null) {
+ result = cacheDataList.get(row);
+
+ if (result instanceof FinancialTransaction) {
+ FinancialTransaction currentRow = (FinancialTransaction)result;
+
+ switch (column) {
+ case 0:
+ result = currentRow.getTransactionDate();
+ break;
+ case 1:
+ result = null; // voucher
+ break;
+ case 2:
+ result = null; //entrybook
+ break;
+ case 3:
+ result = null; // account
+ break;
+ case 4:
+ result = null; // description
+ break;
+ case 5 :
+ result = null; // position
+ break;
+ case 6:
+ result = FinancialTransactionHelper.getDebit(currentRow);
+ break;
+ case 7:
+ result = FinancialTransactionHelper.getCredit(currentRow);
+ break;
+ case 8:
+ result = FinancialTransactionHelper.getDebit(currentRow)
+ - FinancialTransactionHelper.getCredit(currentRow);
+ break;
+ }
+ }
+ else if (result instanceof Entry) {
+ Entry currentEntry = (Entry)result;
+ switch (column) {
+ case 0:
+ result = null; // date
+ break;
+ case 1 : // entry book
+ if (currentEntry.getEntryBook() != null){
+ result = currentEntry.getEntryBook().getCode();
+ }
+ else {
+ result = null;
+ }
+ break;
+ case 2:
+ result = currentEntry.getVoucher();
+ break;
+ case 3: // account
+ if (currentEntry.getAccount() != null){
+ result = currentEntry.getAccount().getAccountNumber();
+ }
+ else {
+ result = null;
+ }
+ break;
+ case 4:
+ result = currentEntry.getDescription();
+ break;
+ case 5 :
+ result = currentEntry.getPosition();
+ break;
+ case 6:
+ result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
+ break;
+ case 7:
+ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
+ break;
+ case 8:
+ result = null; // balance
+ break;
+ }
+
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No fiscalPeriod selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+
+ public void setFinancialPeriod(FinancialPeriod financialPeriod){
+
+ selectedFinancialPeriod = financialPeriod;
+ cacheDataList = getDataList();
+ fireTableDataChanged();
+ }
+
+ /**
+ * To set cells editable or not
+ * different condition for entry or financial transaction
+ */
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ boolean editableCell=false;
+ Object currentRow = cacheDataList.get(rowIndex);
+ // cells editable for the entry row, all cells exclude the date
+ if ((currentRow instanceof Entry) && !(columnIndex==0)) {
+ editableCell=true;
+ }
+ // cells editable for the financialtransaction row, no cells exclude the date
+ if ((currentRow instanceof FinancialTransaction) && (columnIndex==0)){
+ editableCell=true;
+ }
+ return editableCell;
+ }
+
+ /**
+ * @throws LimaException
+ */
+ public void addFinancialTransaction() throws LimaException{
+ /* Calling transaction service */
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ //if a period and an entrybook is selected
+ if (selectedFinancialPeriod != null){
+ financialTransaction.setFinancialPeriod(selectedFinancialPeriod);
+ // get today
+ Calendar actualCalendar = Calendar.getInstance();
+ // get the financial period date
+ Date transactionDate = selectedFinancialPeriod.getBeginDate();
+ // change the day
+ transactionDate = DateUtils.setDays(transactionDate,
+ actualCalendar.get(Calendar.DAY_OF_MONTH));
+ // set date to the financial transaction
+ financialTransaction.setTransactionDate(transactionDate);
+ // create it
+ transactionService.createFinancialTransaction(financialTransaction);
+ //on recharge la liste
+ cacheDataList = getDataList();
+ int row = getDataList().indexOf(financialTransaction);
+ fireTableRowsInserted(row, row);
+ //fireTableDataChanged();
+ }
+ else {
+ throw new LimaBusinessException("No financial period selected");
+ }
+ }
+
+
+
+ /**
+ * @throws LimaException
+ */
+ public void addEmptyEntry(Object value, int row) throws LimaException {
+ FinancialTransaction currentTransaction = null;
+ Object currentRow = cacheDataList.get(row);
+ Entry entry = new EntryImpl();
+ //check if current row is a transaction or an entry
+ if (currentRow instanceof FinancialTransaction) {
+ currentTransaction = (FinancialTransaction)currentRow;
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //get back the parent transaction of the entry
+ currentTransaction = currentEntry.getFinancialTransaction();
+ }
+ //create it
+ entry.setFinancialTransaction(currentTransaction);
+ transactionService.createEntry(entry);
+ //on recharge la liste
+ cacheDataList = getDataList();
+ fireTableDataChanged();
+ }
+
+ /**
+ * to modifiy financialtransaction or entry
+ */
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+
+ // just prevent too much result
+ if (selectedFinancialPeriod != null) {
+ Object currentRow = cacheDataList.get(row);
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentFinancialTransaction =
+ (FinancialTransaction)currentRow;
+ switch (column) {
+ case 0:
+ // 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
+ try {
+ transactionService.
+ updateFinancialTransaction(currentFinancialTransaction);
+ } catch (LimaException e) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't update financial transaction", e);
+ }
+ }
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ switch (column) {
+ case 1 :
+ currentEntry.setEntryBook((EntryBook)value);
+ break;
+ case 2 :
+ currentEntry.setVoucher((String)value);
+ break;
+ case 3:
+ currentEntry.setAccount((Account)value);
+ break;
+ case 4:
+ currentEntry.setDescription((String)value);
+ break;
+ case 5 :
+ currentEntry.setPosition((String)value);
+ break;
+ case 6:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(true);
+ break;
+ case 7:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(false);
+ break;
+ }
+ try {
+ transactionService.updateEntry(currentEntry);
+ } catch (LimaException e) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't update entry", e);
+ }
+ }
+ }
+ //update the financial transaction in entire
+ int financialTransactionRow =
+ getDataList().indexOf(((Entry) currentRow).
+ getFinancialTransaction());
+ //on recharge la liste
+ cacheDataList = getDataList();
+ fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No fiscalPeriod selected skip table model update");
+ }
+ }
+ }
+
+ public Object getElementAt(int row){
+
+ Object currentRow = cacheDataList.get(row);
+ return currentRow;
+ }
+
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @param Object, int
+ * @throws LimaException
+ */
+ public void removeObject(Object object, int row) throws LimaException {
+ Object currentRow = cacheDataList.get(row);
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentTransaction =
+ (FinancialTransaction)currentRow;
+ transactionService.removeFinancialTransaction(currentTransaction);
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ transactionService.removeEntry(currentEntry);
+ }
+ //on recharge la liste
+ cacheDataList = getDataList();
+ fireTableRowsDeleted(row, getRowCount());
+ }
+
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,41 +0,0 @@
-<!-- ##% Lima Swing
- Copyright (C) 2008 - 2010 CodeLutin
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- ##% -->
-
-<Table insets='5,5,5,5'>
- <script>
- protected void removeCriteriaWidget(){}
- </script>
- <row>
- <cell>
- <JAXXComboBox id="criteriaComboBox" width="200">
- <item value='date' label='{_("lima.date")}' selected="true"/>
- <item value='voucher' label='{_("lima.voucher")}'/>
- <item value='account' label='{_("lima.account")}'/>
- <item value='description' label='{_("lima.description")}'/>
- <item value='debit' label='{_("lima.debit")}'/>
- <item value='credit' label='{_("lima.credit")}'/>
- <item value='amount' label='{_("lima.amount")}'/>
- </JAXXComboBox>
- </cell>
- <cell weightx="0">
- <JPanel id="criteriaPanel"/>
- </cell>
- <cell>
- <JButton id="removeButton" text="lima.remove" onActionPerformed="removeCriteriaWidget()"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionHelper.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,84 +0,0 @@
-/* *##% Lima Main
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.transaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.ui.accountsreports.AccountsReportsTableModel;
-
-/**
- * TODO add comment here.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class FinancialTransactionHelper {
- /** log. */
- private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class);
-
- /**
- * Get total credit for a transaction.
- *
- * @param transaction transaction to get credit
- * @return total credit
- */
- public static double getCredit(FinancialTransaction financialtransaction) {
- double credit = 0;
- for (Entry entry : financialtransaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (!entry.getDebit()) {
- credit += entry.getAmount();
- }
- }
- return credit;
- }
-
- /**
- * Get total debit for a transaction.
- *
- * @param transaction transaction to get debit
- * @return total debit
- */
- public static double getDebit(FinancialTransaction financialtransaction) {
- double debit = 0;
- for (Entry entry : financialtransaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (entry.getDebit()) {
- debit += entry.getAmount();
- }
- }
- return debit;
- }
-
- /**
- * Return true if transaction is balanced (credit == debit).
- *
- * @param transaction transaction to test
- * @return {@code true} if transaction is balanced
- */
- public static boolean isBalanced(FinancialTransaction financialtransaction) {
- boolean balanced = getDebit(financialtransaction) == getCredit(financialtransaction);
- return balanced;
- }
-}
Deleted: 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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,90 +0,0 @@
-<!-- ##% Lima Swing
- Copyright (C) 2008 - 2010 CodeLutin
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- ##% -->
-
-<Table>
- <FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" />
- <Boolean id="selectedRow" javaBean="false" />
- <org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/>
- <script>
- <![CDATA[
-
- import org.chorem.lima.entity.FiscalPeriod;
- import org.chorem.lima.entity.FinancialPeriod;
-
- ]]>
- </script>
-
- <!-- <JPopupMenu id="MenuRightPanel">
- <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/>
- <JMenuItem text="lima.print"/>
- </JPopupMenu>
- <JPopupMenu id="MenuRightTransaction">
- <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/>
- <JMenuItem text="lima.print"/>
- </JPopupMenu> -->
-
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell>
- <JLabel id="fiscalPeriodLabel" text="lima.fiscalyear.management"/>
- </cell>
- <cell>
- <JComboBox id="fiscalPeriodComboBox"
- model="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel()}"
- renderer="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer()}"
- onItemStateChanged="getModelFinancialPeriod().setFiscalPeriod( (FiscalPeriod) event.getItem())"
- editable="false"/>
- </cell>
- <cell>
- <JLabel id="financialPeriodLabel" text="lima.transaction.period"
- />
- </cell>
- <cell>
- <JComboBox id="financialPeriodComboBox"
- model="{getModelFinancialPeriod()}"
- renderer="{new org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer()}"
- onItemStateChanged="getFinancialTransactionTableModel().setFinancialPeriod((FinancialPeriod) event.getItem())"
- editable="false"
- />
- </cell>
- <cell>
- <JButton text="lima.add.transaction"
- onActionPerformed="getHandler().addFinancialTransaction()"/>
- </cell>
- <cell>
- <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/>
- </cell>
- <cell>
- <JButton text="lima.common.remove"
- onActionPerformed="getHandler().deleteSelectedRow()"
- enabled="{isSelectedRow()}"/>
- </cell>
- </row>
- <row>
- <cell fill="both" weightx="1" weighty="1" rows="3" columns="7">
- <JScrollPane>
- <org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel
- id="financialTransactionTableModel" />
- <org.chorem.lima.ui.transaction.table.FinancialTransactionTable
- id="financialTransactionTable" sortable="false" rowHeight="22"
- constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}" />
- <javax.swing.ListSelectionModel javaBean="getFinancialTransactionTable().getSelectionModel()"
- onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/>
- </JScrollPane>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: 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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,149 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.transaction;
-
-import static org.nuiton.i18n.I18n._;
-
-
-import 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 financial transaction view.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class FinancialTransactionViewHandler {
-
- /** log. */
- private static final Log log =
- LogFactory.getLog(FinancialTransactionViewHandler.class);
-
- protected FinancialTransactionView view;
-
- protected FinancialTransactionViewHandler(FinancialTransactionView view) {
- this.view = view;
- }
-
- //add a new transaction
- public void addFinancialTransaction() {
- FinancialTransactionTable table =
- (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model =
- (FinancialTransactionTableModel)table.getModel();
-
- try {
- model.addFinancialTransaction();
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't add financialtransaction", ex);
- }
- JOptionPane.showMessageDialog(view,
- _("lima.warning.entrybookscloded"));
- }
- }
-
- //implement new transaction button
- //add a new entry to the selected transaction
- public void addEmptyEntry(){
-
- FinancialTransactionTable table =
- (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model =
- (FinancialTransactionTableModel)table.getModel();
-
- int indexSelectedRow = table.getSelectedRow();
- if (indexSelectedRow != -1) {
- Object selectedValue = model.getElementAt(indexSelectedRow);
- try {
- model.addEmptyEntry(selectedValue, indexSelectedRow);
- } catch (LimaException ex){
- if (log.isErrorEnabled()) {
- log.error("Can't add emptyentry", ex);
- }
- JOptionPane.showMessageDialog(view,
- _("lima.warning.entrybookscloded"));
- }
- }
- else {
- if (log.isWarnEnabled()) {
- log.warn("Call addentry selected transaction without selection");
- }
- }
- }
-
- /**
- * Delete selected row in table (could be transaction or entry).
- *
- * Called by model.
- * @throws LimaException
- */
- public void deleteSelectedRow(){
-
- FinancialTransactionTable table =
- (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model =
- (FinancialTransactionTableModel)table.getModel();
-
- int indexSelectedRow = table.getSelectedRow();
- if (indexSelectedRow != -1) {
-
- Object selectedValue = model.getElementAt(indexSelectedRow);
- String message = null;
- if (selectedValue instanceof FinancialTransaction) {
- message = _("lima.question.remove.transaction");
- }
- else {
- message = _("lima.question.remove.entry");
- }
-
- int response = JOptionPane.showConfirmDialog(view, message,
- _("lima.transaction.confirmdelete"), JOptionPane.YES_NO_OPTION);
-
- if (response == JOptionPane.YES_OPTION) {
-
- try {
- model.removeObject(selectedValue, indexSelectedRow);
- } catch (LimaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't remove transaction or entry", ex);
- }
- JOptionPane.showMessageDialog(view,
- _("lima.warning.entrybookscloded"));
- }
- }
- }
- else {
- if (log.isWarnEnabled()) {
- log.warn("Call delete selected row without selection");
- }
- }
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,122 +0,0 @@
-<!-- ##% Lima Swing
- Copyright (C) 2008 - 2010 CodeLutin
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- ##% -->
-
-<Table fill="both">
- <script>
- <![CDATA[
- import org.chorem.lima.entity.Account;
- import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
- import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
- // Swingx auto complete (for account) :
- AutoCompleteDecorator.decorate(accountComboBox, new ObjectToStringConverter() {
- @Override
- public String getPreferredStringForItem(Object item) {
- if (item == null) {
- return "";
- }
- Account account = (Account) item;
- return account.getAccountNumber() + " : " + account.getLabel();
- }
- });
-
- protected void addLettering() {
- // never been implemented :(
- };
- protected void removeLettering() {
- // never been implemented :(
- };
- ]]>
- </script>
- <row>
- <cell>
- <Table>
- <!-- account -->
- <row fill="horizontal" weightx="1" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.account"/>
- </cell>
- <cell>
- <org.chorem.lima.widgets.JWideComboBox id="accountComboBox"
- model="{new org.chorem.lima.ui.combobox.AccountComboBoxModel()}" />
- </cell>
- </row>
- <!-- from -->
- <row fill="horizontal" weightx="1" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.lettering.from"/>
- </cell>
- <cell>
- <org.chorem.lima.widgets.JWideComboBox id="fromPeriodComoboBox" />
- </cell>
- </row>
- <!-- to -->
- <row fill="horizontal" weightx="1" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.lettering.to"/>
- </cell>
- <cell>
- <org.chorem.lima.widgets.JWideComboBox id="toPeriodComoboBox" />
- </cell>
- </row>
- </Table>
- </cell>
- <cell>
- <!-- entries -->
- <Table fill="both">
- <row columns="3">
- <cell>
- <JLabel text="lima.lettering.entries"/>
- </cell>
- </row>
- <row>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettering.lettered'
- value='{_("lima.lettering.lettered")}' selected='true'/>
- </cell>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettering.notlettered'
- value='{_("lima.lettering.notlettered")}'/>
- </cell>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettering.letteredall'
- value='{_("lima.lettering.letteredall")}'/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row columns="2" weightx="1" weighty="1" anchor="center" fill="both">
- <cell>
- <JScrollPane>
- <org.jdesktop.swingx.JXTable id="letteringTable" />
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell>
- <!-- add lettering -->
- <JButton id="addButton" text="lima.lettering.add"
- onActionPerformed="addLettering()"/>
- </cell>
- <cell>
- <!-- remove lettering -->
- <JButton id="removeButton" text="lima.lettering.remove"
- onActionPerformed="removeLettering()"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,14 +0,0 @@
-package org.chorem.lima.ui.transaction;
-
-public class SearchFinancialTransactionViewHandler {
-
-
- protected void addCriteriaWidget() {
-
- }
-
- protected void doSearch() {
-
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,60 +0,0 @@
-<!-- ##% Lima Swing
- Copyright (C) 2008 - 2010 CodeLutin
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- ##% -->
-
-<JFrame title="lima.search" width="620" height="300" locationRelativeTo="{null}"
- onWindowClosing="windowClosing()"
- defaultCloseOperation="do_nothing_on_close"
- iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
- <script>
- protected void addCriteriaWidget() {};
- protected void doSearch() {};
- protected void windowClosing() {};
- </script>
- <JScrollPane>
- <Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1">
- <row>
- <cell>
- <JButton id="addButton" text="lima.common.add" width="100" onActionPerformed="addCriteriaWidget()"/>
- </cell>
- <cell>
- <JLabel text="lima.search.items.where" width="200"/>
- </cell>
- <cell>
- <JAXXComboBox id="criteriaAllAnyComboBox" width="200">
- <item value='all' label='{_("lima.all.criteria")}' selected="true"/>
- <item value='any' label='{_("lima.any.criteria")}'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell columns="3">
- <VBox id="criteriaWidgetPanel"
- border='{BorderFactory.createTitledBorder(_("lima.search.title.criteria.box"))}'
- />
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" onActionPerformed="doSearch()" text="lima.common.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="windowClosing()"/>
- </cell>
- </row>
- </Table>
- </JScrollPane>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,81 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.transaction.table;
-
-import java.awt.Component;
-import java.awt.event.MouseEvent;
-import java.util.EventObject;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.table.TableCellEditor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.ui.combobox.AccountComboBoxModel;
-import org.chorem.lima.ui.combobox.AccountRenderer;
-import org.chorem.lima.widgets.JWideComboBox;
-
-public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
- private final JWideComboBox comboBox;
- private static final long serialVersionUID = 2580476608066111095L;
- private static AccountTableCellEditor editor;
-
- /**
- * constructor
- */
- public AccountTableCellEditor() {
- comboBox = new JWideComboBox();
- AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel();
- comboBox.setModel(accountComboBoxModel);
- AccountRenderer accountRenderer = new AccountRenderer();
- comboBox.setRenderer(accountRenderer);
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (value instanceof Account){
- comboBox.setSelectedItem((Account) value);
-
- }
- return comboBox;
- }
-
- @Override
- public Object getCellEditorValue() {
- return comboBox.getSelectedItem();
- }
-
- @Override
- public boolean isCellEditable(EventObject evt) {
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
-
- public static AccountTableCellEditor getInstance() {
- if (editor == null) {
- editor = new AccountTableCellEditor();
- }
- return editor;
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,72 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.transaction.table;
-
-import org.chorem.lima.LimaContext;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.*;
-import javax.swing.table.TableCellEditor;
-import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.util.Date;
-import java.util.EventObject;
-
-/**
- * @author ore
- */
-public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- private final JXDatePicker datePicker;
- private static final long serialVersionUID = -8455896587828255307L;
- private static DateTableCellEditor editor;
-
- /**
- * constructor
- */
- public DateTableCellEditor() {
- datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale());
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (value instanceof Date) {
- datePicker.setDate((Date) value);
- }
- return datePicker;
- }
-
- @Override
- public Object getCellEditorValue() {
- return datePicker.getDate();
- }
-
- @Override
- public boolean isCellEditable(EventObject evt) {
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
-
- public static DateTableCellEditor getInstance() {
- if (editor == null) {
- editor = new DateTableCellEditor();
- }
- return editor;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,86 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.transaction.table;
-
-import java.awt.Component;
-import java.awt.event.MouseEvent;
-import java.util.EventObject;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.table.TableCellEditor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
-import org.chorem.lima.ui.combobox.EntryBookRenderer;
-import org.chorem.lima.widgets.JWideComboBox;
-
-public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
- private final JWideComboBox comboBox;
- private static final long serialVersionUID = 2580476608066111095L;
- private static EntryBookTableCellEditor editor;
-
- /**
- * constructor
- */
- public EntryBookTableCellEditor() {
- comboBox = new JWideComboBox();
- EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel();
- comboBox.setModel(entryBookComboBoxModel);
- EntryBookRenderer entryBookRenderer = new EntryBookRenderer();
- comboBox.setRenderer(entryBookRenderer);
-
- /*// Property Change Listener
- LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
- comboBox.setModel(comboBoxModel);
- // AutoCompletion
- AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());*/
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (value instanceof EntryBook){
- comboBox.setSelectedItem((EntryBook) value);
-
- }
- return comboBox;
- }
-
- @Override
- public Object getCellEditorValue() {
- return comboBox.getSelectedItem();
- }
-
- @Override
- public boolean isCellEditable(EventObject evt) {
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
-
- public static EntryBookTableCellEditor getInstance() {
- if (editor == null) {
- editor = new EntryBookTableCellEditor();
- }
- return editor;
- }
-}
Deleted: 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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,200 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.transaction.table;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.util.Date;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.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;
-
-
-/**
- * Table des transaction qui ajoute des comportement (keys).
- *
- * @author ore
- * @author Rémi Chapelet
- */
-public class FinancialTransactionTable extends JXTable implements KeyListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3133690382049594727L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
-
- protected FinancialTransactionViewHandler handler;
-
- private Highlighter colorTransaction;
-
- private ColorHighlighter colorBalance;
-
- /**
- */
- public FinancialTransactionTable(FinancialTransactionViewHandler handler) {
-
- this.handler = handler;
-
- addKeyListener(this);
-
- //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();
- }
-
- /**
- * 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 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.
- * 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() {
- if (colorBalance != null) {
- removeHighlighter(colorBalance);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- boolean isHighlighted = false;
- 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);
- addHighlighter(colorTransaction);
- }
-
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
-
- // delete selected row with the key : delete or ctrl clear
- // ou de l'entree
- if ((e.getKeyCode() == KeyEvent.VK_DELETE )
- || (e.getKeyCode() == KeyEvent.VK_CLEAR
- && e.getModifiers() == KeyEvent.CTRL_MASK)){
- handler.deleteSelectedRow();
- }
-
- // 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();
- }
-
- // 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 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 = 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) {
- handler.addEmptyEntry();
- // positionne la sélection sur la nouvelle ligne créée
- this.setColumnSelectionInterval(0, 0);
- this.setRowSelectionInterval(max_y + 1, max_y + 1);
- }
- }
-
- }
-
- /*
- * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
- */
- @Override
- public void keyTyped(KeyEvent e) {
-
- }
-
- /*
- * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
- */
- @Override
- public void keyReleased(KeyEvent e) {
-
- }
-}
Deleted: 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-17 09:08:42 UTC (rev 2900)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-19 10:52:43 UTC (rev 2901)
@@ -1,559 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.transaction.table;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
-import org.apache.commons.lang.time.DateUtils;
-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;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-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;
-import org.chorem.lima.ui.transaction.FinancialTransactionHelper;
-import org.chorem.lima.util.ErrorHelper;
-
-/**
- * Basic transaction table model.
- *
- * Le modele est filtré sur {@link #selectedEntryBook} et
- * {@link #selectedFinancialPeriod} (montée en charge !).
- *
- * @author ore
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class FinancialTransactionTableModel extends AbstractTableModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3914954536809622358L;
-
- /** log. */
- private static final Log log = LogFactory
- .getLog(FinancialTransactionTableModel.class);
-
- /** Transaction service. */
- protected final FinancialTransactionService transactionService;
-
- /** EntryBook service. */
- protected final EntryBookService entryBookService;
-
- /** FinancialPeriod service. */
- protected final FinancialPeriodService financialPeriodService;
-
- /** selected financial period */
- protected FinancialPeriod selectedFinancialPeriod;
-
- /** data cache */
- protected List<Object> cacheDataList;
-
- /** collection
-
-
- /**
- * Model constructor.
- *
- * Just init service proxies.
- */
- public FinancialTransactionTableModel() {
- /* Services */
- // recordService = LimaServiceFactory.getInstance().getRecordService();
- transactionService = LimaServiceFactory.getInstance()
- .getTransactionService();
- entryBookService = LimaServiceFactory.getInstance().
- getEntryBookService();
- financialPeriodService = LimaServiceFactory.getInstance().
- getFinancialPeriodService();
- }
-
- /**
- * Le model est une combinaison de Transaction/Entries.
- *
- *
- * @return
- */
- protected List<Object> getDataList() {
-
- List<Object> results = new ArrayList<Object>();
- try {
- List<FinancialTransaction> financialtransactions =
- transactionService.getAllFinancialTransactionsForFinancialPeriod(
- selectedFinancialPeriod);
- for (FinancialTransaction financialtransaction : financialtransactions) {
- results.add(financialtransaction);
- results.addAll(financialtransaction.getEntry());
- }
- }
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
- }
-
- ErrorHelper.showErrorDialog("Can't get transaction list", eee);
- }
-
- return results;
- }
-
- @Override
- public int getColumnCount() {
- return 9;
- }
-
- @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 = Account.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = String.class;
- break;
- case 6:
- result = Double.class;
- break;
- case 7:
- result = Double.class;
- break;
- case 8:
- result = Double.class;
- break;
- }
-
- return result;
- }
-
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
-
- switch (column) {
- case 0:
- result = _("lima.transaction.column.date");
- break;
- case 1:
- result = _("lima.transaction.column.entrybook");
- break;
- case 2:
- result = _("lima.transaction.column.voucher");
- break;
- case 3:
- result = _("lima.transaction.column.account");
- break;
- case 4:
- result = _("lima.transaction.column.description");
- break;
- case 5:
- result = _("lima.transaction.column.position");
- break;
- case 6:
- result = _("lima.transaction.column.debit");
- break;
- case 7:
- result = _("lima.transaction.column.credit");
- break;
- case 8:
- result = _("lima.transaction.column.balance");
- break;
- }
-
- return result;
- }
-
- @Override
- public int getRowCount() {
- int result = 0;
-
- // just prevent too much result
- if (selectedFinancialPeriod != null) {
- //cacheDataList = getDataList();
- result = cacheDataList.size();
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No fiscalPeriod selected skip table model update");
- }
- }
-
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
-
- // just prevent too much result
- if (selectedFinancialPeriod != null) {
- result = cacheDataList.get(row);
-
- if (result instanceof FinancialTransaction) {
- FinancialTransaction currentRow = (FinancialTransaction)result;
-
- switch (column) {
- case 0:
- result = currentRow.getTransactionDate();
- break;
- case 1:
- result = null; // voucher
- break;
- case 2:
- result = null; //entrybook
- break;
- case 3:
- result = null; // account
- break;
- case 4:
- result = null; // description
- break;
- case 5 :
- result = null; // position
- break;
- case 6:
- result = FinancialTransactionHelper.getDebit(currentRow);
- break;
- case 7:
- result = FinancialTransactionHelper.getCredit(currentRow);
- break;
- case 8:
- result = FinancialTransactionHelper.getDebit(currentRow)
- - FinancialTransactionHelper.getCredit(currentRow);
- break;
- }
- }
- else if (result instanceof Entry) {
- Entry currentEntry = (Entry)result;
- switch (column) {
- case 0:
- result = null; // date
- break;
- case 1 : // entry book
- if (currentEntry.getEntryBook() != null){
- result = currentEntry.getEntryBook().getCode();
- }
- else {
- result = null;
- }
- break;
- case 2:
- result = currentEntry.getVoucher();
- break;
- case 3: // account
- if (currentEntry.getAccount() != null){
- result = currentEntry.getAccount().getAccountNumber();
- }
- else {
- result = null;
- }
- break;
- case 4:
- result = currentEntry.getDescription();
- break;
- case 5 :
- result = currentEntry.getPosition();
- break;
- case 6:
- result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
- break;
- case 7:
- result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
- break;
- case 8:
- result = null; // balance
- break;
- }
-
- }
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No fiscalPeriod selected skip table model update");
- }
- }
-
- return result;
- }
-
-
- public void setFinancialPeriod(FinancialPeriod financialPeriod){
-
- selectedFinancialPeriod = financialPeriod;
- cacheDataList = getDataList();
- fireTableDataChanged();
- }
-
- /**
- * To set cells editable or not
- * different condition for entry or financial transaction
- */
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- boolean editableCell=false;
- Object currentRow = cacheDataList.get(rowIndex);
- // cells editable for the entry row, all cells exclude the date
- if ((currentRow instanceof Entry) && !(columnIndex==0)) {
- editableCell=true;
- }
- // cells editable for the financialtransaction row, no cells exclude the date
- if ((currentRow instanceof FinancialTransaction) && (columnIndex==0)){
- editableCell=true;
- }
- return editableCell;
- }
-
- /**
- * @throws LimaException
- */
- public void addFinancialTransaction() throws LimaException{
- /* Calling transaction service */
- FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- //if a period and an entrybook is selected
- if (selectedFinancialPeriod != null){
- financialTransaction.setFinancialPeriod(selectedFinancialPeriod);
- // get today
- Calendar actualCalendar = Calendar.getInstance();
- // get the financial period date
- Date transactionDate = selectedFinancialPeriod.getBeginDate();
- // change the day
- transactionDate = DateUtils.setDays(transactionDate,
- actualCalendar.get(Calendar.DAY_OF_MONTH));
- // set date to the financial transaction
- financialTransaction.setTransactionDate(transactionDate);
- // create it
- transactionService.createFinancialTransaction(financialTransaction);
- //on recharge la liste
- cacheDataList = getDataList();
- int row = getDataList().indexOf(financialTransaction);
- fireTableRowsInserted(row, row);
- //fireTableDataChanged();
- }
- else {
- throw new LimaBusinessException("No financial period selected");
- }
- }
-
-
-
- /**
- * @throws LimaException
- */
- public void addEmptyEntry(Object value, int row) throws LimaException {
- FinancialTransaction currentTransaction = null;
- Object currentRow = cacheDataList.get(row);
- Entry entry = new EntryImpl();
- //check if current row is a transaction or an entry
- if (currentRow instanceof FinancialTransaction) {
- currentTransaction = (FinancialTransaction)currentRow;
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- //get back the parent transaction of the entry
- currentTransaction = currentEntry.getFinancialTransaction();
- }
- //create it
- entry.setFinancialTransaction(currentTransaction);
- transactionService.createEntry(entry);
- //on recharge la liste
- cacheDataList = getDataList();
- fireTableDataChanged();
- }
-
- /**
- * to modifiy financialtransaction or entry
- */
- @Override
- public void setValueAt(Object value, int row, int column) {
-
- // just prevent too much result
- if (selectedFinancialPeriod != null) {
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentFinancialTransaction =
- (FinancialTransaction)currentRow;
- switch (column) {
- case 0:
- // 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
- try {
- transactionService.
- updateFinancialTransaction(currentFinancialTransaction);
- } catch (LimaException e) {
- if (log.isDebugEnabled()){
- log.debug("Can't update financial transaction", e);
- }
- }
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- switch (column) {
- case 1 :
- currentEntry.setEntryBook((EntryBook)value);
- break;
- case 2 :
- currentEntry.setVoucher((String)value);
- break;
- case 3:
- currentEntry.setAccount((Account)value);
- break;
- case 4:
- currentEntry.setDescription((String)value);
- break;
- case 5 :
- currentEntry.setPosition((String)value);
- break;
- case 6:
- currentEntry.setAmount((Double)value);
- currentEntry.setDebit(true);
- break;
- case 7:
- currentEntry.setAmount((Double)value);
- currentEntry.setDebit(false);
- break;
- }
- try {
- transactionService.updateEntry(currentEntry);
- } catch (LimaException e) {
- if (log.isDebugEnabled()){
- log.debug("Can't update entry", e);
- }
- }
- }
- //update the financial transaction in entire
- int financialTransactionRow =
- getDataList().indexOf(((Entry) currentRow).
- getFinancialTransaction());
- //on recharge la liste
- cacheDataList = getDataList();
- fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No fiscalPeriod selected skip table model update");
- }
- }
- }
-
- public Object getElementAt(int row){
-
- Object currentRow = cacheDataList.get(row);
- return currentRow;
- }
-
-
- /**
- * Delete selected row in table (could be transaction or entry).
- *
- * Called by model.
- * @param Object, int
- * @throws LimaException
- */
- public void removeObject(Object object, int row) throws LimaException {
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentTransaction =
- (FinancialTransaction)currentRow;
- transactionService.removeFinancialTransaction(currentTransaction);
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- transactionService.removeEntry(currentEntry);
- }
- //on recharge la liste
- cacheDataList = getDataList();
- fireTableRowsDeleted(row, getRowCount());
- }
-
-}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-17 09:08:42 UTC (rev 2900)
+++ trunk/pom.xml 2010-05-19 10:52:43 UTC (rev 2901)
@@ -241,8 +241,8 @@
<!-- customized libs version -->
<nuiton-utils.version>1.2.2</nuiton-utils.version>
- <eugene.version>2.0.1</eugene.version>
- <topia.version>2.3.3</topia.version>
+ <eugene.version>2.0.2-SNAPSHOT</eugene.version>
+ <topia.version>2.4-SNAPSHOT</topia.version>
<jaxx.version>2.0.1</jaxx.version>
<i18n.version>1.2.2</i18n.version>
1
0
r2900 - 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/financialperiod
by jpepin@users.chorem.org 17 May '10
by jpepin@users.chorem.org 17 May '10
17 May '10
Author: jpepin
Date: 2010-05-17 11:08:42 +0200 (Mon, 17 May 2010)
New Revision: 2900
Url: http://chorem.org/repositories/revision/lima/2900
Log:
Tri des journaux/p?\195?\169riodes par date. Requ?\195?\170te journaux/p?\195?\169riodes des p?\195?\169riodes ficales ouvertes
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
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-14 13:46:33 UTC (rev 2899)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-17 09:08:42 UTC (rev 2900)
@@ -48,7 +48,7 @@
/** Methodes for closedperiodicentrybook */
- List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooks() throws LimaException;
+ List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException;
ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook,
FinancialPeriod financialPeriod) throws LimaException;
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-14 13:46:33 UTC (rev 2899)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-17 09:08:42 UTC (rev 2900)
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FinancialPeriodService;
+import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
@@ -33,17 +34,21 @@
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
+import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FiscalPeriod;
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;
+import org.nuiton.topia.framework.TopiaQuery.Op;
/**
@@ -266,20 +271,26 @@
}
@Override
- public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooks() throws LimaException {
+ public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws LimaException {
- List<ClosedPeriodicEntryBook> result = null;
+ List<ClosedPeriodicEntryBook> result = new ArrayList<ClosedPeriodicEntryBook>();
TopiaContext transaction = null;
try {
// basic check done, make check in database
// TODO move it into JTA
transaction = rootContext.beginTransaction();
-
+
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO
= LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
- result = closedPeriodicEntryBookDAO.findAll();
+ TopiaQuery query = closedPeriodicEntryBookDAO.createQuery();
+ String closedPeriodicEntryBookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.FISCAL_PERIOD, FiscalPeriod.LOCKED);
+ query.add(closedPeriodicEntryBookProperty, Boolean.FALSE);
+
+ result = closedPeriodicEntryBookDAO.findAllByQuery(query);
+ log.debug(result);
+
// FOR NO LAZY EXCEPTION
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : result) {
closedPeriodicEntryBook.getEntryBook().getLabel();
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/ClosedPeriodicEntryBookComparator.java 2010-05-17 09:08:42 UTC (rev 2900)
@@ -0,0 +1,40 @@
+/* *##% 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.financialperiod;
+
+import java.util.Comparator;
+
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+
+public class ClosedPeriodicEntryBookComparator implements Comparator<ClosedPeriodicEntryBook>{
+
+ @Override
+ public int compare(ClosedPeriodicEntryBook o1, ClosedPeriodicEntryBook o2) {
+
+ if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == -1) {
+ return -1;
+ } else if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == 1) {
+ return 1;
+ } else {
+ return 0;
+ }
+
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-14 13:46:33 UTC (rev 2899)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-17 09:08:42 UTC (rev 2900)
@@ -1,3 +1,21 @@
+/* *##% 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.financialperiod;
import java.awt.Color;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-14 13:46:33 UTC (rev 2899)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-17 09:08:42 UTC (rev 2900)
@@ -22,12 +22,12 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.exception.Nestable;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.EntryBookService;
@@ -35,12 +35,8 @@
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.util.ErrorHelper;
/**
* TODO add comment here.
@@ -181,12 +177,13 @@
public void getDataList(){
List<ClosedPeriodicEntryBook> results = new ArrayList<ClosedPeriodicEntryBook>();
try {
- results = financialPeriodService.getAllClosedPeriodicEntryBooks();
+ results = financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
} catch (LimaException eee){
if (log.isDebugEnabled()){
log.debug("Can't get closedperiodicentrybook list", eee );
}
}
+ Collections.sort(results, new ClosedPeriodicEntryBookComparator());
cacheDataList=results;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-14 13:46:33 UTC (rev 2899)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-17 09:08:42 UTC (rev 2900)
@@ -27,8 +27,6 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
import org.chorem.lima.util.ErrorHelper;
/**
1
0
r2899 - 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/financialperiod lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model
by jpepin@users.chorem.org 14 May '10
by jpepin@users.chorem.org 14 May '10
14 May '10
Author: jpepin
Date: 2010-05-14 15:46:33 +0200 (Fri, 14 May 2010)
New Revision: 2899
Url: http://chorem.org/repositories/revision/lima/2899
Log:
Nettoyage du code, suppression d'une classe inutile.
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodEntryBook.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java
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-14 12:45:50 UTC (rev 2898)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-14 13:46:33 UTC (rev 2899)
@@ -48,6 +48,8 @@
/** Methodes for closedperiodicentrybook */
+ List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooks() throws LimaException;
+
ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook,
FinancialPeriod financialPeriod) throws LimaException;
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-14 12:45:50 UTC (rev 2898)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-14 13:46:33 UTC (rev 2899)
@@ -264,6 +264,40 @@
}
}
+
+ @Override
+ public List<ClosedPeriodicEntryBook> getAllClosedPeriodicEntryBooks() throws LimaException {
+
+ List<ClosedPeriodicEntryBook> result = null;
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO
+ = LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
+ result = closedPeriodicEntryBookDAO.findAll();
+
+ // FOR NO LAZY EXCEPTION
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : result) {
+ closedPeriodicEntryBook.getEntryBook().getLabel();
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate();
+ }
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ return result;
+ }
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodEntryBook.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodEntryBook.java 2010-05-14 12:45:50 UTC (rev 2898)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodEntryBook.java 2010-05-14 13:46:33 UTC (rev 2899)
@@ -1,32 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.financialperiod;
-
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialPeriod;
-
-/** Object to encapsulate entrybook and financialperiod */
-public class FinancialPeriodEntryBook{
- FinancialPeriod financialPeriod;
- EntryBook entryBook;
- FinancialPeriodEntryBook(FinancialPeriod financialPeriod, EntryBook entryBook){
- this.financialPeriod=financialPeriod;
- this.entryBook=entryBook;
- }
-}
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-14 12:45:50 UTC (rev 2898)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-14 13:46:33 UTC (rev 2899)
@@ -45,11 +45,13 @@
@Override
public boolean isHighlighted(Component renderer,
ComponentAdapter adapter) {
- FinancialPeriodEntryBook financialPeriodEntryBook
- = (FinancialPeriodEntryBook) model.getElementAt(adapter.row);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook
+ = (ClosedPeriodicEntryBook) model.getElementAt(adapter.row);
+ // FinancialPeriodEntryBook financialPeriodEntryBook
+ // = (FinancialPeriodEntryBook) model.getElementAt(adapter.row);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM");
int month = Integer.parseInt(simpleDateFormat.format(
- financialPeriodEntryBook.financialPeriod.getBeginDate()));
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate()));
// true if month is even
return ((month % 2)==0);
@@ -65,11 +67,11 @@
@Override
public boolean isHighlighted(Component renderer,
ComponentAdapter adapter) {
- FinancialPeriodEntryBook financialPeriodEntryBook = (FinancialPeriodEntryBook) model.getElementAt(adapter.row);
ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl();
+ ClosedPeriodicEntryBook selectedClosedPeriodicEntryBook = (ClosedPeriodicEntryBook) model.getElementAt(adapter.row);
// true if locked
try {
- closedPeriodicEntryBook = financialPeriodService.getClosedPeriodicEntryBook(financialPeriodEntryBook.entryBook, financialPeriodEntryBook.financialPeriod);
+ closedPeriodicEntryBook = financialPeriodService.getClosedPeriodicEntryBook(selectedClosedPeriodicEntryBook.getEntryBook(), selectedClosedPeriodicEntryBook.getFinancialPeriod());
} catch (LimaException eee) {
log.debug("Can't get closePeriodicEntryBook",eee);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-14 12:45:50 UTC (rev 2898)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-14 13:46:33 UTC (rev 2899)
@@ -64,7 +64,8 @@
protected FinancialPeriodService financialPeriodService;
/** Datas cache */
- protected List<FinancialPeriodEntryBook> cacheDataList;
+ //protected List<FinancialPeriodEntryBook> cacheDataList;
+ protected List<ClosedPeriodicEntryBook> cacheDataList;
public FinancialPeriodTableModel() {
fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
@@ -129,7 +130,7 @@
return false;
}
- public FinancialPeriodEntryBook getFinancialPeriodAtRow(int row) throws LimaException {
+ public ClosedPeriodicEntryBook getFinancialPeriodAtRow(int row) throws LimaException {
return cacheDataList.get(row);
}
@@ -147,14 +148,11 @@
public Object getValueAt(int rowIndex, int columnIndex) {
Object result = null;
- try {
- FinancialPeriodEntryBook financialPeriodEntryBook
+ ClosedPeriodicEntryBook closedPeriodicEntryBook
= cacheDataList.get(rowIndex);
- if (financialPeriodEntryBook != null){
- FinancialPeriod financialPeriod
- = financialPeriodEntryBook.financialPeriod;
- EntryBook entryBook = financialPeriodEntryBook.entryBook;
+ if (closedPeriodicEntryBook != null){
+ EntryBook entryBook = closedPeriodicEntryBook.getEntryBook();
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat("MMMMM yyyy");
@@ -162,13 +160,13 @@
switch (columnIndex) {
case 0:
result = StringUtils.capitalize(simpleDateFormat.
- format(financialPeriod.getBeginDate()));
+ format(closedPeriodicEntryBook.getFinancialPeriod().getBeginDate()));
break;
case 1:
result = entryBook.getCode()+" - "+entryBook.getLabel();
break;
case 2:
- if(financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod).getLocked()){
+ if(closedPeriodicEntryBook.getLocked()){
result = _("lima.close");
}
else{
@@ -177,56 +175,26 @@
break;
}
}
- }
- catch (LimaException eee){
- if (log.isDebugEnabled()){
- log.debug("Can't get value at row", eee );
- }
- }
return result;
}
public void getDataList(){
-
- List<FinancialPeriodEntryBook> results
- = new ArrayList<FinancialPeriodEntryBook>();
- List<FinancialPeriod> periods = new ArrayList<FinancialPeriod>();
- List<EntryBook> entrybooks = new ArrayList<EntryBook>();
-
+ List<ClosedPeriodicEntryBook> results = new ArrayList<ClosedPeriodicEntryBook>();
try {
- // get all fiscal period unblocked
- List<FiscalPeriod> fiscalPeriods
- = fiscalPeriodService.getAllUnblockedFiscalPeriods();
- for (FiscalPeriod fiscalPeriod : fiscalPeriods) {
- // get all financial period from unblocked fiscal period
- periods.addAll(fiscalPeriod.getFinancialPeriod());
+ results = financialPeriodService.getAllClosedPeriodicEntryBooks();
+ } catch (LimaException eee){
+ if (log.isDebugEnabled()){
+ log.debug("Can't get closedperiodicentrybook list", eee );
}
- // get all entrybook
- entrybooks = entryBookService.getAllEntryBooks();
- // build the list with entrybook and financial period
- for (FinancialPeriod period : periods) {
- for (EntryBook entryB : entrybooks){
- FinancialPeriodEntryBook financialPeriodEntryBook
- = new FinancialPeriodEntryBook(period, entryB);
- results.add(financialPeriodEntryBook);
- }
- }
-
}
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
- }
- ErrorHelper.showErrorDialog("Can't get entrybook and financial period list");
- }
cacheDataList=results;
}
- public void blockFinancialPeriod(FinancialPeriodEntryBook financialPeriodEntryBook) throws LimaException {
- ClosedPeriodicEntryBook closedPeriodicEntryBook =
- financialPeriodService.getClosedPeriodicEntryBook(
+ public void blockFinancialPeriod(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException {
+ /* ClosedPeriodicEntryBook closedPeriodicEntryBook =
+ financialPeriodService.getClosedPeriodicEntryBook(
financialPeriodEntryBook.entryBook,
- financialPeriodEntryBook.financialPeriod);
+ financialPeriodEntryBook.financialPeriod);*/
financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
fireTableDataChanged();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-14 12:45:50 UTC (rev 2898)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-14 13:46:33 UTC (rev 2899)
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
import org.chorem.lima.util.ErrorHelper;
@@ -56,12 +57,12 @@
// blocked it
try {
- FinancialPeriodEntryBook selectedFinancialPeriodEntryBook = model.getFinancialPeriodAtRow(selectedRow);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = model.getFinancialPeriodAtRow(selectedRow);
int response = JOptionPane.showConfirmDialog(view, _("lima.question.financialperiod.blocked"),
_("lima.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
- model.blockFinancialPeriod(selectedFinancialPeriodEntryBook);
+ model.blockFinancialPeriod(closedPeriodicEntryBook);
}
} catch (LimaException ex) {
if (log.isErrorEnabled()) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java 2010-05-14 12:45:50 UTC (rev 2898)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java 2010-05-14 13:46:33 UTC (rev 2899)
@@ -20,20 +20,13 @@
import java.awt.Color;
import java.awt.Component;
-import java.text.SimpleDateFormat;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.FiscalPeriodService;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodEntryBook;
import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodViewHandler;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodViewHandler;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
1
0