r3852 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
Author: sbavencoff Date: 2014-07-18 17:02:19 +0200 (Fri, 18 Jul 2014) New Revision: 3852 Url: http://forge.chorem.org/projects/lima/repository/revisions/3852 Log: refs #1044 : ident + topia function 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 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 2014-07-11 13:27:33 UTC (rev 3851) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2014-07-18 15:02:19 UTC (rev 3852) @@ -186,7 +186,7 @@ * Si le compte n'existe pas, il envoie alors un message d'avertissement. * * @param account compte à modifier - * @throws LimaException + * @throws InvalidAccountNumberException */ @Override public Account updateAccount(Account account) throws InvalidAccountNumberException { @@ -201,6 +201,7 @@ return result; } + // TODO sbavencoff 18/07/2014 revoir la selection des comptes #1046 @Override public List<Account> stringToListAccounts(String selectedAccounts) { Set<Account> accounts = new HashSet<Account>(); 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 2014-07-11 13:27:33 UTC (rev 3851) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2014-07-18 15:02:19 UTC (rev 3852) @@ -25,6 +25,7 @@ package org.chorem.lima.business.ejb; +import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -98,23 +99,19 @@ // remove financialstatement FinancialStatement financialStatementToDelete = - financialStatementTopiaDao.findByTopiaId( - financialStatement.getTopiaId()); + financialStatementTopiaDao.findByTopiaId(financialStatement.getTopiaId()); financialStatementTopiaDao.delete(financialStatementToDelete); //get all subFinancialStatement List<FinancialStatement> financialStatements = - getAllChildrenFinancialStatement(financialStatement, - new ArrayList<FinancialStatement>()); + getAllChildrenFinancialStatement(financialStatement, new ArrayList<FinancialStatement>()); //if FinancialStatement have subFinancialStatement - if (financialStatements.size() > 0) { - for (FinancialStatement subFinancialStatement : financialStatements) { - FinancialStatement subFinancialStatementToDelete = - financialStatementTopiaDao.findByTopiaId( - subFinancialStatement.getTopiaId()); - financialStatementTopiaDao.delete(subFinancialStatementToDelete); - } + for (FinancialStatement subFinancialStatement : financialStatements) { + FinancialStatement subFinancialStatementToDelete = + financialStatementTopiaDao.findByTopiaId( + subFinancialStatement.getTopiaId()); + financialStatementTopiaDao.delete(subFinancialStatementToDelete); } } @@ -147,11 +144,7 @@ @Override public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement masterFinancialStatement) { - - FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao(); - List<FinancialStatement> financialStatements = financialStatementTopiaDao.findChildrenFinancialStatement(masterFinancialStatement); - - return financialStatements; + return Lists.newArrayList(masterFinancialStatement.getSubFinancialStatements()); } @@ -204,49 +197,49 @@ FinancialStatementAmounts financialStatementAmounts = financialStatementAmounts(subFinancialStatement, selectedBeginDate, selectedEndDate); if (!subFinancialStatement.isHeader()) { //on calcul - grossAmount = - grossAmount.add(financialStatementAmounts.getGrossAmount()); + grossAmount = grossAmount.add(financialStatementAmounts.getGrossAmount()); + provisionDeprecationAmount = provisionDeprecationAmount.add( financialStatementAmounts.getProvisionDeprecationAmount()); + subResult.add(financialStatementAmounts); + } else { FinancialStatementDatas financialStatementDatas = financialStatementReport(subFinancialStatement, selectedBeginDate, selectedEndDate, result); + grossAmount = grossAmount.add(financialStatementDatas. getFinancialStatementAmounts().getGrossAmount()); + provisionDeprecationAmount = provisionDeprecationAmount. add(financialStatementDatas.getFinancialStatementAmounts(). getProvisionDeprecationAmount()); - FinancialStatementAmounts headerfinancialStatementAmounts = financialStatementDatas.getFinancialStatementAmounts(); + //Si sous-total if (subFinancialStatement.isSubAmount()) { - FinancialStatementAmounts header = - new FinancialStatementAmountsImpl(); + FinancialStatementAmounts header = new FinancialStatementAmountsImpl(); header.setLabel(headerfinancialStatementAmounts.getLabel()); header.setLevel(headerfinancialStatementAmounts.getLevel()); header.setHeader(true); + //ajoute header subResult.add(header); + //ajoute liste if (financialStatementDatas.getListResult() != null) { 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 une ligne vide @@ -258,10 +251,8 @@ if (subFinancialStatement.isHeaderAmount()) { subResult.add(headerfinancialStatementAmounts); } else { - headerfinancialStatementAmounts. - setGrossAmount(new BigDecimal(0)); - headerfinancialStatementAmounts. - setProvisionDeprecationAmount(new BigDecimal(0)); + headerfinancialStatementAmounts.setGrossAmount(new BigDecimal(0)); + headerfinancialStatementAmounts.setProvisionDeprecationAmount(new BigDecimal(0)); subResult.add(headerfinancialStatementAmounts); } //ajoute liste @@ -271,11 +262,9 @@ } } } - 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.isHeader()); @@ -307,10 +296,8 @@ BigDecimal creditAmount = new BigDecimal(0); BigDecimal provisionDeprecationAmount = new BigDecimal(0); - FinancialStatement masterFinancialStatement = - financialStatement.getMasterFinancialStatement(); - FinancialStatementWayEnum financialStatementWayEnum = - FinancialStatementWayEnum.BOTH; + FinancialStatement masterFinancialStatement = financialStatement.getMasterFinancialStatement(); + FinancialStatementWayEnum financialStatementWayEnum = FinancialStatementWayEnum.BOTH; if (masterFinancialStatement != null) { financialStatementWayEnum = masterFinancialStatement.getWay(); } @@ -332,19 +319,15 @@ //CREDIT ACCOUNTS LIST String creditAccountsString = financialStatement.getCreditAccounts(); if (creditAccountsString != null && !creditAccountsString.equals("")) { - amounts = amountFromAccountList(creditAccountsString, - selectedBeginDate, selectedEndDate); + amounts = amountFromAccountList(creditAccountsString, selectedBeginDate, selectedEndDate); creditAmount = creditAmount.add(amounts.getCredit()); } // PROVISION & DEPRECATION - String provisionDeprecationAccountsString = - financialStatement.getProvisionDeprecationAccounts(); + String provisionDeprecationAccountsString = financialStatement.getProvisionDeprecationAccounts(); if (provisionDeprecationAccountsString != null && !provisionDeprecationAccountsString.equals("")) { amounts = amountFromAccountList(provisionDeprecationAccountsString, selectedBeginDate, selectedEndDate); - provisionDeprecationAmount = - provisionDeprecationAmount.add(amounts.getCredit()); - provisionDeprecationAmount = - provisionDeprecationAmount.subtract(amounts.getDebit()); + provisionDeprecationAmount = provisionDeprecationAmount.add(amounts.getCredit()); + provisionDeprecationAmount = provisionDeprecationAmount.subtract(amounts.getDebit()); } switch (financialStatementWayEnum) { case BOTH: @@ -363,10 +346,8 @@ financialStatementAmounts.setGrossAmount(amount); financialStatementAmounts.setLabel(financialStatement.getLabel()); - financialStatementAmounts.setProvisionDeprecationAmount( - provisionDeprecationAmount); - financialStatementAmounts.setLevel( - financialStatement.getLevel()); + financialStatementAmounts.setProvisionDeprecationAmount(provisionDeprecationAmount); + financialStatementAmounts.setLevel(financialStatement.getLevel()); return financialStatementAmounts; } @@ -379,22 +360,21 @@ BigDecimal credit = new BigDecimal(0); Boolean substract = false; - AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao(); //Remove Spaces String result = StringUtils.deleteWhitespace(accountsNumberList); StringTokenizer stQuote = new StringTokenizer(result, "-"); while (stQuote.hasMoreTokens()) { String s = stQuote.nextToken(); - //List<Account> accountsList = accountTopiaDao.stringToListAccounts(s, false); List<Account> accountsList = accountService.stringToListAccounts(s); BigDecimal debitTemp = new BigDecimal(0); BigDecimal creditTemp = new BigDecimal(0); for (Account account : accountsList) { - ReportsDatas reportsDatas = reportService. - generateAccountsReports( + ReportsDatas reportsDatas = + reportService.generateAccountsReports( account, true, - selectedBeginDate, selectedEndDate); + selectedBeginDate, + selectedEndDate); if (reportsDatas.getSoldeDebit()) { debitTemp = debitTemp.add(reportsDatas.getAmountSolde()); } else { @@ -419,35 +399,24 @@ @Override public String checkFinancialStatementChart() { - StringBuilder result = - new StringBuilder(t("lima-business.financialstatement.check.warn")); + StringBuilder result = new StringBuilder(t("lima-business.financialstatement.check.warn")); AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao(); FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao(); List<Account> accountsList = accountTopiaDao.findAllLeafAccounts(); - List<FinancialStatement> financialStatementsList = - financialStatementTopiaDao.findAll(); + List<FinancialStatement> financialStatementsList = financialStatementTopiaDao.findAll(); - for (FinancialStatement financialStatement : financialStatementsList) { - accountsList.removeAll( - accountService.stringToListAccounts( - financialStatement.getAccounts())); + accountsList.removeAll(accountService.stringToListAccounts(financialStatement.getAccounts())); - accountsList.removeAll( - accountService.stringToListAccounts( - financialStatement.getCreditAccounts())); + accountsList.removeAll(accountService.stringToListAccounts(financialStatement.getCreditAccounts())); - accountsList.removeAll( - accountService.stringToListAccounts( - financialStatement.getDebitAccounts())); + accountsList.removeAll(accountService.stringToListAccounts(financialStatement.getDebitAccounts())); - accountsList.removeAll( - accountService.stringToListAccounts( - financialStatement.getProvisionDeprecationAccounts())); + accountsList.removeAll(accountService.stringToListAccounts(financialStatement.getProvisionDeprecationAccounts())); } for (Account account : accountsList) { @@ -471,7 +440,7 @@ @Override public FinancialStatement getFinancialStatementByLabel(String label) { FinancialStatementTopiaDao financialStatementTopiaDao = getDaoHelper().getFinancialStatementDao(); - FinancialStatement result = financialStatementTopiaDao.findByLabel(label); + FinancialStatement result = financialStatementTopiaDao.forLabelEquals(label).findUniqueOrNull(); return result; }
participants (1)
-
sbavencoff@users.chorem.org