r2934 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/account
Author: jpepin Date: 2010-06-08 11:55:04 +0200 (Tue, 08 Jun 2010) New Revision: 2934 Url: http://chorem.org/repositories/revision/lima/2934 Log: Accounting rules pour modification des comptes. D?\195?\169boguage de l'UI. Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/ Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-06-07 21:27:59 UTC (rev 2933) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-06-08 09:55:04 UTC (rev 2934) @@ -44,7 +44,7 @@ */ public void createAccountRules(Account masterAccount, Account account) throws LimaException; public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException; - public void updateAccountRules(Account account) throws LimaException; + public void updateAccountRules(Account masterAccount, Account account) throws LimaException; public void updateSubLedgerRules(Account account) throws LimaException; public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException; 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-06-07 21:27:59 UTC (rev 2933) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-06-08 09:55:04 UTC (rev 2934) @@ -346,7 +346,7 @@ } @Override - public void updateAccountRules(Account account) throws LimaException { + public void updateAccountRules(Account masterAccount, Account account) throws LimaException { // Check if the numberaccount is not blank if (StringUtils.isBlank(account.getAccountNumber())) { throw new LimaBusinessException("Invalid AccountNumber : " Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-06-07 21:27:59 UTC (rev 2933) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-06-08 09:55:04 UTC (rev 2934) @@ -62,8 +62,31 @@ } - public void updateAccountRules(Account account) throws LimaException { - super.updateAccountRules(account); + public void updateAccountRules(Account masterAccount, Account account) throws LimaException { + log.debug("masterAccount"+masterAccount); + log.debug("acccount"+account); + super.updateAccountRules(masterAccount, account); + // Check if the number account is type numeric + if (!StringUtils.isNumeric(account.getAccountNumber())){ + throw new LimaBusinessException("AccountNumber is not numeric : " + + account.getAccountNumber()); + } + + // Check if the number account start with the number of the master account + if (masterAccount!=null && !account.getAccountNumber().startsWith( + masterAccount.getAccountNumber())){ + + throw new LimaBusinessException( + "Account Number not begin with the number account master : " + + account.getAccountNumber()); + } + + // Check if master account have a number between 1 to 8 + if (masterAccount==null && !account.getAccountNumber().matches("[1-8]")){ + throw new LimaBusinessException( + "Master account is not a digit between 1 to 8 :" + + account.getAccountNumber()); + } } public void updateSubLedgerRules(Account account) throws LimaException { 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-07 21:27:59 UTC (rev 2933) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-08 09:55:04 UTC (rev 2934) @@ -345,19 +345,30 @@ try { transaction = beginTransaction(); - //TODO if account + // DAO + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(transaction); + Account subAccount = accountDAO.findByTopiaId(account.getTopiaId()); //check rules account if ledger or account if (account.getGeneralLedger()==null){ - accountingRules.updateAccountRules(account); + Account master = accountDAO.findContainsSubAccounts(subAccount); + log.debug(master); + accountingRules.updateAccountRules(master, account); + subAccount.setMasterAccount(account.getMasterAccount()); + subAccount.setSubAccounts(account.getSubAccounts()); } else { accountingRules.updateSubLedgerRules(account); + subAccount.setGeneralLedger(account.getGeneralLedger()); + subAccount.setSubLedgers(account.getSubLedgers()); + subAccount.setThirdParty(account.getThirdParty()); } // update account - AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(transaction); - accountDAO.update(account); + subAccount.setAccountNumber(account.getAccountNumber()); + subAccount.setLabel(account.getLabel()); + + accountDAO.update(subAccount); commitTransaction(transaction); } catch (TopiaException ex) { @@ -366,6 +377,9 @@ } throw new LimaException("Can't update account", ex); } + finally { + doFinally(transaction, log); + } } protected TopiaContext beginTransaction() throws TopiaException { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-07 21:27:59 UTC (rev 2933) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-08 09:55:04 UTC (rev 2934) @@ -24,6 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountService; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; @@ -81,25 +82,19 @@ @Override public int getChildCount(Object node) { int result = 0; - if (node instanceof Account) { - if (node == getRoot()) { - try { - result = accountService.getChildrenAccounts(null).size(); - } catch (LimaException e) { - //FIXME - e.printStackTrace(); - } + if (node == getRoot()) { + try { + result = accountService.getChildrenAccounts(null).size(); + } catch (LimaException eee) { + log.debug("Can't count child", eee); } - else { - Account parentAccount = (Account) node; - try { - List<Account> subaccounts = - accountService.getChildrenAccounts(parentAccount); - result = subaccounts.size(); - } catch (LimaException e) { - //FIXME - e.printStackTrace(); - } + } + else { + Account parentAccount = (Account) node; + try { + result = accountService.getChildrenAccounts(parentAccount).size(); + } catch (LimaException eee) { + log.debug("Can't count child", eee); } } return result; @@ -113,9 +108,8 @@ List<Account> allAccounts = accountService.getChildrenAccounts(null); result = allAccounts.get(index); - } catch (LimaException e) { - //FIXME - e.printStackTrace(); + } catch (LimaException eee) { + log.debug("Can't get child", eee); } } else { @@ -126,9 +120,8 @@ List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount); result = subaccounts.get(index); - } catch (LimaException e) { - //FIXME - e.printStackTrace(); + } catch (LimaException eee) { + log.debug("Can't get child", eee); } } return result; @@ -145,9 +138,8 @@ List<Account> allAccounts = accountService.getChildrenAccounts(null); result = allAccounts.indexOf(child); - } catch (LimaException e) { - //FIXME - e.printStackTrace(); + } catch (LimaException eee) { + log.debug("Can't get index child", eee); } } else { @@ -156,9 +148,8 @@ List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount); result = subaccounts.indexOf(childAccount); - } catch (LimaException e) { - //FIXME - e.printStackTrace(); + } catch (LimaException eee) { + log.debug("Can't get index child", eee); } } return result; @@ -205,9 +196,7 @@ parentAccount = null; } accountService.createAccount(parentAccount, account); - int index = getIndexOfChild(path.getLastPathComponent(), account); modelSupport.fireTreeStructureChanged(path); - modelSupport.fireChildAdded(path, index, account); } /** @@ -224,9 +213,7 @@ parentAccount = null; } accountService.createSubLedger(parentAccount, account); - int index = getIndexOfChild(path.getLastPathComponent(), account); modelSupport.fireTreeStructureChanged(path); - modelSupport.fireChildAdded(path, index, account); } /** @@ -238,9 +225,15 @@ */ public void updateAccount(TreePath path, Account account) throws LimaException { // Calling account service - accountService.updateAccount(account); - //refresh the tree of the node - modelSupport.fireTreeStructureChanged(path.getParentPath()); + //FIXME Force fire for no update if error. Where is the cache ? + try{ + accountService.updateAccount(account); + } + catch (LimaBusinessException eee) { + modelSupport.fireTreeStructureChanged(path); + throw eee; + } + modelSupport.fireTreeStructureChanged(path); } /** 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-06-07 21:27:59 UTC (rev 2933) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-08 09:55:04 UTC (rev 2934) @@ -164,10 +164,8 @@ } else { treePath = new TreePath(accountsTreeTableModel.getRoot()); } - //test if selectedrow is account or ledger - + //test if selectedrow is account or ledger if (selectedObject.getGeneralLedger()==null){ - //TODO pepin 20100507 AccountForm accountForm = new AccountForm(view); accountForm.setAccount(selectedObject); // jaxx constructor don't call super() ? @@ -190,7 +188,6 @@ if (selectedObject != null){ // update it try { - accountsTreeTableModel. updateAccount(treePath, selectedObject); } catch (LimaException eee) {
participants (1)
-
jpepin@users.chorem.org