r3303 - in trunk/lima-business/src/main/java/org/chorem/lima/business: ejb ejbinterface
Author: tchemit Date: 2011-09-27 10:21:18 +0200 (Tue, 27 Sep 2011) New Revision: 3303 Url: http://chorem.org/repositories/revision/lima/3303 Log: add getMasterAccount service method Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.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 2011-09-22 17:31:55 UTC (rev 3302) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2011-09-27 08:21:18 UTC (rev 3303) @@ -136,7 +136,6 @@ } } - @Override public void createSubLedgerWithTransaction(Account masterAccount, Account account, @@ -219,6 +218,29 @@ return account; } + @Override + public Account getMasterAccount(String accountNumber) throws LimaException { + Account account = null; + TopiaContext transaction = beginTransaction(rootContext); + try { + + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(transaction); + + while (account == null && accountNumber.length() > 1) { + + accountNumber = accountNumber.substring(0, accountNumber.length() - 1); + account = accountDAO.findByAccountNumber(accountNumber); + } + + } catch (Exception ex) { + doCatch(transaction, ex); + } finally { + doFinally(transaction); + } + return account; + } + /** Permet d'obtenir un compte suivant son numero */ @Override public Account getAccountByNumber(String number) throws LimaException { Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java 2011-09-22 17:31:55 UTC (rev 3302) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java 2011-09-27 08:21:18 UTC (rev 3303) @@ -47,6 +47,19 @@ List<Account> getAllAccountByProperty(String propertyName, String value) throws LimaException; + /** + * Obtain the master account for the given account number. + * + * the master account if the account with the longer account number prefixing the given account number. + * + * Example: for account number 401AB, it could be 4, 40, 401,... + * + * @param accountNumber the account number + * @return the master account number + * @throws LimaException if any pb while loading account + */ + Account getMasterAccount(String accountNumber) throws LimaException; + Account getAccountByNumber(String number) throws LimaException; List<Account> getAllAccounts() throws LimaException;
participants (1)
-
tchemit@users.chorem.org