r3001 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejbinterface lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/ui/entrybook lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction lima-swing/src/main/java/org/chorem/lima/ui/home lima-swing/src/main
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
participants (1)
-
jpepin@users.chorem.org