Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 1853 discussions
r3258 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/account
by vsalaun@users.chorem.org 10 Aug '11
by vsalaun@users.chorem.org 10 Aug '11
10 Aug '11
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
1
0
r3257 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/resources/i18n
by vsalaun@users.chorem.org 10 Aug '11
by vsalaun@users.chorem.org 10 Aug '11
10 Aug '11
Author: vsalaun
Date: 2011-08-10 13:38:02 +0200 (Wed, 10 Aug 2011)
New Revision: 3257
Url: http://chorem.org/repositories/revision/lima/3257
Log:
#426 enable changing master account for an account
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/DocumentServiceImpl.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/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
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-09 12:38:19 UTC (rev 3256)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2011-08-10 11:38:02 UTC (rev 3257)
@@ -335,6 +335,17 @@
}
accountsList.addAll(accountDAO.findAllByQuery(query));
Collections.sort(accountsList, new AccountComparator());
+
+ // sort of bug fix 2011.09.10 vsalaun (+ bleny)
+ // do NOT delete these lines unless you find a better way to
+ // prevent lazy exception when updating account from the account chart
+ for (Account t : accountsList) {
+ if (t.getMasterAccount() != null) {
+ t.getMasterAccount().getTopiaId();
+ }
+ t.sizeSubAccounts();
+ t.sizeSubLedgers();
+ }
}
catch (TopiaException ex) {
@@ -425,9 +436,7 @@
* Il n'est pas possible de modifier un numéro de compte.
* Si le compte n'existe pas, il envoie alors un message d'avertissement.
*
- * @param accountNumber numéro de compte à modifier
- * @param label label à modifier
- * @param masterAccountNumber compte père à modifier
+ * @param account compte à modifier
* @throws LimaException
*/
@@ -444,19 +453,15 @@
LimaCallaoDAOHelper.getAccountDAO(transaction);
Account subAccount = accountDAO.findByTopiaId(account.getTopiaId());
//check rules account if ledger or account
- if (account.getGeneralLedger() == null){
+ if (account.getGeneralLedger() == null) { // is an account
- //get masteraccount, search account have account in params in all subaccounts collection
- TopiaQuery query = accountDAO.createQuery()
- .addInElements(":account", "subAccounts")
- .addParam("account", account);
- Account master = accountDAO.findByQuery(query);
+ Account master = account.getMasterAccount();
accountingRules.updateAccountRules(master, account);
subAccount.setMasterAccount(account.getMasterAccount());
subAccount.setSubAccounts(account.getSubAccounts());
}
- else {
+ else { // is a ledger
accountingRules.updateSubLedgerRules(account);
subAccount.setGeneralLedger(account.getGeneralLedger());
subAccount.setSubLedgers(account.getSubLedgers());
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2011-08-09 12:38:19 UTC (rev 3256)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2011-08-10 11:38:02 UTC (rev 3257)
@@ -37,11 +37,9 @@
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import java.util.Locale;
import javax.ejb.EJB;
import javax.ejb.Stateless;
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-09 12:38:19 UTC (rev 3256)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2011-08-10 11:38:02 UTC (rev 3257)
@@ -28,28 +28,56 @@
onWindowClosing="performCancel();">
<org.chorem.lima.entity.Account id="account" javaBean='null'/>
- <Boolean id="addState" javaBean='true'/>
<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='{isAddState()}' text="{getAccount().getAccountNumber()}"/>
- <javax.swing.text.Document javaBean="getNumberTextField().getDocument()"
- onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())'
- onRemoveUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' />
+ <JTextField id="numberTextField" editable='{false}' text="{getAccount().getAccountNumber()}"/>
</cell>
</row>
<row>
@@ -64,11 +92,19 @@
</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="dispose()"/>
+ <JButton id="ok" text="lima.common.ok" onActionPerformed="performOk()"/>
</cell>
</row>
</Table>
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 2011-08-09 12:38:19 UTC (rev 3256)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2011-08-10 11:38:02 UTC (rev 3257)
@@ -222,21 +222,24 @@
/**
* Update account.
*
- * @param path
* @param account
* @throws LimaException
*/
- public void updateAccount(TreePath path, Account account) throws LimaException {
+ public void updateAccount(Account account) throws LimaException {
// Calling account service
//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);
+ throw new LimaBusinessException("Can't update account : "
+ + account.getAccountNumber(), eee);
}
- modelSupport.fireTreeStructureChanged(path);
+ //FIXME 2011.08.10 vsalaun quick tree refresh, it should only refresh the path where
+ //the account were, and the path where it has been moved
+ //modelSupport.fireTreeStructureChanged(path);
+ modelSupport.fireNewRoot();
}
/**
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-09 12:38:19 UTC (rev 3256)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2011-08-10 11:38:02 UTC (rev 3257)
@@ -144,61 +144,61 @@
};
public void addSubLedger(){
- JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
- AccountTreeTableModel accountsTreeTableModel =
- (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
-
- Account newAccount = new AccountImpl();
- SubLedgerForm subledgerForm = new SubLedgerForm(view);
- subledgerForm.setAccount(newAccount);
- // jaxx constructor don't call super() ?
- subledgerForm.setLocationRelativeTo(view);
- subledgerForm.setVisible(true);
- newAccount=subledgerForm.getAccount();
-
- // null == cancel action
- if (newAccount != null) {
- Account parentAccount = new AccountImpl();
- String number = newAccount.getAccountNumber();
+
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel =
+ (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+ Account newAccount = new AccountImpl();
+ SubLedgerForm subledgerForm = new SubLedgerForm(view);
+ subledgerForm.setAccount(newAccount);
+ // jaxx constructor don't call super() ?
+ subledgerForm.setLocationRelativeTo(view);
+ subledgerForm.setVisible(true);
+ newAccount=subledgerForm.getAccount();
+
+ // null == cancel action
+ if (newAccount != null) {
+ Account parentAccount = new AccountImpl();
+ String number = newAccount.getAccountNumber();
- //search for the nearest account from the one been created
- //e.g.: for 41019 search for 4, 41, 410, 4101
- //and stop when the account doesn't exist, use last account found instead
- for (int i = 1; i<=number.length(); i++) {
- try {
- //get the parent account from the new account subnumber
- parentAccount = accountService.getAccountByNumber(number.substring(0, i));
- } catch (LimaException eee) {
- log.debug("Can't search account : " + number.substring(0, i), eee);
- }
- if (parentAccount == null) {
- try {
- //if the account is null, get the previous account searched then stop the loop
- parentAccount = accountService.getAccountByNumber(number.substring(0, i-1));
- break;
- } catch (LimaException eee) {
- log.debug("Can't search account : " + number.substring(0, i-1), eee);
- }
- }
- }
+ //search for the nearest account from the one been created
+ //e.g.: for 41019 search for 4, 41, 410, 4101
+ //and stop when the account doesn't exist, use last account found instead
+ for (int i = 1; i<=number.length(); i++) {
+ try {
+ //get the parent account from the new account subnumber
+ parentAccount = accountService.getAccountByNumber(number.substring(0, i));
+ } catch (LimaException eee) {
+ log.debug("Can't search account : " + number.substring(0, i), eee);
+ }
+ if (parentAccount == null) {
+ try {
+ //if the account is null, get the previous account searched then stop the loop
+ parentAccount = accountService.getAccountByNumber(number.substring(0, i-1));
+ break;
+ } catch (LimaException eee) {
+ log.debug("Can't search account : " + number.substring(0, i-1), eee);
+ }
+ }
+ }
- // add it
- try {
- accountsTreeTableModel.addSubLedger(parentAccount, newAccount);
- } catch (LimaBusinessException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add subledger", eee);
- }
- DialogHelper.showMessageDialog(eee.getMessage());
- }
+ // add it
+ try {
+ accountsTreeTableModel.addSubLedger(parentAccount, newAccount);
+ } catch (LimaBusinessException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add subledger", eee);
+ }
+ DialogHelper.showMessageDialog(eee.getMessage());
+ }
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't add subledger", eee);
- }
- DialogHelper.showMessageDialog(eee.getMessage());
- }
- }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add subledger", eee);
+ }
+ DialogHelper.showMessageDialog(eee.getMessage());
+ }
+ }
}
/**
@@ -223,7 +223,7 @@
treePath = new TreePath(accountsTreeTableModel.getRoot());
}
//test if selectedrow is account or ledger
- if (selectedObject.getGeneralLedger()==null){
+ if (selectedObject.getGeneralLedger()==null) {
AccountForm accountForm = new AccountForm(view);
accountForm.setAccount(selectedObject);
// jaxx constructor don't call super() ?
@@ -231,9 +231,9 @@
accountForm.setVisible(true);
// null == cancel action
selectedObject = accountForm.getAccount();
- }
+ }
// else is a subledger
- else{
+ else {
SubLedgerForm subLedgerForm = new SubLedgerForm(view);
subLedgerForm.setAccount(selectedObject);
// jaxx constructor don't call super() ?
@@ -243,11 +243,11 @@
selectedObject = subLedgerForm.getAccount();
}
//if action confirmed
- if (selectedObject != null){
+ if (selectedObject != null) {
// update it
try {
accountsTreeTableModel.
- updateAccount(treePath, selectedObject);
+ updateAccount(selectedObject);
} catch (LimaException eee) {
if (log.isErrorEnabled()) {
log.error("Can't add update", eee);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2011-08-09 12:38:19 UTC (rev 3256)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2011-08-10 11:38:02 UTC (rev 3257)
@@ -28,8 +28,6 @@
onWindowClosing="performCancel();">
<org.chorem.lima.entity.Account id="account" javaBean='null'/>
-
- <Boolean id="addState" javaBean='true'/>
<script>
<![CDATA[
@@ -47,7 +45,7 @@
<JLabel text="lima.common.code"/>
</cell>
<cell fill="horizontal">
- <JTextField id="numberTextField" editable='{isAddState()}'
+ <JTextField id="numberTextField"
text="{getAccount().getAccountNumber()}"/>
<javax.swing.text.Document javaBean="getNumberTextField().getDocument()"
onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())'
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2011-08-09 12:38:19 UTC (rev 3256)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2011-08-10 11:38:02 UTC (rev 3257)
@@ -70,6 +70,7 @@
lima.common.globalexception=Global lima exception
lima.common.info=Information
lima.common.label=Label
+lima.common.masteraccount=Master account
lima.common.movmentedfilter=Accounts filtered
lima.common.next=Next
lima.common.ok=OK
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2011-08-09 12:38:19 UTC (rev 3256)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2011-08-10 11:38:02 UTC (rev 3257)
@@ -70,6 +70,7 @@
lima.common.globalexception=Global lima exception
lima.common.info=Information
lima.common.label=Libellé
+lima.common.masteraccount=Compte parent
lima.common.movmentedfilter=Comptes mouvementés
lima.common.next=Suivant
lima.common.ok=OK
1
0
r3256 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/account
by vsalaun@users.chorem.org 09 Aug '11
by vsalaun@users.chorem.org 09 Aug '11
09 Aug '11
Author: vsalaun
Date: 2011-08-09 14:38:19 +0200 (Tue, 09 Aug 2011)
New Revision: 3256
Url: http://chorem.org/repositories/revision/lima/3256
Log:
#426 stop using path to set account inception
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/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
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 2011-08-09 10:35:40 UTC (rev 3255)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2011-08-09 12:38:19 UTC (rev 3256)
@@ -190,23 +190,6 @@
public boolean isLeaf(Object node) {
return getChildCount(node) == 0;
}
-
- /**
- * Add account (path can be null).
- *
- * @param path
- * @param account
- * @throws LimaException
- */
- public void addAccount(TreePath path, Account account) throws LimaException {
- // Calling account service
- Account parentAccount = (Account)path.getLastPathComponent();
- if (parentAccount == getRoot()) {
- parentAccount = null;
- }
- accountService.createAccount(parentAccount, account);
- modelSupport.fireTreeStructureChanged(path);
- }
/**
* Add account
@@ -217,25 +200,23 @@
*/
public void addAccount(Account parentAccount, Account account) throws LimaException{
accountService.createAccount(parentAccount, account);
- //FIXME 2011.08.09 vsalaun quick tree refresh, it should refresh only the path changed
+ //FIXME 2011.08.09 vsalaun quick tree refresh, it should refresh only the path changed
+ //modelSupport.fireTreeStructureChanged(path);
modelSupport.fireNewRoot();
}
/**
- * Add account (path can be null).
+ * Add account
*
- * @param path
+ * @param parentAccount
* @param account
* @throws LimaException
*/
- public void addSubLedger(TreePath path, Account account) throws LimaException {
- // Calling account service
- Account parentAccount = (Account)path.getLastPathComponent();
- if (parentAccount == getRoot()) {
- parentAccount = null;
- }
+ public void addSubLedger(Account parentAccount, Account account) throws LimaException {
accountService.createSubLedger(parentAccount, account);
- modelSupport.fireTreeStructureChanged(path);
+ //FIXME 2011.08.09 vsalaun quick tree refresh, it should refresh only the path changed
+ //modelSupport.fireTreeStructureChanged(path);
+ modelSupport.fireNewRoot();
}
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2011-08-09 10:35:40 UTC (rev 3255)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2011-08-09 12:38:19 UTC (rev 3256)
@@ -55,8 +55,7 @@
<row>
<cell fill="horizontal">
<JButton id="addSubLedger" text="lima.charts.account.addSubLedger"
- onActionPerformed="getHandler().addSubLedger()"
- enabled="{isSelectedRow()}"/>
+ onActionPerformed="getHandler().addSubLedger()"/>
</cell>
</row>
<row>
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-09 10:35:40 UTC (rev 3255)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2011-08-09 12:38:19 UTC (rev 3256)
@@ -99,42 +99,33 @@
newAccount = accountForm.getAccount();
Account parentAccount = new AccountImpl();
if (newAccount != null) {
- // get current selection path
- TreePath treePath = null;
- int selectedRow = view.getAccountsTreeTable().getSelectedRow();
- if (selectedRow != -1) {
- treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
- } else {
- //FIXME Get root created on model with Impl()
- //Can best not create root in model, and verify if root is null ?
- treePath = new TreePath(accountsTreeTableModel.getRoot());
-
- String number = newAccount.getAccountNumber();
+ //get the account number been created
+ String number = newAccount.getAccountNumber();
- for (int i = 1; i<=number.length(); i++) {
+ //search for the nearest account from the one been created
+ //e.g.: for 41019 search for 4, 41, 410, 4101
+ //and stop when the account doesn't exist, use last account found instead
+ for (int i = 1; i<number.length(); i++) {
+ try {
+ //get the parent account from the new account subnumber
+ parentAccount = accountService.getAccountByNumber(number.substring(0, i));
+ } catch (LimaException eee) {
+ log.debug("Can't search account : " + number.substring(0, i), eee);
+ }
+ if (parentAccount == null) {
try {
- parentAccount = accountService.getAccountByNumber(number.substring(0, i));
+ //if the account is null, get the previous account searched then stop the loop
+ parentAccount = accountService.getAccountByNumber(number.substring(0, i-1));
+ break;
} catch (LimaException eee) {
- log.debug("Can't search account : " + number.substring(0, i), eee);
+ log.debug("Can't search account : " + number.substring(0, i-1), eee);
}
- if (parentAccount == null) {
- try {
- parentAccount = accountService.getAccountByNumber(number.substring(0, i-1));
- break;
- } catch (LimaException eee) {
- log.debug("Can't search account : " + number.substring(0, i-1), eee);
- }
- }
}
}
// add it
try {
- if (selectedRow != -1) {
- accountsTreeTableModel.addAccount(treePath, newAccount);
- } else {
- accountsTreeTableModel.addAccount(parentAccount, newAccount);
- }
+ accountsTreeTableModel.addAccount(parentAccount, newAccount);
} catch (LimaBusinessException eee) {
if (log.isErrorEnabled()) {
log.error("Can't add account", eee);
@@ -167,14 +158,33 @@
// null == cancel action
if (newAccount != null) {
- // get current selection path
- TreePath treePath = null;
- int selectedRow = view.getAccountsTreeTable().getSelectedRow();
- treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ Account parentAccount = new AccountImpl();
+ String number = newAccount.getAccountNumber();
+
+ //search for the nearest account from the one been created
+ //e.g.: for 41019 search for 4, 41, 410, 4101
+ //and stop when the account doesn't exist, use last account found instead
+ for (int i = 1; i<=number.length(); i++) {
+ try {
+ //get the parent account from the new account subnumber
+ parentAccount = accountService.getAccountByNumber(number.substring(0, i));
+ } catch (LimaException eee) {
+ log.debug("Can't search account : " + number.substring(0, i), eee);
+ }
+ if (parentAccount == null) {
+ try {
+ //if the account is null, get the previous account searched then stop the loop
+ parentAccount = accountService.getAccountByNumber(number.substring(0, i-1));
+ break;
+ } catch (LimaException eee) {
+ log.debug("Can't search account : " + number.substring(0, i-1), eee);
+ }
+ }
+ }
+
// add it
try {
- accountsTreeTableModel.
- addSubLedger(treePath, newAccount);
+ accountsTreeTableModel.addSubLedger(parentAccount, newAccount);
} catch (LimaBusinessException eee) {
if (log.isErrorEnabled()) {
log.error("Can't add subledger", eee);
1
0
r3255 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/account
by vsalaun@users.chorem.org 09 Aug '11
by vsalaun@users.chorem.org 09 Aug '11
09 Aug '11
Author: vsalaun
Date: 2011-08-09 12:35:40 +0200 (Tue, 09 Aug 2011)
New Revision: 3255
Url: http://chorem.org/repositories/revision/lima/3255
Log:
#426 add possibility to add an account without selecting a row
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/AccountViewHandler.java
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 2011-08-08 14:15:02 UTC (rev 3254)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2011-08-09 10:35:40 UTC (rev 3255)
@@ -66,7 +66,7 @@
accountService =
LimaServiceFactory.getInstance().getService(
AccountServiceMonitorable.class);
- }
+ }
@Override
@@ -207,6 +207,19 @@
accountService.createAccount(parentAccount, account);
modelSupport.fireTreeStructureChanged(path);
}
+
+ /**
+ * Add account
+ *
+ * @param parentAccount
+ * @param account
+ * @throws LimaException
+ */
+ public void addAccount(Account parentAccount, Account account) throws LimaException{
+ accountService.createAccount(parentAccount, account);
+ //FIXME 2011.08.09 vsalaun quick tree refresh, it should refresh only the path changed
+ modelSupport.fireNewRoot();
+ }
/**
* Add account (path can be null).
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-08 14:15:02 UTC (rev 3254)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2011-08-09 10:35:40 UTC (rev 3255)
@@ -31,6 +31,7 @@
import javax.swing.tree.TreePath;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
@@ -64,17 +65,21 @@
protected AccountView view;
- //protected AccountServiceMonitorable accountService;
+ protected AccountServiceMonitorable accountService;
protected AccountViewHandler(AccountView view) {
this.view = view;
// Gets factory service
LimaServiceFactory.getInstance().getService(
ImportServiceMonitorable.class).addListener(this);
+ accountService =
+ LimaServiceFactory.getInstance().getService(
+ AccountServiceMonitorable.class);
}
/**
* Add new account with account form.
+ * @throws LimaException
*/
public void addAccount() {
@@ -92,21 +97,44 @@
// null == cancel action
newAccount = accountForm.getAccount();
+ Account parentAccount = new AccountImpl();
if (newAccount != null) {
// get current selection path
TreePath treePath = null;
int selectedRow = view.getAccountsTreeTable().getSelectedRow();
- if ( selectedRow != -1) {
+ if (selectedRow != -1) {
treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
} else {
//FIXME Get root created on model with Impl()
//Can best not create root in model, and verify if root is null ?
treePath = new TreePath(accountsTreeTableModel.getRoot());
+
+ String number = newAccount.getAccountNumber();
+
+ for (int i = 1; i<=number.length(); i++) {
+ try {
+ parentAccount = accountService.getAccountByNumber(number.substring(0, i));
+ } catch (LimaException eee) {
+ log.debug("Can't search account : " + number.substring(0, i), eee);
+ }
+ if (parentAccount == null) {
+ try {
+ parentAccount = accountService.getAccountByNumber(number.substring(0, i-1));
+ break;
+ } catch (LimaException eee) {
+ log.debug("Can't search account : " + number.substring(0, i-1), eee);
+ }
+ }
+ }
}
// add it
try {
- accountsTreeTableModel.addAccount(treePath, newAccount);
+ if (selectedRow != -1) {
+ accountsTreeTableModel.addAccount(treePath, newAccount);
+ } else {
+ accountsTreeTableModel.addAccount(parentAccount, newAccount);
+ }
} catch (LimaBusinessException eee) {
if (log.isErrorEnabled()) {
log.error("Can't add account", eee);
1
0
r3254 - trunk/lima-business/src/test/java/org/chorem/lima/business
by vsalaun@users.chorem.org 08 Aug '11
by vsalaun@users.chorem.org 08 Aug '11
08 Aug '11
Author: vsalaun
Date: 2011-08-08 16:15:02 +0200 (Mon, 08 Aug 2011)
New Revision: 3254
Url: http://chorem.org/repositories/revision/lima/3254
Log:
#424 update all EntryBooks tests
Modified:
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2011-08-08 13:57:43 UTC (rev 3253)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2011-08-08 14:15:02 UTC (rev 3254)
@@ -92,24 +92,33 @@
@Test
public void searchJournalWithLabelTest() throws LimaException {
List<EntryBook> result = instance.getAllEntryByProperty(EntryBook.LABEL, "Journal des ventes");
- Assert.assertEquals("Journal des ventes", result.get(0).getLabel());
- /*result = instance.searchJournalWithLabel("Journal des achats");
- Assert.assertEquals("Journal des achats", result.getLabel());*/
+ if ((result != null) && (result.size() != 0)) {
+ Assert.assertEquals("Journal des ventes", result.get(0).getLabel());
+ }
+ result = instance.getAllEntryByProperty(EntryBook.LABEL, "Journal des achats");
+ if ((result != null) && (result.size() != 0)) {
+ Assert.assertEquals("Journal des achats", result.get(0).getLabel());
+ }
}
/**
* Permet de tester la modification d'un journal suivant son préfixe.
+ * @throws LimaException
*/
@Test
- public void modifyJournalTest() {
- /*Journal journal = instance.searchJournalWithLabel("Journal des ventes");
- Assert.assertEquals("Journal des ventes", journal.getLabel());
- String result = instance.modifyJournal(journal.getTopiaId(),
- "Journal des ventes", "new_prefix", "new_description");
+ public void modifyJournalTest() throws LimaException {
+ List<EntryBook> entryBooksList = instance.getAllEntryByProperty(EntryBook.LABEL, "Journal des ventes");
+ if (entryBooksList != null) {
+ Assert.assertEquals("Journal des ventes", entryBooksList.get(0).getLabel());
+ entryBooksList.get(0).setCode("New Code");
+ instance.updateEntryBook(entryBooksList.get(0));
+ }
+
// Recherche du journal dans la bdd
- JournalDTO journalDTO = instance
- .searchJournalDTOWithLabel("Journal des ventes");
- Assert.assertEquals("new_prefix", journalDTO.getPrefix());*/
+ entryBooksList = instance.getAllEntryByProperty(EntryBook.LABEL, "Journal des ventes");
+ if (entryBooksList != null) {
+ Assert.assertEquals("New Code", entryBooksList.get(0).getCode());
+ }
}
}
\ No newline at end of file
1
0
r3253 - in trunk/lima-business/src: main/java/org/chorem/lima/business/ejb main/java/org/chorem/lima/business/ejbinterface test/java/org/chorem/lima/business
by vsalaun@users.chorem.org 08 Aug '11
by vsalaun@users.chorem.org 08 Aug '11
08 Aug '11
Author: vsalaun
Date: 2011-08-08 15:57:43 +0200 (Mon, 08 Aug 2011)
New Revision: 3253
Url: http://chorem.org/repositories/revision/lima/3253
Log:
#424 update all accounts tests
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/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookService.java
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.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-08 10:06:23 UTC (rev 3252)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2011-08-08 13:57:43 UTC (rev 3253)
@@ -80,9 +80,7 @@
@Override
- public boolean createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException {
-
- boolean result = true;
+ public void createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException {
try {
// check if account number already exist
@@ -112,10 +110,8 @@
commitTransaction(topiaContext);
}
catch (TopiaException ex) {
- result = false;
doCatch(topiaContext, ex, log);
}
- return result;
}
@@ -129,10 +125,8 @@
* @throws LimaException
*/
@Override
- public boolean createAccount(Account masterAccount, Account account) throws LimaException {
+ public void createAccount(Account masterAccount, Account account) throws LimaException {
- boolean result = true;
-
//check rules before create the account
accountingRules.createAccountRules(masterAccount, account);
@@ -140,17 +134,15 @@
try {
transaction = beginTransaction();
- result = createAccountWithTransaction(masterAccount, account, transaction);
+ createAccountWithTransaction(masterAccount, account, transaction);
}
catch (TopiaException ex) {
- result = false;
doCatch(transaction, ex, log);
}
finally {
doFinally(transaction, log);
}
- return result;
}
@@ -443,6 +435,7 @@
public void updateAccount(Account account) throws LimaException {
TopiaContext transaction = null;
+
try {
transaction = beginTransaction();
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2011-08-08 10:06:23 UTC (rev 3252)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2011-08-08 13:57:43 UTC (rev 3253)
@@ -132,10 +132,9 @@
* @return
* @throws LimaException
*/
- public boolean createEntryBook(EntryBook entryBook) throws LimaException {
+ public void createEntryBook(EntryBook entryBook) throws LimaException {
TopiaContext transaction = null;
- boolean result = true;
try {
transaction = beginTransaction();
@@ -143,13 +142,11 @@
createEntryBookWithTransaction(entryBook, transaction);
}
catch (TopiaException ex) {
- result = false;
doCatch(transaction, ex, log);
}
finally {
doFinally(transaction, log);
}
- return result;
}
/**
@@ -209,9 +206,8 @@
* @throws LimaException
*
*/
- public boolean updateEntryBook(EntryBook entryBook) throws LimaException {
+ public void updateEntryBook(EntryBook entryBook) throws LimaException {
TopiaContext transaction = null;
- boolean result = true;
try {
transaction = beginTransaction();
@@ -225,13 +221,11 @@
commitTransaction(transaction);
}
catch (TopiaException ex) {
- result = false;
doCatch(transaction, ex, log);
}
finally {
doFinally(transaction, log);
}
- return result;
}
/**
@@ -243,10 +237,9 @@
* @param prefix préfixe du EntryBook à supprimer
* @throws LimaException
*/
- public boolean removeEntryBook(EntryBook entryBook) throws LimaException {
+ public void removeEntryBook(EntryBook entryBook) throws LimaException {
TopiaContext topiaTransaction = null;
- boolean result = true;
try {
topiaTransaction = beginTransaction();
@@ -262,13 +255,11 @@
commitTransaction(topiaTransaction);
}
catch (TopiaException ex) {
- result = false;
doCatch(topiaTransaction, ex, log);
}
finally {
doFinally(topiaTransaction, log);
}
- return result;
}
protected TopiaContext beginTransaction() throws TopiaException {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookService.java 2011-08-08 10:06:23 UTC (rev 3252)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookService.java 2011-08-08 13:57:43 UTC (rev 3253)
@@ -45,6 +45,8 @@
List<EntryBook> getAllEntryBooks() throws LimaException;
+ List<EntryBook> getAllEntryByProperty(String propertyName, String value) throws LimaException;
+
void createEntryBook(EntryBook entryBook) throws LimaException;
void updateEntryBook(EntryBook entryBook) throws LimaException;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2011-08-08 10:06:23 UTC (rev 3252)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2011-08-08 13:57:43 UTC (rev 3253)
@@ -91,38 +91,34 @@
*/
@Test
public void createAccountDAOTest() throws LimaException {
- Boolean result;
- // Création des comptes DTO
+ // Création des comptes
Account account = new AccountImpl();
account.setAccountNumber("5");
account.setLabel("COMPTES FINANCIERS");
- result = instance.createAccount(null, account);
-
+ instance.createAccount(null, account);
Account accountChild1 = new AccountImpl();
accountChild1.setAccountNumber("50");
accountChild1.setLabel("Valeurs mobilières de placement");
//accountChild1.setMasterAccount(account);
- result = instance.createAccount(account, accountChild1);
+ instance.createAccount(account, accountChild1);
Account accountChild2 = new AccountImpl();
accountChild2.setAccountNumber("51");
accountChild2.setLabel("Banques établissements financiers et assimilés");
//accountChild2.setMasterAccount(account);
- result = instance.createAccount(account, accountChild2);
+ instance.createAccount(account, accountChild2);
Account accountChildChild1 = new AccountImpl();
accountChildChild1.setAccountNumber("511");
accountChildChild1.setLabel("Valeurs à l'encaissement");
//accountChildChild1.setMasterAccount(accountChild2);
- result = instance.createAccount(accountChild2, accountChildChild1);
+ instance.createAccount(accountChild2, accountChildChild1);
Account accountChildChild2 = new AccountImpl();
accountChildChild2.setAccountNumber("512");
accountChildChild2.setLabel("Banques");
//accountChildChild2.setMasterAccount(accountChild2);
- result = instance.createAccount(accountChild2, accountChildChild2);
-
- Assert.assertEquals(true,result);
+ instance.createAccount(accountChild2, accountChildChild2);
}
@@ -165,32 +161,47 @@
/**
- * Permet de tester si un compte est bien effacé. Si celui-ci n'existe pas
- * un message d'avertissement doit apparaître.
- * On supprime un compte avec seulement son numéro de compte (supposé/vérifié
- * unique lors de la création).
+ * Permet de tester si un compte est bien effacé.
+ * @throws LimaException
*/
@Test
- public void removeAccountTest() {
- boolean result;
+ public void removeAccountTest() throws LimaException {
+ Account masterAccount = instance.getAccountByNumber("4");
// Création de comptes
- /*instance.createAccount("40", "Fournisseurs", "4","actif");
- instance.createAccount("41", "Usagers", "4","actif");
- instance.createAccount("44", "Etat", "4","actif");
+ Account account = new AccountImpl();
+ account.setAccountNumber("40");
+ account.setLabel("Fournisseurs");
+ instance.createAccount(masterAccount, account);
+
+ Account account2 = new AccountImpl();
+ account2.setAccountNumber("41");
+ account2.setLabel("Usagers");
+ instance.createAccount(masterAccount, account2);
+
+ Account account3 = new AccountImpl();
+ account3.setAccountNumber("44");
+ account3.setLabel("Etat");
+ instance.createAccount(masterAccount, account3);
// On souhaite supprimer le compte 41. Ce compte existe bien. Il ne possède
// pas de fils. La suppression se déroule bien.
- result = instance.removeAccount("41");
- Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ instance.removeAccount(account2);
+
// On recherche les fils du compte 4
- List<Account> listAccount = instance.searchListChildAccount("4");
+ List<Account> listAccount = instance.getChildrenAccounts(masterAccount);
// Il ne doit en possèder que 2 (au lieu de 3)
Assert.assertEquals(2,listAccount.size());
-
+ }
+
+
+ @Test(expected=LimaException.class)
+ public void removeUnexistedAccountTest() throws LimaException {
// On souhaite supprimer le compte 422, ce dernier n'existe pas. La
// suppression ne peut s'effectuer.
- result = instance.removeAccount("422");
- Assert.assertEquals(ServiceHelper.ACCOUNT_NOT_EXIST,result);*/
+ Account account4 = new AccountImpl();
+ account4.setAccountNumber("422");
+ account4.setLabel("Unsaved account");
+ instance.removeAccount(account4);
}
@@ -203,36 +214,46 @@
* 50 et 51, dont 51 a à son tour les comptes enfants 511 et 512.
* Nous ajoutons un compte supplémentaire 53 à 5. Nous modifions une valeur
* sur le compte 5, et supprimons le compte 51 (et ses enfants).
+ * @throws LimaException
*/
@Test
- public void updateTest() {
- /*String result;
+ public void updateTest() throws LimaException {
// On recherche le compte 5 - COMPTES FINANCIERS
- AccountDTO accountDTO = instance.searchAccountDTO("5");
+ Account account = instance.getAccountByNumber("5");
+
// {ETAPE 1} Modification du nom pour le compte 5
- accountDTO.setLabel("COMPTES FINANCIERS modifié");
+ account.setLabel("COMPTES FINANCIERS modifié");
+
// {ETAPE 2} Ajout du compte 53
- AccountDTO accountChildDTO = new AccountDTO("","53","Caisse","5",null,"actif");
- accountDTO.addAccountChild(accountChildDTO);
+ Account accountChild = new AccountImpl();
+ accountChild.setAccountNumber("53");
+ accountChild.setLabel("Caisse");
+ accountChild.setMasterAccount(account);
+
+ instance.createAccount(account, accountChild);
+
+ account.addSubAccounts(accountChild);
+
// {ETAPE 3} Supprime le compte 51 (ainsi que ses enfants 511 et 512)
- AccountDTO accountremoveDTO = instance.searchAccountDTO("51");
- accountDTO.removeAccountChild(accountremoveDTO);
+ Account accountRemove = instance.getAccountByNumber("51");
+
+ account.removeSubAccounts(accountRemove);
+
// Met à jour le compte 5 DTO dans la bdd ainsi que toutes les {ETAPE *}
- result = instance.updateDTO(accountDTO);
- Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);
+ instance.updateAccount(account);
// Vérification ETAPE
// ETAPE 1
- Account account = instance.searchAccount("5");
+ account = instance.getAccountByNumber("5");
Assert.assertEquals("COMPTES FINANCIERS modifié",account.getLabel());
// ETAPE 2
- account = instance.searchAccount("53");
+ account = instance.getAccountByNumber("53");
Assert.assertEquals("Caisse",account.getLabel());
// ETAPE 3
- account = instance.searchAccount("5"); // les comptes fils de 5
- List<Account> listAccount = instance.searchListChildAccount(account);
- // Il doit avoir 50 et 53
- Assert.assertEquals(2,listAccount.size());*/
+ account = instance.getAccountByNumber("5"); // les comptes fils de 5
+ List<Account> listAccount = instance.getChildrenAccounts(account);
+ // Il doit avoir 50, 51 (de la méthode searchListAccountTest) et 53
+ Assert.assertEquals(3,listAccount.size());
}
}
\ No newline at end of file
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2011-08-08 10:06:23 UTC (rev 3252)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2011-08-08 13:57:43 UTC (rev 3253)
@@ -82,8 +82,7 @@
EntryBook entryBook = new EntryBookImpl();
entryBook.setLabel("Journal des ventes");
entryBook.setCode("jdv");
- boolean result = instance.createEntryBook(entryBook);
- Assert.assertTrue(result);
+ instance.createEntryBook(entryBook);
}
/**
1
0
r3252 - in trunk/lima-business/src: main/java/org/chorem/lima/business/ejb test/java/org/chorem/lima/business
by vsalaun@users.chorem.org 08 Aug '11
by vsalaun@users.chorem.org 08 Aug '11
08 Aug '11
Author: vsalaun
Date: 2011-08-08 12:06:23 +0200 (Mon, 08 Aug 2011)
New Revision: 3252
Url: http://chorem.org/repositories/revision/lima/3252
Log:
#424 update accounts tests + change return type for AccountServiceImpl and EntryBookServiceImpl
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/EntryBookServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.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-08 09:12:40 UTC (rev 3251)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2011-08-08 10:06:23 UTC (rev 3252)
@@ -80,8 +80,10 @@
@Override
- public void createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException {
+ public boolean createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException {
+ boolean result = true;
+
try {
// check if account number already exist
AccountDAO accountDAO =
@@ -110,8 +112,10 @@
commitTransaction(topiaContext);
}
catch (TopiaException ex) {
+ result = false;
doCatch(topiaContext, ex, log);
- }
+ }
+ return result;
}
@@ -125,8 +129,10 @@
* @throws LimaException
*/
@Override
- public void createAccount(Account masterAccount, Account account) throws LimaException {
+ public boolean createAccount(Account masterAccount, Account account) throws LimaException {
+ boolean result = true;
+
//check rules before create the account
accountingRules.createAccountRules(masterAccount, account);
@@ -134,15 +140,17 @@
try {
transaction = beginTransaction();
- createAccountWithTransaction(masterAccount, account, transaction);
+ result = createAccountWithTransaction(masterAccount, account, transaction);
}
catch (TopiaException ex) {
+ result = false;
doCatch(transaction, ex, log);
}
finally {
doFinally(transaction, log);
}
+ return result;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2011-08-08 09:12:40 UTC (rev 3251)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2011-08-08 10:06:23 UTC (rev 3252)
@@ -129,22 +129,27 @@
* Création d'un EntryBook. Il peut être unique sur son label (au choix).
*
* @param EntryBook EntryBook
+ * @return
* @throws LimaException
*/
- public void createEntryBook(EntryBook entryBook) throws LimaException {
+ public boolean createEntryBook(EntryBook entryBook) throws LimaException {
TopiaContext transaction = null;
+ boolean result = true;
+
try {
transaction = beginTransaction();
- createEntryBookWithTransaction(entryBook, transaction);
+ createEntryBookWithTransaction(entryBook, transaction);
}
catch (TopiaException ex) {
+ result = false;
doCatch(transaction, ex, log);
}
finally {
doFinally(transaction, log);
}
+ return result;
}
/**
@@ -172,15 +177,42 @@
return entryBooksList;
}
+
+ @Override
+ public List<EntryBook> getAllEntryByProperty(String propertyName, String value) throws LimaException {
+ List<EntryBook> entryBookList = null;
+
+ TopiaContext transaction = null;
+
+ try {
+ transaction = beginTransaction();
+
+ EntryBookDAO entryBookDAO =
+ LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ entryBookList = entryBookDAO.findAllByProperty(propertyName, value);
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ return entryBookList;
+ }
+
/**
* Permet de modifier un journal.
*
* @param entryBook journal
- * @throws LimaException
+ * @throws LimaException
+ *
*/
- public void updateEntryBook(EntryBook entryBook) throws LimaException {
+ public boolean updateEntryBook(EntryBook entryBook) throws LimaException {
TopiaContext transaction = null;
+ boolean result = true;
+
try {
transaction = beginTransaction();
@@ -193,11 +225,13 @@
commitTransaction(transaction);
}
catch (TopiaException ex) {
+ result = false;
doCatch(transaction, ex, log);
}
finally {
doFinally(transaction, log);
}
+ return result;
}
/**
@@ -209,9 +243,11 @@
* @param prefix préfixe du EntryBook à supprimer
* @throws LimaException
*/
- public void removeEntryBook(EntryBook entryBook) throws LimaException {
+ public boolean removeEntryBook(EntryBook entryBook) throws LimaException {
TopiaContext topiaTransaction = null;
+ boolean result = true;
+
try {
topiaTransaction = beginTransaction();
@@ -226,11 +262,13 @@
commitTransaction(topiaTransaction);
}
catch (TopiaException ex) {
+ result = false;
doCatch(topiaTransaction, ex, log);
}
finally {
doFinally(topiaTransaction, log);
}
+ return result;
}
protected TopiaContext beginTransaction() throws TopiaException {
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2011-08-08 09:12:40 UTC (rev 3251)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2011-08-08 10:06:23 UTC (rev 3252)
@@ -25,10 +25,13 @@
package org.chorem.lima.business;
+import java.util.List;
+
import org.chorem.lima.business.ejb.AccountServiceImpl;
import org.chorem.lima.business.ejbinterface.AccountService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
+import org.junit.Assert;
import org.junit.Test;
/**
@@ -53,6 +56,7 @@
public void createAccountTest() throws LimaException {
Account myAccount = new AccountImpl();
myAccount.setAccountNumber("4");
+ myAccount.setLabel("Comptes de tiers");
instance.createAccount(null, myAccount);
}
@@ -83,10 +87,11 @@
* Permet de tester l'ajout des comptes sous format DTO. La grande différence
* entre la création classique, l'applicaion va enregistrer tous les comptes
* enfants.
+ * @throws LimaException
*/
@Test
- public void createAccountDAOTest() {
- /*String result;
+ public void createAccountDAOTest() throws LimaException {
+ Boolean result;
// Création des comptes DTO
Account account = new AccountImpl();
account.setAccountNumber("5");
@@ -112,72 +117,50 @@
result = instance.createAccount(accountChild2, accountChildChild1);
Account accountChildChild2 = new AccountImpl();
- accountChildChild2.setAccountNumber("51");
+ accountChildChild2.setAccountNumber("512");
accountChildChild2.setLabel("Banques");
//accountChildChild2.setMasterAccount(accountChild2);
result = instance.createAccount(accountChild2, accountChildChild2);
- Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);*/
+ Assert.assertEquals(true,result);
}
/**
* Recherche d'un compte dans le plan comptable à partir d'un numéro de
* compte.
+ * @throws LimaException
*/
@Test
- public void searchAccountTest() {
- /*// On recherche le compte 4 - Comptes de tiers
- Account result = instance.searchAccount("4");
- Assert.assertEquals("Comptes de tiers",result.getLabel());*/
+ public void searchAccountTest() throws LimaException {
+ // On recherche le compte 4 - Comptes de tiers
+ Account result = instance.getAccountByNumber("4");
+ Assert.assertEquals("Comptes de tiers",result.getLabel());
}
/**
- * Recherche d'un compte dans le plan comptable à partir d'un numéro de
- * compte. Il renvoie un objet DTO compte
- */
- @Test
- public void searchAccountDTOTest() {
- /*// On recherche le compte 4 - Comptes de tiers
- AccountDTO result = instance.searchAccountDTO("4");
- Assert.assertEquals("Comptes de tiers",result.getLabel());*/
- }
-
-
- /**
* Permet de tester le nombre d'enfants renvoyés appartenant à un père.
+ * @throws LimaException
*/
@Test
- public void searchListAccountTest() {
- /*// On recherche le compte 5 - COMPTES FINANCIERS
- Account account = instance.searchAccount("5");
- List<Account> listAccount = instance.searchListChildAccount(account);
+ public void searchListAccountTest() throws LimaException {
+ // On recherche le compte 5 - COMPTES FINANCIERS
+ Account account = instance.getAccountByNumber("5");
+ List<Account> listAccount = instance.getChildrenAccounts(account);
// Il possède les comptes 50 et 51
- Assert.assertEquals(2,listAccount.size());*/
+ Assert.assertEquals(2,listAccount.size());
}
/**
- * Permet de tester le nombre d'enfants renvoyés appartenant à un père.
- */
- @Test
- public void searchListAccountDTOTest() {
- /*// On recherche le compte 5 - COMPTES FINANCIERS
- AccountDTO accountDTO = instance.searchAccountDTO("5");
- // Il possède les comptes 50 et 51
- Assert.assertEquals(2,accountDTO.getAccountChildDTO().size());*/
- }
-
-
- /**
* Permet de tester la méthode recherchant tous les comptes au format DTO.
+ * @throws LimaException
*/
@Test
- public void getAllAccountTest() {
- /*List<AccountDTO> listAccountDTO = instance.getAllAccount();
- // doit être égal à 2 (compte 4 et 5)
- Assert.assertEquals(2,listAccountDTO.size());*/
+ public void getAllAccountTest() throws LimaException {
+ List<Account> listAccount = instance.getAllAccounts();
+ Assert.assertEquals(9,listAccount.size());
}
@@ -189,9 +172,9 @@
*/
@Test
public void removeAccountTest() {
- /*String result;
+ boolean result;
// Création de comptes
- instance.createAccount("40", "Fournisseurs", "4","actif");
+ /*instance.createAccount("40", "Fournisseurs", "4","actif");
instance.createAccount("41", "Usagers", "4","actif");
instance.createAccount("44", "Etat", "4","actif");
1
0
r3251 - trunk/lima-business/src/test/java/org/chorem/lima/business
by vsalaun@users.chorem.org 08 Aug '11
by vsalaun@users.chorem.org 08 Aug '11
08 Aug '11
Author: vsalaun
Date: 2011-08-08 11:12:40 +0200 (Mon, 08 Aug 2011)
New Revision: 3251
Url: http://chorem.org/repositories/revision/lima/3251
Log:
#424 starts adding some tests
Modified:
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2011-08-05 12:09:49 UTC (rev 3250)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2011-08-08 09:12:40 UTC (rev 3251)
@@ -52,7 +52,7 @@
@Test
public void createAccountTest() throws LimaException {
Account myAccount = new AccountImpl();
- myAccount.setAccountNumber("2");
+ myAccount.setAccountNumber("4");
instance.createAccount(null, myAccount);
}
@@ -85,23 +85,38 @@
* enfants.
*/
@Test
- public void createAccountDTOTest() {
+ public void createAccountDAOTest() {
/*String result;
// Création des comptes DTO
- AccountDTO accountDTO = new AccountDTO("","5","COMPTES FINANCIERS","0",null,"actif");
- AccountDTO accountChildDTO = new AccountDTO("","50","Valeurs mobilières de placement","5",null,"actif");
- accountDTO.addAccountChild(accountChildDTO);
- accountChildDTO = new AccountDTO("","51","Banques établissements financiers et assimilés","5",null,"actif");
- accountDTO.addAccountChild(accountChildDTO);
- AccountDTO accountChilChilddDTO = new AccountDTO("","511","Valeurs à l'encaissement","51",null,"actif");
- accountChildDTO.addAccountChild(accountChilChilddDTO);
- accountChilChilddDTO = new AccountDTO("","512","Banques","51",null,"actif");
- accountChildDTO.addAccountChild(accountChilChilddDTO);
- // Pour afficher les comptes enfants
- //accountDTO.toStringAccountChild();
-
- // Création dans la base de données. Les comptes 5, 50, 51, 511 et 512 sont créés.
- result = instance.createAccount(accountDTO);
+ Account account = new AccountImpl();
+ account.setAccountNumber("5");
+ account.setLabel("COMPTES FINANCIERS");
+ result = instance.createAccount(null, account);
+
+ Account accountChild1 = new AccountImpl();
+ accountChild1.setAccountNumber("50");
+ accountChild1.setLabel("Valeurs mobilières de placement");
+ //accountChild1.setMasterAccount(account);
+ result = instance.createAccount(account, accountChild1);
+
+ Account accountChild2 = new AccountImpl();
+ accountChild2.setAccountNumber("51");
+ accountChild2.setLabel("Banques établissements financiers et assimilés");
+ //accountChild2.setMasterAccount(account);
+ result = instance.createAccount(account, accountChild2);
+
+ Account accountChildChild1 = new AccountImpl();
+ accountChildChild1.setAccountNumber("511");
+ accountChildChild1.setLabel("Valeurs à l'encaissement");
+ //accountChildChild1.setMasterAccount(accountChild2);
+ result = instance.createAccount(accountChild2, accountChildChild1);
+
+ Account accountChildChild2 = new AccountImpl();
+ accountChildChild2.setAccountNumber("51");
+ accountChildChild2.setLabel("Banques");
+ //accountChildChild2.setMasterAccount(accountChild2);
+ result = instance.createAccount(accountChild2, accountChildChild2);
+
Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result);*/
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2011-08-05 12:09:49 UTC (rev 3250)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2011-08-08 09:12:40 UTC (rev 3251)
@@ -25,12 +25,16 @@
package org.chorem.lima.business;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ejb.EntryBookServiceImpl;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookImpl;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -54,16 +58,16 @@
*/
@AfterClass
public static void tearDownClass() throws Exception {
- /*List<JournalDTO> list = instance.getAllJournal();
+ List<EntryBook> list = instance.getAllEntryBooks();
// On supprime chaque journal
- for (JournalDTO journalDTO : list) {
- instance.removeJournal(journalDTO);
- }*/
+ for (EntryBook entryBook : list) {
+ instance.removeEntryBook(entryBook);
+ }
}
@Before
public void setUp() {
- //instance = new EntryBookServiceImpl();
+ instance = new EntryBookServiceImpl();
}
public EntryBookServiceImplTest() {
@@ -71,22 +75,26 @@
/**
* Permet de tester l'ajout d'un journal dans la base de données.
+ * @throws LimaException
*/
@Test
- public void createJournalTest() {
- /*String result = instance.createJournal("Journal des ventes", "jdv",
- "description");
- Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS, result);*/
+ public void createJournalTest() throws LimaException {
+ EntryBook entryBook = new EntryBookImpl();
+ entryBook.setLabel("Journal des ventes");
+ entryBook.setCode("jdv");
+ boolean result = instance.createEntryBook(entryBook);
+ Assert.assertTrue(result);
}
/**
* Permet de tester la recherche d'un journal suivant son préfixe.
+ * @throws LimaException
*/
@Test
- public void searchJournalWithLabelTest() {
- /*Journal result = instance.searchJournalWithLabel("Journal des ventes");
- Assert.assertEquals("Journal des ventes", result.getLabel());
- result = instance.searchJournalWithLabel("Journal des achats");
+ public void searchJournalWithLabelTest() throws LimaException {
+ List<EntryBook> result = instance.getAllEntryByProperty(EntryBook.LABEL, "Journal des ventes");
+ Assert.assertEquals("Journal des ventes", result.get(0).getLabel());
+ /*result = instance.searchJournalWithLabel("Journal des achats");
Assert.assertEquals("Journal des achats", result.getLabel());*/
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2011-08-05 12:09:49 UTC (rev 3250)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/GeneratorTest.java 2011-08-08 09:12:40 UTC (rev 3251)
@@ -32,8 +32,11 @@
import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
import org.chorem.lima.business.ejb.FinancialTransactionServiceImpl;
import org.chorem.lima.business.ejb.FiscalPeriodServiceImpl;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookImpl;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -46,48 +49,72 @@
private static final Log log = LogFactory.getLog(FinancialTransactionServiceImpl.class);
private static FinancialTransactionServiceImpl instanceTransaction;
- private static FiscalPeriodServiceImpl instancePeriod;
- private static FinancialPeriodServiceImpl instanceTimespan;
+ private static FiscalPeriodServiceImpl instanceFiscalPeriod;
+ private static FinancialPeriodServiceImpl instanceFinancialPeriod;
private static EntryBookServiceImpl instanceJournal;
private static AccountServiceImpl instanceAccount;
private static String topiaIDTransaction;
@Before
public void setUp() {
- /* instanceTransaction = new FinancialTransactionServiceImpl();
- instancePeriod = new FiscalPeriodServiceImpl();
- instanceTimespan = new FinancialPeriodServiceImpl();
+ instanceTransaction = new FinancialTransactionServiceImpl();
+ instanceFiscalPeriod = new FiscalPeriodServiceImpl();
+ instanceFinancialPeriod = new FinancialPeriodServiceImpl();
instanceJournal = new EntryBookServiceImpl();
- instanceAccount = new AccountServiceImpl();*/
+ instanceAccount = new AccountServiceImpl();
}
/**
* Permet de tester l'ajout d'un timspan
+ * @throws LimaException
*/
@Test
- public void generate ()
+ public void generate () throws LimaException
{
- /*
+
// Création Journal
- instanceJournal.createJournal("Journal des ventes", "jv","description");
- instanceJournal.createJournal("Journal des achats", "ja","description");
- instanceJournal.createJournal("Journal de trésorerie", "jt","description");
- instanceJournal.createJournal("Journal des opérations diverses", "OD","description");
- instanceJournal.createJournal("Journal de banque 1", "jb1","description");
- instanceJournal.createJournal("Journal de banque 2", "jb2","description");
+ EntryBook entryBook1 = new EntryBookImpl();
+ entryBook1.setLabel("Journal des ventes");
+ entryBook1.setCode("jv");
+ instanceJournal.createEntryBook(entryBook1);
+ EntryBook entryBook2 = new EntryBookImpl();
+ entryBook2.setLabel("Journal des achats");
+ entryBook2.setCode("ja");
+ instanceJournal.createEntryBook(entryBook2);
+ EntryBook entryBook3 = new EntryBookImpl();
+ entryBook3.setLabel("Journal de trésorerie");
+ entryBook3.setCode("jt");
+ instanceJournal.createEntryBook(entryBook3);
+ EntryBook entryBook4 = new EntryBookImpl();
+ entryBook4.setLabel("Journal des opérations diverses");
+ entryBook4.setCode("od");
+ instanceJournal.createEntryBook(entryBook4);
+ EntryBook entryBook5 = new EntryBookImpl();
+ entryBook5.setLabel("Journal de banque");
+ entryBook5.setCode("jb");
+ /*instanceJournal.createJournal("Journal de banque 2", "jb2","description");
instanceJournal.createJournal("Journal de banque 3", "jb3","description");
instanceJournal.createJournal("Journal de banque 4", "jb4","description");
instanceJournal.createJournal("Journal de banque 5", "jb5","description");
instanceJournal.createJournal("Journal de banque 6", "jb6","description");
instanceJournal.createJournal("Journal de banque 7", "jb7","description");
- instanceJournal.createJournal("Journal de banque 8", "jb8","description");
+ instanceJournal.createJournal("Journal de banque 8", "jb8","description");*/
// Création account
- instanceAccount.createAccount(1, "COMPTES DE CAPITAUX", null);
- instanceAccount.createAccount(2, "COMPTES D'IMMOBILISATIONS", null);
- instanceAccount.createAccount(3, "COMPTES DE STOCKS ET EN-COURS ", null);
- instanceAccount.createAccount(4, "COMPTES DE TIERS ", null);
+ Account account1 = new AccountImpl();
+ account1.setAccountNumber("1");
+ account1.setLabel("COMPTES DE CAPITAUX");
+ instanceAccount.createAccount(null, account1);
+ Account account2 = new AccountImpl();
+ account2.setAccountNumber("2");
+ account2.setLabel("COMPTES D'IMMOBILISATIONS");
+ instanceAccount.createAccount(null, account2);
+ Account account3 = new AccountImpl();
+ account3.setAccountNumber("3");
+ account3.setLabel("COMPTES DE STOCKS ET EN-COURS");
+ instanceAccount.createAccount(null, account3);
+ /*instanceAccount.createAccount(4, "COMPTES DE TIERS ", null);
instanceAccount.createAccount(5, "COMPTES FINANCIERS", null);
instanceAccount.createAccount(6, "COMPTES DE CHARGES", null);
instanceAccount.createAccount(7, "COMPTES DE PRODUITS", null);
@@ -108,28 +135,25 @@
instanceAccount.createAccount(20, "Immobilisations incorporelles", 2);
instanceAccount.createAccount(201, "Frais d'établissement", 20);
instanceAccount.createAccount(207, "Fonds commercial", 20);
- instanceAccount.createAccount(21, "Immobilisations corporelles", 2);
+ instanceAccount.createAccount(21, "Immobilisations corporelles", 2);*/
-
-
-
- Date beginTimeSpan;
- Date endTimeSpan;
+ /*Date beginDate;
+ Date endDate;
Date dateSearch;
- for (int annee = 109 ; annee < 115 ; annee++)
- {
- beginTimeSpan = new Date(annee,0,1);
- endTimeSpan = new Date(annee,11,31);
- instancePeriod.createPeriod(beginTimeSpan, endTimeSpan, false);
+ for (int annee = 109 ; annee < 115 ; annee++) {
+ beginDate = new Date(annee,0,1);
+ endDate = new Date(annee,11,31);
+ FiscalPeriod fiscalPeriod = new FiscalPeriodImpl();
+ fiscalPeriod.setBeginDate(beginDate);
+ fiscalPeriod.setEndDate(endDate);
+ instanceFiscalPeriod.createFiscalPeriod(fiscalPeriod);
- for (int mois = 0 ; mois<11 ; mois++)
- {
+ for (int mois = 0 ; mois<11 ; mois++) {
dateSearch = new Date(annee,mois,1);
- TimeSpan timespan = instanceTimespan.searchTimeSpanByDate(dateSearch);
+ TimeSpan timespan = instanceFiscalPeriod.searchTimeSpanByDate(dateSearch);
- for (int j=0 ; j<50 ; j++)
- {
+ for (int j=0 ; j<50 ; j++) {
Journal journal = instanceJournal.searchJournalWithLabel("Journal des ventes");
topiaIDTransaction = instanceTransaction.createTransaction(dateSearch, "Facture 6", "description transaction", timespan, journal);
@@ -145,8 +169,7 @@
Period period = instancePeriod.searchPeriodWithDate(beginTimeSpan);
instancePeriod.blockAllTimeSpanOfPeriod(period);
instancePeriod.blockPeriod(period);
- }
- */
+ }*/
}
1
0
r3250 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/resources/i18n lima-swing/src/main/java/org/chorem/lima/ui/importexport lima-swing/src/main/java/org/chorem/lima/ui/vatreports lima-swing/src/main/resources/i18n
by vsalaun@users.chorem.org 05 Aug '11
by vsalaun@users.chorem.org 05 Aug '11
05 Aug '11
Author: vsalaun
Date: 2011-08-05 14:09:49 +0200 (Fri, 05 Aug 2011)
New Revision: 3250
Url: http://chorem.org/repositories/revision/lima/3250
Log:
#347 add i18n text + option setting for vat pdf path
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2011-08-05 12:09:49 UTC (rev 3250)
@@ -129,6 +129,16 @@
setOption(Option.SCALE.key, locale);
saveForUser();
}
+
+ public String getVatPDFUrl() {
+ String vatPDFUrl = getOption(Option.VAT_PDF_URL.getKey());
+ return vatPDFUrl;
+ }
+
+ public void setVatPDFUrl(String url) {
+ setOption(Option.VAT_PDF_URL.key, url);
+ saveForUser();
+ }
/**
* Load configuration with custom file name.
@@ -161,7 +171,8 @@
REPORTS_DIR("lima.report.dir", _("lima.config.reportsdir"), "", String.class, false, false),
HTTP_PORT("lima.httpport", _("lima.config.httpport"), "5462", String.class, false, false),
SERVER_ADRESS("lima.serveraddress", _("lima.config.serveraddress"), "", String.class, false, false),
- SCALE("lima.scale", _("lima.config.scale"), "2", String.class, false, false);
+ SCALE("lima.scale", _("lima.config.scale"), "2", String.class, false, false),
+ VAT_PDF_URL("lima.report.vatpdfurl", _("lima.config.reportvatpdfurl"), "default", String.class, false, false);
private final String key;
private final String description;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2011-08-05 12:09:49 UTC (rev 3250)
@@ -29,6 +29,7 @@
import java.awt.Color;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -155,7 +156,7 @@
log.error("Can't init topia context", ex);
}
}
- path = LimaConfig.getInstance().getReportsDir();
+ path = LimaConfig.getInstance().getReportsDir();
}
@@ -1463,13 +1464,35 @@
TopiaContext transaction = null;
- String filePath =
- path+File.separator+DocumentsEnum.VAT.getFileName()+format.getExtension();
+ String filePath = path + File.separator
+ + DocumentsEnum.VAT.getFileName() + format.getExtension();
+ String path = LimaConfig.getInstance().getReportsDir();
+
+ String filePathDefault = path + File.separator
+ + DocumentsEnum.VAT.getFileName() + "_default.pdf";
+
PDDocument doc = null;
- InputStream reportsStream =
- DocumentServiceImpl.class.getResourceAsStream("/reports/vat_form_fr.pdf");
+ InputStream reportsStream = null;
+ String vatPDFUrl = LimaConfig.getInstance().getVatPDFUrl();
+
+ if (vatPDFUrl.equals("default")) {
+ reportsStream = DocumentServiceImpl.class
+ .getResourceAsStream("/reports/vat_form_fr.pdf");
+ if (reportsStream == null) {
+ throw new LimaException ("Could not find such file "
+ + "/reports/vat_form_fr.pdf");
+ }
+ } else {
+ try {
+ reportsStream = new FileInputStream(filePathDefault);
+ } catch (FileNotFoundException eee) {
+ throw new LimaException("Could not find such file "
+ + filePathDefault, eee);
+ }
+ }
+
try {
transaction = beginTransaction();
@@ -1480,88 +1503,8 @@
if (autocomplete.equals("true")) {
SetField fields = new SetField();
-
- Identity identity = identityService.getIdentity();
-
- //page one
-
- //sets names for each TextField
- String periodTextField = "a1.a1",
- serviceAddressTextField = "a2.a2",
- companyAlternativeAddressTextField = "a3.a3",
- companyAddressTextField = "a4.a4",
- a5TextField = "a5.a5", //field doesn't exist
- SIETextField = "a6.a6",
- fileNumberTextField = "a6.a6",
- keyTextField = "a8.a8",
- PeriodTextField = "a9.a9",
- CDITextField = "a10.a10",
- serviceCodeTextField = "a11.a11",
- regimeTextField = "a12.12",
- VATNumberTextField = "a13.a13",
- phoneNumberTextField = "a14.a14",
- transfertAmount = "a15.a15",
- answerSpace = "a16.a16",
- finalDateTextField = "date1.date1", // dd/mm/yyyy
- payementDateTextField = "date2.date2"; // dd/mm/yyyy;
-
- //fills in Period TextField
- Calendar beginDateCal = Calendar.getInstance();
- beginDateCal.setTime(beginDate);
-
- Calendar endDateCal = Calendar.getInstance();
- endDateCal.setTime(endDate);
-
- Locale locale = new Locale("fr","FR","");
-
- fields.setField(doc, periodTextField,
- beginDateCal.get(Calendar.DAY_OF_WEEK) + " "
- + beginDateCal.getDisplayName(Calendar.MONTH, Calendar.LONG, locale)
- + " " + beginDateCal.get(Calendar.YEAR) + " - "
- + endDateCal.get(Calendar.DAY_OF_WEEK) + " "
- + endDateCal.getDisplayName(Calendar.MONTH, Calendar.LONG, locale)
- + " " + endDateCal.get(Calendar.YEAR));
-
- //fills in address TextField
- String address = "";
- if (identity.getName() != null) {
- address = identity.getName() + "\n";
- }
- if (identity.getAddress() != null) {
- address += identity.getAddress() + "\n";
- }
- if (identity.getAddress2() != null) {
- address += identity.getAddress2() + "\n";
- }
- if (identity.getZipCode() != null) {
- address += identity.getZipCode() + " ";
- }
- if (identity.getCity() != null) {
- address += identity.getCity();
- }
- fields.setField(doc, companyAddressTextField, address);
-
-
- //fills in SIRET TextField
- if (identity.getVatNumber() != null) {
- String VATNumber = "";
- for (int i=0; i<identity.getVatNumber().length(); i++) {
- //add spaces to suit cells width
- VATNumber += identity.getVatNumber().substring(i, i+1) + " ";
- }
- fields.setField(doc, VATNumberTextField, VATNumber);
- }
-
-
- //fills in phone number TextField
- if (identity.getPhoneNumber() != null) {
- fields.setField(doc, phoneNumberTextField, identity.getPhoneNumber());
- }
-
-
- //end of page one
- //page two
-
+
+ //search for all VAT Statements from the report
List<VatStatement> vatStatementsList = vatStatementService.getAllVatStatements();
for (VatStatement vatStatement: vatStatementsList) {
//search for amount to display
@@ -1572,8 +1515,6 @@
}
}
- //end of page two
-
}
// save the updated document to the new file and close
doc.save(filePath);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2011-08-05 12:09:49 UTC (rev 3250)
@@ -636,30 +636,30 @@
return result.toString();
}
- /**
- * Remote method to call entity import from UI
- * This method let import just on type of entity
- * @throws IOException
- * @throws COSVisitorException
- */
@Override
- public String importAsPDF(String datas, ImportExportEntityEnum importExportEntityEnum, boolean saveMode) throws LimaException {
+ public String importAsPDF(String datas, ImportExportEntityEnum importExportEntityEnum, boolean setMode) throws LimaException {
StringBuffer result = new StringBuffer();
try {
String path = LimaConfig.getInstance().getReportsDir();
- String filePath =
- path+File.separator + DocumentsEnum.VAT.getFileName() + "_structure.pdf";
+ String filePathDefault = path + File.separator
+ + DocumentsEnum.VAT.getFileName() + "_default.pdf";
+ String filePathStructured = path + File.separator
+ + DocumentsEnum.VAT.getFileName() + "_structure.pdf";
PDDocument doc = null;
InputStream reportsStream = new FileInputStream(datas);
//DocumentServiceImpl.class.getResourceAsStream("/reports/vat_form_fr.pdf");
- //DocumentServiceImpl.class.getResourceAsStream("~"+datas);
// load the document
doc = PDDocument.load(reportsStream);
+ //save default vat document with empty boxes
+ if (setMode) {
+ doc.save(filePathDefault);
+ }
+
//search for all PDFBox
List<PDField> FieldList = doc.getDocumentCatalog().getAcroForm().getFields();
@@ -668,9 +668,12 @@
pdField.setValue(pdField.getFullyQualifiedName());
}
- // save the updated document to the new file and close
- if (saveMode) {
- doc.save(filePath);
+ // save the structured document
+ doc.save(filePathStructured);
+
+ //sets the new pdf url to be used as pdf document edited for reports
+ if (setMode) {
+ LimaConfig.getInstance().setVatPDFUrl(datas);
}
doc.close();
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2011-08-05 12:09:49 UTC (rev 3250)
@@ -33,10 +33,13 @@
@Stateless
public class OptionsServiceImpl extends AbstractLimaService implements OptionsService, OptionsServiceLocal {
- protected String scale;
+ protected String scale;
+
+ protected String vatPDFUrl;
public OptionsServiceImpl() {
- scale = LimaConfig.getInstance().getScale();
+ scale = LimaConfig.getInstance().getScale();
+ vatPDFUrl = LimaConfig.getInstance().getVatPDFUrl();
}
public int getScale() {
@@ -49,6 +52,14 @@
public void setScale(String scale) {
LimaConfig.getInstance().setScale(scale);
+ }
+
+ public String getVatPDFUrl() {
+ return vatPDFUrl;
+ }
+
+ public void setVatPDFUrl(String url) {
+ LimaConfig.getInstance().setVatPDFUrl(url);
}
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/VatStatementServiceImpl.java 2011-08-05 12:09:49 UTC (rev 3250)
@@ -442,7 +442,6 @@
vatStatementAmounts(subVatStatement,
selectedBeginDate, selectedEndDate, topiaContext);
vatStatementAmounts.setLabel(subVatStatement.getLabel());
- vatStatementAmounts.setAmount(subVatStatement.getAmount());
if (!subVatStatement.getHeader()){
//on calcul
amount =
@@ -465,7 +464,6 @@
new VatStatementAmountsImpl();
header.setLabel(headerVatStatementAmounts.getLabel());
header.setLevel(headerVatStatementAmounts.getLevel());
- header.setAmount(headerVatStatementAmounts.getAmount());
header.setHeader(true);
//ajoute header
subResult.add(header);
@@ -482,8 +480,6 @@
subResult.add(headerVatStatementAmounts);
}
else {
- headerVatStatementAmounts.
- setAmount(new BigDecimal(0));
subResult.add(headerVatStatementAmounts);
}
//ajoute liste
@@ -500,7 +496,6 @@
vatStatementAmounts.setLabel(vatStatement.getLabel());
vatStatementAmounts.setHeader(vatStatement.getHeader());
vatStatementAmounts.setLevel(vatStatement.getLevel());
- vatStatementAmounts.setAmount(vatStatement.getAmount());
}
result.setVatStatementAmounts(vatStatementAmounts);
result.setListResult(subResult);
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2011-08-05 12:09:49 UTC (rev 3250)
@@ -96,7 +96,9 @@
lima-business.import.vatstatementalreadyexist=FAILED \: The vatStatement %s already exists \!\n
lima.config.configFileName.description=
lima.config.httpport=HTTP Port
+lima.config.i18ndir=i18n directories
lima.config.reportsdir=Reports directories
+lima.config.reportvatpdfurl=
lima.config.rulesnationality=Rules Nationality
lima.config.scale=Scale
lima.config.serveraddress=Server Address
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2011-08-05 12:09:49 UTC (rev 3250)
@@ -96,7 +96,9 @@
lima-business.import.vatstatementalreadyexist=u00C9chec \: Le plan %s exist déjà \!\n
lima.config.configFileName.description=
lima.config.httpport=Port HTTP
+lima.config.i18ndir=Dossier des i18n
lima.config.reportsdir=Dossier des rapports
+lima.config.reportvatpdfurl=Chemin du raport
lima.config.rulesnationality=Règles nationales
lima.config.scale=Précision
lima.config.serveraddress=Addresse serveur
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2011-08-05 12:09:49 UTC (rev 3250)
@@ -204,11 +204,20 @@
}
else {
if (importMode){
- JOptionPane.showMessageDialog(
+ //special message when importing a VAT PDF
+ if (importExportMethodeF.equals(ImportExportEnum.PDF_VAT_IMPORT)) {
+ JOptionPane.showMessageDialog(
waitView,
+ _("lima.importexport.import.vatpdfimport"),
+ _("lima.importexport.import"),
+ JOptionPane.INFORMATION_MESSAGE);
+ } else {
+ JOptionPane.showMessageDialog(
+ waitView,
_("lima.importexport.import.terminated"),
_("lima.importexport.import"),
JOptionPane.INFORMATION_MESSAGE);
+ }
}
else {
JOptionPane.showMessageDialog(
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2011-08-05 12:09:49 UTC (rev 3250)
@@ -242,7 +242,7 @@
@Override
public void notifyMethod(String serviceName, String methodeName) {
//automatic refresh when FinancialTransaction, VatStatement chart or import for VAT services have been used by the user
- if (serviceName.contains("FinancialTransaction") || methodeName.contains("VatStatement") || methodeName.contains("importAll")) {
+ if (serviceName.contains("FinancialTransaction") || methodeName.contains("VatStatement") || methodeName.contains("import") ) {
refresh();
}
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2011-08-05 12:09:49 UTC (rev 3250)
@@ -92,7 +92,9 @@
lima.config.currency.description=
lima.config.decimalseparator.description=
lima.config.host.adress=Host adress
+lima.config.i18ndir=Directory used for i18n files
lima.config.locale.description=Localization used by LIMA
+lima.config.resourcesdir=Directory used for Lima resources
lima.config.scale.description=
lima.config.ui.flaunchui.description=
lima.config.ui.fullscreen.description=FullScreen
@@ -199,6 +201,7 @@
lima.importexport.financialstatements=FinancialStatements chart
lima.importexport.import=Import
lima.importexport.import.terminated=Import terminated
+lima.importexport.import.vatpdfimport=The PDF has been imported. It can be found inside the Lima resources directory
lima.importexport.importcsv=Import CSV
lima.importexport.importebp=Import EBP
lima.importexport.usevatpdf=Would you like to use this PDF when editing the VAT document ?
@@ -233,7 +236,6 @@
lima.reports.financialstatement=Financialstatements
lima.reports.ledger=Ledger
lima.reports.vat=Edit VAT
-lima.reports.vatstatement=
lima.response.no=No
lima.response.yes=Yes
lima.splash.1=Loading services...
@@ -283,14 +285,10 @@
lima.vatreport.listerror=Can't get entries list
lima.vatstatement.accounts=List of accounts
lima.vatstatement.boxname=PDF BoxName
-lima.vatstatement.check=
lima.vatstatement.delete=Delete actual VAT statement chart before import new
-lima.vatstatement.header=
lima.vatstatement.label=Label
-lima.vatstatement.masteramount=
lima.vatstatement.mastervatstatement=
lima.vatstatement.movement.add=Add movement
-lima.vatstatement.subamount=
lima.warning.nimbus.landf=Could not find Numbus Look&Feel
limma.config.thousandseparator.description=
nuitonutil.error.applicationconfig.save=
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2011-08-04 11:45:18 UTC (rev 3249)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2011-08-05 12:09:49 UTC (rev 3250)
@@ -92,7 +92,9 @@
lima.config.currency.description=
lima.config.decimalseparator.description=
lima.config.host.adress=Adresse du serveur distant
+lima.config.i18ndir=Répertoire utilisée pour stocker les fichiers i18n
lima.config.locale.description=Locale utilisée par l'application
+lima.config.resourcesdir=Répertoire utilisée pour stocker les ressources
lima.config.scale.description=
lima.config.ui.flaunchui.description=
lima.config.ui.fullscreen.description=Plein écran
@@ -199,6 +201,7 @@
lima.importexport.financialstatements=Plan BCR
lima.importexport.import=Import
lima.importexport.import.terminated=Import terminé
+lima.importexport.import.vatpdfimport=Le PDF a bien été importé dans le répertoire des ressources de Lima
lima.importexport.importcsv=Import CSV
lima.importexport.importebp=Import EBP
lima.importexport.usevatpdf=Voulez-vous utilser ce PDF pour la déclaration de TVA ?
@@ -282,14 +285,11 @@
lima.vatreport.listerror=Erreur lors de la récupération des données de la liste
lima.vatstatement.accounts=Liste des comptes
lima.vatstatement.boxname=PDF BoxName
-lima.vatstatement.check=
lima.vatstatement.delete=Supprimer le plan TVA actuel avant d'importer
lima.vatstatement.header=
lima.vatstatement.label=Libellé
-lima.vatstatement.masteramount=
lima.vatstatement.mastervatstatement=
lima.vatstatement.movement.add=Ajouter un regrouprement
-lima.vatstatement.subamount=
lima.warning.nimbus.landf=Le look and feel nymbus n'a pas été trouvé
limma.config.thousandseparator.description=
nuitonutil.error.applicationconfig.save=
1
0
04 Aug '11
Author: tchemit
Date: 2011-08-04 13:45:18 +0200 (Thu, 04 Aug 2011)
New Revision: 3249
Url: http://chorem.org/repositories/revision/lima/3249
Log:
Evolution #422: Updates to i18n 2.4.1
Evolution #421: Add i18n file in directory in zip release file and add this directory un classpath
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
trunk/pom.xml
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2011-08-04 11:09:14 UTC (rev 3248)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2011-08-04 11:45:18 UTC (rev 3249)
@@ -116,7 +116,7 @@
}
try {
//create directory to store i18n files
- FileUtil.createDirectoryIfNecessary(i18nDirectory.getParentFile());
+ FileUtil.createDirectoryIfNecessary(i18nDirectory);
} catch (IOException eee) {
throw new RuntimeException(
"Could not create directory " +
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-04 11:09:14 UTC (rev 3248)
+++ trunk/pom.xml 2011-08-04 11:45:18 UTC (rev 3249)
@@ -315,7 +315,7 @@
<eugenePluginVersion>2.3.5</eugenePluginVersion>
<topiaVersion>2.5.4</topiaVersion>
<jaxxVersion>2.4.2</jaxxVersion>
- <nuitonI18nVersion>2.4</nuitonI18nVersion>
+ <nuitonI18nVersion>2.4.1-SNAPSHOT</nuitonI18nVersion>
<openEjbVersion>3.1.4</openEjbVersion>
<slf4jVersion>1.6.1</slf4jVersion>
<!--axis.version>1.4.1</axis.version-->
1
0