Author: jpepin Date: 2010-06-28 17:14:33 +0200 (Mon, 28 Jun 2010) New Revision: 2951 Url: http://chorem.org/repositories/revision/lima/2951 Log: Recherche d'une extension de comptes gr?\195?\162ce ?\195?\160 '..' Dans le plan BCR fusion des champs "credit & debit" et "formule". 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/FinancialStatementServiceImpl.java trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementMovementForm.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/AccountServiceImpl.java 2010-06-28 11:03:51 UTC (rev 2950) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-28 15:14:33 UTC (rev 2951) @@ -386,7 +386,7 @@ /** * Convert string of extends number to list of accounts - * Example '22, 45-48, 67' -> [22, 45, 46, 47, 48, 67] + * Example '22, 45..48, 67' -> [22, 45, 46, 47, 48, 67] */ @Override public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, TopiaContext topiaContext) throws LimaException{ @@ -403,11 +403,13 @@ StringTokenizer stComma = new StringTokenizer(selectedAccounts, ","); while (stComma.hasMoreTokens()) { String s = stComma.nextToken(); - if (s.contains("-")){ - //Split hypen - String stringHypen[] = s.split("-"); - int lowAccount=Integer.parseInt(stringHypen[0]); - int highAccount=Integer.parseInt(stringHypen[1]); + if (s.contains("..")){ + //Split .. + String stringDoubleDot[] = s.split("\\.\\."); + log.debug(stringDoubleDot[0]); + log.debug(stringDoubleDot[1]); + int lowAccount=Integer.parseInt(stringDoubleDot[0]); + int highAccount=Integer.parseInt(stringDoubleDot[1]); for (int i=lowAccount; i <= highAccount; i++) { accountNumbers.add(String.valueOf(i)); } 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-06-28 11:03:51 UTC (rev 2950) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-06-28 15:14:33 UTC (rev 2951) @@ -134,16 +134,22 @@ // remove financialstatement - FinancialStatement financialStatementToDelete = financialStatementDAO.findByTopiaId(financialStatement.getTopiaId()); + FinancialStatement financialStatementToDelete = + financialStatementDAO.findByTopiaId( + financialStatement.getTopiaId()); financialStatementDAO.delete(financialStatementToDelete); //get all subFinancialStatement - List<FinancialStatement> financialStatements = getAllChildrenFinancialStatement(financialStatement, new ArrayList<FinancialStatement>()); + List<FinancialStatement> financialStatements = + getAllChildrenFinancialStatement(financialStatement, + new ArrayList<FinancialStatement>()); //if FinancialStatement have subFinancialStatement if (financialStatements.size() > 0){ for (FinancialStatement subFinancialStatement : financialStatements) { - FinancialStatement subFinancialStatementToDelete = financialStatementDAO.findByTopiaId(subFinancialStatement.getTopiaId()); + FinancialStatement subFinancialStatementToDelete = + financialStatementDAO.findByTopiaId( + subFinancialStatement.getTopiaId()); financialStatementDAO.delete(subFinancialStatementToDelete); } } @@ -164,7 +170,8 @@ @Override public List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement, List<FinancialStatement> result) throws LimaException, LimaBusinessException { - List<FinancialStatement> childFinancialStatements = getChildrenFinancialStatement(financialStatement); + List<FinancialStatement> childFinancialStatements = + getChildrenFinancialStatement(financialStatement); for (FinancialStatement childFinancialStatement: childFinancialStatements) { result.add(childFinancialStatement); getAllChildrenFinancialStatement(childFinancialStatement, result); @@ -236,7 +243,9 @@ try { transaction = beginTransaction(); //create list form tree - result = financialStatementReport(null, selectedBeginDate, selectedEndDate, new FinancialStatementDatasImpl(), transaction).getListResult(); + result = financialStatementReport(null, selectedBeginDate, + selectedEndDate, new FinancialStatementDatasImpl(), + transaction).getListResult(); } catch (TopiaException ex) { @@ -255,25 +264,35 @@ getChildrenFinancialStatement(financialStatement); try { Double grossAmount = 0.0, provisionDeprecationAmount = 0.0; - List<FinancialStatementAmounts> subResult = new ArrayList<FinancialStatementAmounts>(); + List<FinancialStatementAmounts> subResult = + new ArrayList<FinancialStatementAmounts>(); for (FinancialStatement subFinancialStatement : financialStatements) { - FinancialStatementAmounts financialStatementAmounts = financialStatementAmounts(subFinancialStatement, selectedBeginDate, selectedEndDate, topiaContext); + FinancialStatementAmounts financialStatementAmounts = + financialStatementAmounts(subFinancialStatement, + selectedBeginDate, selectedEndDate, topiaContext); if (!subFinancialStatement.getHeader()){ //on calcul grossAmount += financialStatementAmounts.getGrossAmount(); - provisionDeprecationAmount += financialStatementAmounts.getProvisionDeprecationAmount(); + provisionDeprecationAmount += + financialStatementAmounts.getProvisionDeprecationAmount(); subResult.add(financialStatementAmounts); } else { - FinancialStatementDatas financialStatementDatas = financialStatementReport(subFinancialStatement, selectedBeginDate, selectedEndDate, result, topiaContext); - grossAmount += financialStatementDatas.getFinancialStatementAmounts().getGrossAmount(); - provisionDeprecationAmount += financialStatementDatas.getFinancialStatementAmounts().getProvisionDeprecationAmount(); + FinancialStatementDatas financialStatementDatas = + financialStatementReport(subFinancialStatement, + selectedBeginDate, selectedEndDate, result, topiaContext); + grossAmount += financialStatementDatas. + getFinancialStatementAmounts().getGrossAmount(); + provisionDeprecationAmount += financialStatementDatas. + getFinancialStatementAmounts().getProvisionDeprecationAmount(); - FinancialStatementAmounts headerfinancialStatementAmounts = financialStatementDatas.getFinancialStatementAmounts(); + FinancialStatementAmounts headerfinancialStatementAmounts = + financialStatementDatas.getFinancialStatementAmounts(); //Si sous-total if (subFinancialStatement.getSubAmount()){ - FinancialStatementAmounts header = new FinancialStatementAmountsImpl(); + FinancialStatementAmounts header = + new FinancialStatementAmountsImpl(); header.setLabel(headerfinancialStatementAmounts.getLabel()); header.setLevel(headerfinancialStatementAmounts.getLevel()); header.setHeader(true); @@ -284,14 +303,20 @@ subResult.addAll(financialStatementDatas.getListResult()); } //ajoute sstotal - FinancialStatementAmounts subAmount = new FinancialStatementAmountsImpl(); - subAmount.setLabel("TOTAL "+headerfinancialStatementAmounts.getLabel()); - subAmount.setLevel(headerfinancialStatementAmounts.getLevel()); - subAmount.setGrossAmount(headerfinancialStatementAmounts.getGrossAmount()); - subAmount.setProvisionDeprecationAmount(headerfinancialStatementAmounts.getProvisionDeprecationAmount()); + FinancialStatementAmounts subAmount = + new FinancialStatementAmountsImpl(); + subAmount.setLabel( + "TOTAL "+headerfinancialStatementAmounts.getLabel()); + subAmount.setLevel( + headerfinancialStatementAmounts.getLevel()); + subAmount.setGrossAmount( + headerfinancialStatementAmounts.getGrossAmount()); + subAmount.setProvisionDeprecationAmount( + headerfinancialStatementAmounts. + getProvisionDeprecationAmount()); subAmount.setSubAmount(true); subResult.add(subAmount); - //ajoute ligne vide + //ajoute une ligne vide subResult.add(new FinancialStatementAmountsImpl()); }//sinon @@ -305,9 +330,11 @@ } } } - FinancialStatementAmounts financialStatementAmounts = new FinancialStatementAmountsImpl(); + FinancialStatementAmounts financialStatementAmounts = + new FinancialStatementAmountsImpl(); financialStatementAmounts.setGrossAmount(grossAmount); - financialStatementAmounts.setProvisionDeprecationAmount(provisionDeprecationAmount); + financialStatementAmounts.setProvisionDeprecationAmount( + provisionDeprecationAmount); if (financialStatement != null){ financialStatementAmounts.setLabel(financialStatement.getLabel()); financialStatementAmounts.setHeader(financialStatement.getHeader()); @@ -334,13 +361,26 @@ String accountsString = financialStatement.getAccounts(); Double amount = 0.0; if (accountsString != null){ - List<Account> accountsList = accountServiceLocal. - stringToListAccountsWithTransaction(accountsString, topiaContext); - for (Account account : accountsList) { - ReportsDatas reportsDatas = reportServiceLocal. - generateAccountReportsWithTransaction(account, - selectedBeginDate, selectedEndDate, topiaContext); - amount += reportsDatas.getAmountSolde(); + //Remove Spaces + accountsString = StringUtils.deleteWhitespace(accountsString); + StringTokenizer stQuote = new StringTokenizer(accountsString, "-"); + while (stQuote.hasMoreTokens()) { + String s = stQuote.nextToken(); + List<Account> accountsStringList = accountServiceLocal. + stringToListAccountsWithTransaction(s, topiaContext); + Double resAmount = 0.0; + for (Account accountString : accountsStringList) { + ReportsDatas reportsDatas = reportServiceLocal. + generateAccountReportsWithTransaction(accountString, + selectedBeginDate, selectedEndDate, topiaContext); + resAmount += reportsDatas.getAmountSolde(); + } + if (amount == 0){ + amount=resAmount; + } + else { + amount-=resAmount; + } } } @@ -379,8 +419,9 @@ financialStatement.getProvisionDeprecationAccounts(); Double provisionDeprecationAmount = 0.0; if (provisionDeprecationAccountsString != null){ - List<Account> provisionDeprecationAccountsList = accountServiceLocal. - stringToListAccountsWithTransaction(provisionDeprecationAccountsString, topiaContext); + List<Account> provisionDeprecationAccountsList = + accountServiceLocal.stringToListAccountsWithTransaction( + provisionDeprecationAccountsString, topiaContext); for (Account account : provisionDeprecationAccountsList) { ReportsDatas reportsDatas = reportServiceLocal. generateAccountReportsWithTransaction(account, @@ -388,69 +429,16 @@ provisionDeprecationAmount += reportsDatas.getAmountSolde(); } } - - // FORMULA - String formulaString = - financialStatement.getFormula(); - Double formulaAmount = 0.0; - if (formulaString != null){ - //Remove Spaces - formulaString = StringUtils.deleteWhitespace(formulaString); - log.debug(formulaString); - //Split simple quote - StringTokenizer stQuote = new StringTokenizer(formulaString, "'"); - while (stQuote.hasMoreTokens()) { - String s = stQuote.nextToken(); - log.debug(s); - if (s.contentEquals("-")){ - s = stQuote.nextToken(); - List<Account> accountsStringList = accountServiceLocal. - stringToListAccountsWithTransaction(s, topiaContext); - Double resAmount = 0.0; - for (Account accountString : accountsStringList) { - ReportsDatas reportsDatas = reportServiceLocal. - generateAccountReportsWithTransaction(accountString, - selectedBeginDate, selectedEndDate, topiaContext); - resAmount += reportsDatas.getAmountSolde(); - } - formulaAmount-=resAmount; - } - else if (s.contains("-")){ - List<Account> accountsStringList = accountServiceLocal. - stringToListAccountsWithTransaction(s, topiaContext); - Double resAmount = 0.0; - for (Account accountString : accountsStringList) { - ReportsDatas reportsDatas = reportServiceLocal. - generateAccountReportsWithTransaction(accountString, - selectedBeginDate, selectedEndDate, topiaContext); - resAmount += reportsDatas.getAmountSolde(); - } - formulaAmount+=resAmount; - } - else{ - List<Account> accountsStringList = accountServiceLocal. - stringToListAccountsWithTransaction(s, topiaContext); - Double resAmount = 0.0; - for (Account accountString : accountsStringList) { - ReportsDatas reportsDatas = reportServiceLocal. - generateAccountReportsWithTransaction(accountString, - selectedBeginDate, selectedEndDate, topiaContext); - resAmount += reportsDatas.getAmountSolde(); - } - formulaAmount+=resAmount;} - } - } - - // set result - financialStatementAmounts.setGrossAmount(amount+creditAmount+debitAmount+formulaAmount); + financialStatementAmounts.setGrossAmount( + amount+creditAmount+debitAmount); financialStatementAmounts.setLabel(financialStatement.getLabel()); - financialStatementAmounts.setProvisionDeprecationAmount(provisionDeprecationAmount); + financialStatementAmounts.setProvisionDeprecationAmount( + provisionDeprecationAmount); financialStatementAmounts.setLevel( financialStatement.getLevel()); - } catch (LimaException ex) { doCatch(topiaContext, ex, log); Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementMovementForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementMovementForm.jaxx 2010-06-28 11:03:51 UTC (rev 2950) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementMovementForm.jaxx 2010-06-28 15:14:33 UTC (rev 2951) @@ -86,17 +86,6 @@ onRemoveUpdate='getFinancialStatement().setProvisionDeprecationAccounts(getProvisionDeprecationAccountsTextField().getText())' /> </cell> </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.financialstatement.formula"/> - </cell> - <cell fill="horizontal"> - <JTextField id="formulaTextField" text="{getFinancialStatement().getFormula()}"/> - <javax.swing.text.Document javaBean="getFormulaTextField().getDocument()" - onInsertUpdate='getFinancialStatement().setFormula(getFormulaTextField().getText())' - onRemoveUpdate='getFinancialStatement().setFormula(getFormulaTextField().getText())' /> - </cell> - </row> <row> <cell fill="none"> <JButton text="lima.common.ok" onActionPerformed="dispose()"/>