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
July 2010
- 3 participants
- 34 discussions
15 Jul '10
Author: jpepin
Date: 2010-07-15 11:47:22 +0200 (Thu, 15 Jul 2010)
New Revision: 2969
Url: http://chorem.org/repositories/revision/lima/2969
Log:
Debug import entries EBP + import accounts chart EBP.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountEBPComparator.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionServiceLocal.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.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/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionServiceLocal.java 2010-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionServiceLocal.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -20,11 +20,8 @@
package org.chorem.lima.business;
import java.util.List;
-
import javax.ejb.Local;
-
import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.entity.FiscalPeriod;
import org.nuiton.topia.TopiaContext;
/**
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java 2010-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -41,7 +41,9 @@
* @param data
* @throws LimaException
*/
- public String importAsEbpCSV(String datas) throws LimaException;
+ public String importEntriesFromEbp(String datas) throws LimaException;
+ public String importAccountsChartFromEbp(String datas) throws LimaException;
+
/**
* Import data as Sage Maestria export.
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-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -153,7 +153,7 @@
*/
@Override
public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction, TopiaContext topiaContext) throws LimaException {
- //check financial period locked
+ //check financial period locked
if (financialTransaction.getFinancialPeriod().getLocked()){
throw new LimaBusinessException("The financial period is blocked");
}
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-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -87,7 +87,7 @@
EntryBookDAO entryBookDAO =
LimaCallaoDAOHelper.getEntryBookDAO(transaction);
EntryBook existingEntryBook =
- entryBookDAO.findByLabel(entryBook.getLabel());
+ entryBookDAO.findByLabel(entryBook.getCode());
if (existingEntryBook != null) {
throw new LimaBusinessException(
_("An EntryBook already exists with this label : %s",
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -33,14 +33,18 @@
import java.util.TreeMap;
import javax.ejb.EJB;
import javax.ejb.Stateless;
+
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.AccountEBP;
+import org.chorem.lima.beans.AccountEBPImpl;
import org.chorem.lima.beans.AccountImport;
import org.chorem.lima.beans.AccountImportImpl;
import org.chorem.lima.beans.ClosedPeriodicEntryBookImport;
import org.chorem.lima.beans.ClosedPeriodicEntryBookImportImpl;
-import org.chorem.lima.beans.EntriesEBP;
-import org.chorem.lima.beans.EntriesEBPImpl;
+import org.chorem.lima.beans.EntryEBP;
+import org.chorem.lima.beans.EntryEBPImpl;
import org.chorem.lima.beans.EntryImport;
import org.chorem.lima.beans.EntryImportImpl;
import org.chorem.lima.beans.FinancialStatementImport;
@@ -58,6 +62,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.AccountEBPComparator;
import org.chorem.lima.business.utils.FiscalPeriodComparator;
import org.chorem.lima.business.utils.ImportExportEntityEnum;
import org.chorem.lima.entity.Account;
@@ -145,7 +150,7 @@
//################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
@Override
- public String importAsEbpCSV(String datas) throws LimaException {
+ public String importEntriesFromEbp(String datas) throws LimaException {
SimpleDateFormat epbDateFormat = new SimpleDateFormat("dd/MM/yyyy");
String result = "";
@@ -154,12 +159,12 @@
topiaContext = beginTransaction();
CSVReader csvReader = new CSVReader(new StringReader(datas));
- ColumnPositionMappingStrategy<EntriesEBPImpl> strat = new ColumnPositionMappingStrategy<EntriesEBPImpl>();
- strat.setType(EntriesEBPImpl.class);
+ ColumnPositionMappingStrategy<EntryEBPImpl> strat = new ColumnPositionMappingStrategy<EntryEBPImpl>();
+ strat.setType(EntryEBPImpl.class);
//read header to set strategy mapping
strat.setColumnMapping(csvReader.readNext());
- CsvToBean<EntriesEBPImpl> csv = new CsvToBean<EntriesEBPImpl>();
- List<EntriesEBPImpl> list = csv.parse(strat, csvReader);
+ CsvToBean<EntryEBPImpl> csv = new CsvToBean<EntryEBPImpl>();
+ List<EntryEBPImpl> list = csv.parse(strat, csvReader);
//DAOs
AccountDAO accountDAO =
@@ -168,13 +173,13 @@
LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
FinancialPeriodDAO financialPeriodDAO =
LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
- FinancialTransactionDAO financialTransactionDAO =
- LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
- EntryDAO entryDAO =
- LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ if (financialPeriodDAO.findAll().size() == 0){
+ throw new LimaBusinessException("Can't import entries, no fiscalperiod is open");
+ }
+
FinancialTransaction financialTransaction = null;
- for (EntriesEBP entryEBP : list) {
+ for (EntryEBP entryEBP : list) {
//create entry
Entry entry = new EntryImpl();
Account account = accountDAO.findByAccountNumber(entryEBP.getCompte());
@@ -197,7 +202,7 @@
}
entry.setDescription(entryEBP.getLibelle());
entry.setLettering(entryEBP.getLettre());
- entryDAO.create(entry);
+ entry.setVoucher(entryEBP.getPiece());
Date date = epbDateFormat.parse(entryEBP.getDatEcr());
String entryBookCode = entryEBP.getJournal();
EntryBook entryBook = entryBookDAO.findByCode(entryBookCode);
@@ -213,20 +218,31 @@
if (financialTransaction == null || !(date.equals(financialTransaction.getTransactionDate()) && entryBook.getCode().equals(financialTransaction.getEntryBook().getCode()))){
+ //update previous financial transaction before create new
+ if (financialTransaction != null){
+ financialTransaction.setAmounts();
+ financialTransactionService.updateFinancialTransaction(financialTransaction);
+ }
//create financial transaction
financialTransaction = new FinancialTransactionImpl();
financialTransaction.setEntryBook(entryBook);
financialTransaction.setTransactionDate(date);
FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(date);
financialTransaction.setFinancialPeriod(financialPeriod);
- financialTransactionDAO.create(financialTransaction);
+ financialTransactionService.createFinancialTransaction(financialTransaction);
result += "SUCCES : FinancialTransaction" + date + " " + entryBook.getCode() + " added\n";
}
- financialTransaction.addEntry(entry);
+ financialTransaction.addEntry(entry);
+ financialTransactionService.createEntry(entry);
result += "SUCCES : Entry" + entry.getDescription() + " " + entry.getAmount() + " added\n";
}
}
+ //update last financial transaction
+ if (financialTransaction != null){
+ financialTransaction.setAmounts();
+ financialTransactionService.updateFinancialTransaction(financialTransaction);
+ }
//commit
commitTransaction(topiaContext);
}
@@ -247,10 +263,72 @@
doFinally(topiaContext, log);
}
return result;
-
-
}
+ @Override
+ public String importAccountsChartFromEbp(String datas) throws LimaException{
+ String result = "";
+ TopiaContext topiaContext = null;
+
+ try {
+ topiaContext = beginTransaction();
+ CSVReader csvReader = new CSVReader(new StringReader(datas));
+ ColumnPositionMappingStrategy<AccountEBPImpl> strat = new ColumnPositionMappingStrategy<AccountEBPImpl>();
+ strat.setType(AccountEBPImpl.class);
+ //read header to set strategy mapping
+ strat.setColumnMapping(csvReader.readNext());
+ CsvToBean<AccountEBPImpl> csv = new CsvToBean<AccountEBPImpl>();
+ List<AccountEBPImpl> list = csv.parse(strat, csvReader);
+ Collections.sort(list, new AccountEBPComparator());
+
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ for (AccountEBP accountEBP : list) {
+ String accountNumber = accountEBP.getNumero();
+ if (accountDAO.findByAccountNumber(accountNumber) != null){
+ result += "FAILED : Account" + accountNumber + " already exist \n";
+ }
+ else {
+ String label = accountEBP.getIntitule();
+ Account account = new AccountImpl();
+ account.setAccountNumber(accountNumber);
+ account.setLabel(label);
+
+ // if account is class account : 1, 2, 3, 4, 5, 6, 7,…
+ int nbCharAccountNumber = accountNumber.length();
+ if (nbCharAccountNumber == 1){
+ accountService.createAccount(null, account);
+ result += "SUCCES : Account" + accountNumber + " " + label + " added\n";
+ }
+ else {
+ Account masterAccount = null;
+ int i = 1;
+ while (masterAccount == null){
+ String masterAccountNumber = accountNumber.substring(0, accountNumber.length()-i);
+ masterAccount = accountDAO.findByAccountNumber(masterAccountNumber);
+ i++;
+ }
+ accountService.createAccount(masterAccount, account);
+ result += "SUCCES : Account" + accountNumber + " " + label + " added\n";
+ }
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't read string", eeeIO);
+ }
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+
+ return result;
+ }
+
+
@Override
public void importAsCiel(byte[] data) throws LimaException {
// TODO Auto-generated method stub
Modified: 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 2010-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -20,7 +20,6 @@
package org.chorem.lima.business.utils;
import java.util.Comparator;
-
import org.chorem.lima.entity.Account;
public class AccountComparator implements Comparator<Account>{
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountEBPComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountEBPComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountEBPComparator.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -0,0 +1,14 @@
+package org.chorem.lima.business.utils;
+
+import java.util.Comparator;
+
+import org.chorem.lima.beans.AccountEBP;
+
+public class AccountEBPComparator implements Comparator<AccountEBP> {
+
+ @Override
+ public int compare(AccountEBP o1, AccountEBP o2) {
+ return o1.getNumero().compareTo(o2.getNumero());
+ }
+
+}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -1,8 +1,24 @@
+/* *##% 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.entity;
-import java.util.ArrayList;
import java.util.List;
-
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
@@ -14,7 +30,6 @@
*/
@Override
public List<Account> findAllSubAccounts() throws TopiaException {
- List<Account> accountsList = new ArrayList<Account>();
TopiaQuery query = createQuery();
String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS);
String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS);
Added: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -0,0 +1,19 @@
+package org.chorem.lima.entity;
+
+
+public class FinancialTransactionImpl extends FinancialTransactionAbstract {
+
+ @Override
+ public void setAmounts() {
+
+ for (Entry entryFT : entry) {
+ if (entryFT.getDebit()){
+ amountDebit += entryFT.getAmount();
+ }
+ else {
+ amountCredit += entryFT.getAmount();
+ }
+ }
+ }
+
+}
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-07-15 09:47:22 UTC (rev 2969)
@@ -22,11 +22,13 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Component;
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import javax.swing.JFileChooser;
import org.apache.commons.logging.Log;
@@ -101,32 +103,37 @@
break;
case LIMA_ALL_IMPORT:
filePath = chooseFile(true);
- datas = extractFile(filePath);
+ datas = extractFile(filePath, charset);
result = importService.importCSV(datas);
break;
case LIMA_ACCOUNTCHARTS_IMPORT:
filePath = chooseFile(true);
- datas = extractFile(filePath);
+ datas = extractFile(filePath, charset);
result = importService.importAccountsChartAsCSV(datas);
break;
case LIMA_ENTRYBOOKS_IMPORT:
filePath = chooseFile(true);
- datas = extractFile(filePath);
+ datas = extractFile(filePath, charset);
result = importService.importEntryBooksChartAsCSV(datas);
break;
case LIMA_FINANCIALSTATEMENTS_IMPORT:
filePath = chooseFile(true);
- datas = extractFile(filePath);
+ datas = extractFile(filePath, charset);
result = importService.importFinancialStatementsChartAsCSV(datas);
break;
case EBP_ACCOUNTCHARTS_IMPORT:
+ //For windows ebp
+ charset = "ISO-8859-1";
filePath = chooseFile(true);
- datas = extractFile(filePath);
+ datas = extractFile(filePath, charset);
+ result = importService.importAccountsChartFromEbp(datas);
break;
case EBP_ENTRIES_IMPORT:
+ //For windows ebp
+ charset = "ISO-8859-1";
filePath = chooseFile(true);
- datas = extractFile(filePath);
- result = importService.importAsEbpCSV(datas);
+ datas = extractFile(filePath, charset);
+ result = importService.importEntriesFromEbp(datas);
break;
}
if (!result.equals("")){
@@ -195,19 +202,19 @@
* Open csv file and get his datas on a string
*
*/
- public String extractFile(String path){
- byte[] buffer = new byte[(int) new File(path).length()];
+ public String extractFile(String filePath, String charset){
+ char[] datas = new char[(int) new File(filePath).length()];
try {
- BufferedInputStream f = new BufferedInputStream(new FileInputStream(path));
- f.read(buffer);
- f.close();
+ BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), charset));
+ in.read(datas);
+ in.close();
}
catch (IOException eee) {
if (log.isDebugEnabled()){
- log.debug("Can't read file "+path, eee);
+ log.debug("Can't read file "+filePath, eee);
}
}
- return new String(buffer);
+ return new String(datas);
}
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-07-13 14:29:30 UTC (rev 2968)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-07-15 09:47:22 UTC (rev 2969)
@@ -102,7 +102,7 @@
lima.importexport.export=Export
lima.importexport.financialstatements=Plan BCR
lima.importexport.import=Import
-lima.importexport.import.terminated=Import
+lima.importexport.import.terminated=Import termin\u00E9
lima.importexport.lima=Import/Export Lima
lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s
lima.init.errorclosing=
1
0
Author: jpepin
Date: 2010-07-13 16:29:30 +0200 (Tue, 13 Jul 2010)
New Revision: 2968
Url: http://chorem.org/repositories/revision/lima/2968
Log:
Import entries from EBP.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.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/ExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-callao/pom.xml
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java
trunk/lima-swing/src/main/resources/icons/action-closeTab.png
trunk/pom.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -41,7 +41,7 @@
* @param data
* @throws LimaException
*/
- public void importAsEbpCSV(byte[] data) throws LimaException;
+ public String importAsEbpCSV(String datas) throws LimaException;
/**
* Import data as Sage Maestria export.
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-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -328,8 +328,8 @@
FiscalPeriodDAO fiscalPeriodDAO =
LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
FiscalPeriod fiscalPeriod =
- fiscalPeriodDAO.findContainsFinancialPeriod(
- financialTransaction.getFinancialPeriod());
+ fiscalPeriodDAO.findContainsFinancialPeriod(
+ financialTransaction.getFinancialPeriod());
Date beginDateFiscalPeriod = fiscalPeriod.getBeginDate();
Date endDateFiscalPeriod = fiscalPeriod.getEndDate();
Date financialTransactionDate =
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-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -4,7 +4,6 @@
import java.util.Calendar;
import java.util.Date;
import java.util.List;
-
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.logging.Log;
@@ -17,7 +16,6 @@
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.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
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-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -314,13 +314,12 @@
// Check rules for account if have entries
accountingRules.removeAccountRules(account, transaction);
-
+
// remove account
Account accountToDelete = accountDAO.findByTopiaId(account.getTopiaId());
- accountDAO.delete(accountToDelete);
//get all subaccounts
- List<Account> accounts = getAllChildrenAccounts(account, new ArrayList<Account>());
+ List<Account> accounts = getAllChildrenAccounts(accountToDelete, new ArrayList<Account>());
//if account have sub accounts
if (accounts.size() > 0){
for (Account subAccount : accounts) {
@@ -330,9 +329,10 @@
accountDAO.delete(subAccountToDelete);
}
}
- //commit
- commitTransaction(transaction);
-
+
+ accountDAO.delete(accountToDelete);
+ //commit
+ commitTransaction(transaction);
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -375,9 +375,8 @@
LimaCallaoDAOHelper.getAccountDAO(transaction);
Account subAccount = accountDAO.findByTopiaId(account.getTopiaId());
//check rules account if ledger or account
- if (account.getGeneralLedger()==null){
+ if (account.getGeneralLedger() == null){
Account master = accountDAO.findContainsSubAccounts(subAccount);
- log.debug(master);
accountingRules.updateAccountRules(master, account);
subAccount.setMasterAccount(account.getMasterAccount());
subAccount.setSubAccounts(account.getSubAccounts());
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -24,7 +24,6 @@
import java.text.SimpleDateFormat;
import java.util.List;
import javax.ejb.Stateless;
-
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -51,8 +50,6 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
-import org.omg.CORBA.portable.ValueOutputStream;
-
import au.com.bytecode.opencsv.CSVWriter;
/**
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -39,6 +39,8 @@
import org.chorem.lima.beans.AccountImportImpl;
import org.chorem.lima.beans.ClosedPeriodicEntryBookImport;
import org.chorem.lima.beans.ClosedPeriodicEntryBookImportImpl;
+import org.chorem.lima.beans.EntriesEBP;
+import org.chorem.lima.beans.EntriesEBPImpl;
import org.chorem.lima.beans.EntryImport;
import org.chorem.lima.beans.EntryImportImpl;
import org.chorem.lima.beans.FinancialStatementImport;
@@ -53,6 +55,7 @@
import org.chorem.lima.business.FiscalPeriodServiceLocal;
import org.chorem.lima.business.ImportService;
import org.chorem.lima.business.ImportServiceLocal;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.utils.FiscalPeriodComparator;
@@ -85,6 +88,8 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import au.com.bytecode.opencsv.CSVReader;
+import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy;
+import au.com.bytecode.opencsv.bean.CsvToBean;
/**
* CSV import export service.
@@ -140,8 +145,110 @@
//################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
@Override
- public void importAsEbpCSV(byte[] data) throws LimaException {
-
+ public String importAsEbpCSV(String datas) throws LimaException {
+ SimpleDateFormat epbDateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ String result = "";
+
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+
+ CSVReader csvReader = new CSVReader(new StringReader(datas));
+ ColumnPositionMappingStrategy<EntriesEBPImpl> strat = new ColumnPositionMappingStrategy<EntriesEBPImpl>();
+ strat.setType(EntriesEBPImpl.class);
+ //read header to set strategy mapping
+ strat.setColumnMapping(csvReader.readNext());
+ CsvToBean<EntriesEBPImpl> csv = new CsvToBean<EntriesEBPImpl>();
+ List<EntriesEBPImpl> list = csv.parse(strat, csvReader);
+
+ //DAOs
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+ FinancialTransactionDAO financialTransactionDAO =
+ LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ EntryDAO entryDAO =
+ LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+
+ FinancialTransaction financialTransaction = null;
+ for (EntriesEBP entryEBP : list) {
+ //create entry
+ Entry entry = new EntryImpl();
+ Account account = accountDAO.findByAccountNumber(entryEBP.getCompte());
+ //if account not exist not export
+ if (account == null){
+ throw new LimaBusinessException("FAILED : Account " + entryEBP.getCompte() + " not exist !\n"
+ + "Import or create all accounts before import entries");
+ }
+ else {
+ entry.setAccount(account);
+ Double debit = new Double(entryEBP.getDebit());
+ Double credit = new Double(entryEBP.getCredit());
+ if (debit == 0){
+ entry.setDebit(false);
+ entry.setAmount(credit);
+ }
+ else {
+ entry.setDebit(true);
+ entry.setAmount(debit);
+ }
+ entry.setDescription(entryEBP.getLibelle());
+ entry.setLettering(entryEBP.getLettre());
+ entryDAO.create(entry);
+ Date date = epbDateFormat.parse(entryEBP.getDatEcr());
+ String entryBookCode = entryEBP.getJournal();
+ EntryBook entryBook = entryBookDAO.findByCode(entryBookCode);
+
+ //if entrybook not exist create it !
+ if (entryBook==null){
+ entryBook = new EntryBookImpl();
+ entryBook.setCode(entryBookCode);
+ //create it
+ entryBookService.createEntryBook(entryBook);
+ result += "WARNING : Entrybook " + entryBook + "not exist was created !\n";
+ }
+
+
+ if (financialTransaction == null || !(date.equals(financialTransaction.getTransactionDate()) && entryBook.getCode().equals(financialTransaction.getEntryBook().getCode()))){
+ //create financial transaction
+ financialTransaction = new FinancialTransactionImpl();
+ financialTransaction.setEntryBook(entryBook);
+ financialTransaction.setTransactionDate(date);
+ FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(date);
+ financialTransaction.setFinancialPeriod(financialPeriod);
+ financialTransactionDAO.create(financialTransaction);
+ result += "SUCCES : FinancialTransaction" + date + " " + entryBook.getCode() + " added\n";
+
+ }
+ financialTransaction.addEntry(entry);
+ result += "SUCCES : Entry" + entry.getDescription() + " " + entry.getAmount() + " added\n";
+ }
+ }
+ //commit
+ commitTransaction(topiaContext);
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't read string", eeeIO);
+ }
+ }
+ catch (ParseException eeePE) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't parse date", eeePE);
+ }
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+
+
}
@Override
Modified: trunk/lima-callao/pom.xml
===================================================================
--- trunk/lima-callao/pom.xml 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-callao/pom.xml 2010-07-13 14:29:30 UTC (rev 2968)
@@ -65,7 +65,7 @@
<phase>generate-sources</phase>
<configuration>
<inputs>zargo</inputs>
- <templates>org.nuiton.topia.generator.TopiaMetaTransformer, org.nuiton.topia.generator.EntityTransformer, org.nuiton.eugene.java.JavaBeanTransformer, org.nuiton.topia.generator.QueryHelperTransformer</templates>
+ <templates>org.nuiton.topia.generator.TopiaMetaTransformer, org.nuiton.topia.generator.EntityTransformer, org.nuiton.eugene.java.JavaBeanTransformer</templates>
<excludeTemplates>
<excludeTemplate>org.nuiton.topia.generator.EntityAbstractTransformer</excludeTemplate>
<excludeTemplate>org.nuiton.topia.generator.EntityImplTransformer</excludeTemplate>
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -24,13 +24,11 @@
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.EventObject;
-
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellEditor;
import javax.swing.text.JTextComponent;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
@@ -46,14 +44,16 @@
private final JWideComboBox comboBox;
private static final long serialVersionUID = 2580476608066111095L;
private static AccountTableCellEditor editor;
+ private static SubAccountComboBoxModel accountComboBoxModel;
private static boolean keyPressed = false;
/**
* constructor
*/
public AccountTableCellEditor() {
+ super();
comboBox = new JWideComboBox();
- SubAccountComboBoxModel accountComboBoxModel = new SubAccountComboBoxModel();
+ accountComboBoxModel = new SubAccountComboBoxModel();
comboBox.setModel(accountComboBoxModel);
AccountRenderer accountRenderer = new AccountRenderer();
comboBox.setRenderer(accountRenderer);
@@ -81,8 +81,9 @@
// Validate editing with enter key
if ( e.getKeyChar() == KeyEvent.VK_ENTER )
{
-
- stopCellEditing();
+ //FIXME pepin 13072010 enter not save the modification
+ log.debug(comboBox.getEditor().getItem());
+ stopCellEditing();
}
}
});
@@ -90,16 +91,15 @@
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (value instanceof Account){
- comboBox.setSelectedItem((Account) value);
-
- }
+ if (value instanceof Account){
+ comboBox.setSelectedItem((Account) value);
+ }
return comboBox;
}
@Override
public Object getCellEditorValue() {
- return comboBox.getSelectedItem();
+ return comboBox.getSelectedItem();
}
/**
@@ -135,6 +135,7 @@
return ( !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2 );
}
+
public static AccountTableCellEditor getInstance() {
if (editor == null) {
editor = new AccountTableCellEditor();
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -31,12 +31,7 @@
private static final long serialVersionUID = -2756100193253351274L;
@Override
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
- // TODO Auto-generated method stub
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = new JLabel();
Account account = (Account) value;
Modified: 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 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -20,10 +20,8 @@
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.AccountService;
@@ -36,7 +34,7 @@
* Account combo box model.
*/
-public class SubAccountComboBoxModel implements ComboBoxModel {
+public class SubAccountComboBoxModel implements ComboBoxModel {
private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
@@ -50,7 +48,7 @@
accountService = LimaServiceFactory.getInstance().getAccountService();
datasCache = getDataList();
}
-
+
@Override
public Object getSelectedItem() {
return selectedAccount;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -126,6 +126,7 @@
case EBP_ENTRIES_IMPORT:
filePath = chooseFile(true);
datas = extractFile(filePath);
+ result = importService.importAsEbpCSV(datas);
break;
}
if (!result.equals("")){
@@ -138,6 +139,7 @@
catch (LimaException eee) {
if (log.isDebugEnabled()){
log.debug("Can't call export import service ", eee);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java 2010-07-13 14:29:30 UTC (rev 2968)
@@ -19,7 +19,7 @@
return result;
}
- public static AccountToString getInstance() {
+ public static AccountToString getInstance() {
if (converter == null) {
converter = new AccountToString();
}
Modified: trunk/lima-swing/src/main/resources/icons/action-closeTab.png
===================================================================
(Binary files differ)
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-07-12 13:08:29 UTC (rev 2967)
+++ trunk/pom.xml 2010-07-13 14:29:30 UTC (rev 2968)
@@ -251,8 +251,8 @@
<!-- customized libs version -->
<nuiton-utils.version>1.3.2-SNAPSHOT</nuiton-utils.version>
- <eugene.version>2.1-SNAPSHOT</eugene.version>
- <topia.version>2.3.5-SNAPSHOT</topia.version>
+ <eugene.version>2.0.2</eugene.version>
+ <topia.version>2.3.4</topia.version>
<jaxx.version>2.0.2</jaxx.version>
<i18n.version>1.2.2</i18n.version>
1
0
Author: jpepin
Date: 2010-07-12 15:08:29 +0200 (Mon, 12 Jul 2010)
New Revision: 2967
Url: http://chorem.org/repositories/revision/lima/2967
Log:
Debug lima-swing.
Modified:
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/AccountRenderer.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/EntryBookRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.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/financialstatementchart/FinancialStatementChartViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.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-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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -19,8 +19,6 @@
package org.chorem.lima.ui.accountsreports;
import static org.nuiton.i18n.I18n._;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.ui.combobox.AccountComboBoxModel;
@@ -36,10 +34,6 @@
*/
public class AccountsReportsViewHandler {
- /** log. */
- private static final Log log =
- LogFactory.getLog(AccountsReportsViewHandler.class);
-
protected AccountsReportsView view;
protected AccountsReportsTableModel tableModel;
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -29,7 +29,6 @@
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.service.LimaServiceFactory;
import org.chorem.lima.util.ErrorHelper;
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -19,8 +19,6 @@
package org.chorem.lima.ui.balance;
import static org.nuiton.i18n.I18n._;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.business.FinancialTransactionService;
import org.chorem.lima.service.LimaServiceFactory;
@@ -37,10 +35,6 @@
*/
public class BalanceViewHandler {
- /** log. */
- private static final Log log =
- LogFactory.getLog(BalanceViewHandler.class);
-
protected BalanceView view;
/** service **/
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -35,7 +35,10 @@
public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel {
- private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+ private static final long serialVersionUID = -4513156210596401121L;
+
+ private static final Log log =
+ LogFactory.getLog(FinancialPeriodTableModel.class);
protected Object selectedAccount;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -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.combobox;
import java.awt.Component;
@@ -10,7 +28,9 @@
public class AccountRenderer extends DefaultListCellRenderer {
- @Override
+ private static final long serialVersionUID = -2756100193253351274L;
+
+ @Override
public Component getListCellRendererComponent(JList list,
Object value,
int index,
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -39,7 +39,10 @@
*/
public class EntryBookComboBoxModel extends DefaultComboBoxModel {
- private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+ private static final long serialVersionUID = -2198896334751124051L;
+
+ private static final Log log =
+ LogFactory.getLog(FinancialPeriodTableModel.class);
protected Object selectedEntryBook;
@@ -48,7 +51,8 @@
protected List<EntryBook> cacheDatas;
public EntryBookComboBoxModel() {
- entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
+ entryBookService =
+ LimaServiceFactory.getInstance().getEntryBookService();
cacheDatas = getDataList();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -12,6 +12,8 @@
public class EntryBookRenderer extends DefaultListCellRenderer {
+ private static final long serialVersionUID = 8415102235262629812L;
+
@Override
public Component getListCellRendererComponent(JList list,
Object value,
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -1,6 +1,3 @@
-package org.chorem.lima.ui.combobox;
-
-
/* *##% Lima Swing
* Copyright (C) 2008 - 2010 CodeLutin
*
@@ -19,6 +16,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* ##%*/
+package org.chorem.lima.ui.combobox;
+
import static org.nuiton.i18n.I18n._;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
@@ -30,10 +29,14 @@
*/
public class EntryBookTypeListModel extends AbstractListModel implements ComboBoxModel {
- protected Object selectedObject;
+ private static final long serialVersionUID = 3777447499815020502L;
+ protected Object selectedObject;
+
/** Data. TODO put string in another place, don't use hard coded string. */
- protected Object[] data = new Object[]{ _("lima.entrybook.type1"), _("lima.entrybook.type2"), _("lima.entrybook.type3"), _("lima.entrybook.type4"), _("lima.entrybook.type5")};
+ protected Object[] data = new Object[]{ _("lima.entrybook.type1"),
+ _("lima.entrybook.type2"), _("lima.entrybook.type3"),
+ _("lima.entrybook.type4"), _("lima.entrybook.type5")};
public EntryBookTypeListModel() {
super();
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -19,10 +19,8 @@
package org.chorem.lima.ui.combobox;
import java.util.List;
-
import javax.swing.AbstractListModel;
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.FinancialPeriodService;
@@ -43,7 +41,9 @@
*/
public class FinancialPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel {
- private static final Log log =
+ private static final long serialVersionUID = 5272891704755358592L;
+
+ private static final Log log =
LogFactory.getLog(FinancialPeriodTableModel.class);
protected Object selectedFinancialPeriod;
@@ -55,7 +55,8 @@
protected FiscalPeriod selectedFiscalPeriod;
public FinancialPeriodComboBoxModel() {
- financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
+ financialPeriodService =
+ LimaServiceFactory.getInstance().getFinancialPeriodService();
datasCache=getDataList();
}
@@ -88,7 +89,8 @@
List<FinancialPeriod> result = null;
try {
if (selectedFiscalPeriod != null){
- result = (List<FinancialPeriod>) selectedFiscalPeriod.getFinancialPeriod();
+ result = (List<FinancialPeriod>)
+ selectedFiscalPeriod.getFinancialPeriod();
}
else {
result = financialPeriodService.getUnblockedFinancialPeriods();
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -18,20 +18,18 @@
package org.chorem.lima.ui.combobox;
-import static org.nuiton.i18n.I18n._;
-
import java.awt.Component;
import java.text.SimpleDateFormat;
-
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
-
import org.chorem.lima.entity.FinancialPeriod;
public class FinancialPeriodComboBoxRenderer extends DefaultListCellRenderer {
+ private static final long serialVersionUID = -6130397429740718196L;
+
@Override
public Component getListCellRendererComponent(JList list,
Object value,
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -22,21 +22,20 @@
import javax.swing.AbstractListModel;
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.FiscalPeriodService;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel{
-
- private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+
protected Object selectedFiscalPeriod;
protected FiscalPeriodService fiscalPeriodService;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -27,6 +27,8 @@
public class FiscalPeriodComboBoxRenderer extends DefaultListCellRenderer {
+ private static final long serialVersionUID = 7131001128874614788L;
+
@Override
public Component getListCellRendererComponent(JList list,
Object value,
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -20,8 +20,6 @@
import java.awt.Color;
import java.awt.Component;
-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.jdesktop.swingx.JXTable;
@@ -42,9 +40,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- /** log. */
- private static final Log log = LogFactory.getLog(EntryBooksReportsTable.class);
-
protected EntryBooksReportsViewHandler handler;
protected EntryBooksReportsTableModel model;
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -19,9 +19,6 @@
package org.chorem.lima.ui.entrybooksreports;
import static org.nuiton.i18n.I18n._;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
@@ -37,10 +34,6 @@
*/
public class EntryBooksReportsViewHandler {
- /** log. */
- private static final Log log =
- LogFactory.getLog(EntryBooksReportsViewHandler.class);
-
protected EntryBooksReportsView view;
protected EntryBooksReportsTable table;
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -37,7 +37,9 @@
public class FinancialPeriodTable extends JXTable {
- private static final Log log =
+ private static final long serialVersionUID = -1960326844433064178L;
+
+ private static final Log log =
LogFactory.getLog(FinancialPeriodTableModel.class);
protected FinancialPeriodViewHandler handler;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -19,7 +19,6 @@
package org.chorem.lima.ui.financialstatementchart;
import static org.nuiton.i18n.I18n._;
-import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.tree.TreePath;
import org.apache.commons.logging.Log;
@@ -35,7 +34,6 @@
import org.chorem.lima.ui.importexport.ImportExportForm;
import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
-import org.chorem.lima.util.FileChooseView;
import org.jdesktop.swingx.JXTreeTable;
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -20,23 +20,10 @@
import java.awt.Color;
import java.awt.Component;
-import java.awt.Font;
-import java.text.SimpleDateFormat;
-
-import javax.swing.border.LineBorder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.FinancialStatementAmounts;
import org.chorem.lima.business.FinancialPeriodService;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
-import org.chorem.lima.entity.FinancialStatement;
-import org.chorem.lima.entity.FinancialStatementImpl;
import org.chorem.lima.service.LimaServiceFactory;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.BorderHighlighter;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
@@ -44,11 +31,10 @@
public class FinancialStatementReportTable extends JXTable {
- private static final Log log =
- LogFactory.getLog(FinancialStatementReportTableModel.class);
+ private static final long serialVersionUID = 154211277688304679L;
+
+ protected FinancialStatementReportViewHandler handler;
- protected FinancialStatementReportViewHandler handler;
-
protected FinancialStatementReportTableModel model;
protected FinancialPeriodService financialPeriodService;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -21,7 +21,6 @@
import javax.swing.table.*;
import javax.swing.*;
import org.chorem.lima.beans.FinancialStatementAmounts;
-import org.chorem.lima.entity.FinancialStatement;
import java.awt.*;
@@ -32,7 +31,9 @@
public class FinancialStatementReportTableCellRenderer extends DefaultTableCellRenderer {
- @Override
+ private static final long serialVersionUID = 4682358397738816778L;
+
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column)
{
@@ -64,24 +65,6 @@
}
}
}
- // Alignement des cellules
- /* switch (column) {
- case 0:
- this.setHorizontalAlignment(JLabel.LEFT);
- break;
- case 1:
- this.setHorizontalAlignment(JLabel.RIGHT);
- break;
- case 2:
- this.setHorizontalAlignment(JLabel.RIGHT);
- break;
- case 3:
- this.setHorizontalAlignment(JLabel.RIGHT);
- break;
- case 4:
- this.setHorizontalAlignment(JLabel.RIGHT);
- break;
- }*/
return this;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -20,20 +20,14 @@
package org.chorem.lima.ui.financialstatementreport;
import static org.nuiton.i18n.I18n._;
-import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.FinancialStatementAmounts;
-import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.FinancialStatementService;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.ReportService;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.util.ErrorHelper;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -18,13 +18,8 @@
package org.chorem.lima.ui.financialstatementreport;
-import static org.nuiton.i18n.I18n._;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.business.FinancialTransactionService;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodView;
/**
@@ -38,10 +33,6 @@
*/
public class FinancialStatementReportViewHandler {
- /** log. */
- private static final Log log =
- LogFactory.getLog(FinancialStatementReportViewHandler.class);
-
protected FinancialStatementReportView view;
/** service **/
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -23,9 +23,6 @@
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.ui.celleditor.AccountTableCellEditor;
@@ -49,9 +46,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- /** log. */
- private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
-
protected FinancialTransactionViewHandler handler;
private Highlighter colorTransaction;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -23,9 +23,6 @@
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.ui.celleditor.AccountTableCellEditor;
@@ -50,9 +47,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- /** log. */
- private static final Log log = LogFactory.getLog(FinancialTransactionUnbalancedTable.class);
-
protected FinancialTransactionUnbalancedViewHandler handler;
private Highlighter colorTransaction;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -20,13 +20,9 @@
import java.awt.Color;
import java.awt.Component;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
@@ -36,10 +32,10 @@
public class FiscalPeriodTable extends JXTable {
-private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+ private static final long serialVersionUID = -8462838870024505659L;
+
+ protected FiscalPeriodViewHandler handler;
- protected FiscalPeriodViewHandler handler;
-
protected FiscalPeriodTableModel model;
protected FiscalPeriodService financialPeriodService;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -2,17 +2,10 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Color;
-import java.awt.Font;
import java.util.List;
-import javax.swing.BorderFactory;
import javax.swing.JEditorPane;
-import javax.swing.JPanel;
-import javax.swing.border.Border;
-import javax.swing.border.EtchedBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
-import javax.swing.plaf.basic.BasicEditorPaneUI;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
@@ -28,8 +21,6 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
-import com.sun.codemodel.internal.JLabel;
-
public class HomeViewHandler implements HyperlinkListener {
private static final Log log = LogFactory.getLog(HomeViewHandler.class);
@@ -112,7 +103,8 @@
entryBookPane.addHyperlinkListener(this);
fiscalYearPane.addHyperlinkListener(this);
dailyPane.addHyperlinkListener(this);
- String htmlBegin = "<font face='sans-serif' size=3><p style=vertical-align:'bottom', horizontal-align:'center'>";
+ String htmlBegin = "<font face='sans-serif' size=3>"
+ + "<p style=vertical-align:'bottom', horizontal-align:'center'>";
String htmlEnd = "</p></font>";
try {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -20,9 +20,6 @@
import java.awt.Color;
import java.awt.Component;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Account;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
@@ -41,9 +38,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- /** log. */
- private static final Log log = LogFactory.getLog(LedgerTable.class);
-
protected LedgerViewHandler handler;
private Highlighter colorReportsDatas;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -19,8 +19,6 @@
package org.chorem.lima.ui.ledger;
import static org.nuiton.i18n.I18n._;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
@@ -35,10 +33,6 @@
*/
public class LedgerViewHandler {
- /** log. */
- private static final Log log =
- LogFactory.getLog(LedgerViewHandler.class);
-
protected LedgerView view;
protected LedgerTableModel model;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-07-12 13:08:29 UTC (rev 2967)
@@ -19,17 +19,10 @@
package org.chorem.lima.util;
import static org.nuiton.i18n.I18n._;
-
import java.awt.Component;
-
-import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
import javax.swing.JTextArea;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.nuiton.util.Resource;
/**
@@ -38,11 +31,6 @@
*/
public class DialogHelper {
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(DialogHelper.class);
-
public static int showConfirmDialog(String message) {
String[] response = {_("lima.response.yes"), _("lima.response.no")};
return JOptionPane.showOptionDialog(null,
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-07-12 13:08:29 UTC (rev 2967)
@@ -184,17 +184,37 @@
lima.transaction.period=Period
lima.voucher=Voucher
lima.warning.nimbus.landf=Could not find Numbus Look&Feel
+limahome.chartaccounts.create=
+limahome.chartaccounts.modify=
+limahome.chartaccounts.nothing=
+limahome.chartaccounts.state1_2=
+limahome.chartaccounts.state2_2=
limahome.chartaccounts1=
limahome.chartaccounts2=
limahome.createchartaccounts=
limahome.createchartaccounts1=
limahome.createchartaccounts2=
limahome.entrybooknoopen=
+limahome.entrybooks.create=
+limahome.entrybooks.modify=
+limahome.entrybooks.nothing=
+limahome.entrybooks.state.single=
+limahome.entrybooks.state1_2.plural=
+limahome.entrybooks.state2_2.plural=
limahome.entrybooks1=
limahome.entrybooks2=
+limahome.fiscalperiod.closed=
+limahome.fiscalperiod.create=
+limahome.fiscalperiod.modify=
+limahome.fiscalperiod.noopen=
+limahome.fiscalperiod.opened=
limahome.fiscalperiodclosed=
limahome.fiscalperiodnoopen=
limahome.fiscalperiodopened=
+limahome.transaction.balanced=
+limahome.transaction.create=
+limahome.transaction.modifiy=
+limahome.transaction.unbalanced=
limahome.transactionbalanced=
limahome.transactionunbalanced=
update=
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-07-12 10:37:10 UTC (rev 2966)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-07-12 13:08:29 UTC (rev 2967)
@@ -184,24 +184,24 @@
lima.transaction.period=P\u00E9riode
lima.voucher=Document
lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9
+limahome.chartaccounts.create=Cr\u00E9er le plan des comptes
+limahome.chartaccounts.modify=Modifier le plan des comptes
limahome.chartaccounts.nothing=Aucun compte \!
limahome.chartaccounts.state1_2=Le plan comptable possede
limahome.chartaccounts.state2_2=comptes
-limahome.chartaccounts.create=Cr\u00E9er le plan des comptes
-limahome.chartaccounts.modify=Modifier le plan des comptes
+limahome.entrybooks.create=Cr\u00E9er les journaux
+limahome.entrybooks.modify=Modifier les journaux
limahome.entrybooks.nothing=Aucun journal ouvert \!
-limahome.entrybooks.modify=Modifier les journaux
-limahome.entrybooks.create=Cr\u00E9er les journaux
+limahome.entrybooks.state.single=Le journal est \:
limahome.entrybooks.state1_2.plural=Les
limahome.entrybooks.state2_2.plural=journaux sont \:
-limahome.entrybooks.state.single=Le journal est \:
limahome.fiscalperiod.closed=exercices clotur\u00E9s
-limahome.fiscalperiod.opened=exercices ouverts
-limahome.fiscalperiod.noopen=Aucun exercice ouvert \!
limahome.fiscalperiod.create=Cr\u00E9er un exercice
limahome.fiscalperiod.modify=Modifier les exercices
+limahome.fiscalperiod.noopen=Aucun exercice ouvert \!
+limahome.fiscalperiod.opened=exercices ouverts
limahome.transaction.balanced=Toutes les \u00E9critures sont \u00E9quilibr\u00E9es
+limahome.transaction.create=Modifier les \u00E9critures
+limahome.transaction.modifiy=Modifier les \u00E9critures non \u00E9quilibr\u00E9es
limahome.transaction.unbalanced=\u00E9critures ne sont pas \u00E9quilibr\u00E9es \!
-limahome.transaction.modifiy=Modifier les \u00E9critures non \u00E9quilibr\u00E9es
-limahome.transaction.create=Modifier les \u00E9critures
update=
1
0
Author: jpepin
Date: 2010-07-12 12:37:10 +0200 (Mon, 12 Jul 2010)
New Revision: 2966
Url: http://chorem.org/repositories/revision/lima/2966
Log:
Modification de l'UI : page d'accueil, icones, menus d'import / export.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java
trunk/lima-swing/src/main/filters/action-leave-fullscreen.png
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportForm.jaxx
trunk/lima-swing/src/main/resources/icons/action-charts-accounts.png
trunk/lima-swing/src/main/resources/icons/action-charts-entrybooks.png
trunk/lima-swing/src/main/resources/icons/action-charts-financialperiod.png
trunk/lima-swing/src/main/resources/icons/action-charts-financialstatements.png
trunk/lima-swing/src/main/resources/icons/action-charts-fiscalperiod.png
trunk/lima-swing/src/main/resources/icons/action-entries-balanced.png
trunk/lima-swing/src/main/resources/icons/action-entries-search.png
trunk/lima-swing/src/main/resources/icons/action-entries-unbalanced.png
trunk/lima-swing/src/main/resources/icons/action-reports-account.png
trunk/lima-swing/src/main/resources/icons/action-reports-balance.png
trunk/lima-swing/src/main/resources/icons/action-reports-entrybook.png
trunk/lima-swing/src/main/resources/icons/action-reports-financialstatement.png
trunk/lima-swing/src/main/resources/icons/action-reports-ledger.png
trunk/lima-swing/src/main/resources/images/accounts.png
trunk/lima-swing/src/main/resources/images/entries.png
trunk/lima-swing/src/main/resources/images/entrybooks.png
trunk/lima-swing/src/main/resources/images/fiscalperiods.png
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java
trunk/lima-swing/src/main/resources/icons/action-account.png
trunk/lima-swing/src/main/resources/icons/action-closure-timespan.png
trunk/lima-swing/src/main/resources/icons/action-closure.png
trunk/lima-swing/src/main/resources/icons/action-journal.png
trunk/lima-swing/src/main/resources/icons/action-rapport.png
trunk/lima-swing/src/main/resources/icons/action-search.png
trunk/lima-swing/src/main/resources/icons/action-transaction.png
trunk/lima-swing/src/main/resources/icons/action-view.png
trunk/lima-swing/src/main/resources/icons/unused/
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.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/ImportServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.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/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
trunk/lima-swing/src/main/resources/icons/action-about.png
trunk/lima-swing/src/main/resources/icons/action-closeTab.png
trunk/lima-swing/src/main/resources/icons/action-lettering.png
trunk/lima-swing/src/main/resources/icons/action-translate.png
trunk/pom.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -59,5 +59,15 @@
*/
public String exportAccountsChartAsCSV() throws LimaException;
+ /**
+ * export entries as EBP
+ */
+ public String exportEntriesAsEBP() throws LimaException;
+
+ /**
+ * export accounts as EBP
+ */
+ public String exportAccountsAsEBP() throws LimaException;
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -24,12 +24,15 @@
import java.text.SimpleDateFormat;
import java.util.List;
import javax.ejb.Stateless;
+
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ExportService;
import org.chorem.lima.business.ExportServiceLocal;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.ImportExportEntityEnum;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
@@ -48,6 +51,8 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
+import org.omg.CORBA.portable.ValueOutputStream;
+
import au.com.bytecode.opencsv.CSVWriter;
/**
@@ -66,7 +71,7 @@
private TopiaContext rootContext;
- private final SimpleDateFormat sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
+ private static final SimpleDateFormat SDateFormat = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
public ExportServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -79,6 +84,140 @@
}
}
+ //############## EXPORT EBP
+ /**
+ * Export entries to EBP
+ * Struturce example : 1,010101,VE,411ART,, "Ventes d’ordinateur ", "123 ",12548.95,D,010301,
+ * Can't use opencsv for create export because don't support "" for just some columns
+ */
+ @Override
+ public String exportEntriesAsEBP() throws LimaException {
+ TopiaContext topiaContext = null;
+ SimpleDateFormat epbDateFormat = new SimpleDateFormat("ddMMyyyy");
+ String result = "";
+ int num = 0;
+
+ try {
+ topiaContext = beginTransaction();
+ //export entries
+ FinancialTransactionDAO financialTransactionDAO =
+ LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ List<FinancialTransaction> listFinancialTransaction =
+ financialTransactionDAO.findAll();
+ // For all financialTransaction
+ for (FinancialTransaction financialTransaction : listFinancialTransaction) {
+ String date = epbDateFormat.format(financialTransaction.getTransactionDate());
+ String entrybookCode = "";
+ EntryBook entryBook = financialTransaction.getEntryBook();
+
+ if (entryBook != null){
+ entrybookCode = entryBook.getCode();
+ }
+
+ String[] nextLine = new String[11];
+ for (Entry entry : financialTransaction.getEntry()) {
+ num++;
+ Account account = entry.getAccount();
+
+ String accountNumber = "";
+ if (account != null){
+ accountNumber = entry.getAccount().getAccountNumber();
+ }
+
+ String debitcredit = "";
+ if (entry.getDebit()){
+ debitcredit = "D";
+ }
+ else {
+ debitcredit = "C";
+ }
+
+ nextLine[0] = String.valueOf(num);
+ nextLine[1] = date;
+ nextLine[2] = entrybookCode;
+ nextLine[3] = accountNumber;
+ nextLine[5] = '"'+entry.getDescription()+'"';
+ nextLine[6] = '"'+entry.getVoucher()+'"';
+ nextLine[7] = new Double(entry.getAmount()).toString();
+ nextLine[8] = debitcredit;
+
+ // Ajoute la ligne au fichier
+ for (int i=0; i<9; i++){
+ String string = "";
+ String nextln = nextLine[i];
+ if (nextln != null){
+ string = nextln;
+ }
+ if (i==8){
+ result+=string+"\r\n";
+ }
+ else {
+ result+=string+",";
+ }
+ }
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ /*catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }*/
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+ }
+
+ /**
+ * Export accounts chart to EBP
+ * Structure ebp - example :
+ * 411DUPOND,DUPOND,,21 rue du bois, 78120, Rambouillet, France,,0135698475,0135698475
+ *
+ */
+ @Override
+ public String exportAccountsAsEBP() throws LimaException {
+ TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+ CSVWriter csvWriter;
+
+
+ try {
+ topiaContext = beginTransaction();
+ csvWriter = new CSVWriter(out, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER);
+ //export accounts
+ String[] nextLine = new String[10];
+ // Récupère tous les comptes
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ List<Account> listAccount = accountDAO.findAll();
+ // Pour tous les comptes
+ for (Account account : listAccount) {
+ nextLine[0] = account.getAccountNumber();
+ nextLine[1] = StringUtils.remove(account.getLabel(), ",");
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ // Write cache in string
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+
+
+ //############## EXPORT CSV
/**
* Export integrality of database in CSV
@@ -162,7 +301,7 @@
financialStatementDAO.findAll();
// For all Financialstatements
for (FinancialStatement financialStatement : listFinancialStatements) {
- nextLine[0] = "FNST";
+ nextLine[0] = ImportExportEntityEnum.FINANCIALSTATEMENT.getLabel();
nextLine[1] = financialStatement.getLabel();
nextLine[2] = new Boolean(
financialStatement.getHeader()).toString();
@@ -236,7 +375,7 @@
List<EntryBook> listEntryBook = entryBookDAO.findAll();
// For all EntryBook
for (EntryBook entryBook : listEntryBook) {
- nextLine[0] = "ENBK";
+ nextLine[0] = ImportExportEntityEnum.ENTRYBOOK.getLabel();
nextLine[1] = entryBook.getCode();
nextLine[2] = entryBook.getLabel();
nextLine[3] = entryBook.getType();
@@ -293,7 +432,7 @@
List<Account> listAccount = accountDAO.findAll();
// Pour tous les comptes
for (Account account : listAccount) {
- nextLine[0] = "ACCN";
+ nextLine[0] = ImportExportEntityEnum.ACCOUNT.getLabel();
nextLine[1] = account.getAccountNumber();
nextLine[2] = account.getLabel();
nextLine[3] = account.getThirdParty();
@@ -336,19 +475,19 @@
// For all financialTransaction
for (FinancialTransaction financialTransaction : listFinancialTransaction) {
String[] nextLine = new String[8];
- nextLine[0] = "FTRC";
+ nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel();
nextLine[1] = String.valueOf(numTransaction);
nextLine[2] =
- sdf.format(financialTransaction.getTransactionDate());
+ SDateFormat.format(financialTransaction.getTransactionDate());
nextLine[3] = new Double(
financialTransaction.getAmountDebit()).toString();
nextLine[4] = new Double(
financialTransaction.getAmountCredit()).toString();
nextLine[5] =
- sdf.format(financialTransaction.getFinancialPeriod().
+ SDateFormat.format(financialTransaction.getFinancialPeriod().
getBeginDate());
nextLine[6] =
- sdf.format(financialTransaction.getFinancialPeriod().
+ SDateFormat.format(financialTransaction.getFinancialPeriod().
getEndDate());
EntryBook entryBook = financialTransaction.getEntryBook();
if (entryBook != null){
@@ -359,7 +498,7 @@
nextLine = new String[10];
for (Entry entry : financialTransaction.getEntry()) {
- nextLine[0] = "NTRY";
+ nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel();
nextLine[1] = String.valueOf(numTransaction);
nextLine[2] = entry.getDescription();
nextLine[3] = new Double(entry.getAmount()).toString();
@@ -395,9 +534,9 @@
fiscalPeriodDAO.findAll();
// For all Entry
for (FiscalPeriod fiscalPeriod : listFiscalPeriod) {
- nextLine[0] = "FSCP";
- nextLine[1] = sdf.format(fiscalPeriod.getBeginDate());
- nextLine[2] = sdf.format(fiscalPeriod.getEndDate());
+ nextLine[0] = ImportExportEntityEnum.FISCALPERIOD.getLabel();
+ nextLine[1] = SDateFormat.format(fiscalPeriod.getBeginDate());
+ nextLine[2] = SDateFormat.format(fiscalPeriod.getEndDate());
nextLine[3] = new Boolean(fiscalPeriod.getLocked()).toString();
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
@@ -423,14 +562,14 @@
closedPeriodicEntryBookDAO.findAll();
// For all Entry
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) {
- nextLine[0] = "CPEB";
+ nextLine[0] = ImportExportEntityEnum.CLOSEDPERIODICENTRYBOOK.getLabel();
nextLine[1] = new Boolean(
closedPeriodicEntryBook.getLocked()).toString();
nextLine[2] =
- sdf.format(closedPeriodicEntryBook.getFinancialPeriod().
+ SDateFormat.format(closedPeriodicEntryBook.getFinancialPeriod().
getBeginDate());
nextLine[3] =
- sdf.format(closedPeriodicEntryBook.getFinancialPeriod().
+ SDateFormat.format(closedPeriodicEntryBook.getFinancialPeriod().
getEndDate());
nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
// Ajoute la ligne au fichier
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-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -19,7 +19,6 @@
package org.chorem.lima.business.ejb;
-import java.util.Collections;
import java.util.List;
import javax.ejb.Stateless;
import org.apache.commons.logging.Log;
@@ -29,7 +28,6 @@
import org.chorem.lima.business.FinancialPeriodServiceLocal;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
@@ -151,8 +149,12 @@
FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.
getFinancialPeriodDAO(transaction);
- result = financialPeriodDAO.findAllByLocked(false);
- Collections.sort(result, new FinancialPeriodComparator());
+
+ TopiaQuery query = financialPeriodDAO.createQuery()
+ .addEquals(FinancialPeriod.LOCKED, Boolean.FALSE)
+ .addOrder(FinancialPeriod.BEGIN_DATE);
+
+ result = financialPeriodDAO.findAllByQuery(query);
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
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-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -412,6 +412,8 @@
entryOld.setAccount(entry.getAccount());
entryOld.setAmount(entryAmount);
entryOld.setDebit(entryAmountBool);
+ entryOld.setDescription(entry.getDescription());
+ entryOld.setVoucher(entry.getVoucher());
entryOld.setFinancialTransaction(entry.getFinancialTransaction());
entryOld.setPosition(entry.getPosition());
entryOld.setLettering(entry.getLettering());
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -56,6 +56,7 @@
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.utils.FiscalPeriodComparator;
+import org.chorem.lima.business.utils.ImportExportEntityEnum;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.AccountImpl;
@@ -122,7 +123,7 @@
EntryBookServiceLocal entryBookService;
- private final SimpleDateFormat sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
+ private static final SimpleDateFormat SDateFormat = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
public ImportServiceImpl() {
@@ -187,28 +188,31 @@
while ((nextLine = csvReader.readNext()) != null) {
- String indice = nextLine[0];
- if (indice.equals("ACCN")){
+ ImportExportEntityEnum importExportEntityEnum = ImportExportEntityEnum.valueOfLabel(nextLine[0]);
+
+ switch (importExportEntityEnum) {
+ case ACCOUNT:
result += importAccountsChartsCSV(nextLine, accounts, topiaContext);
- }
- else if (indice.equals("ENBK")){
+ break;
+ case ENTRYBOOK:
result += importEntryBooksChartCSV(nextLine, topiaContext);
- }
- else if (indice.equals("FNST")){
+ break;
+ case FINANCIALSTATEMENT:
result += importFinancialsStatementChartCSV(nextLine, financialStatements, topiaContext);
- }
- else if (indice.equals("FSCP")){
+ break;
+ case FISCALPERIOD:
result += importFiscalPeriodCSV(nextLine, fiscalPeriods, topiaContext);
- }
- else if (indice.equals("CPEB")){
+ break;
+ case CLOSEDPERIODICENTRYBOOK:
importClosedPeriodicEntryBookCSV(nextLine, closedPeriodicEntryBooks, topiaContext);
- }
- else if (indice.equals("FTRC")){
+ break;
+ case FINANCIALTRANSACTION:
importFinancialTransactionsCSV(nextLine, financialTransactions, topiaContext);
- }
- else if (indice.equals("NTRY")){
+ break;
+ case ENTRY:
importEntriesCSV(nextLine, entries, topiaContext);
- }
+ break;
+ }
}
//create accounts
@@ -254,8 +258,7 @@
CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
while ((nextLine = csvReader.readNext()) != null) {
- String indice = nextLine[0];
- if (indice.equals("ENBK")){
+ if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.ENTRYBOOK){
result += importEntryBooksChartCSV(nextLine, topiaContext);
}
}
@@ -292,8 +295,7 @@
CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
while ((nextLine = csvReader.readNext()) != null) {
- String indice = nextLine[0];
- if (indice.equals("FNST")){
+ if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.FINANCIALSTATEMENT){
result += importFinancialsStatementChartCSV(nextLine, financialStatements, topiaContext);
}
}
@@ -334,8 +336,7 @@
while ((nextLine = csvReader.readNext()) != null) {
- String indice = nextLine[0];
- if (indice.equals("ACCN")){
+ if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.ACCOUNT){
result += importAccountsChartsCSV(nextLine, accounts, topiaContext);
}
}
@@ -410,9 +411,9 @@
LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
- Date beginDate = sdf.parse(nextLine[1]);
+ Date beginDate = SDateFormat.parse(nextLine[1]);
fiscalPeriod.setBeginDate(beginDate);
- Date endDate = sdf.parse(nextLine[2]);
+ Date endDate = SDateFormat.parse(nextLine[2]);
fiscalPeriod.setEndDate(endDate);
fiscalPeriod.setLocked(new Boolean(nextLine[3]));
@@ -742,9 +743,9 @@
for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) {
//update closedPeriodicEntryBook
Date beginDateFinancialPeriod =
- sdf.parse(closedPeriodicEntryBookImport.getBeginDateFinancialPeriod());
+ SDateFormat.parse(closedPeriodicEntryBookImport.getBeginDateFinancialPeriod());
Date endDateFinancialPeriod =
- sdf.parse(closedPeriodicEntryBookImport.getEndDateFinancialPeriod());
+ SDateFormat.parse(closedPeriodicEntryBookImport.getEndDateFinancialPeriod());
FinancialPeriod financialPeriod =
financialPeriodDAO.findByNaturalId(beginDateFinancialPeriod, endDateFinancialPeriod);
String codeEntryBook = closedPeriodicEntryBookImport.getCodeEntryBook();
@@ -784,7 +785,7 @@
for (int num : financialTransactions.keySet()) {
FinancialTransactionImport financialTransactionImport = financialTransactions.get(num);
FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- Date dateFinancialTransaction = sdf.parse(financialTransactionImport.getDate());
+ Date dateFinancialTransaction = SDateFormat.parse(financialTransactionImport.getDate());
financialTransaction.setTransactionDate(dateFinancialTransaction);
financialTransaction.setAmountDebit(new Double(financialTransactionImport.getAmountDebit()));
financialTransaction.setAmountCredit(new Double(financialTransactionImport.getAmountCredit()));
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -1,35 +0,0 @@
-/* *##% Lima Business
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*
- */
-
-package org.chorem.lima.business.utils;
-
-import java.util.Comparator;
-import org.chorem.lima.entity.FinancialPeriod;
-
-public class FinancialPeriodComparator implements Comparator<FinancialPeriod>{
-
- /**
- * sort by financial begin date
- */
- @Override
- public int compare(FinancialPeriod o1, FinancialPeriod o2) {
- return o1.getBeginDate().compareTo(o2.getBeginDate());
- }
-
-}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -0,0 +1,29 @@
+package org.chorem.lima.business.utils;
+
+public enum ImportExportEntityEnum {
+
+ ACCOUNT("ACCN"), ENTRYBOOK("ENBK"), FINANCIALSTATEMENT("FNST"), FISCALPERIOD("FSCP"), CLOSEDPERIODICENTRYBOOK("CPEB"), FINANCIALTRANSACTION("FTRC"), ENTRY("NTRY");
+ private final String label;
+
+ private ImportExportEntityEnum(String label) {
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return this.label;
+ }
+
+ public static ImportExportEntityEnum valueOfLabel(String label){
+ ImportExportEntityEnum value = null;
+
+ for (ImportExportEntityEnum importExportEntityEnum : ImportExportEntityEnum.values()) {
+ if (label.equals(importExportEntityEnum.label)){
+ value = importExportEntityEnum;
+ break;
+ }
+ }
+ return value;
+ }
+}
+
+
Added: trunk/lima-swing/src/main/filters/action-leave-fullscreen.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/filters/action-leave-fullscreen.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -19,18 +19,16 @@
package org.chorem.lima;
import static org.nuiton.i18n.I18n._;
-
import java.beans.PropertyChangeListener;
import java.util.Locale;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.actions.MiscAction;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
-import org.nuiton.util.ConverterUtil;
import org.nuiton.util.Version;
import org.nuiton.util.VersionUtil;
+import org.nuiton.util.converter.ConverterUtil;
/**
* La configuration de l'application.
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -37,8 +37,8 @@
import org.chorem.lima.ui.MainViewHandler;
import org.chorem.lima.util.ErrorHelper;
import org.nuiton.i18n.I18n;
-import org.nuiton.util.ConverterUtil;
import org.nuiton.util.StringUtil;
+import org.nuiton.util.converter.ConverterUtil;
/**
* Lima main.
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx 2010-07-12 10:37:10 UTC (rev 2966)
@@ -1,50 +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.
- ##% -->
-
-<JDialog modal="true">
-
- <jaxx.runtime.swing.JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/>
- <Boolean id="addState" javaBean='true'/>
-
- <script>
- <![CDATA[
- protected void performCancel() {
- getRadioButtons().setSelectedValue(null);
- dispose();
- }
- ]]>
- </script>
-
- <Table>
- <row>
- <cell>
- <JRadioButton text='lima.importexport.export' value='export' buttonGroup="{getRadioButtons()}"
- selected='true'/>
- </cell>
- <cell>
- <JRadioButton text='lima.importexport.import' value='import' buttonGroup="{getRadioButtons()}"
- selected='true'/>
- </cell>
- <cell fill="none">
- <JButton text="lima.common.ok" onActionPerformed="dispose()"/>
- </cell>
- <cell fill="none">
- <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/>
- </cell>
- </row>
- </Table>
-</JDialog>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -1,63 +0,0 @@
-package org.chorem.lima.ui;
-
-import static org.nuiton.i18n.I18n._;
-import javax.swing.JFileChooser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.util.DialogHelper;
-import org.chorem.lima.util.FileChooseView;
-import org.chorem.lima.util.ImportExport;
-
-public class ImportExportHandler {
-
- /** log. */
- private static final Log log = LogFactory.getLog(ImportExportHandler.class);
-
- protected MainView view;
-
- ImportExportHandler(MainView mainView){
- this.view=mainView;
- }
-
- public void importexportDialog(){
-
- ImportExportForm importExportForm = new ImportExportForm(view);
- importExportForm.setLocationRelativeTo(view);
- importExportForm.setVisible(true);
-
- Object value = importExportForm.getRadioButtons().getSelectedValue();
- // if action confirmed
- if (value != null){
- String mode = (String) value;
- FileChooseView fileChooseView = new FileChooseView(view);
-
- JFileChooser chooser = fileChooseView.getChooser();
- ImportExport importExport = ImportExport.getInstance();
-
- try {
- if (mode.equals("import")){
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
- String filePath = chooser.getSelectedFile().getAbsolutePath();
- String message = importExport.importFromCsvFile(filePath, "");
- DialogHelper.showReportDialog(message, _("lima.importexport.import"), view);
- }
- }
- else {
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
- String filePath = chooser.getSelectedFile().getAbsolutePath();
- importExport.exportToCsvFile(filePath, "");
- }
- }
- } catch (LimaException eee) {
- if (log.isErrorEnabled()){
- log.error("Can't "+ mode +" this file", eee);
- }
- DialogHelper.showMessageDialog(eee.getMessage());
- }
- }
- }
-
-}
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-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-07-12 10:37:10 UTC (rev 2966)
@@ -23,6 +23,7 @@
<script><![CDATA[
import java.util.Locale;
import org.chorem.lima.LimaConfig;
+import org.chorem.lima.ui.importexport.ImportExportEnum;
public LimaConfig getConfig() {
return getContextValue(LimaConfig.class);
@@ -77,20 +78,32 @@
</script>
<JMenuBar>
+
<JMenu text="lima.menu.file">
- <JMenuItem text="lima.common.importexport" onActionPerformed='getHandler().showImportExportView(this)'/>
- <!-- <JMenu text="lima.import" actionIcon='import-element'>
- <JMenuItem text="lima.import.all" onActionPerformed='getHandler().showImportView("all")'/>
- <JMenuItem text="lima.import.all.csv" onActionPerformed='getHandler().showImportView("all_csv")'/>
- <JMenuItem text="lima.import.all.csv.ebp" onActionPerformed='getHandler().showImportView("all_csv_ebp")'/>
- <JMenuItem text="lima.import.account" onActionPerformed='getHandler().showImportView("account")'/>
- <JMenuItem text="lima.import.journal" onActionPerformed='getHandler().showImportView("journal")'/>
- </JMenu>
- <JMenu text="lima.export" actionIcon='export-element'>
- <JMenuItem text="lima.export.all" onActionPerformed='getHandler().showExportView("all")'/>
- <JMenuItem text="lima.export.all.csv" onActionPerformed='getHandler().showExportView("all_csv")'/>
- <JMenuItem text="lima.export.account" onActionPerformed='getHandler().showExportView("account")'/>
- </JMenu> -->
+ <JMenu text="lima.importexport.lima">
+ <JMenu text="lima.importexport.import" actionIcon='import-element'>
+ <JMenuItem text="lima.importexport.all" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ALL_IMPORT)'/>
+ <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ACCOUNTCHARTS_IMPORT)'/>
+ <JMenuItem text="lima.importexport.entrybooks" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ENTRYBOOKS_IMPORT)'/>
+ <JMenuItem text="lima.importexport.financialstatements" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_FINANCIALSTATEMENTS_IMPORT)'/>
+ </JMenu>
+ <JMenu text="lima.importexport.export" actionIcon='export-element'>
+ <JMenuItem text="lima.importexport.all" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ALL_EXPORT)'/>
+ <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ACCOUNTCHARTS_EXPORT)'/>
+ <JMenuItem text="lima.importexport.entrybooks" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ENTRYBOOKS_EXPORT)'/>
+ <JMenuItem text="lima.importexport.financialstatements" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_FINANCIALSTATEMENTS_EXPORT)'/>
+ </JMenu>
+ </JMenu>
+ <JMenu text="lima.importexport.ebp">
+ <JMenu text="lima.importexport.import" actionIcon='import-element'>
+ <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT)'/>
+ <JMenuItem text="lima.importexport.entries" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ENTRIES_IMPORT)'/>
+ </JMenu>
+ <JMenu text="lima.importexport.export" actionIcon='export-element'>
+ <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ACCOUNTCHARTS_EXPORT)'/>
+ <JMenuItem text="lima.importexport.entries" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ENTRIES_EXPORT)'/>
+ </JMenu>
+ </JMenu>
<JSeparator/>
<JMenuItem text="lima.common.print" actionIcon='print'/>
<JSeparator/>
@@ -118,19 +131,22 @@
<JMenu text="lima.structure">
<JMenuItem text="lima.charts.account" onActionPerformed='getHandler().showAccountView(this)'
- actionIcon='account'/>
+ actionIcon='charts-accounts'/>
<JMenuItem text="lima.charts.entrybook" onActionPerformed='getHandler().showEntryBookView(this)'
- actionIcon='journal'/>
- <JMenuItem text="lima.charts.fiscalyear" onActionPerformed='getHandler().showFiscalPeriodView(this)'/>
- <JMenuItem text="lima.charts.financialperiod" onActionPerformed='getHandler().showFinancialPeriodView(this)'/>
- <JMenuItem text="lima.charts.financialstatement" onActionPerformed='getHandler().showFinancialStatementView(this)'/>
+ actionIcon='charts-entrybooks'/>
+ <JMenuItem text="lima.charts.fiscalyear" onActionPerformed='getHandler().showFiscalPeriodView(this)'
+ actionIcon='charts-fiscalperiod'/>
+ <JMenuItem text="lima.charts.financialperiod" onActionPerformed='getHandler().showFinancialPeriodView(this)'
+ actionIcon='charts-financialperiod'/>
+ <JMenuItem text="lima.charts.financialstatement" onActionPerformed='getHandler().showFinancialStatementView(this)'
+ actionIcon='charts-financialstatements'/>
</JMenu>
<JMenu text="lima.entries">
<JMenuItem text="lima.entries.addtransaction" onActionPerformed='getHandler().showTransactionView(this)'
- actionIcon='transaction'/>
+ actionIcon='entries-balanced'/>
<JMenuItem text="lima.entries.searchunbalancedtransaction" onActionPerformed='getHandler().showTransactionUnbalancedView(this)'
- actionIcon='search'/>
+ actionIcon='entries-unbalanced'/>
<JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)'
actionIcon='lettering'/>
</JMenu>
@@ -142,11 +158,16 @@
</JMenu>
-->
<JMenu text="lima.reports">
- <JMenuItem text="lima.reports.accounts" onActionPerformed='getHandler().showAccountReports(this)'/>
- <JMenuItem text="lima.reports.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)'/>
- <JMenuItem text="lima.reports.balance" onActionPerformed='getHandler().showBalanceView(this)'/>
- <JMenuItem text="lima.reports.ledger" onActionPerformed='getHandler().showLedgerView(this)'/>
- <JMenuItem text="lima.reports.financialstatement" onActionPerformed='getHandler().showFinancialStatementReportsView(this)' actionIcon='rapport'/>
+ <JMenuItem text="lima.reports.accounts" onActionPerformed='getHandler().showAccountReports(this)'
+ actionIcon='reports-account'/>
+ <JMenuItem text="lima.reports.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)'
+ actionIcon='reports-entrybook'/>
+ <JMenuItem text="lima.reports.balance" onActionPerformed='getHandler().showBalanceView(this)'
+ actionIcon='reports-balance'/>
+ <JMenuItem text="lima.reports.ledger" onActionPerformed='getHandler().showLedgerView(this)'
+ actionIcon='reports-ledger'/>
+ <JMenuItem text="lima.reports.financialstatement" onActionPerformed='getHandler().showFinancialStatementReportsView(this)'
+ actionIcon='reports-financialstatement'/>
</JMenu>
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-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -44,6 +44,8 @@
import org.chorem.lima.ui.financialtransaction.LetteringView;
import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedView;
import org.chorem.lima.ui.home.HomeView;
+import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.ui.importexport.ImportExportEnum;
import org.chorem.lima.ui.ledger.LedgerView;
import org.chorem.lima.util.ErrorHelper;
@@ -383,10 +385,10 @@
mainView.showTab(_("lima.reports.financialstatement"), financialStatementReportView);
}
- public void showImportExportView(JAXXContext rootContext) {
+ public void showImportExportView(JAXXContext rootContext, ImportExportEnum type) {
MainView mainView = getUI(rootContext);
- ImportExportHandler importExportHandler = new ImportExportHandler(mainView);
- importExportHandler.importexportDialog();
+ ImportExport importExport = ImportExport.getInstance(mainView);
+ importExport.importExport(type);
}
public void showExportView(String type) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -19,7 +19,6 @@
package org.chorem.lima.ui.account;
import static org.nuiton.i18n.I18n._;
-import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.tree.TreePath;
import org.apache.commons.logging.Log;
@@ -30,14 +29,14 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.ImportExportForm;
import org.chorem.lima.ui.account.AccountForm;
import org.chorem.lima.ui.account.AccountView;
import org.chorem.lima.ui.account.SubLedgerForm;
+import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.ui.importexport.ImportExportEnum;
+import org.chorem.lima.ui.importexport.ImportExportForm;
import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
-import org.chorem.lima.util.FileChooseView;
-import org.chorem.lima.util.ImportExport;
import org.jdesktop.swingx.JXTreeTable;
/**
@@ -261,31 +260,19 @@
// if action confirmed
if (value != null){
String mode = (String) value;
- FileChooseView fileChooseView = new FileChooseView(view);
+ ImportExport importExport = ImportExport.getInstance(view);
- JFileChooser chooser = fileChooseView.getChooser();
- ImportExport importExport = ImportExport.getInstance();
-
try {
if (mode.equals("import")){
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
- String filePath = chooser.getSelectedFile().getAbsolutePath();
- String message = importExport.importFromCsvFile(filePath, "importAccountsChart");
+ importExport.importExport(ImportExportEnum.LIMA_ACCOUNTCHARTS_IMPORT);
accountsTreeTableModel.refreshTree();
- DialogHelper.showReportDialog(message, _("lima.importexport.import"), view);
- }
}
else {
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
- String filePath = chooser.getSelectedFile().getAbsolutePath();
- importExport.exportToCsvFile(filePath, "exportAccountsChart");
- }
+ importExport.importExport(ImportExportEnum.LIMA_ACCOUNTCHARTS_EXPORT);
}
} catch (LimaException eee) {
if (log.isErrorEnabled()){
- log.error("Can't "+ mode +" this file", eee);
+ log.error("Can't refresh tree", eee);
}
DialogHelper.showMessageDialog(eee.getMessage());
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -19,17 +19,16 @@
package org.chorem.lima.ui.entrybook;
import static org.nuiton.i18n.I18n._;
-import javax.swing.JFileChooser;
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.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
-import org.chorem.lima.ui.ImportExportForm;
+import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.ui.importexport.ImportExportEnum;
+import org.chorem.lima.ui.importexport.ImportExportForm;
import org.chorem.lima.util.DialogHelper;
-import org.chorem.lima.util.FileChooseView;
-import org.chorem.lima.util.ImportExport;
import org.jdesktop.swingx.JXTable;
/**
@@ -153,35 +152,16 @@
Object value = importExportForm.getRadioButtons().getSelectedValue();
// if action confirmed
if (value != null){
- String mode = (String) value;
- FileChooseView fileChooseView = new FileChooseView(view);
+ String mode = (String) value;
+ ImportExport importExport = ImportExport.getInstance(view);
- JFileChooser chooser = fileChooseView.getChooser();
- ImportExport importExport = ImportExport.getInstance();
-
- try {
- if (mode.equals("import")){
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
- String filePath = chooser.getSelectedFile().getAbsolutePath();
- String message = importExport.importFromCsvFile(filePath, "importEntryBookChart");
- entryBookTableModel.refreshTable();
- DialogHelper.showReportDialog(message, _("lima.importexport.import"), view);
- }
- }
- else {
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
- String filePath = chooser.getSelectedFile().getAbsolutePath();
- importExport.exportToCsvFile(filePath, "exportEntryBookChart");
- }
- }
- } catch (LimaException eee) {
- if (log.isErrorEnabled()){
- log.error("Can't "+ mode +" this file", eee);
- }
- DialogHelper.showMessageDialog(eee.getMessage());
- }
- }
- }
+ if (mode.equals("import")){
+ importExport.importExport(ImportExportEnum.LIMA_ENTRYBOOKS_IMPORT);
+ entryBookTableModel.refreshTable();
+ }
+ else {
+ importExport.importExport(ImportExportEnum.LIMA_ENTRYBOOKS_EXPORT);
+ }
+ }
+ }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -28,13 +28,14 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementImpl;
-import org.chorem.lima.ui.ImportExportForm;
import org.chorem.lima.ui.financialstatementchart.FinancialStatementHeaderForm;
import org.chorem.lima.ui.financialstatementchart.FinancialStatementMovementForm;
+import org.chorem.lima.ui.importexport.ImportExport;
+import org.chorem.lima.ui.importexport.ImportExportEnum;
+import org.chorem.lima.ui.importexport.ImportExportForm;
import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
import org.chorem.lima.util.FileChooseView;
-import org.chorem.lima.util.ImportExport;
import org.jdesktop.swingx.JXTreeTable;
/**
@@ -249,11 +250,7 @@
}
public void importexportFinancialStatement(){
-
- JXTreeTable treeTable = view.getTreeTable();
- FinancialStatementChartTreeTableModel treeTableModel =
- (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel();
-
+
ImportExportForm importExportForm = new ImportExportForm(view);
importExportForm.setLocationRelativeTo(view);
importExportForm.setVisible(true);
@@ -262,34 +259,13 @@
// if action confirmed
if (value != null){
String mode = (String) value;
- FileChooseView fileChooseView = new FileChooseView(view);
-
- JFileChooser chooser = fileChooseView.getChooser();
- ImportExport importExport = ImportExport.getInstance();
-
- try {
- if (mode.equals("import")){
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
- String filePath = chooser.getSelectedFile().getAbsolutePath();
- String message = importExport.importFromCsvFile(filePath, "importFinancialStatementsChart");
- treeTableModel.refreshTree();
- DialogHelper.showReportDialog(message, _("lima.importexport.import"), view);
- }
- }
- else {
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
- String filePath = chooser.getSelectedFile().getAbsolutePath();
- importExport.exportToCsvFile(filePath, "exportFinancialStatementsChart");
- }
- }
- } catch (LimaException eee) {
- if (log.isErrorEnabled()){
- log.error("Can't "+ mode +" this file", eee);
- }
- DialogHelper.showMessageDialog(eee.getMessage());
- }
+ ImportExport importExport = ImportExport.getInstance(view);
+ if (mode.equals("import")){
+ importExport.importExport(ImportExportEnum.LIMA_FINANCIALSTATEMENTS_IMPORT);
+ }
+ else {
+ importExport.importExport(ImportExportEnum.LIMA_FINANCIALSTATEMENTS_EXPORT);
+ }
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx 2010-07-12 10:37:10 UTC (rev 2966)
@@ -1,68 +1,104 @@
<Table>
<HomeViewHandler id="handler" javaBean='new HomeViewHandler(this)' />
- <Dimension id="fixedSize" javaBean='new Dimension(600,150)' />
+ <Dimension id="fixedSize" javaBean='new Dimension(500,200)' />
+ <Dimension id="miniSize" javaBean='new Dimension(300,150)' />
+ <Color id="green" javaBean='new Color(0xee, 0xff, 0xee)'/>
+
+
<script>
<![CDATA[
import static org.nuiton.i18n.I18n._;
+ import java.awt.Color;
+ import java.awt.Font;
void $afterCompleteSetup() {
getHandler().refresh();
}
]]>
</script>
- <row weightx="1" weighty="1" anchor="west">
- <cell>
- <JLabel font='{new Font("Arial", 0, 16)}' text="LIMA"/>
- </cell>
- </row>
- <row weightx="1" weighty="1">
- <cell>
+ <row>
+ <cell anchor="southeast">
<JPanel id="limaHomeChartAccount"
- border='{BorderFactory.createTitledBorder(_("lima.charts.account"))}'
- minimumSize='{getFixedSize()}'
+ border='{BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)}'
+ minimumSize='{getMiniSize()}'
preferredSize='{getFixedSize()}'
layout='{new BoxLayout(limaHomeChartAccount,BoxLayout.X_AXIS)}'>
- <JEditorPane id="textHomeAccount"/>
+ <Table>
+ <row>
+ <cell weightx="0" weighty="0.1" anchor="northwest"><JLabel icon='{new ImageIcon(getClass().getResource("/images/accounts.png"))}'/></cell>
+ <cell weightx="1" weighty="0.1" anchor="center"><JLabel foreground='{Color.DARK_GRAY}' font='{new Font("sans-serif", Font.BOLD, 16)}' text='lima.charts.account'/></cell>
+ </row>
+ <row fill="both">
+ <cell columns="2" weightx="1" weighty="0.9">
+ <JEditorPane id="textHomeAccount"
+ opaque="true" contentType="text/html" editable="false" UI="{new javax.swing.plaf.basic.BasicEditorPaneUI()}" background="{getGreen()}"/>
+ </cell>
+ </row>
+ </Table>
</JPanel>
</cell>
- </row>
- <row>
- <cell>
+ <cell anchor="southwest">
<JPanel id="limaHomeEntryBook"
- border='{BorderFactory.createTitledBorder(_("lima.charts.entrybook"))}'
- minimumSize='{getFixedSize()}'
+ border='{BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)}'
+ minimumSize='{getMiniSize()}'
preferredSize='{getFixedSize()}'
layout='{new BoxLayout(limaHomeEntryBook,BoxLayout.X_AXIS)}'>
- <JEditorPane id="textHomeEntryBook"/>
+ <Table>
+ <row>
+ <cell weightx="0" weighty="0.1" anchor="northwest"><JLabel icon='{new ImageIcon(getClass().getResource("/images/entrybooks.png"))}'/></cell>
+ <cell weightx="1" weighty="0.1" anchor="center"><JLabel foreground='{Color.DARK_GRAY}' font='{new Font("sans-serif", Font.BOLD, 16)}' text='lima.charts.entrybook'/></cell>
+ </row>
+ <row fill="both">
+ <cell columns="2" weightx="1" weighty="0.9">
+ <JEditorPane id="textHomeEntryBook"
+ opaque="true" contentType="text/html" editable="false" UI="{new javax.swing.plaf.basic.BasicEditorPaneUI()}" background="{getGreen()}"/>
+ </cell>
+ </row>
+ </Table>
</JPanel>
</cell>
</row>
<row>
- <cell>
+ <cell anchor="northeast">
<JPanel id="limaHomeFiscalYear"
- border='{BorderFactory.createTitledBorder(_("lima.charts.fiscalyear"))}'
- minimumSize='{getFixedSize()}'
+ border='{BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)}'
+ minimumSize='{getMiniSize()}'
preferredSize='{getFixedSize()}'
layout='{new BoxLayout(limaHomeFiscalYear,BoxLayout.X_AXIS)}'>
- <JEditorPane id="textHomeFiscalYear"/>
+ <Table>
+ <row>
+ <cell weightx="0" weighty="0.1" anchor="northwest"><JLabel icon='{new ImageIcon(getClass().getResource("/images/fiscalperiods.png"))}'/></cell>
+ <cell weightx="1" weighty="0.1" anchor="center"><JLabel foreground='{Color.DARK_GRAY}' font='{new Font("sans-serif", Font.BOLD, 16)}' text='lima.charts.fiscalyear'/></cell>
+ </row>
+ <row fill="both">
+ <cell columns="2" weightx="1" weighty="0.9">
+ <JEditorPane id="textHomeFiscalYear"
+ opaque="true" contentType="text/html" editable="false" UI="{new javax.swing.plaf.basic.BasicEditorPaneUI()}" background="{getGreen()}"/>
+ </cell>
+ </row>
+ </Table>
</JPanel>
</cell>
- </row>
- <row>
- <cell>
+ <cell anchor="northwest">
<JPanel id="limaHomeDaily"
- border='{BorderFactory.createTitledBorder(_("lima.daily"))}'
- minimumSize='{getFixedSize()}'
+ border='{BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)}'
+ minimumSize='{getMiniSize()}'
preferredSize='{getFixedSize()}'
layout='{new BoxLayout(limaHomeDaily,BoxLayout.X_AXIS)}'>
- <JEditorPane id="textHomeDaily"/>
+ <Table>
+ <row>
+ <cell weightx="0" weighty="0.1" anchor="northwest"><JLabel icon='{new ImageIcon(getClass().getResource("/images/entries.png"))}'/></cell>
+ <cell weightx="1" weighty="0.1" anchor="center"><JLabel foreground='{Color.DARK_GRAY}' font='{new Font("sans-serif", Font.BOLD, 16)}' text='lima.daily'/></cell>
+ </row>
+ <row fill="both">
+ <cell columns="2" weightx="1" weighty="0.9">
+ <JEditorPane id="textHomeDaily"
+ opaque="true" contentType="text/html" editable="false" UI="{new javax.swing.plaf.basic.BasicEditorPaneUI()}" background="{getGreen()}"/>
+ </cell>
+ </row>
+ </Table>
</JPanel>
</cell>
</row>
- <row weightx="1" weighty="1" anchor="west">
- <cell>
- <JLabel icon='{new ImageIcon(getClass().getResource("/images/logo-codelutin.png"))}'/>
- </cell>
- </row>
</Table>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -2,10 +2,17 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Color;
+import java.awt.Font;
import java.util.List;
+import javax.swing.BorderFactory;
import javax.swing.JEditorPane;
+import javax.swing.JPanel;
+import javax.swing.border.Border;
+import javax.swing.border.EtchedBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
+import javax.swing.plaf.basic.BasicEditorPaneUI;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
@@ -21,6 +28,8 @@
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
+import com.sun.codemodel.internal.JLabel;
+
public class HomeViewHandler implements HyperlinkListener {
private static final Log log = LogFactory.getLog(HomeViewHandler.class);
@@ -38,10 +47,8 @@
protected HyperlinkListener accountsListener;
protected HyperlinkListener entrybookListener;
-
- private Color greenBackground;
- private Color redBackground;
+ private static Color redBackground = new Color(0xff, 0xee, 0xee);
protected HomeViewHandler(HomeView view) {
@@ -57,11 +64,7 @@
LimaServiceFactory.getInstance().getTransactionService();
fiscalPeriodService =
LimaServiceFactory.getInstance().getFiscalPeriodService();
-
- greenBackground = new Color(153, 255, 153);
- redBackground = new Color(255, 102, 102);
-
}
@@ -98,52 +101,76 @@
public void refresh(){
-
+ //Get all editorpanes
+ JEditorPane accountPane = view.getTextHomeAccount();
+ JEditorPane entryBookPane = view.getTextHomeEntryBook();
+ JEditorPane fiscalYearPane = view.getTextHomeFiscalYear();
+ JEditorPane dailyPane = view.getTextHomeDaily();
+
+ //add hyperlink listener
+ accountPane.addHyperlinkListener(this);
+ entryBookPane.addHyperlinkListener(this);
+ fiscalYearPane.addHyperlinkListener(this);
+ dailyPane.addHyperlinkListener(this);
+ String htmlBegin = "<font face='sans-serif' size=3><p style=vertical-align:'bottom', horizontal-align:'center'>";
+ String htmlEnd = "</p></font>";
+
try {
- //ACCOUNT
+
+ //ACCOUNTS CHART
List<Account> accounts = accountService.getAllAccounts();
- JEditorPane accountPane = view.getTextHomeAccount();
- accountPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI());
- accountPane.setOpaque(true);
- accountPane.setContentType("text/html");
- accountPane.setEditable(false);
- accountPane.addHyperlinkListener(this);
if (accounts.size()>0){
- String accountsString = _("limahome.chartaccounts1") + " " +
- accounts.size() + " " + _("limahome.chartaccounts2");
- accountPane.setBackground(greenBackground);
- accountPane.setText("<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#accountschart'>"+accountsString+"</a></p>");
+ String accountsString = _("limahome.chartaccounts.state1_2") + " "
+ + accounts.size() + " " + _("limahome.chartaccounts.state2_2")
+ + "<br/><br/><a href='#accountschart'>"
+ + _("limahome.chartaccounts.modify") + "</a>";
+ //set Text
+ accountPane.setText(htmlBegin + accountsString + htmlEnd);
}
else {
accountPane.setBackground(redBackground);
- String accountsString = "<p style=vertical-align:'bottom', horizontal-align:'center'>"+_("limahome.fiscalperiodnoopen") +
- "<br/><a href='#accountschart'>"+_("limahome.createchartaccounts")+"</a>";
- accountPane.setText(accountsString+"</p>");
+ String accountsString = _("limahome.chartaccounts.nothing")
+ + "<br/><br/><a href='#accountschart'>"
+ + _("limahome.chartaccounts.create") + "</a>";
+ //set Text
+ accountPane.setText(htmlBegin + accountsString + htmlEnd);
}
- //ENTRYBOOK
+
+ //ENTRYBOOKS
List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
- JEditorPane entryBookPane = view.getTextHomeEntryBook();
- entryBookPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI());
- entryBookPane.setOpaque(true);
- entryBookPane.setContentType("text/html");
- entryBookPane.setEditable(false);
- entryBookPane.addHyperlinkListener(this);
-
- if (entryBooks.size()>0){
- entryBookPane.setBackground(greenBackground);
- String entryBooksString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#entrybookschart'>"+_("limahome.entrybooks1") +
- " " + entryBooks.size() + " " + _("limahome.entrybooks2") +
- "</a><br/><ul>";
- for (EntryBook entryBook : entryBooks) {
- entryBooksString += "<li>"+entryBook.getCode() +
- " - "+entryBook.getLabel()+"</li>";
+ int ebSize = entryBooks.size();
+ if (ebSize>0){
+ String entryBooksString="";
+ if (ebSize == 1){
+ entryBooksString = _("limahome.entrybooks.state.single")
+ + "<br/>" + entryBooks.get(0)
+ + "<br/><br/><a href='#entrybookschart'>"
+ + _("limahome.entrybooks.modify") + "</a>";
+
}
- entryBookPane.setText(entryBooksString+"</ul>"+"</p>");
+ else {
+ entryBooksString = _("limahome.entrybooks.state1_2.plural")
+ + " " + entryBooks.size() + " "
+ + _("limahome.entrybooks.state2_2.plural") + "<ul>";
+ for (EntryBook entryBook : entryBooks) {
+ entryBooksString += "<li>"+entryBook.getCode() +
+ " - "+entryBook.getLabel()+"</li>";
+ }
+ entryBooksString += "</ul></p><p horizontal-align:'center'>"
+ + "<a href='#entrybookschart'>"
+ + _("limahome.entrybooks.modify") + "</a>";
+ }
+ //set Text
+ entryBookPane.setText(htmlBegin + entryBooksString + htmlEnd);
}
else {
entryBookPane.setBackground(redBackground);
- entryBookPane.setText("<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#entrybookschart'>"+_("limahome.entrybooknoopen")+"</a></p>");
+ //set Text
+ entryBookPane.setText(htmlBegin
+ + _("limahome.entrybooks.nothing")
+ + "<br/><br/><a href='#entrybookschart'>"
+ + _("limahome.entrybooks.create") +"</a>" + htmlEnd);
}
//FISCAL PERIOD
@@ -151,58 +178,49 @@
fiscalPeriodService.getAllFiscalPeriods();
List<FiscalPeriod> unblockedFiscalPeriods =
fiscalPeriodService.getAllUnblockedFiscalPeriods();
-
- JEditorPane fiscalYearPane = view.getTextHomeFiscalYear();
- fiscalYearPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI());
- fiscalYearPane.setOpaque(true);
- fiscalYearPane.setContentType("text/html");
- fiscalYearPane.setEditable(false);
- fiscalYearPane.addHyperlinkListener(this);
-
- JEditorPane dailyPane = view.getTextHomeDaily();
- dailyPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI());
- dailyPane.setOpaque(true);
- dailyPane.setContentType("text/html");
- dailyPane.setEditable(false);
- dailyPane.addHyperlinkListener(this);
-
if (unblockedFiscalPeriods.size()>0){
- fiscalYearPane.setBackground(greenBackground);
- String fiscalString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#fiscalperiodschart'>"
- + unblockedFiscalPeriods.size() +
- " " + _("limahome.fiscalperiodopened")+"<br/>" +
- (fiscalPeriods.size()-unblockedFiscalPeriods.size()) +
- " " + _("limahome.fiscalperiodclosed");
- fiscalYearPane.setText(fiscalString+"</a></p>");
+ String fiscalString = unblockedFiscalPeriods.size() + " "
+ + _("limahome.fiscalperiod.opened") + "<br/>"
+ + (fiscalPeriods.size()-unblockedFiscalPeriods.size())
+ + " " + _("limahome.fiscalperiod.closed")
+ + "<br/><br/><a href='#fiscalperiodschart'>"
+ + _("limahome.fiscalperiod.modify") + "</a>";
+ //set Text
+ fiscalYearPane.setText(htmlBegin + fiscalString + htmlEnd);
- //FINACIAL TRANSACTION
+ //FINANCIAL TRANSACTION
List<FinancialTransaction> financialTransactions =
financialTransactionService.
getAllFinancialTransactionsUnbalanced(fiscalPeriods.get(0));
if (financialTransactions.size()>0){
dailyPane.setBackground(redBackground);
- String transactionsString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#financialtransactionunbalanced'>"
- + financialTransactions.size() +
- _("limahome.transactionunbalanced")+"</a></p>";
- dailyPane.setText(transactionsString);
+ String transactionsString = financialTransactions.size()
+ + " " + _("limahome.transaction.unbalanced")
+ + "<br/><br/><a href='#financialtransactionunbalanced'>"
+ + _("limahome.transaction.modifiy") + "</a>";
+ //set Text
+ dailyPane.setText(htmlBegin + transactionsString + htmlEnd);
}
else {
- dailyPane.setBackground(greenBackground);
- String transactionsString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#financialtransactionbalanced'>"
- + _("limahome.transactionbalanced");
- dailyPane.setText(transactionsString+"</a></p>");
+ String transactionsString = _("limahome.transaction.balanced")
+ + "<br/><br/><a href='#financialtransactionbalanced'>"
+ + _("limahome.transaction.create") + "</a>";
+ //set Text
+ dailyPane.setText(htmlBegin + transactionsString + htmlEnd);
}
-
}
else {
fiscalYearPane.setBackground(redBackground);
dailyPane.setBackground(redBackground);
- String fiscalString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#fiscalperiodschart'>" + _("limahome.fiscalperiodnoopen");
+ String fiscalString = _("limahome.fiscalperiod.noopen");
if (fiscalPeriods.size()>0){
- fiscalString += fiscalPeriods.size() +
- _("limahome.fiscalperiodclosed");
+ fiscalString += "<br/>" + fiscalPeriods.size() + " "
+ + _("limahome.fiscalperiod.closed");
}
- fiscalYearPane.setText(fiscalString+"</a></p>");
+ fiscalString += "<br/><br/><a href='#fiscalperiodschart'>"
+ + _("limahome.fiscalperiod.create") + "</a>";
+ //set Text
+ fiscalYearPane.setText(htmlBegin + fiscalString + htmlEnd);
}
} catch (LimaException eee) {
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java (from rev 2964, trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -0,0 +1,223 @@
+/* *##% 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.importexport;
+
+import static org.nuiton.i18n.I18n._;
+import java.awt.Component;
+import java.io.BufferedInputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import javax.swing.JFileChooser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ExportService;
+import org.chorem.lima.business.ImportService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.account.AccountViewHandler;
+import org.chorem.lima.util.DialogHelper;
+import org.chorem.lima.util.FileChooseView;
+
+public class ImportExport {
+
+ private static ImportExport exchanger;
+
+ private static final Log log = LogFactory.getLog(AccountViewHandler.class);
+
+ protected static Component viewComponent;
+
+ protected ImportService importService;
+
+ protected ExportService exportService;
+
+ public ImportExport(Component view) {
+ viewComponent=view;
+ importService = LimaServiceFactory.getInstance().getImportService();
+ exportService = LimaServiceFactory.getInstance().getExportService();
+ }
+
+
+ public void importExport(ImportExportEnum importExportMethode){
+ String result = "";
+ String datas = "";
+ String filePath = "";
+ String charset = "UTF-8";
+ try {
+ switch (importExportMethode) {
+ case LIMA_ALL_EXPORT:
+ filePath = chooseFile(false);
+ datas = exportService.exportAsCSV();
+ createFile(filePath, charset, datas);
+ break;
+ case LIMA_ACCOUNTCHARTS_EXPORT:
+ filePath = chooseFile(false);
+ datas = exportService.exportAccountsChartAsCSV();
+ createFile(filePath, charset, datas);
+ break;
+ case LIMA_ENTRYBOOKS_EXPORT:
+ filePath = chooseFile(false);
+ datas = exportService.exportEntryBookChartAsCSV();
+ createFile(filePath, charset, datas);
+ break;
+ case LIMA_FINANCIALSTATEMENTS_EXPORT:
+ filePath = chooseFile(false);
+ datas = exportService.exportFinancialStatementChartAsCSV();
+ createFile(filePath, charset, datas);
+ break;
+ case EBP_ACCOUNTCHARTS_EXPORT:
+ //For windows ebp
+ filePath = chooseFile(false);
+ charset = "ISO-8859-1";
+ datas = exportService.exportAccountsAsEBP();
+ createFile(filePath, charset, datas);
+ break;
+ case EBP_ENTRIES_EXPORT:
+ //For windows ebp
+ charset = "ISO-8859-1";
+ filePath = chooseFile(false);
+ datas = exportService.exportEntriesAsEBP();
+ createFile(filePath, charset, datas);
+ break;
+ case LIMA_ALL_IMPORT:
+ filePath = chooseFile(true);
+ datas = extractFile(filePath);
+ result = importService.importCSV(datas);
+ break;
+ case LIMA_ACCOUNTCHARTS_IMPORT:
+ filePath = chooseFile(true);
+ datas = extractFile(filePath);
+ result = importService.importAccountsChartAsCSV(datas);
+ break;
+ case LIMA_ENTRYBOOKS_IMPORT:
+ filePath = chooseFile(true);
+ datas = extractFile(filePath);
+ result = importService.importEntryBooksChartAsCSV(datas);
+ break;
+ case LIMA_FINANCIALSTATEMENTS_IMPORT:
+ filePath = chooseFile(true);
+ datas = extractFile(filePath);
+ result = importService.importFinancialStatementsChartAsCSV(datas);
+ break;
+ case EBP_ACCOUNTCHARTS_IMPORT:
+ filePath = chooseFile(true);
+ datas = extractFile(filePath);
+ break;
+ case EBP_ENTRIES_IMPORT:
+ filePath = chooseFile(true);
+ datas = extractFile(filePath);
+ break;
+ }
+ if (!result.equals("")){
+ DialogHelper.showReportDialog(result, _("lima.importexport.import"), viewComponent);
+ }
+ else {
+ DialogHelper.showMessageDialog(_("lima.importexport.import.terminated"));
+ }
+ }
+ catch (LimaException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't call export import service ", eee);
+ }
+ }
+
+
+ }
+
+
+
+ public String chooseFile(Boolean importMode){
+ String filePath = "";
+ FileChooseView fileChooseView = new FileChooseView();
+ JFileChooser chooser = fileChooseView.getChooser();
+
+ if (importMode){
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) {
+ filePath = chooser.getSelectedFile().getAbsolutePath();
+ }
+ }
+ else {
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) {
+ filePath = chooser.getSelectedFile().getAbsolutePath();
+ }
+ }
+ return filePath;
+ }
+
+
+
+ /**
+ * Get csv datas in string and write file
+ *
+ */
+ public void createFile(String filePath, String charset, String datas){
+ try {
+ File file = new File(filePath);
+ BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset));
+ out.write(datas);
+ out.flush();
+ out.close();
+ }
+ catch (IOException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't write file " + filePath, eee);
+ }
+ }
+ }
+
+
+
+ /**
+ * Open csv file and get his datas on a string
+ *
+ */
+ public String extractFile(String path){
+ byte[] buffer = new byte[(int) new File(path).length()];
+ try {
+ BufferedInputStream f = new BufferedInputStream(new FileInputStream(path));
+ f.read(buffer);
+ f.close();
+ }
+ catch (IOException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't read file "+path, eee);
+ }
+ }
+ return new String(buffer);
+ }
+
+
+
+ public static ImportExport getInstance(Component view) {
+ if (exchanger == null) {
+ exchanger = new ImportExport(view);
+ }
+ else {
+ viewComponent=view;
+ }
+ return exchanger;
+ }
+
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -0,0 +1,9 @@
+package org.chorem.lima.ui.importexport;
+
+public enum ImportExportEnum {
+ LIMA_ALL_EXPORT, LIMA_ALL_IMPORT,
+ LIMA_ACCOUNTCHARTS_EXPORT, LIMA_ENTRYBOOKS_EXPORT, LIMA_FINANCIALSTATEMENTS_EXPORT,
+ LIMA_ACCOUNTCHARTS_IMPORT, LIMA_ENTRYBOOKS_IMPORT, LIMA_FINANCIALSTATEMENTS_IMPORT,
+ EBP_ACCOUNTCHARTS_EXPORT, EBP_ENTRIES_EXPORT,
+ EBP_ACCOUNTCHARTS_IMPORT, EBP_ENTRIES_IMPORT;
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportForm.jaxx (from rev 2959, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportForm.jaxx 2010-07-12 10:37:10 UTC (rev 2966)
@@ -0,0 +1,50 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<JDialog modal="true">
+
+ <jaxx.runtime.swing.JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/>
+ <Boolean id="addState" javaBean='true'/>
+
+ <script>
+ <![CDATA[
+ protected void performCancel() {
+ getRadioButtons().setSelectedValue(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row>
+ <cell>
+ <JRadioButton text='lima.importexport.export' value='export' buttonGroup="{getRadioButtons()}"
+ selected='true'/>
+ </cell>
+ <cell>
+ <JRadioButton text='lima.importexport.import' value='import' buttonGroup="{getRadioButtons()}"
+ selected='true'/>
+ </cell>
+ <cell fill="none">
+ <JButton text="lima.common.ok" onActionPerformed="dispose()"/>
+ </cell>
+ <cell fill="none">
+ <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-12 10:37:10 UTC (rev 2966)
@@ -1,134 +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.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.ExportService;
-import org.chorem.lima.business.ImportService;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.account.AccountViewHandler;
-
-public class ImportExport {
-
- private static ImportExport exchanger;
-
- private static final Log log = LogFactory.getLog(AccountViewHandler.class);
-
- protected ImportService importService;
-
- protected ExportService exportService;
-
- public ImportExport() {
- importService = LimaServiceFactory.getInstance().getImportService();
- exportService = LimaServiceFactory.getInstance().getExportService();
- }
-
- /**
- * Call export methode in business
- * Get csv datas in string and write file
- * @param path
- * @param exportMethode
- * @throws LimaException
- */
- public void exportToCsvFile(String path, String exportMethode) throws LimaException {
- String result = "";
- try {
- FileWriter f = new FileWriter(new File(path));
- if (exportMethode.equals("exportEntryBookChart")){
- result = exportService.exportEntryBookChartAsCSV();
- }
- else if (exportMethode.equals("exportAccountsChart")){
- result = exportService.exportAccountsChartAsCSV();
-
- }
- else if (exportMethode.equals("exportFinancialStatementsChart")){
- result = exportService.exportFinancialStatementChartAsCSV();
- }
- else {
- result = exportService.exportAsCSV();
- }
- f.write(result);
- f.flush();
- f.close();
- }
- catch (IOException eee) {
- if (log.isDebugEnabled()){
- log.debug("Can't write file "+path, eee);
- }
- }
- }
-
-
- /**
- * Open scv file and get his datas on a string
- * Call import methode in business
- *
- * @param path
- * @param importMethode
- * @return
- * @throws LimaException
- */
- public String importFromCsvFile(String path, String importMethode) throws LimaException {
- String result = "";
- byte[] buffer = new byte[(int) new File(path).length()];
- try {
- BufferedInputStream f = new BufferedInputStream(new FileInputStream(path));
- f.read(buffer);
-
- if (importMethode.equals("importEntryBookChart")){
- result = importService.importEntryBooksChartAsCSV(new String(buffer));
- }
- else if (importMethode.equals("importAccountsChart")){
- result = importService.importAccountsChartAsCSV(new String(buffer));
- }
- else if (importMethode.equals("importFinancialStatementsChart")){
- result = importService.importFinancialStatementsChartAsCSV(new String(buffer));
- }
- else {
- result = importService.importCSV(new String(buffer));
- }
- f.close();
- }
- catch (IOException eee) {
- if (log.isDebugEnabled()){
- log.debug("Can't read file "+path, eee);
- }
- }
-
- return result;
- }
-
- public static ImportExport getInstance() {
- if (exchanger == null) {
- exchanger = new ImportExport();
- }
- return exchanger;
- }
-
-}
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-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-07-12 10:37:10 UTC (rev 2966)
@@ -94,8 +94,16 @@
lima.import.all.csv=Import all datas (CSV)
lima.import.all.csv.ebp=Import all datas (EBP)
lima.import.journal=Import journal
+lima.importexport.accountcharts=
+lima.importexport.all=
+lima.importexport.ebp=
+lima.importexport.entries=
+lima.importexport.entrybooks=
lima.importexport.export=Export
+lima.importexport.financialstatements=
lima.importexport.import=Import
+lima.importexport.import.terminated=
+lima.importexport.lima=
lima.init.closed=Lima closed at %1$s
lima.init.errorclosing=
lima.lettering.add=
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-07-07 10:58:46 UTC (rev 2965)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-07-12 10:37:10 UTC (rev 2966)
@@ -94,8 +94,16 @@
lima.import.all.csv=Importer une nouvelle base (CSV)
lima.import.all.csv.ebp=Importer des donn\u00E9es de EBP
lima.import.journal=Importer le journal
+lima.importexport.accountcharts=Plan des comptes
+lima.importexport.all=Tout
+lima.importexport.ebp=Import/Export EBP
+lima.importexport.entries=\u00C9critures
+lima.importexport.entrybooks=Journaux
lima.importexport.export=Export
+lima.importexport.financialstatements=Plan BCR
lima.importexport.import=Import
+lima.importexport.import.terminated=Import
+lima.importexport.lima=Import/Export Lima
lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s
lima.init.errorclosing=
lima.lettering.add=Ajouter une lettre
@@ -176,16 +184,24 @@
lima.transaction.period=P\u00E9riode
lima.voucher=Document
lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9
-limahome.accountsnoopen=Aucun compte \!
-limahome.chartaccounts1=Le plan comptable possede
-limahome.chartaccounts2=comptes
-limahome.createchartaccounts=Cr\u00E9er le plan comptable
-limahome.entrybooknoopen=Aucun journal ouvert \!
-limahome.entrybooks1=Les
-limahome.entrybooks2=journaux sont \:
-limahome.fiscalperiodclosed=exercices clotur\u00E9s
-limahome.fiscalperiodnoopen=Aucun exercice ouvert \!
-limahome.fiscalperiodopened=exercices ouverts
-limahome.transactionbalanced=Toutes les entr\u00E9es sont \u00E9quilibr\u00E9es
-limahome.transactionunbalanced=ne sont pas \u00E9quilibr\u00E9e \!
+limahome.chartaccounts.nothing=Aucun compte \!
+limahome.chartaccounts.state1_2=Le plan comptable possede
+limahome.chartaccounts.state2_2=comptes
+limahome.chartaccounts.create=Cr\u00E9er le plan des comptes
+limahome.chartaccounts.modify=Modifier le plan des comptes
+limahome.entrybooks.nothing=Aucun journal ouvert \!
+limahome.entrybooks.modify=Modifier les journaux
+limahome.entrybooks.create=Cr\u00E9er les journaux
+limahome.entrybooks.state1_2.plural=Les
+limahome.entrybooks.state2_2.plural=journaux sont \:
+limahome.entrybooks.state.single=Le journal est \:
+limahome.fiscalperiod.closed=exercices clotur\u00E9s
+limahome.fiscalperiod.opened=exercices ouverts
+limahome.fiscalperiod.noopen=Aucun exercice ouvert \!
+limahome.fiscalperiod.create=Cr\u00E9er un exercice
+limahome.fiscalperiod.modify=Modifier les exercices
+limahome.transaction.balanced=Toutes les \u00E9critures sont \u00E9quilibr\u00E9es
+limahome.transaction.unbalanced=\u00E9critures ne sont pas \u00E9quilibr\u00E9es \!
+limahome.transaction.modifiy=Modifier les \u00E9critures non \u00E9quilibr\u00E9es
+limahome.transaction.create=Modifier les \u00E9critures
update=
Modified: trunk/lima-swing/src/main/resources/icons/action-about.png
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/resources/icons/action-account.png
===================================================================
(Binary files differ)
Added: trunk/lima-swing/src/main/resources/icons/action-charts-accounts.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-accounts.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-charts-entrybooks.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-entrybooks.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-charts-financialperiod.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-financialperiod.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-charts-financialstatements.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-financialstatements.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-charts-fiscalperiod.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-fiscalperiod.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/lima-swing/src/main/resources/icons/action-closeTab.png
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/resources/icons/action-closure-timespan.png
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/resources/icons/action-closure.png
===================================================================
(Binary files differ)
Added: trunk/lima-swing/src/main/resources/icons/action-entries-balanced.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-entries-balanced.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-entries-search.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-entries-search.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-entries-unbalanced.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-entries-unbalanced.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: trunk/lima-swing/src/main/resources/icons/action-journal.png
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/resources/icons/action-lettering.png
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/resources/icons/action-rapport.png
===================================================================
(Binary files differ)
Added: trunk/lima-swing/src/main/resources/icons/action-reports-account.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-account.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-reports-balance.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-balance.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-reports-entrybook.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-entrybook.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-reports-financialstatement.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-financialstatement.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-reports-ledger.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-ledger.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: trunk/lima-swing/src/main/resources/icons/action-search.png
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/resources/icons/action-transaction.png
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/resources/icons/action-translate.png
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/resources/icons/action-view.png
===================================================================
(Binary files differ)
Added: trunk/lima-swing/src/main/resources/images/accounts.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/images/accounts.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/images/entries.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/images/entries.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/images/entrybooks.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/images/entrybooks.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/images/fiscalperiods.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/images/fiscalperiods.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-07-07 10:58:46 UTC (rev 2965)
+++ trunk/pom.xml 2010-07-12 10:37:10 UTC (rev 2966)
@@ -254,7 +254,7 @@
<eugene.version>2.1-SNAPSHOT</eugene.version>
<topia.version>2.3.5-SNAPSHOT</topia.version>
<jaxx.version>2.0.2</jaxx.version>
- <i18n.version>1.2.3-SNAPSHOT</i18n.version>
+ <i18n.version>1.2.2</i18n.version>
<!--axis.version>1.4.1</axis.version-->
<!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar
1
0
Author: jpepin
Date: 2010-07-07 12:58:46 +0200 (Wed, 07 Jul 2010)
New Revision: 2965
Url: http://chorem.org/repositories/revision/lima/2965
Log:
Import/Export Debug. Ajout d'une vue pour le rapport d'import/export.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ReportDialogView.jaxx
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.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/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.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/ejb/ExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -37,9 +37,6 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookDAO;
-import org.chorem.lima.entity.EntryDAO;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementDAO;
import org.chorem.lima.entity.FinancialTransaction;
@@ -68,10 +65,8 @@
LogFactory.getLog(ExportServiceImpl.class);
private TopiaContext rootContext;
-
- protected CSVWriter csvWriter;
-
- protected SimpleDateFormat sdf;
+
+ private final SimpleDateFormat sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
public ExportServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -82,7 +77,6 @@
log.error("Can't init topia context", ex);
}
}
- sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
}
@@ -93,16 +87,18 @@
public String exportAsCSV() throws LimaException {
TopiaContext topiaContext = null;
StringWriter out = new StringWriter();
+ CSVWriter csvWriter;
+
try {
topiaContext = beginTransaction();
csvWriter = new CSVWriter(out, ';');
- exportAccountsChartAsCSV(topiaContext);
- exportEntryBookChartAsCSV(topiaContext);
- exportFinancialStatementChartAsCSV(topiaContext);
- exportFiscalPeriodAsCSV(topiaContext);
- exportClosedPeriodicEntryBooksAsCSV(topiaContext);
- exportFinancialTransactionsAndEntriesAsCSV(topiaContext);
+ exportAccountsChartAsCSV(csvWriter, topiaContext);
+ exportEntryBookChartAsCSV(csvWriter, topiaContext);
+ exportFinancialStatementChartAsCSV(csvWriter, topiaContext);
+ exportFiscalPeriodAsCSV(csvWriter, topiaContext);
+ exportClosedPeriodicEntryBooksAsCSV(csvWriter, topiaContext);
+ exportFinancialTransactionsAndEntriesAsCSV(csvWriter, topiaContext);
// Write cache in string
csvWriter.flush();
csvWriter.close();
@@ -127,11 +123,12 @@
public String exportFinancialStatementChartAsCSV() throws LimaException {
TopiaContext topiaContext = null;
StringWriter out = new StringWriter();
+ CSVWriter csvWriter;
try {
topiaContext = beginTransaction();
csvWriter = new CSVWriter(out, ';');
- exportFinancialStatementChartAsCSV(topiaContext);
+ exportFinancialStatementChartAsCSV(csvWriter, topiaContext);
// Write cache in file
csvWriter.flush();
csvWriter.close();
@@ -155,7 +152,7 @@
* | CreditAccounts | ProvisionDeprecationAccounts | SubAmount
* | HeaderAmount | MasterFinancialStatement
*/
- public void exportFinancialStatementChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException {
try {
String[] nextLine = new String[10];
// Get all Financialstatements
@@ -203,11 +200,12 @@
public String exportEntryBookChartAsCSV() throws LimaException {
TopiaContext topiaContext = null;
StringWriter out = new StringWriter();
+ CSVWriter csvWriter;
try {
topiaContext = beginTransaction();
csvWriter = new CSVWriter(out, ';');
- exportEntryBookChartAsCSV(topiaContext);
+ exportEntryBookChartAsCSV(csvWriter, topiaContext);
// Write cache in file
csvWriter.flush();
csvWriter.close();
@@ -229,7 +227,7 @@
* Local methode, export entrybooks from database
* Structure : TYPE | Code | Label | Type
*/
- public void exportEntryBookChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ public void exportEntryBookChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException {
try {
String[] nextLine = new String[4];
// Get all entrybook
@@ -259,10 +257,12 @@
public String exportAccountsChartAsCSV() throws LimaException {
TopiaContext topiaContext = null;
StringWriter out = new StringWriter();
+ CSVWriter csvWriter;
+
try {
topiaContext = beginTransaction();
csvWriter = new CSVWriter(out, ';');
- exportAccountsChartAsCSV(topiaContext);
+ exportAccountsChartAsCSV(csvWriter, topiaContext);
// Write cache in file
csvWriter.flush();
csvWriter.close();
@@ -284,7 +284,7 @@
* Local methode, export accounts from database
* Structure : TYPE | AccountNumber | Label | ThirdParty | MasteAccount | GeneralLedger
*/
- public void exportAccountsChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ public void exportAccountsChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException {
try {
String[] nextLine = new String[6];
// Récupère tous les comptes
@@ -325,7 +325,7 @@
* Structure : TYPE | TransactionDate | AmountDebit | AmountCredit
* | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code
*/
- public void exportFinancialTransactionsAndEntriesAsCSV(TopiaContext topiaContext) throws LimaException {
+ public void exportFinancialTransactionsAndEntriesAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException {
int numTransaction = 0;
// Get all financialtransactions
try {
@@ -385,7 +385,7 @@
* Local methode, export fiscalperiods from database
* Structure : TYPE | BeginDate | EndDate | Locked
*/
- public void exportFiscalPeriodAsCSV(TopiaContext topiaContext) throws LimaException {
+ public void exportFiscalPeriodAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException {
try {
String[] nextLine = new String[5];
// Get all fiscalperiod
@@ -413,7 +413,7 @@
* Local methode, export ClosedPeriodicEntryBooks from database
* Structure : TYPE | Locked | FinancialPeriod beginDate | FinancialPeriod endDate | EntryBook Code
*/
- public void exportClosedPeriodicEntryBooksAsCSV(TopiaContext topiaContext) throws LimaException {
+ public void exportClosedPeriodicEntryBooksAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException {
try {
String[] nextLine = new String[5];
// Get all fiscalperiod
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-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -19,6 +19,7 @@
package org.chorem.lima.business.ejb;
+import java.util.Collections;
import java.util.List;
import javax.ejb.Stateless;
import org.apache.commons.logging.Log;
@@ -28,6 +29,7 @@
import org.chorem.lima.business.FinancialPeriodServiceLocal;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl;
@@ -150,6 +152,7 @@
FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.
getFinancialPeriodDAO(transaction);
result = financialPeriodDAO.findAllByLocked(false);
+ Collections.sort(result, new FinancialPeriodComparator());
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -84,7 +84,6 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import au.com.bytecode.opencsv.CSVReader;
-import au.com.bytecode.opencsv.CSVWriter;
/**
* CSV import export service.
@@ -122,27 +121,9 @@
@EJB
EntryBookServiceLocal entryBookService;
- //Import datas lists
- Map<String, AccountImport> accounts;
+ private final SimpleDateFormat sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
- Map<String, FinancialStatementImport> financialStatements;
-
- List<FiscalPeriod> fiscalPeriods;
-
- List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks;
-
- Map<Integer, FinancialTransactionImport> financialTransactions;
-
- Map<Integer, List<EntryImport>> entries;
-
- //Utils
-
- protected CSVWriter csvWriter;
-
- protected SimpleDateFormat sdf;
-
-
public ImportServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -153,7 +134,6 @@
log.error("Can't init topia context", ex);
}
}
- sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
}
//################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
@@ -185,17 +165,17 @@
public String importCSV(String datas) throws LimaException {
String result = "";
- accounts = new TreeMap<String, AccountImport>();
+ Map<String, AccountImport> accounts = new TreeMap<String, AccountImport>();
- financialStatements = new TreeMap<String, FinancialStatementImport>();
+ Map<String, FinancialStatementImport> financialStatements = new TreeMap<String, FinancialStatementImport>();
- fiscalPeriods = new ArrayList<FiscalPeriod>();
+ List<FiscalPeriod> fiscalPeriods = new ArrayList<FiscalPeriod>();
- closedPeriodicEntryBooks = new ArrayList<ClosedPeriodicEntryBookImport>();
+ List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks = new ArrayList<ClosedPeriodicEntryBookImport>();
- financialTransactions = new HashMap<Integer,FinancialTransactionImport>();
+ Map<Integer, FinancialTransactionImport> financialTransactions = new HashMap<Integer,FinancialTransactionImport>();
- entries = new HashMap<Integer, List<EntryImport>>();
+ Map<Integer, List<EntryImport>> entries = new HashMap<Integer, List<EntryImport>>();
TopiaContext topiaContext = null;
@@ -209,39 +189,39 @@
while ((nextLine = csvReader.readNext()) != null) {
String indice = nextLine[0];
if (indice.equals("ACCN")){
- result += importAccountsChartsCSV(nextLine, topiaContext);
+ result += importAccountsChartsCSV(nextLine, accounts, topiaContext);
}
else if (indice.equals("ENBK")){
result += importEntryBooksChartCSV(nextLine, topiaContext);
}
else if (indice.equals("FNST")){
- result += importFinancialsStatementChartCSV(nextLine, topiaContext);
+ result += importFinancialsStatementChartCSV(nextLine, financialStatements, topiaContext);
}
else if (indice.equals("FSCP")){
- result += importFiscalPeriodCSV(nextLine, topiaContext);
+ result += importFiscalPeriodCSV(nextLine, fiscalPeriods, topiaContext);
}
else if (indice.equals("CPEB")){
- importClosedPeriodicEntryBookCSV(nextLine, topiaContext);
+ importClosedPeriodicEntryBookCSV(nextLine, closedPeriodicEntryBooks, topiaContext);
}
else if (indice.equals("FTRC")){
- importFinancialTransactionsCSV(nextLine, topiaContext);
+ importFinancialTransactionsCSV(nextLine, financialTransactions, topiaContext);
}
else if (indice.equals("NTRY")){
- importEntriesCSV(nextLine, topiaContext);
+ importEntriesCSV(nextLine, entries, topiaContext);
}
}
//create accounts
- result += createAccounts(topiaContext);
+ result += createAccounts(accounts, topiaContext);
//create financialStatements
- result += createFinancialStatements(topiaContext);
+ result += createFinancialStatements(financialStatements, topiaContext);
//create fiscalperiod
Collections.sort(fiscalPeriods, new FiscalPeriodComparator());
- result += createFiscalPeriod(topiaContext);
+ result += createFiscalPeriod(fiscalPeriods, topiaContext);
//update closedperiodicentrybooks
- result += updateClosedPeriodicEntryBooks(topiaContext);
+ result += updateClosedPeriodicEntryBooks(closedPeriodicEntryBooks, topiaContext);
//create financialtransaction and entries
- result += createFinancialTransactionsAndEntries(topiaContext);
+ result += createFinancialTransactionsAndEntries(financialTransactions, entries, topiaContext);
commitTransaction(topiaContext);
@@ -301,7 +281,7 @@
String result = "";
//FinancialStatements
- financialStatements =
+ Map<String, FinancialStatementImport> financialStatements =
new TreeMap<String, FinancialStatementImport>();
TopiaContext topiaContext = null;
@@ -314,12 +294,12 @@
while ((nextLine = csvReader.readNext()) != null) {
String indice = nextLine[0];
if (indice.equals("FNST")){
- result += importFinancialsStatementChartCSV(nextLine, topiaContext);
+ result += importFinancialsStatementChartCSV(nextLine, financialStatements, topiaContext);
}
}
//create financialStatements
- result += createFinancialStatements(topiaContext);
+ result += createFinancialStatements(financialStatements, topiaContext);
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
@@ -342,7 +322,7 @@
String result = "";
//Accounts
- accounts =
+ Map<String, AccountImport> accounts =
new TreeMap<String, AccountImport>();
TopiaContext topiaContext = null;
@@ -356,12 +336,12 @@
while ((nextLine = csvReader.readNext()) != null) {
String indice = nextLine[0];
if (indice.equals("ACCN")){
- result += importAccountsChartsCSV(nextLine, topiaContext);
+ result += importAccountsChartsCSV(nextLine, accounts, topiaContext);
}
}
//create accounts
- result += createAccounts(topiaContext);
+ result += createAccounts(accounts, topiaContext);
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
@@ -382,7 +362,7 @@
* Import and create accounts
* Structure : TYPE | accountNumber | label | thirdparty | masterAccountNumber | generalLedgerNumber
*/
- public String importAccountsChartsCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException{
+ public String importAccountsChartsCSV(String[] nextLine, Map<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException{
String result = "";
String accountNumber = nextLine[1];
@@ -423,7 +403,7 @@
* Import and create fiscal period
* Structure : TYPE | BeginDate | EndDate | Locked
*/
- public String importFiscalPeriodCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ public String importFiscalPeriodCSV(String[] nextLine, List<FiscalPeriod> fiscalPeriods, TopiaContext topiaContext) throws LimaException {
String result ="";
try {
FiscalPeriodDAO fiscalPeriodDAO =
@@ -496,7 +476,7 @@
* Import and create closedperiodicentrybook import
* Structure : TYPE | BeginDate | EndDate | Locked
*/
- public void importClosedPeriodicEntryBookCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ public void importClosedPeriodicEntryBookCSV(String[] nextLine, List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks, TopiaContext topiaContext) throws LimaException {
String locked = nextLine[1];
String beginDate = nextLine[2];
String endDate = nextLine[3];
@@ -519,7 +499,7 @@
* Structure : TYPE | label | header | accounts | debitAccount | creditAccount
* | provisitionDeprecationAccounts | subAmount | headerAmount | masterFinancialStatement
*/
- public String importFinancialsStatementChartCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ public String importFinancialsStatementChartCSV(String[] nextLine, Map<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
String result = "";
String label = nextLine[1];
@@ -533,7 +513,6 @@
String masterFinancialStatement = nextLine[9];
try {
-
FinancialStatementDAO financialStatementDAO =
LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
@@ -574,7 +553,7 @@
* Structue : TYPE | NumTransac | TransactionDate | AmountDebit | AmountCredit
* | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code
*/
- public void importFinancialTransactionsCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ public void importFinancialTransactionsCSV(String[] nextLine, Map<Integer, FinancialTransactionImport> financialTransactions, TopiaContext topiaContext) throws LimaException {
int num = new Integer(nextLine[1]);
FinancialTransactionImport financialTransactionImport = new FinancialTransactionImportImpl();
financialTransactionImport.setDate(nextLine[2]);
@@ -594,7 +573,7 @@
* Voucher | Position | FinancialTransaction Date | FinancialTransaction EntryBookCode |
* FinancialTransaction AmountDebit | FinancialTransaction AmountCredit
*/
- public void importEntriesCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ public void importEntriesCSV(String[] nextLine, Map<Integer, List<EntryImport>> entries, TopiaContext topiaContext) throws LimaException {
int num = new Integer(nextLine[1]);
EntryImport entryImport = new EntryImportImpl();
@@ -605,7 +584,7 @@
entryImport.setDetail(nextLine[6]);
entryImport.setVoucher(nextLine[7]);
entryImport.setPosition(nextLine[8]);
- entryImport.setAccount(nextLine[0]);
+ entryImport.setAccount(nextLine[9]);
if (entries.containsKey(num)){
List<EntryImport> entryImports = entries.get(num);
@@ -622,7 +601,7 @@
//################ CREATE ENTITY IN DB FOR IMPORT ################
- public String createFinancialStatements(TopiaContext topiaContext) throws LimaException {
+ public String createFinancialStatements(Map<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
String result = "";
try {
@@ -684,7 +663,7 @@
return result;
}
- public String createFiscalPeriod(TopiaContext topiaContext){
+ public String createFiscalPeriod(List<FiscalPeriod> fiscalPeriods, TopiaContext topiaContext){
String result = "";
for (FiscalPeriod fiscalPeriod : fiscalPeriods) {
//create fiscalPeriod
@@ -700,7 +679,7 @@
return result;
}
- public String createAccounts(TopiaContext topiaContext) throws LimaException {
+ public String createAccounts(Map<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException {
String result = "";
try {
@@ -750,7 +729,7 @@
return result;
}
- public String updateClosedPeriodicEntryBooks (TopiaContext topiaContext) throws LimaException {
+ public String updateClosedPeriodicEntryBooks (List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks, TopiaContext topiaContext) throws LimaException {
String result="";
try {
@@ -794,7 +773,7 @@
return result;
}
- public String createFinancialTransactionsAndEntries (TopiaContext topiaContext) throws LimaException {
+ public String createFinancialTransactionsAndEntries (Map<Integer, FinancialTransactionImport> financialTransactions, Map<Integer, List<EntryImport>> entries, TopiaContext topiaContext) throws LimaException {
String result = "";
try {
EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
@@ -807,7 +786,8 @@
FinancialTransaction financialTransaction = new FinancialTransactionImpl();
Date dateFinancialTransaction = sdf.parse(financialTransactionImport.getDate());
financialTransaction.setTransactionDate(dateFinancialTransaction);
-
+ financialTransaction.setAmountDebit(new Double(financialTransactionImport.getAmountDebit()));
+ financialTransaction.setAmountCredit(new Double(financialTransactionImport.getAmountCredit()));
EntryBook entryBook = entryBookDAO.findByCode(financialTransactionImport.getCodeEntryBook());
financialTransaction.setEntryBook(entryBook);
@@ -828,7 +808,6 @@
entry.setDetail(entryImport.getDetail());
entry.setVoucher(entryImport.getVoucher());
entry.setPosition(entryImport.getPosition());
- log.debug(entry);
entryDAO.create(entry);
financialTransaction.addEntry(entry);
}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -0,0 +1,35 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business.utils;
+
+import java.util.Comparator;
+import org.chorem.lima.entity.FinancialPeriod;
+
+public class FinancialPeriodComparator implements Comparator<FinancialPeriod>{
+
+ /**
+ * sort by financial begin date
+ */
+ @Override
+ public int compare(FinancialPeriod o1, FinancialPeriod o2) {
+ return o1.getBeginDate().compareTo(o2.getBeginDate());
+ }
+
+}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -25,7 +25,7 @@
public class FiscalPeriodComparator implements Comparator<FiscalPeriod>{
/**
- * sort by accout number in lexicographical order
+ * sort by fiscal begin date
*/
@Override
public int compare(FiscalPeriod o1, FiscalPeriod o2) {
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -1,5 +1,6 @@
package org.chorem.lima.ui;
+import static org.nuiton.i18n.I18n._;
import javax.swing.JFileChooser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -40,7 +41,7 @@
if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
String filePath = chooser.getSelectedFile().getAbsolutePath();
String message = importExport.importFromCsvFile(filePath, "");
- DialogHelper.showMessageDialog(message);
+ DialogHelper.showReportDialog(message, _("lima.importexport.import"), view);
}
}
else {
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-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -19,17 +19,14 @@
package org.chorem.lima.ui;
import static org.nuiton.i18n.I18n._;
-
import java.awt.Desktop;
import java.net.URL;
import java.util.Locale;
-
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.editor.config.ConfigUI;
import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -273,7 +273,7 @@
String filePath = chooser.getSelectedFile().getAbsolutePath();
String message = importExport.importFromCsvFile(filePath, "importAccountsChart");
accountsTreeTableModel.refreshTree();
- DialogHelper.showMessageDialog(message);
+ DialogHelper.showReportDialog(message, _("lima.importexport.import"), view);
}
}
else {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -166,7 +166,7 @@
String filePath = chooser.getSelectedFile().getAbsolutePath();
String message = importExport.importFromCsvFile(filePath, "importEntryBookChart");
entryBookTableModel.refreshTable();
- DialogHelper.showMessageDialog(message);
+ DialogHelper.showReportDialog(message, _("lima.importexport.import"), view);
}
}
else {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -274,7 +274,7 @@
String filePath = chooser.getSelectedFile().getAbsolutePath();
String message = importExport.importFromCsvFile(filePath, "importFinancialStatementsChart");
treeTableModel.refreshTree();
- DialogHelper.showMessageDialog(message);
+ DialogHelper.showReportDialog(message, _("lima.importexport.import"), view);
}
}
else {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -2,14 +2,10 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Color;
-import java.io.IOException;
import java.util.List;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
-import javax.swing.text.html.HTMLDocument;
-import javax.swing.text.html.HTMLFrameHyperlinkEvent;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
@@ -24,7 +20,6 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
-import org.chorem.lima.util.DialogHelper;
public class HomeViewHandler implements HyperlinkListener {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-07-07 10:58:46 UTC (rev 2965)
@@ -19,8 +19,15 @@
package org.chorem.lima.util;
import static org.nuiton.i18n.I18n._;
+
+import java.awt.Component;
+
+import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.Resource;
@@ -65,8 +72,7 @@
* @param titre
* @param type
*/
- public static void showMessageDialog (String message,String titre,int type)
- {
+ public static void showMessageDialog (String message,String titre,int type) {
JFrame f = new JFrame();
f.setIconImage(Resource.getIcon("icons/lima.png").getImage());
JOptionPane.showMessageDialog(
@@ -76,4 +82,23 @@
type);
f.dispose();
}
+
+ /**
+ * Permet d'afficher une boite de dialogue avec rapport
+ * @param message
+ * @param titre
+ * @param type
+ */
+ public static void showReportDialog (String message, String title, Component parent) {
+ ReportDialogView reportDialogView = new ReportDialogView();
+ reportDialogView.setIconImage(Resource.getIcon("icons/lima.png").getImage());
+ JTextArea textArea = reportDialogView.getTextArea();
+ textArea.setText(message);
+ reportDialogView.setSize(600,400);
+ reportDialogView.setTitle(title);
+ reportDialogView.setLocationRelativeTo(parent);
+ reportDialogView.setVisible(true);
+ }
+
+
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/util/ReportDialogView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ReportDialogView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ReportDialogView.jaxx 2010-07-07 10:58:46 UTC (rev 2965)
@@ -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.
+ ##% -->
+
+<JDialog modal="true">
+ <script>
+ <![CDATA[
+ protected void performOk() {
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row weightx="1" weighty="1">
+ <cell fill="both">
+ <JScrollPane id="scrollPane">
+ <JTextArea id="textArea" editable="false"/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row anchor="east">
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" onActionPerformed="performOk()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
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-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-07-07 10:58:46 UTC (rev 2965)
@@ -52,6 +52,7 @@
lima.date=Date
lima.debit=Debit
lima.description=Description
+lima.dialogreport=
lima.entries=Entries
lima.entries.addtransaction=
lima.entries.lettering=
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-07-06 16:39:52 UTC (rev 2964)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-07-07 10:58:46 UTC (rev 2965)
@@ -52,6 +52,7 @@
lima.date=Date
lima.debit=Debit
lima.description=Description
+lima.dialogreport=
lima.entries=Traitement
lima.entries.addtransaction=Saisir des \u00E9critures
lima.entries.lettering=Ajouter une lettre
1
0
r2964 - in trunk: . lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/utils lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/util
by jpepin@users.chorem.org 06 Jul '10
by jpepin@users.chorem.org 06 Jul '10
06 Jul '10
Author: jpepin
Date: 2010-07-06 18:39:52 +0200 (Tue, 06 Jul 2010)
New Revision: 2964
Url: http://chorem.org/repositories/revision/lima/2964
Log:
Import / Export (suite)
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.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/ImportServiceImpl.java
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
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java
trunk/pom.xml
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-07-05 17:07:51 UTC (rev 2963)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -161,6 +161,8 @@
Date loopDate = fiscalPeriod.getBeginDate();
while(loopDate.before(endDate)){
FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked
+ financialPeriod.setLocked(fiscalPeriod.getLocked());
financialPeriod.setBeginDate(loopDate);
loopDate = DateUtils.addMonths(loopDate, 1);
loopDate = DateUtils.truncate(loopDate, Calendar.MONTH);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-05 17:07:51 UTC (rev 2963)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -101,11 +101,9 @@
exportEntryBookChartAsCSV(topiaContext);
exportFinancialStatementChartAsCSV(topiaContext);
exportFiscalPeriodAsCSV(topiaContext);
- exportFinancialPeriodAsCSV(topiaContext);
exportClosedPeriodicEntryBooksAsCSV(topiaContext);
- exportFinancialTransactionsAsCSV(topiaContext);
- exportEntriesAsCSV(topiaContext);
- // Write cache in file
+ exportFinancialTransactionsAndEntriesAsCSV(topiaContext);
+ // Write cache in string
csvWriter.flush();
csvWriter.close();
}
@@ -120,7 +118,8 @@
}
return out.getBuffer().toString();
}
-
+
+
/**
* Remote methode call from UI.
*/
@@ -148,6 +147,7 @@
}
return out.getBuffer().toString();
}
+
/**
* Local methode, export financialstatements from database
@@ -194,6 +194,7 @@
doCatch(topiaContext, eeeTE, log);
}
}
+
/**
* Remote methode call from UI.
@@ -249,6 +250,7 @@
doCatch(topiaContext, eeeTE, log);
}
}
+
/**
* Remote methode call from UI.
@@ -277,6 +279,7 @@
return out.getBuffer().toString();
}
+
/**
* Local methode, export accounts from database
* Structure : TYPE | AccountNumber | Label | ThirdParty | MasteAccount | GeneralLedger
@@ -315,79 +318,68 @@
doCatch(topiaContext, eeeTE, log);
}
}
+
/**
* Local methode, export financialtransactions from database
- * Structue : TYPE | TransactionDate | AmountDebit | AmountCredit
+ * Structure : TYPE | TransactionDate | AmountDebit | AmountCredit
* | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code
*/
- public void exportFinancialTransactionsAsCSV(TopiaContext topiaContext) throws LimaException {
- String[] nextLine = new String[7];
+ public void exportFinancialTransactionsAndEntriesAsCSV(TopiaContext topiaContext) throws LimaException {
+ int numTransaction = 0;
// Get all financialtransactions
try {
- FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
- List<FinancialTransaction> listFinancialTransaction = financialTransactionDAO.findAll();
+ FinancialTransactionDAO financialTransactionDAO =
+ LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ List<FinancialTransaction> listFinancialTransaction =
+ financialTransactionDAO.findAll();
// For all financialTransaction
for (FinancialTransaction financialTransaction : listFinancialTransaction) {
+ String[] nextLine = new String[8];
nextLine[0] = "FTRC";
- nextLine[1] = sdf.format(financialTransaction.getTransactionDate());
- nextLine[2] = new Double(
- financialTransaction.getAmountDebit()).toString();
+ nextLine[1] = String.valueOf(numTransaction);
+ nextLine[2] =
+ sdf.format(financialTransaction.getTransactionDate());
nextLine[3] = new Double(
+ financialTransaction.getAmountDebit()).toString();
+ nextLine[4] = new Double(
financialTransaction.getAmountCredit()).toString();
- nextLine[4] = sdf.format(financialTransaction.getFinancialPeriod().
+ nextLine[5] =
+ sdf.format(financialTransaction.getFinancialPeriod().
getBeginDate());
- nextLine[5] = sdf.format(financialTransaction.getFinancialPeriod().
+ nextLine[6] =
+ sdf.format(financialTransaction.getFinancialPeriod().
getEndDate());
- nextLine[6] = financialTransaction.getEntryBook().getCode();
+ EntryBook entryBook = financialTransaction.getEntryBook();
+ if (entryBook != null){
+ nextLine[7] = entryBook.getCode();
+ }
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
+
+ nextLine = new String[10];
+ for (Entry entry : financialTransaction.getEntry()) {
+ nextLine[0] = "NTRY";
+ nextLine[1] = String.valueOf(numTransaction);
+ nextLine[2] = entry.getDescription();
+ nextLine[3] = new Double(entry.getAmount()).toString();
+ nextLine[4] = new Boolean(entry.getDebit()).toString();
+ nextLine[5] = entry.getLettering();
+ nextLine[6] = entry.getDetail();
+ nextLine[7] = entry.getVoucher();
+ nextLine[8] = entry.getPosition();
+ nextLine[9] = entry.getAccount().getAccountNumber();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ numTransaction++;
}
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
}
-
- /**
- * Local methode, export entries from database
- * Structure : TYPE | Description | Amount | Debit | Lettering | Detail |
- * Voucher | Position | FinancialTransaction Date | FinancialTransaction Code |
- * FinancialTransaction AmountDebit | FinancialTransaction AmountCredit
- */
- public void exportEntriesAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[12];
- // Get all Entry
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- List<Entry> listEntry = entryDAO.findAll();
- // For all Entry
- for (Entry entry : listEntry) {
- nextLine[0] = "NTRY";
- nextLine[1] = entry.getDescription();
- nextLine[2] = new Double(entry.getAmount()).toString();
- nextLine[3] = new Boolean(entry.getDebit()).toString();
- nextLine[4] = entry.getLettering();
- nextLine[5] = entry.getVoucher();
- nextLine[6] = entry.getPosition();
- nextLine[7] = entry.getAccount().getAccountNumber();
- nextLine[8] = sdf.format(entry.getFinancialTransaction().
- getTransactionDate());
- nextLine[9] = entry.getFinancialTransaction().
- getEntryBook().getCode();
- nextLine[10] = new Double(entry.getFinancialTransaction()
- .getAmountDebit()).toString();
- nextLine[11] = new Double(entry.getFinancialTransaction()
- .getAmountCredit()).toString();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
/**
* Local methode, export fiscalperiods from database
@@ -416,40 +408,6 @@
}
}
- /**
- * Local methode, export financialperiods from database
- * Structure : TYPE | BeginDate | EndDate | Locked | FiscalPeriod beginDate | FiscalPeriod endDate
- */
- public void exportFinancialPeriodAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[6];
- // Get all fiscalperiod
- FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
- List<FinancialPeriod> listFinancialPeriod =
- financialPeriodDAO.findAll();
-
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
-
- // For all Entry
- for (FinancialPeriod financialPeriod : listFinancialPeriod) {
- nextLine[0] = "FNCP";
- nextLine[1] = sdf.format(financialPeriod.getBeginDate());
- nextLine[2] = sdf.format(financialPeriod.getEndDate());
- nextLine[3] = new Boolean(financialPeriod.getLocked()).toString();
- FiscalPeriod fiscalPeriod = fiscalPeriodDAO.
- findContainsFinancialPeriod(financialPeriod);
- nextLine[4] = sdf.format(fiscalPeriod.getBeginDate());
- nextLine[5] = sdf.format(fiscalPeriod.getEndDate());
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
/**
* Local methode, export ClosedPeriodicEntryBooks from database
@@ -468,9 +426,11 @@
nextLine[0] = "CPEB";
nextLine[1] = new Boolean(
closedPeriodicEntryBook.getLocked()).toString();
- nextLine[2] = sdf.format(closedPeriodicEntryBook.getFinancialPeriod().
+ nextLine[2] =
+ sdf.format(closedPeriodicEntryBook.getFinancialPeriod().
getBeginDate());
- nextLine[3] =sdf.format(closedPeriodicEntryBook.getFinancialPeriod().
+ nextLine[3] =
+ sdf.format(closedPeriodicEntryBook.getFinancialPeriod().
getEndDate());
nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
// Ajoute la ligne au fichier
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-07-05 17:07:51 UTC (rev 2963)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -23,8 +23,6 @@
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
-import javax.management.Query;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
@@ -32,7 +30,6 @@
import org.chorem.lima.business.FinancialTransactionServiceLocal;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
@@ -47,7 +44,6 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
/**
* Cette classe permet la création d'une transaction comptable dans l'application.
@@ -416,9 +412,7 @@
entryOld.setAccount(entry.getAccount());
entryOld.setAmount(entryAmount);
entryOld.setDebit(entryAmountBool);
- entryOld.setDescription(entry.getDescription());
entryOld.setFinancialTransaction(entry.getFinancialTransaction());
- entryOld.setVoucher(entry.getVoucher());
entryOld.setPosition(entry.getPosition());
entryOld.setLettering(entry.getLettering());
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-05 17:07:51 UTC (rev 2963)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -24,9 +24,12 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.TreeMap;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -34,30 +37,44 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.AccountImport;
import org.chorem.lima.beans.AccountImportImpl;
-import org.chorem.lima.beans.FinancialPeriodImport;
-import org.chorem.lima.beans.FinancialPeriodImportImpl;
+import org.chorem.lima.beans.ClosedPeriodicEntryBookImport;
+import org.chorem.lima.beans.ClosedPeriodicEntryBookImportImpl;
+import org.chorem.lima.beans.EntryImport;
+import org.chorem.lima.beans.EntryImportImpl;
import org.chorem.lima.beans.FinancialStatementImport;
import org.chorem.lima.beans.FinancialStatementImportImpl;
+import org.chorem.lima.beans.FinancialTransactionImport;
+import org.chorem.lima.beans.FinancialTransactionImportImpl;
import org.chorem.lima.business.AccountServiceLocal;
import org.chorem.lima.business.EntryBookServiceLocal;
+import org.chorem.lima.business.FinancialPeriodServiceLocal;
import org.chorem.lima.business.FinancialStatementServiceLocal;
import org.chorem.lima.business.FinancialTransactionServiceLocal;
+import org.chorem.lima.business.FiscalPeriodServiceLocal;
import org.chorem.lima.business.ImportService;
import org.chorem.lima.business.ImportServiceLocal;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.FiscalPeriodComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.AccountImpl;
+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.EntryBookDAO;
import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
-import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementDAO;
import org.chorem.lima.entity.FinancialStatementImpl;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionDAO;
+import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.FiscalPeriodImpl;
@@ -85,10 +102,18 @@
private TopiaContext rootContext;
+ //Services
+
@EJB
AccountServiceLocal accountService;
@EJB
+ FiscalPeriodServiceLocal fiscalPeriodService;
+
+ @EJB
+ FinancialPeriodServiceLocal financialPeriodService;
+
+ @EJB
FinancialTransactionServiceLocal financialTransactionService;
@EJB
@@ -97,9 +122,27 @@
@EJB
EntryBookServiceLocal entryBookService;
+ //Import datas lists
+
+ Map<String, AccountImport> accounts;
+
+ Map<String, FinancialStatementImport> financialStatements;
+
+ List<FiscalPeriod> fiscalPeriods;
+
+ List<ClosedPeriodicEntryBookImport> closedPeriodicEntryBooks;
+
+ Map<Integer, FinancialTransactionImport> financialTransactions;
+
+ Map<Integer, List<EntryImport>> entries;
+
+ //Utils
+
protected CSVWriter csvWriter;
protected SimpleDateFormat sdf;
+
+
public ImportServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -115,10 +158,6 @@
//################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
-
- /*
- * @see org.chorem.lima.business.ImportExportService#importAsEBPCSV(byte[])
- */
@Override
public void importAsEbpCSV(byte[] data) throws LimaException {
@@ -139,27 +178,26 @@
//################ IMPORT ################
-
+ /**
+ * Remote methode to call all entities import from UI
+ */
@Override
public String importCSV(String datas) throws LimaException {
String result = "";
- //Accounts
- TreeMap<String, AccountImport> accounts =
- new TreeMap<String, AccountImport>();
+ accounts = new TreeMap<String, AccountImport>();
- //FinancialStatements
- TreeMap<String, FinancialStatementImport> financialStatements =
- new TreeMap<String, FinancialStatementImport>();
+ financialStatements = new TreeMap<String, FinancialStatementImport>();
- //FiscalPeriods
- List<FiscalPeriod> fiscalPeriods = new ArrayList<FiscalPeriod>();
+ fiscalPeriods = new ArrayList<FiscalPeriod>();
+
+ closedPeriodicEntryBooks = new ArrayList<ClosedPeriodicEntryBookImport>();
- //FinancialPeriods
- List<FinancialPeriodImport> financialPeriodImports =
- new ArrayList<FinancialPeriodImport>();
+ financialTransactions = new HashMap<Integer,FinancialTransactionImport>();
-
+ entries = new HashMap<Integer, List<EntryImport>>();
+
+
TopiaContext topiaContext = null;
try {
topiaContext = beginTransaction();
@@ -171,42 +209,42 @@
while ((nextLine = csvReader.readNext()) != null) {
String indice = nextLine[0];
if (indice.equals("ACCN")){
- accounts = importAccountsChartsCSV(
- nextLine, accounts, topiaContext);
+ result += importAccountsChartsCSV(nextLine, topiaContext);
}
else if (indice.equals("ENBK")){
- result += importEntryBooksChartCSV(
- nextLine, topiaContext);
+ result += importEntryBooksChartCSV(nextLine, topiaContext);
}
else if (indice.equals("FNST")){
- financialStatements = importFinancialsStatementChartCSV(
- nextLine, financialStatements, topiaContext);
+ result += importFinancialsStatementChartCSV(nextLine, topiaContext);
}
else if (indice.equals("FSCP")){
- fiscalPeriods = importFiscalPeriodCSV(nextLine, fiscalPeriods, topiaContext);
+ result += importFiscalPeriodCSV(nextLine, topiaContext);
}
- else if (indice.equals("FNCP")){
- financialPeriodImports = importFinancialPeriodChartCSV(nextLine, financialPeriodImports, topiaContext);
- }
else if (indice.equals("CPEB")){
- //result+=
+ importClosedPeriodicEntryBookCSV(nextLine, topiaContext);
}
else if (indice.equals("FTRC")){
- //result+=
+ importFinancialTransactionsCSV(nextLine, topiaContext);
}
else if (indice.equals("NTRY")){
- //result+=
+ importEntriesCSV(nextLine, topiaContext);
}
}
//create accounts
- result+=createAccounts(accounts, topiaContext);
+ result += createAccounts(topiaContext);
//create financialStatements
- result+=createFinancialStatements(financialStatements, topiaContext);
+ result += createFinancialStatements(topiaContext);
//create fiscalperiod
+ Collections.sort(fiscalPeriods, new FiscalPeriodComparator());
+ result += createFiscalPeriod(topiaContext);
+ //update closedperiodicentrybooks
+ result += updateClosedPeriodicEntryBooks(topiaContext);
+ //create financialtransaction and entries
+ result += createFinancialTransactionsAndEntries(topiaContext);
- //create financialperiod
- result+=createFinancialPeriod(financialPeriodImports, topiaContext);
+ commitTransaction(topiaContext);
+
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
@@ -220,6 +258,10 @@
return result;
}
+
+ /**
+ * Remote methode to call entrybooks import from UI
+ */
@Override
public String importEntryBooksChartAsCSV(String datas) throws LimaException{
String result = "";
@@ -234,7 +276,7 @@
while ((nextLine = csvReader.readNext()) != null) {
String indice = nextLine[0];
if (indice.equals("ENBK")){
- result+=importEntryBooksChartCSV(nextLine, topiaContext);
+ result += importEntryBooksChartCSV(nextLine, topiaContext);
}
}
}
@@ -251,12 +293,15 @@
}
+ /**
+ * Remote methode to call financialStatements import from UI
+ */
@Override
public String importFinancialStatementsChartAsCSV(String datas) throws LimaException {
String result = "";
//FinancialStatements
- TreeMap<String, FinancialStatementImport> financialStatements =
+ financialStatements =
new TreeMap<String, FinancialStatementImport>();
TopiaContext topiaContext = null;
@@ -269,13 +314,12 @@
while ((nextLine = csvReader.readNext()) != null) {
String indice = nextLine[0];
if (indice.equals("FNST")){
- financialStatements = importFinancialsStatementChartCSV(
- nextLine, financialStatements, topiaContext);
+ result += importFinancialsStatementChartCSV(nextLine, topiaContext);
}
}
//create financialStatements
- result+=createFinancialStatements(financialStatements, topiaContext);
+ result += createFinancialStatements(topiaContext);
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
@@ -290,12 +334,15 @@
}
+ /**
+ * Remote methode to call accounts import from UI
+ */
@Override
public String importAccountsChartAsCSV(String datas) throws LimaException {
String result = "";
//Accounts
- TreeMap<String, AccountImport> accounts =
+ accounts =
new TreeMap<String, AccountImport>();
TopiaContext topiaContext = null;
@@ -309,13 +356,12 @@
while ((nextLine = csvReader.readNext()) != null) {
String indice = nextLine[0];
if (indice.equals("ACCN")){
- accounts = importAccountsChartsCSV(
- nextLine, accounts, topiaContext);
- }
+ result += importAccountsChartsCSV(nextLine, topiaContext);
+ }
}
//create accounts
- result+=createAccounts(accounts, topiaContext);
+ result += createAccounts(topiaContext);
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
@@ -329,7 +375,15 @@
return result;
}
- public TreeMap<String, AccountImport> importAccountsChartsCSV(String[] nextLine, TreeMap<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException{
+
+ //################ Import entities an put to lists ################
+
+ /**
+ * Import and create accounts
+ * Structure : TYPE | accountNumber | label | thirdparty | masterAccountNumber | generalLedgerNumber
+ */
+ public String importAccountsChartsCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException{
+ String result = "";
String accountNumber = nextLine[1];
String label = nextLine[2];
@@ -353,16 +407,15 @@
// put it in hashset
accounts.put(accountNumber, accountImport);
}
- /*else {
+ else {
result += "FAILED : The account "
+ accountNumber + " already exists !\n";
- }*/
+ }
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
-
- return accounts;
+ return result;
}
@@ -370,8 +423,9 @@
* Import and create fiscal period
* Structure : TYPE | BeginDate | EndDate | Locked
*/
- public List<FiscalPeriod> importFiscalPeriodCSV(String[] nextLine, List<FiscalPeriod> fiscalPeriods, TopiaContext topiaContext) throws LimaException {
- try {
+ public String importFiscalPeriodCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ String result ="";
+ try {
FiscalPeriodDAO fiscalPeriodDAO =
LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
@@ -386,6 +440,10 @@
if (fiscalPeriodDAO.findByNaturalId(beginDate, endDate) == null){
fiscalPeriods.add(fiscalPeriod);
}
+ else {
+ result += "FAILED : The fiscalperiod "
+ + beginDate + "-" + endDate + " already exists !\n";
+ }
}
catch (ParseException eeePE) {
if(log.isDebugEnabled()){
@@ -395,10 +453,14 @@
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
- return fiscalPeriods;
+ return result;
}
+ /**
+ * Import and create entrybooks
+ * Structure : TYPE | Code | Label | Type
+ */
public String importEntryBooksChartCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
String result ="";
try {
@@ -429,9 +491,37 @@
return result;
}
+
+ /**
+ * Import and create closedperiodicentrybook import
+ * Structure : TYPE | BeginDate | EndDate | Locked
+ */
+ public void importClosedPeriodicEntryBookCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ String locked = nextLine[1];
+ String beginDate = nextLine[2];
+ String endDate = nextLine[3];
+ String entryBookCode = nextLine[4];
+
+ if (new Boolean(locked)){
+ ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport = new ClosedPeriodicEntryBookImportImpl();
+ closedPeriodicEntryBookImport.setLocked(locked);
+ closedPeriodicEntryBookImport.setBeginDateFinancialPeriod(beginDate);
+ closedPeriodicEntryBookImport.setEndDateFinancialPeriod(endDate);
+ closedPeriodicEntryBookImport.setCodeEntryBook(entryBookCode);
- public TreeMap<String, FinancialStatementImport> importFinancialsStatementChartCSV(String[] nextLine, TreeMap<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
-
+ closedPeriodicEntryBooks.add(closedPeriodicEntryBookImport);
+ }
+ }
+
+
+ /**
+ * Import and create financialstatement
+ * Structure : TYPE | label | header | accounts | debitAccount | creditAccount
+ * | provisitionDeprecationAccounts | subAmount | headerAmount | masterFinancialStatement
+ */
+ public String importFinancialsStatementChartCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ String result = "";
+
String label = nextLine[1];
String header = nextLine[2];
String accounts = nextLine[3];
@@ -467,66 +557,72 @@
// put it in hashset
financialStatements.put(label, financialStatementImport);
}
- /*else {
+ else {
result += "FAILED : The financialstatement "
+ label + " already exists !\n";
- }*/
+ }
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
- return financialStatements;
+ return result;
}
+
/**
- * Structure : TYPE | BeginDate | EndDate | Locked | FiscalPeriod beginDate | FiscalPeriod endDate
+ * Import and create financialtransactions
+ * Structue : TYPE | NumTransac | TransactionDate | AmountDebit | AmountCredit
+ * | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code
*/
+ public void importFinancialTransactionsCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ int num = new Integer(nextLine[1]);
+ FinancialTransactionImport financialTransactionImport = new FinancialTransactionImportImpl();
+ financialTransactionImport.setDate(nextLine[2]);
+ financialTransactionImport.setAmountDebit(nextLine[3]);
+ financialTransactionImport.setAmountCredit(nextLine[4]);
+ financialTransactionImport.setBeginDateFinancialPeriod(nextLine[5]);
+ financialTransactionImport.setEndDateFinancialPeriod(nextLine[6]);
+ financialTransactionImport.setCodeEntryBook(nextLine[7]);
+
+ financialTransactions.put(num, financialTransactionImport);
+ }
- public List<FinancialPeriodImport> importFinancialPeriodChartCSV(String[] nextLine, List<FinancialPeriodImport> financialPeriodImports, TopiaContext topiaContext) throws LimaException {
-
- String beginDate = nextLine[1];
- String endDate = nextLine[2];
- String locked = nextLine[3];
- String beginDateFiscalPeriod = nextLine[4];
- String endDateFiscalPeriod = nextLine[5];
-
- try {
-
- FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+
+ /**
+ * Import and create entries
+ * Structure : TYPE | NumTransac | Description | Amount | Debit | Lettering | Detail |
+ * Voucher | Position | FinancialTransaction Date | FinancialTransaction EntryBookCode |
+ * FinancialTransaction AmountDebit | FinancialTransaction AmountCredit
+ */
+ public void importEntriesCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ int num = new Integer(nextLine[1]);
- //if exist, skip
- if (financialPeriodDAO.findByNaturalId(sdf.parse(beginDate), sdf.parse(endDate)) == null){
- //create it
- FinancialPeriodImport financialPeriodImport =
- new FinancialPeriodImportImpl();
- financialPeriodImport.setBeginDate(beginDate);
- financialPeriodImport.setEndDate(endDate);
- financialPeriodImport.setBeginDateFiscalPeriod(beginDateFiscalPeriod);
- financialPeriodImport.setEndDateFiscalPeriod(endDateFiscalPeriod);
- financialPeriodImport.setLocked(locked);
-
- // put it in list
- financialPeriodImports.add(financialPeriodImport);
+ EntryImport entryImport = new EntryImportImpl();
+ entryImport.setDescription(nextLine[2]);
+ entryImport.setAmount(nextLine[3]);
+ entryImport.setDebit(nextLine[4]);
+ entryImport.setLettering(nextLine[5]);
+ entryImport.setDetail(nextLine[6]);
+ entryImport.setVoucher(nextLine[7]);
+ entryImport.setPosition(nextLine[8]);
+ entryImport.setAccount(nextLine[0]);
+
+ if (entries.containsKey(num)){
+ List<EntryImport> entryImports = entries.get(num);
+ entryImports.add(entryImport);
}
- }
- catch (ParseException eeePE) {
- if(log.isDebugEnabled()){
- log.debug("Can't parse date", eeePE);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
-
- return financialPeriodImports;
+ else {
+ List<EntryImport> entryImports = new ArrayList<EntryImport>();
+ entryImports.add(entryImport);
+ entries.put(num, entryImports);
+ }
}
//################ CREATE ENTITY IN DB FOR IMPORT ################
- public String createFinancialStatements(TreeMap<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
+ public String createFinancialStatements(TopiaContext topiaContext) throws LimaException {
String result = "";
try {
@@ -588,49 +684,23 @@
return result;
}
- public String createFinancialPeriod(List<FinancialPeriodImport> financialPeriodImports, TopiaContext topiaContext) throws LimaException{
+ public String createFiscalPeriod(TopiaContext topiaContext){
String result = "";
- try {
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
- FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
-
- for (FinancialPeriodImport financialPeriodImport : financialPeriodImports) {
- //create financialPeriod
- FinancialPeriod financialPeriod = new FinancialPeriodImpl();
- Date beginDate = sdf.parse(financialPeriodImport.getBeginDate());
- Date endDate = sdf.parse(financialPeriodImport.getEndDate());
- financialPeriod.setBeginDate(beginDate);
- financialPeriod.setEndDate(endDate);
- financialPeriod.setLocked(new Boolean(financialPeriodImport.getLocked()));
- financialPeriodDAO.create(financialPeriod);
-
- //add to fiscalperiod
- Date beginDateFiscalPeriod =
- sdf.parse(financialPeriodImport.getBeginDateFiscalPeriod());
- Date endDateFiscalPeriod =
- sdf.parse(financialPeriodImport.getEndDateFiscalPeriod());
- FiscalPeriod fiscalPeriod =
- fiscalPeriodDAO.findByNaturalId(beginDateFiscalPeriod, endDateFiscalPeriod);
- fiscalPeriod.addFinancialPeriod(financialPeriod);
-
- result += "SUCCESS : The financialPeriod " +
- financialPeriodImport.getBeginDate()+"-"+financialPeriodImport.getEndDate() + " is created ! \n";
+ for (FiscalPeriod fiscalPeriod : fiscalPeriods) {
+ //create fiscalPeriod
+ try {
+ fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
+ result += "SUCCESS : The fiscalPeriod " +
+ fiscalPeriod.getBeginDate()+"-"+fiscalPeriod.getEndDate() + " is created ! \n";
+ }
+ catch (LimaException eee){
+ result += "FAILED : "+eee+" \n";
+ }
}
- }
- catch (ParseException eeePE) {
- if(log.isDebugEnabled()){
- log.debug("Can't parse date", eeePE);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
return result;
}
-
- public String createAccounts(TreeMap<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException {
+
+ public String createAccounts(TopiaContext topiaContext) throws LimaException {
String result = "";
try {
@@ -680,7 +750,101 @@
return result;
}
-
+ public String updateClosedPeriodicEntryBooks (TopiaContext topiaContext) throws LimaException {
+ String result="";
+
+ try {
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) {
+ //update closedPeriodicEntryBook
+ Date beginDateFinancialPeriod =
+ sdf.parse(closedPeriodicEntryBookImport.getBeginDateFinancialPeriod());
+ Date endDateFinancialPeriod =
+ sdf.parse(closedPeriodicEntryBookImport.getEndDateFinancialPeriod());
+ FinancialPeriod financialPeriod =
+ financialPeriodDAO.findByNaturalId(beginDateFinancialPeriod, endDateFinancialPeriod);
+ String codeEntryBook = closedPeriodicEntryBookImport.getCodeEntryBook();
+ EntryBook entryBook = entryBookDAO.findByCode(codeEntryBook);
+ ClosedPeriodicEntryBook closedPeriodicEntryBook =
+ closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(entryBook, financialPeriod);
+ try {
+ financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ result += "SUCCESS : The blockClosedPeriodicEntryBook " +
+ beginDateFinancialPeriod + "-" + endDateFinancialPeriod + ", " +
+ codeEntryBook + " is updated ! \n";
+ }
+ catch (LimaException eee){
+ result += "FAILED : "+eee+" \n";
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (ParseException eeePE) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't parse date", eeePE);
+ }
+ }
+ return result;
+ }
+
+ public String createFinancialTransactionsAndEntries (TopiaContext topiaContext) throws LimaException {
+ String result = "";
+ try {
+ EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+ FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ for (int num : financialTransactions.keySet()) {
+ FinancialTransactionImport financialTransactionImport = financialTransactions.get(num);
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ Date dateFinancialTransaction = sdf.parse(financialTransactionImport.getDate());
+ financialTransaction.setTransactionDate(dateFinancialTransaction);
+
+ EntryBook entryBook = entryBookDAO.findByCode(financialTransactionImport.getCodeEntryBook());
+ financialTransaction.setEntryBook(entryBook);
+
+ FinancialPeriod financialPeriod = financialPeriodDAO.findByDate(dateFinancialTransaction);
+
+ financialTransactionDAO.create(financialTransaction);
+ financialPeriod.addFinancialTransaction(financialTransaction);
+
+ List<EntryImport> entryImports = entries.get(num);
+ for (EntryImport entryImport : entryImports) {
+ Entry entry = new EntryImpl();
+ Account account = accountDAO.findByAccountNumber(entryImport.getAccount());
+ entry.setAccount(account);
+ entry.setDescription(entryImport.getDescription());
+ entry.setAmount(new Double(entryImport.getAmount()));
+ entry.setDebit(new Boolean(entryImport.getDebit()));
+ entry.setLettering(entryImport.getLettering());
+ entry.setDetail(entryImport.getDetail());
+ entry.setVoucher(entryImport.getVoucher());
+ entry.setPosition(entryImport.getPosition());
+ log.debug(entry);
+ entryDAO.create(entry);
+ financialTransaction.addEntry(entry);
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (ParseException eeePE) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't parse date", eeePE);
+ }
+ }
+ return result;
+ }
+
protected TopiaContext beginTransaction() throws TopiaException {
// basic check done, make check in database
// TODO move it into JTA
@@ -689,4 +853,15 @@
log.trace("beginTransaction"+topiaTransaction);
return topiaTransaction;
}
+
+ protected void commitTransaction(TopiaContext topiaTransaction) throws TopiaException {
+ try {
+ topiaTransaction.commitTransaction();
+ } catch (TopiaException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during commit context", eee);
+ }
+ throw eee;
+ }
+ }
}
Modified: 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 2010-07-05 17:07:51 UTC (rev 2963)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -1,4 +1,4 @@
-/* *##% Lima Swing
+/* *##% Lima Business
* Copyright (C) 2008 - 2010 CodeLutin
*
* This program is free software; you can redistribute it and/or
@@ -14,7 +14,8 @@
* 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;
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-07-05 17:07:51 UTC (rev 2963)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -1,4 +1,4 @@
-/* *##% Lima Swing
+/* *##% Lima Business
* Copyright (C) 2008 - 2010 CodeLutin
*
* This program is free software; you can redistribute it and/or
@@ -14,7 +14,8 @@
* 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;
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FiscalPeriodComparator.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -0,0 +1,35 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business.utils;
+
+import java.util.Comparator;
+import org.chorem.lima.entity.FiscalPeriod;
+
+public class FiscalPeriodComparator implements Comparator<FiscalPeriod>{
+
+ /**
+ * sort by accout number in lexicographical order
+ */
+ @Override
+ public int compare(FiscalPeriod o1, FiscalPeriod o2) {
+ return o1.getBeginDate().compareTo(o2.getBeginDate());
+ }
+
+}
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-05 17:07:51 UTC (rev 2963)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -25,7 +25,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
-import org.chorem.lima.business.ImportService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-05 17:07:51 UTC (rev 2963)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-06 16:39:52 UTC (rev 2964)
@@ -19,7 +19,10 @@
package org.chorem.lima.util;
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
@@ -95,8 +98,8 @@
String result = "";
byte[] buffer = new byte[(int) new File(path).length()];
try {
- FileReader f = new FileReader(new File(path));
- f.read();
+ BufferedInputStream f = new BufferedInputStream(new FileInputStream(path));
+ f.read(buffer);
if (importMethode.equals("importEntryBookChart")){
result = importService.importEntryBooksChartAsCSV(new String(buffer));
@@ -118,7 +121,7 @@
}
}
- return result;
+ return result;
}
public static ImportExport getInstance() {
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-07-05 17:07:51 UTC (rev 2963)
+++ trunk/pom.xml 2010-07-06 16:39:52 UTC (rev 2964)
@@ -248,8 +248,6 @@
<properties>
<platform>chorem.org</platform>
<projectId>lima</projectId>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- customized libs version -->
<nuiton-utils.version>1.3.2-SNAPSHOT</nuiton-utils.version>
1
0
r2963 - 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/service lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/util
by jpepin@users.chorem.org 05 Jul '10
by jpepin@users.chorem.org 05 Jul '10
05 Jul '10
Author: jpepin
Date: 2010-07-05 19:07:51 +0200 (Mon, 05 Jul 2010)
New Revision: 2963
Url: http://chorem.org/repositories/revision/lima/2963
Log:
Split importexportservice (trop de m?\195?\169thodes) : en exportservice, et importservice + refactor.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ExportServiceLocal.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportServiceLocal.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportServiceLocal.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
Modified:
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/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -0,0 +1,63 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import javax.ejb.Remote;
+
+/**
+ * Import export service.
+ *
+ * Currently import and export as XML.
+ *
+ * @author chatellier
+ * @version $Revision: 2962 $
+ *
+ * Last update : $Date: 2010-07-05 16:59:28 +0200 (lun., 05 juil. 2010) $
+ * By : $Author: jpepin $
+ */
+@Remote
+public interface ExportService {
+
+
+ /**
+ * Get database export as CSV;
+ *
+ * @return export as byte array
+ * @throws LimaException
+ */
+ public String exportAsCSV() throws LimaException;
+
+ /**
+ * export entrybook chart as CSV.
+ */
+ public String exportEntryBookChartAsCSV() throws LimaException;
+
+ /**
+ * export financialstatement chart as CSV.
+ */
+ public String exportFinancialStatementChartAsCSV() throws LimaException;
+
+ /**
+ * export accounts chart as CSV.
+ */
+ public String exportAccountsChartAsCSV() throws LimaException;
+
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ExportServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ExportServiceLocal.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ExportServiceLocal.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -0,0 +1,38 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import javax.ejb.Local;
+
+/**
+ * Import export service.
+ *
+ * Currently import and export as XML.
+ *
+ * @author chatellier
+ * @version $Revision: 2824 $
+ *
+ * Last update : $Date: 2010-04-02 18:55:19 +0200 (ven. 02 avril 2010) $
+ * By : $Author: echatellier $
+ */
+@Local
+public interface ExportServiceLocal extends ExportService {
+
+}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-07-05 14:59:28 UTC (rev 2962)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -1,103 +0,0 @@
-/* *##% Lima Business
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*
- */
-
-package org.chorem.lima.business;
-
-import javax.ejb.Remote;
-
-/**
- * Import export service.
- *
- * Currently import and export as XML.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-@Remote
-public interface ImportExportService {
-
- //########### INPORT
-
- /**
- * Import data as EBP CSV export.
- *
- * @param data
- * @throws LimaException
- */
- public void importAsEbpCSV(byte[] data) throws LimaException;
-
- /**
- * Import data as Sage Maestria export.
- *
- * @param data
- * @throws LimaException
- */
- public void importAsSage(byte[] data) throws LimaException;
-
- /**
- * Import data as Ciel Compta export.
- *
- * @param data
- * @throws LimaException
- */
- public void importAsCiel(byte[] data) throws LimaException;
-
- /**
- * import CSV.
- * Return result log
- */
- public String importCSV(String path) throws LimaException;
-
- public String importAccountsChartAsCSV(String path) throws LimaException;
-
- public String importFinancialStatementsChartAsCSV(String path) throws LimaException;
-
- public String importEntryBooksChartAsCSV(String path) throws LimaException;
-
-
- //########### EXPORT
-
- /**
- * Get database export as CSV;
- *
- * @return export as byte array
- * @throws LimaException
- */
- public String exportAsCSV() throws LimaException;
-
- /**
- * export entrybook chart as CSV.
- */
- public String exportEntryBookChartAsCSV() throws LimaException;
-
- /**
- * export financialstatement chart as CSV.
- */
- public String exportFinancialStatementChartAsCSV() throws LimaException;
-
- /**
- * export accounts chart as CSV.
- */
- public String exportAccountsChartAsCSV() throws LimaException;
-
-
-}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportServiceLocal.java 2010-07-05 14:59:28 UTC (rev 2962)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportServiceLocal.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -1,38 +0,0 @@
-/* *##% Lima Business
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*
- */
-
-package org.chorem.lima.business;
-
-import javax.ejb.Local;
-
-/**
- * Import export service.
- *
- * Currently import and export as XML.
- *
- * @author chatellier
- * @version $Revision: 2824 $
- *
- * Last update : $Date: 2010-04-02 18:55:19 +0200 (ven. 02 avril 2010) $
- * By : $Author: echatellier $
- */
-@Local
-public interface ImportExportServiceLocal extends ImportExportService {
-
-}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java (from rev 2962, trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -0,0 +1,73 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import javax.ejb.Remote;
+
+/**
+ * Import export service.
+ *
+ * Currently import and export as XML.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+@Remote
+public interface ImportService {
+
+ /**
+ * Import data as EBP CSV export.
+ *
+ * @param data
+ * @throws LimaException
+ */
+ public void importAsEbpCSV(byte[] data) throws LimaException;
+
+ /**
+ * Import data as Sage Maestria export.
+ *
+ * @param data
+ * @throws LimaException
+ */
+ public void importAsSage(byte[] data) throws LimaException;
+
+ /**
+ * Import data as Ciel Compta export.
+ *
+ * @param data
+ * @throws LimaException
+ */
+ public void importAsCiel(byte[] data) throws LimaException;
+
+ /**
+ * import CSV.
+ * Return result log
+ */
+ public String importCSV(String path) throws LimaException;
+
+ public String importAccountsChartAsCSV(String path) throws LimaException;
+
+ public String importFinancialStatementsChartAsCSV(String path) throws LimaException;
+
+ public String importEntryBooksChartAsCSV(String path) throws LimaException;
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportServiceLocal.java (from rev 2958, trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportServiceLocal.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportServiceLocal.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportServiceLocal.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -0,0 +1,38 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import javax.ejb.Local;
+
+/**
+ * Import export service.
+ *
+ * Currently import and export as XML.
+ *
+ * @author chatellier
+ * @version $Revision: 2824 $
+ *
+ * Last update : $Date: 2010-04-02 18:55:19 +0200 (ven. 02 avril 2010) $
+ * By : $Author: echatellier $
+ */
+@Local
+public interface ImportServiceLocal extends ImportService {
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -0,0 +1,493 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import javax.ejb.Stateless;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ExportService;
+import org.chorem.lima.business.ExportServiceLocal;
+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.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookDAO;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
+import org.chorem.lima.entity.FinancialStatement;
+import org.chorem.lima.entity.FinancialStatementDAO;
+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;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+import au.com.bytecode.opencsv.CSVWriter;
+
+/**
+ * CSV import export service.
+ *
+ * @version $Revision: 2962 $
+ *
+ * Last update : $Date: 2010-07-05 16:59:28 +0200 (lun., 05 juil. 2010) $
+ * By : $Author: jpepin $
+ */
+@Stateless
+public class ExportServiceImpl extends AbstractLimaService implements ExportService, ExportServiceLocal {
+
+ private static final Log log =
+ LogFactory.getLog(ExportServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ protected CSVWriter csvWriter;
+
+ protected SimpleDateFormat sdf;
+
+ public ExportServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
+ }
+
+
+ /**
+ * Export integrality of database in CSV
+ */
+ @Override
+ public String exportAsCSV() throws LimaException {
+ TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+
+ try {
+ topiaContext = beginTransaction();
+ csvWriter = new CSVWriter(out, ';');
+ exportAccountsChartAsCSV(topiaContext);
+ exportEntryBookChartAsCSV(topiaContext);
+ exportFinancialStatementChartAsCSV(topiaContext);
+ exportFiscalPeriodAsCSV(topiaContext);
+ exportFinancialPeriodAsCSV(topiaContext);
+ exportClosedPeriodicEntryBooksAsCSV(topiaContext);
+ exportFinancialTransactionsAsCSV(topiaContext);
+ exportEntriesAsCSV(topiaContext);
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+ /**
+ * Remote methode call from UI.
+ */
+ @Override
+ public String exportFinancialStatementChartAsCSV() throws LimaException {
+ TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+
+ try {
+ topiaContext = beginTransaction();
+ csvWriter = new CSVWriter(out, ';');
+ exportFinancialStatementChartAsCSV(topiaContext);
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+ /**
+ * Local methode, export financialstatements from database
+ * structure : TYPE | Label | Header | Accounts | DebitAccounts
+ * | CreditAccounts | ProvisionDeprecationAccounts | SubAmount
+ * | HeaderAmount | MasterFinancialStatement
+ */
+ public void exportFinancialStatementChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[10];
+ // Get all Financialstatements
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+ List<FinancialStatement> listFinancialStatements =
+ financialStatementDAO.findAll();
+ // For all Financialstatements
+ for (FinancialStatement financialStatement : listFinancialStatements) {
+ nextLine[0] = "FNST";
+ nextLine[1] = financialStatement.getLabel();
+ nextLine[2] = new Boolean(
+ financialStatement.getHeader()).toString();
+ nextLine[3] = financialStatement.getAccounts();
+ nextLine[4] = financialStatement.getDebitAccounts();
+ nextLine[5] = financialStatement.getCreditAccounts();
+ nextLine[6] = financialStatement.
+ getProvisionDeprecationAccounts();
+ nextLine[7] = new Boolean(
+ financialStatement.getSubAmount()).toString();
+ nextLine[8] = new Boolean(
+ financialStatement.getHeaderAmount()).toString();
+ FinancialStatement masterFinancialStatement =
+ financialStatement.getMasterFinancialStatement();
+ String masterFinancialStatementString = "";
+ if (masterFinancialStatement != null){
+ masterFinancialStatementString =
+ masterFinancialStatement.getLabel();
+ }
+ nextLine[9] = masterFinancialStatementString;
+ // Add line in file
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Remote methode call from UI.
+ */
+ @Override
+ public String exportEntryBookChartAsCSV() throws LimaException {
+ TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+
+ try {
+ topiaContext = beginTransaction();
+ csvWriter = new CSVWriter(out, ';');
+ exportEntryBookChartAsCSV(topiaContext);
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+
+ /**
+ * Local methode, export entrybooks from database
+ * Structure : TYPE | Code | Label | Type
+ */
+ public void exportEntryBookChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[4];
+ // Get all entrybook
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+ List<EntryBook> listEntryBook = entryBookDAO.findAll();
+ // For all EntryBook
+ for (EntryBook entryBook : listEntryBook) {
+ nextLine[0] = "ENBK";
+ nextLine[1] = entryBook.getCode();
+ nextLine[2] = entryBook.getLabel();
+ nextLine[3] = entryBook.getType();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Remote methode call from UI.
+ */
+ @Override
+ public String exportAccountsChartAsCSV() throws LimaException {
+ TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+ try {
+ topiaContext = beginTransaction();
+ csvWriter = new CSVWriter(out, ';');
+ exportAccountsChartAsCSV(topiaContext);
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+ /**
+ * Local methode, export accounts from database
+ * Structure : TYPE | AccountNumber | Label | ThirdParty | MasteAccount | GeneralLedger
+ */
+ public void exportAccountsChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[6];
+ // Récupère tous les comptes
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ List<Account> listAccount = accountDAO.findAll();
+ // Pour tous les comptes
+ for (Account account : listAccount) {
+ nextLine[0] = "ACCN";
+ nextLine[1] = account.getAccountNumber();
+ nextLine[2] = account.getLabel();
+ nextLine[3] = account.getThirdParty();
+ Account masterAccount = account.getMasterAccount();
+ Account generalLedger = account.getGeneralLedger();
+ String masterAccountString = "";
+ String generalLedgerString = "";
+ if (masterAccount != null){
+ masterAccountString = masterAccount.getAccountNumber();
+ }
+ nextLine[4] = masterAccountString;
+ if (generalLedger != null){
+ generalLedgerString = generalLedger.getAccountNumber();
+ }
+ nextLine[5] = generalLedgerString;
+
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export financialtransactions from database
+ * Structue : TYPE | TransactionDate | AmountDebit | AmountCredit
+ * | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code
+ */
+ public void exportFinancialTransactionsAsCSV(TopiaContext topiaContext) throws LimaException {
+ String[] nextLine = new String[7];
+ // Get all financialtransactions
+ try {
+ FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+ List<FinancialTransaction> listFinancialTransaction = financialTransactionDAO.findAll();
+ // For all financialTransaction
+ for (FinancialTransaction financialTransaction : listFinancialTransaction) {
+ nextLine[0] = "FTRC";
+ nextLine[1] = sdf.format(financialTransaction.getTransactionDate());
+ nextLine[2] = new Double(
+ financialTransaction.getAmountDebit()).toString();
+ nextLine[3] = new Double(
+ financialTransaction.getAmountCredit()).toString();
+ nextLine[4] = sdf.format(financialTransaction.getFinancialPeriod().
+ getBeginDate());
+ nextLine[5] = sdf.format(financialTransaction.getFinancialPeriod().
+ getEndDate());
+ nextLine[6] = financialTransaction.getEntryBook().getCode();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export entries from database
+ * Structure : TYPE | Description | Amount | Debit | Lettering | Detail |
+ * Voucher | Position | FinancialTransaction Date | FinancialTransaction Code |
+ * FinancialTransaction AmountDebit | FinancialTransaction AmountCredit
+ */
+ public void exportEntriesAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[12];
+ // Get all Entry
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ List<Entry> listEntry = entryDAO.findAll();
+ // For all Entry
+ for (Entry entry : listEntry) {
+ nextLine[0] = "NTRY";
+ nextLine[1] = entry.getDescription();
+ nextLine[2] = new Double(entry.getAmount()).toString();
+ nextLine[3] = new Boolean(entry.getDebit()).toString();
+ nextLine[4] = entry.getLettering();
+ nextLine[5] = entry.getVoucher();
+ nextLine[6] = entry.getPosition();
+ nextLine[7] = entry.getAccount().getAccountNumber();
+ nextLine[8] = sdf.format(entry.getFinancialTransaction().
+ getTransactionDate());
+ nextLine[9] = entry.getFinancialTransaction().
+ getEntryBook().getCode();
+ nextLine[10] = new Double(entry.getFinancialTransaction()
+ .getAmountDebit()).toString();
+ nextLine[11] = new Double(entry.getFinancialTransaction()
+ .getAmountCredit()).toString();
+
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export fiscalperiods from database
+ * Structure : TYPE | BeginDate | EndDate | Locked
+ */
+ public void exportFiscalPeriodAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[5];
+ // Get all fiscalperiod
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+ List<FiscalPeriod> listFiscalPeriod =
+ fiscalPeriodDAO.findAll();
+ // For all Entry
+ for (FiscalPeriod fiscalPeriod : listFiscalPeriod) {
+ nextLine[0] = "FSCP";
+ nextLine[1] = sdf.format(fiscalPeriod.getBeginDate());
+ nextLine[2] = sdf.format(fiscalPeriod.getEndDate());
+ nextLine[3] = new Boolean(fiscalPeriod.getLocked()).toString();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export financialperiods from database
+ * Structure : TYPE | BeginDate | EndDate | Locked | FiscalPeriod beginDate | FiscalPeriod endDate
+ */
+ public void exportFinancialPeriodAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[6];
+ // Get all fiscalperiod
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+ List<FinancialPeriod> listFinancialPeriod =
+ financialPeriodDAO.findAll();
+
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+
+ // For all Entry
+ for (FinancialPeriod financialPeriod : listFinancialPeriod) {
+ nextLine[0] = "FNCP";
+ nextLine[1] = sdf.format(financialPeriod.getBeginDate());
+ nextLine[2] = sdf.format(financialPeriod.getEndDate());
+ nextLine[3] = new Boolean(financialPeriod.getLocked()).toString();
+ FiscalPeriod fiscalPeriod = fiscalPeriodDAO.
+ findContainsFinancialPeriod(financialPeriod);
+ nextLine[4] = sdf.format(fiscalPeriod.getBeginDate());
+ nextLine[5] = sdf.format(fiscalPeriod.getEndDate());
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export ClosedPeriodicEntryBooks from database
+ * Structure : TYPE | Locked | FinancialPeriod beginDate | FinancialPeriod endDate | EntryBook Code
+ */
+ public void exportClosedPeriodicEntryBooksAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[5];
+ // Get all fiscalperiod
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook =
+ closedPeriodicEntryBookDAO.findAll();
+ // For all Entry
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) {
+ nextLine[0] = "CPEB";
+ nextLine[1] = new Boolean(
+ closedPeriodicEntryBook.getLocked()).toString();
+ nextLine[2] = sdf.format(closedPeriodicEntryBook.getFinancialPeriod().
+ getBeginDate());
+ nextLine[3] =sdf.format(closedPeriodicEntryBook.getFinancialPeriod().
+ getEndDate());
+ nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ protected TopiaContext beginTransaction() throws TopiaException {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ TopiaContext topiaTransaction;
+ topiaTransaction = rootContext.beginTransaction();
+ log.trace("beginTransaction"+topiaTransaction);
+ return topiaTransaction;
+ }
+}
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-07-05 14:59:28 UTC (rev 2962)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -1,947 +0,0 @@
-/* *##% Lima Business
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*
- */
-
-package org.chorem.lima.business.ejb;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Iterator;
-import java.util.List;
-import java.util.TreeMap;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.AccountImport;
-import org.chorem.lima.beans.AccountImportImpl;
-import org.chorem.lima.beans.FinancialStatementImport;
-import org.chorem.lima.beans.FinancialStatementImportImpl;
-import org.chorem.lima.business.AccountServiceLocal;
-import org.chorem.lima.business.EntryBookServiceLocal;
-import org.chorem.lima.business.FinancialStatementServiceLocal;
-import org.chorem.lima.business.FinancialTransactionServiceLocal;
-import org.chorem.lima.business.ImportExportService;
-import org.chorem.lima.business.ImportExportServiceLocal;
-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.AccountImpl;
-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.EntryBookDAO;
-import org.chorem.lima.entity.EntryBookImpl;
-import org.chorem.lima.entity.EntryDAO;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialPeriodDAO;
-import org.chorem.lima.entity.FinancialStatement;
-import org.chorem.lima.entity.FinancialStatementDAO;
-import org.chorem.lima.entity.FinancialStatementImpl;
-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;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import au.com.bytecode.opencsv.CSVReader;
-import au.com.bytecode.opencsv.CSVWriter;
-
-/**
- * CSV import export service.
- *
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-@Stateless
-public class ImportExportServiceImpl extends AbstractLimaService implements ImportExportService, ImportExportServiceLocal {
-
- private static final Log log =
- LogFactory.getLog(ImportExportServiceImpl.class);
-
- private TopiaContext rootContext;
-
- @EJB
- AccountServiceLocal accountService;
-
- @EJB
- FinancialTransactionServiceLocal financialTransactionService;
-
- @EJB
- FinancialStatementServiceLocal financialStatementService;
-
- @EJB
- EntryBookServiceLocal entryBookService;
-
- protected CSVWriter csvWriter;
-
- public ImportExportServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
- }
-
- //################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
-
-
- /*
- * @see org.chorem.lima.business.ImportExportService#importAsEBPCSV(byte[])
- */
- @Override
- public void importAsEbpCSV(byte[] data) throws LimaException {
-
- }
-
- @Override
- public void importAsCiel(byte[] data) throws LimaException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void importAsSage(byte[] data) throws LimaException {
- // TODO Auto-generated method stub
-
- }
-
-
- //################ EXPORT ################
-
- /**
- * Export integrality of database in CSV
- */
- @Override
- public String exportAsCSV() throws LimaException {
- TopiaContext topiaContext = null;
- StringWriter out = new StringWriter();
-
- try {
- topiaContext = beginTransaction();
- csvWriter = new CSVWriter(out, ';');
- exportAccountsChartAsCSV(topiaContext);
- exportEntryBookChartAsCSV(topiaContext);
- exportFinancialStatementChartAsCSV(topiaContext);
- exportFiscalPeriodAsCSV(topiaContext);
- exportFinancialPeriodAsCSV(topiaContext);
- exportClosedPeriodicEntryBooksAsCSV(topiaContext);
- exportFinancialTransactionsAsCSV(topiaContext);
- exportEntriesAsCSV(topiaContext);
- // Write cache in file
- csvWriter.flush();
- csvWriter.close();
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Writer",eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return out.getBuffer().toString();
- }
-
- /**
- * Remote methode call from UI.
- */
- @Override
- public String exportFinancialStatementChartAsCSV() throws LimaException {
- TopiaContext topiaContext = null;
- StringWriter out = new StringWriter();
-
- try {
- topiaContext = beginTransaction();
- csvWriter = new CSVWriter(out, ';');
- exportFinancialStatementChartAsCSV(topiaContext);
- // Write cache in file
- csvWriter.flush();
- csvWriter.close();
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Writer",eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return out.getBuffer().toString();
- }
-
- /**
- * Local methode, export financialstatements from database
- * structure : TYPE | Label | Header | Accounts | DebitAccounts
- * | CreditAccounts | ProvisionDeprecationAccounts | SubAmount
- * | HeaderAmount | MasterFinancialStatement
- */
- public void exportFinancialStatementChartAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[10];
- // Get all Financialstatements
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
- List<FinancialStatement> listFinancialStatements =
- financialStatementDAO.findAll();
- // For all Financialstatements
- for (FinancialStatement financialStatement : listFinancialStatements) {
- nextLine[0] = "FNST";
- nextLine[1] = financialStatement.getLabel();
- nextLine[2] = new Boolean(
- financialStatement.getHeader()).toString();
- nextLine[3] = financialStatement.getAccounts();
- nextLine[4] = financialStatement.getDebitAccounts();
- nextLine[5] = financialStatement.getCreditAccounts();
- nextLine[6] = financialStatement.
- getProvisionDeprecationAccounts();
- nextLine[7] = new Boolean(
- financialStatement.getSubAmount()).toString();
- nextLine[8] = new Boolean(
- financialStatement.getHeaderAmount()).toString();
- FinancialStatement masterFinancialStatement =
- financialStatement.getMasterFinancialStatement();
- String masterFinancialStatementString = "";
- if (masterFinancialStatement != null){
- masterFinancialStatementString =
- masterFinancialStatement.getLabel();
- }
- nextLine[9] = masterFinancialStatementString;
- // Add line in file
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
-
- /**
- * Remote methode call from UI.
- */
- @Override
- public String exportEntryBookChartAsCSV() throws LimaException {
- TopiaContext topiaContext = null;
- StringWriter out = new StringWriter();
-
- try {
- topiaContext = beginTransaction();
- csvWriter = new CSVWriter(out, ';');
- exportEntryBookChartAsCSV(topiaContext);
- // Write cache in file
- csvWriter.flush();
- csvWriter.close();
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Writer",eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return out.getBuffer().toString();
- }
-
-
- /**
- * Local methode, export entrybooks from database
- * Structure : TYPE | Code | Label | Type
- */
- public void exportEntryBookChartAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[4];
- // Get all entrybook
- EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
- List<EntryBook> listEntryBook = entryBookDAO.findAll();
- // For all EntryBook
- for (EntryBook entryBook : listEntryBook) {
- nextLine[0] = "ENBK";
- nextLine[1] = entryBook.getCode();
- nextLine[2] = entryBook.getLabel();
- nextLine[3] = entryBook.getType();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
-
- /**
- * Remote methode call from UI.
- */
- @Override
- public String exportAccountsChartAsCSV() throws LimaException {
- TopiaContext topiaContext = null;
- StringWriter out = new StringWriter();
- try {
- topiaContext = beginTransaction();
- csvWriter = new CSVWriter(out, ';');
- exportAccountsChartAsCSV(topiaContext);
- // Write cache in file
- csvWriter.flush();
- csvWriter.close();
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Writer",eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return out.getBuffer().toString();
- }
-
- /**
- * Local methode, export accounts from database
- * Structure : TYPE | AccountNumber | Label | ThirdParty | MasteAccount | GeneralLedger
- */
- public void exportAccountsChartAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[6];
- // Récupère tous les comptes
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(topiaContext);
- List<Account> listAccount = accountDAO.findAll();
- // Pour tous les comptes
- for (Account account : listAccount) {
- nextLine[0] = "ACCN";
- nextLine[1] = account.getAccountNumber();
- nextLine[2] = account.getLabel();
- nextLine[3] = account.getThirdParty();
- Account masterAccount = account.getMasterAccount();
- Account generalLedger = account.getGeneralLedger();
- String masterAccountString = "";
- String generalLedgerString = "";
- if (masterAccount != null){
- masterAccountString = masterAccount.getAccountNumber();
- }
- nextLine[4] = masterAccountString;
- if (generalLedger != null){
- generalLedgerString = generalLedger.getAccountNumber();
- }
- nextLine[5] = generalLedgerString;
-
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
-
- /**
- * Local methode, export financialtransactions from database
- * Structue : TYPE | TransactionDate | AmountDebit | AmountCredit
- * | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code
- */
- public void exportFinancialTransactionsAsCSV(TopiaContext topiaContext) throws LimaException {
- String[] nextLine = new String[7];
- // Get all financialtransactions balanced
- List<FinancialTransaction> listFinancialTransaction =
- financialTransactionService.getAllFinancialTransactionsBalanced(topiaContext);
- // For all balanced financialTransaction
- for (FinancialTransaction financialTransaction : listFinancialTransaction) {
- nextLine[0] = "FTRC";
- nextLine[1] = financialTransaction.getTransactionDate().toString();
- nextLine[2] = new Double(
- financialTransaction.getAmountDebit()).toString();
- nextLine[3] = new Double(
- financialTransaction.getAmountCredit()).toString();
- nextLine[4] = financialTransaction.getFinancialPeriod().
- getBeginDate().toString();
- nextLine[5] = financialTransaction.getFinancialPeriod().
- getEndDate().toString();
- nextLine[6] = financialTransaction.getEntryBook().getCode();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
-
- /**
- * Local methode, export entries from database
- * Structure : TYPE | Description | Amount | Debit | Lettering | Detail |
- * Voucher | Position | FinancialTransaction Date | FinancialTransaction Code |
- * FinancialTransaction AmountDebit | FinancialTransaction AmountCredit
- */
- public void exportEntriesAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[12];
- // Get all Entry
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- List<Entry> listEntry = entryDAO.findAll();
- // For all Entry
- for (Entry entry : listEntry) {
- nextLine[0] = "NTRY";
- nextLine[1] = entry.getDescription();
- nextLine[2] = new Double(entry.getAmount()).toString();
- nextLine[3] = new Boolean(entry.getDebit()).toString();
- nextLine[4] = entry.getLettering();
- nextLine[5] = entry.getVoucher();
- nextLine[6] = entry.getPosition();
- nextLine[7] = entry.getAccount().getAccountNumber();
- nextLine[8] = entry.getFinancialTransaction().
- getTransactionDate().toString();
- nextLine[9] = entry.getFinancialTransaction().
- getEntryBook().getCode();
- nextLine[10] = new Double(entry.getFinancialTransaction()
- .getAmountDebit()).toString();
- nextLine[11] = new Double(entry.getFinancialTransaction()
- .getAmountCredit()).toString();
-
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
-
- /**
- * Local methode, export fiscalperiods from database
- * Structure : TYPE | BeginDate | EndDate | Locked
- */
- public void exportFiscalPeriodAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[5];
- // Get all fiscalperiod
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
- List<FiscalPeriod> listFiscalPeriod =
- fiscalPeriodDAO.findAll();
- // For all Entry
- for (FiscalPeriod fiscalPeriod : listFiscalPeriod) {
- nextLine[0] = "FSCP";
- nextLine[1] = fiscalPeriod.getBeginDate().toString();
- nextLine[2] = fiscalPeriod.getEndDate().toString();
- nextLine[3] = new Boolean(fiscalPeriod.getLocked()).toString();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
-
- /**
- * Local methode, export financialperiods from database
- * Structure : TYPE | BeginDate | EndDate | Locked | FiscalPeriod beginDate | FiscalPeriod endDate
- */
- public void exportFinancialPeriodAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[6];
- // Get all fiscalperiod
- FinancialPeriodDAO financialPeriodDAO =
- LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
- List<FinancialPeriod> listFinancialPeriod =
- financialPeriodDAO.findAll();
-
- FiscalPeriodDAO fiscalPeriodDAO =
- LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
-
- // For all Entry
- for (FinancialPeriod financialPeriod : listFinancialPeriod) {
- nextLine[0] = "FNCP";
- nextLine[1] = financialPeriod.getBeginDate().toString();
- nextLine[2] = financialPeriod.getEndDate().toString();
- nextLine[3] = new Boolean(financialPeriod.getLocked()).toString();
- FiscalPeriod fiscalPeriod = fiscalPeriodDAO.
- findContainsFinancialPeriod(financialPeriod);
- nextLine[4] = fiscalPeriod.getBeginDate().toString();
- nextLine[5] = fiscalPeriod.getEndDate().toString();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
-
- /**
- * Local methode, export ClosedPeriodicEntryBooks from database
- * Structure : TYPE | Locked | FinancialPeriod beginDate | FinancialPeriod endDate | EntryBook Code
- */
- public void exportClosedPeriodicEntryBooksAsCSV(TopiaContext topiaContext) throws LimaException {
- try {
- String[] nextLine = new String[5];
- // Get all fiscalperiod
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
- List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook =
- closedPeriodicEntryBookDAO.findAll();
- // For all Entry
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) {
- nextLine[0] = "CPEB";
- nextLine[1] = new Boolean(
- closedPeriodicEntryBook.getLocked()).toString();
- nextLine[2] = closedPeriodicEntryBook.getFinancialPeriod().
- getBeginDate().toString();
- nextLine[3] =closedPeriodicEntryBook.getFinancialPeriod().
- getEndDate().toString();
- nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- }
-
- //################ IMPORT ################
-
-
- @Override
- public String importCSV(String datas) throws LimaException {
- String result = "";
-
- //Accounts
- TreeMap<String, AccountImport> accounts =
- new TreeMap<String, AccountImport>();
-
- //FinancialStatements
- TreeMap<String, FinancialStatementImport> financialStatements =
- new TreeMap<String, FinancialStatementImport>();
-
- TopiaContext topiaContext = null;
- try {
- topiaContext = beginTransaction();
-
- String[] nextLine = new String[1];
- CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
-
-
- while ((nextLine = csvReader.readNext()) != null) {
- String indice = nextLine[0];
- if (indice.equals("ACCN")){
- accounts = importAccountsChartsCSV(
- nextLine, accounts, topiaContext);
- }
- else if (indice.equals("ENBK")){
- result+=importEntryBooksChartCSV(
- nextLine, topiaContext);
- }
- else if (indice.equals("FNST")){
- financialStatements = importFinancialsStatementChartCSV(
- nextLine, financialStatements, topiaContext);
- }
- else if (indice.equals("FSCP")){
- //result+=
- }
- else if (indice.equals("FNCP")){
- //result+=
- }
- else if (indice.equals("CPEB")){
- //result+=
- }
- else if (indice.equals("FTRC")){
- //result+=
- }
- else if (indice.equals("NTRY")){
- //result+=
- }
- }
-
- //create accounts
- result+=createAccounts(accounts, topiaContext);
- //create financialStatements
- result+=createFinancialStatements(financialStatements, topiaContext);
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Reader",eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return result;
- }
-
- @Override
- public String importEntryBooksChartAsCSV(String datas) throws LimaException{
- String result = "";
-
- TopiaContext topiaContext = null;
- try {
- topiaContext = beginTransaction();
-
- String[] nextLine = new String[1];
- CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
-
- while ((nextLine = csvReader.readNext()) != null) {
- String indice = nextLine[0];
- if (indice.equals("ENBK")){
- result+=importEntryBooksChartCSV(nextLine, topiaContext);
- }
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Reader",eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return result;
- }
-
-
- @Override
- public String importFinancialStatementsChartAsCSV(String datas) throws LimaException {
- String result = "";
-
- //FinancialStatements
- TreeMap<String, FinancialStatementImport> financialStatements =
- new TreeMap<String, FinancialStatementImport>();
-
- TopiaContext topiaContext = null;
- try {
- topiaContext = beginTransaction();
-
- String[] nextLine = new String[1];
- CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
-
- while ((nextLine = csvReader.readNext()) != null) {
- String indice = nextLine[0];
- if (indice.equals("FNST")){
- financialStatements = importFinancialsStatementChartCSV(
- nextLine, financialStatements, topiaContext);
- }
- }
-
- //create financialStatements
- result+=createFinancialStatements(financialStatements, topiaContext);
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Reader",eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return result;
- }
-
-
- @Override
- public String importAccountsChartAsCSV(String datas) throws LimaException {
- String result = "";
-
- //Accounts
- TreeMap<String, AccountImport> accounts =
- new TreeMap<String, AccountImport>();
-
- TopiaContext topiaContext = null;
- try {
- topiaContext = beginTransaction();
-
- String[] nextLine = new String[1];
- CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
-
-
- while ((nextLine = csvReader.readNext()) != null) {
- String indice = nextLine[0];
- if (indice.equals("ACCN")){
- accounts = importAccountsChartsCSV(
- nextLine, accounts, topiaContext);
- }
- }
-
- //create accounts
- result+=createAccounts(accounts, topiaContext);
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Reader",eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return result;
- }
-
- public TreeMap<String, AccountImport> importAccountsChartsCSV(String[] nextLine, TreeMap<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException{
-
- String accountNumber = nextLine[1];
- String label = nextLine[2];
- String thirdParty = nextLine[3];
- String masterAccountNumber = nextLine[4];
- String generalLedgerNumber = nextLine[5];
-
- try {
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(topiaContext);
-
- //if not exist, create it
- if (accountDAO.findByAccountNumber(accountNumber) == null){
- //create it
- AccountImport accountImport = new AccountImportImpl();
- accountImport.setAccountNumber(accountNumber);
- accountImport.setLabel(label);
- accountImport.setThirdParty(thirdParty);
- accountImport.setMasterAccount(masterAccountNumber);
- accountImport.setGeneralLedger(generalLedgerNumber);
- // put it in hashset
- accounts.put(accountNumber, accountImport);
- }
- /*else {
- result += "FAILED : The account "
- + accountNumber + " already exists !\n";
- }*/
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
-
- return accounts;
- }
-
-
- public String createAccounts(TreeMap<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException {
- String result = "";
-
- try {
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
-
- while (accounts.size() > 0){
- for (Iterator<AccountImport> itr = accounts.values().iterator(); itr.hasNext();){
- AccountImport accountImport = itr.next();
- String masterAccountNumber = accountImport.getMasterAccount();
- String generalLedgerNumber = accountImport.getGeneralLedger();
- Account masterAccount =
- accountDAO.findByAccountNumber(masterAccountNumber);
- Account generalLedger =
- accountDAO.findByAccountNumber(generalLedgerNumber);
-
- if ((masterAccountNumber.equals("") && generalLedgerNumber.equals(""))
- || masterAccount != null || generalLedger != null){
- //create it
- Account account = new AccountImpl();
- account.setAccountNumber(accountImport.getAccountNumber());
- account.setLabel(accountImport.getLabel());
- account.setThirdParty(accountImport.getThirdParty());
-
- if (generalLedger != null){
- accountService.createSubLedger(generalLedger, account);
- }
- else {
- accountService.createAccount(masterAccount, account);
- }
- result += "SUCCESS : The account " +
- accountImport.getAccountNumber() + " is created ! \n";
- itr.remove();
- }
- else if (!accounts.containsKey(masterAccountNumber)
- && !accounts.containsKey(generalLedgerNumber) ){
- result += "FAILED : The account " +
- accountImport.getAccountNumber() + " have masterAccount : " +
- masterAccountNumber + "which not exist \n";
- itr.remove();
- }
- }
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- return result;
- }
-
-
- public String importEntryBooksChartCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
- String result ="";
- try {
-
- EntryBookDAO entryBookDAO =
- LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
-
- EntryBook entryBook = new EntryBookImpl();
- entryBook.setCode(nextLine[1]);
- entryBook.setLabel(nextLine[2]);
- entryBook.setType(nextLine[3]);
-
- //if exist, skip
- if (entryBookDAO.findByCode(entryBook.getCode()) != null){
- result += "FAILED : The entrybook "
- + entryBook.getLabel() + " already exists !\n";
- }
- else {
- //create it
- entryBookService.createEntryBook(entryBook);
- result += "SUCCESS : The financialStatement " +
- entryBook.getLabel() + " is created ! \n";
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- return result;
- }
-
-
- public TreeMap<String, FinancialStatementImport> importFinancialsStatementChartCSV(String[] nextLine, TreeMap<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
-
- String label = nextLine[1];
- String header = nextLine[2];
- String accounts = nextLine[3];
- String debitAccounts = nextLine[4];
- String creditAccounts = nextLine[5];
- String provisionDeprecationAccounts = nextLine[6];
- String subAmount = nextLine[7];
- String headerAmount = nextLine[8];
- String masterFinancialStatement = nextLine[9];
-
- try {
-
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
-
- //if exist, skip
- if (financialStatementDAO.findByLabel(label) == null){
- //create it
- FinancialStatementImport financialStatementImport =
- new FinancialStatementImportImpl();
- financialStatementImport.setLabel(label);
- financialStatementImport.setHeader(header);
- financialStatementImport.setAccounts(accounts);
- financialStatementImport.setCreditAccounts(creditAccounts);
- financialStatementImport.setDebitAccounts(debitAccounts);
- financialStatementImport.setHeaderAmount(headerAmount);
- financialStatementImport.setProvisionDeprecationAccounts(
- provisionDeprecationAccounts);
- financialStatementImport.setSubAmount(subAmount);
- financialStatementImport.setMasterFinancialStatement(
- masterFinancialStatement);
-
- // put it in hashset
- financialStatements.put(label, financialStatementImport);
- }
- /*else {
- result += "FAILED : The financialstatement "
- + label + " already exists !\n";
- }*/
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- return financialStatements;
- }
-
-
- public String createFinancialStatements(TreeMap<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
- String result = "";
- try {
-
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
-
- while (financialStatements.size() > 0){
- for (Iterator<FinancialStatementImport> itr = financialStatements.values().iterator(); itr.hasNext();){
- FinancialStatementImport financialStatementImport = itr.next();
- String masterFinancialStatementLabel =
- financialStatementImport.getMasterFinancialStatement();
- FinancialStatement masterFinancialStatement =
- financialStatementDAO.findByLabel(
- masterFinancialStatementLabel);
-
- if (masterFinancialStatementLabel.equals("")
- || masterFinancialStatement != null){
- //create it
- FinancialStatement financialStatement =
- new FinancialStatementImpl();
- financialStatement.setLabel(
- financialStatementImport.getLabel());
- financialStatement.setHeader(Boolean.parseBoolean(
- financialStatementImport.getHeader()));
- financialStatement.setAccounts(
- financialStatementImport.getAccounts());
- financialStatement.setDebitAccounts(
- financialStatementImport.getDebitAccounts());
- financialStatement.setCreditAccounts(
- financialStatementImport.getCreditAccounts());
- financialStatement.setProvisionDeprecationAccounts(
- financialStatementImport.
- getProvisionDeprecationAccounts());
- financialStatement.setSubAmount(Boolean.parseBoolean(
- financialStatementImport.getSubAmount()));
- financialStatement.setHeaderAmount(Boolean.parseBoolean(
- financialStatementImport.getHeaderAmount()));
-
- financialStatementService.createFinancialStatement(
- masterFinancialStatement, financialStatement);
-
- result += "SUCCESS : The financialStatement " +
- financialStatementImport.getLabel() + " is created ! \n";
- itr.remove();
- }
- else if (!financialStatements.containsKey(masterFinancialStatementLabel)){
- result += "FAILED : The financialStatement " +
- financialStatementImport.getLabel() +
- " have masterFinancialStatement : " +
- masterFinancialStatementLabel + "which not exist \n";
- itr.remove();
- }
- }
- }
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- return result;
- }
-
-
- protected TopiaContext beginTransaction() throws TopiaException {
- // basic check done, make check in database
- // TODO move it into JTA
- TopiaContext topiaTransaction;
- topiaTransaction = rootContext.beginTransaction();
- log.trace("beginTransaction"+topiaTransaction);
- return topiaTransaction;
- }
-}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java (from rev 2962, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -0,0 +1,692 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.TreeMap;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.AccountImport;
+import org.chorem.lima.beans.AccountImportImpl;
+import org.chorem.lima.beans.FinancialPeriodImport;
+import org.chorem.lima.beans.FinancialPeriodImportImpl;
+import org.chorem.lima.beans.FinancialStatementImport;
+import org.chorem.lima.beans.FinancialStatementImportImpl;
+import org.chorem.lima.business.AccountServiceLocal;
+import org.chorem.lima.business.EntryBookServiceLocal;
+import org.chorem.lima.business.FinancialStatementServiceLocal;
+import org.chorem.lima.business.FinancialTransactionServiceLocal;
+import org.chorem.lima.business.ImportService;
+import org.chorem.lima.business.ImportServiceLocal;
+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.AccountImpl;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookDAO;
+import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
+import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FinancialStatement;
+import org.chorem.lima.entity.FinancialStatementDAO;
+import org.chorem.lima.entity.FinancialStatementImpl;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.FiscalPeriodDAO;
+import org.chorem.lima.entity.FiscalPeriodImpl;
+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 au.com.bytecode.opencsv.CSVReader;
+import au.com.bytecode.opencsv.CSVWriter;
+
+/**
+ * CSV import export service.
+ *
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+@Stateless
+public class ImportServiceImpl extends AbstractLimaService implements ImportService, ImportServiceLocal {
+
+ private static final Log log =
+ LogFactory.getLog(ImportServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ @EJB
+ AccountServiceLocal accountService;
+
+ @EJB
+ FinancialTransactionServiceLocal financialTransactionService;
+
+ @EJB
+ FinancialStatementServiceLocal financialStatementService;
+
+ @EJB
+ EntryBookServiceLocal entryBookService;
+
+ protected CSVWriter csvWriter;
+
+ protected SimpleDateFormat sdf;
+
+ public ImportServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss");
+ }
+
+ //################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
+
+
+ /*
+ * @see org.chorem.lima.business.ImportExportService#importAsEBPCSV(byte[])
+ */
+ @Override
+ public void importAsEbpCSV(byte[] data) throws LimaException {
+
+ }
+
+ @Override
+ public void importAsCiel(byte[] data) throws LimaException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void importAsSage(byte[] data) throws LimaException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ //################ IMPORT ################
+
+
+ @Override
+ public String importCSV(String datas) throws LimaException {
+ String result = "";
+
+ //Accounts
+ TreeMap<String, AccountImport> accounts =
+ new TreeMap<String, AccountImport>();
+
+ //FinancialStatements
+ TreeMap<String, FinancialStatementImport> financialStatements =
+ new TreeMap<String, FinancialStatementImport>();
+
+ //FiscalPeriods
+ List<FiscalPeriod> fiscalPeriods = new ArrayList<FiscalPeriod>();
+
+ //FinancialPeriods
+ List<FinancialPeriodImport> financialPeriodImports =
+ new ArrayList<FinancialPeriodImport>();
+
+
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+
+ String[] nextLine = new String[1];
+ CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
+
+
+ while ((nextLine = csvReader.readNext()) != null) {
+ String indice = nextLine[0];
+ if (indice.equals("ACCN")){
+ accounts = importAccountsChartsCSV(
+ nextLine, accounts, topiaContext);
+ }
+ else if (indice.equals("ENBK")){
+ result += importEntryBooksChartCSV(
+ nextLine, topiaContext);
+ }
+ else if (indice.equals("FNST")){
+ financialStatements = importFinancialsStatementChartCSV(
+ nextLine, financialStatements, topiaContext);
+ }
+ else if (indice.equals("FSCP")){
+ fiscalPeriods = importFiscalPeriodCSV(nextLine, fiscalPeriods, topiaContext);
+ }
+ else if (indice.equals("FNCP")){
+ financialPeriodImports = importFinancialPeriodChartCSV(nextLine, financialPeriodImports, topiaContext);
+ }
+ else if (indice.equals("CPEB")){
+ //result+=
+ }
+ else if (indice.equals("FTRC")){
+ //result+=
+ }
+ else if (indice.equals("NTRY")){
+ //result+=
+ }
+ }
+
+ //create accounts
+ result+=createAccounts(accounts, topiaContext);
+ //create financialStatements
+ result+=createFinancialStatements(financialStatements, topiaContext);
+ //create fiscalperiod
+
+ //create financialperiod
+ result+=createFinancialPeriod(financialPeriodImports, topiaContext);
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+ }
+
+ @Override
+ public String importEntryBooksChartAsCSV(String datas) throws LimaException{
+ String result = "";
+
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+
+ String[] nextLine = new String[1];
+ CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
+
+ while ((nextLine = csvReader.readNext()) != null) {
+ String indice = nextLine[0];
+ if (indice.equals("ENBK")){
+ result+=importEntryBooksChartCSV(nextLine, topiaContext);
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+ }
+
+
+ @Override
+ public String importFinancialStatementsChartAsCSV(String datas) throws LimaException {
+ String result = "";
+
+ //FinancialStatements
+ TreeMap<String, FinancialStatementImport> financialStatements =
+ new TreeMap<String, FinancialStatementImport>();
+
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+
+ String[] nextLine = new String[1];
+ CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
+
+ while ((nextLine = csvReader.readNext()) != null) {
+ String indice = nextLine[0];
+ if (indice.equals("FNST")){
+ financialStatements = importFinancialsStatementChartCSV(
+ nextLine, financialStatements, topiaContext);
+ }
+ }
+
+ //create financialStatements
+ result+=createFinancialStatements(financialStatements, topiaContext);
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+ }
+
+
+ @Override
+ public String importAccountsChartAsCSV(String datas) throws LimaException {
+ String result = "";
+
+ //Accounts
+ TreeMap<String, AccountImport> accounts =
+ new TreeMap<String, AccountImport>();
+
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+
+ String[] nextLine = new String[1];
+ CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
+
+
+ while ((nextLine = csvReader.readNext()) != null) {
+ String indice = nextLine[0];
+ if (indice.equals("ACCN")){
+ accounts = importAccountsChartsCSV(
+ nextLine, accounts, topiaContext);
+ }
+ }
+
+ //create accounts
+ result+=createAccounts(accounts, topiaContext);
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+ }
+
+ public TreeMap<String, AccountImport> importAccountsChartsCSV(String[] nextLine, TreeMap<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException{
+
+ String accountNumber = nextLine[1];
+ String label = nextLine[2];
+ String thirdParty = nextLine[3];
+ String masterAccountNumber = nextLine[4];
+ String generalLedgerNumber = nextLine[5];
+
+ try {
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+
+ //if not exist, create it
+ if (accountDAO.findByAccountNumber(accountNumber) == null){
+ //create it
+ AccountImport accountImport = new AccountImportImpl();
+ accountImport.setAccountNumber(accountNumber);
+ accountImport.setLabel(label);
+ accountImport.setThirdParty(thirdParty);
+ accountImport.setMasterAccount(masterAccountNumber);
+ accountImport.setGeneralLedger(generalLedgerNumber);
+ // put it in hashset
+ accounts.put(accountNumber, accountImport);
+ }
+ /*else {
+ result += "FAILED : The account "
+ + accountNumber + " already exists !\n";
+ }*/
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+
+ return accounts;
+ }
+
+
+ /**
+ * Import and create fiscal period
+ * Structure : TYPE | BeginDate | EndDate | Locked
+ */
+ public List<FiscalPeriod> importFiscalPeriodCSV(String[] nextLine, List<FiscalPeriod> fiscalPeriods, TopiaContext topiaContext) throws LimaException {
+ try {
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+
+ FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
+ Date beginDate = sdf.parse(nextLine[1]);
+ fiscalPeriod.setBeginDate(beginDate);
+ Date endDate = sdf.parse(nextLine[2]);
+ fiscalPeriod.setEndDate(endDate);
+ fiscalPeriod.setLocked(new Boolean(nextLine[3]));
+
+ //if not exist, skip
+ if (fiscalPeriodDAO.findByNaturalId(beginDate, endDate) == null){
+ fiscalPeriods.add(fiscalPeriod);
+ }
+ }
+ catch (ParseException eeePE) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't parse date", eeePE);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ return fiscalPeriods;
+ }
+
+
+ public String importEntryBooksChartCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ String result ="";
+ try {
+
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+
+ EntryBook entryBook = new EntryBookImpl();
+ entryBook.setCode(nextLine[1]);
+ entryBook.setLabel(nextLine[2]);
+ entryBook.setType(nextLine[3]);
+
+ //if exist, skip
+ if (entryBookDAO.findByCode(entryBook.getCode()) != null){
+ result += "FAILED : The entrybook "
+ + entryBook.getLabel() + " already exists !\n";
+ }
+ else {
+ //create it
+ entryBookService.createEntryBook(entryBook);
+ result += "SUCCESS : The financialStatement " +
+ entryBook.getLabel() + " is created ! \n";
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ return result;
+ }
+
+
+ public TreeMap<String, FinancialStatementImport> importFinancialsStatementChartCSV(String[] nextLine, TreeMap<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
+
+ String label = nextLine[1];
+ String header = nextLine[2];
+ String accounts = nextLine[3];
+ String debitAccounts = nextLine[4];
+ String creditAccounts = nextLine[5];
+ String provisionDeprecationAccounts = nextLine[6];
+ String subAmount = nextLine[7];
+ String headerAmount = nextLine[8];
+ String masterFinancialStatement = nextLine[9];
+
+ try {
+
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+
+ //if exist, skip
+ if (financialStatementDAO.findByLabel(label) == null){
+ //create it
+ FinancialStatementImport financialStatementImport =
+ new FinancialStatementImportImpl();
+ financialStatementImport.setLabel(label);
+ financialStatementImport.setHeader(header);
+ financialStatementImport.setAccounts(accounts);
+ financialStatementImport.setCreditAccounts(creditAccounts);
+ financialStatementImport.setDebitAccounts(debitAccounts);
+ financialStatementImport.setHeaderAmount(headerAmount);
+ financialStatementImport.setProvisionDeprecationAccounts(
+ provisionDeprecationAccounts);
+ financialStatementImport.setSubAmount(subAmount);
+ financialStatementImport.setMasterFinancialStatement(
+ masterFinancialStatement);
+
+ // put it in hashset
+ financialStatements.put(label, financialStatementImport);
+ }
+ /*else {
+ result += "FAILED : The financialstatement "
+ + label + " already exists !\n";
+ }*/
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ return financialStatements;
+ }
+
+ /**
+ * Structure : TYPE | BeginDate | EndDate | Locked | FiscalPeriod beginDate | FiscalPeriod endDate
+ */
+
+ public List<FinancialPeriodImport> importFinancialPeriodChartCSV(String[] nextLine, List<FinancialPeriodImport> financialPeriodImports, TopiaContext topiaContext) throws LimaException {
+
+ String beginDate = nextLine[1];
+ String endDate = nextLine[2];
+ String locked = nextLine[3];
+ String beginDateFiscalPeriod = nextLine[4];
+ String endDateFiscalPeriod = nextLine[5];
+
+ try {
+
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+
+ //if exist, skip
+ if (financialPeriodDAO.findByNaturalId(sdf.parse(beginDate), sdf.parse(endDate)) == null){
+ //create it
+ FinancialPeriodImport financialPeriodImport =
+ new FinancialPeriodImportImpl();
+ financialPeriodImport.setBeginDate(beginDate);
+ financialPeriodImport.setEndDate(endDate);
+ financialPeriodImport.setBeginDateFiscalPeriod(beginDateFiscalPeriod);
+ financialPeriodImport.setEndDateFiscalPeriod(endDateFiscalPeriod);
+ financialPeriodImport.setLocked(locked);
+
+ // put it in list
+ financialPeriodImports.add(financialPeriodImport);
+ }
+ }
+ catch (ParseException eeePE) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't parse date", eeePE);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+
+ return financialPeriodImports;
+ }
+
+
+ //################ CREATE ENTITY IN DB FOR IMPORT ################
+
+
+ public String createFinancialStatements(TreeMap<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
+ String result = "";
+ try {
+
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+
+ while (financialStatements.size() > 0){
+ for (Iterator<FinancialStatementImport> itr = financialStatements.values().iterator(); itr.hasNext();){
+ FinancialStatementImport financialStatementImport = itr.next();
+ String masterFinancialStatementLabel =
+ financialStatementImport.getMasterFinancialStatement();
+ FinancialStatement masterFinancialStatement =
+ financialStatementDAO.findByLabel(
+ masterFinancialStatementLabel);
+
+ if (masterFinancialStatementLabel.equals("")
+ || masterFinancialStatement != null){
+ //create it
+ FinancialStatement financialStatement =
+ new FinancialStatementImpl();
+ financialStatement.setLabel(
+ financialStatementImport.getLabel());
+ financialStatement.setHeader(Boolean.parseBoolean(
+ financialStatementImport.getHeader()));
+ financialStatement.setAccounts(
+ financialStatementImport.getAccounts());
+ financialStatement.setDebitAccounts(
+ financialStatementImport.getDebitAccounts());
+ financialStatement.setCreditAccounts(
+ financialStatementImport.getCreditAccounts());
+ financialStatement.setProvisionDeprecationAccounts(
+ financialStatementImport.
+ getProvisionDeprecationAccounts());
+ financialStatement.setSubAmount(Boolean.parseBoolean(
+ financialStatementImport.getSubAmount()));
+ financialStatement.setHeaderAmount(Boolean.parseBoolean(
+ financialStatementImport.getHeaderAmount()));
+
+ financialStatementService.createFinancialStatement(
+ masterFinancialStatement, financialStatement);
+
+ result += "SUCCESS : The financialStatement " +
+ financialStatementImport.getLabel() + " is created ! \n";
+ itr.remove();
+ }
+ else if (!financialStatements.containsKey(masterFinancialStatementLabel)){
+ result += "FAILED : The financialStatement " +
+ financialStatementImport.getLabel() +
+ " have masterFinancialStatement : " +
+ masterFinancialStatementLabel + "which not exist \n";
+ itr.remove();
+ }
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ return result;
+ }
+
+ public String createFinancialPeriod(List<FinancialPeriodImport> financialPeriodImports, TopiaContext topiaContext) throws LimaException{
+ String result = "";
+ try {
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+
+ for (FinancialPeriodImport financialPeriodImport : financialPeriodImports) {
+ //create financialPeriod
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ Date beginDate = sdf.parse(financialPeriodImport.getBeginDate());
+ Date endDate = sdf.parse(financialPeriodImport.getEndDate());
+ financialPeriod.setBeginDate(beginDate);
+ financialPeriod.setEndDate(endDate);
+ financialPeriod.setLocked(new Boolean(financialPeriodImport.getLocked()));
+ financialPeriodDAO.create(financialPeriod);
+
+ //add to fiscalperiod
+ Date beginDateFiscalPeriod =
+ sdf.parse(financialPeriodImport.getBeginDateFiscalPeriod());
+ Date endDateFiscalPeriod =
+ sdf.parse(financialPeriodImport.getEndDateFiscalPeriod());
+ FiscalPeriod fiscalPeriod =
+ fiscalPeriodDAO.findByNaturalId(beginDateFiscalPeriod, endDateFiscalPeriod);
+ fiscalPeriod.addFinancialPeriod(financialPeriod);
+
+ result += "SUCCESS : The financialPeriod " +
+ financialPeriodImport.getBeginDate()+"-"+financialPeriodImport.getEndDate() + " is created ! \n";
+ }
+ }
+ catch (ParseException eeePE) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't parse date", eeePE);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ return result;
+ }
+
+ public String createAccounts(TreeMap<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException {
+ String result = "";
+
+ try {
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+
+ while (accounts.size() > 0){
+ for (Iterator<AccountImport> itr = accounts.values().iterator(); itr.hasNext();){
+ AccountImport accountImport = itr.next();
+ String masterAccountNumber = accountImport.getMasterAccount();
+ String generalLedgerNumber = accountImport.getGeneralLedger();
+ Account masterAccount =
+ accountDAO.findByAccountNumber(masterAccountNumber);
+ Account generalLedger =
+ accountDAO.findByAccountNumber(generalLedgerNumber);
+
+ if ((masterAccountNumber.equals("") && generalLedgerNumber.equals(""))
+ || masterAccount != null || generalLedger != null){
+ //create it
+ Account account = new AccountImpl();
+ account.setAccountNumber(accountImport.getAccountNumber());
+ account.setLabel(accountImport.getLabel());
+ account.setThirdParty(accountImport.getThirdParty());
+
+ if (generalLedger != null){
+ accountService.createSubLedger(generalLedger, account);
+ }
+ else {
+ accountService.createAccount(masterAccount, account);
+ }
+ result += "SUCCESS : The account " +
+ accountImport.getAccountNumber() + " is created ! \n";
+ itr.remove();
+ }
+ else if (!accounts.containsKey(masterAccountNumber)
+ && !accounts.containsKey(generalLedgerNumber) ){
+ result += "FAILED : The account " +
+ accountImport.getAccountNumber() + " have masterAccount : " +
+ masterAccountNumber + "which not exist \n";
+ itr.remove();
+ }
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ return result;
+ }
+
+
+ protected TopiaContext beginTransaction() throws TopiaException {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ TopiaContext topiaTransaction;
+ topiaTransaction = rootContext.beginTransaction();
+ log.trace("beginTransaction"+topiaTransaction);
+ return topiaTransaction;
+ }
+}
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-07-05 14:59:28 UTC (rev 2962)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -33,10 +33,11 @@
import org.chorem.lima.LimaMain;
import org.chorem.lima.business.AccountService;
import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.ExportService;
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.FinancialStatementService;
import org.chorem.lima.business.FiscalPeriodService;
-import org.chorem.lima.business.ImportExportService;
+import org.chorem.lima.business.ImportService;
import org.chorem.lima.business.RecordService;
import org.chorem.lima.business.FinancialTransactionService;
import org.chorem.lima.business.ReportService;
@@ -275,15 +276,15 @@
}
/**
- * Get financial statement service.
+ * Get import service.
*
*/
- public ImportExportService getImportExportService() {
+ public ImportService getImportService() {
- String lookupName = "ImportExportServiceImplRemote";
- ImportExportService ejbHome = null;
+ String lookupName = "ImportServiceImplRemote";
+ ImportService ejbHome = null;
try {
- ejbHome = (ImportExportService)ctx.lookup(lookupName);
+ ejbHome = (ImportService)ctx.lookup(lookupName);
} catch (NamingException eee) {
if (log.isErrorEnabled()) {
log.error("Can't lookup for service : " + lookupName, eee);
@@ -292,7 +293,26 @@
return ejbHome;
}
+
/**
+ * Get export service.
+ *
+ */
+ public ExportService getExportService() {
+
+ String lookupName = "ExportServiceImplRemote";
+ ExportService ejbHome = null;
+ try {
+ ejbHome = (ExportService)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
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-05 14:59:28 UTC (rev 2962)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -25,7 +25,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
-import org.chorem.lima.business.ImportExportService;
+import org.chorem.lima.business.ImportService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-05 14:59:28 UTC (rev 2962)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-05 17:07:51 UTC (rev 2963)
@@ -19,15 +19,14 @@
package org.chorem.lima.util;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.ImportExportService;
+import org.chorem.lima.business.ExportService;
+import org.chorem.lima.business.ImportService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.account.AccountViewHandler;
@@ -38,10 +37,13 @@
private static final Log log = LogFactory.getLog(AccountViewHandler.class);
- protected ImportExportService importExportService;
+ protected ImportService importService;
+
+ protected ExportService exportService;
public ImportExport() {
- importExportService = LimaServiceFactory.getInstance().getImportExportService();
+ importService = LimaServiceFactory.getInstance().getImportService();
+ exportService = LimaServiceFactory.getInstance().getExportService();
}
/**
@@ -54,21 +56,21 @@
public void exportToCsvFile(String path, String exportMethode) throws LimaException {
String result = "";
try {
- BufferedOutputStream f = new BufferedOutputStream(new FileOutputStream(path));
+ FileWriter f = new FileWriter(new File(path));
if (exportMethode.equals("exportEntryBookChart")){
- result = importExportService.exportEntryBookChartAsCSV();
+ result = exportService.exportEntryBookChartAsCSV();
}
else if (exportMethode.equals("exportAccountsChart")){
- result = importExportService.exportAccountsChartAsCSV();
+ result = exportService.exportAccountsChartAsCSV();
}
else if (exportMethode.equals("exportFinancialStatementsChart")){
- result = importExportService.exportFinancialStatementChartAsCSV();
+ result = exportService.exportFinancialStatementChartAsCSV();
}
else {
- result = importExportService.exportAsCSV();
+ result = exportService.exportAsCSV();
}
- f.write(result.getBytes());
+ f.write(result);
f.flush();
f.close();
}
@@ -93,20 +95,20 @@
String result = "";
byte[] buffer = new byte[(int) new File(path).length()];
try {
- BufferedInputStream f = new BufferedInputStream(new FileInputStream(path));
- f.read(buffer);
+ FileReader f = new FileReader(new File(path));
+ f.read();
if (importMethode.equals("importEntryBookChart")){
- result = importExportService.importEntryBooksChartAsCSV(new String(buffer));
+ result = importService.importEntryBooksChartAsCSV(new String(buffer));
}
else if (importMethode.equals("importAccountsChart")){
- result = importExportService.importAccountsChartAsCSV(new String(buffer));
+ result = importService.importAccountsChartAsCSV(new String(buffer));
}
else if (importMethode.equals("importFinancialStatementsChart")){
- result = importExportService.importFinancialStatementsChartAsCSV(new String(buffer));
+ result = importService.importFinancialStatementsChartAsCSV(new String(buffer));
}
else {
- result = importExportService.importCSV(new String(buffer));
+ result = importService.importCSV(new String(buffer));
}
f.close();
}
1
0
Author: jpepin
Date: 2010-07-05 16:59:28 +0200 (Mon, 05 Jul 2010)
New Revision: 2962
Url: http://chorem.org/repositories/revision/lima/2962
Log:
Lecture et cr?\195?\169ation de fichier dans l'UI. Dans l'export des entit?\195?\169s CSV ajout de champs manquants.s
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionServiceLocal.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.properties
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/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionServiceLocal.java 2010-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionServiceLocal.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -19,8 +19,14 @@
package org.chorem.lima.business;
-import javax.ejb.Remote;
+import java.util.List;
+import javax.ejb.Local;
+
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.nuiton.topia.TopiaContext;
+
/**
* Transaction service.
*
@@ -31,7 +37,9 @@
* By : $Author: jpepin $
*/
-@Remote
+@Local
public interface FinancialTransactionServiceLocal extends FinancialTransactionService {
+ public List<FinancialTransaction> getAllFinancialTransactionsBalanced(TopiaContext topiaContext) throws LimaException;
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -34,56 +34,16 @@
*/
@Remote
public interface ImportExportService {
-
- /**
- * Get database export as xml.
- *
- * For now it's use byte[] to be {@link java.io.Serializable}. InputStream
- * nor file is allowed.
- *
- * TODO find a better solution than byte[]
- *
- * @return export as byte array
- * @throws LimaException
- */
- byte[] exportAsXML() throws LimaException;
-
- /**
- * Import xml data into database.
- *
- * For now it's use byte[] to be {@link java.io.Serializable}. InputStream
- * nor file is allowed.
- *
- * TODO find a better solution than byte[]
- *
- * @param data xml data as byte array
- * @throws LimaException
- */
- void importAsXML(byte[] data) throws LimaException;
- /**
- * Get database export as CSV;
- *
- * @return export as byte array
- * @throws LimaException
- */
- byte[] exportAsCSV() throws LimaException;
+ //########### INPORT
/**
- * Import data as CSV into database.
- *
- * @param data data to import (CSV)
- * @throws LimaException
- */
- void importAsCSV(byte[] data) throws LimaException;
-
- /**
* Import data as EBP CSV export.
*
* @param data
* @throws LimaException
*/
- void importAsEbpCSV(byte[] data) throws LimaException;
+ public void importAsEbpCSV(byte[] data) throws LimaException;
/**
* Import data as Sage Maestria export.
@@ -91,7 +51,7 @@
* @param data
* @throws LimaException
*/
- void importAsSage(byte[] data) throws LimaException;
+ public void importAsSage(byte[] data) throws LimaException;
/**
* Import data as Ciel Compta export.
@@ -99,37 +59,45 @@
* @param data
* @throws LimaException
*/
- void importAsCiel(byte[] data) throws LimaException;
-
+ public void importAsCiel(byte[] data) throws LimaException;
+
/**
- * export accounts chart as CSV.
- */
- void exportAccountsChartAsCSV(String path) throws LimaException;
-
- /**
- * import accounts chart CSV.
+ * import CSV.
* Return result log
*/
- String importAccountsChartCSV(String path) throws LimaException;
+ public String importCSV(String path) throws LimaException;
+ public String importAccountsChartAsCSV(String path) throws LimaException;
+
+ public String importFinancialStatementsChartAsCSV(String path) throws LimaException;
+
+ public String importEntryBooksChartAsCSV(String path) throws LimaException;
+
+
+ //########### EXPORT
+
/**
- * export entrybook chart as CSV.
+ * Get database export as CSV;
+ *
+ * @return export as byte array
+ * @throws LimaException
*/
- void exportEntryBookChartAsCSV(String path) throws LimaException;
+ public String exportAsCSV() throws LimaException;
/**
- * import entrybook chart CSV.
+ * export entrybook chart as CSV.
*/
- String importEntryBookChartCSV(String path) throws LimaException;
+ public String exportEntryBookChartAsCSV() throws LimaException;
/**
* export financialstatement chart as CSV.
*/
- void exportFinancialStatementChartAsCSV(String path) throws LimaException;
+ public String exportFinancialStatementChartAsCSV() throws LimaException;
/**
- * import financialstatement chart CSV.
- * Return result log
+ * export accounts chart as CSV.
*/
- String importFinancialStatementChartCSV(String path) throws LimaException;
+ public String exportAccountsChartAsCSV() 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-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -137,7 +137,7 @@
FiscalPeriod lastFiscalPeriod = fiscalPeriodDAO.findByQuery(query);
//check the new fiscal period adjoining the last
- Date dateLastFiscalPeriod=lastFiscalPeriod.getEndDate();
+ Date dateLastFiscalPeriod = lastFiscalPeriod.getEndDate();
dateLastFiscalPeriod = DateUtils.
addMilliseconds(dateLastFiscalPeriod, 1);
Date dateFiscalPeriod=fiscalPeriod.getBeginDate();
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-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -47,6 +47,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
/**
* Cette classe permet la création d'une transaction comptable dans l'application.
@@ -213,7 +214,41 @@
return result;
}
+
/**
+ * Get balanced financialtransaction from selected fiscalperiod
+ */
+ @Override
+ public List<FinancialTransaction> getAllFinancialTransactionsBalanced(TopiaContext topiaContext) throws LimaException {
+ List<FinancialTransaction> result = null;
+ try {
+ FinancialTransactionDAO financialTransactionDAO =
+ LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
+
+ TopiaQuery query = financialTransactionDAO.createQuery("E");
+ query.addWhere("E.amountCredit = E.amountDebit")
+ .addNotNull("E.entryBook");
+ result = financialTransactionDAO.findAllByQuery(query);
+
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ for (FinancialTransaction financialTransaction : result) {
+
+ for (Entry entry : financialTransaction.getEntry()) {
+ entry.getAccount();
+ entry.getFinancialTransaction();
+ entry.getFinancialTransaction().getEntryBook();
+ entry.getFinancialTransaction().getFinancialPeriod();
+ }
+ }
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ return result;
+ }
+
+
+ /**
* update date and amount of a financial transaction
* call accounting rules
*
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -19,43 +19,46 @@
package org.chorem.lima.business.ejb;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
-import java.io.OutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import javax.ejb.EJB;
import javax.ejb.Stateless;
-import javax.swing.text.StyledEditorKit.BoldAction;
-
-import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.AccountImport;
import org.chorem.lima.beans.AccountImportImpl;
import org.chorem.lima.beans.FinancialStatementImport;
import org.chorem.lima.beans.FinancialStatementImportImpl;
-import org.chorem.lima.business.AccountService;
-import org.chorem.lima.business.EntryBookService;
-import org.chorem.lima.business.FinancialStatementService;
+import org.chorem.lima.business.AccountServiceLocal;
+import org.chorem.lima.business.EntryBookServiceLocal;
+import org.chorem.lima.business.FinancialStatementServiceLocal;
+import org.chorem.lima.business.FinancialTransactionServiceLocal;
import org.chorem.lima.business.ImportExportService;
import org.chorem.lima.business.ImportExportServiceLocal;
-import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.AccountImpl;
+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.EntryBookDAO;
import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementDAO;
import org.chorem.lima.entity.FinancialStatementImpl;
+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;
@@ -63,15 +66,10 @@
import org.nuiton.topia.TopiaNotFoundException;
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
-import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy;
-import au.com.bytecode.opencsv.bean.CsvToBean;
/**
- * XML and CSV import export service.
+ * CSV import export service.
*
- * TODO maybe split this impl into different XML and CSV impl.
- *
- * @author chatellier
* @version $Revision$
*
* Last update : $Date$
@@ -80,18 +78,24 @@
@Stateless
public class ImportExportServiceImpl extends AbstractLimaService implements ImportExportService, ImportExportServiceLocal {
- private static final Log log = LogFactory.getLog(ImportExportServiceImpl.class);
+ private static final Log log =
+ LogFactory.getLog(ImportExportServiceImpl.class);
private TopiaContext rootContext;
@EJB
- AccountService accountService;
+ AccountServiceLocal accountService;
+
+ @EJB
+ FinancialTransactionServiceLocal financialTransactionService;
@EJB
- FinancialStatementService financialStatementService;
+ FinancialStatementServiceLocal financialStatementService;
@EJB
- EntryBookService entryBookService;
+ EntryBookServiceLocal entryBookService;
+
+ protected CSVWriter csvWriter;
public ImportExportServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -104,70 +108,10 @@
}
}
- /*
- * @see org.chorem.lima.business.ImportExportService#exportAsXML()
- */
- @Override
- public byte[] exportAsXML() throws LimaException {
-
- byte[] data = null;
- ByteArrayOutputStream byteArrayOutputStream = null;
- try {
- byteArrayOutputStream = new ByteArrayOutputStream();
- exportAsXML(byteArrayOutputStream);
- }
- catch (IOException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't export as xml", eee);
- }
- throw new LimaException("Can't export as xml", eee);
- }
- finally {
- IOUtils.closeQuietly(byteArrayOutputStream);
- }
-
- if (byteArrayOutputStream != null) {
- data = byteArrayOutputStream.toByteArray();
- }
-
- return data;
- }
+ //################ IMPORT THIRD PART ACCOUNTING SOFTWARE ################
- /**
- * Do real output into a simple {@link OutputStream}.
- *
- * @param output
- * @throws IOException
- */
- protected void exportAsXML(OutputStream output) throws IOException {
-
- }
-
+
/*
- * @see org.chorem.lima.business.ImportExportService#importAsXML(byte[])
- */
- @Override
- public void importAsXML(byte[] data) {
-
- }
-
- /*
- * @see org.chorem.lima.business.ImportExportService#exportAsCSV()
- */
- @Override
- public byte[] exportAsCSV() throws LimaException {
- return null;
- }
-
- /*
- * @see org.chorem.lima.business.ImportExportService#importAsCSV(byte[])
- */
- @Override
- public void importAsCSV(byte[] data) throws LimaException {
-
- }
-
- /*
* @see org.chorem.lima.business.ImportExportService#importAsEBPCSV(byte[])
*/
@Override
@@ -187,24 +131,217 @@
}
+
+ //################ EXPORT ################
+
+ /**
+ * Export integrality of database in CSV
+ */
+ @Override
+ public String exportAsCSV() throws LimaException {
+ TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+
+ try {
+ topiaContext = beginTransaction();
+ csvWriter = new CSVWriter(out, ';');
+ exportAccountsChartAsCSV(topiaContext);
+ exportEntryBookChartAsCSV(topiaContext);
+ exportFinancialStatementChartAsCSV(topiaContext);
+ exportFiscalPeriodAsCSV(topiaContext);
+ exportFinancialPeriodAsCSV(topiaContext);
+ exportClosedPeriodicEntryBooksAsCSV(topiaContext);
+ exportFinancialTransactionsAsCSV(topiaContext);
+ exportEntriesAsCSV(topiaContext);
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+ /**
+ * Remote methode call from UI.
+ */
@Override
- public void exportAccountsChartAsCSV(String path) throws LimaException {
- File f = new File(path);
+ public String exportFinancialStatementChartAsCSV() throws LimaException {
+ TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+
+ try {
+ topiaContext = beginTransaction();
+ csvWriter = new CSVWriter(out, ';');
+ exportFinancialStatementChartAsCSV(topiaContext);
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+ /**
+ * Local methode, export financialstatements from database
+ * structure : TYPE | Label | Header | Accounts | DebitAccounts
+ * | CreditAccounts | ProvisionDeprecationAccounts | SubAmount
+ * | HeaderAmount | MasterFinancialStatement
+ */
+ public void exportFinancialStatementChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[10];
+ // Get all Financialstatements
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+ List<FinancialStatement> listFinancialStatements =
+ financialStatementDAO.findAll();
+ // For all Financialstatements
+ for (FinancialStatement financialStatement : listFinancialStatements) {
+ nextLine[0] = "FNST";
+ nextLine[1] = financialStatement.getLabel();
+ nextLine[2] = new Boolean(
+ financialStatement.getHeader()).toString();
+ nextLine[3] = financialStatement.getAccounts();
+ nextLine[4] = financialStatement.getDebitAccounts();
+ nextLine[5] = financialStatement.getCreditAccounts();
+ nextLine[6] = financialStatement.
+ getProvisionDeprecationAccounts();
+ nextLine[7] = new Boolean(
+ financialStatement.getSubAmount()).toString();
+ nextLine[8] = new Boolean(
+ financialStatement.getHeaderAmount()).toString();
+ FinancialStatement masterFinancialStatement =
+ financialStatement.getMasterFinancialStatement();
+ String masterFinancialStatementString = "";
+ if (masterFinancialStatement != null){
+ masterFinancialStatementString =
+ masterFinancialStatement.getLabel();
+ }
+ nextLine[9] = masterFinancialStatementString;
+ // Add line in file
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Remote methode call from UI.
+ */
+ @Override
+ public String exportEntryBookChartAsCSV() throws LimaException {
TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+
try {
topiaContext = beginTransaction();
- CSVWriter csvWriter = new CSVWriter(new FileWriter(f), ';');
- String[] nextLine = new String[5];
+ csvWriter = new CSVWriter(out, ';');
+ exportEntryBookChartAsCSV(topiaContext);
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+
+ /**
+ * Local methode, export entrybooks from database
+ * Structure : TYPE | Code | Label | Type
+ */
+ public void exportEntryBookChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[4];
+ // Get all entrybook
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+ List<EntryBook> listEntryBook = entryBookDAO.findAll();
+ // For all EntryBook
+ for (EntryBook entryBook : listEntryBook) {
+ nextLine[0] = "ENBK";
+ nextLine[1] = entryBook.getCode();
+ nextLine[2] = entryBook.getLabel();
+ nextLine[3] = entryBook.getType();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Remote methode call from UI.
+ */
+ @Override
+ public String exportAccountsChartAsCSV() throws LimaException {
+ TopiaContext topiaContext = null;
+ StringWriter out = new StringWriter();
+ try {
+ topiaContext = beginTransaction();
+ csvWriter = new CSVWriter(out, ';');
+ exportAccountsChartAsCSV(topiaContext);
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return out.getBuffer().toString();
+ }
+
+ /**
+ * Local methode, export accounts from database
+ * Structure : TYPE | AccountNumber | Label | ThirdParty | MasteAccount | GeneralLedger
+ */
+ public void exportAccountsChartAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[6];
// Récupère tous les comptes
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(topiaContext);
List<Account> listAccount = accountDAO.findAll();
- nextLine[0] = "lima.accountschart";
- csvWriter.writeNext(nextLine);
// Pour tous les comptes
for (Account account : listAccount) {
- nextLine[0] = account.getAccountNumber();
- nextLine[1] = account.getLabel();
- nextLine[2] = account.getThirdParty();
+ nextLine[0] = "ACCN";
+ nextLine[1] = account.getAccountNumber();
+ nextLine[2] = account.getLabel();
+ nextLine[3] = account.getThirdParty();
Account masterAccount = account.getMasterAccount();
Account generalLedger = account.getGeneralLedger();
String masterAccountString = "";
@@ -212,81 +349,407 @@
if (masterAccount != null){
masterAccountString = masterAccount.getAccountNumber();
}
- nextLine[3] = masterAccountString;
+ nextLine[4] = masterAccountString;
if (generalLedger != null){
generalLedgerString = generalLedger.getAccountNumber();
}
- nextLine[4] = generalLedgerString;
+ nextLine[5] = generalLedgerString;
// Ajoute la ligne au fichier
csvWriter.writeNext(nextLine);
}
- // Write cache in file
- csvWriter.flush();
- csvWriter.close();
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export financialtransactions from database
+ * Structue : TYPE | TransactionDate | AmountDebit | AmountCredit
+ * | FinancialPeriod BeginDate | FinancialPeriod EndDate | EntryBook Code
+ */
+ public void exportFinancialTransactionsAsCSV(TopiaContext topiaContext) throws LimaException {
+ String[] nextLine = new String[7];
+ // Get all financialtransactions balanced
+ List<FinancialTransaction> listFinancialTransaction =
+ financialTransactionService.getAllFinancialTransactionsBalanced(topiaContext);
+ // For all balanced financialTransaction
+ for (FinancialTransaction financialTransaction : listFinancialTransaction) {
+ nextLine[0] = "FTRC";
+ nextLine[1] = financialTransaction.getTransactionDate().toString();
+ nextLine[2] = new Double(
+ financialTransaction.getAmountDebit()).toString();
+ nextLine[3] = new Double(
+ financialTransaction.getAmountCredit()).toString();
+ nextLine[4] = financialTransaction.getFinancialPeriod().
+ getBeginDate().toString();
+ nextLine[5] = financialTransaction.getFinancialPeriod().
+ getEndDate().toString();
+ nextLine[6] = financialTransaction.getEntryBook().getCode();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+
+ /**
+ * Local methode, export entries from database
+ * Structure : TYPE | Description | Amount | Debit | Lettering | Detail |
+ * Voucher | Position | FinancialTransaction Date | FinancialTransaction Code |
+ * FinancialTransaction AmountDebit | FinancialTransaction AmountCredit
+ */
+ public void exportEntriesAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[12];
+ // Get all Entry
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ List<Entry> listEntry = entryDAO.findAll();
+ // For all Entry
+ for (Entry entry : listEntry) {
+ nextLine[0] = "NTRY";
+ nextLine[1] = entry.getDescription();
+ nextLine[2] = new Double(entry.getAmount()).toString();
+ nextLine[3] = new Boolean(entry.getDebit()).toString();
+ nextLine[4] = entry.getLettering();
+ nextLine[5] = entry.getVoucher();
+ nextLine[6] = entry.getPosition();
+ nextLine[7] = entry.getAccount().getAccountNumber();
+ nextLine[8] = entry.getFinancialTransaction().
+ getTransactionDate().toString();
+ nextLine[9] = entry.getFinancialTransaction().
+ getEntryBook().getCode();
+ nextLine[10] = new Double(entry.getFinancialTransaction()
+ .getAmountDebit()).toString();
+ nextLine[11] = new Double(entry.getFinancialTransaction()
+ .getAmountCredit()).toString();
+
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
}
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export fiscalperiods from database
+ * Structure : TYPE | BeginDate | EndDate | Locked
+ */
+ public void exportFiscalPeriodAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[5];
+ // Get all fiscalperiod
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+ List<FiscalPeriod> listFiscalPeriod =
+ fiscalPeriodDAO.findAll();
+ // For all Entry
+ for (FiscalPeriod fiscalPeriod : listFiscalPeriod) {
+ nextLine[0] = "FSCP";
+ nextLine[1] = fiscalPeriod.getBeginDate().toString();
+ nextLine[2] = fiscalPeriod.getEndDate().toString();
+ nextLine[3] = new Boolean(fiscalPeriod.getLocked()).toString();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export financialperiods from database
+ * Structure : TYPE | BeginDate | EndDate | Locked | FiscalPeriod beginDate | FiscalPeriod endDate
+ */
+ public void exportFinancialPeriodAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[6];
+ // Get all fiscalperiod
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(topiaContext);
+ List<FinancialPeriod> listFinancialPeriod =
+ financialPeriodDAO.findAll();
+
+ FiscalPeriodDAO fiscalPeriodDAO =
+ LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext);
+
+ // For all Entry
+ for (FinancialPeriod financialPeriod : listFinancialPeriod) {
+ nextLine[0] = "FNCP";
+ nextLine[1] = financialPeriod.getBeginDate().toString();
+ nextLine[2] = financialPeriod.getEndDate().toString();
+ nextLine[3] = new Boolean(financialPeriod.getLocked()).toString();
+ FiscalPeriod fiscalPeriod = fiscalPeriodDAO.
+ findContainsFinancialPeriod(financialPeriod);
+ nextLine[4] = fiscalPeriod.getBeginDate().toString();
+ nextLine[5] = fiscalPeriod.getEndDate().toString();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ /**
+ * Local methode, export ClosedPeriodicEntryBooks from database
+ * Structure : TYPE | Locked | FinancialPeriod beginDate | FinancialPeriod endDate | EntryBook Code
+ */
+ public void exportClosedPeriodicEntryBooksAsCSV(TopiaContext topiaContext) throws LimaException {
+ try {
+ String[] nextLine = new String[5];
+ // Get all fiscalperiod
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
+ List<ClosedPeriodicEntryBook> listClosedPeriodicEntryBook =
+ closedPeriodicEntryBookDAO.findAll();
+ // For all Entry
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) {
+ nextLine[0] = "CPEB";
+ nextLine[1] = new Boolean(
+ closedPeriodicEntryBook.getLocked()).toString();
+ nextLine[2] = closedPeriodicEntryBook.getFinancialPeriod().
+ getBeginDate().toString();
+ nextLine[3] =closedPeriodicEntryBook.getFinancialPeriod().
+ getEndDate().toString();
+ nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ }
+
+ //################ IMPORT ################
+
+
+ @Override
+ public String importCSV(String datas) throws LimaException {
+ String result = "";
+
+ //Accounts
+ TreeMap<String, AccountImport> accounts =
+ new TreeMap<String, AccountImport>();
+
+ //FinancialStatements
+ TreeMap<String, FinancialStatementImport> financialStatements =
+ new TreeMap<String, FinancialStatementImport>();
+
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+
+ String[] nextLine = new String[1];
+ CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
+
+
+ while ((nextLine = csvReader.readNext()) != null) {
+ String indice = nextLine[0];
+ if (indice.equals("ACCN")){
+ accounts = importAccountsChartsCSV(
+ nextLine, accounts, topiaContext);
+ }
+ else if (indice.equals("ENBK")){
+ result+=importEntryBooksChartCSV(
+ nextLine, topiaContext);
+ }
+ else if (indice.equals("FNST")){
+ financialStatements = importFinancialsStatementChartCSV(
+ nextLine, financialStatements, topiaContext);
+ }
+ else if (indice.equals("FSCP")){
+ //result+=
+ }
+ else if (indice.equals("FNCP")){
+ //result+=
+ }
+ else if (indice.equals("CPEB")){
+ //result+=
+ }
+ else if (indice.equals("FTRC")){
+ //result+=
+ }
+ else if (indice.equals("NTRY")){
+ //result+=
+ }
+ }
+
+ //create accounts
+ result+=createAccounts(accounts, topiaContext);
+ //create financialStatements
+ result+=createFinancialStatements(financialStatements, topiaContext);
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
catch (IOException eeeIO) {
- log.debug("Can't create new CSV Writer with file"+f+eeeIO);
+ log.debug("Can't create new CSV Reader",eeeIO);
}
finally {
doFinally(topiaContext, log);
- }
+ }
+ return result;
}
+
+ @Override
+ public String importEntryBooksChartAsCSV(String datas) throws LimaException{
+ String result = "";
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+
+ String[] nextLine = new String[1];
+ CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
+
+ while ((nextLine = csvReader.readNext()) != null) {
+ String indice = nextLine[0];
+ if (indice.equals("ENBK")){
+ result+=importEntryBooksChartCSV(nextLine, topiaContext);
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+ }
+
@Override
- public String importAccountsChartCSV(String path) throws LimaException {
- File f = new File(path);
+ public String importFinancialStatementsChartAsCSV(String datas) throws LimaException {
String result = "";
+
+ //FinancialStatements
+ TreeMap<String, FinancialStatementImport> financialStatements =
+ new TreeMap<String, FinancialStatementImport>();
TopiaContext topiaContext = null;
try {
topiaContext = beginTransaction();
String[] nextLine = new String[1];
- CSVReader csvReader = new CSVReader(new FileReader(f), ';');
+ CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
+
+ while ((nextLine = csvReader.readNext()) != null) {
+ String indice = nextLine[0];
+ if (indice.equals("FNST")){
+ financialStatements = importFinancialsStatementChartCSV(
+ nextLine, financialStatements, topiaContext);
+ }
+ }
+
+ //create financialStatements
+ result+=createFinancialStatements(financialStatements, topiaContext);
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+ }
+
+
+ @Override
+ public String importAccountsChartAsCSV(String datas) throws LimaException {
+ String result = "";
+
+ //Accounts
+ TreeMap<String, AccountImport> accounts =
+ new TreeMap<String, AccountImport>();
- nextLine = csvReader.readNext(); // Date début période
- if (!nextLine[0].equals("lima.accountschart")){
- throw new LimaBusinessException(
- "The file is not an export csv file type accountschart");
- }
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+
+ String[] nextLine = new String[1];
+ CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
- AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
-
- TreeMap<String, AccountImport> accounts =
- new TreeMap<String, AccountImport>();
- while ((nextLine = csvReader.readNext()) != null) {
- String accountNumber = nextLine[0];
- String label = nextLine[1];
- String thirdParty = nextLine[2];
- String masterAccountNumber = nextLine[3];
- String generalLedgerNumber = nextLine[4];
-
- //if exist, skip
- if (accountDAO.findByAccountNumber(accountNumber) != null){
- result += "FAILED : The account "
- + accountNumber + " already exists !\n";
+ while ((nextLine = csvReader.readNext()) != null) {
+ String indice = nextLine[0];
+ if (indice.equals("ACCN")){
+ accounts = importAccountsChartsCSV(
+ nextLine, accounts, topiaContext);
}
- else {
- //create it
- AccountImport accountImport = new AccountImportImpl();
- accountImport.setAccountNumber(accountNumber);
- accountImport.setLabel(label);
- accountImport.setThirdParty(thirdParty);
- accountImport.setMasterAccount(masterAccountNumber);
- accountImport.setGeneralLedger(generalLedgerNumber);
- // put it in hashset
- accounts.put(accountNumber, accountImport);
- }
- }
+ }
+
+ //create accounts
+ result+=createAccounts(accounts, topiaContext);
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader",eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
+ }
+
+ public TreeMap<String, AccountImport> importAccountsChartsCSV(String[] nextLine, TreeMap<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException{
+
+ String accountNumber = nextLine[1];
+ String label = nextLine[2];
+ String thirdParty = nextLine[3];
+ String masterAccountNumber = nextLine[4];
+ String generalLedgerNumber = nextLine[5];
+
+ try {
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(topiaContext);
+
+ //if not exist, create it
+ if (accountDAO.findByAccountNumber(accountNumber) == null){
+ //create it
+ AccountImport accountImport = new AccountImportImpl();
+ accountImport.setAccountNumber(accountNumber);
+ accountImport.setLabel(label);
+ accountImport.setThirdParty(thirdParty);
+ accountImport.setMasterAccount(masterAccountNumber);
+ accountImport.setGeneralLedger(generalLedgerNumber);
+ // put it in hashset
+ accounts.put(accountNumber, accountImport);
+ }
+ /*else {
+ result += "FAILED : The account "
+ + accountNumber + " already exists !\n";
+ }*/
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+
+ return accounts;
+ }
+
+
+ public String createAccounts(TreeMap<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException {
+ String result = "";
+
+ try {
+ AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext);
while (accounts.size() > 0){
- for (Iterator<AccountImport> itr =accounts.values().iterator(); itr.hasNext();){
+ for (Iterator<AccountImport> itr = accounts.values().iterator(); itr.hasNext();){
AccountImport accountImport = itr.next();
String masterAccountNumber = accountImport.getMasterAccount();
String generalLedgerNumber = accountImport.getGeneralLedger();
@@ -326,223 +789,98 @@
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Reader with file"+f+eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
return result;
}
- @Override
- public void exportEntryBookChartAsCSV(String path) throws LimaException {
- File f = new File(path);
- TopiaContext topiaContext = null;
+ public String importEntryBooksChartCSV(String[] nextLine, TopiaContext topiaContext) throws LimaException {
+ String result ="";
try {
- topiaContext = beginTransaction();
- CSVWriter csvWriter = new CSVWriter(new FileWriter(f), ';');
- String[] nextLine = new String[3];
- // Get all entrybook
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+
+ EntryBook entryBook = new EntryBookImpl();
+ entryBook.setCode(nextLine[1]);
+ entryBook.setLabel(nextLine[2]);
+ entryBook.setType(nextLine[3]);
- List<EntryBook> listEntryBook = entryBookDAO.findAll();
- nextLine[0] = "lima.entrybooks";
- csvWriter.writeNext(nextLine);
- // For all EntryBook
- for (EntryBook entryBook : listEntryBook) {
- nextLine[0] = entryBook.getCode();
- nextLine[1] = entryBook.getLabel();
- nextLine[2] = entryBook.getType();
- // Ajoute la ligne au fichier
- csvWriter.writeNext(nextLine);
- }
- // Write cache in file
- csvWriter.flush();
- csvWriter.close();
- }
+ //if exist, skip
+ if (entryBookDAO.findByCode(entryBook.getCode()) != null){
+ result += "FAILED : The entrybook "
+ + entryBook.getLabel() + " already exists !\n";
+ }
+ else {
+ //create it
+ entryBookService.createEntryBook(entryBook);
+ result += "SUCCESS : The financialStatement " +
+ entryBook.getLabel() + " is created ! \n";
+ }
+ }
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Writer with file"+f+eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
-
+ return result;
}
-
- @Override
- public String importEntryBookChartCSV(String path) throws LimaException {
- File f = new File(path);
- String result = "";
- TopiaContext topiaContext = null;
+ public TreeMap<String, FinancialStatementImport> importFinancialsStatementChartCSV(String[] nextLine, TreeMap<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
+
+ String label = nextLine[1];
+ String header = nextLine[2];
+ String accounts = nextLine[3];
+ String debitAccounts = nextLine[4];
+ String creditAccounts = nextLine[5];
+ String provisionDeprecationAccounts = nextLine[6];
+ String subAmount = nextLine[7];
+ String headerAmount = nextLine[8];
+ String masterFinancialStatement = nextLine[9];
+
try {
- topiaContext = beginTransaction();
- String[] nextLine = new String[1];
- CSVReader csvReader = new CSVReader(new FileReader(f), ';');
- nextLine = csvReader.readNext(); // File Type
- if (!nextLine[0].equals("lima.entrybooks")){
- throw new LimaBusinessException(
- "The file is not an export csv file type entrybooks");
- }
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
- EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
-
- while ((nextLine = csvReader.readNext()) != null) {
- EntryBook entryBook = new EntryBookImpl();
- entryBook.setCode(nextLine[0]);
- entryBook.setLabel(nextLine[1]);
- entryBook.setType(nextLine[2]);
-
- //if exist, skip
- if (entryBookDAO.findByCode(entryBook.getCode()) != null){
- result += "FAILED : The entrybook "
- + entryBook.getLabel() + " already exists !\n";
- }
- else {
- //create it
- entryBookService.createEntryBook(entryBook);
- result += "SUCCESS : The financialStatement " +
- entryBook.getLabel() + " is created ! \n";
- }
+ //if exist, skip
+ if (financialStatementDAO.findByLabel(label) == null){
+ //create it
+ FinancialStatementImport financialStatementImport =
+ new FinancialStatementImportImpl();
+ financialStatementImport.setLabel(label);
+ financialStatementImport.setHeader(header);
+ financialStatementImport.setAccounts(accounts);
+ financialStatementImport.setCreditAccounts(creditAccounts);
+ financialStatementImport.setDebitAccounts(debitAccounts);
+ financialStatementImport.setHeaderAmount(headerAmount);
+ financialStatementImport.setProvisionDeprecationAccounts(
+ provisionDeprecationAccounts);
+ financialStatementImport.setSubAmount(subAmount);
+ financialStatementImport.setMasterFinancialStatement(
+ masterFinancialStatement);
+
+ // put it in hashset
+ financialStatements.put(label, financialStatementImport);
}
+ /*else {
+ result += "FAILED : The financialstatement "
+ + label + " already exists !\n";
+ }*/
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Reader with file"+f+eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return result;
+ return financialStatements;
}
-
- @Override
- public void exportFinancialStatementChartAsCSV(String path) throws LimaException {
- File f = new File(path);
- TopiaContext topiaContext = null;
-
- try {
- topiaContext = beginTransaction();
- CSVWriter csvWriter = new CSVWriter(new FileWriter(f), ';');
- String[] nextLine = new String[9];
- // Get all Financialstatements
- FinancialStatementDAO financialStatementDAO =
- LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
- List<FinancialStatement> listFinancialStatements =
- financialStatementDAO.findAll();
- nextLine[0] = "lima.financialstatementschart";
- csvWriter.writeNext(nextLine);
- // For all Financialstatements
- for (FinancialStatement financialStatement : listFinancialStatements) {
- nextLine[0] = financialStatement.getLabel();
- nextLine[1] = new Boolean(
- financialStatement.getHeader()).toString();
- nextLine[2] = financialStatement.getAccounts();
- nextLine[3] = financialStatement.getDebitAccounts();
- nextLine[4] = financialStatement.getCreditAccounts();
- nextLine[5] = financialStatement.
- getProvisionDeprecationAccounts();
- nextLine[6] = new Boolean(
- financialStatement.getSubAmount()).toString();
- nextLine[7] = new Boolean(
- financialStatement.getHeaderAmount()).toString();
- FinancialStatement masterFinancialStatement =
- financialStatement.getMasterFinancialStatement();
- String masterFinancialStatementString = "";
- if (masterFinancialStatement != null){
- masterFinancialStatementString =
- masterFinancialStatement.getLabel();
- }
- nextLine[8] = masterFinancialStatementString;
- // Add line in file
- csvWriter.writeNext(nextLine);
- }
- // Write cache in file
- csvWriter.flush();
- csvWriter.close();
- }
- catch (TopiaException eeeTE){
- doCatch(topiaContext, eeeTE, log);
- }
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Writer with file"+f+eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- }
- @Override
- public String importFinancialStatementChartCSV(String path) throws LimaException {
- File f = new File(path);
+
+ public String createFinancialStatements(TreeMap<String, FinancialStatementImport> financialStatements, TopiaContext topiaContext) throws LimaException {
String result = "";
-
- TopiaContext topiaContext = null;
try {
- topiaContext = beginTransaction();
- String[] nextLine = new String[1];
- CSVReader csvReader = new CSVReader(new FileReader(f), ';');
-
- nextLine = csvReader.readNext(); // File Type
- if (!nextLine[0].equals("lima.financialstatementschart")){
- throw new LimaBusinessException(
- "The file is not an export csv file type financialstatementschart");
- }
-
- FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
-
-
- TreeMap<String, FinancialStatementImport> financialStatements =
- new TreeMap<String, FinancialStatementImport>();
-
- while ((nextLine = csvReader.readNext()) != null) {
- String label = nextLine[0];
- String header = nextLine[1];
- String accounts = nextLine[2];
- String debitAccounts = nextLine[3];
- String creditAccounts = nextLine[4];
- String provisionDeprecationAccounts = nextLine[5];
- String subAmount = nextLine[6];
- String headerAmount = nextLine[7];
- String masterFinancialStatement = nextLine[8];
-
- //if exist, skip
- if (financialStatementDAO.findByLabel(label) != null){
- result += "FAILED : The financialstatement "
- + label + " already exists !\n";
- }
- else {
- //create it
- FinancialStatementImport financialStatementImport =
- new FinancialStatementImportImpl();
- financialStatementImport.setLabel(label);
- financialStatementImport.setHeader(header);
- financialStatementImport.setAccounts(accounts);
- financialStatementImport.setCreditAccounts(creditAccounts);
- financialStatementImport.setDebitAccounts(debitAccounts);
- financialStatementImport.setHeaderAmount(headerAmount);
- financialStatementImport.setProvisionDeprecationAccounts(
- provisionDeprecationAccounts);
- financialStatementImport.setSubAmount(subAmount);
- financialStatementImport.setMasterFinancialStatement(
- masterFinancialStatement);
-
- // put it in hashset
- financialStatements.put(label, financialStatementImport);
- }
- }
-
-
- while (financialStatements.size() > 0){
+
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+
+ while (financialStatements.size() > 0){
for (Iterator<FinancialStatementImport> itr = financialStatements.values().iterator(); itr.hasNext();){
FinancialStatementImport financialStatementImport = itr.next();
String masterFinancialStatementLabel =
@@ -589,20 +927,14 @@
itr.remove();
}
}
-
- }
+ }
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
- catch (IOException eeeIO) {
- log.debug("Can't create new CSV Reader with file"+f+eeeIO);
- }
- finally {
- doFinally(topiaContext, log);
- }
- return result;
+ return result;
}
+
protected TopiaContext beginTransaction() throws TopiaException {
// basic check done, make check in database
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2010-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-07-05 14:59:28 UTC (rev 2962)
@@ -1,10 +1,24 @@
# Precise l'entete de l'ensemble des fichiers generes
model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */
+# natural id
org.chorem.lima.entity.Account.class.tagvalue.naturalIdMutable=false
org.chorem.lima.entity.Account.attribute.accountNumber.tagvalue.naturalId=true
org.chorem.lima.entity.Account.attribute.accountNumber.tagvalue.notNull=true
+org.chorem.lima.entity.FinancialPeriod.class.tagvalue.naturalIdMutable=false
+org.chorem.lima.entity.FinancialPeriod.attribute.beginDate.tagvalue.naturalId=true
+org.chorem.lima.entity.FinancialPeriod.attribute.beginDate.tagvalue.notNull=true
+org.chorem.lima.entity.FinancialPeriod.attribute.endDate.tagvalue.naturalId=true
+org.chorem.lima.entity.FinancialPeriod.attribute.endDate.tagvalue.notNull=true
+
+org.chorem.lima.entity.FiscalPeriod.class.tagvalue.naturalIdMutable=false
+org.chorem.lima.entity.FiscalPeriod.attribute.beginDate.tagvalue.naturalId=true
+org.chorem.lima.entity.FiscalPeriod.attribute.beginDate.tagvalue.notNull=true
+org.chorem.lima.entity.FiscalPeriod.attribute.endDate.tagvalue.naturalId=true
+org.chorem.lima.entity.FiscalPeriod.attribute.endDate.tagvalue.notNull=true
+
+# lazy
org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false
org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false
org.chorem.lima.entity.FinancialTransaction.attribute.financialPeriod.tagvalue.lazy=false
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -19,15 +19,11 @@
package org.chorem.lima;
import static org.nuiton.i18n.I18n._;
-
import java.util.List;
import java.util.Locale;
-
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
-
import jaxx.runtime.SwingUtil;
-
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.Converter;
import org.apache.commons.beanutils.converters.DateConverter;
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -0,0 +1,62 @@
+package org.chorem.lima.ui;
+
+import javax.swing.JFileChooser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.util.DialogHelper;
+import org.chorem.lima.util.FileChooseView;
+import org.chorem.lima.util.ImportExport;
+
+public class ImportExportHandler {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(ImportExportHandler.class);
+
+ protected MainView view;
+
+ ImportExportHandler(MainView mainView){
+ this.view=mainView;
+ }
+
+ public void importexportDialog(){
+
+ ImportExportForm importExportForm = new ImportExportForm(view);
+ importExportForm.setLocationRelativeTo(view);
+ importExportForm.setVisible(true);
+
+ Object value = importExportForm.getRadioButtons().getSelectedValue();
+ // if action confirmed
+ if (value != null){
+ String mode = (String) value;
+ FileChooseView fileChooseView = new FileChooseView(view);
+
+ JFileChooser chooser = fileChooseView.getChooser();
+ ImportExport importExport = ImportExport.getInstance();
+
+ try {
+ if (mode.equals("import")){
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
+ String filePath = chooser.getSelectedFile().getAbsolutePath();
+ String message = importExport.importFromCsvFile(filePath, "");
+ DialogHelper.showMessageDialog(message);
+ }
+ }
+ else {
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
+ String filePath = chooser.getSelectedFile().getAbsolutePath();
+ importExport.exportToCsvFile(filePath, "");
+ }
+ }
+ } catch (LimaException eee) {
+ if (log.isErrorEnabled()){
+ log.error("Can't "+ mode +" this file", eee);
+ }
+ DialogHelper.showMessageDialog(eee.getMessage());
+ }
+ }
+ }
+
+}
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-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-07-05 14:59:28 UTC (rev 2962)
@@ -78,7 +78,8 @@
<JMenuBar>
<JMenu text="lima.menu.file">
- <JMenu text="lima.import" actionIcon='import-element'>
+ <JMenuItem text="lima.common.importexport" onActionPerformed='getHandler().showImportExportView(this)'/>
+ <!-- <JMenu text="lima.import" actionIcon='import-element'>
<JMenuItem text="lima.import.all" onActionPerformed='getHandler().showImportView("all")'/>
<JMenuItem text="lima.import.all.csv" onActionPerformed='getHandler().showImportView("all_csv")'/>
<JMenuItem text="lima.import.all.csv.ebp" onActionPerformed='getHandler().showImportView("all_csv_ebp")'/>
@@ -89,7 +90,7 @@
<JMenuItem text="lima.export.all" onActionPerformed='getHandler().showExportView("all")'/>
<JMenuItem text="lima.export.all.csv" onActionPerformed='getHandler().showExportView("all_csv")'/>
<JMenuItem text="lima.export.account" onActionPerformed='getHandler().showExportView("account")'/>
- </JMenu>
+ </JMenu> -->
<JSeparator/>
<JMenuItem text="lima.common.print" actionIcon='print'/>
<JSeparator/>
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-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -382,17 +382,18 @@
public void showFinancialStatementReportsView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- FinancialStatementReportView financialStatementReportView= new FinancialStatementReportView(mainView);
- mainView.showTab(_("lima.reports.financialstatement"), financialStatementReportView);
+ FinancialStatementReportView financialStatementReportView = new FinancialStatementReportView(mainView);
+ mainView.showTab(_("lima.reports.financialstatement"), financialStatementReportView);
}
- public void showImportView(String type) {
- /*if (!getImportView(type).isEnabled()) {
- getImportView(type).setEnabled(true);
- }*/
+ public void showImportExportView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ ImportExportHandler importExportHandler = new ImportExportHandler(mainView);
+ importExportHandler.importexportDialog();
}
public void showExportView(String type) {
+
/*if (!getExportView(type).isEnabled()) {
getExportView(type).setEnabled(true);
}*/
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -38,6 +38,7 @@
import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
import org.chorem.lima.util.FileChooseView;
+import org.chorem.lima.util.ImportExport;
import org.jdesktop.swingx.JXTreeTable;
/**
@@ -57,12 +58,10 @@
protected AccountView view;
protected AccountService accountService;
- protected ImportExportService importExportService;
protected AccountViewHandler(AccountView view) {
this.view = view;
// Gets factory service
- importExportService = LimaServiceFactory.getInstance().getImportExportService();
accountService = LimaServiceFactory.getInstance().getAccountService();
}
@@ -266,13 +265,14 @@
FileChooseView fileChooseView = new FileChooseView(view);
JFileChooser chooser = fileChooseView.getChooser();
+ ImportExport importExport = ImportExport.getInstance();
try {
if (mode.equals("import")){
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
String filePath = chooser.getSelectedFile().getAbsolutePath();
- String message = importExportService.importAccountsChartCSV(filePath);
+ String message = importExport.importFromCsvFile(filePath, "importAccountsChart");
accountsTreeTableModel.refreshTree();
DialogHelper.showMessageDialog(message);
}
@@ -281,7 +281,7 @@
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
String filePath = chooser.getSelectedFile().getAbsolutePath();
- importExportService.exportAccountsChartAsCSV(filePath);
+ importExport.exportToCsvFile(filePath, "exportAccountsChart");
}
}
} catch (LimaException eee) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -19,24 +19,18 @@
package org.chorem.lima.ui.entrybook;
import static org.nuiton.i18n.I18n._;
-
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.ImportExportService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
-import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.ImportExportForm;
-import org.chorem.lima.ui.account.AccountTreeTableModel;
import org.chorem.lima.util.DialogHelper;
-import org.chorem.lima.util.ErrorHelper;
import org.chorem.lima.util.FileChooseView;
+import org.chorem.lima.util.ImportExport;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.JXTreeTable;
/**
* Handler for entry book view.
@@ -52,12 +46,9 @@
private static final Log log = LogFactory.getLog(EntryBookViewHandler.class);
protected EntryBookView view;
-
- protected ImportExportService importExportService;
-
+
public EntryBookViewHandler(EntryBookView view) {
this.view = view;
- importExportService = LimaServiceFactory.getInstance().getImportExportService();
}
public void addEntryBook() {
@@ -166,13 +157,14 @@
FileChooseView fileChooseView = new FileChooseView(view);
JFileChooser chooser = fileChooseView.getChooser();
+ ImportExport importExport = ImportExport.getInstance();
try {
if (mode.equals("import")){
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
String filePath = chooser.getSelectedFile().getAbsolutePath();
- String message = importExportService.importEntryBookChartCSV(filePath);
+ String message = importExport.importFromCsvFile(filePath, "importEntryBookChart");
entryBookTableModel.refreshTable();
DialogHelper.showMessageDialog(message);
}
@@ -181,7 +173,7 @@
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
String filePath = chooser.getSelectedFile().getAbsolutePath();
- importExportService.exportEntryBookChartAsCSV(filePath);
+ importExport.exportToCsvFile(filePath, "exportEntryBookChart");
}
}
} catch (LimaException eee) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-02 10:31:31 UTC (rev 2961)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -24,18 +24,17 @@
import javax.swing.tree.TreePath;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.ImportExportService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementImpl;
-import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.ImportExportForm;
import org.chorem.lima.ui.financialstatementchart.FinancialStatementHeaderForm;
import org.chorem.lima.ui.financialstatementchart.FinancialStatementMovementForm;
import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
import org.chorem.lima.util.FileChooseView;
+import org.chorem.lima.util.ImportExport;
import org.jdesktop.swingx.JXTreeTable;
/**
@@ -53,12 +52,9 @@
private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class);
protected FinancialStatementChartView view;
-
- protected ImportExportService importExportService;
-
+
protected FinancialStatementChartViewHandler(FinancialStatementChartView view) {
this.view = view;
- importExportService = LimaServiceFactory.getInstance().getImportExportService();
}
/**
@@ -67,10 +63,13 @@
public void addFinancialStatementHeader() {
JXTreeTable treeTable = view.getTreeTable();
- FinancialStatementChartTreeTableModel treeTableModel = (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel();
+ FinancialStatementChartTreeTableModel treeTableModel =
+ (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel();
- FinancialStatement newFinancialStatementHeader = new FinancialStatementImpl();
- FinancialStatementHeaderForm financialStatementHeaderForm = new FinancialStatementHeaderForm(view);
+ FinancialStatement newFinancialStatementHeader =
+ new FinancialStatementImpl();
+ FinancialStatementHeaderForm financialStatementHeaderForm =
+ new FinancialStatementHeaderForm(view);
financialStatementHeaderForm.setFinancialStatement(newFinancialStatementHeader);
// jaxx constructor don't call super() ?
financialStatementHeaderForm.setLocationRelativeTo(view);
@@ -112,10 +111,13 @@
public void addFinancialStatementMovement(){
JXTreeTable treeTable = view.getTreeTable();
- FinancialStatementChartTreeTableModel treeTableModel = (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel();
+ FinancialStatementChartTreeTableModel treeTableModel =
+ (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel();
- FinancialStatement newFinancialStatementMovement = new FinancialStatementImpl();
- FinancialStatementMovementForm financialStatementMovementForm = new FinancialStatementMovementForm(view);
+ FinancialStatement newFinancialStatementMovement =
+ new FinancialStatementImpl();
+ FinancialStatementMovementForm financialStatementMovementForm =
+ new FinancialStatementMovementForm(view);
financialStatementMovementForm.setFinancialStatement(newFinancialStatementMovement);
// jaxx constructor don't call super() ?
financialStatementMovementForm.setLocationRelativeTo(view);
@@ -155,12 +157,14 @@
public void updateFinancialStatement() {
JXTreeTable treeTable = view.getTreeTable();
- FinancialStatementChartTreeTableModel treeTableModel = (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel();
+ FinancialStatementChartTreeTableModel treeTableModel =
+ (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel();
// get selected account
int selectedRow = view.treeTable.getSelectedRow();
TreePath treePath = view.treeTable.getPathForRow(selectedRow); // not null
- FinancialStatement financialStatement = (FinancialStatement) treePath.getLastPathComponent();
+ FinancialStatement financialStatement =
+ (FinancialStatement) treePath.getLastPathComponent();
//update Account or update SubLedger
if (financialStatement != null) {
// get current selection path
@@ -172,7 +176,8 @@
//test if selectedrow is account or ledger
log.debug(financialStatement.getHeader());
if (financialStatement.getHeader()){
- FinancialStatementHeaderForm financialStatementHeaderForm = new FinancialStatementHeaderForm(view);
+ FinancialStatementHeaderForm financialStatementHeaderForm =
+ new FinancialStatementHeaderForm(view);
financialStatementHeaderForm.setFinancialStatement(financialStatement);
// jaxx constructor don't call super() ?
financialStatementHeaderForm.setLocationRelativeTo(view);
@@ -182,19 +187,22 @@
}
// else is a movement
else{
- FinancialStatementMovementForm financialStatementMovementForm = new FinancialStatementMovementForm(view);
+ FinancialStatementMovementForm financialStatementMovementForm =
+ new FinancialStatementMovementForm(view);
financialStatementMovementForm.setFinancialStatement(financialStatement);
// jaxx constructor don't call super() ?
financialStatementMovementForm.setLocationRelativeTo(view);
financialStatementMovementForm.setVisible(true);
// null == cancel action
- financialStatement = financialStatementMovementForm.getFinancialStatement();
+ financialStatement =
+ financialStatementMovementForm.getFinancialStatement();
}
//if action confirmed
if (financialStatement != null){
// update it
try {
- treeTableModel.updateFinancialStatement(treePath, financialStatement);
+ treeTableModel.updateFinancialStatement(
+ treePath, financialStatement);
} catch (LimaException eee) {
if (log.isErrorEnabled()) {
log.error("Can't add update", eee);
@@ -224,10 +232,12 @@
if (n == JOptionPane.YES_OPTION) {
// update view of treetable
TreePath treePath = view.treeTable.getPathForRow(selectedRow);
- FinancialStatement financialStatement = (FinancialStatement) treePath.getLastPathComponent();
+ FinancialStatement financialStatement =
+ (FinancialStatement) treePath.getLastPathComponent();
try{
- treeTableModel.removeFinancialStatementObject(treePath, financialStatement);
+ treeTableModel.removeFinancialStatementObject(
+ treePath, financialStatement);
} catch (LimaException eee) {
if (log.isErrorEnabled()) {
log.error("Can't delete account", eee);
@@ -255,13 +265,14 @@
FileChooseView fileChooseView = new FileChooseView(view);
JFileChooser chooser = fileChooseView.getChooser();
+ ImportExport importExport = ImportExport.getInstance();
try {
if (mode.equals("import")){
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
String filePath = chooser.getSelectedFile().getAbsolutePath();
- String message = importExportService.importFinancialStatementChartCSV(filePath);
+ String message = importExport.importFromCsvFile(filePath, "importFinancialStatementsChart");
treeTableModel.refreshTree();
DialogHelper.showMessageDialog(message);
}
@@ -270,7 +281,7 @@
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
String filePath = chooser.getSelectedFile().getAbsolutePath();
- importExportService.exportFinancialStatementChartAsCSV(filePath);
+ importExport.exportToCsvFile(filePath, "exportFinancialStatementsChart");
}
}
} catch (LimaException eee) {
Added: trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-05 14:59:28 UTC (rev 2962)
@@ -0,0 +1,129 @@
+/* *##% 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.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ImportExportService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.account.AccountViewHandler;
+
+public class ImportExport {
+
+ private static ImportExport exchanger;
+
+ private static final Log log = LogFactory.getLog(AccountViewHandler.class);
+
+ protected ImportExportService importExportService;
+
+ public ImportExport() {
+ importExportService = LimaServiceFactory.getInstance().getImportExportService();
+ }
+
+ /**
+ * Call export methode in business
+ * Get csv datas in string and write file
+ * @param path
+ * @param exportMethode
+ * @throws LimaException
+ */
+ public void exportToCsvFile(String path, String exportMethode) throws LimaException {
+ String result = "";
+ try {
+ BufferedOutputStream f = new BufferedOutputStream(new FileOutputStream(path));
+ if (exportMethode.equals("exportEntryBookChart")){
+ result = importExportService.exportEntryBookChartAsCSV();
+ }
+ else if (exportMethode.equals("exportAccountsChart")){
+ result = importExportService.exportAccountsChartAsCSV();
+
+ }
+ else if (exportMethode.equals("exportFinancialStatementsChart")){
+ result = importExportService.exportFinancialStatementChartAsCSV();
+ }
+ else {
+ result = importExportService.exportAsCSV();
+ }
+ f.write(result.getBytes());
+ f.flush();
+ f.close();
+ }
+ catch (IOException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't write file "+path, eee);
+ }
+ }
+ }
+
+
+ /**
+ * Open scv file and get his datas on a string
+ * Call import methode in business
+ *
+ * @param path
+ * @param importMethode
+ * @return
+ * @throws LimaException
+ */
+ public String importFromCsvFile(String path, String importMethode) throws LimaException {
+ String result = "";
+ byte[] buffer = new byte[(int) new File(path).length()];
+ try {
+ BufferedInputStream f = new BufferedInputStream(new FileInputStream(path));
+ f.read(buffer);
+
+ if (importMethode.equals("importEntryBookChart")){
+ result = importExportService.importEntryBooksChartAsCSV(new String(buffer));
+ }
+ else if (importMethode.equals("importAccountsChart")){
+ result = importExportService.importAccountsChartAsCSV(new String(buffer));
+ }
+ else if (importMethode.equals("importFinancialStatementsChart")){
+ result = importExportService.importFinancialStatementsChartAsCSV(new String(buffer));
+ }
+ else {
+ result = importExportService.importCSV(new String(buffer));
+ }
+ f.close();
+ }
+ catch (IOException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't read file "+path, eee);
+ }
+ }
+
+ return result;
+ }
+
+ public static ImportExport getInstance() {
+ if (exchanger == null) {
+ exchanger = new ImportExport();
+ }
+ return exchanger;
+ }
+
+}
1
0
r2961 - 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/entrybook lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart lima-swing/src/main/resources/i18n
by jpepin@users.chorem.org 02 Jul '10
by jpepin@users.chorem.org 02 Jul '10
02 Jul '10
Author: jpepin
Date: 2010-07-02 12:31:31 +0200 (Fri, 02 Jul 2010)
New Revision: 2961
Url: http://chorem.org/repositories/revision/lima/2961
Log:
Import / Export des journaux
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-07-02 09:46:14 UTC (rev 2960)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-07-02 10:31:31 UTC (rev 2961)
@@ -120,7 +120,7 @@
/**
* import entrybook chart CSV.
*/
- void importEntryBookChartCSV(String path) throws LimaException;
+ String importEntryBookChartCSV(String path) throws LimaException;
/**
* export financialstatement chart as CSV.
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-07-02 09:46:14 UTC (rev 2960)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-07-02 10:31:31 UTC (rev 2961)
@@ -40,6 +40,7 @@
import org.chorem.lima.beans.FinancialStatementImport;
import org.chorem.lima.beans.FinancialStatementImportImpl;
import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.EntryBookService;
import org.chorem.lima.business.FinancialStatementService;
import org.chorem.lima.business.ImportExportService;
import org.chorem.lima.business.ImportExportServiceLocal;
@@ -49,6 +50,9 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookDAO;
+import org.chorem.lima.entity.EntryBookImpl;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementDAO;
import org.chorem.lima.entity.FinancialStatementImpl;
@@ -85,6 +89,9 @@
@EJB
FinancialStatementService financialStatementService;
+
+ @EJB
+ EntryBookService entryBookService;
public ImportExportServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -331,15 +338,91 @@
@Override
public void exportEntryBookChartAsCSV(String path) throws LimaException {
+ File f = new File(path);
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+ CSVWriter csvWriter = new CSVWriter(new FileWriter(f), ';');
+ String[] nextLine = new String[3];
+ // Get all entrybook
+ EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+
+ List<EntryBook> listEntryBook = entryBookDAO.findAll();
+ nextLine[0] = "lima.entrybooks";
+ csvWriter.writeNext(nextLine);
+ // For all EntryBook
+ for (EntryBook entryBook : listEntryBook) {
+ nextLine[0] = entryBook.getCode();
+ nextLine[1] = entryBook.getLabel();
+ nextLine[2] = entryBook.getType();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ // Write cache in file
+ csvWriter.flush();
+ csvWriter.close();
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Writer with file"+f+eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
-
}
@Override
- public void importEntryBookChartCSV(String path) throws LimaException {
- // TODO Auto-generated method stub
-
+ public String importEntryBookChartCSV(String path) throws LimaException {
+ File f = new File(path);
+ String result = "";
+
+ TopiaContext topiaContext = null;
+ try {
+ topiaContext = beginTransaction();
+ String[] nextLine = new String[1];
+ CSVReader csvReader = new CSVReader(new FileReader(f), ';');
+
+ nextLine = csvReader.readNext(); // File Type
+ if (!nextLine[0].equals("lima.entrybooks")){
+ throw new LimaBusinessException(
+ "The file is not an export csv file type entrybooks");
+ }
+
+ EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
+
+ while ((nextLine = csvReader.readNext()) != null) {
+ EntryBook entryBook = new EntryBookImpl();
+ entryBook.setCode(nextLine[0]);
+ entryBook.setLabel(nextLine[1]);
+ entryBook.setType(nextLine[2]);
+
+ //if exist, skip
+ if (entryBookDAO.findByCode(entryBook.getCode()) != null){
+ result += "FAILED : The entrybook "
+ + entryBook.getLabel() + " already exists !\n";
+ }
+ else {
+ //create it
+ entryBookService.createEntryBook(entryBook);
+ result += "SUCCESS : The financialStatement " +
+ entryBook.getLabel() + " is created ! \n";
+ }
+ }
+ }
+ catch (TopiaException eeeTE){
+ doCatch(topiaContext, eeeTE, log);
+ }
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader with file"+f+eeeIO);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ return result;
}
@Override
@@ -351,14 +434,14 @@
topiaContext = beginTransaction();
CSVWriter csvWriter = new CSVWriter(new FileWriter(f), ';');
String[] nextLine = new String[9];
- // Récupère tous les comptes
+ // Get all Financialstatements
FinancialStatementDAO financialStatementDAO =
LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
List<FinancialStatement> listFinancialStatements =
financialStatementDAO.findAll();
nextLine[0] = "lima.financialstatementschart";
csvWriter.writeNext(nextLine);
- // Pour tous les comptes
+ // For all Financialstatements
for (FinancialStatement financialStatement : listFinancialStatements) {
nextLine[0] = financialStatement.getLabel();
nextLine[1] = new Boolean(
@@ -380,7 +463,7 @@
masterFinancialStatement.getLabel();
}
nextLine[8] = masterFinancialStatementString;
- // Ajoute la ligne au fichier
+ // Add line in file
csvWriter.writeNext(nextLine);
}
// Write cache in file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-07-02 09:46:14 UTC (rev 2960)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-07-02 10:31:31 UTC (rev 2961)
@@ -132,6 +132,11 @@
return false;
}
+
+ public void refreshTable(){
+ fireTableDataChanged();
+ }
+
/**
* @param entryBook
* @throws LimaException
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-07-02 09:46:14 UTC (rev 2960)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-07-02 10:31:31 UTC (rev 2961)
@@ -27,7 +27,7 @@
]]>
</script>
<row>
- <cell fill="both" weightx="1" weighty="1" rows='4'>
+ <cell fill="both" weightx="1" weighty="1" rows='5'>
<JScrollPane>
<org.jdesktop.swingx.JXTable id="entryBooksTable" rowHeight="24"
model="{new org.chorem.lima.ui.entrybook.EntryBookTableModel()}"
@@ -57,4 +57,10 @@
onActionPerformed="getHandler().deleteEntryBook()"/>
</cell>
</row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="importexportButton" text="lima.common.importexport"
+ onActionPerformed="getHandler().importexportEntryBook()"/>
+ </cell>
+ </row>
</Table>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-02 09:46:14 UTC (rev 2960)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-02 10:31:31 UTC (rev 2961)
@@ -20,16 +20,23 @@
import static org.nuiton.i18n.I18n._;
+import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ImportExportService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.ImportExportForm;
+import org.chorem.lima.ui.account.AccountTreeTableModel;
import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
+import org.chorem.lima.util.FileChooseView;
import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.JXTreeTable;
/**
* Handler for entry book view.
@@ -46,8 +53,11 @@
protected EntryBookView view;
+ protected ImportExportService importExportService;
+
public EntryBookViewHandler(EntryBookView view) {
this.view = view;
+ importExportService = LimaServiceFactory.getInstance().getImportExportService();
}
public void addEntryBook() {
@@ -137,4 +147,49 @@
DialogHelper.showMessageDialog(eee.getMessage());
}
}
+
+
+public void importexportEntryBook(){
+
+ JXTable entryBookTable = view.getEntryBooksTable();
+ EntryBookTableModel entryBookTableModel =
+ (EntryBookTableModel)entryBookTable.getModel();
+
+ ImportExportForm importExportForm = new ImportExportForm(view);
+ importExportForm.setLocationRelativeTo(view);
+ importExportForm.setVisible(true);
+
+ Object value = importExportForm.getRadioButtons().getSelectedValue();
+ // if action confirmed
+ if (value != null){
+ String mode = (String) value;
+ FileChooseView fileChooseView = new FileChooseView(view);
+
+ JFileChooser chooser = fileChooseView.getChooser();
+
+ try {
+ if (mode.equals("import")){
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
+ String filePath = chooser.getSelectedFile().getAbsolutePath();
+ String message = importExportService.importEntryBookChartCSV(filePath);
+ entryBookTableModel.refreshTable();
+ DialogHelper.showMessageDialog(message);
+ }
+ }
+ else {
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) {
+ String filePath = chooser.getSelectedFile().getAbsolutePath();
+ importExportService.exportEntryBookChartAsCSV(filePath);
+ }
+ }
+ } catch (LimaException eee) {
+ if (log.isErrorEnabled()){
+ log.error("Can't "+ mode +" this file", eee);
+ }
+ DialogHelper.showMessageDialog(eee.getMessage());
+ }
+ }
+ }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx 2010-07-02 09:46:14 UTC (rev 2960)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx 2010-07-02 10:31:31 UTC (rev 2961)
@@ -64,7 +64,7 @@
enabled="{isSelectedRow()}"/>
</cell>
</row>
- <row>
+ <row>
<cell fill="horizontal">
<JButton id="importexportButton" text="lima.common.importexport"
onActionPerformed="getHandler().importexportFinancialStatement()"/>
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-07-02 09:46:14 UTC (rev 2960)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-07-02 10:31:31 UTC (rev 2961)
@@ -33,7 +33,7 @@
lima.common.add=
lima.common.addSubLedger=
lima.common.cancel=
-lima.common.importexport=
+lima.common.importexport=Import/Export
lima.common.ok=
lima.common.print=
lima.common.quit=
@@ -93,9 +93,8 @@
lima.import.all.csv=Import all datas (CSV)
lima.import.all.csv.ebp=Import all datas (EBP)
lima.import.journal=Import journal
-lima.importexport.export=
-lima.importexport.import=
-lima.importexport.update=
+lima.importexport.export=Export
+lima.importexport.import=Import
lima.init.closed=Lima closed at %1$s
lima.init.errorclosing=
lima.lettering.add=
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-07-02 09:46:14 UTC (rev 2960)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-07-02 10:31:31 UTC (rev 2961)
@@ -33,7 +33,7 @@
lima.common.add=Ajout Compte G\u00E9n\u00E9ral
lima.common.addSubLedger=Ajouter Compte Tiers
lima.common.cancel=Annuler
-lima.common.importexport=
+lima.common.importexport=Importer/Exporter
lima.common.ok=OK
lima.common.print=
lima.common.quit=Quitter
@@ -93,9 +93,8 @@
lima.import.all.csv=Importer une nouvelle base (CSV)
lima.import.all.csv.ebp=Importer des donn\u00E9es de EBP
lima.import.journal=Importer le journal
-lima.importexport.export=
-lima.importexport.import=
-lima.importexport.update=
+lima.importexport.export=Export
+lima.importexport.import=Import
lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s
lima.init.errorclosing=
lima.lettering.add=Ajouter une lettre
1
0
r2960 - in trunk/lima-business/src/main/java/org/chorem/lima/business: . ejb
by jpepin@users.chorem.org 02 Jul '10
by jpepin@users.chorem.org 02 Jul '10
02 Jul '10
Author: jpepin
Date: 2010-07-02 11:46:14 +0200 (Fri, 02 Jul 2010)
New Revision: 2960
Url: http://chorem.org/repositories/revision/lima/2960
Log:
Ajout import plan BCR.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-07-01 15:51:40 UTC (rev 2959)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-07-02 09:46:14 UTC (rev 2960)
@@ -107,26 +107,29 @@
void exportAccountsChartAsCSV(String path) throws LimaException;
/**
- * import accounts chart as CSV.
+ * import accounts chart CSV.
* Return result log
*/
String importAccountsChartCSV(String path) throws LimaException;
/**
* export entrybook chart as CSV.
- *
- * @param data
- * @throws LimaException
*/
- void exportEntryBookChartAsCSV(byte[] data) throws LimaException;
+ void exportEntryBookChartAsCSV(String path) throws LimaException;
/**
+ * import entrybook chart CSV.
+ */
+ void importEntryBookChartCSV(String path) throws LimaException;
+
+ /**
* export financialstatement chart as CSV.
*/
void exportFinancialStatementChartAsCSV(String path) throws LimaException;
/**
- * export financialstatement chart as CSV.
+ * import financialstatement chart CSV.
+ * Return result log
*/
String importFinancialStatementChartCSV(String path) throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-07-01 15:51:40 UTC (rev 2959)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-07-02 09:46:14 UTC (rev 2960)
@@ -106,10 +106,15 @@
financialStatementDAO.create(financialStatement);
+ FinancialStatement masterfinancialStatementUpdate = null;
+ if (masterFinancialStatement != null){
+ masterfinancialStatementUpdate = financialStatementDAO.findByLabel(masterFinancialStatement.getLabel());
+ }
+
// check if parent account exist;
- if (masterFinancialStatement != null) {
- masterFinancialStatement.addSubFinancialStatements(financialStatement);
- financialStatementDAO.update(masterFinancialStatement);
+ if (masterfinancialStatementUpdate != null) {
+ masterfinancialStatementUpdate.addSubFinancialStatements(financialStatement);
+ financialStatementDAO.update(masterfinancialStatementUpdate);
}
commitTransaction(transaction);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-07-01 15:51:40 UTC (rev 2959)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-07-02 09:46:14 UTC (rev 2960)
@@ -30,12 +30,15 @@
import java.util.TreeMap;
import javax.ejb.EJB;
import javax.ejb.Stateless;
+import javax.swing.text.StyledEditorKit.BoldAction;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.AccountImport;
import org.chorem.lima.beans.AccountImportImpl;
import org.chorem.lima.beans.FinancialStatementImport;
+import org.chorem.lima.beans.FinancialStatementImportImpl;
import org.chorem.lima.business.AccountService;
import org.chorem.lima.business.FinancialStatementService;
import org.chorem.lima.business.ImportExportService;
@@ -264,14 +267,14 @@
}
else {
//create it
- AccountImport account = new AccountImportImpl();
- account.setAccountNumber(accountNumber);
- account.setLabel(label);
- account.setThirdParty(thirdParty);
- account.setMasterAccount(masterAccountNumber);
- account.setGeneralLedger(generalLedgerNumber);
+ AccountImport accountImport = new AccountImportImpl();
+ accountImport.setAccountNumber(accountNumber);
+ accountImport.setLabel(label);
+ accountImport.setThirdParty(thirdParty);
+ accountImport.setMasterAccount(masterAccountNumber);
+ accountImport.setGeneralLedger(generalLedgerNumber);
// put it in hashset
- accounts.put(accountNumber, account);
+ accounts.put(accountNumber, accountImport);
}
}
@@ -292,8 +295,6 @@
account.setAccountNumber(accountImport.getAccountNumber());
account.setLabel(accountImport.getLabel());
account.setThirdParty(accountImport.getThirdParty());
- account.setMasterAccount(masterAccount);
- account.setGeneralLedger(generalLedger);
if (generalLedger != null){
accountService.createSubLedger(generalLedger, account);
@@ -329,8 +330,17 @@
@Override
- public void exportEntryBookChartAsCSV(byte[] data) throws LimaException {
+ public void exportEntryBookChartAsCSV(String path) throws LimaException {
+
+
}
+
+
+ @Override
+ public void importEntryBookChartCSV(String path) throws LimaException {
+ // TODO Auto-generated method stub
+
+ }
@Override
public void exportFinancialStatementChartAsCSV(String path) throws LimaException {
@@ -342,24 +352,32 @@
CSVWriter csvWriter = new CSVWriter(new FileWriter(f), ';');
String[] nextLine = new String[9];
// Récupère tous les comptes
- FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
- List<FinancialStatement> listFinancialStatements = financialStatementDAO.findAll();
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+ List<FinancialStatement> listFinancialStatements =
+ financialStatementDAO.findAll();
nextLine[0] = "lima.financialstatementschart";
csvWriter.writeNext(nextLine);
// Pour tous les comptes
for (FinancialStatement financialStatement : listFinancialStatements) {
nextLine[0] = financialStatement.getLabel();
- nextLine[1] = new Boolean(financialStatement.getHeader()).toString();
+ nextLine[1] = new Boolean(
+ financialStatement.getHeader()).toString();
nextLine[2] = financialStatement.getAccounts();
nextLine[3] = financialStatement.getDebitAccounts();
nextLine[4] = financialStatement.getCreditAccounts();
- nextLine[5] = financialStatement.getProvisionDeprecationAccounts();
- nextLine[6] = new Boolean(financialStatement.getSubAmount()).toString();
- nextLine[7] = new Boolean(financialStatement.getHeaderAmount()).toString();
- FinancialStatement masterFinancialStatement = financialStatement.getMasterFinancialStatement();
+ nextLine[5] = financialStatement.
+ getProvisionDeprecationAccounts();
+ nextLine[6] = new Boolean(
+ financialStatement.getSubAmount()).toString();
+ nextLine[7] = new Boolean(
+ financialStatement.getHeaderAmount()).toString();
+ FinancialStatement masterFinancialStatement =
+ financialStatement.getMasterFinancialStatement();
String masterFinancialStatementString = "";
if (masterFinancialStatement != null){
- masterFinancialStatementString = masterFinancialStatement.getLabel();
+ masterFinancialStatementString =
+ masterFinancialStatement.getLabel();
}
nextLine[8] = masterFinancialStatementString;
// Ajoute la ligne au fichier
@@ -388,11 +406,10 @@
TopiaContext topiaContext = null;
try {
topiaContext = beginTransaction();
- /*
String[] nextLine = new String[1];
CSVReader csvReader = new CSVReader(new FileReader(f), ';');
- nextLine = csvReader.readNext(); // Date début période
+ nextLine = csvReader.readNext(); // File Type
if (!nextLine[0].equals("lima.financialstatementschart")){
throw new LimaBusinessException(
"The file is not an export csv file type financialstatementschart");
@@ -400,93 +417,104 @@
FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
- TreeMap<String, AccountImport> accounts =
- new TreeMap<String, AccountImport>();
-
- ColumnPositionMappingStrategy strat =
- new ColumnPositionMappingStrategy();
- strat.setType(FinancialStatementImport.class);
- String[] columns = new String[] {"label", "header", "accounts",
- "debitAccounts", "creditAccounts","provisionDeprecationAccounts",
- "subAmount", "headerAmount", "masterFinancialStatement"};
- strat.setColumnMapping(columns);
- CsvToBean csv = new CsvToBean();
- List list = csv.parse(strat, csvReader);
+ TreeMap<String, FinancialStatementImport> financialStatements =
+ new TreeMap<String, FinancialStatementImport>();
while ((nextLine = csvReader.readNext()) != null) {
- String accountNumber = nextLine[0];
- String label = nextLine[1];
- String thirdParty = nextLine[2];
- String masterAccountNumber = nextLine[3];
- String generalLedgerNumber = nextLine[4];
+ String label = nextLine[0];
+ String header = nextLine[1];
+ String accounts = nextLine[2];
+ String debitAccounts = nextLine[3];
+ String creditAccounts = nextLine[4];
+ String provisionDeprecationAccounts = nextLine[5];
+ String subAmount = nextLine[6];
+ String headerAmount = nextLine[7];
+ String masterFinancialStatement = nextLine[8];
//if exist, skip
- if (financialStatementDAO.findByLabel(accountNumber) != null){
- result += "FAILED : The account "
- + accountNumber + " already exists !\n";
+ if (financialStatementDAO.findByLabel(label) != null){
+ result += "FAILED : The financialstatement "
+ + label + " already exists !\n";
}
else {
//create it
- AccountImport account = new AccountImportImpl();
- account.setAccountNumber(accountNumber);
- account.setLabel(label);
- account.setThirdParty(thirdParty);
- account.setMasterAccount(masterAccountNumber);
- account.setGeneralLedger(generalLedgerNumber);
+ FinancialStatementImport financialStatementImport =
+ new FinancialStatementImportImpl();
+ financialStatementImport.setLabel(label);
+ financialStatementImport.setHeader(header);
+ financialStatementImport.setAccounts(accounts);
+ financialStatementImport.setCreditAccounts(creditAccounts);
+ financialStatementImport.setDebitAccounts(debitAccounts);
+ financialStatementImport.setHeaderAmount(headerAmount);
+ financialStatementImport.setProvisionDeprecationAccounts(
+ provisionDeprecationAccounts);
+ financialStatementImport.setSubAmount(subAmount);
+ financialStatementImport.setMasterFinancialStatement(
+ masterFinancialStatement);
+
// put it in hashset
- accounts.put(accountNumber, account);
+ financialStatements.put(label, financialStatementImport);
}
- }
+ }
+
- while (accounts.size() > 0){
- for (Iterator<AccountImport> itr =accounts.values().iterator(); itr.hasNext();){
- AccountImport accountImport = itr.next();
- String masterAccountNumber = accountImport.getMasterAccount();
- String generalLedgerNumber = accountImport.getGeneralLedger();
- //Account masterAccount =
- accountDAO.findByAccountNumber(masterAccountNumber);
- Account generalLedger =
- accountDAO.findByAccountNumber(generalLedgerNumber);
+ while (financialStatements.size() > 0){
+ for (Iterator<FinancialStatementImport> itr = financialStatements.values().iterator(); itr.hasNext();){
+ FinancialStatementImport financialStatementImport = itr.next();
+ String masterFinancialStatementLabel =
+ financialStatementImport.getMasterFinancialStatement();
+ FinancialStatement masterFinancialStatement =
+ financialStatementDAO.findByLabel(
+ masterFinancialStatementLabel);
- if ((masterAccountNumber.equals("") && generalLedgerNumber.equals(""))
- || masterAccount != null || generalLedger != null){
+ if (masterFinancialStatementLabel.equals("")
+ || masterFinancialStatement != null){
//create it
- Account account = new AccountImpl();
- account.setAccountNumber(accountImport.getAccountNumber());
- account.setLabel(accountImport.getLabel());
- account.setThirdParty(accountImport.getThirdParty());
- account.setMasterAccount(masterAccount);
- account.setGeneralLedger(generalLedger);
+ FinancialStatement financialStatement =
+ new FinancialStatementImpl();
+ financialStatement.setLabel(
+ financialStatementImport.getLabel());
+ financialStatement.setHeader(Boolean.parseBoolean(
+ financialStatementImport.getHeader()));
+ financialStatement.setAccounts(
+ financialStatementImport.getAccounts());
+ financialStatement.setDebitAccounts(
+ financialStatementImport.getDebitAccounts());
+ financialStatement.setCreditAccounts(
+ financialStatementImport.getCreditAccounts());
+ financialStatement.setProvisionDeprecationAccounts(
+ financialStatementImport.
+ getProvisionDeprecationAccounts());
+ financialStatement.setSubAmount(Boolean.parseBoolean(
+ financialStatementImport.getSubAmount()));
+ financialStatement.setHeaderAmount(Boolean.parseBoolean(
+ financialStatementImport.getHeaderAmount()));
+
+ financialStatementService.createFinancialStatement(
+ masterFinancialStatement, financialStatement);
- if (generalLedger != null){
- accountService.createSubLedger(generalLedger, account);
- }
- else {
- accountService.createAccount(masterAccount, account);
- }
- result += "SUCCESS : The account " +
- accountImport.getAccountNumber() + " is created ! \n";
+ result += "SUCCESS : The financialStatement " +
+ financialStatementImport.getLabel() + " is created ! \n";
itr.remove();
}
- else if (!accounts.containsKey(masterAccountNumber)
- && !accounts.containsKey(generalLedgerNumber) ){
- result += "FAILED : The account " +
- accountImport.getAccountNumber() + " have masterAccount : " +
- masterAccountNumber + "which not exist \n";
+ else if (!financialStatements.containsKey(masterFinancialStatementLabel)){
+ result += "FAILED : The financialStatement " +
+ financialStatementImport.getLabel() +
+ " have masterFinancialStatement : " +
+ masterFinancialStatementLabel + "which not exist \n";
itr.remove();
}
}
}
- */
}
catch (TopiaException eeeTE){
doCatch(topiaContext, eeeTE, log);
}
- //catch (IOException eeeIO) {
- // log.debug("Can't create new CSV Reader with file"+f+eeeIO);
- //}
+ catch (IOException eeeIO) {
+ log.debug("Can't create new CSV Reader with file"+f+eeeIO);
+ }
finally {
doFinally(topiaContext, log);
}
1
0