Author: vsalaun Date: 2011-08-10 15:27:34 +0200 (Wed, 10 Aug 2011) New Revision: 3258 Url: http://chorem.org/repositories/revision/lima/3258 Log: #426 add forms for updating accounts + uppercase ledger account number (when contains letters) Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateSubLedgerForm.jaxx Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.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-08-10 11:38:02 UTC (rev 3257) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2011-08-10 13:27:34 UTC (rev 3258) @@ -83,6 +83,9 @@ public void createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException { try { + // force upppercase account number + account.setAccountNumber(account.getAccountNumber().toUpperCase()); + // check if account number already exist AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); @@ -150,6 +153,10 @@ public void createSubLedgerWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException { try { + + // force upppercase account number + account.setAccountNumber(account.getAccountNumber().toUpperCase()); + // check if the accountnumber already exist AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2011-08-10 11:38:02 UTC (rev 3257) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2011-08-10 13:27:34 UTC (rev 3258) @@ -31,42 +31,11 @@ <script> <![CDATA[ - import org.chorem.lima.business.AccountServiceMonitorable; - import org.chorem.lima.service.LimaServiceFactory; - import org.chorem.lima.business.LimaException; - import org.chorem.lima.entity.AccountImpl; - getRootPane().setDefaultButton(ok); protected void performCancel() { setAccount(null); dispose(); } - protected void performOk() { - if (getMasterAccountTextField().getText().length() != 0) { - AccountServiceMonitorable accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); - Account masterAccount = new AccountImpl(); - try { - System.out.println("setMaster : " - + getMasterAccountTextField().getText() + " to : " - + getAccount().getAccountNumber()); - masterAccount = accountService - .getAccountByNumber(getMasterAccountTextField().getText()); - } catch (LimaException eee) { - log.debug("Can't search account for update : " - + getMasterAccountTextField().getText(), eee); - } - if (masterAccount != null) { - getAccount().setMasterAccount(masterAccount); - } else { - getAccount().setMasterAccount(null); - } - } else { - setAccount(null); - } - dispose(); - } ]]> </script> @@ -77,7 +46,10 @@ <JLabel text="lima.charts.account.number"/> </cell> <cell fill="horizontal"> - <JTextField id="numberTextField" editable='{false}' text="{getAccount().getAccountNumber()}"/> + <JTextField id="numberTextField" text="{getAccount().getAccountNumber()}"/> + <javax.swing.text.Document javaBean="getNumberTextField().getDocument()" + onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' + onRemoveUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' /> </cell> </row> <row> @@ -92,19 +64,11 @@ </cell> </row> <row> - <cell fill="horizontal"> - <JLabel text="lima.common.masteraccount"/> - </cell> - <cell fill="horizontal"> - <JTextField id="masterAccountTextField" text="{getAccount().getMasterAccount().getAccountNumber()}"/> - </cell> - </row> - <row> <cell fill="none"> <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> </cell> <cell fill="none"> - <JButton id="ok" text="lima.common.ok" onActionPerformed="performOk()"/> + <JButton id="ok" text="lima.common.ok" onActionPerformed="dispose()"/> </cell> </row> </Table> 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 2011-08-10 11:38:02 UTC (rev 3257) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2011-08-10 13:27:34 UTC (rev 3258) @@ -44,6 +44,8 @@ import org.chorem.lima.ui.account.AccountForm; import org.chorem.lima.ui.account.AccountView; import org.chorem.lima.ui.account.SubLedgerForm; +import org.chorem.lima.ui.account.UpdateAccountForm; +import org.chorem.lima.ui.account.UpdateSubLedgerForm; import org.chorem.lima.ui.importexport.ImportExport; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; @@ -224,7 +226,7 @@ } //test if selectedrow is account or ledger if (selectedObject.getGeneralLedger()==null) { - AccountForm accountForm = new AccountForm(view); + UpdateAccountForm accountForm = new UpdateAccountForm(view); accountForm.setAccount(selectedObject); // jaxx constructor don't call super() ? accountForm.setLocationRelativeTo(view); @@ -234,7 +236,7 @@ } // else is a subledger else { - SubLedgerForm subLedgerForm = new SubLedgerForm(view); + UpdateSubLedgerForm subLedgerForm = new UpdateSubLedgerForm(view); subLedgerForm.setAccount(selectedObject); // jaxx constructor don't call super() ? subLedgerForm.setLocationRelativeTo(view); Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx 2011-08-10 13:27:34 UTC (rev 3258) @@ -0,0 +1,86 @@ +<JDialog modal="true" + defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" + onWindowClosing="performCancel();"> + + <org.chorem.lima.entity.Account id="account" javaBean='null'/> + + <script> + <![CDATA[ + import org.chorem.lima.business.AccountServiceMonitorable; + import org.chorem.lima.service.LimaServiceFactory; + import org.chorem.lima.business.LimaException; + import org.chorem.lima.entity.AccountImpl; + + getRootPane().setDefaultButton(ok); + protected void performCancel() { + setAccount(null); + dispose(); + } + protected void performOk() { + if (getMasterAccountTextField().getText().length() != 0) { + AccountServiceMonitorable accountService = + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); + Account masterAccount = new AccountImpl(); + try { + System.out.println("setMaster : " + + getMasterAccountTextField().getText() + " to : " + + getAccount().getAccountNumber()); + masterAccount = accountService + .getAccountByNumber(getMasterAccountTextField().getText()); + } catch (LimaException eee) { + log.debug("Can't search account for update : " + + getMasterAccountTextField().getText(), eee); + } + if (masterAccount != null) { + getAccount().setMasterAccount(masterAccount); + } else { + getAccount().setMasterAccount(null); + } + } else { + setAccount(null); + } + dispose(); + } + ]]> + </script> + + <Table> + + <row> + <cell fill="horizontal"> + <JLabel text="lima.charts.account.number"/> + </cell> + <cell fill="horizontal"> + <JTextField id="numberTextField" editable='{false}' text="{getAccount().getAccountNumber()}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.common.label"/> + </cell> + <cell fill="horizontal"> + <JTextField id="descriptionTextField" text="{getAccount().getLabel()}"/> + <javax.swing.text.Document javaBean="getDescriptionTextField().getDocument()" + onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())' + onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' /> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.common.masteraccount"/> + </cell> + <cell fill="horizontal"> + <JTextField id="masterAccountTextField" text="{getAccount().getMasterAccount().getAccountNumber()}"/> + </cell> + </row> + <row> + <cell fill="none"> + <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + <cell fill="none"> + <JButton id="ok" text="lima.common.ok" onActionPerformed="performOk()"/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateSubLedgerForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateSubLedgerForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateSubLedgerForm.jaxx 2011-08-10 13:27:34 UTC (rev 3258) @@ -0,0 +1,101 @@ +<JDialog modal="true" + defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" + onWindowClosing="performCancel();"> + + <org.chorem.lima.entity.Account id="account" javaBean='null'/> + + <script> + <![CDATA[ + import org.chorem.lima.business.AccountServiceMonitorable; + import org.chorem.lima.service.LimaServiceFactory; + import org.chorem.lima.business.LimaException; + import org.chorem.lima.entity.AccountImpl; + + getRootPane().setDefaultButton(ok); + protected void performCancel() { + setAccount(null); + dispose(); + } + protected void performOk() { + if (getMasterAccountTextField().getText().length() != 0) { + AccountServiceMonitorable accountService = + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); + Account masterAccount = new AccountImpl(); + try { + System.out.println("setMaster : " + + getMasterAccountTextField().getText() + " to : " + + getAccount().getAccountNumber()); + masterAccount = accountService + .getAccountByNumber(getMasterAccountTextField().getText()); + } catch (LimaException eee) { + log.debug("Can't search account for update : " + + getMasterAccountTextField().getText(), eee); + } + if (masterAccount != null) { + getAccount().setMasterAccount(masterAccount); + } else { + getAccount().setMasterAccount(null); + } + } else { + setAccount(null); + } + dispose(); + } + ]]> + </script> + + <Table> + <row> + <cell fill="horizontal"> + <JLabel text="lima.common.code"/> + </cell> + <cell fill="horizontal"> + <JTextField id="numberTextField" + text="{getAccount().getAccountNumber()}"/> + <javax.swing.text.Document javaBean="getNumberTextField().getDocument()" + onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' + onRemoveUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' /> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.common.label"/> + </cell> + <cell fill="horizontal"> + <JTextField id="descriptionTextField" text="{getAccount().getLabel()}"/> + <javax.swing.text.Document javaBean="getDescriptionTextField().getDocument()" + onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())' + onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' /> + </cell> + </row> + <!-- Lien Fiche contact--> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.contact"/> + </cell> + <cell fill="horizontal"> + <JTextField id="thirdPartyTextField" text="{getAccount().getThirdParty()}"/> + <javax.swing.text.Document javaBean="getThirdPartyTextField().getDocument()" + onInsertUpdate='getAccount().setThirdParty(getThirdPartyTextField().getText())' + onRemoveUpdate='getAccount().setThirdParty(getThirdPartyTextField().getText())' /> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.common.masteraccount"/> + </cell> + <cell fill="horizontal"> + <JTextField id="masterAccountTextField" text="{getAccount().getMasterAccount().getAccountNumber()}"/> + </cell> + </row> + <row> + <cell fill="none"> + <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + <cell fill="none"> + <JButton id="ok" text="lima.common.ok" onActionPerformed="performOk()"/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file