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
August 2010
- 3 participants
- 42 discussions
Author: jpepin
Date: 2010-08-13 12:43:53 +0200 (Fri, 13 Aug 2010)
New Revision: 3001
Url: http://chorem.org/repositories/revision/lima/3001
Log:
Ajout import compte tiers depuis EBP.
Mise ?\195?\160 jour algo de calcul du bilan / compte de r?\195?\169sultat : probl?\195?\168me avec les comptes tiers.
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/ExportServiceImpl.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/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ImportService.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.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/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -490,7 +490,6 @@
first=false;
}
//add all accounts
- log.debug("accountNumbers "+accountNumbers);
for (String accountNumber : accountNumbers) {
if (subAccountsMode){
Account account = accountDAO.findSubAccountByNumber(accountNumber);
@@ -499,7 +498,7 @@
String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS);
String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS);
query.addWhere("not exists elements ("+subAccountsProperty+")")
- .addWhere("not exists elements ("+subLedgersProperty+")")
+ //.addWhere("not exists elements ("+subLedgersProperty+")")
.addWhere(Account.ACCOUNT_NUMBER, Op.LIKE, accountNumber+"%");
List<Account> accountsResult = accountDAO.findAllByQuery(query);
if (accountsResult != null){
@@ -520,7 +519,6 @@
}
//remove all accounts
- log.debug("accountNumbersToRemove "+accountNumbersToRemove);
for (String accountNumber : accountNumbersToRemove) {
Account account = null;
if (subAccountsMode){
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-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.io.StringWriter;
-import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.List;
import javax.ejb.Stateless;
@@ -435,7 +434,7 @@
/**
* Local methode, export accounts from database
- * Structure : TYPE | AccountNumber | Label | ThirdParty | MasteAccount | GeneralLedger
+ * Structure : TYPE | AccountNumber | Label | ThirdParty | MasterAccount | GeneralLedger
*/
public void exportAccountsChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException {
try {
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-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -304,7 +304,9 @@
return result;
}
-
+ /**
+ * Créé la liste de postes contenant les calculs de comptes
+ */
public FinancialStatementDatas financialStatementReport(FinancialStatement financialStatement, Date selectedBeginDate, Date selectedEndDate,FinancialStatementDatas result, TopiaContext topiaContext) throws LimaException{
List<FinancialStatement> financialStatements =
@@ -405,20 +407,67 @@
}
/**
- * Permet de calculer tous les comptes contenu dans un mouvement
+ * Permet de calculer le montant de tous les comptes contenu dans un mouvement
*/
public FinancialStatementAmounts financialStatementAmounts(FinancialStatement financialStatement, Date selectedBeginDate, Date selectedEndDate, TopiaContext topiaContext) throws LimaException{
FinancialStatementAmounts financialStatementAmounts =
new FinancialStatementAmountsImpl();
+
+ FinancialStatement masterFinancialStatement = financialStatement.getMasterFinancialStatement();
+ FinancialStatementWayEnum financialStatementWayEnum = FinancialStatementWayEnum.BOTH;
+ if (masterFinancialStatement != null){
+ financialStatementWayEnum = masterFinancialStatement.getWay();
+ }
+
+ // DEBIT & CREDIT ACCOUNTS LIST
+ String accountsString = financialStatement.getAccounts();
+ BigDecimal amount = accountsNumberListToAmount(accountsString,
+ financialStatementWayEnum, FinancialStatementWayEnum.BOTH,
+ selectedBeginDate,selectedEndDate, topiaContext);
+ // DEBIT ACCOUNTS LIST
+ String debitAccountsString = financialStatement.getDebitAccounts();
+ BigDecimal debitAmount = accountsNumberListToAmount(debitAccountsString,
+ financialStatementWayEnum, FinancialStatementWayEnum.DEBIT,
+ selectedBeginDate, selectedEndDate, topiaContext);
+ //CREDIT ACCOUNTS LIST
+ String creditAccountsString = financialStatement.getCreditAccounts();
+ BigDecimal creditAmount = accountsNumberListToAmount(creditAccountsString,
+ financialStatementWayEnum, FinancialStatementWayEnum.CREDIT,
+ selectedBeginDate, selectedEndDate, topiaContext);
+ // PROVISION & DEPRECATION
+ String provisionDeprecationAccountsString =
+ financialStatement.getProvisionDeprecationAccounts();
+ BigDecimal provisionDeprecationAmount = accountsNumberListToAmount(
+ provisionDeprecationAccountsString, financialStatementWayEnum,
+ FinancialStatementWayEnum.BOTH, selectedBeginDate,
+ selectedEndDate, topiaContext);
+
+ // set result
+ amount = amount.add(creditAmount);
+ amount = amount.add(debitAmount);
+ financialStatementAmounts.setGrossAmount(amount);
+ financialStatementAmounts.setLabel(financialStatement.getLabel());
+ financialStatementAmounts.setProvisionDeprecationAmount(
+ provisionDeprecationAmount);
+ financialStatementAmounts.setLevel(
+ financialStatement.getLevel());
+ return financialStatementAmounts;
+ }
+
+ /**
+ * Calulate the amount of string contains a list of account
+ * account number seperate by ',' use methode stringToList from account service
+ * the list support '-' minus operation
+ * @return
+ */
+ public BigDecimal accountsNumberListToAmount (String accountsNumberList, FinancialStatementWayEnum financialStatementWayEnum, FinancialStatementWayEnum debitCredit, Date selectedBeginDate, Date selectedEndDate, TopiaContext topiaContext) throws LimaException{
+ BigDecimal amount = new BigDecimal(0);
try {
- // DEBIT & CREDIT
- String accountsString = financialStatement.getAccounts();
- BigDecimal amount = new BigDecimal(0);
- if (accountsString != null){
+ if (accountsNumberList != null){
//Remove Spaces
- accountsString = StringUtils.deleteWhitespace(accountsString);
- StringTokenizer stQuote = new StringTokenizer(accountsString, "-");
+ accountsNumberList = StringUtils.deleteWhitespace(accountsNumberList);
+ StringTokenizer stQuote = new StringTokenizer(accountsNumberList, "-");
while (stQuote.hasMoreTokens()) {
String s = stQuote.nextToken();
List<Account> accountsList = accountServiceLocal.
@@ -426,102 +475,59 @@
BigDecimal resAmount = new BigDecimal(0);
for (Account account : accountsList) {
- log.debug(account.getAccountNumber());
ReportsDatas reportsDatas = reportServiceLocal.
generateAccountReportsWithTransaction(account,
selectedBeginDate, selectedEndDate, topiaContext);
+ BigDecimal tempAmount = new BigDecimal(0);
//check the way of financialstatement amount
- FinancialStatementWayEnum financialStatementWayEnum =
- financialStatement.getMasterFinancialStatement().getWay();
+ //exemple compte de résultat : charge -> débit, produit -> crédit
switch (financialStatementWayEnum) {
case BOTH:
- resAmount = resAmount.add(reportsDatas.getAmountSolde());
+ tempAmount = tempAmount.add(reportsDatas.getAmountSolde());
break;
case DEBIT:
- resAmount = resAmount.add(reportsDatas.getAmountDebit());
- resAmount = resAmount.subtract(reportsDatas.getAmountCredit());
+ tempAmount = tempAmount.add(reportsDatas.getAmountDebit());
+ tempAmount = tempAmount.subtract(reportsDatas.getAmountCredit());
break;
case CREDIT:
- resAmount = resAmount.add(reportsDatas.getAmountCredit());
- resAmount = resAmount.subtract(reportsDatas.getAmountDebit());
+ tempAmount = tempAmount.add(reportsDatas.getAmountCredit());
+ tempAmount = tempAmount.subtract(reportsDatas.getAmountDebit());
break;
}
+
+ //add the calcul in function of list type: allaccounts, debit or credit
+ switch (debitCredit) {
+ case BOTH:
+ resAmount = resAmount.add(tempAmount);
+ break;
+ case DEBIT:
+ if (reportsDatas.getSoldeDebit()){
+ resAmount = resAmount.add(tempAmount);
+ }
+ break;
+ case CREDIT:
+ if (!reportsDatas.getSoldeDebit()){
+ resAmount = resAmount.add(tempAmount);
+ }
+ break;
+ }
}
if (amount.doubleValue() == 0){
amount = resAmount;
}
+ //compte(s) précédé du signe -
else {
amount = amount.subtract(resAmount);
}
}
- }
-
- // CREDIT
- String creditAccountsString = financialStatement.getCreditAccounts();
- BigDecimal creditAmount = new BigDecimal(0);
- if (creditAccountsString != null){
- List<Account> creditAccountsList = accountServiceLocal.
- stringToListAccountsWithTransaction(creditAccountsString, false, topiaContext);
- for (Account account : creditAccountsList) {
- ReportsDatas reportsDatas = reportServiceLocal.
- generateAccountReportsWithTransaction(account,
- selectedBeginDate, selectedEndDate, topiaContext);
- creditAmount = creditAmount.add(reportsDatas.getAmountCredit());
- }
- }
-
-
- // DEBIT
- String debitAccountsString = financialStatement.getDebitAccounts();
- BigDecimal debitAmount = new BigDecimal(0);
- if (debitAccountsString != null){
- List<Account> debitAccountsList = accountServiceLocal.
- stringToListAccountsWithTransaction(debitAccountsString, false, topiaContext);
- for (Account account : debitAccountsList) {
- ReportsDatas reportsDatas = reportServiceLocal.
- generateAccountReportsWithTransaction(account,
- selectedBeginDate, selectedEndDate, topiaContext);
- debitAmount = debitAmount.add(reportsDatas.getAmountDebit());
- }
- }
-
-
- // PROVISION & DEPRECATION
- String provisionDeprecationAccountsString =
- financialStatement.getProvisionDeprecationAccounts();
- BigDecimal provisionDeprecationAmount = new BigDecimal(0);
- if (provisionDeprecationAccountsString != null){
- List<Account> provisionDeprecationAccountsList =
- accountServiceLocal.stringToListAccountsWithTransaction(
- provisionDeprecationAccountsString, false, topiaContext);
- for (Account account : provisionDeprecationAccountsList) {
- ReportsDatas reportsDatas = reportServiceLocal.
- generateAccountReportsWithTransaction(account,
- selectedBeginDate, selectedEndDate, topiaContext);
- provisionDeprecationAmount = provisionDeprecationAmount.add(reportsDatas.getAmountSolde());
- }
- }
-
- // set result
- amount = amount.add(creditAmount);
- amount = amount.add(debitAmount);
- financialStatementAmounts.setGrossAmount(amount);
- financialStatementAmounts.setLabel(financialStatement.getLabel());
- financialStatementAmounts.setProvisionDeprecationAmount(
- provisionDeprecationAmount);
- financialStatementAmounts.setLevel(
- financialStatement.getLevel());
-
- }
- catch (LimaException ex) {
- doCatch(topiaContext, ex, log);
- }
-
- return financialStatementAmounts;
+ }
+ }catch (LimaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ return amount;
}
-
@Override
public String checkFinancialStatementChart() throws LimaException {
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-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -26,7 +26,6 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@@ -37,6 +36,8 @@
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.FinancialStatementWayEnum;
@@ -192,6 +193,7 @@
CsvToBean<EntryEBPImpl> csv = new CsvToBean<EntryEBPImpl>();
List<EntryEBPImpl> list = csv.parse(strat, csvReader);
Collections.sort(list, new EntryEBPComparator());
+ log.debug(list.size()+" list /n"+list);
// DAOs
AccountDAO accountDAO = LimaCallaoDAOHelper
@@ -364,14 +366,8 @@
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.createAccountWithTransaction(null,
- account, topiaContext);
- result += "SUCCES : Account" + accountNumber + " "
- + label + " added\n";
- } else {
+ // if is thirdPart account
+ if (!StringUtils.isNumeric(accountNumber)){
Account masterAccount = null;
int i = 1;
while (masterAccount == null) {
@@ -381,11 +377,37 @@
.findByAccountNumber(masterAccountNumber);
i++;
}
- accountService.createAccountWithTransaction(
+ accountService.createSubLedgerWithTransaction(
masterAccount, account, topiaContext);
result += "SUCCES : Account" + accountNumber + " "
+ label + " added\n";
}
+ // else is account
+ else {
+ // if account is class account : 1, 2, 3, 4, 5, 6, 7,…
+ int nbCharAccountNumber = accountNumber.length();
+ if (nbCharAccountNumber == 1) {
+ accountService.createAccountWithTransaction(null,
+ account, topiaContext);
+ 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.createAccountWithTransaction(
+ masterAccount, account, topiaContext);
+ result += "SUCCES : Account" + accountNumber + " "
+ + label + " added\n";
+ }
+ }
}
}
} catch (TopiaException eeeTE) {
@@ -512,46 +534,27 @@
}
/**
- * Remote methode to call entrybooks import from UI
+ * Remote methode to call entity import from UI
+ * This methode let import just on type of entity
*/
@Override
- public String importEntryBooksChartAsCSV(String datas) throws LimaException {
+ public String importAsCSV(String datas, ImportExportEntityEnum importExportEntityEnum) 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) {
- if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.ENTRYBOOK) {
- 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;
- }
-
- /**
- * Remote methode to call financialStatements import from UI
- */
- @Override
- public String importFinancialStatementsChartAsCSV(String datas)
- throws LimaException {
- String result = "";
-
// FinancialStatements
- LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements =
- new LinkedHashMap<String, ArrayList<FinancialStatementImport>>();
-
+ LinkedHashMap<String, ArrayList<FinancialStatementImport>> financialStatements = null;
+ // Accounts
+ Map<String, AccountImport> accounts = null;
+
+ switch (importExportEntityEnum) {
+ case ACCOUNT:
+ accounts = new TreeMap<String, AccountImport>();
+ break;
+ case FINANCIALSTATEMENT:
+ financialStatements = new LinkedHashMap<String, ArrayList<FinancialStatementImport>>();
+ break;
+ }
+
TopiaContext topiaContext = null;
try {
topiaContext = beginTransaction();
@@ -560,51 +563,36 @@
CSVReader csvReader = new CSVReader(new StringReader(datas), ';');
while ((nextLine = csvReader.readNext()) != null) {
- if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.FINANCIALSTATEMENT) {
- result += importFinancialsStatementChartCSV(nextLine,
- financialStatements, topiaContext);
- }
- }
+ if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == importExportEntityEnum) {
+ switch (importExportEntityEnum) {
+ case ENTRYBOOK:
+ result += importEntryBooksChartCSV(nextLine, topiaContext);
+ break;
- // 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;
- }
+ case ACCOUNT:
+ result += importAccountsChartsCSV(nextLine, accounts,
+ topiaContext);
+ break;
+ case FINANCIALSTATEMENT:
- /**
- * Remote methode to call accounts import from UI
- */
- @Override
- public String importAccountsChartAsCSV(String datas) throws LimaException {
- String result = "";
-
- // Accounts
- Map<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) {
- if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.ACCOUNT) {
- result += importAccountsChartsCSV(nextLine, accounts,
- topiaContext);
+ result += importFinancialsStatementChartCSV(nextLine,
+ financialStatements, topiaContext);
+ break;
+ }
}
}
- // create accounts
- result += createAccounts(accounts, topiaContext);
+ //create entity
+ switch (importExportEntityEnum) {
+ case ACCOUNT:
+ result += createAccounts(accounts, topiaContext);
+ break;
+ case FINANCIALSTATEMENT:
+ result += createFinancialStatements(financialStatements,
+ topiaContext);
+ break;
+ }
+
} catch (TopiaException eeeTE) {
doCatch(topiaContext, eeeTE, log);
} catch (IOException eeeIO) {
@@ -614,6 +602,7 @@
}
return result;
}
+
// ################ Import entities an put to lists ################
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -97,9 +97,10 @@
* Recursiv
* List entries for a period and an account
* Calculate the amounts
- * Two case:
+ * 3 cases:
* - for subaccount
* - for a foldaccounts, contains many accounts
+ * - for a foldthirdparts accounts
*/
@Override
public ReportsDatas generateAccountReportsWithTransaction (Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException{
@@ -107,18 +108,28 @@
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
BigDecimal solde = new BigDecimal(0);
+ List<Entry> entries = new ArrayList<Entry>();
if (account != null){
- // First subaccount
+
+ //Get allsubaccounts and thirdParts accounts
List<Account> accounts = (List<Account>) account.getSubAccounts();
- accounts.addAll(account.getSubLedgers());
+ List<Account> thirdPartAccount = (List<Account>) account.getSubLedgers();
+ if (thirdPartAccount != null){
+ ReportsDatas subReportsDatas = generateSubAccountReportsWithTransaction(account,
+ beginDate, endDate, topiaContext);
+ entries.addAll(subReportsDatas.getListEntry());
+ debit = debit.add(subReportsDatas.getAmountDebit());
+ credit = credit.add(subReportsDatas.getAmountCredit());
+ accounts.addAll(thirdPartAccount);
+ }
+ // is already subaccount
if (accounts.size() == 0){
reportsDatas = generateSubAccountReportsWithTransaction(account,
beginDate, endDate, topiaContext);
}
- //Second many account
+ // else is folder accounts contains many subs and thirds accoutns
else {
- List<Entry> entries = new ArrayList<Entry>();
- for (Account subAccount : accounts) {
+ for (Account subAccount : accounts) {
ReportsDatas subReportsDatas =
generateAccountReportsWithTransaction(subAccount,
beginDate,endDate, topiaContext);
@@ -462,7 +473,7 @@
selectedAccounts = StringUtils.deleteWhitespace(selectedAccounts);
//if no filter account
if (selectedAccounts == null || selectedAccounts.equals("")){
- accounts = accountDAO.findAllSubAccounts();
+ accounts = accountDAO.findAll();
}
//build list account from selectedAccounts
else{
@@ -479,7 +490,7 @@
amount = new BigDecimal(0);
}
if (movementedFilter){
- if (amount.doubleValue() != 0){
+ if (reportsDatas.getAmountCredit().doubleValue() != 0 || reportsDatas.getAmountDebit().doubleValue() != 0){
// add balance sheet to balance trial
balanceTrial.addReportsDatas(reportsDatas);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ImportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ImportService.java 2010-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ImportService.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -21,6 +21,7 @@
import javax.ejb.Remote;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.ImportExportEntityEnum;
/**
* Import export service.
@@ -68,9 +69,5 @@
*/
public String importAllAsCSV(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;
+ public String importAsCSV(String path, ImportExportEntityEnum importExportEntityEnum) throws LimaException;
}
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-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -1,4 +1,4 @@
-/* *##% Lima Swing
+/* *##% Lima Callao
* Copyright (C) 2008 - 2010 CodeLutin
*
* This program is free software; you can redistribute it and/or
@@ -25,25 +25,16 @@
public class AccountDAOImpl <E extends Account> extends AccountDAOAbstract<E> {
/**
- * List all subaccounts (no folderaccounts)
+ * List all subaccounts (no folderaccounts, exclude accounts contains thirdpart accounts)
* Sort by accout number in lexicographical order
*/
@Override
public List<Account> findAllSubAccounts() throws TopiaException {
TopiaQuery query = createQuery();
String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS);
- String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS);
query.addWhere("not exists elements ("+subAccountsProperty+")")
- .addWhere("not exists elements ("+subLedgersProperty+")")
.addOrder(Account.ACCOUNT_NUMBER);
- /* alternative query
- * wich are the best ? exist or count ?
- *
- * query.addWhere("size ("+subAccountsProperty+") = 0")
- * .addWhere("size ("+subLedgersProperty+") = 0");
- *
- */
return (List<Account>) findAllByQuery(query);
}
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-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -269,23 +269,33 @@
//
form.setLocationRelativeTo(view);
form.setVisible(true);
+
+ ImportExport importExport = ImportExport.getInstance(view);
Object value = form.getRadioButtons().getSelectedValue();
// if action confirmed
if (value != null){
-
AccountsChartEnum defaultAccountsChartEnum =
(AccountsChartEnum) value;
- ImportExport importExport = ImportExport.getInstance(view);
- importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT,
- defaultAccountsChartEnum.getFilePath(), true);
+ //Import accounts chart
+ switch (defaultAccountsChartEnum) {
+ case IMPORTEBP:
+ importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT,
+ defaultAccountsChartEnum.getFilePath(), false);
+ break;
+
+ default:
+ importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT,
+ defaultAccountsChartEnum.getFilePath(), false);
+ break;
+ }
}
}
@Override
- public void notifyMethod(String serviceName, String methodName) {
+ public void notifyMethod(String serviceName, String methodeName) {
- if (methodName.contains("importAccounts") || methodName.contains("importAll")){
+ if (methodeName.contains("importAccounts") || methodeName.contains("importAll") || methodeName.contains("importAsCSV")){
refresh();
}
}
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-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -173,10 +173,10 @@
}
@Override
- public void notifyMethod(String serviceName, String methodName) {
+ public void notifyMethod(String serviceName, String methodeName) {
//refresh on import datas
- if (methodName.contains("importEntryBooks") || methodName.contains("importAll")){
+ if (methodeName.contains("importEntryBooks") || methodeName.contains("importAll") || methodeName.contains("importAs")){
fireTableDataChanged();
}
}
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-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -317,7 +317,7 @@
@Override
public void notifyMethod(String serviceName, String methodName) {
- if (methodName.contains("importFinancialStatements") || methodName.contains("importAll")){
+ if (methodName.contains("importFinancialStatements") || methodName.contains("importAll") || methodName.contains("importAs")){
refresh();
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -343,6 +343,8 @@
public void addFinancialTransaction() throws LimaException{
/* Calling transaction service */
FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ financialTransaction.setAmountDebit(new BigDecimal(0));
+ financialTransaction.setAmountCredit(new BigDecimal(0));
//if a period is selected
if (selectedFinancialPeriod != null){
financialTransaction.setFinancialPeriod(selectedFinancialPeriod);
@@ -392,6 +394,7 @@
FinancialTransaction currentTransaction = null;
Object currentRow = cacheDataList.get(row);
Entry entry = new EntryImpl();
+ entry.setAmount(new BigDecimal(0));
//check if current row is a transaction or an entry
if (currentRow instanceof FinancialTransaction) {
currentTransaction = (FinancialTransaction)currentRow;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2010-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -114,7 +114,7 @@
@Override
public void notifyMethod(String serviceName, String methodeName) {
- if (methodeName.contains("Account") || methodeName.contains("importAll")){
+ if (methodeName.contains("Account") || methodeName.contains("importAll") || methodeName.contains("importAsCSV")){
refresh();
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2010-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -131,7 +131,7 @@
@Override
public void notifyMethod(String serviceName, String methodeName) {
- if (methodeName.contains("EntryBook") || methodeName.contains("importAll")){
+ if (methodeName.contains("EntryBook") || methodeName.contains("importAll") || methodeName.contains("importAs")){
refresh();
}
}
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-08-12 13:51:19 UTC (rev 3000)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-08-13 10:43:53 UTC (rev 3001)
@@ -43,6 +43,7 @@
import org.chorem.lima.business.ExportServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.ImportExportEntityEnum;
import org.chorem.lima.enums.EncodingEnum;
import org.chorem.lima.enums.ImportExportEnum;
import org.chorem.lima.service.LimaServiceFactory;
@@ -138,15 +139,15 @@
break;
case CSV_ACCOUNTCHARTS_IMPORT:
datas = extractFile(filePath, charset.getEncoding());
- result = importService.importAccountsChartAsCSV(datas);
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.ACCOUNT);
break;
case CSV_ENTRYBOOKS_IMPORT:
datas = extractFile(filePath, charset.getEncoding());
- result = importService.importEntryBooksChartAsCSV(datas);
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.ENTRYBOOK);
break;
case CSV_FINANCIALSTATEMENTS_IMPORT:
datas = extractFile(filePath, charset.getEncoding());
- result = importService.importFinancialStatementsChartAsCSV(datas);
+ result = importService.importAsCSV(datas, ImportExportEntityEnum.FINANCIALSTATEMENT);
break;
case EBP_ACCOUNTCHARTS_IMPORT:
//For windows ebp
1
0
Author: jpepin
Date: 2010-08-12 15:51:19 +0200 (Thu, 12 Aug 2010)
New Revision: 3000
Url: http://chorem.org/repositories/revision/lima/3000
Log:
Ajout d'une fonction pour v?\195?\169rifier la concordance entre le plan BCR et le plan des comptes.
Refactor du type Double vers BigDecimal.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryEBPComparator.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.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/FinancialStatementServiceImpl.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/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountServiceLocal.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -38,7 +38,6 @@
import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
-import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
@@ -440,9 +439,10 @@
/**
* Convert string of extends number to list of accounts
* Example '22, 45..48, 67' -> [22, 45, 46, 47, 48, 67]
+ * SubAccountsMode return list of existing subaccounts ex 6 return : 61, 62, .., 69, 610, .., 619 etc
*/
@Override
- public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, TopiaContext topiaContext) throws LimaException{
+ public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, Boolean subAccountsMode, TopiaContext topiaContext) throws LimaException{
List<Account> accounts = new ArrayList<Account>();
if (selectedAccounts != null){
try {
@@ -452,45 +452,96 @@
selectedAccounts = StringUtils.deleteWhitespace(selectedAccounts);
//use hashset for delete duplicate numbers
HashSet<String> accountNumbers = new HashSet<String>();
- //Split comma
- StringTokenizer stComma = new StringTokenizer(selectedAccounts, ",");
- while (stComma.hasMoreTokens()) {
- String s = stComma.nextToken();
- if (s.contains("..")){
- //Split ..
- String stringDoubleDot[] = s.split("\\.\\.");
- int lowAccount=Integer.parseInt(stringDoubleDot[0]);
- int highAccount=Integer.parseInt(stringDoubleDot[1]);
- for (int i=lowAccount; i <= highAccount; i++) {
- accountNumbers.add(String.valueOf(i));
- }
- }
- else{
- accountNumbers.add(s);
- }
- }
-
+ HashSet<String> accountNumbersToRemove = new HashSet<String>();
+ Boolean first = true;
+ StringTokenizer stStar = new StringTokenizer(selectedAccounts, "-");
+ while (stStar.hasMoreTokens()) {
+ String subString = stStar.nextToken();
+
+ //Split comma
+ StringTokenizer stComma = new StringTokenizer(subString, ",");
+ while (stComma.hasMoreTokens()) {
+ String s = stComma.nextToken();
+ if (s.contains("..")){
+ //Split ..
+ String stringDoubleDot[] = s.split("\\.\\.");
+ int lowAccount=Integer.parseInt(stringDoubleDot[0]);
+ int highAccount=Integer.parseInt(stringDoubleDot[1]);
+ for (int i=lowAccount; i <= highAccount; i++) {
+ //if first add accounts, else remove
+ if (first){
+ accountNumbers.add(String.valueOf(i));
+ }
+ else {
+ accountNumbersToRemove.add(String.valueOf(i));
+ }
+ }
+ }
+ else{
+ //if first
+ if (first){
+ accountNumbers.add(s);
+ }
+ else {
+ accountNumbersToRemove.add(s);
+ }
+ }
+ }
+ first=false;
+ }
+ //add all accounts
+ log.debug("accountNumbers "+accountNumbers);
for (String accountNumber : accountNumbers) {
- Account account = accountDAO.findByAccountNumber(accountNumber);
- if (account == null){
- TopiaQuery query = accountDAO.createQuery();
- query.addWhere(Account.ACCOUNT_NUMBER, Op.LIKE, accountNumber+"%");
- List<Account> accountsResult = accountDAO.findAllByQuery(query);
- if (accountsResult != null){
- accounts.addAll(accountsResult);
+ if (subAccountsMode){
+ Account account = accountDAO.findSubAccountByNumber(accountNumber);
+ if (account == null){
+ TopiaQuery query = accountDAO.createQuery();
+ String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS);
+ String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS);
+ query.addWhere("not exists elements ("+subAccountsProperty+")")
+ .addWhere("not exists elements ("+subLedgersProperty+")")
+ .addWhere(Account.ACCOUNT_NUMBER, Op.LIKE, accountNumber+"%");
+ List<Account> accountsResult = accountDAO.findAllByQuery(query);
+ if (accountsResult != null){
+ accounts.addAll(accountsResult);
+ }
}
+ //add account if exist
+ else {
+ accounts.add(account);
+ }
}
- //add account if exist
else {
- accounts.add(account);
+ Account account = accountDAO.findByAccountNumber(accountNumber);
+ if (account != null){
+ accounts.add(account);
+ }
}
+
}
+ //remove all accounts
+ log.debug("accountNumbersToRemove "+accountNumbersToRemove);
+ for (String accountNumber : accountNumbersToRemove) {
+ Account account = null;
+ if (subAccountsMode){
+ account = accountDAO.findSubAccountByNumber(accountNumber);
+ }
+ else {
+ account = accountDAO.findByAccountNumber(accountNumber);
+ }
+ if (account != null) {
+ accounts.remove(account);
+ }
+ }
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
}
}
-
+ for (Account account : accounts) {
+ log.debug("accounts " + account.getAccountNumber());
+ }
+
return accounts;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -24,6 +24,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
@@ -377,10 +378,16 @@
String label = financialStatementAmount.getLabel();
int level = financialStatementAmount.getLevel();
- Double grossAmount =
+ BigDecimal grossAmount =
financialStatementAmount.getGrossAmount();
- Double provisionDeprecationAmount =
+ if (grossAmount == null){
+ grossAmount = new BigDecimal(0);
+ }
+ BigDecimal provisionDeprecationAmount =
financialStatementAmount.getProvisionDeprecationAmount();
+ if (provisionDeprecationAmount == null){
+ provisionDeprecationAmount = new BigDecimal(0);
+ }
if (financialStatementAmount.getSubAmount() && level==1){
cell.setGrayFill(0.88f);
@@ -414,7 +421,7 @@
c.setHorizontalAlignment(Element.ALIGN_LEFT);
t.addCell(c);
//cell2
- if (grossAmount != 0.0){
+ if (grossAmount.doubleValue() != 0){
phrase = new Phrase(String.valueOf(
grossAmount), normalFont);
}
@@ -423,7 +430,7 @@
}
t.addCell(phrase);
//cell 3
- if (provisionDeprecationAmount != 0.0){
+ if (provisionDeprecationAmount.doubleValue() != 0){
phrase = new Phrase(String.valueOf(
provisionDeprecationAmount), normalFont);
}
@@ -432,9 +439,10 @@
}
t.addCell(phrase);
//cell 4
- if (grossAmount-provisionDeprecationAmount != 0.0){
- phrase = new Phrase(String.valueOf(
- grossAmount-provisionDeprecationAmount), normalFont);
+ BigDecimal solde = grossAmount;
+ solde = solde.subtract(provisionDeprecationAmount);
+ if (solde.doubleValue() != 0){
+ phrase = new Phrase(solde.toString(), normalFont);
}
else {
phrase = new Phrase("");
@@ -476,8 +484,8 @@
String dateS = dateFormat.format(newDate);
String hourS = hourFormat.format(newDate);
- Double currentAmountDebit = 0.0;
- Double currentAmountCredit = 0.0;
+ BigDecimal currentAmountDebit = new BigDecimal(0);
+ BigDecimal currentAmountCredit = new BigDecimal(0);
String accountcarry ="";
String filePath = path+File.separator+DocumentsEnum.LEDGER.getFileName();
@@ -537,8 +545,12 @@
for (Object object : subList) {
if (object instanceof Entry){
Entry entry = (Entry) object;
- currentAmountDebit += entry.getDebit() ? entry.getAmount() : 0;
- currentAmountCredit += entry.getDebit() ? 0 : entry.getAmount();
+ if (entry.getDebit()){
+ currentAmountDebit = currentAmountDebit.add(entry.getAmount());
+ }
+ else {
+ currentAmountCredit = currentAmountCredit.add(entry.getAmount());
+ }
}
else {
ReportsDatas reportsDatas = (ReportsDatas) object;
@@ -636,8 +648,8 @@
if (account != null){
accountS = account.getAccountNumber()+"\t"+account.getLabel();
}
- Double amountCredit = reportsDatas.getAmountCredit();
- Double amountDebit = reportsDatas.getAmountDebit();
+ BigDecimal amountCredit = reportsDatas.getAmountCredit();
+ BigDecimal amountDebit = reportsDatas.getAmountDebit();
Cell c = new Cell(new Phrase(accountS, boldFont));
c.setColspan(4);
@@ -645,7 +657,9 @@
t.addCell(c);
t.addCell(new Phrase(String.valueOf(amountDebit), boldFont));
t.addCell(new Phrase(String.valueOf(amountCredit), boldFont));
- t.addCell(new Phrase(String.valueOf(amountDebit-amountCredit), boldFont));
+ BigDecimal solde = amountDebit;
+ solde = solde.subtract(amountCredit);
+ t.addCell(new Phrase(String.valueOf(solde), boldFont));
}
else {
Entry entry = (Entry) object;
@@ -655,21 +669,27 @@
if (entryBook != null){
entryBookCode = entryBook.getCode();
}
+ BigDecimal amountDebit = new BigDecimal(0),
+ amountCredit = new BigDecimal(0);
+ if (entry.getDebit()){
+ amountDebit = entry.getAmount();
+ }
+ else {
+ amountCredit = entry.getAmount();
+ }
- Double amountDebit = entry.getDebit() ? entry.getAmount() : 0;
- Double amountCredit = entry.getDebit() ? 0 : entry.getAmount();
-
t.addCell(new Phrase(dateFormat.format(
entry.getFinancialTransaction().getTransactionDate()),
normalFont));
t.addCell(new Phrase(entryBookCode, normalFont));
t.addCell(new Phrase(entry.getVoucher(), normalFont));
t.addCell(new Phrase(entry.getDescription(), normalFont));
- t.addCell(new Phrase(String.valueOf(amountDebit),
+ t.addCell(new Phrase(amountDebit.toString(),
normalFont));
- t.addCell(new Phrase(String.valueOf(amountCredit),
+ t.addCell(new Phrase(amountCredit.toString(),
normalFont));
- t.addCell(new Phrase(String.valueOf(amountDebit-amountCredit),
+ BigDecimal solde = amountDebit.subtract(amountCredit);
+ t.addCell(new Phrase(solde.toString(),
normalFont));
}
@@ -681,7 +701,7 @@
return t;
}
- public Table createLedgerAmountTable(String account, String title, Double credit, Double debit){
+ public Table createLedgerAmountTable(String account, String title, BigDecimal debit, BigDecimal credit){
Table t = null;
try {
t = new Table(5,1);
@@ -695,7 +715,6 @@
cell.setBorder(Rectangle.RIGHT);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
t.setDefaultCell(cell);
-
Cell accountCell = new Cell(new Phrase(account, boldFont));
accountCell.setHorizontalAlignment(Element.ALIGN_LEFT);
accountCell.setBorder(Rectangle.NO_BORDER);
@@ -703,7 +722,7 @@
t.addCell(new Phrase(title, boldFont));
t.addCell(new Phrase(debit.toString(), boldFont));
t.addCell(new Phrase(credit.toString(), boldFont));
- Double solde = debit-credit;
+ BigDecimal solde = debit.subtract(credit);
t.addCell(new Phrase(solde.toString(), boldFont));
} catch (BadElementException eeBEE) {
log.error("Can't create table", eeBEE);
@@ -765,22 +784,22 @@
List<Entry> entries = entryDAO.findAllByQuery(query);
List<Object[]> results = new ArrayList<Object[]>();
- Double debit = 0.0;
- Double credit = 0.0;
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal credit = new BigDecimal(0);
query.setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")");
query.addGroup(Entry.DEBIT);
results = query.execute(transaction);
int nbAmount = results.size();
if(nbAmount==2){
- debit = (Double)results.get(0)[1];
- credit = (Double)results.get(1)[1];
+ debit = (BigDecimal)results.get(0)[1];
+ credit = (BigDecimal)results.get(1)[1];
}
if (nbAmount==1){
if ((Boolean)results.get(0)[0]){
- debit = (Double)results.get(0)[1];
+ debit = (BigDecimal)results.get(0)[1];
}
else {
- credit = (Double)results.get(0)[1];
+ credit = (BigDecimal)results.get(0)[1];
}
}
@@ -913,7 +932,7 @@
return t;
}
- public Table createEntryBooksAmountTable(String title, Double credit, Double debit){
+ public Table createEntryBooksAmountTable(String title, BigDecimal credit, BigDecimal debit){
Table t = null;
try {
t = new Table(3,1);
@@ -954,10 +973,10 @@
String hourS = hourFormat.format(newDate);
String fileDateS = filedateFormat.format(newDate);
- Double currentAmountDebit = 0.0;
- Double currentAmountCredit = 0.0;
- Double currentSoldeDebit = 0.0;
- Double currentSoldeCredit = 0.0;
+ BigDecimal currentAmountDebit = new BigDecimal(0);
+ BigDecimal currentAmountCredit = new BigDecimal(0);
+ BigDecimal currentSoldeDebit = new BigDecimal(0);
+ BigDecimal currentSoldeCredit = new BigDecimal(0);
String filePath = path+File.separator+DocumentsEnum.BALANCE.getFileName();
FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension());
@@ -1014,12 +1033,14 @@
paragraphTable.add(table);
chapter.add(paragraphTable);
for (ReportsDatas reportsDatas : subList){
- currentAmountDebit += reportsDatas.getAmountDebit();
- currentAmountCredit += reportsDatas.getAmountCredit();
- currentSoldeDebit +=
- reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0;
- currentSoldeCredit +=
- reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde();
+ currentAmountDebit = currentAmountDebit.add(reportsDatas.getAmountDebit());
+ currentAmountCredit = currentAmountCredit.add(reportsDatas.getAmountCredit());
+ if (reportsDatas.getSoldeDebit()){
+ currentSoldeDebit = currentSoldeDebit.add(reportsDatas.getAmountSolde());
+ }
+ else {
+ currentSoldeCredit = currentSoldeCredit.add(reportsDatas.getAmountSolde());
+ }
}
//forward amounts
if (n > max && i <= n-max){
@@ -1118,7 +1139,7 @@
return t;
}
- public Table createBalanceAmountTable(String title, Double amountDebit, Double amountCredit, Double soldeDebit, Double soldeCredit ){
+ public Table createBalanceAmountTable(String title, BigDecimal amountDebit, BigDecimal amountCredit, BigDecimal soldeDebit, BigDecimal soldeCredit){
Table t = null;
try {
t = new Table(5,1);
@@ -1191,21 +1212,21 @@
financialPeriodDAO.findAllByQuery(financialPeriodsQuery);
List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>();
- Double amountDebit = 0.0;
- Double amountCredit = 0.0;
+ BigDecimal amountDebit = new BigDecimal(0);
+ BigDecimal amountCredit = new BigDecimal(0);
for (FinancialPeriod financialPeriod : financialPeriods) {
List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
closedPeriodicEntryBookDAO.findAllByDates(
financialPeriod.getBeginDate(), financialPeriod.getEndDate());
- Double subAmountDebit = 0.0;
- Double subAmountCredit = 0.0;
+ BigDecimal subAmountDebit = new BigDecimal(0);
+ BigDecimal subAmountCredit = new BigDecimal(0);
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
List<Object[]> results = new ArrayList<Object[]>();
TopiaQuery query = entryDAO.createQuery();
- Double debit = 0.0;
- Double credit = 0.0;
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal credit = new BigDecimal(0);
String financialPeriodProperty = TopiaQuery.getProperty(
Entry.FINANCIAL_TRANSACTION,
@@ -1223,15 +1244,15 @@
int nbAmount = results.size();
if(nbAmount == 2){
- debit = (Double)results.get(0)[1];
- credit = (Double)results.get(1)[1];
+ debit = (BigDecimal)results.get(0)[1];
+ credit = (BigDecimal)results.get(1)[1];
}
if (nbAmount == 1){
if ((Boolean)results.get(0)[0]){
- debit = (Double)results.get(0)[1];
+ debit = (BigDecimal)results.get(0)[1];
}
else {
- credit = (Double)results.get(0)[1];
+ credit = (BigDecimal)results.get(0)[1];
}
}
GeneralEntryBooksDatas generalEntryBooksDatas =
@@ -1245,8 +1266,8 @@
generalEntryBooksDatas.setCredit(credit);
generalEntryBooksDatas.setDebit(debit);
list.add(generalEntryBooksDatas);
- subAmountCredit += credit;
- subAmountDebit += debit;
+ subAmountCredit = subAmountCredit.add(credit);
+ subAmountDebit = subAmountDebit.add(debit);
}
GeneralEntryBooksDatas generalEntryBooksDatas =
new GeneralEntryBooksDatasImpl();
@@ -1256,8 +1277,8 @@
generalEntryBooksDatas.setPeriod(
monthYearFormat.format(financialPeriod.getBeginDate()));
list.add(generalEntryBooksDatas);
- amountCredit += subAmountCredit;
- amountDebit += subAmountDebit;
+ amountCredit = amountCredit.add(subAmountCredit);
+ amountDebit = amountDebit.add(subAmountDebit);
}
GeneralEntryBooksDatas generalEntryBooksDatas =
new GeneralEntryBooksDatasImpl();
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.StringWriter;
+import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.List;
import javax.ejb.Stateless;
@@ -140,7 +141,7 @@
nextLine[3] = accountNumber;
nextLine[5] = '"'+entry.getDescription()+'"';
nextLine[6] = '"'+entry.getVoucher()+'"';
- nextLine[7] = new Double(entry.getAmount()).toString();
+ nextLine[7] = entry.getAmount().toString();
nextLine[8] = debitcredit;
// Ajoute la ligne au fichier
@@ -492,10 +493,8 @@
nextLine[1] = String.valueOf(numTransaction);
nextLine[2] =
SDateFormat.format(financialTransaction.getTransactionDate());
- nextLine[3] = new Double(
- financialTransaction.getAmountDebit()).toString();
- nextLine[4] = new Double(
- financialTransaction.getAmountCredit()).toString();
+ nextLine[3] = financialTransaction.getAmountDebit().toString();
+ nextLine[4] = financialTransaction.getAmountCredit().toString();
nextLine[5] =
SDateFormat.format(financialTransaction.getFinancialPeriod().
getBeginDate());
@@ -514,7 +513,7 @@
nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel();
nextLine[1] = String.valueOf(numTransaction);
nextLine[2] = entry.getDescription();
- nextLine[3] = new Double(entry.getAmount()).toString();
+ nextLine[3] = entry.getAmount().toString();
nextLine[4] = new Boolean(entry.getDebit()).toString();
nextLine[5] = entry.getLettering();
nextLine[6] = entry.getDetail();
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -20,6 +20,8 @@
package org.chorem.lima.business.ejb;
import static org.nuiton.i18n.I18n._;
+
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -308,7 +310,7 @@
List<FinancialStatement> financialStatements =
getChildrenFinancialStatement(financialStatement);
try {
- Double grossAmount = 0.0, provisionDeprecationAmount = 0.0;
+ BigDecimal grossAmount = new BigDecimal(0), provisionDeprecationAmount = new BigDecimal(0);
List<FinancialStatementAmounts> subResult =
new ArrayList<FinancialStatementAmounts>();
for (FinancialStatement subFinancialStatement : financialStatements) {
@@ -317,19 +319,20 @@
selectedBeginDate, selectedEndDate, topiaContext);
if (!subFinancialStatement.getHeader()){
//on calcul
- grossAmount += financialStatementAmounts.getGrossAmount();
- provisionDeprecationAmount +=
- financialStatementAmounts.getProvisionDeprecationAmount();
+ grossAmount = grossAmount.add(financialStatementAmounts.getGrossAmount());
+ provisionDeprecationAmount = provisionDeprecationAmount.add(
+ financialStatementAmounts.getProvisionDeprecationAmount());
subResult.add(financialStatementAmounts);
}
else {
FinancialStatementDatas financialStatementDatas =
financialStatementReport(subFinancialStatement,
selectedBeginDate, selectedEndDate, result, topiaContext);
- grossAmount += financialStatementDatas.
- getFinancialStatementAmounts().getGrossAmount();
- provisionDeprecationAmount += financialStatementDatas.
- getFinancialStatementAmounts().getProvisionDeprecationAmount();
+ grossAmount = grossAmount.add(financialStatementDatas.
+ getFinancialStatementAmounts().getGrossAmount());
+ provisionDeprecationAmount = provisionDeprecationAmount.
+ add(financialStatementDatas.getFinancialStatementAmounts().
+ getProvisionDeprecationAmount());
FinancialStatementAmounts headerfinancialStatementAmounts =
@@ -371,8 +374,8 @@
subResult.add(headerfinancialStatementAmounts);
}
else {
- headerfinancialStatementAmounts.setGrossAmount(0);
- headerfinancialStatementAmounts.setProvisionDeprecationAmount(0);
+ headerfinancialStatementAmounts.setGrossAmount(new BigDecimal(0));
+ headerfinancialStatementAmounts.setProvisionDeprecationAmount(new BigDecimal(0));
subResult.add(headerfinancialStatementAmounts);
}
//ajoute liste
@@ -411,8 +414,7 @@
try {
// DEBIT & CREDIT
String accountsString = financialStatement.getAccounts();
- log.debug("\n" + accountsString);
- Double amount = 0.0;
+ BigDecimal amount = new BigDecimal(0);
if (accountsString != null){
//Remove Spaces
accountsString = StringUtils.deleteWhitespace(accountsString);
@@ -420,8 +422,8 @@
while (stQuote.hasMoreTokens()) {
String s = stQuote.nextToken();
List<Account> accountsList = accountServiceLocal.
- stringToListAccountsWithTransaction(s, topiaContext);
- Double resAmount = 0.0;
+ stringToListAccountsWithTransaction(s, false, topiaContext);
+ BigDecimal resAmount = new BigDecimal(0);
for (Account account : accountsList) {
log.debug(account.getAccountNumber());
@@ -434,51 +436,53 @@
financialStatement.getMasterFinancialStatement().getWay();
switch (financialStatementWayEnum) {
case BOTH:
- resAmount += reportsDatas.getAmountSolde();
+ resAmount = resAmount.add(reportsDatas.getAmountSolde());
break;
case DEBIT:
- resAmount += reportsDatas.getAmountDebit()-reportsDatas.getAmountCredit();
+ resAmount = resAmount.add(reportsDatas.getAmountDebit());
+ resAmount = resAmount.subtract(reportsDatas.getAmountCredit());
break;
case CREDIT:
- resAmount += reportsDatas.getAmountCredit()-reportsDatas.getAmountDebit();
+ resAmount = resAmount.add(reportsDatas.getAmountCredit());
+ resAmount = resAmount.subtract(reportsDatas.getAmountDebit());
break;
}
}
- if (amount == 0){
- amount=resAmount;
+ if (amount.doubleValue() == 0){
+ amount = resAmount;
}
else {
- amount-=resAmount;
+ amount = amount.subtract(resAmount);
}
}
}
// CREDIT
String creditAccountsString = financialStatement.getCreditAccounts();
- Double creditAmount = 0.0;
+ BigDecimal creditAmount = new BigDecimal(0);
if (creditAccountsString != null){
List<Account> creditAccountsList = accountServiceLocal.
- stringToListAccountsWithTransaction(creditAccountsString, topiaContext);
+ stringToListAccountsWithTransaction(creditAccountsString, false, topiaContext);
for (Account account : creditAccountsList) {
ReportsDatas reportsDatas = reportServiceLocal.
generateAccountReportsWithTransaction(account,
selectedBeginDate, selectedEndDate, topiaContext);
- creditAmount += reportsDatas.getAmountCredit();
+ creditAmount = creditAmount.add(reportsDatas.getAmountCredit());
}
}
// DEBIT
String debitAccountsString = financialStatement.getDebitAccounts();
- Double debitAmount = 0.0;
+ BigDecimal debitAmount = new BigDecimal(0);
if (debitAccountsString != null){
List<Account> debitAccountsList = accountServiceLocal.
- stringToListAccountsWithTransaction(debitAccountsString, topiaContext);
+ stringToListAccountsWithTransaction(debitAccountsString, false, topiaContext);
for (Account account : debitAccountsList) {
ReportsDatas reportsDatas = reportServiceLocal.
generateAccountReportsWithTransaction(account,
selectedBeginDate, selectedEndDate, topiaContext);
- debitAmount += reportsDatas.getAmountDebit();
+ debitAmount = debitAmount.add(reportsDatas.getAmountDebit());
}
}
@@ -486,22 +490,23 @@
// PROVISION & DEPRECATION
String provisionDeprecationAccountsString =
financialStatement.getProvisionDeprecationAccounts();
- Double provisionDeprecationAmount = 0.0;
+ BigDecimal provisionDeprecationAmount = new BigDecimal(0);
if (provisionDeprecationAccountsString != null){
List<Account> provisionDeprecationAccountsList =
accountServiceLocal.stringToListAccountsWithTransaction(
- provisionDeprecationAccountsString, topiaContext);
+ provisionDeprecationAccountsString, false, topiaContext);
for (Account account : provisionDeprecationAccountsList) {
ReportsDatas reportsDatas = reportServiceLocal.
generateAccountReportsWithTransaction(account,
selectedBeginDate, selectedEndDate, topiaContext);
- provisionDeprecationAmount += reportsDatas.getAmountSolde();
+ provisionDeprecationAmount = provisionDeprecationAmount.add(reportsDatas.getAmountSolde());
}
}
// set result
- financialStatementAmounts.setGrossAmount(
- amount+creditAmount+debitAmount);
+ amount = amount.add(creditAmount);
+ amount = amount.add(debitAmount);
+ financialStatementAmounts.setGrossAmount(amount);
financialStatementAmounts.setLabel(financialStatement.getLabel());
financialStatementAmounts.setProvisionDeprecationAmount(
provisionDeprecationAmount);
@@ -520,36 +525,43 @@
@Override
public String checkFinancialStatementChart() throws LimaException {
- String result = "";
- List<Account> accountsList = new ArrayList<Account>();
-
+ String result ="";
TopiaContext transaction = null;
try {
transaction = beginTransaction();
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(transaction);
- accountsList = accountDAO.findAllSubAccounts();
- Collections.sort(accountsList, new AccountComparator());
-
+ List<Account> accountsList = accountDAO.findAllSubAccounts();
+
+ List<FinancialStatement> financialStatementsList =
+ financialStatementDAO.findAll();
+
+
+ for (FinancialStatement financialStatement : financialStatementsList) {
+
+ accountsList.removeAll(
+ accountServiceLocal.stringToListAccountsWithTransaction(
+ financialStatement.getAccounts(), true, transaction));
+
+ accountsList.removeAll(
+ accountServiceLocal.stringToListAccountsWithTransaction(
+ financialStatement.getCreditAccounts(), true, transaction));
+
+ accountsList.removeAll(
+ accountServiceLocal.stringToListAccountsWithTransaction(
+ financialStatement.getDebitAccounts(), true, transaction));
+
+ accountsList.removeAll(
+ accountServiceLocal.stringToListAccountsWithTransaction(
+ financialStatement.getProvisionDeprecationAccounts(), true, transaction));
+ }
+
for (Account account : accountsList) {
- Boolean find = false;
- String accountNumber = account.getAccountNumber();
- if (accountNumber.length()>1){
- while (!find && accountNumber.length() > 1){
- log.debug(accountNumber);
- List<FinancialStatement> financialStatements =
- findFinancialStatementByAccountNumber(accountNumber, transaction);
- log.debug(financialStatements);
- if (!(find = financialStatements.size() > 0)){
- accountNumber = accountNumber.substring(0, accountNumber.length()-1);
- }
- }
-
- if (!find){
- result += "NOT FOUND : "+account.getAccountNumber()+"\n";
- }
- }
+
+ result += "NOT FOUND : "+account.getAccountNumber()+"\n";
}
}
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -20,6 +20,8 @@
package org.chorem.lima.business.ejb;
import static org.nuiton.i18n.I18n._;
+
+import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
@@ -80,6 +82,7 @@
public void createFinancialTransactionWithTransaction(
FinancialTransaction financialtransaction, TopiaContext topiaContext)
throws LimaException {
+ log.debug(financialtransaction);
try {
//check if the financial period is blocked
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
@@ -439,22 +442,32 @@
accountingRules.updateEntryRules(entry, entryOld, topiaContext);
//get new entry amounts
- Double entryAmount = entry.getAmount();
- Boolean entryAmountBool = entry.getDebit();
- Double entryDebit = entryAmountBool ? entryAmount : 0;
- Double entryCredit = entryAmountBool ? 0 : entryAmount;
+ BigDecimal entryAmount = entry.getAmount();
+ Boolean entryAmountIsDebit = entry.getDebit();
+ BigDecimal entryDebit = new BigDecimal(0), entryCredit = new BigDecimal(0);
+ if (entryAmountIsDebit){
+ entryDebit = entryAmount;
+ }
+ else {
+ entryCredit = entryAmount;
+ }
//get old entry amounts
- Double entryAmountOld = entryOld.getAmount();
- Boolean entryAmountBoolOld = entryOld.getDebit();
- Double entryDebitOld = entryAmountBoolOld ? entryAmountOld : 0;
- Double entryCreditOld = entryAmountBoolOld ? 0 : entryAmountOld;
+ BigDecimal entryAmountOld = entryOld.getAmount();
+ Boolean entryAmountOldIsDebit = entryOld.getDebit();
+ BigDecimal entryDebitOld = new BigDecimal(0), entryCreditOld = new BigDecimal(0);
+ if (entryAmountOldIsDebit){
+ entryDebitOld = entryAmountOld;
+ }
+ else {
+ entryCreditOld = entryAmountOld;
+ }
//FIXME PEPIN 20100520 conflict object already instanciate
// Exist best solution ?
entryOld.setAccount(entry.getAccount());
entryOld.setAmount(entryAmount);
- entryOld.setDebit(entryAmountBool);
+ entryOld.setDebit(entryAmountIsDebit);
entryOld.setDescription(entry.getDescription());
entryOld.setVoucher(entry.getVoucher());
entryOld.setFinancialTransaction(entry.getFinancialTransaction());
@@ -464,13 +477,17 @@
//calculate financial transaction amounts
FinancialTransaction financialTransaction =
entryOld.getFinancialTransaction();
- Double amountDebit = financialTransaction.getAmountDebit();
- Double amountCredit = financialTransaction.getAmountCredit();
- financialTransaction.setAmountDebit(
- amountDebit-entryDebitOld+entryDebit);
- financialTransaction.setAmountCredit(
- amountCredit-entryCreditOld+entryCredit);
+ BigDecimal amountDebit = financialTransaction.getAmountDebit();
+ amountDebit = amountDebit.subtract(entryDebitOld);
+ amountDebit = amountDebit.add(entryDebit);
+ financialTransaction.setAmountDebit(amountDebit);
+
+ BigDecimal amountCredit = financialTransaction.getAmountCredit();
+ amountCredit = amountCredit.subtract(entryCreditOld);
+ amountCredit = amountCredit.add(entryCredit);
+ financialTransaction.setAmountCredit(amountCredit);
+
//update financial transaction
updateFinancialTransactionWithTransaction(
financialTransaction, topiaContext);
@@ -503,18 +520,26 @@
entry.getFinancialTransaction(), topiaContext);
//get entry amounts
- Double entryAmount = entry.getAmount();
- Boolean entryAmountBool = entry.getDebit();
- Double entryDebit = entryAmountBool ? entryAmount : 0;
- Double entryCredit = entryAmountBool ? 0 : entryAmount;
+ BigDecimal entryAmount = entry.getAmount();
+ Boolean entryAmountIsDebit = entry.getDebit();
+ BigDecimal entryDebit = new BigDecimal(0), entryCredit = new BigDecimal(0);
+ if (entryAmountIsDebit){
+ entryDebit = entryAmount;
+ }
+ else {
+ entryCredit = entryAmount;
+ }
//calculate financial transaction amounts
FinancialTransaction financialTransaction =
entry.getFinancialTransaction();
- Double amountDebit = financialTransaction.getAmountDebit();
- Double amountCredit = financialTransaction.getAmountCredit();
- financialTransaction.setAmountDebit(amountDebit-entryDebit);
- financialTransaction.setAmountCredit(amountCredit-entryCredit);
+ BigDecimal amountDebit = financialTransaction.getAmountDebit();
+ amountDebit = amountDebit.subtract(entryDebit);
+ financialTransaction.setAmountDebit(amountDebit);
+
+ BigDecimal amountCredit = financialTransaction.getAmountCredit();
+ amountCredit = amountCredit.subtract(entryCredit);
+ financialTransaction.setAmountCredit(amountCredit);
//update financial transaction
updateFinancialTransactionWithTransaction(
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -21,10 +21,12 @@
import java.io.IOException;
import java.io.StringReader;
+import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@@ -65,6 +67,7 @@
import org.chorem.lima.business.ejbinterface.ImportService;
import org.chorem.lima.business.ejbinterface.ImportServiceLocal;
import org.chorem.lima.business.utils.AccountEBPComparator;
+import org.chorem.lima.business.utils.EntryEBPComparator;
import org.chorem.lima.business.utils.FiscalPeriodComparator;
import org.chorem.lima.business.utils.ImportExportEntityEnum;
import org.chorem.lima.entity.Account;
@@ -188,16 +191,20 @@
CsvToBean<EntryEBPImpl> csv = new CsvToBean<EntryEBPImpl>();
List<EntryEBPImpl> list = csv.parse(strat, csvReader);
+ Collections.sort(list, new EntryEBPComparator());
// DAOs
AccountDAO accountDAO = LimaCallaoDAOHelper
.getAccountDAO(topiaContext);
EntryBookDAO entryBookDAO = LimaCallaoDAOHelper
.getEntryBookDAO(topiaContext);
+ List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ Collections.sort(fiscalPeriods, new FiscalPeriodComparator());
+ int nbFiscalPeriods = fiscalPeriods.size();
FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper
.getFinancialPeriodDAO(topiaContext);
- if (financialPeriodDAO.findAll().size() == 0) {
+ if (nbFiscalPeriods == 0) {
throw new LimaBusinessException(
"Can't import entries, no fiscalperiod is open");
}
@@ -208,18 +215,33 @@
Entry entry = new EntryImpl();
Account account = accountDAO.findByAccountNumber(entryEBP
.getCompte());
+
+ Date date = epbDateFormat.parse(entryEBP.getDatEcr());
+ Date beginDate = fiscalPeriods.get(0).getBeginDate();
+ Date endDate = fiscalPeriods.get(nbFiscalPeriods-1).getEndDate();
+
// 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 {
+ + "Import aborted ! Create all accounts before import entries");
+ }
+
+ else if (date.compareTo(beginDate) < 0 || date.compareTo(endDate) > 0){
+
+ result += "WARNING : " + date + " entries is out of range of" +
+ " opened fiscal periods. "
+ + "Entry was skip !\n";
+ }
+ else {
entry.setAccount(account);
- Double debit = new Double(entryEBP.getDebit());
- Double credit = new Double(entryEBP.getCredit());
- if (debit == 0) {
+ BigDecimal debit = new BigDecimal(entryEBP.getDebit());
+ log.debug(debit);
+ BigDecimal credit = new BigDecimal(entryEBP.getCredit());
+ log.debug(credit);
+ if (debit.doubleValue() == 0) {
entry.setDebit(false);
entry.setAmount(credit);
} else {
@@ -229,7 +251,6 @@
entry.setDescription(entryEBP.getLibelle());
entry.setLettering(entryEBP.getLettre());
entry.setVoucher(entryEBP.getPiece());
- Date date = epbDateFormat.parse(entryEBP.getDatEcr());
String entryBookCode = entryEBP.getJournal();
EntryBook entryBook = entryBookDAO
.findByCode(entryBookCode);
@@ -245,11 +266,9 @@
}
if (financialTransaction == null
- || !(date.equals(financialTransaction
- .getTransactionDate()) && entryBook
- .getCode().equals(
- financialTransaction.getEntryBook()
- .getCode()))) {
+ || !(date.equals(financialTransaction.getTransactionDate())
+ && entryBook.getCode().equals(financialTransaction.getEntryBook().getCode()))) {
+
// update previous financial transaction before create
// new
if (financialTransaction != null) {
@@ -1085,9 +1104,9 @@
.parse(financialTransactionImport.getDate());
financialTransaction
.setTransactionDate(dateFinancialTransaction);
- financialTransaction.setAmountDebit(new Double(
+ financialTransaction.setAmountDebit(new BigDecimal(
financialTransactionImport.getAmountDebit()));
- financialTransaction.setAmountCredit(new Double(
+ financialTransaction.setAmountCredit(new BigDecimal(
financialTransactionImport.getAmountCredit()));
EntryBook entryBook = entryBookDAO
.findByCode(financialTransactionImport
@@ -1107,7 +1126,7 @@
.findByAccountNumber(entryImport.getAccount());
entry.setAccount(account);
entry.setDescription(entryImport.getDescription());
- entry.setAmount(new Double(entryImport.getAmount()));
+ entry.setAmount(new BigDecimal(entryImport.getAmount()));
entry.setDebit(new Boolean(entryImport.getDebit()));
entry.setLettering(entryImport.getLettering());
entry.setDetail(entryImport.getDetail());
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -19,6 +19,7 @@
package org.chorem.lima.business.ejb;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -103,7 +104,9 @@
@Override
public ReportsDatas generateAccountReportsWithTransaction (Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException{
ReportsDatas reportsDatas = new ReportsDatasImpl();
- double credit = 0, debit = 0, solde = 0;
+ BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal solde = new BigDecimal(0);
if (account != null){
// First subaccount
List<Account> accounts = (List<Account>) account.getSubAccounts();
@@ -119,15 +122,18 @@
ReportsDatas subReportsDatas =
generateAccountReportsWithTransaction(subAccount,
beginDate,endDate, topiaContext);
- debit += subReportsDatas.getAmountDebit();
- credit += subReportsDatas.getAmountCredit();
+ debit = debit.add(subReportsDatas.getAmountDebit());
+ credit = credit.add(subReportsDatas.getAmountCredit());
entries.addAll(subReportsDatas.getListEntry());
}
- solde = debit - credit;
- if (solde > 0){
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+
+ if (solde.doubleValue() > 0){
reportsDatas.setSoldeDebit(true);
}
- solde = Math.abs(solde);
+ solde = solde.abs();
reportsDatas.setAmountCredit(credit);
reportsDatas.setAmountDebit(debit);
reportsDatas.setAmountSolde(solde);
@@ -170,7 +176,10 @@
@SuppressWarnings("unchecked")
protected ReportsDatas generateSubAccountReportsWithTransaction(Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
- double credit = 0, debit = 0, solde = 0;
+ BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal solde = new BigDecimal(0);
+
List<Object[]> results = new ArrayList<Object[]>();
String queryAlias = "E";
if (beginDate != null && endDate != null){
@@ -194,24 +203,27 @@
results = amountsQuery.execute(topiaContext);
int nbAmount = results.size();
if(nbAmount==2){
- debit = (Double)results.get(0)[1];
- credit = (Double)results.get(1)[1];
+ debit = (BigDecimal) results.get(0)[1];
+ credit = (BigDecimal)results.get(1)[1];
}
if (nbAmount==1){
if ((Boolean)results.get(0)[0]){
- debit = (Double)results.get(0)[1];
+ debit = (BigDecimal) results.get(0)[1];
}
else {
- credit = (Double)results.get(0)[1];
+ credit = (BigDecimal)results.get(0)[1];
}
}
// set the amounts and solde
- solde = debit - credit;
- if (solde > 0){
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+
+ if (solde.doubleValue() > 0){
reportsDatas.setSoldeDebit(true);
}
- solde = Math.abs(solde);
+ solde = solde.abs();
reportsDatas.setAmountCredit(credit);
reportsDatas.setAmountDebit(debit);
@@ -235,10 +247,15 @@
@SuppressWarnings("unchecked")
protected ReportsDatas generateSubAccountBalanceWithTransaction(Account account, Date beginDate, Date endDate, Boolean getEntries, TopiaContext topiaContext) throws LimaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
- double credit = 0, debit = 0, solde = 0;
+ BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal solde = new BigDecimal(0);
+
+
List<Object[]> results = new ArrayList<Object[]>();
String queryAlias = "E";
if (beginDate != null && endDate != null){
+ log.debug("solde 0 : "+solde);
try {
EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
@@ -261,24 +278,28 @@
results = amountsQuery.execute(topiaContext);
int nbAmount = results.size();
if(nbAmount==2){
- debit = (Double)results.get(0)[1];
- credit = (Double)results.get(1)[1];
+ debit = (BigDecimal)results.get(0)[1];
+ credit = (BigDecimal)results.get(1)[1];
}
if (nbAmount==1){
if ((Boolean)results.get(0)[0]){
- debit = (Double)results.get(0)[1];
+ debit = (BigDecimal)results.get(0)[1];
}
else {
- credit = (Double)results.get(0)[1];
+ credit = (BigDecimal)results.get(0)[1];
}
}
// set the amounts and solde
- solde = debit - credit;
- if (solde > 0){
+ //solde = debit - credit
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+
+ if (solde.doubleValue() > 0){
reportsDatas.setSoldeDebit(true);
+
}
- solde = Math.abs(solde);
+ solde = solde.abs();
reportsDatas.setAmountCredit(credit);
reportsDatas.setAmountDebit(debit);
@@ -306,7 +327,10 @@
@Override
public ReportsDatas generateEntryBooksReports(EntryBook entryBook, Date beginDate, Date endDate) throws LimaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
- double credit = 0, debit = 0, solde = 0;
+ BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal solde = new BigDecimal(0);
+
List<Object[]> results = new ArrayList<Object[]>();
if (entryBook != null && beginDate != null && endDate != null){
// Get all entries with a topia query
@@ -339,24 +363,26 @@
results = amountsQuery.execute(topiaTransaction);
int nbAmount = results.size();
if(nbAmount==2){
- debit = (Double)results.get(0)[1];
- credit = (Double)results.get(1)[1];
+ debit = (BigDecimal)results.get(0)[1];
+ credit = (BigDecimal)results.get(1)[1];
}
if (nbAmount==1){
if ((Boolean)results.get(0)[0]){
- debit = (Double)results.get(0)[1];
+ debit = (BigDecimal)results.get(0)[1];
}
else {
- credit = (Double)results.get(0)[1];
+ credit = (BigDecimal)results.get(0)[1];
}
}
// set the amounts and solde
- solde = debit - credit;
- if (solde > 0){
+ //solde = debit - credit;
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+ if (solde.doubleValue() > 0){
reportsDatas.setSoldeDebit(true);
}
- solde = Math.abs(solde);
+ solde = solde.abs();
reportsDatas.setAmountCredit(credit);
reportsDatas.setAmountDebit(debit);
@@ -419,8 +445,9 @@
public BalanceTrial generateBalanceTrial(Date beginDate, Date endDate, String selectedAccounts, Boolean getEntries, Boolean movementedFilter) throws LimaException {
BalanceTrial balanceTrial = new BalanceTrialImpl();
balanceTrial.setReportsDatas(new ArrayList<ReportsDatas>());
- double credit = 0, debit = 0, solde = 0;
-
+ BigDecimal credit = new BigDecimal(0);
+ BigDecimal debit = new BigDecimal(0);
+ BigDecimal solde = new BigDecimal(0);
TopiaContext topiaTransaction = null;
try {
topiaTransaction = beginTransaction();
@@ -439,16 +466,20 @@
}
//build list account from selectedAccounts
else{
- accounts=accountServiceLocal.stringToListAccountsWithTransaction(selectedAccounts, topiaTransaction);
+ accounts = accountServiceLocal.stringToListAccountsWithTransaction(
+ selectedAccounts, false, topiaTransaction);
}
for (Account account : accounts) {
ReportsDatas reportsDatas =
generateSubAccountBalanceWithTransaction(account, beginDate,
endDate, getEntries, topiaTransaction);
reportsDatas.setAccount(account);
- Double amount = reportsDatas.getAmountSolde();
+ BigDecimal amount = reportsDatas.getAmountSolde();
+ if (amount == null){
+ amount = new BigDecimal(0);
+ }
if (movementedFilter){
- if (amount != 0){
+ if (amount.doubleValue() != 0){
// add balance sheet to balance trial
balanceTrial.addReportsDatas(reportsDatas);
}
@@ -459,18 +490,20 @@
}
if (reportsDatas.getSoldeDebit()) {
- debit += amount;
+ debit = debit.add(amount);
}
else {
- credit += amount;
+ credit = credit.add(amount);
}
}
// set the amounts and solde
- solde = debit - credit;
- if (solde > 0){
+ //solde = debit - credit;
+ solde = solde.add(debit);
+ solde = solde.subtract(credit);
+ if (solde.doubleValue() > 0){
balanceTrial.setSoldeDebit(true);
}
- solde = Math.abs(solde);
+ solde = solde.abs();
balanceTrial.setAmountCredit(credit);
balanceTrial.setAmountDebit(debit);
balanceTrial.setAmountSolde(solde);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountServiceLocal.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountServiceLocal.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -40,7 +40,7 @@
@Local
public interface AccountServiceLocal extends AccountService{
- public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, TopiaContext topiaContext) throws LimaException;
+ public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, Boolean subAccountsMode, TopiaContext topiaContext) throws LimaException;
void createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException, LimaBusinessException;
void createSubLedgerWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException;
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryEBPComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryEBPComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryEBPComparator.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -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.utils;
+
+import java.util.Comparator;
+import org.chorem.lima.beans.EntryEBP;
+
+public class EntryEBPComparator implements Comparator<EntryEBP>{
+
+ @Override
+ public int compare(EntryEBP o1, EntryEBP o2) {
+
+ int result = o1.getDatEcr().compareTo(o2.getDatEcr());
+
+ if(result==0)
+ result = o1.getJournal().compareTo(o2.getJournal());
+
+ return result;
+ }
+
+}
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -47,4 +47,15 @@
return (List<Account>) findAllByQuery(query);
}
+ @Override
+ public Account findSubAccountByNumber(String number) throws TopiaException {
+ TopiaQuery query = createQuery();
+ String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS);
+ String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS);
+ query.addWhere("not exists elements ("+subAccountsProperty+")")
+ .addWhere("not exists elements ("+subLedgersProperty+")")
+ .addEquals(Account.ACCOUNT_NUMBER, number);
+ return findByQuery(query);
+ }
+
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -1,17 +1,25 @@
package org.chorem.lima.entity;
+import java.math.BigDecimal;
+
public class FinancialTransactionImpl extends FinancialTransactionAbstract {
@Override
public void setAmounts() {
+ if (amountDebit == null){
+ amountDebit = new BigDecimal(0);
+ }
+ if (amountCredit == null){
+ amountCredit = new BigDecimal(0);
+ }
for (Entry entryFT : entry) {
if (entryFT.getDebit()){
- amountDebit += entryFT.getAmount();
+ amountDebit = amountDebit.add(entryFT.getAmount());
}
else {
- amountCredit += entryFT.getAmount();
+ amountCredit = amountCredit.add(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/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-08-12 13:51:19 UTC (rev 3000)
@@ -42,7 +42,7 @@
getEndDatePicker().setDate(endDate);
void $afterCompleteSetup() {
- getHandler().refresh();
+ //getHandler().refresh();
}
]]>
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -19,6 +19,8 @@
package org.chorem.lima.ui.accountsreports;
import static org.nuiton.i18n.I18n._;
+
+import java.math.BigDecimal;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -91,15 +93,18 @@
public ReportsDatas getDataList(){
ReportsDatas results = null;
- try {
- results = reportService.generateAccountsReports(selectedAccount,
- selectedBeginDate, selectedEndDate);
- }
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
+ //avoid unnecessary call to service
+ if (selectedAccount != null){
+ try {
+ results = reportService.generateAccountsReports(selectedAccount,
+ selectedBeginDate, selectedEndDate);
}
- ErrorHelper.showErrorDialog("Can't get entries list", eee);
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+ ErrorHelper.showErrorDialog("Can't get entries list", eee);
+ }
}
return results;
}
@@ -117,13 +122,13 @@
if (datasList != null){
// set amounts credit and debit and solde
- view.amountCreditLabel.setText(String.valueOf(datasList.getAmountCredit()));
- view.amountDebitLabel.setText(String.valueOf(datasList.getAmountDebit()));
- Double amountSolde = datasList.getAmountSolde();
- view.amountSoldeLabel.setText(String.valueOf(amountSolde));
+ view.amountCreditLabel.setText(datasList.getAmountCredit().toString());
+ view.amountDebitLabel.setText(datasList.getAmountDebit().toString());
+ BigDecimal amountSolde = datasList.getAmountSolde();
+ view.amountSoldeLabel.setText(amountSolde.toString());
- if (amountSolde == 0){
+ if (amountSolde.doubleValue() == 0){
view.soldeLabel.setText(_("lima.solde"));
}
else {
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -21,6 +21,7 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Desktop;
import java.io.IOException;
+import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
@@ -134,11 +135,11 @@
// set amounts credit, debit and solde
view.amountCreditLabel.setText(String.valueOf(datasList.getAmountCredit()));
view.amountDebitLabel.setText(String.valueOf(datasList.getAmountDebit()));
- Double amountSolde = datasList.getAmountSolde();
+ BigDecimal amountSolde = datasList.getAmountSolde();
view.amountSoldeLabel.setText(String.valueOf(amountSolde));
- if (amountSolde == 0){
+ if (amountSolde.doubleValue() == 0){
view.soldeLabel.setText(_("lima.solde"));
}
else {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -48,7 +48,7 @@
int result = 0;
// just prevent too much result
- if (cacheDataList.getListEntry() != null) {
+ if (cacheDataList != null && cacheDataList.getListEntry() != null) {
result = cacheDataList.getListEntry().size();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-08-12 13:51:19 UTC (rev 3000)
@@ -43,7 +43,7 @@
getEndDatePicker().setDate(endDate);
void $afterCompleteSetup() {
- getHandler().refresh();
+ //getHandler().refresh();
}
]]>
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -22,6 +22,7 @@
import java.awt.Desktop;
import java.io.IOException;
+import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
@@ -43,7 +44,6 @@
import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
import org.chorem.lima.util.ErrorHelper;
@@ -114,16 +114,18 @@
}
public ReportsDatas getDataList(){
- ReportsDatas results = new ReportsDatasImpl();
- try {
- results =
- reportService.generateEntryBooksReports(selectedEntryBook, selectedBeginDate, selectedEndDate);
- }
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
+ ReportsDatas results = null;
+ if (selectedEntryBook != null){
+ try {
+ results =
+ reportService.generateEntryBooksReports(selectedEntryBook, selectedBeginDate, selectedEndDate);
}
- ErrorHelper.showErrorDialog("Can't get entries list", eee);
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+ ErrorHelper.showErrorDialog("Can't get entries list", eee);
+ }
}
return results;
}
@@ -143,11 +145,10 @@
// set amounts credit, debit and solde
view.amountCreditLabel.setText(String.valueOf(datasList.getAmountCredit()));
view.amountDebitLabel.setText(String.valueOf(datasList.getAmountDebit()));
- Double amountSolde = datasList.getAmountSolde();
+ BigDecimal amountSolde = datasList.getAmountSolde();
view.amountSoldeLabel.setText(String.valueOf(amountSolde));
-
- if (amountSolde == 0){
+ if (amountSolde.doubleValue() == 0){
view.soldeLabel.setText(_("lima.solde"));
}
else {
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -23,6 +23,7 @@
import java.awt.Desktop;
import java.io.IOException;
+import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
@@ -145,8 +146,15 @@
//get entries for the period for the current row
if (result instanceof FinancialStatementAmounts) {
FinancialStatementAmounts currentRow = (FinancialStatementAmounts) result;
- Double grossAmount = currentRow.getGrossAmount();
- Double provisionDeprecationAmount = currentRow.getProvisionDeprecationAmount();
+ BigDecimal grossAmount = currentRow.getGrossAmount();
+ if (grossAmount == null ){
+ grossAmount = new BigDecimal(0);
+ }
+
+ BigDecimal provisionDeprecationAmount = currentRow.getProvisionDeprecationAmount();
+ if (provisionDeprecationAmount == null ){
+ provisionDeprecationAmount = new BigDecimal(0);
+ }
switch (column) {
case 0:
result = "";
@@ -159,7 +167,7 @@
}
break;
case 1:
- if (grossAmount == 0){
+ if (grossAmount.doubleValue() == 0){
result = null;
}
else {
@@ -167,7 +175,7 @@
}
break;
case 2:
- if (provisionDeprecationAmount == 0){
+ if (provisionDeprecationAmount.doubleValue() == 0){
result = null;
}
else {
@@ -175,11 +183,12 @@
}
break;
case 3:
- if (grossAmount-provisionDeprecationAmount == 0){
+ BigDecimal solde = grossAmount.subtract(provisionDeprecationAmount);
+ if (solde.doubleValue() == 0){
result = null;
}
else {
- result = grossAmount-provisionDeprecationAmount;
+ result = solde;
}
break;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -19,6 +19,8 @@
package org.chorem.lima.ui.financialtransaction;
import static org.nuiton.i18n.I18n._;
+
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
@@ -160,13 +162,13 @@
result = String.class;
break;
case 6:
- result = Double.class;
+ result = BigDecimal.class;
break;
case 7:
- result = Double.class;
+ result = BigDecimal.class;
break;
case 8:
- result = Double.class;
+ result = BigDecimal.class;
break;
}
@@ -231,8 +233,8 @@
if (result instanceof FinancialTransaction) {
FinancialTransaction currentRow = (FinancialTransaction)result;
- Double amountDebit = currentRow.getAmountDebit();
- Double amountCredit = currentRow.getAmountCredit();
+ BigDecimal amountDebit = currentRow.getAmountDebit();
+ BigDecimal amountCredit = currentRow.getAmountCredit();
switch (column) {
case 0:
@@ -265,7 +267,7 @@
result = amountCredit;
break;
case 8:
- result = amountDebit - amountCredit;
+ result = amountDebit.subtract(amountCredit);
break;
}
}
@@ -458,11 +460,11 @@
currentEntry.setPosition((String)value);
break;
case 6:
- currentEntry.setAmount((Double)value);
+ currentEntry.setAmount((BigDecimal)value);
currentEntry.setDebit(true);
break;
case 7:
- currentEntry.setAmount((Double)value);
+ currentEntry.setAmount((BigDecimal)value);
currentEntry.setDebit(false);
break;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -19,6 +19,8 @@
package org.chorem.lima.ui.financialtransactionunbalanced;
import static org.nuiton.i18n.I18n._;
+
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -152,13 +154,13 @@
result = String.class;
break;
case 6:
- result = Double.class;
+ result = BigDecimal.class;
break;
case 7:
- result = Double.class;
+ result = BigDecimal.class;
break;
case 8:
- result = Double.class;
+ result = BigDecimal.class;
break;
}
@@ -224,8 +226,8 @@
if (result instanceof FinancialTransaction) {
FinancialTransaction currentRow = (FinancialTransaction)result;
- Double amountDebit = currentRow.getAmountDebit();
- Double amountCredit = currentRow.getAmountCredit();
+ BigDecimal amountDebit = currentRow.getAmountDebit();
+ BigDecimal amountCredit = currentRow.getAmountCredit();
switch (column) {
case 0:
@@ -258,7 +260,7 @@
result = amountCredit;
break;
case 8:
- result = amountDebit - amountCredit;
+ result = amountDebit.subtract(amountCredit);
break;
}
}
@@ -403,11 +405,11 @@
currentEntry.setPosition((String)value);
break;
case 6:
- currentEntry.setAmount((Double)value);
+ currentEntry.setAmount((BigDecimal)value);
currentEntry.setDebit(true);
break;
case 7:
- currentEntry.setAmount((Double)value);
+ currentEntry.setAmount((BigDecimal)value);
currentEntry.setDebit(false);
break;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -20,6 +20,8 @@
package org.chorem.lima.ui.ledger;
import static org.nuiton.i18n.I18n._;
+
+import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.List;
import javax.swing.table.AbstractTableModel;
@@ -110,8 +112,8 @@
if (result instanceof ReportsDatas) {
ReportsDatas currentRow = (ReportsDatas)result;
- Double amountDebit = currentRow.getAmountDebit();
- Double amountCredit = currentRow.getAmountCredit();
+ BigDecimal amountDebit = currentRow.getAmountDebit();
+ BigDecimal amountCredit = currentRow.getAmountCredit();
switch (column) {
case 0:
@@ -141,15 +143,21 @@
result = amountCredit;
break;
case 7:
- result = amountDebit - amountCredit;
+ result = amountDebit.subtract(amountCredit);
break;
}
}
else if (result instanceof Entry) {
Entry currentRow = (Entry)result;
- Double amountDebit = currentRow.getDebit() ? currentRow.getAmount() : 0;
- Double amountCredit = currentRow.getDebit() ? 0 : currentRow.getAmount();
-
+ BigDecimal amountDebit = new BigDecimal(0),
+ amountCredit = new BigDecimal(0);
+ if (currentRow.getDebit()){
+ amountDebit = currentRow.getAmount();
+ }
+ else {
+ amountCredit = currentRow.getAmount();
+ }
+
switch (column) {
case 0:
result = null; // account
@@ -179,7 +187,7 @@
result = amountCredit;
break;
case 7:
- result = amountDebit - amountCredit;
+ result = amountDebit.subtract(amountCredit);
break;
}
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-08-11 14:50:40 UTC (rev 2999)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-08-12 13:51:19 UTC (rev 3000)
@@ -22,6 +22,7 @@
import java.awt.Desktop;
import java.io.IOException;
+import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
@@ -164,11 +165,11 @@
String.valueOf(balanceTrialCache.getAmountCredit()));
view.amountDebitLabel.setText(
String.valueOf(balanceTrialCache.getAmountDebit()));
- Double amountSolde = balanceTrialCache.getAmountSolde();
+ BigDecimal amountSolde = balanceTrialCache.getAmountSolde();
view.amountSoldeLabel.setText(
String.valueOf(amountSolde));
- if (amountSolde == 0){
+ if (amountSolde.doubleValue() == 0){
view.soldeLabel.setText(_("lima.solde"));
}
else {
1
0
Author: tchemit
Date: 2010-08-11 16:50:40 +0200 (Wed, 11 Aug 2010)
New Revision: 2999
Url: http://chorem.org/repositories/revision/lima/2999
Log:
Utilisation de mavenpom4redmine 2.2.3
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-08-06 15:10:31 UTC (rev 2998)
+++ trunk/pom.xml 2010-08-11 14:50:40 UTC (rev 2999)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.2.2.1</version>
+ <version>2.2.3</version>
</parent>
<groupId>org.chorem</groupId>
1
0
r2998 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: accountsreports celleditor combobox entrybooksreports financialtransaction
by jpepin@users.chorem.org 06 Aug '10
by jpepin@users.chorem.org 06 Aug '10
06 Aug '10
Author: jpepin
Date: 2010-08-06 17:10:31 +0200 (Fri, 06 Aug 2010)
New Revision: 2998
Url: http://chorem.org/repositories/revision/lima/2998
Log:
Ajout auto compl?\195?\169tion entrybook report.
Debug auto compl?\195?\169tion dans la saisie d'?\195?\169criture.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.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/SubAccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2010-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.ui.combobox.AccountComboBoxModel;
import org.chorem.lima.util.AccountToString;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java 2010-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -1,110 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.accountsreports;
-
-import java.util.List;
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.AccountServiceMonitorable;
-import org.chorem.lima.business.ImportServiceMonitorable;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
-
-/**
- * Account combo box model.
- */
-
-public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
-
- private static final long serialVersionUID = 1L;
-
- private static final Log log =
- LogFactory.getLog(FinancialPeriodTableModel.class);
-
- protected Object selectedAccount;
-
- protected List<Account> datasCache;
-
- protected AccountServiceMonitorable accountService;
-
- public AccountComboBoxModel () {
- accountService =
- LimaServiceFactory.getInstance().getService(
- AccountServiceMonitorable.class);
- accountService.addListener(this);
- LimaServiceFactory.getInstance().getService(
- ImportServiceMonitorable.class).addListener(this);
- datasCache = getDataList();
- }
-
- @Override
- public Object getSelectedItem() {
- return selectedAccount;
- }
-
- @Override
- public void setSelectedItem(Object anItem) {
- selectedAccount = anItem;
- fireContentsChanged(this, -1, -1);
- }
-
-
- @Override
- public Object getElementAt(int index) {
- return datasCache.get(index);
- }
-
- @Override
- public int getSize() {
- return datasCache.size();
- }
-
- public List<Account> getDataList(){
- List<Account> result = null;
- try {
- result = accountService.getAllAccounts();
- }
- catch (LimaException eee) {
- if (log.isDebugEnabled()){
- log.debug("Can't get list accounts", eee);
- }
- }
- return result;
-
- }
-
- public void refresh(){
- datasCache = getDataList();
- fireContentsChanged(this, 0, datasCache.size());
- }
-
- @Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (methodeName.contains("Account") || methodeName.contains("importAll")){
- refresh();
- }
- }
-
-
-}
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-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -30,6 +30,7 @@
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.combobox.AccountComboBoxModel;
import org.chorem.lima.util.ErrorHelper;
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-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -20,15 +20,17 @@
package org.chorem.lima.ui.celleditor;
import java.awt.Component;
-import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
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;
@@ -38,7 +40,7 @@
import org.chorem.lima.widgets.JWideComboBox;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor, KeyListener {
protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
private final JWideComboBox comboBox;
@@ -58,35 +60,7 @@
AccountRenderer accountRenderer = new AccountRenderer();
comboBox.setRenderer(accountRenderer);
AutoCompleteDecorator.decorate(comboBox, AccountToString.getInstance());
-
-
- /**
- * Ajout d'un listener pour la frappe au clavier seulement, permettant
- * de déplacer la sélection (et le caret) du fait que la première touche
- * n'est pas prise en compte.
- */
- comboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
-
- @Override
- public void keyReleased(KeyEvent e) {
- // Vérifie si c'est la première frappe au clavier
- if ( keyPressed == false )
- {
- // Récupère l'editor de la comboBox
- JTextComponent edit = (JTextComponent) comboBox.getEditor().getEditorComponent();
- // Met en place le curseur et la selection après la première lettre
- edit.select(1, edit.getText().length());
- keyPressed = true;
- }
- // Validate editing with enter key
- if ( e.getKeyChar() == KeyEvent.VK_ENTER )
- {
- //FIXME pepin 13072010 enter not save the modification
- log.debug(comboBox.getEditor().getItem());
- stopCellEditing();
- }
- }
- });
+ comboBox.getEditor().getEditorComponent().addKeyListener(this);
}
@Override
@@ -108,14 +82,13 @@
* @param evt
* @return
*/
- @Override
+ @Override
public boolean isCellEditable(EventObject evt) {
// Si il y a une frappe au clavier
if (evt instanceof KeyEvent) {
final KeyEvent keyEvent = (KeyEvent) evt;
// Empèche la touche echap
- if ( keyEvent.getKeyChar() != KeyEvent.VK_ESCAPE )
- {
+ if ( keyEvent.getKeyChar() != KeyEvent.VK_ESCAPE){
// Permet de placer le focus sur l'editor de la comboBox
SwingUtilities.invokeLater(new Runnable() {
@Override
@@ -130,17 +103,46 @@
});
}
}
- // Remet à faux pour la premiere lettre tapée au clavier
keyPressed = false;
return ( !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2 );
}
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+
+ // Vérifie si c'est la première frappe au clavier
+ if ( keyPressed == false )
+ {
+ // Récupère l'editor de la comboBox
+ JTextComponent edit = (JTextComponent) comboBox.getEditor().getEditorComponent();
+ // Met en place le curseur et la selection après la première lettre
+ edit.select(1, edit.getText().length());
+ keyPressed = true;
+ }
+
+ // delegate popup list menu
+ if ( e.getKeyChar() == KeyEvent.VK_ENTER )
+ {
+ fireEditingStopped();
+ }
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
public static AccountTableCellEditor getInstance() {
if (editor == null) {
editor = new AccountTableCellEditor();
}
return editor;
}
-
+
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2010-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -56,11 +56,6 @@
EntryBookRenderer entryBookRenderer = new EntryBookRenderer();
comboBox.setRenderer(entryBookRenderer);
- /*// Property Change Listener
- LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
- comboBox.setModel(comboBoxModel);*/
- //LimaContext.getContext().addPropertyChangeListener(entryBookComboBoxModel);
-
// AutoCompletion
AutoCompleteDecorator.decorate(comboBox, EntryBookToString.getInstance());
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java (from rev 2997, trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -0,0 +1,110 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.combobox;
+
+import java.util.List;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountServiceMonitorable;
+import org.chorem.lima.business.ImportServiceMonitorable;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
+
+/**
+ * Account combo box model.
+ */
+
+public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log =
+ LogFactory.getLog(FinancialPeriodTableModel.class);
+
+ protected Object selectedAccount;
+
+ protected List<Account> datasCache;
+
+ protected AccountServiceMonitorable accountService;
+
+ public AccountComboBoxModel () {
+ accountService =
+ LimaServiceFactory.getInstance().getService(
+ AccountServiceMonitorable.class);
+ accountService.addListener(this);
+ LimaServiceFactory.getInstance().getService(
+ ImportServiceMonitorable.class).addListener(this);
+ datasCache = getDataList();
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ return selectedAccount;
+ }
+
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedAccount = anItem;
+ fireContentsChanged(this, -1, -1);
+ }
+
+
+ @Override
+ public Object getElementAt(int index) {
+ return datasCache.get(index);
+ }
+
+ @Override
+ public int getSize() {
+ return datasCache.size();
+ }
+
+ public List<Account> getDataList(){
+ List<Account> result = null;
+ try {
+ result = accountService.getAllAccounts();
+ }
+ catch (LimaException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't get list accounts", eee);
+ }
+ }
+ return result;
+
+ }
+
+ public void refresh(){
+ datasCache = getDataList();
+ fireContentsChanged(this, 0, datasCache.size());
+ }
+
+ @Override
+ public void notifyMethod(String serviceName, String methodeName) {
+ if (methodeName.contains("Account") || methodeName.contains("importAll")){
+ refresh();
+ }
+ }
+
+
+}
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-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -19,7 +19,8 @@
package org.chorem.lima.ui.combobox;
import java.util.List;
-import javax.swing.DefaultComboBoxModel;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.EntryBookServiceMonitorable;
@@ -39,7 +40,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class EntryBookComboBoxModel extends DefaultComboBoxModel implements ServiceListener {
+public class EntryBookComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
private static final long serialVersionUID = 1L;
@@ -75,6 +76,7 @@
@Override
public void setSelectedItem(Object anItem) {
selectedEntryBook = anItem;
+ fireContentsChanged(this, -1, -1);
}
@Override
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-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -22,7 +22,6 @@
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.AccountServiceMonitorable;
@@ -31,7 +30,6 @@
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
/**
* Account combo box model.
@@ -39,12 +37,9 @@
public class SubAccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
- /**
- *
- */
private static final long serialVersionUID = 1L;
- private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+ private static final Log log = LogFactory.getLog(SubAccountComboBoxModel.class);
protected Object selectedAccount;
@@ -70,15 +65,10 @@
@Override
public void setSelectedItem(Object anItem) {
selectedAccount = anItem;
+ fireContentsChanged(this, -1, -1);
}
@Override
- public void addListDataListener(ListDataListener arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public Object getElementAt(int index) {
return datasCache.get(index);
}
@@ -88,12 +78,6 @@
return datasCache.size();
}
- @Override
- public void removeListDataListener(ListDataListener arg0) {
- // TODO Auto-generated method stub
-
- }
-
public List<Account> getDataList(){
List<Account> result = new ArrayList<Account>();
try {
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -0,0 +1,89 @@
+/* *##% 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.entrybooksreports;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import javax.swing.JComboBox;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
+import org.chorem.lima.ui.combobox.EntryBookRenderer;
+import org.chorem.lima.util.EntryBookToString;
+import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
+
+public class EntryBookComboBox extends JComboBox implements KeyListener, ActionListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log =
+ LogFactory.getLog(EntryBookComboBox.class);
+
+ protected EntryBooksReportsViewHandler handler;
+
+ public EntryBookComboBox(EntryBooksReportsViewHandler handler) {
+ this.handler = handler;
+ EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel();
+ EntryBookRenderer entryBookRenderer = new EntryBookRenderer();
+ setModel(entryBookComboBoxModel);
+ setRenderer(entryBookRenderer);
+ setEditable(true);
+ AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance());
+ this.getEditor().getEditorComponent().addKeyListener(this);
+ this.addActionListener(this);
+ }
+
+
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object object = this.getSelectedItem();
+ if (object instanceof EntryBook){
+ handler.setEntryBook((EntryBook) this.getSelectedItem());
+ }
+ }
+
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ Object object = this.getSelectedItem();
+ if (object instanceof EntryBook){
+ handler.setEntryBook((EntryBook) this.getSelectedItem());
+ }
+ // delegate popup list menu
+ if ( e.getKeyChar() == KeyEvent.VK_ENTER )
+ {
+ firePopupMenuCanceled();
+ }
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-08-06 15:10:31 UTC (rev 2998)
@@ -66,13 +66,8 @@
<cell anchor="east">
<JLabel id="entryBookSelectorLabel" text="lima.entrybook"/>
</cell>
- <cell anchor="west">
- <JComboBox id="entryBookComboBox"
- model="{getModelEntryBook()}"
- renderer="{new org.chorem.lima.ui.combobox.EntryBookRenderer()}"
- onActionPerformed="getHandler().setEntryBook((EntryBook) entryBookComboBox.getSelectedItem())"
- editable="false"
- />
+ <cell anchor="west">
+ <JComboBox javaBean='new org.chorem.lima.ui.entrybooksreports.EntryBookComboBox(getHandler())' />
</cell>
<cell>
<EnumEditor id='DocumentEditor'
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-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -59,8 +59,6 @@
protected EntryBooksReportsTableModel tableModel;
- protected EntryBookComboBoxModel comboBoxModel;
-
/** log. */
private static final Log log = LogFactory.getLog(EntryBooksReportsViewHandler.class);
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-08-06 14:01:37 UTC (rev 2997)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2010-08-06 15:10:31 UTC (rev 2998)
@@ -52,8 +52,6 @@
private ColorHighlighter colorBalance;
- /**
- */
public FinancialTransactionTable(FinancialTransactionViewHandler handler) {
this.handler = handler;
1
0
Author: jpepin
Date: 2010-08-06 16:01:37 +0200 (Fri, 06 Aug 2010)
New Revision: 2997
Url: http://chorem.org/repositories/revision/lima/2997
Log:
Debug generation bilan et compte de resultat :
- ajout d'un sens d?\195?\169bit et cr?\195?\169dit (utile pour le compte de r?\195?\169sultat).
- dans la liste des comptes de chaque poste, recherche de tout les comptes commencant par le compte recherch?\195?\169.
Ajout combobox editable dans accounts report avec auto completion.
Modification des filtres dans la balance et le grand-livre : filtre automatique lors de la saisie.
Added:
trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceFilterTextField.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerFilterTextField.java
Removed:
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/financialtransaction/LetteringView.jaxx
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/ExportServiceImpl.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/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementService.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementHeaderForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -38,12 +38,14 @@
import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
+import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
/**
* Permet d'implémenter le Plan Comptable Général.
@@ -222,8 +224,7 @@
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
- List<Account> accounts = accountDAO.findAll();
- accountsList.addAll(accounts);
+ accountsList = accountDAO.findAll();
Collections.sort(accountsList, new AccountComparator());
}
@@ -470,10 +471,18 @@
}
for (String accountNumber : accountNumbers) {
- Account accountFilter = accountDAO.findByAccountNumber(accountNumber);
+ Account account = accountDAO.findByAccountNumber(accountNumber);
+ if (account == null){
+ TopiaQuery query = accountDAO.createQuery();
+ query.addWhere(Account.ACCOUNT_NUMBER, Op.LIKE, accountNumber+"%");
+ List<Account> accountsResult = accountDAO.findAllByQuery(query);
+ if (accountsResult != null){
+ accounts.addAll(accountsResult);
+ }
+ }
//add account if exist
- if (accountFilter != null){
- accounts.add(accountFilter);
+ else {
+ accounts.add(account);
}
}
}
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -27,6 +27,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.FinancialStatementWayEnum;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ejbinterface.ExportService;
@@ -295,7 +296,7 @@
*/
public void exportFinancialStatementChartAsCSV(CSVWriter csvWriter, TopiaContext topiaContext) throws LimaException {
try {
- String[] nextLine = new String[10];
+ String[] nextLine = new String[11];
// Get all Financialstatements
FinancialStatementDAO financialStatementDAO =
LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
@@ -328,6 +329,12 @@
masterFinancialStatement.getLabel();
}
nextLine[9] = masterFinancialStatementString;
+ FinancialStatementWayEnum financialStatementWayEnum = financialStatement.getWay();
+ String financialStatementWay = "";
+ if (financialStatementWayEnum != null){
+ financialStatementWay = financialStatementWayEnum.name();
+ }
+ nextLine[10] = financialStatementWay;
// Add line in file
csvWriter.writeNext(nextLine);
}
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -21,6 +21,7 @@
import static org.nuiton.i18n.I18n._;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.StringTokenizer;
@@ -29,6 +30,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.FinancialStatementWayEnum;
import org.chorem.lima.beans.FinancialStatementAmounts;
import org.chorem.lima.beans.FinancialStatementAmountsImpl;
import org.chorem.lima.beans.FinancialStatementDatas;
@@ -42,7 +44,9 @@
import org.chorem.lima.business.ejbinterface.FinancialStatementService;
import org.chorem.lima.business.ejbinterface.FinancialStatementServiceLocal;
import org.chorem.lima.business.ejbinterface.ReportServiceLocal;
+import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.FinancialStatement;
import org.chorem.lima.entity.FinancialStatementDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -51,6 +55,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
@Stateless
public class FinancialStatementServiceImpl extends AbstractLimaService implements FinancialStatementService, FinancialStatementServiceLocal{
@@ -406,6 +411,7 @@
try {
// DEBIT & CREDIT
String accountsString = financialStatement.getAccounts();
+ log.debug("\n" + accountsString);
Double amount = 0.0;
if (accountsString != null){
//Remove Spaces
@@ -413,14 +419,30 @@
StringTokenizer stQuote = new StringTokenizer(accountsString, "-");
while (stQuote.hasMoreTokens()) {
String s = stQuote.nextToken();
- List<Account> accountsStringList = accountServiceLocal.
+ List<Account> accountsList = accountServiceLocal.
stringToListAccountsWithTransaction(s, topiaContext);
Double resAmount = 0.0;
- for (Account accountString : accountsStringList) {
+
+ for (Account account : accountsList) {
+ log.debug(account.getAccountNumber());
ReportsDatas reportsDatas = reportServiceLocal.
- generateAccountReportsWithTransaction(accountString,
+ generateAccountReportsWithTransaction(account,
selectedBeginDate, selectedEndDate, topiaContext);
- resAmount += reportsDatas.getAmountSolde();
+
+ //check the way of financialstatement amount
+ FinancialStatementWayEnum financialStatementWayEnum =
+ financialStatement.getMasterFinancialStatement().getWay();
+ switch (financialStatementWayEnum) {
+ case BOTH:
+ resAmount += reportsDatas.getAmountSolde();
+ break;
+ case DEBIT:
+ resAmount += reportsDatas.getAmountDebit()-reportsDatas.getAmountCredit();
+ break;
+ case CREDIT:
+ resAmount += reportsDatas.getAmountCredit()-reportsDatas.getAmountDebit();
+ break;
+ }
}
if (amount == 0){
amount=resAmount;
@@ -456,7 +478,7 @@
ReportsDatas reportsDatas = reportServiceLocal.
generateAccountReportsWithTransaction(account,
selectedBeginDate, selectedEndDate, topiaContext);
- debitAmount += reportsDatas.getAmountCredit();
+ debitAmount += reportsDatas.getAmountDebit();
}
}
@@ -493,8 +515,74 @@
return financialStatementAmounts;
}
+
+
- protected TopiaContext beginTransaction() throws TopiaException {
+ @Override
+ public String checkFinancialStatementChart() throws LimaException {
+ String result = "";
+ List<Account> accountsList = new ArrayList<Account>();
+
+ TopiaContext transaction = null;
+ try {
+ transaction = beginTransaction();
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
+
+ accountsList = accountDAO.findAllSubAccounts();
+ Collections.sort(accountsList, new AccountComparator());
+
+ for (Account account : accountsList) {
+ Boolean find = false;
+ String accountNumber = account.getAccountNumber();
+ if (accountNumber.length()>1){
+ while (!find && accountNumber.length() > 1){
+ log.debug(accountNumber);
+ List<FinancialStatement> financialStatements =
+ findFinancialStatementByAccountNumber(accountNumber, transaction);
+ log.debug(financialStatements);
+ if (!(find = financialStatements.size() > 0)){
+ accountNumber = accountNumber.substring(0, accountNumber.length()-1);
+ }
+ }
+
+ if (!find){
+ result += "NOT FOUND : "+account.getAccountNumber()+"\n";
+ }
+ }
+ }
+
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+ return result;
+ }
+
+ public List<FinancialStatement> findFinancialStatementByAccountNumber(String accountNumber, TopiaContext topiaContext) throws TopiaException{
+
+ FinancialStatementDAO financialStatementDAO =
+ LimaCallaoDAOHelper.getFinancialStatementDAO(topiaContext);
+ TopiaQuery query = financialStatementDAO.createQuery();
+
+ String accountProperty = TopiaQuery.getProperty(FinancialStatement.ACCOUNTS);
+ String creditAccountProperty = TopiaQuery.getProperty(FinancialStatement.CREDIT_ACCOUNTS);
+ String debitAccountProperty = TopiaQuery.getProperty(FinancialStatement.DEBIT_ACCOUNTS);
+ String provisionDeprecationProperty = TopiaQuery.getProperty(FinancialStatement.PROVISION_DEPRECATION_ACCOUNTS);
+ String likeCondition = " " + Op.LIKE + " '%"+accountNumber + "%'";
+
+ query.addWhere(accountProperty + likeCondition
+ + " OR " + creditAccountProperty + likeCondition
+ + " OR " + debitAccountProperty + likeCondition
+ + " OR " + provisionDeprecationProperty + likeCondition);
+
+ return financialStatementDAO.findAllByQuery(query);
+ }
+
+ protected TopiaContext beginTransaction() throws TopiaException {
// basic check done, make check in database
// TODO move it into JTA
TopiaContext topiaTransaction;
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -37,6 +37,7 @@
import javax.ejb.Stateless;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.FinancialStatementWayEnum;
import org.chorem.lima.beans.AccountEBP;
import org.chorem.lima.beans.AccountEBPImpl;
import org.chorem.lima.beans.AccountImport;
@@ -749,6 +750,7 @@
String subAmount = nextLine[7];
String headerAmount = nextLine[8];
String masterFinancialStatement = nextLine[9];
+ String financialStatementWay = nextLine[10];
try {
FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper
@@ -769,6 +771,7 @@
financialStatementImport.setSubAmount(subAmount);
financialStatementImport
.setMasterFinancialStatement(masterFinancialStatement);
+ financialStatementImport.setWay(financialStatementWay);
// put it in hashlinkedlist
if (financialStatements.containsKey(label)){
@@ -891,6 +894,13 @@
financialStatement.setHeaderAmount(Boolean
.parseBoolean(financialStatementImport
.getHeaderAmount()));
+ String financialStatementWay = financialStatementImport.getWay();
+ if (!financialStatementWay.equals("")){
+ FinancialStatementWayEnum financialStatementWayEnum =
+ FinancialStatementWayEnum.valueOf(financialStatementWay);
+ financialStatement.setWay(financialStatementWayEnum);
+ }
+
financialStatementService
.createFinancialStatementWithTransaction(
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -180,6 +180,7 @@
createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
entriesQuery.addLoad(Entry.FINANCIAL_TRANSACTION);
+ entriesQuery.addLoad(Entry.ACCOUNT);
String loadEntryBookProperty =
TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
FinancialTransaction.ENTRY_BOOK);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementService.java 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialStatementService.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -41,5 +41,7 @@
public List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement, List<FinancialStatement> financialStatements) throws LimaException, LimaBusinessException;
public List<FinancialStatementAmounts> financialStatementReport(Date selectedBeginDate, Date selectedEndDate) throws LimaException;
+
+ public String checkFinancialStatementChart() throws LimaException;
}
Added: trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java (rev 0)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -0,0 +1,7 @@
+package org.chorem.lima;
+
+public enum FinancialStatementWayEnum {
+
+ BOTH, DEBIT, CREDIT;
+
+}
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -42,7 +42,6 @@
import org.chorem.lima.ui.financialstatementchart.FinancialStatementChartView;
import org.chorem.lima.ui.financialstatementreport.FinancialStatementReportView;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionView;
-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.identity.IdentityForm;
@@ -414,8 +413,8 @@
public void showLetteringView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
- LetteringView letteringView = new LetteringView(mainView);
- mainView.showTab(_("lima.entries.lettering"), letteringView);
+ // LetteringView letteringView = new LetteringView(mainView);
+ // mainView.showTab(_("lima.entries.lettering"), letteringView);
}
public void showSearchView(JAXXContext rootContext) {
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -0,0 +1,88 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.accountsreports;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import javax.swing.JComboBox;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.util.AccountToString;
+import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
+
+public class AccountComboBox extends JComboBox implements KeyListener, ActionListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log =
+ LogFactory.getLog(AccountComboBox.class);
+
+ protected AccountsReportsViewHandler handler;
+
+ public AccountComboBox(AccountsReportsViewHandler handler) {
+ this.handler = handler;
+ AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel();
+ AccountRenderer accountRenderer = new AccountRenderer();
+ setModel(accountComboBoxModel);
+ setRenderer(accountRenderer);
+ setEditable(true);
+ AutoCompleteDecorator.decorate(this, AccountToString.getInstance());
+ this.getEditor().getEditorComponent().addKeyListener(this);
+ this.addActionListener(this);
+ }
+
+
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object object = this.getSelectedItem();
+ if (object instanceof Account){
+ handler.setAccount((Account) this.getSelectedItem());
+ }
+ }
+
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ Object object = this.getSelectedItem();
+ if (object instanceof Account){
+ handler.setAccount((Account) this.getSelectedItem());
+ }
+
+ // delegate popup list menu
+ if ( e.getKeyChar() == KeyEvent.VK_ENTER )
+ {
+ firePopupMenuCanceled();
+ }
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java (from rev 2986, trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBoxModel.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -0,0 +1,110 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.accountsreports;
+
+import java.util.List;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountServiceMonitorable;
+import org.chorem.lima.business.ImportServiceMonitorable;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
+
+/**
+ * Account combo box model.
+ */
+
+public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log =
+ LogFactory.getLog(FinancialPeriodTableModel.class);
+
+ protected Object selectedAccount;
+
+ protected List<Account> datasCache;
+
+ protected AccountServiceMonitorable accountService;
+
+ public AccountComboBoxModel () {
+ accountService =
+ LimaServiceFactory.getInstance().getService(
+ AccountServiceMonitorable.class);
+ accountService.addListener(this);
+ LimaServiceFactory.getInstance().getService(
+ ImportServiceMonitorable.class).addListener(this);
+ datasCache = getDataList();
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ return selectedAccount;
+ }
+
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedAccount = anItem;
+ fireContentsChanged(this, -1, -1);
+ }
+
+
+ @Override
+ public Object getElementAt(int index) {
+ return datasCache.get(index);
+ }
+
+ @Override
+ public int getSize() {
+ return datasCache.size();
+ }
+
+ public List<Account> getDataList(){
+ List<Account> result = null;
+ try {
+ result = accountService.getAllAccounts();
+ }
+ catch (LimaException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't get list accounts", eee);
+ }
+ }
+ return result;
+
+ }
+
+ public void refresh(){
+ datasCache = getDataList();
+ fireContentsChanged(this, 0, datasCache.size());
+ }
+
+ @Override
+ public void notifyMethod(String serviceName, String methodeName) {
+ if (methodeName.contains("Account") || methodeName.contains("importAll")){
+ refresh();
+ }
+ }
+
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java (from rev 2986, trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -0,0 +1,49 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.accountsreports;
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+import org.chorem.lima.entity.Account;
+
+public class AccountRenderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+
+ JLabel label = new JLabel();
+ Account account = (Account) value;
+ if (account != null){
+ String accountLabel = account.getLabel();
+ int nbChars = 30;
+ if (accountLabel.length()>nbChars){
+ accountLabel = accountLabel.substring(0, nbChars)+"…";
+ }
+ label.setText(account.getAccountNumber() +" - " + accountLabel);
+ }
+ return label;
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -59,29 +59,32 @@
@Override
public int getColumnCount() {
- return 6;
+ return 7;
}
@Override
public String getColumnName(int column) {
String res = "n/a";
switch (column) {
- case 0:
+ case 0:
+ res = _("lima.table.account"); //Account Number
+ break;
+ case 1:
res = _("lima.table.date"); //Date
break;
- case 1:
+ case 2:
res = _("lima.table.entrybook"); //EntryBook
break;
- case 2:
+ case 3:
res = _("lima.table.voucher"); // Voucher
break;
- case 3:
+ case 4:
res = _("lima.table.description"); //Description
break;
- case 4:
+ case 5:
res = _("lima.table.debit"); //Debit
break;
- case 5:
+ case 6:
res = _("lima.table.credit"); //Credit
break;
}
@@ -97,11 +100,14 @@
= new SimpleDateFormat("dd MMMMM yyyy");
switch (column) {
- case 0:
+ case 0:
+ result = currentRow.getAccount().getAccountNumber();
+ break;
+ case 1:
result = simpleDateFormat.
format(currentRow.getFinancialTransaction().getTransactionDate());
break;
- case 1:
+ case 2:
if (currentRow.getFinancialTransaction().getEntryBook() != null){
result = currentRow.getFinancialTransaction().getEntryBook().getCode();
}
@@ -109,16 +115,16 @@
result = null;
}
break;
- case 2:
+ case 3:
result = currentRow.getVoucher();
break;
- case 3:
+ case 4:
result = currentRow.getDescription();
break;
- case 4:
+ case 5:
result = currentRow.getDebit() ? currentRow.getAmount() : 0;
break;
- case 5:
+ case 6:
result = currentRow.getDebit() ? 0 : currentRow.getAmount();
break;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-08-06 14:01:37 UTC (rev 2997)
@@ -18,7 +18,6 @@
<Table>
<AccountsReportsViewHandler id="handler" javaBean="new AccountsReportsViewHandler(this)" />
<Boolean id="selectedRow" javaBean="false" />
- <org.chorem.lima.ui.combobox.AccountComboBoxModel id="modelAccounts"/>
<org.chorem.lima.ui.accountsreports.AccountsReportsTableModel id="modelAccountsReportsTable"/>
<script>
<![CDATA[
@@ -67,12 +66,7 @@
<JLabel id="accountSelectorLabel" text="lima.account"/>
</cell>
<cell anchor="west">
- <JComboBox id="accountSelectorComboBox"
- model="{getModelAccounts()}"
- renderer="{new org.chorem.lima.ui.combobox.AccountRenderer()}"
- onActionPerformed="getHandler().setAccount((Account) accountSelectorComboBox.getSelectedItem())"
- editable="false"
- />
+ <JComboBox javaBean='new org.chorem.lima.ui.accountsreports.AccountComboBox(getHandler())' />
</cell>
</row>
<row>
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -30,7 +30,6 @@
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.combobox.AccountComboBoxModel;
import org.chorem.lima.util.ErrorHelper;
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceFilterTextField.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceFilterTextField.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceFilterTextField.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -0,0 +1,56 @@
+/*
+ * *##% 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 Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.balance;
+
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import javax.swing.JTextField;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class BalanceFilterTextField extends JTextField implements KeyListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log =
+ LogFactory.getLog(BalanceFilterTextField.class);
+
+ protected BalanceViewHandler handler;
+
+ public BalanceFilterTextField(BalanceViewHandler handler) {
+ this.handler = handler;
+ addKeyListener(this);
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ handler.setAccountFilter(getText());
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+}
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -1,5 +1,5 @@
/*
- * *##% Lima Main
+ * *##% Lima Swing
* Copyright (C) 2008 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-08-06 14:01:37 UTC (rev 2997)
@@ -25,9 +25,7 @@
import org.chorem.lima.entity.Account;
import org.apache.commons.lang.time.DateUtils;
import java.util.Calendar;
-
- getRootPane().setDefaultButton(filter);
-
+
// get begin date
Calendar calendarBegin = Calendar.getInstance();
// set begindate to JAN 1 - 0:00.000 of this years
@@ -66,11 +64,10 @@
onActionPerformed="getHandler().setEndDate(endDatePicker.getDate())"/>
</cell>
<cell anchor="east">
- <JTextField id="accountFilter"/>
+ <JLabel text="lima.accountsreports.accountfilter"/>
</cell>
<cell anchor="west">
- <JButton id="filter" text="lima.accountsreports.accountfilter"
- onActionPerformed="getHandler().setAccountFilter(accountFilter.getText())"/>
+ <JTextField javaBean="new org.chorem.lima.ui.balance.BalanceFilterTextField(getHandler())"/>
</cell>
<cell anchor="center">
<JCheckBox id='movmentedFilter' text='lima.accountsreports.movmentedfilter' selected='false'
@@ -78,8 +75,8 @@
</cell>
<cell>
<EnumEditor id='DocumentEditor'
- constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'
- onActionPerformed="getHandler().createDocument()"/>
+ constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'
+ onActionPerformed="getHandler().createDocument()"/>
</cell>
</row>
<row>
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -32,7 +32,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
-import org.chorem.lima.ui.combobox.AccountRenderer;
+import org.chorem.lima.ui.accountsreports.AccountRenderer;
import org.chorem.lima.ui.combobox.SubAccountComboBoxModel;
import org.chorem.lima.util.AccountToString;
import org.chorem.lima.widgets.JWideComboBox;
Deleted: 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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -1,110 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.combobox;
-
-import java.util.List;
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.AccountServiceMonitorable;
-import org.chorem.lima.business.ImportServiceMonitorable;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
-
-/**
- * Account combo box model.
- */
-
-public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener {
-
- private static final long serialVersionUID = 1L;
-
- private static final Log log =
- LogFactory.getLog(FinancialPeriodTableModel.class);
-
- protected Object selectedAccount;
-
- protected List<Account> datasCache;
-
- protected AccountServiceMonitorable accountService;
-
- public AccountComboBoxModel() {
- accountService =
- LimaServiceFactory.getInstance().getService(
- AccountServiceMonitorable.class);
- accountService.addListener(this);
- LimaServiceFactory.getInstance().getService(
- ImportServiceMonitorable.class).addListener(this);
- datasCache = getDataList();
- }
-
- @Override
- public Object getSelectedItem() {
- return selectedAccount;
- }
-
- @Override
- public void setSelectedItem(Object anItem) {
- selectedAccount = anItem;
- fireContentsChanged(this, -1, -1);
- }
-
-
- @Override
- public Object getElementAt(int index) {
- return datasCache.get(index);
- }
-
- @Override
- public int getSize() {
- return datasCache.size();
- }
-
- public List<Account> getDataList(){
- List<Account> result = null;
- try {
- result = accountService.getAllAccounts();
- }
- catch (LimaException eee) {
- if (log.isDebugEnabled()){
- log.debug("Can't get list accounts", eee);
- }
- }
- return result;
-
- }
-
- public void refresh(){
- datasCache = getDataList();
- fireContentsChanged(this, 0, datasCache.size());
- }
-
- @Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (methodeName.contains("Account") || methodeName.contains("importAll")){
- refresh();
- }
- }
-
-
-}
Deleted: 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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -1,44 +0,0 @@
-/* *##% Lima Swing
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.combobox;
-
-import java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JLabel;
-import javax.swing.JList;
-
-import org.chorem.lima.entity.Account;
-
-public class AccountRenderer extends DefaultListCellRenderer {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
-
- JLabel label = new JLabel();
- Account account = (Account) value;
- if (account != null){
- label.setText(account.getAccountNumber()+" - "+account.getLabel());
- }
- return label;
- }
-
-}
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx 2010-08-06 14:01:37 UTC (rev 2997)
@@ -27,7 +27,7 @@
</script>
<row>
- <cell fill="both" weightx="1" weighty="1" rows='5'>
+ <cell fill="both" weightx="1" weighty="1" rows='6'>
<JScrollPane>
<org.jdesktop.swingx.JXTreeTable id="treeTable"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
@@ -64,10 +64,16 @@
enabled="{isSelectedRow()}"/>
</cell>
</row>
- <row>
+ <row>
<cell fill="horizontal">
<JButton id="importButton" text="lima.importexport.import"
onActionPerformed="getHandler().importFinancialStatementChart()"/>
</cell>
</row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="checkButton" text="lima.financialstament.check"
+ onActionPerformed="getHandler().financialStatementChartCheck()"/>
+ </cell>
+ </row>
</Table>
\ No newline at end of file
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -302,6 +302,18 @@
}
+ public void financialStatementChartCheck(){
+ String result;
+ try {
+ result = financialStatementService.checkFinancialStatementChart();
+ DialogHelper.showReportDialog(result, _("lima.financialstatement.check"), view);
+
+ } catch (LimaException e) {
+ log.error("Can't check financialstatement chart",e);
+ }
+
+ }
+
@Override
public void notifyMethod(String serviceName, String methodName) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementHeaderForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementHeaderForm.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementHeaderForm.jaxx 2010-08-06 14:01:37 UTC (rev 2997)
@@ -22,6 +22,21 @@
<script>
<![CDATA[
+ import org.chorem.lima.entity.FinancialStatementImpl;
+ import org.chorem.lima.FinancialStatementWayEnum;
+
+
+ protected void getFinancialStatementWayValue(){
+
+ FinancialStatementWayEnum fSWE =
+ (FinancialStatementWayEnum) wayEnumEditor.getSelectedItem();
+
+ if (fSWE == null){
+ fSWE = FinancialStatementWayEnum.BOTH;
+ }
+ getFinancialStatement().setWay(fSWE);
+ }
+
getRootPane().setDefaultButton(ok);
protected void performCancel() {
setFinancialStatement(null);
@@ -57,6 +72,14 @@
</cell>
</row>
<row>
+ <cell>
+ <EnumEditor id='wayEnumEditor'
+ selectedItem="{getFinancialStatement().getWay()}"
+ constructorParams='org.chorem.lima.FinancialStatementWayEnum.class'
+ onActionPerformed="getFinancialStatementWayValue()"/>
+ </cell>
+ </row>
+ <row>
<cell fill="none">
<JButton text="lima.common.cancel" onActionPerformed="performCancel()"/>
</cell>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetteringView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetteringView.jaxx 2010-08-06 14:01:37 UTC (rev 2997)
@@ -1,122 +0,0 @@
-<!-- ##% Lima Swing
- Copyright (C) 2008 - 2010 CodeLutin
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- ##% -->
-
-<Table fill="both">
- <script>
- <![CDATA[
- import org.chorem.lima.entity.Account;
- import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
- import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
- // Swingx auto complete (for account) :
- AutoCompleteDecorator.decorate(accountComboBox, new ObjectToStringConverter() {
- @Override
- public String getPreferredStringForItem(Object item) {
- if (item == null) {
- return "";
- }
- Account account = (Account) item;
- return account.getAccountNumber() + " : " + account.getLabel();
- }
- });
-
- protected void addLettering() {
- // never been implemented :(
- };
- protected void removeLettering() {
- // never been implemented :(
- };
- ]]>
- </script>
- <row>
- <cell>
- <Table>
- <!-- account -->
- <row fill="horizontal" weightx="1" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.account"/>
- </cell>
- <cell>
- <org.chorem.lima.widgets.JWideComboBox id="accountComboBox"
- model="{new org.chorem.lima.ui.combobox.AccountComboBoxModel()}" />
- </cell>
- </row>
- <!-- from -->
- <row fill="horizontal" weightx="1" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.lettering.from"/>
- </cell>
- <cell>
- <org.chorem.lima.widgets.JWideComboBox id="fromPeriodComoboBox" />
- </cell>
- </row>
- <!-- to -->
- <row fill="horizontal" weightx="1" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.lettering.to"/>
- </cell>
- <cell>
- <org.chorem.lima.widgets.JWideComboBox id="toPeriodComoboBox" />
- </cell>
- </row>
- </Table>
- </cell>
- <cell>
- <!-- entries -->
- <Table fill="both">
- <row columns="3">
- <cell>
- <JLabel text="lima.lettering.entries"/>
- </cell>
- </row>
- <row>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettering.lettered'
- value='{_("lima.lettering.lettered")}' selected='true'/>
- </cell>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettering.notlettered'
- value='{_("lima.lettering.notlettered")}'/>
- </cell>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettering.letteredall'
- value='{_("lima.lettering.letteredall")}'/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row columns="2" weightx="1" weighty="1" anchor="center" fill="both">
- <cell>
- <JScrollPane>
- <org.jdesktop.swingx.JXTable id="letteringTable" />
- </JScrollPane>
- </cell>
- </row>
- <row>
- <cell>
- <!-- add lettering -->
- <JButton id="addButton" text="lima.lettering.add"
- onActionPerformed="addLettering()"/>
- </cell>
- <cell>
- <!-- remove lettering -->
- <JButton id="removeButton" text="lima.lettering.remove"
- onActionPerformed="removeLettering()"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerFilterTextField.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerFilterTextField.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerFilterTextField.java 2010-08-06 14:01:37 UTC (rev 2997)
@@ -0,0 +1,58 @@
+/*
+ * *##% 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 Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.ledger;
+
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import javax.swing.JTextField;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class LedgerFilterTextField extends JTextField implements KeyListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log =
+ LogFactory.getLog(LedgerFilterTextField.class);
+
+ protected LedgerViewHandler handler;
+
+ public LedgerFilterTextField(LedgerViewHandler handler) {
+ this.handler = handler;
+ addKeyListener(this);
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ handler.setAccountFilter(getText());
+
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-08-06 14:01:37 UTC (rev 2997)
@@ -26,8 +26,6 @@
import org.apache.commons.lang.time.DateUtils;
import java.util.Calendar;
- getRootPane().setDefaultButton(filter);
-
// get begin date
Calendar calendarBegin = Calendar.getInstance();
// set begindate to JAN 1 - 0:00.000 of this years
@@ -65,11 +63,10 @@
onActionPerformed="getHandler().setEndDate(endDatePicker.getDate())"/>
</cell>
<cell anchor="east">
- <JTextField id="accountFilter"/>
+ <JLabel text="lima.accountsreports.accountfilter"/>
</cell>
<cell anchor="west">
- <JButton id="filter" text="lima.accountsreports.accountfilter"
- onActionPerformed="getHandler().setAccountFilter(accountFilter.getText())"/>
+ <JTextField javaBean="new org.chorem.lima.ui.ledger.LedgerFilterTextField(getHandler())"/>
</cell>
<cell anchor="center">
<JCheckBox id='movmentedFilter' text='lima.accountsreports.movmentedfilter' selected='false'
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-06 14:01:37 UTC (rev 2997)
@@ -96,8 +96,12 @@
lima.export.all=Export all datas (XML)
lima.export.all.csv=Exporter all datas (CSV)
lima.financialperiod.block=
+lima.financialstament.check=
lima.financialstatement.accounts=
+lima.financialstatement.check=
+lima.financialstatement.credit=
lima.financialstatement.creditaccounts=
+lima.financialstatement.debit=
lima.financialstatement.debitaccounts=
lima.financialstatement.delete=
lima.financialstatement.formula=
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-08-05 10:50:11 UTC (rev 2996)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-06 14:01:37 UTC (rev 2997)
@@ -91,7 +91,10 @@
lima.export.all=Exporter toutes les donn\u00E9es (XML)
lima.export.all.csv=Exporter toutes les donn\u00E9es (CSV)
lima.financialperiod.block=Cloturer une p\u00E9riode
+lima.financialstament.check=
lima.financialstatement.accounts=Liste de comptes au cr\u00E9dit et au d\u00E9bit
+lima.financialstatement.check=
+lima.financialstatement.credit=Sens du poste \: d\u00E9bit
lima.financialstatement.creditaccounts=Liste de comptes au cr\u00E9dit
lima.financialstatement.debitaccounts=Liste de comptes au d\u00E9bit
lima.financialstatement.delete=Supprimer le plan BCR actuel avant d'importer
1
0
Author: jpepin
Date: 2010-08-05 12:50:11 +0200 (Thu, 05 Aug 2010)
New Revision: 2996
Url: http://chorem.org/repositories/revision/lima/2996
Log:
Ajout choix de format sur la servlet : html ou pdf.
Ajout d'une propertie de config vers l'adresse du server dans l'ui.
Ajout dans l'ui appel des documents du serveur http.
Modification d'icones.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FormatsEnum.java
trunk/lima-swing/src/main/resources/icons/action-documents.png
Removed:
trunk/lima-swing/src/main/resources/icons/action-print.png
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java
trunk/lima-business/src/main/resources/lima.properties
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/balance/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.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/FinancialStatementReportView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.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-export-element.png
trunk/lima-swing/src/main/resources/icons/action-import-element.png
trunk/lima-swing/src/main/resources/lima-config.properties
trunk/pom.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -119,7 +119,7 @@
}
}
instance.setOption("topia.persistence.classes", LimaCallaoDAOHelper.getImplementationClassesAsString());
- }
+ }
/**
* Lima option definition.
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -46,7 +46,9 @@
import org.chorem.lima.business.ejbinterface.FinancialStatementService;
import org.chorem.lima.business.ejbinterface.IdentityService;
import org.chorem.lima.business.ejbinterface.ReportService;
+import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.EntryComparator;
+import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
@@ -58,8 +60,6 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.ResourceHandler;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -225,7 +225,7 @@
@Override
- public void createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException {
+ public void createFinancialStatementsDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
List<FinancialStatementAmounts> financialStatementAmounts =
@@ -236,10 +236,16 @@
String dateS = dateFormat.format(newDate);
String hourS = hourFormat.format(newDate);
- PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_financialstatements.pdf"));
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_financialstatements.html"));
+ String filePath = path+File.separator+DocumentsEnum.FINANCIALSTATEMENT.getFileName();
+ FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension());
+ switch (format) {
+ case HTML:
+ HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
+ break;
+ case PDF:
+ PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
+ break;
+ }
document.open();
int nbpages = 1;
@@ -270,11 +276,16 @@
for (List<FinancialStatementAmounts> list : listList) {
String title = list.get(0).getLabel();
//list = list.subList(1, list.size());
- int i=0;
- int n=list.size();
- while (i<n){
- int j=i+35;
- if (j>n){
+ int i = 0;
+ int n = list.size();
+ int max = n;
+ // alloc nb rows max for pdf documents on one page
+ if (format == FormatsEnum.PDF){
+ max = 35;
+ }
+ while (i < n){
+ int j = i + max;
+ if (j > n){
j = n;
}
List <FinancialStatementAmounts> subFinancialStatementAmounts =
@@ -300,7 +311,7 @@
chapter.add(paragraphTable);
//add page
document.add(chapter);
- i=i+35;
+ i = i + max;
nbpages++;
}
}
@@ -444,12 +455,12 @@
@Override
- public void createLedgerDocuments(Date beginDate, Date endDate) throws LimaException {
+ public void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
List<Object> list = new ArrayList<Object>();
try {
- BalanceTrial balanceTrial = reportService.generateLedger(beginDate, endDate, true);
+ BalanceTrial balanceTrial = reportService.generateLedger(beginDate, endDate, null, true);
if (balanceTrial.getReportsDatas() != null){
for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) {
list.add(reportsDatas);
@@ -469,22 +480,31 @@
Double currentAmountCredit = 0.0;
String accountcarry ="";
- PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_ledger.pdf"));
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_ledger.html"));
+ String filePath = path+File.separator+DocumentsEnum.LEDGER.getFileName();
+ FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension());
+ switch (format) {
+ case HTML:
+ HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
+ break;
+ case PDF:
+ PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
+ break;
+ }
document.open();
int nbpages = 1;
Identity identity = identityService.getIdentity();
//create pages
- String title = _("lima-business.document.ledger");
- int i=0;
- int n=list.size();
- int max = 32;
- while (i<n){
- int j = i+max;
- if (j>n){
+ int i = 0;
+ int n = list.size();
+ int max = n;
+ // alloc nb rows max for pdf documents on one page
+ if (format == FormatsEnum.PDF){
+ max = 32;
+ }
+ while (i < n){
+ int j = i + max;
+ if (j > n){
j = n;
}
List <Object> subList = list.subList(i, j);
@@ -493,7 +513,7 @@
//new page
Chapter chapter = new Chapter(0);
//headerPage
- chapter.add(createHeaderPage(title, identity,
+ chapter.add(createHeaderPage(DocumentsEnum.LEDGER.getDescription(), identity,
dateFormat.format(beginDate), dateFormat.format(endDate)));
//n° page
chapter.add(createNumberPage(nbpages, dateS, hourS));
@@ -530,7 +550,7 @@
}
}
//forward amounts
- if (n>max && i<=n-max){
+ if (n > max && i <= n-max){
Paragraph forwardParagraph = new Paragraph();
forwardParagraph.add(createLedgerAmountTable("",
_("lima-business.document.carryforward"),
@@ -538,7 +558,7 @@
chapter.add(forwardParagraph);
}
//final amounts
- if (i>=n-max){
+ if (i >= n-max){
Paragraph finalAmountParagraph = new Paragraph();
finalAmountParagraph.add(createLedgerAmountTable("",
_("lima-business.document.amounts"),
@@ -547,7 +567,7 @@
}
//add page
document.add(chapter);
- i=i+max;
+ i = i + max;
nbpages++;
}
document.close();
@@ -696,7 +716,7 @@
@Override
- public void createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException {
+ public void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
TopiaContext transaction = null;
@@ -706,109 +726,117 @@
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
String hourS = hourFormat.format(newDate);
- String fileDateS = filedateFormat.format(newDate);
- log.debug(path);
- PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_entrybooks.pdf"));
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_entrybooks.html"));
- document.open();
- int nbpages = 1;
+ String filePath = path+File.separator+DocumentsEnum.ENTRYBOOKS.getFileName();
+ FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension());
+ switch (format) {
+ case HTML:
+ HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
+ break;
+ case PDF:
+ PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
+ break;
+ }
+ document.open();
+ int nbpages = 1;
+
+ Identity identity = identityService.getIdentity();
+
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
+ //Split list by financialstatement type
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
+ closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
- Identity identity = identityService.getIdentity();
+ TopiaQuery query = entryDAO.createQuery();
+ String financialPeriodProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.FINANCIAL_PERIOD);
+ String entryBookProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.ENTRY_BOOK);
+ query.addWhere(financialPeriodProperty, Op.EQ,
+ closedPeriodicEntryBook.getFinancialPeriod())
+ .addWhere(entryBookProperty, Op.EQ,
+ closedPeriodicEntryBook.getEntryBook());
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
- LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
- EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
- //Split list by financialstatement type
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
- closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
- for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
-
- TopiaQuery query = entryDAO.createQuery();
- String financialPeriodProperty =
- TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
- FinancialTransaction.FINANCIAL_PERIOD);
- String entryBookProperty =
- TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
- FinancialTransaction.ENTRY_BOOK);
- query.addWhere(financialPeriodProperty, Op.EQ,
- closedPeriodicEntryBook.getFinancialPeriod())
- .addWhere(entryBookProperty, Op.EQ,
- closedPeriodicEntryBook.getEntryBook());
-
- List<Entry> entries = entryDAO.findAllByQuery(query);
-
- List<Object[]> results = new ArrayList<Object[]>();
- Double debit = 0.0;
- Double credit = 0.0;
- query.setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")");
- query.addGroup(Entry.DEBIT);
- results = query.execute(transaction);
- int nbAmount = results.size();
- if(nbAmount==2){
- debit = (Double)results.get(0)[1];
- credit = (Double)results.get(1)[1];
- }
- if (nbAmount==1){
- if ((Boolean)results.get(0)[0]){
- debit = (Double)results.get(0)[1];
- }
- else {
- credit = (Double)results.get(0)[1];
- }
- }
-
- //create pages
- String title = closedPeriodicEntryBook.getEntryBook().getLabel()
- + "\n" + monthYearFormat.format(
- closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
- //list = list.subList(1, list.size());
- int i=0;
- int n=entries.size();
- int max=35;
- while (i<n){
- int j=i+max;
- if (j>n){
- j = n;
- }
- List <Entry> subEntries =
- entries.subList(i, j);
- //create page : header + table + footer
- Table headerTable = createEntryBooksHeaderTable();
- Table table = createEntryBooksTable(subEntries);
- //new page
- Chapter chapter = new Chapter(0);
- //headerPage
- chapter.add(createHeaderPage(title, identity,
- dateFormat.format(beginDate), dateFormat.format(endDate)));
- //n° page
- chapter.add(createNumberPage(nbpages, dateS, hourS));
- //headerTable
- Paragraph paragraphHeaderTable = new Paragraph();
- paragraphHeaderTable.add(headerTable);
- chapter.add(paragraphHeaderTable);
- //table
- Paragraph paragraphTable = new Paragraph();
- paragraphTable.add(table);
- chapter.add(paragraphTable);
- //final amounts
- if (i>=n-max){
- Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createEntryBooksAmountTable(
- _("lima-business.document.amounts"), debit, credit));
- chapter.add(finalAmountParagraph);
- }
- //add page
- document.add(chapter);
- i=i+max;
- nbpages++;
+ List<Entry> entries = entryDAO.findAllByQuery(query);
+
+ List<Object[]> results = new ArrayList<Object[]>();
+ Double debit = 0.0;
+ Double credit = 0.0;
+ query.setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")");
+ query.addGroup(Entry.DEBIT);
+ results = query.execute(transaction);
+ int nbAmount = results.size();
+ if(nbAmount==2){
+ debit = (Double)results.get(0)[1];
+ credit = (Double)results.get(1)[1];
+ }
+ if (nbAmount==1){
+ if ((Boolean)results.get(0)[0]){
+ debit = (Double)results.get(0)[1];
+ }
+ else {
+ credit = (Double)results.get(0)[1];
+ }
+ }
+
+ //create pages
+ String title = closedPeriodicEntryBook.getEntryBook().getLabel()
+ + "\n" + monthYearFormat.format(
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
+ //list = list.subList(1, list.size());
+ int i = 0;
+ int n = entries.size();
+ int max = n;
+ // alloc nb rows max for pdf documents on one page
+ if (format == FormatsEnum.PDF){
+ max = 35;
+ }
+ while (i < n){
+ int j = i + max;
+ if (j > n){
+ j = n;
}
+ List <Entry> subEntries =
+ entries.subList(i, j);
+ //create page : header + table + footer
+ Table headerTable = createEntryBooksHeaderTable();
+ Table table = createEntryBooksTable(subEntries);
+ //new page
+ Chapter chapter = new Chapter(0);
+ //headerPage
+ chapter.add(createHeaderPage(title, identity,
+ dateFormat.format(beginDate), dateFormat.format(endDate)));
+ //n° page
+ chapter.add(createNumberPage(nbpages, dateS, hourS));
+ //headerTable
+ Paragraph paragraphHeaderTable = new Paragraph();
+ paragraphHeaderTable.add(headerTable);
+ chapter.add(paragraphHeaderTable);
+ //table
+ Paragraph paragraphTable = new Paragraph();
+ paragraphTable.add(table);
+ chapter.add(paragraphTable);
+ //final amounts
+ if (i>=n-max){
+ Paragraph finalAmountParagraph = new Paragraph();
+ finalAmountParagraph.add(createEntryBooksAmountTable(
+ _("lima-business.document.amounts"), debit, credit));
+ chapter.add(finalAmountParagraph);
+ }
+ //add page
+ document.add(chapter);
+ i = i + max;
+ nbpages++;
}
+ }
+
+ document.close();
- document.close();
-
} catch (FileNotFoundException eeFNFE) {
log.error("Can't create pdf file", eeFNFE);
} catch (DocumentException eeDE) {
@@ -912,7 +940,7 @@
//############## Balance ##############
@Override
- public void createBalanceDocuments(Date beginDate, Date endDate) throws LimaException {
+ public void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
BalanceTrial balanceTrial =
@@ -931,22 +959,31 @@
Double currentSoldeDebit = 0.0;
Double currentSoldeCredit = 0.0;
- PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_balance.pdf"));
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_balance.html"));
+ String filePath = path+File.separator+DocumentsEnum.BALANCE.getFileName();
+ FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension());
+ switch (format) {
+ case HTML:
+ HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
+ break;
+ case PDF:
+ PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
+ break;
+ }
document.open();
int nbpages = 1;
Identity identity = identityService.getIdentity();
//create pages
- String title = _("lima-business.document.balance");
- int i=0;
- int n=list.size();
- int max = 26;
- while (i<n){
- int j = i+max;
- if (j>n){
+ int i = 0;
+ int n = list.size();
+ int max = n;
+ // alloc nb rows max for pdf documents on one page
+ if (format == FormatsEnum.PDF){
+ max = 26;
+ }
+ while (i < n){
+ int j = i + max;
+ if (j > n){
j = n;
}
List <ReportsDatas> subList = list.subList(i, j);
@@ -955,7 +992,7 @@
//new page
Chapter chapter = new Chapter(0);
//headerPage
- chapter.add(createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate)));
+ chapter.add(createHeaderPage(DocumentsEnum.BALANCE.getDescription(), identity, dateFormat.format(beginDate), dateFormat.format(endDate)));
//n° page
chapter.add(createNumberPage(nbpages, dateS, hourS));
//headerTable
@@ -985,7 +1022,7 @@
reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde();
}
//forward amounts
- if (n>max && i<=n-max){
+ if (n > max && i <= n-max){
Paragraph forwardParagraph = new Paragraph();
forwardParagraph.add(createBalanceAmountTable(
_("lima-business.document.carryforward"),
@@ -994,7 +1031,7 @@
chapter.add(forwardParagraph);
}
//final amounts
- if (i>=n-max){
+ if (i >= n-max){
Paragraph finalAmountParagraph = new Paragraph();
finalAmountParagraph.add(createBalanceAmountTable(
_("lima-business.document.amounts"),
@@ -1004,7 +1041,7 @@
}
//add page
document.add(chapter);
- i=i+max;
+ i = i + max;
nbpages++;
}
document.close();
@@ -1111,7 +1148,7 @@
@Override
- public void createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException {
+ public void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
TopiaContext transaction = null;
@@ -1121,10 +1158,17 @@
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
String hourS = hourFormat.format(newDate);
- PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_general_entybook.pdf"));
- HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream(path+File.separator+"lima_general_entybook.html"));
+
+ String filePath = path+File.separator+DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
+ FileOutputStream fileOut = new FileOutputStream(filePath+format.getExtension());
+ switch (format) {
+ case HTML:
+ HtmlWriter htmlWriter = HtmlWriter.getInstance(document, fileOut);
+ break;
+ case PDF:
+ PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOut);
+ break;
+ }
document.open();
int nbpages = 1;
@@ -1178,11 +1222,11 @@
results = query.execute(transaction);
int nbAmount = results.size();
- if(nbAmount==2){
+ if(nbAmount == 2){
debit = (Double)results.get(0)[1];
credit = (Double)results.get(1)[1];
}
- if (nbAmount==1){
+ if (nbAmount == 1){
if ((Boolean)results.get(0)[0]){
debit = (Double)results.get(0)[1];
}
@@ -1224,12 +1268,16 @@
//create pages
- int i=0;
- int n=list.size();
- int max=35;
- while (i<n){
- int j=i+max;
- if (j>n){
+ int i = 0;
+ int n = list.size();
+ int max = n;
+ // alloc nb rows max for pdf documents on one page
+ if (format == FormatsEnum.PDF){
+ max = 35;
+ }
+ while (i < n){
+ int j = i + max;
+ if (j > n){
j = n;
}
List <GeneralEntryBooksDatas> subList =
@@ -1241,7 +1289,7 @@
Chapter chapter = new Chapter(0);
//headerPage
chapter.add(createHeaderPage(
- _("lima-business.document.generalentrybook"),
+ DocumentsEnum.GENERAL_ENTRYBOOK.getDescription(),
identity, dateFormat.format(beginDate),
dateFormat.format(endDate)));
//n° page
@@ -1256,7 +1304,7 @@
chapter.add(paragraphTable);
//add page
document.add(chapter);
- i=i+max;
+ i = i + max;
nbpages++;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -21,16 +21,9 @@
package org.chorem.lima.business.ejb;
import static org.nuiton.i18n.I18n._;
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.text.ParseException;
@@ -39,13 +32,11 @@
import java.util.Date;
import javax.ejb.EJB;
import javax.ejb.Stateless;
-import javax.imageio.ImageIO;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.logging.Log;
@@ -56,13 +47,10 @@
import org.chorem.lima.business.ejbinterface.HttpServerService;
import org.chorem.lima.business.ejbinterface.HttpServerServiceLocal;
import org.chorem.lima.business.utils.DocumentsEnum;
+import org.chorem.lima.business.utils.FormatsEnum;
import org.mortbay.jetty.Server;
-import org.mortbay.jetty.AbstractGenerator.Output;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.util.Resource;
@@ -71,9 +59,7 @@
private static final Log log =
LogFactory.getLog(HttpServerServiceImpl.class);
-
- private TopiaContext rootContext;
-
+
@EJB
DocumentService documentService;
@@ -81,37 +67,30 @@
protected String path;
+ protected int port;
+
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
public HttpServerServiceImpl() {
- LimaConfig config = LimaConfig.getInstance();
- try {
- rootContext = TopiaContextFactory.getContext(config.getOptions());
- } catch (TopiaNotFoundException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't init topia context", ex);
- }
- }
path = LimaConfig.getInstance().getReportsDir();
-
+ port = LimaConfig.getInstance().getHttpPort();
}
/** start the server */
+ @Override
public void start() {
if (server == null) {
- int port = LimaConfig.getInstance().getHttpPort();
new File(path).mkdir();
- String imagesPath = getClass().getResource("/images").toExternalForm();
try {
server = new Server(port);
Context root = new Context(server, "/", Context.NO_SESSIONS);
root.addServlet(new ServletHolder((Servlet) new MainServlet()), "/");
-
server.start();
+
log.info("Web server are running on port: "+port);
} catch (Exception eee) {
@@ -121,18 +100,31 @@
}
- /** this servlet send a static html page */
+
+ @Override
+ public int getHttpPort() {
+ return port;
+ }
+
+
+ /** this servlet send a static html page */
public class MainServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
String serverAddressConfig = LimaConfig.getInstance().getAddressServer();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ //get all params
String imageParam = req.getParameter("img");
- log.info(imageParam);
+ String model = req.getParameter("model");
+ String format = req.getParameter("format");
+ String beginDate = req.getParameter("beginDate");
+ String endDate = req.getParameter("endDate");
+
+ //if image
if (imageParam != null){
URL image = Resource.getURLOrNull("images/"+imageParam);
- log.info("image :"+image);
if (image != null){
resp.setContentType("image/png");
InputStream in = image.openStream();
@@ -140,8 +132,51 @@
IOUtils.copy(in, out);
}
}
+ //if doc pdf or html
+ else if (model != null && format != null && beginDate != null && endDate != null){
+ FormatsEnum formatsEnum = FormatsEnum.valueOfExtension(format);
+ URL doc = new URL("file:" + path + File.separator
+ + model +formatsEnum.getExtension());
+ //create docs
+ try {
+ Date beginDateFormat = dateFormat.parse(beginDate);
+ Date endDateFormat = dateFormat.parse(endDate);
+
+ switch (DocumentsEnum.valueOfLink(model)) {
+ case BALANCE:
+ documentService.createBalanceDocuments(
+ beginDateFormat, endDateFormat, formatsEnum);
+ break;
+ case ENTRYBOOKS:
+ documentService.createEntryBooksDocuments(
+ beginDateFormat, endDateFormat, formatsEnum);
+ break;
+ case FINANCIALSTATEMENT:
+ documentService.createFinancialStatementsDocuments(
+ beginDateFormat, endDateFormat, formatsEnum);
+ break;
+ case GENERAL_ENTRYBOOK:
+ documentService.createGeneralEntryBooksDocuments(
+ beginDateFormat, endDateFormat, formatsEnum);
+ break;
+ case LEDGER:
+ documentService.createLedgerDocuments(
+ beginDateFormat, endDateFormat, formatsEnum);
+ break;
+ }
+ } catch (LimaException eeeLE) {
+ log.error("Can't call document service for create html document", eeeLE);
+ } catch (ParseException eeePE) {
+ log.error("Can't parse date", eeePE);
+ }
+ resp.setContentType(formatsEnum.getMimeType());
+ InputStream in = doc.openStream();
+ OutputStream out = resp.getOutputStream();
+ IOUtils.copy(in, out);
+ }
+ // else return home html
else {
- resp.setContentType("text/html");
+ resp.setContentType(FormatsEnum.HTML.getMimeType());
String pageContent = "";
String serverAdress = "http://";
@@ -149,94 +184,73 @@
/** create server Address : static config if exist or dynamical adress */
if (serverAddressConfig.equals("")){
- serverAdress += req.getServerName() + ":" + req.getServerPort();
+ serverAdress += req.getServerName()
+ + ":" + req.getServerPort();
}
else {
serverAdress += serverAddressConfig + ":"
+ LimaConfig.getInstance().getHttpPort();
}
-
- String link = req.getParameter("link");
- String beginDate = req.getParameter("beginDate");
- String endDate = req.getParameter("endDate");
-
- if (link != null && beginDate != null && endDate != null){
- try {
- Date beginDateFormat = dateFormat.parse(beginDate);
- Date endDateFormat = dateFormat.parse(endDate);
- switch (DocumentsEnum.valueOfLink(link)) {
- case BALANCE:
- documentService.createBalanceDocuments(beginDateFormat, endDateFormat);
- break;
- case ENTRYBOOKS:
- documentService.createEntryBooksDocuments(beginDateFormat, endDateFormat);
- break;
- case FINANCIALSTATEMENT:
- documentService.createFinancialStatementsDocuments(beginDateFormat, endDateFormat);
- break;
- case GENERAL_ENTRYBOOK:
- documentService.createGeneralEntryBooksDocuments(beginDateFormat, endDateFormat);
- break;
- case LEDGER:
- documentService.createLedgerDocuments(beginDateFormat, endDateFormat);
- break;
- }
- } catch (LimaException eeeLE) {
- log.error("Can't call document service for create html document", eeeLE);
- } catch (ParseException eeePE) {
- log.error("Can't parse date", eeePE);
- }
- pageContent = extractFile(path+File.separatorChar+link);
- }
- else {
-
- Calendar calendar = Calendar.getInstance();
- Date endDatePicker = calendar.getTime();
- Date beginDatePicker = calendar.getTime();
- beginDatePicker = DateUtils.truncate(beginDatePicker, Calendar.YEAR);
-
- pageContent = "<!DOCTYPE html>\n"
- + "<html lang=\"fr\">\n"
- + "<head>\n"
- + "<title>LIMA Documents Report</title>\n"
- + "<style type=\"text/css\">"
- + "body { font: 14px sans-serif; }"
- + "h1 { font: 20px sans-serif; text-align: center; }"
- + "table.paddingleft td {padding-left:100px;}"
- + ".tdright {text-align: right;}"
- + "</style>"
- + "</head>\n"
- + "<body>\n"
- + "<table class=\"paddingleft\">\n"
- + "<tr><td colspan=2><h1>LIMA Documents Report</h1></td></tr>\n"
- + "<tr><td><img src=\"?img=identity.png\"/></td>\n"
- + "<td rowspan=3><form method=GET action=" + serverAdress + ">\n"
- + _("lima-business.document.date.begin") + "<input value=\""+dateFormat.format(beginDatePicker)
- + "\" type=\"date\" name=\"beginDate\">\n"
- + _("lima-business.document.date.end") + "<input value=\""+dateFormat.format(endDatePicker)
- + "\" type=\"date\" name=\"endDate\">\n<br/><br/>"
- + "Documents : <select name=\"link\">";
-
- for (DocumentsEnum documentsEnum : DocumentsEnum.values()) {
- pageContent += "<option value=\""+documentsEnum.getLink()+"\">"
- + documentsEnum.getDescription()+"</OPTION>\n";
- }
-
- pageContent += "<tr><td><img src=\"?img=entries.png\"/></td></tr>\n"
- + "<tr><td><img src=\"?img=accounts.png\"/></td></tr>\n"
- + "<tr><td><img src=\"?img=entrybooks.png\"/></td>\n"
- + "</select>\n<br/><br/>"
- + "<td class=\"tdright\"><input type=\"submit\"></td></tr>"
- + "</form>\n"
- + "<tr><td><img src=\"?img=fiscalperiods.png\"/></td></tr>\n"
- + "</table>\n"
- + "</body>\n"
- + "</html>";
- }
-
- resp.getWriter().write(pageContent);
+ Calendar calendar = Calendar.getInstance();
+ Date endDatePicker = calendar.getTime();
+ Date beginDatePicker = calendar.getTime();
+ beginDatePicker =
+ DateUtils.truncate(beginDatePicker, Calendar.YEAR);
+
+ pageContent = "<!DOCTYPE html>\n"
+ + "<html lang=\"fr\">\n"
+ + "<head>\n"
+ + "<title>LIMA Documents Report</title>\n"
+ + "<style type=\"text/css\">"
+ + "body { font: 14px sans-serif; }"
+ + "h1 { font: 20px sans-serif; text-align: center; }"
+ + "table.paddingleft td {padding-left:100px;}"
+ + ".tdright {text-align: right;}"
+ + "</style>"
+ + "</head>\n"
+ + "<body>\n"
+ + "<table class=\"paddingleft\">\n"
+ + "<tr><td colspan=2><h1>LIMA Documents Report</h1></td></tr>\n"
+ + "<tr><td><img src=\"?img=identity.png\"/></td>\n"
+ + "<td rowspan=3><form method=GET action="
+ + serverAdress + ">\n"
+ + _("lima-business.document.date.begin")
+ + "<input value=\""+dateFormat.format(beginDatePicker)
+ + "\" type=\"date\" name=\"beginDate\">\n"
+ + _("lima-business.document.date.end")
+ + "<input value=\""+dateFormat.format(endDatePicker)
+ + "\" type=\"date\" name=\"endDate\">\n<br/><br/>"
+ + "Format : <select name=\"format\">";
+
+ for (FormatsEnum formatsEnum : FormatsEnum.values()) {
+ pageContent += "<option value=\""
+ + formatsEnum.getExtension()+"\">"
+ + formatsEnum.getDescription()+"</option>\n";
+ }
+
+ pageContent += "</select>\n"
+ + "Documents : <select name=\"model\">";
+
+ for (DocumentsEnum documentsEnum : DocumentsEnum.values()) {
+ pageContent += "<option value=\""
+ + documentsEnum.getFileName()+"\">"
+ + documentsEnum.getDescription()+"</option>\n";
+ }
+
+ pageContent += "</select>\n"
+ + "<tr><td><img src=\"?img=entries.png\"/></td></tr>\n"
+ + "<tr><td><img src=\"?img=accounts.png\"/></td></tr>\n"
+ + "<tr><td><img src=\"?img=entrybooks.png\"/></td>\n"
+ + "<td class=\"tdright\"><input type=\"submit\"></td></tr>"
+ + "</form>\n"
+ + "<tr><td><img src=\"?img=fiscalperiods.png\"/></td></tr>\n"
+ + "</table>\n"
+ + "</body>\n"
+ + "</html>";
+ resp.getWriter().write(pageContent);
+
}
}
@Override
@@ -246,20 +260,5 @@
}
}
-
- public String extractFile(String filePath){
- char[] datas = new char[(int) new File(filePath).length()];
- try {
- BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)));
- in.read(datas);
- in.close();
- }
- catch (IOException eee) {
- if (log.isDebugEnabled()){
- log.debug("Can't read file "+filePath, eee);
- }
- }
- return new String(datas);
- }
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -492,8 +492,8 @@
* Get all entries
*/
@Override
- public BalanceTrial generateLedger(Date beginDate, Date endDate, Boolean movementedFilter) throws LimaException {
- return generateBalanceTrial(beginDate, endDate, null, true, movementedFilter);
+ public BalanceTrial generateLedger(Date beginDate, Date endDate, String selectedAccounts, Boolean movementedFilter) throws LimaException {
+ return generateBalanceTrial(beginDate, endDate, selectedAccounts, true, movementedFilter);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -20,9 +20,9 @@
package org.chorem.lima.business.ejbinterface;
import java.util.Date;
-import java.util.List;
import javax.ejb.Remote;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.utils.FormatsEnum;
/**
* Interface to create pdf and html docs
@@ -33,10 +33,10 @@
@Remote
public interface DocumentService {
- public void createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException;
- public void createLedgerDocuments(Date beginDate, Date endDate) throws LimaException;
- public void createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
- public void createBalanceDocuments(Date beginDate, Date endDate) throws LimaException;
- public void createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+ public void createFinancialStatementsDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ public void createLedgerDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ public void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ public void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
+ public void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -26,5 +26,6 @@
public interface HttpServerService {
public void start();
+ public int getHttpPort();
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -68,7 +68,7 @@
*
* @throws LimaException
*/
- BalanceTrial generateLedger(Date beginDate, Date endDate, Boolean movementedFilter) throws LimaException;
+ BalanceTrial generateLedger(Date beginDate, Date endDate, String selectedAccounts, Boolean movementedFilter) throws LimaException;
/**
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -1,3 +1,23 @@
+/* *##% 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 static org.nuiton.i18n.I18n._;
@@ -4,24 +24,24 @@
public enum DocumentsEnum {
-
- ENTRYBOOKS(_("lima-business.document.entrybook"),"lima_entrybooks.html"),
- GENERAL_ENTRYBOOK(_("lima-business.document.generalentrybook"),"lima_general_entybook.html"),
- FINANCIALSTATEMENT(_("lima-business.document.financialstatement"),"lima_financialstatements.html"),
- BALANCE(_("lima-business.document.balance"),"lima_balance.html"),
- LEDGER(_("lima-business.document.ledger"),"lima_ledger.html");
- private final String link;
+ GENERAL_ENTRYBOOK(_("lima-business.document.generalentrybook"),"lima_general_entybook"),
+ ENTRYBOOKS(_("lima-business.document.entrybook"),"lima_entrybooks"),
+ BALANCE(_("lima-business.document.balance"),"lima_balance"),
+ LEDGER(_("lima-business.document.ledger"),"lima_ledger"),
+ FINANCIALSTATEMENT(_("lima-business.document.financialstatement"),"lima_financialstatements");
+ private final String fileName;
+
private final String description;
- private DocumentsEnum(String description, String link) {
+ private DocumentsEnum(String description, String fileName) {
this.description = description;
- this.link = link;
+ this.fileName = fileName;
}
- public String getLink() {
- return this.link;
+ public String getFileName() {
+ return this.fileName;
}
public String getDescription() {
@@ -32,7 +52,7 @@
DocumentsEnum value = null;
for (DocumentsEnum documentsEnum : DocumentsEnum.values()) {
- if (label.equals(documentsEnum.link)){
+ if (label.equals(documentsEnum.fileName)){
value = documentsEnum;
break;
}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FormatsEnum.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FormatsEnum.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FormatsEnum.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -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.utils;
+
+public enum FormatsEnum {
+
+ HTML(".html","text/html", "Page Html"),
+ PDF(".pdf","application/pdf", "Document PDF");
+
+ private final String extension;
+ private final String mimeType;
+ private final String description;
+
+ private FormatsEnum(String extension, String mimeType, String description) {
+ this.extension = extension;
+ this.mimeType = mimeType;
+ this.description = description;
+ }
+
+ public String getExtension() {
+ return this.extension;
+ }
+
+ public String getMimeType() {
+ return this.mimeType;
+ }
+
+ public String getDescription(){
+ return this.description;
+ }
+
+ public static FormatsEnum valueOfExtension(String extension){
+ FormatsEnum value = null;
+
+ for (FormatsEnum formatsEnum : FormatsEnum.values()) {
+ if (extension.equals(formatsEnum.getExtension())){
+ value = formatsEnum;
+ break;
+ }
+ }
+ return value;
+ }
+
+
+}
Modified: trunk/lima-business/src/main/resources/lima.properties
===================================================================
--- trunk/lima-business/src/main/resources/lima.properties 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-business/src/main/resources/lima.properties 2010-08-05 10:50:11 UTC (rev 2996)
@@ -1,6 +1,6 @@
#LIMA Defaults values
# main directory
-lima.dir=${user.home}/.lima/
+lima.dir=${user.home}/.lima
# http port for reports
lima.httpport=5462
# server address (optional for server behind proxy)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.actions.MiscAction;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.util.Version;
@@ -45,7 +46,11 @@
* to use log facility, just put in your code: log.info(\"...\");
*/
static private Log log = LogFactory.getLog(LimaConfig.class);
-
+
+ protected static LimaConfig instance;
+
+ private static final String configFile = "lima-config.properties";
+
/**
* La version du logiciel.
*/
@@ -99,9 +104,27 @@
//getLimaUserDirectory().mkdirs();
}
- /*
- * @see org.nuiton.util.ApplicationConfig#parse(java.lang.String[])
- */
+ public static LimaConfig getInstance() {
+ if (instance == null) {
+ instance = new LimaConfig();
+ instance.loadConfiguration(configFile);
+ }
+ return instance;
+ }
+
+ protected void loadConfiguration(String configFileName){
+
+ instance.setConfigFileName(configFileName);
+ try {
+ instance.parse(new String[0]);
+ } catch (ArgumentsParserException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't read configuration", ex);
+ }
+ }
+ instance.setOption("topia.persistence.classes", LimaCallaoDAOHelper.getImplementationClassesAsString());
+}
+
@Override
public void parse(String[] args) throws ArgumentsParserException {
@@ -205,9 +228,8 @@
public String getHostAdress() {
return getOption(Option.LIMA_HOST_ADDRESS.key);
- }
+ }
-
/**
* Used in ????
*/
@@ -249,7 +271,7 @@
LAUNCH_UI("lima.ui.launchui", _("lima.config.ui.flaunchui.description"), "true", Boolean.class, true, true),
SUPPORT_EMAIL("lima.misc.supportemail", _("lima.misc.supportemail.description"), "", String.class, false, false),
OPENEJB_REMOTEMODE("lima.openejb.remotemode", _("lima.openejb.remotemode.description"), "false", String.class, false, false),
- LIMA_HOST_ADDRESS("lima.host.address", _("lima.config.host.adress"), "", String.class, false, false);
+ LIMA_HOST_ADDRESS("lima.host.address", _("lima.config.host.adress"), "localhost", String.class, false, false);
public final String key;
public final String description;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -21,29 +21,21 @@
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;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountServiceMonitorable;
import org.chorem.lima.business.HttpServerServiceMonitorable;
import org.chorem.lima.business.ejbinterface.AccountService;
-import org.chorem.lima.business.ejbinterface.HttpServerService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
import org.chorem.lima.ui.MainViewHandler;
import org.chorem.lima.ui.opening.OpeningView;
-import org.chorem.lima.ui.opening.OpeningViewHandler;
import org.chorem.lima.util.ErrorHelper;
import org.nuiton.i18n.I18n;
import org.nuiton.util.StringUtil;
-import org.nuiton.util.converter.ConverterUtil;
/**
* Lima main.
@@ -175,7 +167,7 @@
// if not, call #loadDefaultAccount()
splash.updateProgression(0.5, _("Loading accounting..."));
- //start servlet
+ //start http server
LimaServiceFactory.getInstance().getService(HttpServerServiceMonitorable.class).start();
AccountService accountService =
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-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
@@ -29,6 +29,8 @@
import org.chorem.lima.enums.ImportExportEnum;
import java.net.URISyntaxException;
import java.net.URI;
+ import org.chorem.lima.business.HttpServerServiceMonitorable;
+ import org.chorem.lima.service.LimaServiceFactory;
public LimaConfig getConfig() {
return getContextValue(LimaConfig.class);
@@ -41,21 +43,19 @@
public boolean acceptLocale(Locale l, String expected) {
return l != null && l.toString().equals(expected);
}
-
- URI uri = null;
- try {
- uri = new URI("http://localhost:5462/");
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- public void loadURI(){
- try {
- desktop.browse(uri);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ public void loadURI(){
+ try {
+ int port = LimaServiceFactory.getInstance().getService(
+ HttpServerServiceMonitorable.class).getHttpPort();
+ String address = LimaConfig.getInstance().getHostAdress();
+ String url = "http://"+address+":"+port+"/";
+ desktop.browse(new URI(url));
+ } catch (IOException e) {
+ log.error("Can't open browser",e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create URI",e);
+ }
}
/**
@@ -101,7 +101,7 @@
<JMenuBar>
<JMenu text="lima.menu.file">
- <JMenu text="lima.importexport.lima">
+ <JMenu text="lima.importexport.csv">
<JMenu text="lima.importexport.import" actionIcon='import-element'>
<JMenuItem text="lima.importexport.all" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_ALL_IMPORT)'/>
<JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT)'/>
@@ -126,7 +126,7 @@
</JMenu>
</JMenu>
<JSeparator/>
- <JMenuItem text="lima.documents.html"
+ <JMenuItem actionIcon='documents' text="lima.documents"
onActionPerformed="loadURI()"/>
<JSeparator/>
<JMenuItem text="lima.identity"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
@@ -26,6 +26,8 @@
import org.apache.commons.lang.time.DateUtils;
import java.util.Calendar;
+ getRootPane().setDefaultButton(filter);
+
// get begin date
Calendar calendarBegin = Calendar.getInstance();
// set begindate to JAN 1 - 0:00.000 of this years
@@ -67,16 +69,18 @@
<JTextField id="accountFilter"/>
</cell>
<cell anchor="west">
- <JButton text="lima.accountsreports.accountfilter"
+ <JButton id="filter" text="lima.accountsreports.accountfilter"
onActionPerformed="getHandler().setAccountFilter(accountFilter.getText())"/>
</cell>
<cell anchor="center">
<JCheckBox id='movmentedFilter' text='lima.accountsreports.movmentedfilter' selected='false'
onActionPerformed="getHandler().refresh()"/>
</cell>
- <cell>
- <JButton text="lima.createPDF" onActionPerformed="getHandler().createPdf()"/>
- </cell>
+ <cell>
+ <EnumEditor id='DocumentEditor'
+ constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'
+ onActionPerformed="getHandler().createDocument()"/>
+ </cell>
</row>
<row>
<cell fill="both" weightx="1" weighty="1" columns="8">
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-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -19,16 +19,24 @@
package org.chorem.lima.ui.balance;
import static org.nuiton.i18n.I18n._;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.BalanceTrial;
-import org.chorem.lima.business.DocumentServiceMonitorable;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
+import org.chorem.lima.business.HttpServerServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ReportServiceMonitorable;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.utils.DocumentsEnum;
+import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.util.ErrorHelper;
@@ -46,7 +54,7 @@
/** Services. */
protected ReportServiceMonitorable reportService;
- protected DocumentServiceMonitorable documentService;
+ protected HttpServerServiceMonitorable httpServerServiceMonitorable;
/** DatePicker Begin Date. */
protected Date selectedBeginDate;
@@ -58,16 +66,20 @@
protected String selectedAccounts;
protected BalanceTableModel model;
-
+
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
+
+ protected int port;
+
protected BalanceViewHandler(BalanceView view) {
this.view = view;
reportService =
LimaServiceFactory.getInstance().getService(
ReportServiceMonitorable.class);
- documentService =
- LimaServiceFactory.getInstance().getService(
- DocumentServiceMonitorable.class);
+ port = LimaServiceFactory.getInstance().getService(
+ HttpServerServiceMonitorable.class).getHttpPort();
LimaServiceFactory.getInstance().getService(
ImportServiceMonitorable.class).addListener(this);
LimaServiceFactory.getInstance().getService(
@@ -141,13 +153,20 @@
}
}
- public void createPdf() {
+ public void createDocument() {
+
+ FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
+ String address = LimaConfig.getInstance().getHostAdress();
+
try {
- documentService.createBalanceDocuments(selectedBeginDate, selectedEndDate);
- } catch (LimaException eee) {
- if(log.isDebugEnabled()){
- log.debug("Can't create PDF", eee);
- }
+ String url = "http://"+address+":"+port+"/?beginDate="+dateFormat.format(selectedBeginDate)
+ +"&endDate="+dateFormat.format(selectedEndDate)+"&format="+selectedEnum.getExtension()+"&model="
+ + DocumentsEnum.BALANCE.getFileName();
+ Desktop.getDesktop().browse(new URI(url));
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create news URI", e);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
@@ -75,7 +75,9 @@
/>
</cell>
<cell>
- <JButton text="lima.createPDF" onActionPerformed="getHandler().createPdf()"/>
+ <EnumEditor id='DocumentEditor'
+ constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'
+ onActionPerformed="getHandler().createDocument()"/>
</cell>
</row>
<row>
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-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -20,18 +20,27 @@
import static org.nuiton.i18n.I18n._;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.beans.ReportsDatasImpl;
import org.chorem.lima.business.DocumentServiceMonitorable;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
+import org.chorem.lima.business.HttpServerServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ReportServiceMonitorable;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.utils.DocumentsEnum;
+import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
@@ -67,6 +76,11 @@
/** EndDate. */
protected Date selectedEndDate;
+
+ protected int port;
+
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
protected EntryBooksReportsViewHandler(EntryBooksReportsView view) {
this.view = view;
@@ -74,6 +88,8 @@
reportService =
LimaServiceFactory.getInstance().getService(
ReportServiceMonitorable.class);
+ port = LimaServiceFactory.getInstance().getService(
+ HttpServerServiceMonitorable.class).getHttpPort();
documentService =
LimaServiceFactory.getInstance().getService(
DocumentServiceMonitorable.class);
@@ -148,14 +164,28 @@
}
}
- public void createPdf() {
+
+
+ public void createDocument() {
+
+ FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
+ String address = LimaConfig.getInstance().getHostAdress();
+
try {
- documentService.createEntryBooksDocuments(selectedBeginDate, selectedEndDate);
- documentService.createGeneralEntryBooksDocuments(selectedBeginDate, selectedEndDate);
- } catch (LimaException eee) {
- if(log.isDebugEnabled()){
- log.debug("Can't create PDF", eee);
- }
+ String url = "http://"+address+":"+port+"/?beginDate="+dateFormat.format(selectedBeginDate)
+ +"&endDate="+dateFormat.format(selectedEndDate)+"&format="+selectedEnum.getExtension()+"&model="
+ + DocumentsEnum.ENTRYBOOKS.getFileName();
+ Desktop.getDesktop().browse(new URI(url));
+
+ String url2 = "http://"+address+":"+port+"/?beginDate="+dateFormat.format(selectedBeginDate)
+ +"&endDate="+dateFormat.format(selectedEndDate)+"&format="+selectedEnum.getExtension()+"&model="
+ + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
+ Desktop.getDesktop().browse(new URI(url2));
+
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create news URI", e);
}
}
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-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -20,18 +20,28 @@
package org.chorem.lima.ui.financialstatementreport;
import static org.nuiton.i18n.I18n._;
+
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
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.LimaConfig;
import org.chorem.lima.beans.FinancialStatementAmounts;
import org.chorem.lima.business.DocumentServiceMonitorable;
import org.chorem.lima.business.FinancialStatementServiceMonitorable;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
+import org.chorem.lima.business.HttpServerServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.utils.DocumentsEnum;
+import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.util.ErrorHelper;
@@ -63,6 +73,11 @@
/** DatePicker EndDate. */
protected Date selectedEndDate;
+ protected int port;
+
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
+
/** data cache */
protected List<FinancialStatementAmounts> cacheDataList;
@@ -73,7 +88,10 @@
financialStatementService =
LimaServiceFactory.getInstance().getService(
FinancialStatementServiceMonitorable.class);
+
financialStatementService.addListener(this);
+ port = LimaServiceFactory.getInstance().getService(
+ HttpServerServiceMonitorable.class).getHttpPort();
LimaServiceFactory.getInstance().getService(
ImportServiceMonitorable.class).addListener(this);
LimaServiceFactory.getInstance().getService(
@@ -208,16 +226,23 @@
fireTableDataChanged();
}
- public void createDocuments(){
+
+ public void createDocument(FormatsEnum formatsEnum) {
+
+ String address = LimaConfig.getInstance().getHostAdress();
+
try {
- documentService.createFinancialStatementsDocuments(selectedBeginDate, selectedEndDate);
- } catch (LimaException e) {
- if (log.isDebugEnabled()){
- log.debug("Error on create document",e);
- }
+ String url = "http://"+address+":"+port+"/?beginDate="+dateFormat.format(selectedBeginDate)
+ +"&endDate="+dateFormat.format(selectedEndDate)+"&format="+formatsEnum.getExtension()+"&model="
+ + DocumentsEnum.FINANCIALSTATEMENT.getFileName();
+ Desktop.getDesktop().browse(new URI(url));
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create news URI", e);
}
}
-
+
@Override
public void notifyMethod(String serviceName, String methodeName) {
if (serviceName.contains("FinancialTransaction") || methodeName.contains("FinancialStatement") || methodeName.contains("importAll")){
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
@@ -66,7 +66,9 @@
getHandler().refresh()"/>
</cell>
<cell>
- <JButton text="lima.createPDF" onActionPerformed="getHandler().createPdf()"/>
+ <EnumEditor id='DocumentEditor'
+ constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'
+ onActionPerformed="getHandler().createDocument()"/>
</cell>
</row>
<row>
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-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -18,8 +18,17 @@
package org.chorem.lima.ui.financialstatementreport;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.business.utils.DocumentsEnum;
+import org.chorem.lima.business.utils.FormatsEnum;
+
+
/**
* Handler associated with accounts reports view.
*
@@ -48,7 +57,10 @@
return view;
}
- public void createPdf() {
- model.createDocuments();
+ public void createDocument() {
+
+ FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
+ model.createDocument(selectedEnum);
+
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-08-05 10:50:11 UTC (rev 2996)
@@ -26,6 +26,8 @@
import org.apache.commons.lang.time.DateUtils;
import java.util.Calendar;
+ getRootPane().setDefaultButton(filter);
+
// get begin date
Calendar calendarBegin = Calendar.getInstance();
// set begindate to JAN 1 - 0:00.000 of this years
@@ -62,13 +64,22 @@
<org.jdesktop.swingx.JXDatePicker id="endDatePicker"
onActionPerformed="getHandler().setEndDate(endDatePicker.getDate())"/>
</cell>
- <cell>
- <JButton text="lima.createPDF" onActionPerformed="getHandler().createPdf()"/>
+ <cell anchor="east">
+ <JTextField id="accountFilter"/>
</cell>
+ <cell anchor="west">
+ <JButton id="filter" text="lima.accountsreports.accountfilter"
+ onActionPerformed="getHandler().setAccountFilter(accountFilter.getText())"/>
+ </cell>
<cell anchor="center">
<JCheckBox id='movmentedFilter' text='lima.accountsreports.movmentedfilter' selected='false'
onActionPerformed="getHandler().refresh()"/>
</cell>
+ <cell>
+ <EnumEditor id='DocumentEditor'
+ constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'
+ onActionPerformed="getHandler().createDocument()"/>
+ </cell>
</row>
<row>
<cell fill="both" weightx="1" weighty="1" columns="8">
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-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-08-05 10:50:11 UTC (rev 2996)
@@ -20,6 +20,11 @@
import static org.nuiton.i18n.I18n._;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -27,15 +32,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.DocumentServiceMonitorable;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
+import org.chorem.lima.business.HttpServerServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ReportServiceMonitorable;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.EntryComparator;
+import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
@@ -68,8 +77,16 @@
/** EndDate. */
protected Date selectedEndDate;
+ /** Text field Accounts */
+ protected String selectedAccounts;
+
protected BalanceTrial balanceTrialCache;
+
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
+ protected int port;
+
protected List<Object> cachedatasList;
protected LedgerViewHandler(LedgerView view) {
@@ -79,6 +96,8 @@
LimaServiceFactory.getInstance().getService(
ReportServiceMonitorable.class);
reportService.addListener(this);
+ port = LimaServiceFactory.getInstance().getService(
+ HttpServerServiceMonitorable.class).getHttpPort();
documentService =
LimaServiceFactory.getInstance().getService(
DocumentServiceMonitorable.class);
@@ -96,6 +115,11 @@
selectedEndDate = date;
}
+ public void setAccountFilter(String accounts) {
+ selectedAccounts = accounts;
+ refresh();
+ }
+
/**
* get all account fot the selected period
* @return
@@ -103,7 +127,8 @@
public List<Object> getDataList(){
List<Object> results = new ArrayList<Object>();
try {
- balanceTrialCache = reportService.generateLedger(selectedBeginDate, selectedEndDate, view.getMovmentedFilter().isSelected());
+ balanceTrialCache = reportService.generateLedger(selectedBeginDate,
+ selectedEndDate, selectedAccounts, view.getMovmentedFilter().isSelected());
if (balanceTrialCache.getReportsDatas() != null){
for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) {
results.add(reportsDatas);
@@ -158,13 +183,20 @@
}
}
- public void createPdf() {
+ public void createDocument() {
+
+ FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
+ String address = LimaConfig.getInstance().getHostAdress();
+
try {
- documentService.createLedgerDocuments(selectedBeginDate, selectedEndDate);
- } catch (LimaException eee) {
- if(log.isDebugEnabled()){
- log.debug("Can't create PDF", eee);
- }
+ String url = "http://"+address+":"+port+"/?beginDate="+dateFormat.format(selectedBeginDate)
+ +"&endDate="+dateFormat.format(selectedEndDate)+"&format="+selectedEnum.getExtension()+"&model="
+ + DocumentsEnum.LEDGER.getFileName();
+ Desktop.getDesktop().browse(new URI(url));
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create news URI", e);
}
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-05 10:50:11 UTC (rev 2996)
@@ -61,6 +61,7 @@
lima.config.category.other.description=
lima.config.configFileName.description=
lima.config.host.adress=
+lima.config.host.httpport=
lima.config.locale.description=
lima.config.ui.flaunchui.description=
lima.config.ui.fullscreen.description=
@@ -71,6 +72,7 @@
lima.debit=Debit
lima.description=Description
lima.dialogreport=
+lima.documents=
lima.documents.html=
lima.entries=Entries
lima.entries.addtransaction=
@@ -129,6 +131,7 @@
lima.importexport.accountcharts=
lima.importexport.all=
lima.importexport.choiceencoding=
+lima.importexport.csv=
lima.importexport.ebp=
lima.importexport.entries=
lima.importexport.entrybooks=
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-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-05 10:50:11 UTC (rev 2996)
@@ -57,6 +57,7 @@
lima.config.category.other.description=Autre propri\u00E9t\u00E9s de configuration
lima.config.configFileName.description=
lima.config.host.adress=
+lima.config.host.httpport=
lima.config.locale.description=Locale utilis\u00E9e par l'application
lima.config.ui.flaunchui.description=
lima.config.ui.fullscreen.description=
@@ -67,7 +68,7 @@
lima.debit=Debit
lima.description=Description
lima.dialogreport=
-lima.documents.html=
+lima.documents=Documents\u0085
lima.entries=Traitement
lima.entries.addtransaction=Saisir des \u00E9critures
lima.entries.lettering=Ajouter une lettre
@@ -120,6 +121,7 @@
lima.importexport.accountcharts=Plan des comptes
lima.importexport.all=Tout
lima.importexport.choiceencoding=Choisir encodage \:
+lima.importexport.csv=Import/Export CSV
lima.importexport.ebp=Import/Export EBP
lima.importexport.entries=\u00C9critures
lima.importexport.entrybooks=Journaux
@@ -129,7 +131,6 @@
lima.importexport.import.terminated=Import termin\u00E9
lima.importexport.importcsv=Import CSV
lima.importexport.importebp=Import EBP
-lima.importexport.lima=Import/Export Lima
lima.importexport.wait=Traitement en cours \u2026
lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s
lima.init.errorclosing=
Added: trunk/lima-swing/src/main/resources/icons/action-documents.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-documents.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/lima-swing/src/main/resources/icons/action-export-element.png
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/resources/icons/action-import-element.png
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/src/main/resources/icons/action-print.png
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/resources/lima-config.properties
===================================================================
--- trunk/lima-swing/src/main/resources/lima-config.properties 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/lima-swing/src/main/resources/lima-config.properties 2010-08-05 10:50:11 UTC (rev 2996)
@@ -18,7 +18,7 @@
lima.openejb.remotemode=false
java.naming.factory.initial=org.openejb.client.LocalInitialContextFactory
-#Lima Accounting Host address
+#Lima Accounting Host
lima.host.address=localhost
# Remote mode
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-08-04 17:59:27 UTC (rev 2995)
+++ trunk/pom.xml 2010-08-05 10:50:11 UTC (rev 2996)
@@ -253,6 +253,16 @@
<role>Développeur</role>
</roles>
</contributor>
+ <contributor>
+ <name>jpepin</name>
+ <email>pepin(a)codelutin.com</email>
+ <organization>Code Lutin</organization>
+ <organizationUrl>http://www.codelutin.com</organizationUrl>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </contributor>
</contributors>
<!-- ************************************************************* -->
1
0
Author: jpepin
Date: 2010-08-04 19:59:27 +0200 (Wed, 04 Aug 2010)
New Revision: 2995
Url: http://chorem.org/repositories/revision/lima/2995
Log:
Ajout servelet pour acc?\195?\168der aux documents html.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/HttpServerServiceMonitorable.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerServiceLocal.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java
trunk/lima-business/src/main/resources/images/
trunk/lima-business/src/main/resources/images/accounts.png
trunk/lima-business/src/main/resources/images/entries.png
trunk/lima-business/src/main/resources/images/entrybooks.png
trunk/lima-business/src/main/resources/images/fiscalperiods.png
trunk/lima-business/src/main/resources/images/identity.png
trunk/lima-business/src/main/resources/images/logo-codelutin.png
trunk/lima-business/src/main/resources/images/splash.png
Removed:
trunk/lima-swing/:limadb.lock.db
trunk/lima-swing/limadb.h2.db
trunk/lima-swing/limadb.lock.db
trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityService.java
trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties
trunk/lima-business/src/main/resources/lima.properties
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/service/ServiceMonitorableHandler.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/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/lima-config.properties
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/HttpServerServiceMonitorable.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/HttpServerServiceMonitorable.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/HttpServerServiceMonitorable.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -0,0 +1,26 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import org.chorem.lima.business.ejbinterface.HttpServerService;
+
+public interface HttpServerServiceMonitorable extends HttpServerService, ServiceMonitorable {
+
+}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -99,6 +99,10 @@
return getOption(Option.REPORTS_DIR.getKey());
}
+ public String getAddressServer(){
+ return getOption(Option.SERVER_ADRESS.getKey());
+ }
+
public int getHttpPort(){
return Integer.valueOf(getOption(Option.HTTP_PORT.getKey()));
}
@@ -128,8 +132,9 @@
CONFIG_FILE(CONFIG_FILE_NAME, _("lima.config.configFileName.description"), "lima-config.properties", String.class, true, true),
RULES_NATIONALTY("lima.rules", _("lima.config.rulesnationality"), "default", String.class, false, false),
- REPORTS_DIR("lima.report.dir", _("lima.config.reports-dir"), "", String.class, false, false),
- HTTP_PORT("lima.httpport", _("lima.config.http-port"), "5462", String.class, false, false);
+ REPORTS_DIR("lima.report.dir", _("lima.config.reportsdir"), "", String.class, false, false),
+ HTTP_PORT("lima.httpport", _("lima.config.httpport"), "5462", String.class, false, false),
+ SERVER_ADRESS("lima.serveraddress", _("lima.config.serveraddress"), "", String.class, false, false);
public final String key;
public final String description;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -88,9 +88,7 @@
LogFactory.getLog(DocumentServiceImpl.class);
private TopiaContext rootContext;
-
- protected Server server;
-
+
//Services
@EJB
IdentityService identityService;
@@ -140,30 +138,9 @@
}
}
path = LimaConfig.getInstance().getReportsDir();
- start();
}
- /** start the server */
- public void start() {
- if (server == null) {
- int port = LimaConfig.getInstance().getHttpPort();
- new File(path).mkdir();
- try {
- server = new Server(port);
- ResourceHandler resourceHandler = new ResourceHandler();
- resourceHandler.setResourceBase(path);
- server.setHandler(resourceHandler);
- server.start();
- log.info("Web server are running on port: "+port);
-
- } catch (Exception eee) {
- log.error("error while booting http server", eee);
- }
- }
- }
-
-
public Paragraph createHeaderPage(String title, Identity identity, String beginDate, String endDate){
Paragraph paragraphHeaderPage = new Paragraph();
Table t = null;
@@ -240,6 +217,7 @@
+ hourS, normalFont));
infos.addCell(new Phrase(_("lima-business.document.pagenumber")
+ nbPages, normalFont));
+ paragraphPage.add(infos);
return paragraphPage;
}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -0,0 +1,265 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+
+package org.chorem.lima.business.ejb;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.imageio.ImageIO;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ejbinterface.DocumentService;
+import org.chorem.lima.business.ejbinterface.HttpServerService;
+import org.chorem.lima.business.ejbinterface.HttpServerServiceLocal;
+import org.chorem.lima.business.utils.DocumentsEnum;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.AbstractGenerator.Output;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.util.Resource;
+
+
+@Stateless
+public class HttpServerServiceImpl extends AbstractLimaService implements HttpServerService, HttpServerServiceLocal {
+
+ private static final Log log =
+ LogFactory.getLog(HttpServerServiceImpl.class);
+
+ private TopiaContext rootContext;
+
+ @EJB
+ DocumentService documentService;
+
+ protected Server server;
+
+ protected String path;
+
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
+
+ public HttpServerServiceImpl() {
+ LimaConfig config = LimaConfig.getInstance();
+ try {
+ rootContext = TopiaContextFactory.getContext(config.getOptions());
+ } catch (TopiaNotFoundException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init topia context", ex);
+ }
+ }
+ path = LimaConfig.getInstance().getReportsDir();
+
+ }
+
+
+
+ /** start the server */
+ public void start() {
+ if (server == null) {
+ int port = LimaConfig.getInstance().getHttpPort();
+ new File(path).mkdir();
+ String imagesPath = getClass().getResource("/images").toExternalForm();
+ try {
+ server = new Server(port);
+
+ Context root = new Context(server, "/", Context.NO_SESSIONS);
+ root.addServlet(new ServletHolder((Servlet) new MainServlet()), "/");
+
+ server.start();
+ log.info("Web server are running on port: "+port);
+
+ } catch (Exception eee) {
+ log.error("error while booting http server", eee);
+ }
+ }
+ }
+
+
+ /** this servlet send a static html page */
+ public class MainServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ String serverAddressConfig = LimaConfig.getInstance().getAddressServer();
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ String imageParam = req.getParameter("img");
+ log.info(imageParam);
+ if (imageParam != null){
+ URL image = Resource.getURLOrNull("images/"+imageParam);
+ log.info("image :"+image);
+ if (image != null){
+ resp.setContentType("image/png");
+ InputStream in = image.openStream();
+ OutputStream out = resp.getOutputStream();
+ IOUtils.copy(in, out);
+ }
+ }
+ else {
+ resp.setContentType("text/html");
+ String pageContent = "";
+ String serverAdress = "http://";
+
+ log.info("Page load");
+
+ /** create server Address : static config if exist or dynamical adress */
+ if (serverAddressConfig.equals("")){
+ serverAdress += req.getServerName() + ":" + req.getServerPort();
+ }
+ else {
+ serverAdress += serverAddressConfig + ":"
+ + LimaConfig.getInstance().getHttpPort();
+ }
+
+ String link = req.getParameter("link");
+ String beginDate = req.getParameter("beginDate");
+ String endDate = req.getParameter("endDate");
+
+ if (link != null && beginDate != null && endDate != null){
+ try {
+ Date beginDateFormat = dateFormat.parse(beginDate);
+ Date endDateFormat = dateFormat.parse(endDate);
+
+ switch (DocumentsEnum.valueOfLink(link)) {
+ case BALANCE:
+ documentService.createBalanceDocuments(beginDateFormat, endDateFormat);
+ break;
+ case ENTRYBOOKS:
+ documentService.createEntryBooksDocuments(beginDateFormat, endDateFormat);
+ break;
+ case FINANCIALSTATEMENT:
+ documentService.createFinancialStatementsDocuments(beginDateFormat, endDateFormat);
+ break;
+ case GENERAL_ENTRYBOOK:
+ documentService.createGeneralEntryBooksDocuments(beginDateFormat, endDateFormat);
+ break;
+ case LEDGER:
+ documentService.createLedgerDocuments(beginDateFormat, endDateFormat);
+ break;
+ }
+ } catch (LimaException eeeLE) {
+ log.error("Can't call document service for create html document", eeeLE);
+ } catch (ParseException eeePE) {
+ log.error("Can't parse date", eeePE);
+ }
+ pageContent = extractFile(path+File.separatorChar+link);
+ }
+ else {
+
+ Calendar calendar = Calendar.getInstance();
+ Date endDatePicker = calendar.getTime();
+ Date beginDatePicker = calendar.getTime();
+ beginDatePicker = DateUtils.truncate(beginDatePicker, Calendar.YEAR);
+
+ pageContent = "<!DOCTYPE html>\n"
+ + "<html lang=\"fr\">\n"
+ + "<head>\n"
+ + "<title>LIMA Documents Report</title>\n"
+ + "<style type=\"text/css\">"
+ + "body { font: 14px sans-serif; }"
+ + "h1 { font: 20px sans-serif; text-align: center; }"
+ + "table.paddingleft td {padding-left:100px;}"
+ + ".tdright {text-align: right;}"
+ + "</style>"
+ + "</head>\n"
+ + "<body>\n"
+ + "<table class=\"paddingleft\">\n"
+ + "<tr><td colspan=2><h1>LIMA Documents Report</h1></td></tr>\n"
+ + "<tr><td><img src=\"?img=identity.png\"/></td>\n"
+ + "<td rowspan=3><form method=GET action=" + serverAdress + ">\n"
+ + _("lima-business.document.date.begin") + "<input value=\""+dateFormat.format(beginDatePicker)
+ + "\" type=\"date\" name=\"beginDate\">\n"
+ + _("lima-business.document.date.end") + "<input value=\""+dateFormat.format(endDatePicker)
+ + "\" type=\"date\" name=\"endDate\">\n<br/><br/>"
+ + "Documents : <select name=\"link\">";
+
+ for (DocumentsEnum documentsEnum : DocumentsEnum.values()) {
+ pageContent += "<option value=\""+documentsEnum.getLink()+"\">"
+ + documentsEnum.getDescription()+"</OPTION>\n";
+ }
+
+ pageContent += "<tr><td><img src=\"?img=entries.png\"/></td></tr>\n"
+ + "<tr><td><img src=\"?img=accounts.png\"/></td></tr>\n"
+ + "<tr><td><img src=\"?img=entrybooks.png\"/></td>\n"
+ + "</select>\n<br/><br/>"
+ + "<td class=\"tdright\"><input type=\"submit\"></td></tr>"
+ + "</form>\n"
+ + "<tr><td><img src=\"?img=fiscalperiods.png\"/></td></tr>\n"
+ + "</table>\n"
+ + "</body>\n"
+ + "</html>";
+ }
+
+ resp.getWriter().write(pageContent);
+
+ }
+ }
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doGet(req, resp);
+
+ }
+ }
+
+ public String extractFile(String filePath){
+ char[] datas = new char[(int) new File(filePath).length()];
+ try {
+ BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)));
+ in.read(datas);
+ in.close();
+ }
+ catch (IOException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't read file "+filePath, eee);
+ }
+ }
+ return new String(datas);
+ }
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerService.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -0,0 +1,30 @@
+/* *##% 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.ejbinterface;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface HttpServerService {
+
+ public void start();
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerServiceLocal.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/HttpServerServiceLocal.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -0,0 +1,28 @@
+/* *##% 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.ejbinterface;
+
+import javax.ejb.Local;
+
+@Local
+public interface HttpServerServiceLocal {
+
+}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityService.java 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/IdentityService.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -23,7 +23,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Identity;
-import org.nuiton.topia.TopiaContext;
@Remote
public interface IdentityService {
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -0,0 +1,43 @@
+package org.chorem.lima.business.utils;
+
+import static org.nuiton.i18n.I18n._;
+
+
+public enum DocumentsEnum {
+
+ ENTRYBOOKS(_("lima-business.document.entrybook"),"lima_entrybooks.html"),
+ GENERAL_ENTRYBOOK(_("lima-business.document.generalentrybook"),"lima_general_entybook.html"),
+ FINANCIALSTATEMENT(_("lima-business.document.financialstatement"),"lima_financialstatements.html"),
+ BALANCE(_("lima-business.document.balance"),"lima_balance.html"),
+ LEDGER(_("lima-business.document.ledger"),"lima_ledger.html");
+
+ private final String link;
+
+ private final String description;
+
+ private DocumentsEnum(String description, String link) {
+ this.description = description;
+ this.link = link;
+ }
+
+ public String getLink() {
+ return this.link;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public static DocumentsEnum valueOfLink(String label){
+ DocumentsEnum value = null;
+
+ for (DocumentsEnum documentsEnum : DocumentsEnum.values()) {
+ if (label.equals(documentsEnum.link)){
+ value = documentsEnum;
+ break;
+ }
+ }
+ return value;
+ }
+
+}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-04 17:59:27 UTC (rev 2995)
@@ -1,6 +1,7 @@
An\ EntryBook\ already\ exists\ with\ this\ label\ \:\ %s=
An\ account\ already\ exists\ with\ this\ number\ \:\ %s=
An\ financialStatement\ already\ exists\ with\ this\ label\ \:\ %s=
+business.document.financialstatement=
lima-business.config.configFileName.description=
lima-business.config.rulesnationality=
lima-business.document.accountnubmer=
@@ -17,9 +18,12 @@
lima-business.document.createdate2=
lima-business.document.credit=Credit
lima-business.document.date=Date
+lima-business.document.date.begin=
+lima-business.document.date.end=
lima-business.document.debit=Debit
lima-business.document.description=Description
lima-business.document.entrybook=EntryBook
+lima-business.document.financialstatement=
lima-business.document.generalentrybook=
lima-business.document.grossamount=Gross Amount
lima-business.document.label=Label
@@ -39,8 +43,11 @@
lima.business.document.date=Date
lima.config.configFileName.description=
lima.config.http-port=
+lima.config.httpport=
lima.config.reports-dir=
+lima.config.reportsdir=
lima.config.rulesnationality=
+lima.config.serveraddress=
lima.table.grossamount=
lima.table.label=Test
lima.table.netamount=
Modified: trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-04 17:59:27 UTC (rev 2995)
@@ -1,9 +1,11 @@
An\ EntryBook\ already\ exists\ with\ this\ label\ \:\ %s=
An\ account\ already\ exists\ with\ this\ number\ \:\ %s=
An\ financialStatement\ already\ exists\ with\ this\ label\ \:\ %s=
+business.document.financialstatement=
lima-business.document.accountnumber=N\u00B0 Compte
lima-business.document.amounts=Totaux
lima-business.document.balance=Balance
+lima-business.document.beginDate=Date de d\u00E9but \:
lima-business.document.businessnumber=N\u00B0 Siret
lima-business.document.carryback=Report
lima-business.document.carryforward=\u00C0 reporter
@@ -12,9 +14,13 @@
lima-business.document.createdate2=\u00E0
lima-business.document.credit=Cr\u00E9dit
lima-business.document.date=Date
+lima-business.document.date.begin=Date de d\u00E9but \:
+lima-business.document.date.end=Date de fin \:
lima-business.document.debit=D\u00E9bit
lima-business.document.description=Description
+lima-business.document.endDate=Date de fin \:
lima-business.document.entrybook=Journal
+lima-business.document.financialstatement=Bilan et compte de r\u00E9sultat
lima-business.document.generalentrybook=Journal G\u00E9n\u00E9ral
lima-business.document.grossamount=Brut
lima-business.document.label=Libell\u00E9
@@ -33,5 +39,8 @@
lima-business.document.voucher=Pi\u00E8ce comptable
lima.config.configFileName.description=
lima.config.http-port=
+lima.config.httpport=
lima.config.reports-dir=
+lima.config.reportsdir=
lima.config.rulesnationality=
+lima.config.serveraddress=
Added: trunk/lima-business/src/main/resources/images/accounts.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-business/src/main/resources/images/accounts.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-business/src/main/resources/images/entries.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-business/src/main/resources/images/entries.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-business/src/main/resources/images/entrybooks.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-business/src/main/resources/images/entrybooks.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-business/src/main/resources/images/fiscalperiods.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-business/src/main/resources/images/fiscalperiods.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-business/src/main/resources/images/identity.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-business/src/main/resources/images/identity.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-business/src/main/resources/images/logo-codelutin.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-business/src/main/resources/images/logo-codelutin.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-business/src/main/resources/images/splash.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-business/src/main/resources/images/splash.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/lima-business/src/main/resources/lima.properties
===================================================================
--- trunk/lima-business/src/main/resources/lima.properties 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-business/src/main/resources/lima.properties 2010-08-04 17:59:27 UTC (rev 2995)
@@ -3,6 +3,8 @@
lima.dir=${user.home}/.lima/
# http port for reports
lima.httpport=5462
+# server address (optional for server behind proxy)
+lima.serveraddress=
# Local class for accounting rules
lima.rules=org.chorem.lima.business.accountingrules.FranceAccountingRules
# directory for http server
Deleted: trunk/lima-swing/:limadb.lock.db
===================================================================
--- trunk/lima-swing/:limadb.lock.db 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/:limadb.lock.db 2010-08-04 17:59:27 UTC (rev 2995)
@@ -1,4 +0,0 @@
-#FileLock
-#Tue Aug 03 19:12:33 CEST 2010
-id=12a38f0b67cbf55cf1fb51d173d8db55399628ae048
-method=file
Deleted: trunk/lima-swing/limadb.h2.db
===================================================================
(Binary files differ)
Deleted: trunk/lima-swing/limadb.lock.db
===================================================================
--- trunk/lima-swing/limadb.lock.db 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/limadb.lock.db 2010-08-04 17:59:27 UTC (rev 2995)
@@ -1,4 +0,0 @@
-#FileLock
-#Tue Aug 03 19:13:22 CEST 2010
-id=12a38f1750004a9a1ddce8ec18615a18acf9c511c71
-method=file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -202,7 +202,12 @@
boolean result = getOptionAsBoolean(Option.OPENEJB_REMOTEMODE.key);
return result;
}
+
+ public String getHostAdress() {
+ return getOption(Option.LIMA_HOST_ADDRESS.key);
+ }
+
/**
* Used in ????
*/
@@ -243,8 +248,9 @@
FULL_SCREEN("lima.ui.fullscreen", _("lima.config.ui.fullscreen.description"), "false", Boolean.class, false, false),
LAUNCH_UI("lima.ui.launchui", _("lima.config.ui.flaunchui.description"), "true", Boolean.class, true, true),
SUPPORT_EMAIL("lima.misc.supportemail", _("lima.misc.supportemail.description"), "", String.class, false, false),
- OPENEJB_REMOTEMODE("lima.openejb.remotemode", _("lima.openejb.remotemode.description"), "false", String.class, false, false);
-
+ OPENEJB_REMOTEMODE("lima.openejb.remotemode", _("lima.openejb.remotemode.description"), "false", String.class, false, false),
+ LIMA_HOST_ADDRESS("lima.host.address", _("lima.config.host.adress"), "", String.class, false, false);
+
public final String key;
public final String description;
public String defaultValue;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -31,7 +31,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountServiceMonitorable;
+import org.chorem.lima.business.HttpServerServiceMonitorable;
import org.chorem.lima.business.ejbinterface.AccountService;
+import org.chorem.lima.business.ejbinterface.HttpServerService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.MainView;
@@ -172,6 +174,9 @@
// load accounts and test if there is an account plan defined
// if not, call #loadDefaultAccount()
splash.updateProgression(0.5, _("Loading accounting..."));
+
+ //start servlet
+ LimaServiceFactory.getInstance().getService(HttpServerServiceMonitorable.class).start();
AccountService accountService =
LimaServiceFactory.getInstance().getService(
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -19,6 +19,7 @@
package org.chorem.lima.service;
import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@@ -58,7 +59,11 @@
removeServiceListener((ServiceListener) args[0]);
}
else {
+ try {
result = method.invoke(service, args);
+ }catch (InvocationTargetException eee){
+ throw eee.getCause();
+ }
if (!method.getName().startsWith("get")){
for (ServiceListener serviceListener : listeners) {
serviceListener.notifyMethod(service.toString(), method.getName());
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-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-08-04 17:59:27 UTC (rev 2995)
@@ -21,25 +21,43 @@
resizable="true" width="800" height="600"
extendedState='{this.MAXIMIZED_BOTH}'>
-
+<java.awt.Desktop id='desktop' javaBean='java.awt.Desktop.getDesktop()'/>
<script><![CDATA[
-import java.util.Locale;
-import org.chorem.lima.LimaConfig;
-import org.chorem.lima.enums.ImportExportEnum;
+ import java.util.Locale;
+ import org.chorem.lima.LimaConfig;
+ import org.chorem.lima.enums.ImportExportEnum;
+ import java.net.URISyntaxException;
+ import java.net.URI;
-public LimaConfig getConfig() {
- return getContextValue(LimaConfig.class);
-}
+ public LimaConfig getConfig() {
+ return getContextValue(LimaConfig.class);
+ }
-public MainViewHandler getHandler() {
- return getContextValue(MainViewHandler.class);
-}
+ public MainViewHandler getHandler() {
+ return getContextValue(MainViewHandler.class);
+ }
-public boolean acceptLocale(Locale l, String expected) {
- return l != null && l.toString().equals(expected);
-}
+ public boolean acceptLocale(Locale l, String expected) {
+ return l != null && l.toString().equals(expected);
+ }
+ URI uri = null;
+ try {
+ uri = new URI("http://localhost:5462/");
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+
+ public void loadURI(){
+ try {
+ desktop.browse(uri);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
/**
* Show a new closable tab.
*
@@ -107,6 +125,9 @@
<JMenuItem text="lima.importexport.entries" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ENTRIES_EXPORT)'/>
</JMenu>
</JMenu>
+ <JSeparator/>
+ <JMenuItem text="lima.documents.html"
+ onActionPerformed="loadURI()"/>
<JSeparator/>
<JMenuItem text="lima.identity"
actionIcon="identity" onActionPerformed="getHandler().showIdentity(this)"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-08-04 17:59:27 UTC (rev 2995)
@@ -77,7 +77,6 @@
* @return l'ui instancie et initialisee mais non visible encore
*/
public MainView initUI(LimaContext rootContext, boolean fullscreen) {
-
// show main ui
MainView ui = new MainView(rootContext);
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-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-04 17:59:27 UTC (rev 2995)
@@ -60,6 +60,7 @@
lima.config.category.other=
lima.config.category.other.description=
lima.config.configFileName.description=
+lima.config.host.adress=
lima.config.locale.description=
lima.config.ui.flaunchui.description=
lima.config.ui.fullscreen.description=
@@ -70,6 +71,7 @@
lima.debit=Debit
lima.description=Description
lima.dialogreport=
+lima.documents.html=
lima.entries=Entries
lima.entries.addtransaction=
lima.entries.lettering=
@@ -164,6 +166,7 @@
lima.opening.accounts=
lima.opening.entrybook=
lima.opening.welcome=
+lima.pdf=
lima.period.begindate=
lima.period.create=
lima.period.enddate=
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-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-04 17:59:27 UTC (rev 2995)
@@ -56,6 +56,7 @@
lima.config.category.other=Autre
lima.config.category.other.description=Autre propri\u00E9t\u00E9s de configuration
lima.config.configFileName.description=
+lima.config.host.adress=
lima.config.locale.description=Locale utilis\u00E9e par l'application
lima.config.ui.flaunchui.description=
lima.config.ui.fullscreen.description=
@@ -66,6 +67,7 @@
lima.debit=Debit
lima.description=Description
lima.dialogreport=
+lima.documents.html=
lima.entries=Traitement
lima.entries.addtransaction=Saisir des \u00E9critures
lima.entries.lettering=Ajouter une lettre
@@ -155,6 +157,7 @@
lima.opening.accounts=<html><center>Aucun plan comptable charg\u00E9<br/>Veuillez s\u00E9lectionner un plan par d\u00E9fault, <br/>importer un plan personnalis\u00E9<br/> ou annuler pour cr\u00E9er votre propre plan.</center></html>
lima.opening.entrybook=<html>Cochez la case pour importer les journaux par d\u00E9faut \:<br/> Achats, Ventes, Tr\u00E9sorerie, Op\u00E9ration diverses</html>
lima.opening.welcome=<html><center>Bienvenue dans Lima<br/>Laissez vous guider par cet assistant pour d\u00E9marrer votre comptabilit\u00E9 en quelques instants\u0085</center></html>
+lima.pdf=
lima.period.begindate=D\u00E9but
lima.period.create=Choisissez la date de d\u00E9but et de fin du nouvel exercice
lima.period.enddate=Fin
Modified: trunk/lima-swing/src/main/resources/lima-config.properties
===================================================================
--- trunk/lima-swing/src/main/resources/lima-config.properties 2010-08-03 17:23:31 UTC (rev 2994)
+++ trunk/lima-swing/src/main/resources/lima-config.properties 2010-08-04 17:59:27 UTC (rev 2995)
@@ -18,6 +18,9 @@
lima.openejb.remotemode=false
java.naming.factory.initial=org.openejb.client.LocalInitialContextFactory
+#Lima Accounting Host address
+lima.host.address=localhost
+
# Remote mode
#lima.openejb.remotemode=true
#java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory
1
0
03 Aug '10
Author: jpepin
Date: 2010-08-03 19:23:31 +0200 (Tue, 03 Aug 2010)
New Revision: 2994
Url: http://chorem.org/repositories/revision/lima/2994
Log:
Serveur http embarqu?\195?\169 + ajout de propri?\195?\169t?\195?\169s dans lima config.
Added:
trunk/lima-swing/:limadb.lock.db
trunk/lima-swing/limadb.h2.db
trunk/lima-swing/limadb.lock.db
trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentHtmlPane.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentHtmlView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentPdf.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportFileChooser.java
Modified:
trunk/lima-business/pom.xml
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties
trunk/lima-business/src/main/resources/lima.properties
trunk/pom.xml
Modified: trunk/lima-business/pom.xml
===================================================================
--- trunk/lima-business/pom.xml 2010-08-03 10:41:31 UTC (rev 2993)
+++ trunk/lima-business/pom.xml 2010-08-03 17:23:31 UTC (rev 2994)
@@ -32,7 +32,13 @@
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</dependency>
+
<dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-08-03 10:41:31 UTC (rev 2993)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-08-03 17:23:31 UTC (rev 2994)
@@ -91,7 +91,19 @@
}
+ /**
+ *
+ * @param configFileName
+ */
+ public String getReportsDir(){
+ return getOption(Option.REPORTS_DIR.getKey());
+ }
+ public int getHttpPort(){
+ return Integer.valueOf(getOption(Option.HTTP_PORT.getKey()));
+ }
+
+
protected void loadConfiguration(String configFileName){
instance.setConfigFileName(configFileName);
@@ -115,7 +127,9 @@
public static enum Option implements OptionDef {
CONFIG_FILE(CONFIG_FILE_NAME, _("lima.config.configFileName.description"), "lima-config.properties", String.class, true, true),
- RULES_NATIONALTY("lima.rules",_("lima.config.rulesnationality"),"default", String.class, false, false);
+ RULES_NATIONALTY("lima.rules", _("lima.config.rulesnationality"), "default", String.class, false, false),
+ REPORTS_DIR("lima.report.dir", _("lima.config.reports-dir"), "", String.class, false, false),
+ HTTP_PORT("lima.httpport", _("lima.config.http-port"), "5462", String.class, false, false);
public final String key;
public final String description;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-03 10:41:31 UTC (rev 2993)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-03 17:23:31 UTC (rev 2994)
@@ -21,6 +21,7 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Color;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
@@ -57,13 +58,14 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ResourceHandler;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
-
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.Chapter;
@@ -87,7 +89,9 @@
private TopiaContext rootContext;
- //Service
+ protected Server server;
+
+ //Services
@EJB
IdentityService identityService;
@@ -100,6 +104,8 @@
@EJB
ReportService reportService;
+ protected String path;
+
//SDFs
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("dd/MM/yyyy");
@@ -133,10 +139,31 @@
log.error("Can't init topia context", ex);
}
}
+ path = LimaConfig.getInstance().getReportsDir();
+ start();
}
-
+ /** start the server */
+ public void start() {
+ if (server == null) {
+ int port = LimaConfig.getInstance().getHttpPort();
+ new File(path).mkdir();
+ try {
+ server = new Server(port);
+ ResourceHandler resourceHandler = new ResourceHandler();
+ resourceHandler.setResourceBase(path);
+ server.setHandler(resourceHandler);
+ server.start();
+ log.info("Web server are running on port: "+port);
+
+ } catch (Exception eee) {
+ log.error("error while booting http server", eee);
+ }
+ }
+ }
+
+
public Paragraph createHeaderPage(String title, Identity identity, String beginDate, String endDate){
Paragraph paragraphHeaderPage = new Paragraph();
Table t = null;
@@ -230,12 +257,11 @@
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
String hourS = hourFormat.format(newDate);
- String fileDateS = filedateFormat.format(newDate);
PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream("/lima_bcr"+fileDateS+".pdf"));
+ new FileOutputStream(path+File.separator+"lima_financialstatements.pdf"));
HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream("/lima_bcr"+fileDateS+".html"));
+ new FileOutputStream(path+File.separator+"lima_financialstatements.html"));
document.open();
int nbpages = 1;
@@ -460,16 +486,15 @@
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
String hourS = hourFormat.format(newDate);
- String fileDateS = filedateFormat.format(newDate);
Double currentAmountDebit = 0.0;
Double currentAmountCredit = 0.0;
String accountcarry ="";
PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream("/ledger_lima"+fileDateS+".pdf"));
+ new FileOutputStream(path+File.separator+"lima_ledger.pdf"));
HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream("/ledger_lima"+fileDateS+".html"));
+ new FileOutputStream(path+File.separator+"lima_ledger.html"));
document.open();
int nbpages = 1;
Identity identity = identityService.getIdentity();
@@ -705,10 +730,11 @@
String hourS = hourFormat.format(newDate);
String fileDateS = filedateFormat.format(newDate);
+ log.debug(path);
PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream("/lima_ebs"+fileDateS+".pdf"));
+ new FileOutputStream(path+File.separator+"lima_entrybooks.pdf"));
HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream("/lima_ebs"+fileDateS+".html"));
+ new FileOutputStream(path+File.separator+"lima_entrybooks.html"));
document.open();
int nbpages = 1;
@@ -928,9 +954,9 @@
Double currentSoldeCredit = 0.0;
PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream("/balance_lima"+fileDateS+".pdf"));
+ new FileOutputStream(path+File.separator+"lima_balance.pdf"));
HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream("/balance_lima"+fileDateS+".html"));
+ new FileOutputStream(path+File.separator+"lima_balance.html"));
document.open();
int nbpages = 1;
Identity identity = identityService.getIdentity();
@@ -1117,12 +1143,10 @@
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
String hourS = hourFormat.format(newDate);
- String fileDateS = filedateFormat.format(newDate);
-
PdfWriter pdfWriter = PdfWriter.getInstance(document,
- new FileOutputStream("/lima_Gebs"+fileDateS+".pdf"));
+ new FileOutputStream(path+File.separator+"lima_general_entybook.pdf"));
HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
- new FileOutputStream("/lima_Gebs"+fileDateS+".html"));
+ new FileOutputStream(path+File.separator+"lima_general_entybook.html"));
document.open();
int nbpages = 1;
Modified: trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-03 10:41:31 UTC (rev 2993)
+++ trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-03 17:23:31 UTC (rev 2994)
@@ -38,6 +38,8 @@
lima-business.document.voucher=Voucher
lima.business.document.date=Date
lima.config.configFileName.description=
+lima.config.http-port=
+lima.config.reports-dir=
lima.config.rulesnationality=
lima.table.grossamount=
lima.table.label=Test
Modified: trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-03 10:41:31 UTC (rev 2993)
+++ trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-03 17:23:31 UTC (rev 2994)
@@ -32,4 +32,6 @@
lima-business.document.vatnumber=N\u00B0 TVA
lima-business.document.voucher=Pi\u00E8ce comptable
lima.config.configFileName.description=
+lima.config.http-port=
+lima.config.reports-dir=
lima.config.rulesnationality=
Modified: trunk/lima-business/src/main/resources/lima.properties
===================================================================
--- trunk/lima-business/src/main/resources/lima.properties 2010-08-03 10:41:31 UTC (rev 2993)
+++ trunk/lima-business/src/main/resources/lima.properties 2010-08-03 17:23:31 UTC (rev 2994)
@@ -1,3 +1,14 @@
+#LIMA Defaults values
+# main directory
+lima.dir=${user.home}/.lima/
+# http port for reports
+lima.httpport=5462
+# Local class for accounting rules
+lima.rules=org.chorem.lima.business.accountingrules.FranceAccountingRules
+# directory for http server
+lima.report.dir=${lima.dir}/reports
+
+
# Proprietes par defaut pour une base de donnees de type H2
hibernate.hbm2ddl.auto=update
#hibernate.show_sql=true
@@ -2,2 +13,3 @@
+
hibernate.dialect=org.hibernate.dialect.H2Dialect
@@ -7,5 +19,4 @@
hibernate.connection.password=
hibernate.connection.driver_class=org.h2.Driver
hibernate.connection.url=jdbc:h2:file:~/.lima/limadb
-
-lima.rules=org.chorem.lima.business.accountingrules.FranceAccountingRules
+#FIXME hibernate.connection.url=jdbc:h2:file:${lima.dir}/limadb
\ No newline at end of file
Added: trunk/lima-swing/:limadb.lock.db
===================================================================
--- trunk/lima-swing/:limadb.lock.db (rev 0)
+++ trunk/lima-swing/:limadb.lock.db 2010-08-03 17:23:31 UTC (rev 2994)
@@ -0,0 +1,4 @@
+#FileLock
+#Tue Aug 03 19:12:33 CEST 2010
+id=12a38f0b67cbf55cf1fb51d173d8db55399628ae048
+method=file
Added: trunk/lima-swing/limadb.h2.db
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/limadb.h2.db
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/limadb.lock.db
===================================================================
--- trunk/lima-swing/limadb.lock.db (rev 0)
+++ trunk/lima-swing/limadb.lock.db 2010-08-03 17:23:31 UTC (rev 2994)
@@ -0,0 +1,4 @@
+#FileLock
+#Tue Aug 03 19:13:22 CEST 2010
+id=12a38f1750004a9a1ddce8ec18615a18acf9c511c71
+method=file
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentHtmlPane.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentHtmlPane.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentHtmlPane.java 2010-08-03 17:23:31 UTC (rev 2994)
@@ -0,0 +1,122 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.document;
+
+import static org.nuiton.i18n.I18n._;
+import java.awt.Color;
+import java.util.List;
+import javax.swing.JEditorPane;
+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;
+import org.chorem.lima.business.AccountServiceMonitorable;
+import org.chorem.lima.business.ImportServiceMonitorable;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.MainView;
+
+public class DocumentHtmlPane extends JEditorPane implements HyperlinkListener, ServiceListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log = LogFactory.getLog(DocumentHtmlPane.class);
+
+ protected DocumentHtmlView view;
+
+ protected AccountServiceMonitorable accountService;
+
+ private static Color redBackground = new Color(0xff, 0xee, 0xee);
+ private static Color greenBackground = new Color(0xee, 0xff, 0xee);
+
+
+
+ public DocumentHtmlPane(DocumentHtmlView view) {
+ this.view=view;
+ accountService =
+ LimaServiceFactory.getInstance().getService(
+ AccountServiceMonitorable.class);
+ accountService.addListener(this);
+ LimaServiceFactory.getInstance().getService(
+ ImportServiceMonitorable.class).addListener(this);
+
+ //init
+ setOpaque(true);
+ setContentType("text/html");
+ setEditable(false);
+ setUI(new BasicEditorPaneUI());
+ addHyperlinkListener(this);
+ refresh();
+ }
+
+ @Override
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+
+ if (e.getDescription().equals("#accountschart")) {
+ MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view);
+ ui.getHandler().showAccountView(ui);
+ }
+ }
+ }
+
+ public void refresh(){
+
+ String htmlBegin = "<font face='sans-serif' size=3>"
+ + "<p style=vertical-align:'bottom', horizontal-align:'center'>";
+ String htmlEnd = "</p></font>";
+
+ try {
+
+ List<Account> accounts = accountService.getAllAccounts();
+ if (accounts.size()>0){
+ setBackground(greenBackground);
+ String accountsString = _("limahome.chartaccounts.state1_2") + " "
+ + accounts.size() + " " + _("limahome.chartaccounts.state2_2")
+ + "<br/><br/><a href='#accountschart'>"
+ + _("limahome.chartaccounts.modify") + "</a>";
+ //set Text
+ setText(htmlBegin + accountsString + htmlEnd);
+ }
+ else {
+ setBackground(redBackground);
+ String accountsString = _("limahome.chartaccounts.nothing")
+ + "<br/><br/><a href='#accountschart'>"
+ + _("limahome.chartaccounts.create") + "</a>";
+ //set Text
+ setText(htmlBegin + accountsString + htmlEnd);
+ }
+ } catch (LimaException eee) {
+ log.debug("Can't get datas account editor pane home", eee);
+ }
+ }
+
+ @Override
+ public void notifyMethod(String serviceName, String methodeName) {
+ if (methodeName.contains("Account") || methodeName.contains("importAll")){
+ refresh();
+ }
+ }
+
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentHtmlView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentHtmlView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentHtmlView.jaxx 2010-08-03 17:23:31 UTC (rev 2994)
@@ -0,0 +1,42 @@
+<!-- ##% 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[
+ import javax.swing.BorderFactory;
+ getRootPane().setDefaultButton(ok);
+ protected void performOk() {
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row>
+ <cell>
+ <JEditorPane javaBean='new org.chorem.lima.ui.document.DocumentHtmlPane(this)'/>
+ </cell>
+ </row>
+ <row>
+ <cell anchor='east' fill="none">
+ <JButton id='ok' text="lima.common.ok" onActionPerformed="performOk()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentPdf.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentPdf.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/document/DocumentPdf.java 2010-08-03 17:23:31 UTC (rev 2994)
@@ -0,0 +1,5 @@
+package org.chorem.lima.ui.document;
+
+public class DocumentPdf {
+
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportFileChooser.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportFileChooser.java 2010-08-03 10:41:31 UTC (rev 2993)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportFileChooser.java 2010-08-03 17:23:31 UTC (rev 2994)
@@ -1,34 +0,0 @@
-package org.chorem.lima.ui.importexport;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-
-import javax.swing.JPanel;
-
-public class ImportExportFileChooser extends JPanel {
-
- private static final long serialVersionUID = 1L;
-
- public ImportExportFileChooser() {
-
- setLayout(new BorderLayout());
- // il y a 4 composants dans le JFileChooser, on les retire un par un pour les replacer comme on le souhaite
- Component navigationBar = getComponent(0);
- remove(0);
- // on retire un JPanel qui n'est pas utile
- remove(0);
- add(navigationBar, BorderLayout.NORTH);
- Component panelFiles = getComponent(0);
- remove(0);
- add(panelFiles, BorderLayout.CENTER);
- Component buttons = getComponent(0);
- remove(0);
- add(buttons, BorderLayout.SOUTH);
-
- //this.add(panelFileChooser);
- //this.add(panelOptions, BorderLayout.SOUTH);
-
- }
-
-
-}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-08-03 10:41:31 UTC (rev 2993)
+++ trunk/pom.xml 2010-08-03 17:23:31 UTC (rev 2994)
@@ -173,6 +173,13 @@
<version>2.1.7</version>
</dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.25</version>
+ </dependency>
+
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
1
0
r2993 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejbinterface lima-business/src/main/resources/i18n lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports lima-swing/src/main/java/org/chorem/lima/ui/ledger
by jpepin@users.chorem.org 03 Aug '10
by jpepin@users.chorem.org 03 Aug '10
03 Aug '10
Author: jpepin
Date: 2010-08-03 12:41:31 +0200 (Tue, 03 Aug 2010)
New Revision: 2993
Url: http://chorem.org/repositories/revision/lima/2993
Log:
Sortie document pdf journal g?\195?\169n?\195?\169ral.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java
trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-02 16:54:10 UTC (rev 2992)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-03 10:41:31 UTC (rev 2993)
@@ -25,6 +25,7 @@
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
@@ -33,6 +34,8 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.FinancialStatementAmounts;
+import org.chorem.lima.beans.GeneralEntryBooksDatas;
+import org.chorem.lima.beans.GeneralEntryBooksDatasImpl;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
@@ -42,12 +45,15 @@
import org.chorem.lima.business.ejbinterface.FinancialStatementService;
import org.chorem.lima.business.ejbinterface.IdentityService;
import org.chorem.lima.business.ejbinterface.ReportService;
+import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -131,7 +137,8 @@
- public Table createHeaderPage(String title, Identity identity, String beginDate, String endDate){
+ public Paragraph createHeaderPage(String title, Identity identity, String beginDate, String endDate){
+ Paragraph paragraphHeaderPage = new Paragraph();
Table t = null;
try {
@@ -154,34 +161,61 @@
titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
titleCell.setRowspan(2);
t.addCell(titleCell);
- t.addCell(new Phrase(_("lima-business.document.businessnumber"), bolditalicFont));
+ t.addCell(new Phrase(_("lima-business.document.businessnumber"),
+ bolditalicFont));
t.addCell(new Phrase(identity.getBusinessNumber(), italicFont));
//line 2
t.addCell(new Phrase(identity.getDescription(), italicFont));
- t.addCell(new Phrase(_("lima-business.document.classificationcode"), bolditalicFont));
+ t.addCell(new Phrase(_("lima-business.document.classificationcode"),
+ bolditalicFont));
t.addCell(new Phrase(identity.getClassificationCode(), italicFont));
//line 3
t.addCell(new Phrase(identity.getAddress(), italicFont));
t.addCell("");
- t.addCell(new Phrase(_("lima-business.document.vatnumber"), bolditalicFont));
+ t.addCell(new Phrase(_("lima-business.document.vatnumber"),
+ bolditalicFont));
t.addCell(new Phrase(identity.getVatNumber(), italicFont));
//line 4
t.addCell(new Phrase(identity.getAddress2(), italicFont));
t.addCell("");
- t.addCell(new Phrase(_("lima-business.document.period1"), bolditalicFont));
+ t.addCell(new Phrase(_("lima-business.document.period1"),
+ bolditalicFont));
t.addCell(new Phrase(beginDate, italicFont));
//line 5
- t.addCell(new Phrase(identity.getZipCode() + " " + identity.getCity(), italicFont));
+ t.addCell(new Phrase(identity.getZipCode() + " " + identity.getCity(),
+ italicFont));
t.addCell("");
- t.addCell(new Phrase(_("lima-business.document.period2"), bolditalicFont));
+ t.addCell(new Phrase(_("lima-business.document.period2"),
+ bolditalicFont));
t.addCell(new Phrase(endDate, italicFont));
} catch (BadElementException eeBEE) {
log.error("Can't create table", eeBEE);
}
- return t;
+
+ paragraphHeaderPage.add(t);
+ return paragraphHeaderPage;
}
+ public Paragraph createNumberPage (int nbPages, String dateS, String hourS) throws BadElementException{
+ //n° page
+ Paragraph paragraphPage = new Paragraph();
+ Table infos = new Table(2);
+ infos.setWidth(100f);
+ infos.setBorder(Rectangle.NO_BORDER);
+ infos.setOffset(2);
+ Cell c = new Cell();
+ c.setBorder(Rectangle.NO_BORDER);
+ c.setHorizontalAlignment(Element.ALIGN_CENTER);
+ infos.setDefaultCell(c);
+ infos.addCell(new Phrase(_("lima-business.document.createdate1")
+ + dateS + _("lima-business.document.createdate2")
+ + hourS, normalFont));
+ infos.addCell(new Phrase(_("lima-business.document.pagenumber")
+ + nbPages, normalFont));
+ return paragraphPage;
+ }
+
//############## FinancialStatements ##############
@@ -189,7 +223,8 @@
public void createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
- List<FinancialStatementAmounts> financialStatementAmounts = financialStatementService.financialStatementReport(beginDate, endDate);
+ List<FinancialStatementAmounts> financialStatementAmounts =
+ financialStatementService.financialStatementReport(beginDate, endDate);
try {
Date newDate = new Date();
@@ -207,12 +242,14 @@
Identity identity = identityService.getIdentity();
//Split list by financialstatement type
- List<List<FinancialStatementAmounts>> listList = new ArrayList<List<FinancialStatementAmounts>>();
+ List<List<FinancialStatementAmounts>> listList =
+ new ArrayList<List<FinancialStatementAmounts>>();
Boolean first = true;
int min=0;
int size = financialStatementAmounts.size();
for (int i=0;i<size;i++) {
- FinancialStatementAmounts fStatementAmounts = financialStatementAmounts.get(i);
+ FinancialStatementAmounts fStatementAmounts =
+ financialStatementAmounts.get(i);
if (fStatementAmounts.getLevel() == 1 && fStatementAmounts.getSubAmount() == false){
if (first){
first=false;
@@ -239,29 +276,16 @@
List <FinancialStatementAmounts> subFinancialStatementAmounts =
list.subList(i, j);
//create page : header + table + footer
- Table headerPage = createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate));
Table headerTable = createFinancialStatementsHeaderTable();
- Table table = createFinancialStatementsTable(subFinancialStatementAmounts);
+ Table table = createFinancialStatementsTable(
+ subFinancialStatementAmounts);
//new page
Chapter chapter = new Chapter(0);
//headerPage
- Paragraph paragraphHeaderPage = new Paragraph();
- paragraphHeaderPage.add(headerPage);
- chapter.add(paragraphHeaderPage);
+ chapter.add(createHeaderPage(title, identity,
+ dateFormat.format(beginDate), dateFormat.format(endDate)));
//n° page
- Paragraph paragraphPage = new Paragraph();
- Table infos = new Table(2);
- infos.setWidth(100f);
- infos.setBorder(Rectangle.NO_BORDER);
- infos.setOffset(2);
- Cell c = new Cell();
- c.setBorder(Rectangle.NO_BORDER);
- c.setHorizontalAlignment(Element.ALIGN_CENTER);
- infos.setDefaultCell(c);
- infos.addCell(new Phrase(_("lima-business.document.createdate1") + dateS + _("lima-business.document.createdate2") + hourS, normalFont));
- infos.addCell(new Phrase(_("lima-business.document.pagenumber")+nbpages, normalFont));
- paragraphPage.add(infos);
- chapter.add(paragraphPage);
+ chapter.add(createNumberPage(nbpages, dateS, hourS));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -300,10 +324,14 @@
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
t.setDefaultCell(cell);
t.setOffset(8);
- t.addCell(new Phrase(_("lima-business.document.label"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.grossamount"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.provisiondeprecationamount"), boldFont));
- t.addCell(new Phrase(_("lima-business.document.netamount"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.label"),
+ boldFont));
+ t.addCell(new Phrase(_("lima-business.document.grossamount"),
+ boldFont));
+ t.addCell(new Phrase(_("lima-business.document.provisiondeprecationamount"),
+ boldFont));
+ t.addCell(new Phrase(_("lima-business.document.netamount"),
+ boldFont));
} catch (BadElementException eeBEE) {
log.error("Can't create table", eeBEE);
@@ -334,10 +362,11 @@
String label = financialStatementAmount.getLabel();
int level = financialStatementAmount.getLevel();
- Double grossAmount = financialStatementAmount.getGrossAmount();
- Double provisionDeprecationAmount = financialStatementAmount.getProvisionDeprecationAmount();
+ Double grossAmount =
+ financialStatementAmount.getGrossAmount();
+ Double provisionDeprecationAmount =
+ financialStatementAmount.getProvisionDeprecationAmount();
- log.debug(label +" "+ level);
if (financialStatementAmount.getSubAmount() && level==1){
cell.setGrayFill(0.88f);
}
@@ -371,7 +400,8 @@
t.addCell(c);
//cell2
if (grossAmount != 0.0){
- phrase = new Phrase(String.valueOf(grossAmount), normalFont);
+ phrase = new Phrase(String.valueOf(
+ grossAmount), normalFont);
}
else {
phrase = new Phrase("");
@@ -379,7 +409,8 @@
t.addCell(phrase);
//cell 3
if (provisionDeprecationAmount != 0.0){
- phrase = new Phrase(String.valueOf(provisionDeprecationAmount), normalFont);
+ phrase = new Phrase(String.valueOf(
+ provisionDeprecationAmount), normalFont);
}
else {
phrase = new Phrase("");
@@ -387,7 +418,8 @@
t.addCell(phrase);
//cell 4
if (grossAmount-provisionDeprecationAmount != 0.0){
- phrase = new Phrase(String.valueOf(grossAmount-provisionDeprecationAmount), normalFont);
+ phrase = new Phrase(String.valueOf(
+ grossAmount-provisionDeprecationAmount), normalFont);
}
else {
phrase = new Phrase("");
@@ -408,10 +440,23 @@
@Override
- public void createLedgerDocuments(List<Object> list, Date beginDate, Date endDate) throws LimaException {
+ public void createLedgerDocuments(Date beginDate, Date endDate) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
-
+ List<Object> list = new ArrayList<Object>();
try {
+
+ BalanceTrial balanceTrial = reportService.generateLedger(beginDate, endDate, true);
+ if (balanceTrial.getReportsDatas() != null){
+ for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) {
+ list.add(reportsDatas);
+ List<Entry> entries = (List<Entry>) reportsDatas.getListEntry();
+ if (entries != null){
+ Collections.sort(entries, new EntryComparator());
+ list.addAll(entries);
+ }
+ }
+ }
+
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
String hourS = hourFormat.format(newDate);
@@ -441,28 +486,14 @@
}
List <Object> subList = list.subList(i, j);
//create page : header + table + footer
- Table headerPage = createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate));
Table headerTable = createLedgerHeaderTable();
//new page
Chapter chapter = new Chapter(0);
//headerPage
- Paragraph paragraphHeaderPage = new Paragraph();
- paragraphHeaderPage.add(headerPage);
- chapter.add(paragraphHeaderPage);
+ chapter.add(createHeaderPage(title, identity,
+ dateFormat.format(beginDate), dateFormat.format(endDate)));
//n° page
- Paragraph paragraphPage = new Paragraph();
- Table infos = new Table(2);
- infos.setWidth(100f);
- infos.setBorder(Rectangle.NO_BORDER);
- infos.setOffset(2);
- Cell c = new Cell();
- c.setBorder(Rectangle.NO_BORDER);
- c.setHorizontalAlignment(Element.ALIGN_CENTER);
- infos.setDefaultCell(c);
- infos.addCell(new Phrase(_("lima-business.document.createdate1") + dateS + _("lima-business.document.createdate2") + hourS, normalFont));
- infos.addCell(new Phrase(_("lima-business.document.pagenumber")+nbpages, normalFont));
- paragraphPage.add(infos);
- chapter.add(paragraphPage);
+ chapter.add(createNumberPage(nbpages, dateS, hourS));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -470,7 +501,9 @@
//backward amounts
if (n>max && nbpages>1){
Paragraph backwardParagraph = new Paragraph();
- backwardParagraph.add(createLedgerAmountTable(accountcarry, _("lima-business.document.carryback"), currentAmountDebit, currentAmountCredit));
+ backwardParagraph.add(createLedgerAmountTable(
+ accountcarry, _("lima-business.document.carryback"),
+ currentAmountDebit, currentAmountCredit));
chapter.add(backwardParagraph);
}
//table
@@ -488,21 +521,25 @@
ReportsDatas reportsDatas = (ReportsDatas) object;
Account account = reportsDatas.getAccount();
if ( account != null){
- accountcarry = account.getAccountNumber()+" "+account.getLabel()+" ";
- log.debug(accountcarry);
+ accountcarry = account.getAccountNumber()
+ + " " + account.getLabel() + " ";
}
}
}
//forward amounts
if (n>max && i<=n-max){
Paragraph forwardParagraph = new Paragraph();
- forwardParagraph.add(createLedgerAmountTable("", _("lima-business.document.carryforward"), currentAmountDebit, currentAmountCredit));
+ forwardParagraph.add(createLedgerAmountTable("",
+ _("lima-business.document.carryforward"),
+ currentAmountDebit, currentAmountCredit));
chapter.add(forwardParagraph);
}
//final amounts
if (i>=n-max){
Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createLedgerAmountTable("", _("lima-business.document.amounts"), currentAmountDebit, currentAmountCredit));
+ finalAmountParagraph.add(createLedgerAmountTable("",
+ _("lima-business.document.amounts"),
+ currentAmountDebit, currentAmountCredit));
chapter.add(finalAmountParagraph);
}
//add page
@@ -599,13 +636,18 @@
Double amountDebit = entry.getDebit() ? entry.getAmount() : 0;
Double amountCredit = entry.getDebit() ? 0 : entry.getAmount();
- t.addCell(new Phrase(dateFormat.format(entry.getFinancialTransaction().getTransactionDate()), normalFont));
+ t.addCell(new Phrase(dateFormat.format(
+ entry.getFinancialTransaction().getTransactionDate()),
+ normalFont));
t.addCell(new Phrase(entryBookCode, normalFont));
t.addCell(new Phrase(entry.getVoucher(), normalFont));
t.addCell(new Phrase(entry.getDescription(), normalFont));
- t.addCell(new Phrase(String.valueOf(amountDebit), normalFont));
- t.addCell(new Phrase(String.valueOf(amountCredit), normalFont));
- t.addCell(new Phrase(String.valueOf(amountDebit-amountCredit), normalFont));
+ t.addCell(new Phrase(String.valueOf(amountDebit),
+ normalFont));
+ t.addCell(new Phrase(String.valueOf(amountCredit),
+ normalFont));
+ t.addCell(new Phrase(String.valueOf(amountDebit-amountCredit),
+ normalFont));
}
}
@@ -672,17 +714,25 @@
Identity identity = identityService.getIdentity();
- ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
//Split list by financialstatement type
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList = closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
+ closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
TopiaQuery query = entryDAO.createQuery();
- String financialPeriodProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.FINANCIAL_PERIOD);
- String entryBookProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK);
- query.addWhere(financialPeriodProperty, Op.EQ, closedPeriodicEntryBook.getFinancialPeriod())
- .addWhere(entryBookProperty, Op.EQ, closedPeriodicEntryBook.getEntryBook());
+ String financialPeriodProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.FINANCIAL_PERIOD);
+ String entryBookProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.ENTRY_BOOK);
+ query.addWhere(financialPeriodProperty, Op.EQ,
+ closedPeriodicEntryBook.getFinancialPeriod())
+ .addWhere(entryBookProperty, Op.EQ,
+ closedPeriodicEntryBook.getEntryBook());
List<Entry> entries = entryDAO.findAllByQuery(query);
@@ -707,7 +757,9 @@
}
//create pages
- String title = closedPeriodicEntryBook.getEntryBook().getLabel() + "\n" + monthYearFormat.format(closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
+ String title = closedPeriodicEntryBook.getEntryBook().getLabel()
+ + "\n" + monthYearFormat.format(
+ closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
//list = list.subList(1, list.size());
int i=0;
int n=entries.size();
@@ -720,29 +772,15 @@
List <Entry> subEntries =
entries.subList(i, j);
//create page : header + table + footer
- Table headerPage = createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate));
Table headerTable = createEntryBooksHeaderTable();
Table table = createEntryBooksTable(subEntries);
//new page
Chapter chapter = new Chapter(0);
- //headerPage
- Paragraph paragraphHeaderPage = new Paragraph();
- paragraphHeaderPage.add(headerPage);
- chapter.add(paragraphHeaderPage);
- //n° page
- Paragraph paragraphPage = new Paragraph();
- Table infos = new Table(2);
- infos.setWidth(100f);
- infos.setBorder(Rectangle.NO_BORDER);
- infos.setOffset(2);
- Cell c = new Cell();
- c.setBorder(Rectangle.NO_BORDER);
- c.setHorizontalAlignment(Element.ALIGN_CENTER);
- infos.setDefaultCell(c);
- infos.addCell(new Phrase(_("lima-business.document.createdate1") + dateS + _("lima-business.document.createdate2") + hourS, normalFont));
- infos.addCell(new Phrase(_("lima-business.document.pagenumber")+nbpages, normalFont));
- paragraphPage.add(infos);
- chapter.add(paragraphPage);
+ //headerPage
+ chapter.add(createHeaderPage(title, identity,
+ dateFormat.format(beginDate), dateFormat.format(endDate)));
+ //n° page
+ chapter.add(createNumberPage(nbpages, dateS, hourS));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -754,7 +792,8 @@
//final amounts
if (i>=n-max){
Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createEntryBooksAmountTable(_("lima-business.document.amounts"), debit, credit));
+ finalAmountParagraph.add(createEntryBooksAmountTable(
+ _("lima-business.document.amounts"), debit, credit));
chapter.add(finalAmountParagraph);
}
//add page
@@ -824,12 +863,16 @@
t.setDefaultCell(cell);
for (Entry entry : entries) {
- t.addCell(new Phrase(dateFormat.format(entry.getFinancialTransaction().getTransactionDate()), normalFont));
+ t.addCell(new Phrase(dateFormat.format(
+ entry.getFinancialTransaction().getTransactionDate()),
+ normalFont));
t.addCell(new Phrase(entry.getAccount().getAccountNumber(), normalFont));
t.addCell(new Phrase(entry.getVoucher(), normalFont));
t.addCell(new Phrase(entry.getDescription(), normalFont));
- t.addCell(new Phrase(String.valueOf(entry.getDebit() ? entry.getAmount() : 0), normalFont));
- t.addCell(new Phrase(String.valueOf(entry.getDebit() ? entry.getAmount() : 0), normalFont));
+ t.addCell(new Phrase(String.valueOf(
+ entry.getDebit() ? entry.getAmount() : 0), normalFont));
+ t.addCell(new Phrase(String.valueOf(
+ entry.getDebit() ? entry.getAmount() : 0), normalFont));
}
} catch (BadElementException eeBEE) {
@@ -869,7 +912,7 @@
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
BalanceTrial balanceTrial =
- reportService.generateBalanceTrial(beginDate, endDate, null, false, false);
+ reportService.generateBalanceTrial(beginDate, endDate, null, false, true);
List<ReportsDatas> list = (List<ReportsDatas>) balanceTrial.getReportsDatas();
@@ -904,28 +947,13 @@
}
List <ReportsDatas> subList = list.subList(i, j);
//create page : header + table + footer
- Table headerPage = createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate));
Table headerTable = createBalanceHeaderTable();
//new page
Chapter chapter = new Chapter(0);
//headerPage
- Paragraph paragraphHeaderPage = new Paragraph();
- paragraphHeaderPage.add(headerPage);
- chapter.add(paragraphHeaderPage);
+ chapter.add(createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate)));
//n° page
- Paragraph paragraphPage = new Paragraph();
- Table infos = new Table(2);
- infos.setWidth(100f);
- infos.setBorder(Rectangle.NO_BORDER);
- infos.setOffset(2);
- Cell c = new Cell();
- c.setBorder(Rectangle.NO_BORDER);
- c.setHorizontalAlignment(Element.ALIGN_CENTER);
- infos.setDefaultCell(c);
- infos.addCell(new Phrase(_("lima-business.document.createdate1") + dateS + _("lima-business.document.createdate2") + hourS, normalFont));
- infos.addCell(new Phrase(_("lima-business.document.pagenumber") + nbpages, normalFont));
- paragraphPage.add(infos);
- chapter.add(paragraphPage);
+ chapter.add(createNumberPage(nbpages, dateS, hourS));
//headerTable
Paragraph paragraphHeaderTable = new Paragraph();
paragraphHeaderTable.add(headerTable);
@@ -933,7 +961,10 @@
//backward amounts
if (n>max && nbpages>1){
Paragraph backwardParagraph = new Paragraph();
- backwardParagraph.add(createBalanceAmountTable(_("lima-business.document.carryback"), currentAmountDebit, currentAmountCredit, currentSoldeDebit, currentSoldeCredit));
+ backwardParagraph.add(createBalanceAmountTable(
+ _("lima-business.document.carryback"),
+ currentAmountDebit, currentAmountCredit,
+ currentSoldeDebit, currentSoldeCredit));
chapter.add(backwardParagraph);
}
//table
@@ -944,19 +975,27 @@
for (ReportsDatas reportsDatas : subList){
currentAmountDebit += reportsDatas.getAmountDebit();
currentAmountCredit += reportsDatas.getAmountCredit();
- currentSoldeDebit += reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0;
- currentSoldeCredit += reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde();
+ currentSoldeDebit +=
+ reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0;
+ currentSoldeCredit +=
+ reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde();
}
//forward amounts
if (n>max && i<=n-max){
Paragraph forwardParagraph = new Paragraph();
- forwardParagraph.add(createBalanceAmountTable(_("lima-business.document.carryforward"), currentAmountDebit, currentAmountCredit, currentSoldeDebit, currentSoldeCredit));
+ forwardParagraph.add(createBalanceAmountTable(
+ _("lima-business.document.carryforward"),
+ currentAmountDebit, currentAmountCredit,
+ currentSoldeDebit, currentSoldeCredit));
chapter.add(forwardParagraph);
}
//final amounts
if (i>=n-max){
Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createBalanceAmountTable(_("lima-business.document.amounts"), currentAmountDebit, currentAmountCredit, currentSoldeDebit, currentSoldeCredit));
+ finalAmountParagraph.add(createBalanceAmountTable(
+ _("lima-business.document.amounts"),
+ currentAmountDebit, currentAmountCredit,
+ currentSoldeDebit, currentSoldeCredit));
chapter.add(finalAmountParagraph);
}
//add page
@@ -1064,7 +1103,267 @@
return t;
}
+ //############## General EntryBook ##############
+
+ @Override
+ public void createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException {
+ Document document = new Document(PageSize.A4, 8, 8, 8, 8);
+ TopiaContext transaction = null;
+
+ try {
+ transaction = beginTransaction();
+
+ Date newDate = new Date();
+ String dateS = dateFormat.format(newDate);
+ String hourS = hourFormat.format(newDate);
+ String fileDateS = filedateFormat.format(newDate);
+
+ PdfWriter pdfWriter = PdfWriter.getInstance(document,
+ new FileOutputStream("/lima_Gebs"+fileDateS+".pdf"));
+ HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
+ new FileOutputStream("/lima_Gebs"+fileDateS+".html"));
+ document.open();
+ int nbpages = 1;
+
+ Identity identity = identityService.getIdentity();
+
+ FinancialPeriodDAO financialPeriodDAO =
+ LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
+ LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
+
+
+ TopiaQuery financialPeriodsQuery = financialPeriodDAO.createQuery();
+ String beginDateProperty = TopiaQuery.getProperty(FinancialPeriod.BEGIN_DATE);
+ String endDateProperty = TopiaQuery.getProperty(FinancialPeriod.BEGIN_DATE);
+ financialPeriodsQuery.addWhere(beginDateProperty, Op.GE, beginDate)
+ .addWhere(endDateProperty, Op.LE, endDate)
+ .addOrder(beginDateProperty);
+ List<FinancialPeriod> financialPeriods =
+ financialPeriodDAO.findAllByQuery(financialPeriodsQuery);
+
+ List<GeneralEntryBooksDatas> list = new ArrayList<GeneralEntryBooksDatas>();
+ Double amountDebit = 0.0;
+ Double amountCredit = 0.0;
+ for (FinancialPeriod financialPeriod : financialPeriods) {
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList =
+ closedPeriodicEntryBookDAO.findAllByDates(
+ financialPeriod.getBeginDate(), financialPeriod.getEndDate());
+
+ Double subAmountDebit = 0.0;
+ Double subAmountCredit = 0.0;
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
+
+ List<Object[]> results = new ArrayList<Object[]>();
+ TopiaQuery query = entryDAO.createQuery();
+ Double debit = 0.0;
+ Double credit = 0.0;
+
+ String financialPeriodProperty = TopiaQuery.getProperty(
+ Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.FINANCIAL_PERIOD);
+ String entryBookProperty = TopiaQuery.getProperty(
+ Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.ENTRY_BOOK);
+ query.addWhere(financialPeriodProperty, Op.EQ,
+ closedPeriodicEntryBook.getFinancialPeriod())
+ .addWhere(entryBookProperty, Op.EQ,
+ closedPeriodicEntryBook.getEntryBook())
+ .setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")")
+ .addGroup(Entry.DEBIT);
+ results = query.execute(transaction);
+
+ int nbAmount = results.size();
+ if(nbAmount==2){
+ debit = (Double)results.get(0)[1];
+ credit = (Double)results.get(1)[1];
+ }
+ if (nbAmount==1){
+ if ((Boolean)results.get(0)[0]){
+ debit = (Double)results.get(0)[1];
+ }
+ else {
+ credit = (Double)results.get(0)[1];
+ }
+ }
+ GeneralEntryBooksDatas generalEntryBooksDatas =
+ new GeneralEntryBooksDatasImpl();
+ generalEntryBooksDatas.setCode(
+ closedPeriodicEntryBook.getEntryBook().getCode());
+ generalEntryBooksDatas.setDescription(
+ closedPeriodicEntryBook.getEntryBook().getLabel());
+ generalEntryBooksDatas.setPeriod(
+ monthYearFormat.format(financialPeriod.getBeginDate()));
+ generalEntryBooksDatas.setCredit(credit);
+ generalEntryBooksDatas.setDebit(debit);
+ list.add(generalEntryBooksDatas);
+ subAmountCredit += credit;
+ subAmountDebit += debit;
+ }
+ GeneralEntryBooksDatas generalEntryBooksDatas =
+ new GeneralEntryBooksDatasImpl();
+ generalEntryBooksDatas.setSubAmount(true);
+ generalEntryBooksDatas.setCredit(subAmountCredit);
+ generalEntryBooksDatas.setDebit(subAmountDebit);
+ generalEntryBooksDatas.setPeriod(
+ monthYearFormat.format(financialPeriod.getBeginDate()));
+ list.add(generalEntryBooksDatas);
+ amountCredit += subAmountCredit;
+ amountDebit += subAmountDebit;
+ }
+ GeneralEntryBooksDatas generalEntryBooksDatas =
+ new GeneralEntryBooksDatasImpl();
+ generalEntryBooksDatas.setAmount(true);
+ generalEntryBooksDatas.setCredit(amountCredit);
+ generalEntryBooksDatas.setDebit(amountDebit);
+ list.add(generalEntryBooksDatas);
+
+
+ //create pages
+ int i=0;
+ int n=list.size();
+ int max=35;
+ while (i<n){
+ int j=i+max;
+ if (j>n){
+ j = n;
+ }
+ List <GeneralEntryBooksDatas> subList =
+ list.subList(i, j);
+ //create page : header + table + footer
+ Table headerTable = createGeneralEntryBooksHeaderTable();
+ Table table = createGeneralEntryBooksTable(subList);
+ //new page
+ Chapter chapter = new Chapter(0);
+ //headerPage
+ chapter.add(createHeaderPage(
+ _("lima-business.document.generalentrybook"),
+ identity, dateFormat.format(beginDate),
+ dateFormat.format(endDate)));
+ //n° page
+ chapter.add(createNumberPage(nbpages, dateS, hourS));
+ //headerTable
+ Paragraph paragraphHeaderTable = new Paragraph();
+ paragraphHeaderTable.add(headerTable);
+ chapter.add(paragraphHeaderTable);
+ //table
+ Paragraph paragraphTable = new Paragraph();
+ paragraphTable.add(table);
+ chapter.add(paragraphTable);
+ //add page
+ document.add(chapter);
+ i=i+max;
+ nbpages++;
+ }
+
+ document.close();
+
+ } catch (FileNotFoundException eeFNFE) {
+ log.error("Can't create pdf file", eeFNFE);
+ } catch (DocumentException eeDE) {
+ log.error("Can't create document", eeDE);
+ } catch (TopiaException eeTE) {
+ log.error("Can't get entries", eeTE);
+ }
+
+ }
+
+ public Table createGeneralEntryBooksHeaderTable(){
+ Table t = null;
+ try {
+ t = new Table(5,1);
+ float[] widths = {0.1f, 0.45f, 0.15f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setWidth(100f);
+ t.setPadding(3f);
+ //defaut cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.LEFT);
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
+ t.setDefaultCell(cell);
+ t.setOffset(8);
+ t.addCell(new Phrase(_("lima-business.document.entrybook"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.label"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.date"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.debit"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.credit"), boldFont));
+
+ } catch (BadElementException eeBEE) {
+ log.error("Can't create table", eeBEE);
+ }
+ return t;
+
+ }
+
+ public Table createGeneralEntryBooksTable(List <GeneralEntryBooksDatas> list){
+ int nbrow = list.size();
+ Table t = null;
+ try {
+ //define table
+ t = new Table(5,nbrow);
+ t.setWidth(100f);
+ float[] widths = {0.1f, 0.45f, 0.15f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setPadding(1.5f);
+ t.setBorderWidth(1);
+ t.setOffset(0);
+ //define default cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.LEFT);
+ cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
+ t.setDefaultCell(cell);
+
+ for (GeneralEntryBooksDatas generalEntryBooksDatas : list) {
+ if (!generalEntryBooksDatas.getAmount() && !generalEntryBooksDatas.getSubAmount()){
+ t.addCell(new Phrase(
+ generalEntryBooksDatas.getCode(), normalFont));
+ t.addCell(new Phrase(
+ generalEntryBooksDatas.getDescription(), normalFont));
+ t.addCell(new Phrase(
+ generalEntryBooksDatas.getPeriod(), normalFont));
+ t.addCell(new Phrase(
+ String.valueOf(generalEntryBooksDatas.getDebit()),
+ normalFont));
+ t.addCell(new Phrase(
+ String.valueOf(generalEntryBooksDatas.getCredit()),
+ normalFont));
+ }
+ else {
+ Phrase phrase = null;
+ if (generalEntryBooksDatas.getAmount()){
+ phrase = new Phrase(_("lima-business.document.amounts"),
+ boldFont);
+ }
+ else {
+ phrase = new Phrase(_("lima-business.document.amounts")
+ + " " + generalEntryBooksDatas.getPeriod(),
+ boldFont);
+ }
+ Cell cell2 = new Cell(phrase);
+ cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM);
+ cell2.setColspan(3);
+ t.addCell(cell2);
+ cell2 = new Cell(new Phrase(
+ String.valueOf(generalEntryBooksDatas.getDebit()),
+ boldFont));
+ cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM);
+ t.addCell(cell2);
+ cell2 = new Cell(new Phrase(
+ String.valueOf(generalEntryBooksDatas.getCredit()),
+ boldFont));
+ cell2.setBorder(Rectangle.TOP+Rectangle.BOTTOM);
+ t.addCell(cell2);
+ }
+ }
+
+ } catch (BadElementException eeBEE) {
+ log.error("Can't create table", eeBEE);
+ }
+ return t;
+ }
+
protected TopiaContext beginTransaction() throws TopiaException {
// basic check done, make check in database
// TODO move it into JTA
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2010-08-02 16:54:10 UTC (rev 2992)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2010-08-03 10:41:31 UTC (rev 2993)
@@ -34,7 +34,9 @@
public interface DocumentService {
public void createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException;
- public void createLedgerDocuments(List<Object> objects, Date beginDate, Date endDate) throws LimaException;
+ public void createLedgerDocuments(Date beginDate, Date endDate) throws LimaException;
public void createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
public void createBalanceDocuments(Date beginDate, Date endDate) throws LimaException;
+ public void createGeneralEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+
}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-02 16:54:10 UTC (rev 2992)
+++ trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-03 10:41:31 UTC (rev 2993)
@@ -20,6 +20,7 @@
lima-business.document.debit=Debit
lima-business.document.description=Description
lima-business.document.entrybook=EntryBook
+lima-business.document.generalentrybook=
lima-business.document.grossamount=Gross Amount
lima-business.document.label=Label
lima-business.document.ledger=
Modified: trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-02 16:54:10 UTC (rev 2992)
+++ trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-03 10:41:31 UTC (rev 2993)
@@ -15,6 +15,7 @@
lima-business.document.debit=D\u00E9bit
lima-business.document.description=Description
lima-business.document.entrybook=Journal
+lima-business.document.generalentrybook=Journal G\u00E9n\u00E9ral
lima-business.document.grossamount=Brut
lima-business.document.label=Libell\u00E9
lima-business.document.ledger=Grand Livre
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
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-08-02 16:54:10 UTC (rev 2992)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-08-03 10:41:31 UTC (rev 2993)
@@ -151,6 +151,7 @@
public void createPdf() {
try {
documentService.createEntryBooksDocuments(selectedBeginDate, selectedEndDate);
+ documentService.createGeneralEntryBooksDocuments(selectedBeginDate, selectedEndDate);
} catch (LimaException eee) {
if(log.isDebugEnabled()){
log.debug("Can't create PDF", eee);
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-08-02 16:54:10 UTC (rev 2992)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-08-03 10:41:31 UTC (rev 2993)
@@ -160,7 +160,7 @@
public void createPdf() {
try {
- documentService.createLedgerDocuments(cachedatasList, selectedBeginDate, selectedEndDate);
+ documentService.createLedgerDocuments(selectedBeginDate, selectedEndDate);
} catch (LimaException eee) {
if(log.isDebugEnabled()){
log.debug("Can't create PDF", eee);
1
0
Author: jpepin
Date: 2010-08-02 18:54:10 +0200 (Mon, 02 Aug 2010)
New Revision: 2992
Url: http://chorem.org/repositories/revision/lima/2992
Log:
Sortie document pdf balance et journaux.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.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/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java
trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java
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-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -173,7 +173,7 @@
for (EntryBook entryBook : entryBooks) {
ClosedPeriodicEntryBook closedPeriodicEntryBook =
- closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(
+ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
entryBook, financialPeriod);
if(closedPeriodicEntryBook.getLocked()){
closedEntryBooks.add(entryBook);
@@ -237,7 +237,7 @@
//second case
ClosedPeriodicEntryBook closedPeriodicEntryBook =
- closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(
+ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
entryOld.getFinancialTransaction().getEntryBook(), financialPeriod);
if (closedPeriodicEntryBook.getLocked()){
throw new LimaBusinessException("2 - Can't update entry : financialperiod of this entrybook is closed");
@@ -245,7 +245,7 @@
//third case
ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
- closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(
+ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
entry.getFinancialTransaction().getEntryBook(), financialPeriod);
// Check 2 & 3 cases
@@ -293,7 +293,7 @@
//3. the actual entrybook belong to a blocked closedPeriodicEntryBook
ClosedPeriodicEntryBook closedPeriodicEntryBookOld =
- closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(
+ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
financialTransactionOld.getEntryBook(), financialPeriod);
if (closedPeriodicEntryBookOld.getLocked()){
throw new LimaBusinessException("Can't update financialtransaction : financialperiod of this entrybook is closed");
@@ -301,7 +301,7 @@
//4. the new entrybook belong to a blocked closedPeriodicEntryBook
ClosedPeriodicEntryBook closedPeriodicEntryBook =
- closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(
+ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
financialTransaction.getEntryBook(), financialPeriod);
if (closedPeriodicEntryBook.getLocked()){
throw new LimaBusinessException("Can't update financialtransaction : financialperiod of new entrybook is closed");
@@ -309,7 +309,7 @@
//5. the actual entrybook belong to a blocked closedPeriodicEntryBook
ClosedPeriodicEntryBook closedPeriodicEntryBookOld2 =
- closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(
+ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
financialTransactionOld.getEntryBook(), financialPeriodOld);
if (closedPeriodicEntryBookOld2.getLocked()){
throw new LimaBusinessException("Can't update financialtransaction : the new financialperiod of this entrybook is closed");
@@ -317,7 +317,7 @@
//6. the new entrybook belong to a blocked closedPeriodicEntryBook
ClosedPeriodicEntryBook closedPeriodicEntryBook2 =
- closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(
+ closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(
financialTransaction.getEntryBook(), financialPeriodOld);
if (closedPeriodicEntryBook2.getLocked()){
throw new LimaBusinessException("Can't update financialtransaction : this financialperiod of new entrybook is closed");
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -31,21 +31,33 @@
import javax.ejb.Stateless;
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.LimaConfig;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ejbinterface.DocumentService;
import org.chorem.lima.business.ejbinterface.DocumentServiceLocal;
+import org.chorem.lima.business.ejbinterface.EntryBookService;
+import org.chorem.lima.business.ejbinterface.FinancialStatementService;
import org.chorem.lima.business.ejbinterface.IdentityService;
+import org.chorem.lima.business.ejbinterface.ReportService;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.Identity;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.Chapter;
@@ -73,6 +85,15 @@
@EJB
IdentityService identityService;
+ @EJB
+ EntryBookService entryBookService;
+
+ @EJB
+ FinancialStatementService financialStatementService;
+
+ @EJB
+ ReportService reportService;
+
//SDFs
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("dd/MM/yyyy");
@@ -80,6 +101,8 @@
new SimpleDateFormat("HH:mm");
private static SimpleDateFormat filedateFormat =
new SimpleDateFormat("dd-MM-yyyy_HH-mm");
+ private static SimpleDateFormat monthYearFormat =
+ new SimpleDateFormat("MMM yyyy");
//FONTs
private static Font titleFont =
@@ -158,14 +181,16 @@
return t;
}
-
+
//############## FinancialStatements ##############
@Override
- public void createFinancialStatementsDocuments(List<FinancialStatementAmounts> financialStatementAmounts, Date beginDate, Date endDate) throws LimaException {
+ public void createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
+ List<FinancialStatementAmounts> financialStatementAmounts = financialStatementService.financialStatementReport(beginDate, endDate);
+
try {
Date newDate = new Date();
String dateS = dateFormat.format(newDate);
@@ -383,8 +408,7 @@
@Override
- public void createLedgerDocuments(List<Object> list, Date beginDate,
- Date endDate) throws LimaException {
+ public void createLedgerDocuments(List<Object> list, Date beginDate, Date endDate) throws LimaException {
Document document = new Document(PageSize.A4, 8, 8, 8, 8);
try {
@@ -472,13 +496,13 @@
//forward amounts
if (n>max && i<=n-max){
Paragraph forwardParagraph = new Paragraph();
- forwardParagraph.add(createLedgerAmountTable("", _("", "lima-business.document.carryforward"), currentAmountDebit, currentAmountCredit));
+ forwardParagraph.add(createLedgerAmountTable("", _("lima-business.document.carryforward"), currentAmountDebit, currentAmountCredit));
chapter.add(forwardParagraph);
}
//final amounts
if (i>=n-max){
Paragraph finalAmountParagraph = new Paragraph();
- finalAmountParagraph.add(createLedgerAmountTable("", _("lima-business.document.amount"), currentAmountDebit, currentAmountCredit));
+ finalAmountParagraph.add(createLedgerAmountTable("", _("lima-business.document.amounts"), currentAmountDebit, currentAmountCredit));
chapter.add(finalAmountParagraph);
}
//add page
@@ -524,37 +548,6 @@
}
- public Table createLedgerAmountTable(String account, String title, Double credit, Double debit){
- Table t = null;
- try {
- t = new Table(5,1);
- float[] widths = {0.4f,0.15f, 0.15f, 0.15f, 0.15f};
- t.setWidths(widths);
- t.setWidth(100f);
- t.setPadding(3f);
- t.setOffset(0);
- //defaut cell
- Cell cell = new Cell();
- cell.setBorder(Rectangle.RIGHT);
- cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
- t.setDefaultCell(cell);
-
- Cell accountCell = new Cell(new Phrase(account, boldFont));
- accountCell.setHorizontalAlignment(Element.ALIGN_LEFT);
- accountCell.setBorder(Rectangle.NO_BORDER);
- t.addCell(accountCell);
- t.addCell(new Phrase(title, boldFont));
- t.addCell(new Phrase(debit.toString(), boldFont));
- t.addCell(new Phrase(credit.toString(), boldFont));
- Double solde = debit-credit;
- t.addCell(new Phrase(solde.toString(), boldFont));
- } catch (BadElementException eeBEE) {
- log.error("Can't create table", eeBEE);
- }
- return t;
-
- }
-
public Table createLedgerTable(List<Object> subList){
int nbrow = subList.size();
Table t = null;
@@ -623,7 +616,456 @@
return t;
}
- protected TopiaContext beginTransaction() throws TopiaException {
+ public Table createLedgerAmountTable(String account, String title, Double credit, Double debit){
+ Table t = null;
+ try {
+ t = new Table(5,1);
+ float[] widths = {0.4f,0.15f, 0.15f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setWidth(100f);
+ t.setPadding(3f);
+ t.setOffset(0);
+ //defaut cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.RIGHT);
+ cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
+ t.setDefaultCell(cell);
+
+ Cell accountCell = new Cell(new Phrase(account, boldFont));
+ accountCell.setHorizontalAlignment(Element.ALIGN_LEFT);
+ accountCell.setBorder(Rectangle.NO_BORDER);
+ t.addCell(accountCell);
+ t.addCell(new Phrase(title, boldFont));
+ t.addCell(new Phrase(debit.toString(), boldFont));
+ t.addCell(new Phrase(credit.toString(), boldFont));
+ Double solde = debit-credit;
+ t.addCell(new Phrase(solde.toString(), boldFont));
+ } catch (BadElementException eeBEE) {
+ log.error("Can't create table", eeBEE);
+ }
+ return t;
+ }
+
+ //############## EntryBooks ##############
+
+
+
+ @Override
+ public void createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException {
+ Document document = new Document(PageSize.A4, 8, 8, 8, 8);
+ TopiaContext transaction = null;
+
+ try {
+ transaction = beginTransaction();
+
+ Date newDate = new Date();
+ String dateS = dateFormat.format(newDate);
+ String hourS = hourFormat.format(newDate);
+ String fileDateS = filedateFormat.format(newDate);
+
+ PdfWriter pdfWriter = PdfWriter.getInstance(document,
+ new FileOutputStream("/lima_ebs"+fileDateS+".pdf"));
+ HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
+ new FileOutputStream("/lima_ebs"+fileDateS+".html"));
+ document.open();
+ int nbpages = 1;
+
+ Identity identity = identityService.getIdentity();
+
+ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction);
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction);
+ //Split list by financialstatement type
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBookList = closedPeriodicEntryBookDAO.findAllByDates(beginDate, endDate);
+ for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBookList) {
+
+ TopiaQuery query = entryDAO.createQuery();
+ String financialPeriodProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.FINANCIAL_PERIOD);
+ String entryBookProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK);
+ query.addWhere(financialPeriodProperty, Op.EQ, closedPeriodicEntryBook.getFinancialPeriod())
+ .addWhere(entryBookProperty, Op.EQ, closedPeriodicEntryBook.getEntryBook());
+
+ List<Entry> entries = entryDAO.findAllByQuery(query);
+
+ List<Object[]> results = new ArrayList<Object[]>();
+ Double debit = 0.0;
+ Double credit = 0.0;
+ query.setSelect(Entry.DEBIT, "SUM("+Entry.AMOUNT+")");
+ query.addGroup(Entry.DEBIT);
+ results = query.execute(transaction);
+ int nbAmount = results.size();
+ if(nbAmount==2){
+ debit = (Double)results.get(0)[1];
+ credit = (Double)results.get(1)[1];
+ }
+ if (nbAmount==1){
+ if ((Boolean)results.get(0)[0]){
+ debit = (Double)results.get(0)[1];
+ }
+ else {
+ credit = (Double)results.get(0)[1];
+ }
+ }
+
+ //create pages
+ String title = closedPeriodicEntryBook.getEntryBook().getLabel() + "\n" + monthYearFormat.format(closedPeriodicEntryBook.getFinancialPeriod().getBeginDate());
+ //list = list.subList(1, list.size());
+ int i=0;
+ int n=entries.size();
+ int max=35;
+ while (i<n){
+ int j=i+max;
+ if (j>n){
+ j = n;
+ }
+ List <Entry> subEntries =
+ entries.subList(i, j);
+ //create page : header + table + footer
+ Table headerPage = createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate));
+ Table headerTable = createEntryBooksHeaderTable();
+ Table table = createEntryBooksTable(subEntries);
+ //new page
+ Chapter chapter = new Chapter(0);
+ //headerPage
+ Paragraph paragraphHeaderPage = new Paragraph();
+ paragraphHeaderPage.add(headerPage);
+ chapter.add(paragraphHeaderPage);
+ //n° page
+ Paragraph paragraphPage = new Paragraph();
+ Table infos = new Table(2);
+ infos.setWidth(100f);
+ infos.setBorder(Rectangle.NO_BORDER);
+ infos.setOffset(2);
+ Cell c = new Cell();
+ c.setBorder(Rectangle.NO_BORDER);
+ c.setHorizontalAlignment(Element.ALIGN_CENTER);
+ infos.setDefaultCell(c);
+ infos.addCell(new Phrase(_("lima-business.document.createdate1") + dateS + _("lima-business.document.createdate2") + hourS, normalFont));
+ infos.addCell(new Phrase(_("lima-business.document.pagenumber")+nbpages, normalFont));
+ paragraphPage.add(infos);
+ chapter.add(paragraphPage);
+ //headerTable
+ Paragraph paragraphHeaderTable = new Paragraph();
+ paragraphHeaderTable.add(headerTable);
+ chapter.add(paragraphHeaderTable);
+ //table
+ Paragraph paragraphTable = new Paragraph();
+ paragraphTable.add(table);
+ chapter.add(paragraphTable);
+ //final amounts
+ if (i>=n-max){
+ Paragraph finalAmountParagraph = new Paragraph();
+ finalAmountParagraph.add(createEntryBooksAmountTable(_("lima-business.document.amounts"), debit, credit));
+ chapter.add(finalAmountParagraph);
+ }
+ //add page
+ document.add(chapter);
+ i=i+max;
+ nbpages++;
+ }
+ }
+
+ document.close();
+
+ } catch (FileNotFoundException eeFNFE) {
+ log.error("Can't create pdf file", eeFNFE);
+ } catch (DocumentException eeDE) {
+ log.error("Can't create document", eeDE);
+ } catch (TopiaException eeTE) {
+ log.error("Can't get entries", eeTE);
+
+ }
+
+ }
+
+ public Table createEntryBooksHeaderTable(){
+ Table t = null;
+ try {
+ t = new Table(6,1);
+ float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setWidth(100f);
+ t.setPadding(3f);
+ //defaut cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.LEFT);
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
+ t.setDefaultCell(cell);
+ t.setOffset(8);
+ t.addCell(new Phrase(_("lima-business.document.date"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.accountnumber"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.voucher"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.description"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.debit"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.credit"), boldFont));
+
+ } catch (BadElementException eeBEE) {
+ log.error("Can't create table", eeBEE);
+ }
+ return t;
+
+ }
+
+ public Table createEntryBooksTable(List<Entry> entries){
+ int nbrow = entries.size();
+ Table t = null;
+ try {
+ //define table
+ t = new Table(6,nbrow);
+ t.setWidth(100f);
+ float[] widths = {0.1f, 0.1f, 0.1f, 0.4f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setPadding(1.5f);
+ t.setBorderWidth(1);
+ t.setOffset(0);
+ //define default cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.LEFT);
+ cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
+ t.setDefaultCell(cell);
+
+ for (Entry entry : entries) {
+ t.addCell(new Phrase(dateFormat.format(entry.getFinancialTransaction().getTransactionDate()), normalFont));
+ t.addCell(new Phrase(entry.getAccount().getAccountNumber(), normalFont));
+ t.addCell(new Phrase(entry.getVoucher(), normalFont));
+ t.addCell(new Phrase(entry.getDescription(), normalFont));
+ t.addCell(new Phrase(String.valueOf(entry.getDebit() ? entry.getAmount() : 0), normalFont));
+ t.addCell(new Phrase(String.valueOf(entry.getDebit() ? entry.getAmount() : 0), normalFont));
+ }
+
+ } catch (BadElementException eeBEE) {
+ log.error("Can't create table", eeBEE);
+ }
+ return t;
+ }
+
+ public Table createEntryBooksAmountTable(String title, Double credit, Double debit){
+ Table t = null;
+ try {
+ t = new Table(3,1);
+ float[] widths = {0.7f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setWidth(100f);
+ t.setPadding(3f);
+ t.setOffset(0);
+ //defaut cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.RIGHT);
+ cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
+ t.setDefaultCell(cell);
+
+ t.addCell(new Phrase(title, boldFont));
+ t.addCell(new Phrase(debit.toString(), boldFont));
+ t.addCell(new Phrase(credit.toString(), boldFont));
+ } catch (BadElementException eeBEE) {
+ log.error("Can't create table", eeBEE);
+ }
+ return t;
+ }
+
+ //############## Balance ##############
+
+ @Override
+ public void createBalanceDocuments(Date beginDate, Date endDate) throws LimaException {
+ Document document = new Document(PageSize.A4, 8, 8, 8, 8);
+
+ BalanceTrial balanceTrial =
+ reportService.generateBalanceTrial(beginDate, endDate, null, false, false);
+
+ List<ReportsDatas> list = (List<ReportsDatas>) balanceTrial.getReportsDatas();
+
+ try {
+ Date newDate = new Date();
+ String dateS = dateFormat.format(newDate);
+ String hourS = hourFormat.format(newDate);
+ String fileDateS = filedateFormat.format(newDate);
+
+ Double currentAmountDebit = 0.0;
+ Double currentAmountCredit = 0.0;
+ Double currentSoldeDebit = 0.0;
+ Double currentSoldeCredit = 0.0;
+
+ PdfWriter pdfWriter = PdfWriter.getInstance(document,
+ new FileOutputStream("/balance_lima"+fileDateS+".pdf"));
+ HtmlWriter htmlWriter = HtmlWriter.getInstance(document,
+ new FileOutputStream("/balance_lima"+fileDateS+".html"));
+ document.open();
+ int nbpages = 1;
+ Identity identity = identityService.getIdentity();
+
+ //create pages
+ String title = _("lima-business.document.balance");
+ int i=0;
+ int n=list.size();
+ int max = 26;
+ while (i<n){
+ int j = i+max;
+ if (j>n){
+ j = n;
+ }
+ List <ReportsDatas> subList = list.subList(i, j);
+ //create page : header + table + footer
+ Table headerPage = createHeaderPage(title, identity, dateFormat.format(beginDate), dateFormat.format(endDate));
+ Table headerTable = createBalanceHeaderTable();
+ //new page
+ Chapter chapter = new Chapter(0);
+ //headerPage
+ Paragraph paragraphHeaderPage = new Paragraph();
+ paragraphHeaderPage.add(headerPage);
+ chapter.add(paragraphHeaderPage);
+ //n° page
+ Paragraph paragraphPage = new Paragraph();
+ Table infos = new Table(2);
+ infos.setWidth(100f);
+ infos.setBorder(Rectangle.NO_BORDER);
+ infos.setOffset(2);
+ Cell c = new Cell();
+ c.setBorder(Rectangle.NO_BORDER);
+ c.setHorizontalAlignment(Element.ALIGN_CENTER);
+ infos.setDefaultCell(c);
+ infos.addCell(new Phrase(_("lima-business.document.createdate1") + dateS + _("lima-business.document.createdate2") + hourS, normalFont));
+ infos.addCell(new Phrase(_("lima-business.document.pagenumber") + nbpages, normalFont));
+ paragraphPage.add(infos);
+ chapter.add(paragraphPage);
+ //headerTable
+ Paragraph paragraphHeaderTable = new Paragraph();
+ paragraphHeaderTable.add(headerTable);
+ chapter.add(paragraphHeaderTable);
+ //backward amounts
+ if (n>max && nbpages>1){
+ Paragraph backwardParagraph = new Paragraph();
+ backwardParagraph.add(createBalanceAmountTable(_("lima-business.document.carryback"), currentAmountDebit, currentAmountCredit, currentSoldeDebit, currentSoldeCredit));
+ chapter.add(backwardParagraph);
+ }
+ //table
+ Paragraph paragraphTable = new Paragraph();
+ Table table = createBalanceTable(subList);
+ paragraphTable.add(table);
+ chapter.add(paragraphTable);
+ for (ReportsDatas reportsDatas : subList){
+ currentAmountDebit += reportsDatas.getAmountDebit();
+ currentAmountCredit += reportsDatas.getAmountCredit();
+ currentSoldeDebit += reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0;
+ currentSoldeCredit += reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde();
+ }
+ //forward amounts
+ if (n>max && i<=n-max){
+ Paragraph forwardParagraph = new Paragraph();
+ forwardParagraph.add(createBalanceAmountTable(_("lima-business.document.carryforward"), currentAmountDebit, currentAmountCredit, currentSoldeDebit, currentSoldeCredit));
+ chapter.add(forwardParagraph);
+ }
+ //final amounts
+ if (i>=n-max){
+ Paragraph finalAmountParagraph = new Paragraph();
+ finalAmountParagraph.add(createBalanceAmountTable(_("lima-business.document.amounts"), currentAmountDebit, currentAmountCredit, currentSoldeDebit, currentSoldeCredit));
+ chapter.add(finalAmountParagraph);
+ }
+ //add page
+ document.add(chapter);
+ i=i+max;
+ nbpages++;
+ }
+ document.close();
+
+ } catch (FileNotFoundException eeFNFE) {
+ log.error("Can't create pdf file", eeFNFE);
+ } catch (DocumentException eeDE) {
+ log.error("Can't create document", eeDE);
+ }
+ }
+
+ public Table createBalanceHeaderTable(){
+ Table t = null;
+ try {
+ t = new Table(6,1);
+ float[] widths = {0.07f, 0.33f, 0.15f, 0.15f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setWidth(100f);
+ t.setPadding(3.5f);
+ //defaut cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.LEFT);
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
+ t.setDefaultCell(cell);
+ t.setOffset(8);
+ t.addCell(new Phrase(_("lima-business.document.accountnumber"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.description"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.movementdebit"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.movementcredit"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.soldedebit"), boldFont));
+ t.addCell(new Phrase(_("lima-business.document.soldecredit"), boldFont));
+
+ } catch (BadElementException eeBEE) {
+ log.error("Can't create table", eeBEE);
+ }
+ return t;
+
+ }
+
+ public Table createBalanceTable(List<ReportsDatas> subList){
+ int nbrow = subList.size();
+ Table t = null;
+ try {
+ //define table
+ t = new Table(6, nbrow);
+ t.setWidth(100f);
+ float[] widths = {0.07f, 0.33f, 0.15f, 0.15f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setPadding(1.5f);
+ t.setBorderWidth(1);
+ t.setOffset(0);
+ //define default cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.LEFT);
+ cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
+ t.setDefaultCell(cell);
+
+ for (ReportsDatas reportsDatas : subList) {
+
+ String soldeDebit = String.valueOf(reportsDatas.getSoldeDebit() ? reportsDatas.getAmountSolde() : 0);
+ String soldeCredit = String.valueOf(reportsDatas.getSoldeDebit() ? 0 : reportsDatas.getAmountSolde());
+
+ t.addCell(new Phrase(reportsDatas.getAccount().getAccountNumber(), normalFont));
+ t.addCell(new Phrase(reportsDatas.getAccount().getLabel(), normalFont));
+ t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountDebit()), normalFont));
+ t.addCell(new Phrase(String.valueOf(reportsDatas.getAmountCredit()), normalFont));
+ t.addCell(new Phrase(soldeDebit, normalFont));
+ t.addCell(new Phrase(soldeCredit, normalFont));
+ }
+ } catch (DocumentException eeDE) {
+ log.error("Can't create table", eeDE);
+
+ }
+ return t;
+ }
+
+ public Table createBalanceAmountTable(String title, Double amountDebit, Double amountCredit, Double soldeDebit, Double soldeCredit ){
+ Table t = null;
+ try {
+ t = new Table(5,1);
+ float[] widths = {0.4f,0.15f, 0.15f, 0.15f, 0.15f};
+ t.setWidths(widths);
+ t.setWidth(100f);
+ t.setPadding(3f);
+ t.setOffset(0);
+ //defaut cell
+ Cell cell = new Cell();
+ cell.setBorder(Rectangle.RIGHT);
+ cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
+ t.setDefaultCell(cell);
+
+ t.addCell(new Phrase(title, boldFont));
+ t.addCell(new Phrase(amountDebit.toString(), boldFont));
+ t.addCell(new Phrase(amountCredit.toString(), boldFont));
+ t.addCell(new Phrase(soldeDebit.toString(), boldFont));
+ t.addCell(new Phrase(soldeCredit.toString(), boldFont));
+ } catch (BadElementException eeBEE) {
+ log.error("Can't create table", eeBEE);
+ }
+ return t;
+ }
+
+
+ protected TopiaContext beginTransaction() throws TopiaException {
// basic check done, make check in database
// TODO move it into JTA
TopiaContext topiaTransaction;
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-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -225,7 +225,7 @@
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
- closedPeriodicEntryBook = closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(entryBook, financialPeriod);
+ closedPeriodicEntryBook = closedPeriodicEntryBookDAO.findByEntryBookAndFinancialPeriod(entryBook, financialPeriod);
}
catch (TopiaException ex) {
doCatch(topiaContext, 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-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -1026,7 +1026,7 @@
.getCodeEntryBook();
EntryBook entryBook = entryBookDAO.findByCode(codeEntryBook);
ClosedPeriodicEntryBook closedPeriodicEntryBook = closedPeriodicEntryBookDAO
- .findbyEntryBookAndFinancialPeriod(entryBook,
+ .findByEntryBookAndFinancialPeriod(entryBook,
financialPeriod);
try {
financialPeriodService
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -175,7 +175,7 @@
String queryAlias = "E";
if (beginDate != null && endDate != null){
try {
- EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
TopiaQuery entriesQuery =
createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2010-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -21,10 +21,7 @@
import java.util.Date;
import java.util.List;
-
import javax.ejb.Remote;
-
-import org.chorem.lima.beans.FinancialStatementAmounts;
import org.chorem.lima.business.LimaException;
/**
@@ -36,6 +33,8 @@
@Remote
public interface DocumentService {
- public void createFinancialStatementsDocuments(List<FinancialStatementAmounts> financialStatementAmounts, Date beginDate, Date endDate) throws LimaException;
+ public void createFinancialStatementsDocuments(Date beginDate, Date endDate) throws LimaException;
public void createLedgerDocuments(List<Object> objects, Date beginDate, Date endDate) throws LimaException;
+ public void createEntryBooksDocuments(Date beginDate, Date endDate) throws LimaException;
+ public void createBalanceDocuments(Date beginDate, Date endDate) throws LimaException;
}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-02 16:54:10 UTC (rev 2992)
@@ -3,7 +3,11 @@
An\ financialStatement\ already\ exists\ with\ this\ label\ \:\ %s=
lima-business.config.configFileName.description=
lima-business.config.rulesnationality=
+lima-business.document.accountnubmer=
+lima-business.document.accountnumber=
lima-business.document.amount=Amout
+lima-business.document.amounts=
+lima-business.document.balance=
lima-business.document.businessnumber=
lima-business.document.carryback=Carry Back
lima-business.document.carryforward=reporter\u00C0
@@ -19,12 +23,16 @@
lima-business.document.grossamount=Gross Amount
lima-business.document.label=Label
lima-business.document.ledger=
+lima-business.document.movementcredit=
+lima-business.document.movementdebit=
lima-business.document.netamount=Net Amount
lima-business.document.pagenumber=
lima-business.document.period1=
lima-business.document.period2=
lima-business.document.provisiondeprecationamount=Provision Deprecation Amount
lima-business.document.solde=Solde
+lima-business.document.soldecredit=
+lima-business.document.soldedebit=
lima-business.document.vatnumber=
lima-business.document.voucher=Voucher
lima.business.document.date=Date
Modified: trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-02 16:54:10 UTC (rev 2992)
@@ -1,7 +1,9 @@
An\ EntryBook\ already\ exists\ with\ this\ label\ \:\ %s=
An\ account\ already\ exists\ with\ this\ number\ \:\ %s=
An\ financialStatement\ already\ exists\ with\ this\ label\ \:\ %s=
-lima-business.document.amount=Total
+lima-business.document.accountnumber=N\u00B0 Compte
+lima-business.document.amounts=Totaux
+lima-business.document.balance=Balance
lima-business.document.businessnumber=N\u00B0 Siret
lima-business.document.carryback=Report
lima-business.document.carryforward=\u00C0 reporter
@@ -16,12 +18,16 @@
lima-business.document.grossamount=Brut
lima-business.document.label=Libell\u00E9
lima-business.document.ledger=Grand Livre
+lima-business.document.movementcredit=Mouvement Cr\u00E9diteur
+lima-business.document.movementdebit=Mouvement D\u00E9biteur
lima-business.document.netamount=Net
lima-business.document.pagenumber=N\u00B0 page
lima-business.document.period1=P\u00E9riode du
lima-business.document.period2=au
lima-business.document.provisiondeprecationamount=Amortissements et provisions
lima-business.document.solde=Solde
+lima-business.document.soldecredit=Solde Cr\u00E9diteur
+lima-business.document.soldedebit=Solde D\u00E9biteur
lima-business.document.vatnumber=N\u00B0 TVA
lima-business.document.voucher=Pi\u00E8ce comptable
lima.config.configFileName.description=
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2010-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -1,19 +1,28 @@
package org.chorem.lima.entity;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.ClosedPeriodicEntryBookDAOAbstract;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
public class ClosedPeriodicEntryBookDAOImpl <E extends ClosedPeriodicEntryBook> extends ClosedPeriodicEntryBookDAOAbstract<E>{
+ private static final Log log = LogFactory.getLog(ClosedPeriodicEntryBookDAOImpl.class);
+
+
/**
* Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod
*/
@Override
- public ClosedPeriodicEntryBook findbyEntryBookAndFinancialPeriod(
+ public ClosedPeriodicEntryBook findByEntryBookAndFinancialPeriod(
EntryBook entryBook, FinancialPeriod financialPeriod)
throws TopiaException {
@@ -27,4 +36,19 @@
return findByQuery(query);
}
+ @Override
+ public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate,
+ Date endDate) throws TopiaException {
+ TopiaQuery query = createQuery();
+ if (beginDate != null && endDate != null){
+ String beginDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE);
+ String endDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE);
+ String entrybookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.ENTRY_BOOK, EntryBook.CODE);
+ query.addWhere(beginDateProperty, Op.GE, beginDate)
+ .addWhere(endDateProperty, Op.LE, endDate)
+ .addOrder(beginDateProperty, entrybookProperty);
+ }
+ return (List<ClosedPeriodicEntryBook>) findAllByQuery(query);
+ }
+
}
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-08-02 16:54:10 UTC (rev 2992)
@@ -74,9 +74,12 @@
<JCheckBox id='movmentedFilter' text='lima.accountsreports.movmentedfilter' selected='false'
onActionPerformed="getHandler().refresh()"/>
</cell>
+ <cell>
+ <JButton text="lima.createPDF" onActionPerformed="getHandler().createPdf()"/>
+ </cell>
</row>
<row>
- <cell fill="both" weightx="1" weighty="1" columns="7">
+ <cell fill="both" weightx="1" weighty="1" columns="8">
<JScrollPane>
<org.jdesktop.swingx.JXTable id="balanceTable" rowHeight="24"
model="{getModelBalanceTable()}"
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-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -23,6 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.business.DocumentServiceMonitorable;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaException;
@@ -45,6 +46,7 @@
/** Services. */
protected ReportServiceMonitorable reportService;
+ protected DocumentServiceMonitorable documentService;
/** DatePicker Begin Date. */
protected Date selectedBeginDate;
@@ -63,6 +65,9 @@
reportService =
LimaServiceFactory.getInstance().getService(
ReportServiceMonitorable.class);
+ documentService =
+ LimaServiceFactory.getInstance().getService(
+ DocumentServiceMonitorable.class);
LimaServiceFactory.getInstance().getService(
ImportServiceMonitorable.class).addListener(this);
LimaServiceFactory.getInstance().getService(
@@ -136,6 +141,16 @@
}
}
+ public void createPdf() {
+ try {
+ documentService.createBalanceDocuments(selectedBeginDate, selectedEndDate);
+ } catch (LimaException eee) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't create PDF", eee);
+ }
+ }
+ }
+
@Override
public void notifyMethod(String serviceName, String methodeName) {
if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-08-02 16:54:10 UTC (rev 2992)
@@ -74,9 +74,12 @@
editable="false"
/>
</cell>
+ <cell>
+ <JButton text="lima.createPDF" onActionPerformed="getHandler().createPdf()"/>
+ </cell>
</row>
<row>
- <cell fill="both" weightx="1" weighty="1" columns="6">
+ <cell fill="both" weightx="1" weighty="1" columns="7">
<JScrollPane>
<org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTable
id="table" sortable="false" rowHeight="24"
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-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -26,6 +26,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.beans.ReportsDatasImpl;
+import org.chorem.lima.business.DocumentServiceMonitorable;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaException;
@@ -56,6 +57,7 @@
/** Services. */
protected ReportServiceMonitorable reportService;
+ protected DocumentServiceMonitorable documentService;
/** Account. */
protected EntryBook selectedEntryBook;
@@ -72,6 +74,9 @@
reportService =
LimaServiceFactory.getInstance().getService(
ReportServiceMonitorable.class);
+ documentService =
+ LimaServiceFactory.getInstance().getService(
+ DocumentServiceMonitorable.class);
LimaServiceFactory.getInstance().getService(
ImportServiceMonitorable.class).addListener(this);
LimaServiceFactory.getInstance().getService(
@@ -143,6 +148,16 @@
}
}
+ public void createPdf() {
+ try {
+ documentService.createEntryBooksDocuments(selectedBeginDate, selectedEndDate);
+ } catch (LimaException eee) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't create PDF", eee);
+ }
+ }
+ }
+
@Override
public void notifyMethod(String serviceName, String methodeName) {
if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntryBook") || methodeName.contains("importAll")){
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-08-02 13:02:10 UTC (rev 2991)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2010-08-02 16:54:10 UTC (rev 2992)
@@ -210,7 +210,7 @@
public void createDocuments(){
try {
- documentService.createFinancialStatementsDocuments(cacheDataList, selectedBeginDate, selectedEndDate);
+ documentService.createFinancialStatementsDocuments(selectedBeginDate, selectedEndDate);
} catch (LimaException e) {
if (log.isDebugEnabled()){
log.debug("Error on create document",e);
1
0