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
July 2011
- 3 participants
- 46 discussions
Author: vsalaun
Date: 2011-07-04 18:06:24 +0200 (Mon, 04 Jul 2011)
New Revision: 3197
Url: http://chorem.org/repositories/revision/lima/3197
Log:
update packages and jaxx files
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-07-01 14:31:21 UTC (rev 3196)
+++ trunk/pom.xml 2011-07-04 16:06:24 UTC (rev 3197)
@@ -83,7 +83,7 @@
<dependency>
<groupId>org.nuiton.topia</groupId>
<artifactId>topia-service-migration</artifactId>
- <version>2.5.3</version>
+ <version>${topiaVersion}</version>
<scope>compile</scope>
</dependency>
@@ -146,8 +146,8 @@
<!-- autres libraires -->
<dependency>
<groupId>org.swinglabs</groupId>
- <artifactId>swingx</artifactId>
- <version>1.6.1</version>
+ <artifactId>swingx-core</artifactId>
+ <version>1.6.2-2</version>
<scope>compile</scope>
</dependency>
@@ -290,11 +290,11 @@
<projectId>lima</projectId>
<!-- customized libs version -->
- <nuitonUtilsVersion>2.1.2</nuitonUtilsVersion>
- <eugenePluginVersion>2.3.3</eugenePluginVersion>
- <topiaVersion>2.5.3</topiaVersion>
- <jaxxVersion>2.3</jaxxVersion>
- <nuitonI18nVersion>2.3.2</nuitonI18nVersion>
+ <nuitonUtilsVersion>2.2</nuitonUtilsVersion>
+ <eugenePluginVersion>2.3.5</eugenePluginVersion>
+ <topiaVersion>2.5.4</topiaVersion>
+ <jaxxVersion>2.4.2</jaxxVersion>
+ <nuitonI18nVersion>2.4</nuitonI18nVersion>
<openEjbVersion>3.1.4</openEjbVersion>
<slf4jVersion>1.6.1</slf4jVersion>
<!--axis.version>1.4.1</axis.version-->
@@ -321,7 +321,7 @@
<!-- plugin i18n -->
<plugin>
<groupId>org.nuiton.i18n</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
+ <artifactId>nuiton-i18n</artifactId>
<version>${nuitonI18nVersion}</version>
</plugin>
1
0
r3196 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/balance lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod lima-swing/src/main/resources/i18n
by vsalaun@users.chorem.org 01 Jul '11
by vsalaun@users.chorem.org 01 Jul '11
01 Jul '11
Author: vsalaun
Date: 2011-07-01 16:31:21 +0200 (Fri, 01 Jul 2011)
New Revision: 3196
Url: http://chorem.org/repositories/revision/lima/3196
Log:
block document edition when the fiscal isn't closed
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsDateForm.jaxx
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2011-07-01 14:03:16 UTC (rev 3195)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2011-07-01 14:31:21 UTC (rev 3196)
@@ -441,7 +441,6 @@
//holds entries of all closing transactions
FinancialTransaction endfinancialTransaction = new FinancialTransactionImpl();
if (lastFPeriod != null) {
- System.out.println("not null");
//Sets the endfinancialTransaction
endfinancialTransaction.setAmountDebit(BigDecimal.ZERO);
endfinancialTransaction.setAmountCredit(BigDecimal.ZERO);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2011-07-01 14:03:16 UTC (rev 3195)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2011-07-01 14:31:21 UTC (rev 3196)
@@ -32,12 +32,18 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
+import org.chorem.lima.business.FiscalPeriodServiceMonitorable;
import org.chorem.lima.business.HttpServerServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
import org.chorem.lima.business.LimaException;
@@ -45,6 +51,7 @@
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.FormatsEnum;
+import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.util.ErrorHelper;
@@ -63,6 +70,7 @@
/** Services. */
protected ReportServiceMonitorable reportService;
protected HttpServerServiceMonitorable httpServerServiceMonitorable;
+ protected FiscalPeriodServiceMonitorable fiscalPeriodService;
/** DatePicker Begin Date. */
protected Date selectedBeginDate;
@@ -90,10 +98,14 @@
ReportServiceMonitorable.class);
port = LimaServiceFactory.getInstance().getService(
HttpServerServiceMonitorable.class).getHttpPort();
+ fiscalPeriodService =
+ LimaServiceFactory.getInstance().getService(
+ FiscalPeriodServiceMonitorable.class);
LimaServiceFactory.getInstance().getService(
ImportServiceMonitorable.class).addListener(this);
LimaServiceFactory.getInstance().getService(
FinancialTransactionServiceMonitorable.class).addListener(this);
+
}
public void setBeginDate(Date date){
@@ -172,21 +184,55 @@
public void createDocument() {
if (selectedBeginDate != null & selectedEndDate != null){
- FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
- String address = LimaConfig.getInstance().getHostAdress();
+ //looks for all blocked fiscal periods
+ List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>();
try {
- String url = "http://"+address+":"+port+"/?beginDate="
- +dateFormat.format(selectedBeginDate)
- +"&endDate="+dateFormat.format(selectedEndDate)+"&format="
- +selectedEnum.getExtension()+"&model="
- + DocumentsEnum.BALANCE.getFileName();
- Desktop.getDesktop().browse(new URI(url));
- } catch (IOException e) {
- log.error("Can't open browser", e);
- } catch (URISyntaxException e) {
- log.error("Can't create news URI", e);
+ blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
+ }catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Enable to create document ", eee);
+ }
+ ErrorHelper.showErrorDialog("Enable to create document ", eee);
}
+
+ //tells if the fiscaPeriod as been found and is blocked
+ boolean error = true;
+
+ for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
+ if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
+ && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ && blockedFiscalPeriod.getLocked()) {
+ error = false;
+ }
+ }
+
+ //shows error message to user if the fiscalPeriod is unblocked
+ if (error) {
+ JOptionPane.showMessageDialog(
+ view,
+ "Can't create document on an open fiscal year",
+ _("lima.common.error"),
+ JOptionPane.ERROR_MESSAGE);
+ } else {
+
+ FormatsEnum selectedEnum =
+ (FormatsEnum) view.getDocumentEditor().getSelectedItem();
+ String address = LimaConfig.getInstance().getHostAdress();
+
+ try {
+ String url = "http://"+address+":"+port+"/?beginDate="
+ +dateFormat.format(selectedBeginDate)
+ +"&endDate="+dateFormat.format(selectedEndDate)+"&format="
+ +selectedEnum.getExtension()+"&model="
+ + DocumentsEnum.BALANCE.getFileName();
+ Desktop.getDesktop().browse(new URI(url));
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create news URI", e);
+ }
+ }
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-07-01 14:03:16 UTC (rev 3195)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-07-01 14:31:21 UTC (rev 3196)
@@ -118,7 +118,6 @@
int selectedRow = fiscalPeriodeTable.getSelectedRow();
FiscalPeriodTableModel model =
(FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel();
- System.out.println(fiscalPeriodeTable.getRowCount() + " " + selectedRow);
// blocked it
try {
FiscalPeriod selectedFiscalPeriod =
@@ -149,7 +148,7 @@
}
}
addRetainedEarnings(selectedFiscalPeriod, newyear);
- //model.blockFiscalPeriod(selectedFiscalPeriod);
+ model.blockFiscalPeriod(selectedFiscalPeriod);
}
} catch (LimaException eee) {
if (log.isErrorEnabled()) {
@@ -179,9 +178,6 @@
// null == cancel action
EntryBook entryBook = entryBookForm.getEntryBook();
if (entryBook != null) {
- System.out.println(selectedFiscalPeriod);
- System.out.println(newyear);
- System.out.println(entryBook);
fiscalPeriodService.addRetainedEarnings(selectedFiscalPeriod, newyear, entryBook);
}
} catch (LimaException eee) {
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsDateForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsDateForm.jaxx 2011-07-01 14:03:16 UTC (rev 3195)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsDateForm.jaxx 2011-07-01 14:31:21 UTC (rev 3196)
@@ -1,47 +0,0 @@
-<JDialog modal="true"
- defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}"
- onWindowClosing="performCancel();">
-
- <script>
- <![CDATA[
-
- getRootPane().setDefaultButton(okButton);
-
- import org.apache.commons.lang.time.DateUtils;
-
- // set begin date picker
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.DATE);
- getBeginDatePicker().setDate(beginDate);
-
- /**
- * Sets null to Date and closes JDialog
- */
- protected void performCancel() {
- getBeginDatePicker().setDate(null);
- dispose();
- }
- ]]>
- </script>
-
- <Table>
- <row>
- <cell anchor="center">
- <JLabel text="lima.table.date"/>
- </cell>
- <cell anchor="west">
- <org.jdesktop.swingx.JXDatePicker id="beginDatePicker"/>
- </cell>
- </row>
- <row>
- <cell anchor="center">
- <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/>
- </cell>
- <cell anchor="center">
- <JButton id="okButton" text="lima.common.ok" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JDialog>
\ No newline at end of file
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-07-01 14:03:16 UTC (rev 3195)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2011-07-01 14:31:21 UTC (rev 3196)
@@ -32,6 +32,7 @@
lima.charts.fiscalperiod.create=Choisissez la date de d\u00E9but et de fin du nouvel exercice
lima.charts.fiscalperiod.question.blocked=\u00C8tes vous s\u00FBre de vouloir cl\u00F4turer cette exercice ? Cette action est irr\u00E9versible \!
lima.charts.fiscalperiod.question.morethan12=La p\u00E9riode s\u00E9lectionn\u00E9e n'est pas de 12 mois, voulez-vous continuer ?
+lima.charts.fiscalperiod.question.newyear=Voulez vous cr\u00E9er un nouvel exercice?
lima.charts.fiscalyear=Exercices
lima.common.account=Compte
lima.common.amount=Montant
@@ -82,6 +83,7 @@
lima.config.ui.fullscreen.description=Plein \u00E9cran
lima.daily=Quotidien
lima.documents=Documents\u2026
+lima.documents.error=Impossible de cr\u00E9er un document lorsque l'exercice est ouvert
lima.entries=Traitement
lima.entries.addEntry=Ajouter entr\u00E9e
lima.entries.addTransaction=Ajouter transaction
@@ -213,6 +215,8 @@
lima.tab.home=Accueil
lima.table.account=Compte
lima.table.balance=Balance
+lima.table.begin.credit=Reprise cr\u00E8dit
+lima.table.begin.debit=Reprise d\u00E9bit
lima.table.closure=Cloture
lima.table.code=Code
lima.table.collectedvat=TVA collect\u00E9e
@@ -250,3 +254,4 @@
lima.tooltip.lettering=<html>Pour ajouter une lettre \u00E0 plusieurs \u00E9critures <br/>S\u00E9lectionner plusieurs lignes avec la combinaison ctrl + click</html>
lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9
limma.config.thousandseparator.description=
+nuitonutil.error.applicationconfig.save=
1
0
r3195 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejbinterface lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod lima-swing/src/main/resources/i18n
by vsalaun@users.chorem.org 01 Jul '11
by vsalaun@users.chorem.org 01 Jul '11
01 Jul '11
Author: vsalaun
Date: 2011-07-01 16:03:16 +0200 (Fri, 01 Jul 2011)
New Revision: 3195
Url: http://chorem.org/repositories/revision/lima/3195
Log:
#345 changing and refactoring retained earnings service and swing (report a nouveau)
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FiscalPeriodService.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2011-07-01 13:58:36 UTC (rev 3194)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2011-07-01 14:03:16 UTC (rev 3195)
@@ -25,22 +25,44 @@
package org.chorem.lima.business.ejb;
+import static org.nuiton.i18n.I18n._;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ejbinterface.AccountService;
+import org.chorem.lima.business.ejbinterface.EntryBookService;
import org.chorem.lima.business.ejbinterface.FinancialPeriodServiceLocal;
+import org.chorem.lima.business.ejbinterface.FinancialTransactionServiceLocal;
import org.chorem.lima.business.ejbinterface.FiscalPeriodService;
import org.chorem.lima.business.ejbinterface.FiscalPeriodServiceLocal;
+import org.chorem.lima.business.ejbinterface.ReportService;
+import org.chorem.lima.business.utils.FinancialPeriodComparator;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -67,7 +89,19 @@
protected AccountingRules accountingRules;
@EJB
- private FinancialPeriodServiceLocal financialPeriodService;
+ protected AccountService accountService;
+
+ @EJB
+ protected FinancialPeriodServiceLocal financialPeriodService;
+
+ @EJB
+ protected EntryBookService entryBookService;
+
+ @EJB
+ protected ReportService reportService;
+
+ @EJB
+ protected FinancialTransactionServiceLocal financialTransactionService;
public FiscalPeriodServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -285,7 +319,221 @@
}
}
+ @Override
+ public void addRetainedEarnings(FiscalPeriod fiscalPeriod, boolean newyear,
+ EntryBook entryBook) throws LimaException {
+
+ TopiaContext topiaContext = null;
+ try {
+
+ //sets dates
+ // - endRetainedEarnings: last day of the closing year
+ // - beginRetainedEarnings: first open day of the following year
+ Date endRetainedEarnings = fiscalPeriod.getBeginDate();
+ Date beginRetainedEarnings = null;
+
+ topiaContext = beginTransaction();
+
+ //Sets entryBook
+ //search for the entryBook to use using param
+ boolean found = false;
+ List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks();
+ for (EntryBook entry : entryBooksList) {
+ if (!found && entry.getCode().equals(entryBook.getCode())
+ && entry.getLabel().equals(entryBook.getLabel())) {
+ entryBook = entry;
+ found = true;
+ }
+ }
+ //if entrybook isn't found
+ //then create it
+ if (!found) {
+ entryBookService.createEntryBook(entryBook);
+ entryBooksList = entryBookService.getAllEntryBooks();
+ for (EntryBook entry : entryBooksList) {
+ if (!found && entry.getCode().equals(entryBook.getCode())
+ && entry.getLabel().equals(entryBook.getLabel())) {
+ entryBook = entry;
+ found = true;
+ }
+ }
+ }
+
+ //Sets accounts, check if they exist, if not create them
+ //-> 8 COMPTES SPECIAUX
+ // -> 89 BILAN
+ // -> 890 Bilan d'ouverture
+ // -> 891 Bilan de cloture
+
+ //89 BILAN
+ Account accountMaster = accountService.getAccountByNumber("89");
+ if (accountMaster == null) {
+ Account accountSuperMaster = accountService.getAccountByNumber("8");
+ accountMaster.setAccountNumber("89");
+ accountMaster.setLabel("BILAN");
+ accountService.createAccount(accountSuperMaster, accountMaster);
+ accountMaster = accountService.getAccountByNumber("89");
+ }
+
+ //890 Bilan d'ouverture
+ Account beginRetainedAccount = accountService.getAccountByNumber("890");
+ if (beginRetainedAccount == null) {
+ beginRetainedAccount = new AccountImpl();
+ beginRetainedAccount.setAccountNumber("890");
+ beginRetainedAccount.setLabel("Bilan d'ouverture");
+ accountService.createAccount(accountMaster, beginRetainedAccount);
+ beginRetainedAccount = accountService.getAccountByNumber("890");
+ }
+
+ //891 Bilan de cloture
+ Account endRetainedAccount = accountService.getAccountByNumber("891");
+ if (endRetainedAccount == null) {
+ endRetainedAccount = new AccountImpl();
+ endRetainedAccount.setAccountNumber("891");
+ endRetainedAccount.setLabel("Bilan de clôture");
+ accountService.createAccount(accountMaster, endRetainedAccount);
+ endRetainedAccount = accountService.getAccountByNumber("891");
+ }
+
+ //look for the last financial period from the previous fiscal year
+ Collection<FinancialPeriod> fperiod = fiscalPeriod.getFinancialPeriod();
+
+ Iterator itr = fperiod.iterator();
+ FinancialPeriod lastFPeriod = null;
+ while (itr.hasNext()) {
+ lastFPeriod = (FinancialPeriod) itr.next();
+ }
+ //check if the last financial period isn't blocked
+ if (lastFPeriod.getLocked()) {
+ throw new LimaException("The last financial period from the fiscal period is blocked");
+ }
+
+ FinancialPeriod beginfinancialPeriod = null;
+ //settings to be done only if a new year exists
+ if (newyear) {
+ //look for the first financial period on the new fiscal year which is unlocked
+ found = false;
+ List<ClosedPeriodicEntryBook> resultsArray =
+ new ArrayList<ClosedPeriodicEntryBook>();
+ List<ClosedPeriodicEntryBook> closedPeriodicEntryBook =
+ financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
+ Collections.sort(closedPeriodicEntryBook, new FinancialPeriodComparator());
+ resultsArray.addAll(closedPeriodicEntryBook);
+ for (ClosedPeriodicEntryBook cPeriodicEntryBook : resultsArray) {
+ //check for - unlocked financial period
+ // - date after the closing fiscal year
+ // - unlocked entrybook
+ // - right code and label
+ if (!found && !cPeriodicEntryBook.getFinancialPeriod().getLocked()
+ && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(fiscalPeriod.getEndDate())
+ && !cPeriodicEntryBook.getLocked()
+ && cPeriodicEntryBook.getEntryBook().getCode().equals(entryBook.getCode())
+ && cPeriodicEntryBook.getEntryBook().getLabel().equals(entryBook.getLabel())) {
+ found = true;
+ beginfinancialPeriod = cPeriodicEntryBook.getFinancialPeriod();
+ }
+ }
+ if (!found) {
+ throw new LimaException("Can't set financial period on the following fiscal year ");
+ }
+ }
+
+ //holds entries of all closing transactions
+ FinancialTransaction endfinancialTransaction = new FinancialTransactionImpl();
+ if (lastFPeriod != null) {
+ System.out.println("not null");
+ //Sets the endfinancialTransaction
+ endfinancialTransaction.setAmountDebit(BigDecimal.ZERO);
+ endfinancialTransaction.setAmountCredit(BigDecimal.ZERO);
+ endfinancialTransaction.setEntryBook(entryBook);
+ endfinancialTransaction.setFinancialPeriod(lastFPeriod);
+ endfinancialTransaction.setTransactionDate(fiscalPeriod.getEndDate());
+ financialTransactionService.createFinancialTransaction(endfinancialTransaction);
+ }
+
+ //holds entries of all opening transactions
+ FinancialTransaction beginfinancialTransaction = new FinancialTransactionImpl();
+ if (newyear) {
+ if (found) {
+ //Sets the endfinancialTransaction
+ beginfinancialTransaction.setAmountDebit(BigDecimal.ZERO);
+ beginfinancialTransaction.setAmountCredit(BigDecimal.ZERO);
+ beginfinancialTransaction.setEntryBook(entryBook);
+ beginfinancialTransaction.setFinancialPeriod(beginfinancialPeriod);
+ beginfinancialTransaction.setTransactionDate(beginfinancialPeriod.getBeginDate());
+ financialTransactionService.createFinancialTransaction(beginfinancialTransaction);
+ }
+ }
+
+ //Sets date for description, e.g: Report à nouveau (DATE)
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(fiscalPeriod.getEndDate());
+
+ //Sets entries
+ Entry beginEntry = null;
+
+
+ BalanceTrial results = reportService.generateBalanceTrial(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), null, false, false);
+
+ List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
+
+ for (ReportsDatas report : reportsDatasList) {
+ //Account class from 1 to 5 and only non zero amount
+ if (report.getAccount().getAccountNumber().substring(0, 1).matches("[1-5]")
+ && !report.getAmountSolde().equals(BigDecimal.ZERO)) {
+ //close accounts by removing amounts from all class 1 to 5 accounts
+ beginEntry = new EntryImpl();
+ beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
+ beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
+ beginEntry.setFinancialTransaction(endfinancialTransaction);
+ beginEntry.setAccount(report.getAccount());
+ beginEntry.setAmount(report.getAmountSolde().abs());
+ beginEntry.setDebit(!report.getSoldeDebit());
+ financialTransactionService.createEntryWithTransaction(beginEntry, topiaContext);
+ //save amounts inside account number 891
+ beginEntry = new EntryImpl();
+ beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
+ beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
+ beginEntry.setFinancialTransaction(endfinancialTransaction);
+ beginEntry.setAccount(endRetainedAccount);
+ beginEntry.setAmount(report.getAmountSolde().abs());
+ beginEntry.setDebit(report.getSoldeDebit());
+ financialTransactionService.createEntryWithTransaction(beginEntry, topiaContext);
+ //open new year accounts if new year exists and a date has been found for the transaction
+ if (newyear && found) {
+ //give back amounts from class 1 to 5 accounts
+ beginEntry = new EntryImpl();
+ beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
+ beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
+ beginEntry.setFinancialTransaction(beginfinancialTransaction);
+ beginEntry.setAccount(report.getAccount());
+ beginEntry.setAmount(report.getAmountSolde().abs());
+ beginEntry.setDebit(report.getSoldeDebit());
+ financialTransactionService.createEntryWithTransaction(beginEntry, topiaContext);
+ //close account by removing amount from account number 890
+ beginEntry = new EntryImpl();
+ beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
+ beginEntry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
+ beginEntry.setFinancialTransaction(beginfinancialTransaction);
+ beginEntry.setAccount(endRetainedAccount);
+ beginEntry.setAmount(report.getAmountSolde().abs());
+ beginEntry.setDebit(!report.getSoldeDebit());
+ financialTransactionService.createEntryWithTransaction(beginEntry, topiaContext);
+ }
+ }
+ }
+ //if no problem appeared, commit
+ commitTransaction(topiaContext);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaContext, ex, log);
+ }
+ finally {
+ doFinally(topiaContext, log);
+ }
+ }
+
protected TopiaContext beginTransaction() throws TopiaException {
// basic check done, make check in database
// TODO move it into JTA
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FiscalPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FiscalPeriodService.java 2011-07-01 13:58:36 UTC (rev 3194)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FiscalPeriodService.java 2011-07-01 14:03:16 UTC (rev 3195)
@@ -28,6 +28,7 @@
import java.util.List;
import javax.ejb.Remote;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FiscalPeriod;
/**
@@ -52,5 +53,13 @@
void createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
- void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+ void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+
+ /**
+ * Methods for report retained earnings
+ * @param previousFiscalPeriod, fiscalPeriod, entryBook
+ * @throws LimaException
+ */
+
+ void addRetainedEarnings(FiscalPeriod fiscalPeriod, boolean newyear, EntryBook entryBook) throws LimaException;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2011-07-01 13:58:36 UTC (rev 3194)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2011-07-01 14:03:16 UTC (rev 3195)
@@ -29,7 +29,6 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
@@ -41,11 +40,9 @@
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
import org.chorem.lima.business.FiscalPeriodServiceMonitorable;
import org.chorem.lima.business.ImportServiceMonitorable;
-import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.utils.FiscalPeriodComparator;
-import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -245,33 +242,6 @@
refresh();
}
}
-
- /**
- * Sets FiscalPeriods and call for performing adding retained earnings
- * @param selectedRow
- * @param entryBook
- * @throws LimaException
- */
- public void addRetainedEarnings(int selectedRow, EntryBook entryBook, Date date) throws LimaException {
-
- FiscalPeriod fiscalPeriod = getFiscalPeriodAtRow(selectedRow);
- //check if the current fiscal period isn't block
- if (fiscalPeriod.getLocked()) {
- throw new LimaBusinessException("The fiscal period is blocked");
- }
- if (selectedRow == 0) {
- throw new LimaBusinessException("Can't find previous fiscal period");
- }
-
- //check if the previous fiscal period exists, if so check if it is blocked
- FiscalPeriod previousFiscalPeriod = getFiscalPeriodAtRow(selectedRow-1);
- if (!previousFiscalPeriod.getLocked()) {
- throw new LimaBusinessException("The previous fiscal period isn't blocked");
- }
-
- financialTransactionService.addRetainedEarnings(previousFiscalPeriod, fiscalPeriod, entryBook, date);
-
- }
@Override
public void notifyMethod(String serviceName, String methodeName) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2011-07-01 13:58:36 UTC (rev 3194)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2011-07-01 14:03:16 UTC (rev 3195)
@@ -66,10 +66,4 @@
onActionPerformed="getHandler().blockFiscalPeriod()" />
</cell>
</row>
- <row>
- <cell fill="horizontal">
- <JButton id="ranButton" text="lima.charts.fiscalperiod.addretainedearnings" enabled="{isSelectedPeriod()}"
- onActionPerformed="getHandler().addRetainedEarnings()" />
- </cell>
- </row>
</Table>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-07-01 13:58:36 UTC (rev 3194)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-07-01 14:03:16 UTC (rev 3195)
@@ -34,10 +34,13 @@
import org.nuiton.util.DateUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
+import org.chorem.lima.business.FiscalPeriodServiceMonitorable;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.fiscalperiod.AddPeriod;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
import org.chorem.lima.util.DialogHelper;
@@ -61,8 +64,15 @@
protected FiscalPeriodTableModel tableModel;
+ /** Service. */
+ protected FiscalPeriodServiceMonitorable fiscalPeriodService;
+
protected FiscalPeriodViewHandler(FiscalPeriodView view) {
this.view=view;
+
+ fiscalPeriodService =
+ LimaServiceFactory.getInstance().getService(
+ FiscalPeriodServiceMonitorable.class);
}
public void addFiscalPeriod() {
@@ -108,19 +118,38 @@
int selectedRow = fiscalPeriodeTable.getSelectedRow();
FiscalPeriodTableModel model =
(FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel();
-
+ System.out.println(fiscalPeriodeTable.getRowCount() + " " + selectedRow);
// blocked it
try {
FiscalPeriod selectedFiscalPeriod =
model.getFiscalPeriodAtRow(selectedRow);
+ //check if the user want to block the fiscal year
int response =
JOptionPane.showConfirmDialog(getView(),
_("lima.charts.fiscalperiod.question.blocked"),
_("lima.common.question"), JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
-
if (response == JOptionPane.YES_OPTION) {
- model.blockFiscalPeriod(selectedFiscalPeriod);
+ //use to tell if the user wants to create a new fiscal year
+ boolean newyear = false;
+ //check if two fiscal periods are open
+ if (model.getRowCount()-1 != selectedRow) {
+ newyear = true; //two are open
+ } else {
+ //check if the user want to create a new fiscal year
+ response =
+ JOptionPane.showConfirmDialog(getView(),
+ _("lima.charts.fiscalperiod.question.newyear"),
+ _("lima.common.question"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ //create a new fiscal year
+ if (response == JOptionPane.YES_OPTION) {
+ addFiscalPeriod();
+ newyear = true;
+ }
+ }
+ addRetainedEarnings(selectedFiscalPeriod, newyear);
+ //model.blockFiscalPeriod(selectedFiscalPeriod);
}
} catch (LimaException eee) {
if (log.isErrorEnabled()) {
@@ -131,40 +160,29 @@
}
/**
- * Checks confirmation from user
+ *
* Sets EntryBook and Date to use
*/
- public void addRetainedEarnings() {
+ public void addRetainedEarnings(FiscalPeriod selectedFiscalPeriod, boolean newyear) {
JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable();
int selectedRow = fiscalPeriodeTable.getSelectedRow();
FiscalPeriodTableModel model =
(FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel();
try {
- int response = JOptionPane.showConfirmDialog(view, _("lima.charts.fiscalperiod.addretainedearnings"),
- _("lima.common.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
-
- if (response == JOptionPane.YES_OPTION) {
- //Sets EntryBook
- EntryBook newEntryBook = new EntryBookImpl();
- RetainedEarningsEntryBookForm entryBookForm = new RetainedEarningsEntryBookForm(view);
- entryBookForm.setEntryBook(newEntryBook);
- // jaxx constructor don't call super() ?
- entryBookForm.setLocationRelativeTo(view);
- entryBookForm.setVisible(true);
- // null == cancel action
- EntryBook entryBook = entryBookForm.getEntryBook();
- if (entryBook != null) {
- //Sets Date
- RetainedEarningsDateForm dateForm = new RetainedEarningsDateForm(view);
- // jaxx constructor don't call super() ?
- dateForm.setLocationRelativeTo(view);
- dateForm.setVisible(true);
- // null == cancel action
- Date date = dateForm.getBeginDatePicker().getDate();
- if (date != null) {
- model.addRetainedEarnings(selectedRow, entryBook, date);
- }
- }
+ //Sets EntryBook
+ EntryBook newEntryBook = new EntryBookImpl();
+ RetainedEarningsEntryBookForm entryBookForm = new RetainedEarningsEntryBookForm(view);
+ entryBookForm.setEntryBook(newEntryBook);
+ // jaxx constructor don't call super() ?
+ entryBookForm.setLocationRelativeTo(view);
+ entryBookForm.setVisible(true);
+ // null == cancel action
+ EntryBook entryBook = entryBookForm.getEntryBook();
+ if (entryBook != null) {
+ System.out.println(selectedFiscalPeriod);
+ System.out.println(newyear);
+ System.out.println(entryBook);
+ fiscalPeriodService.addRetainedEarnings(selectedFiscalPeriod, newyear, entryBook);
}
} catch (LimaException eee) {
if (log.isErrorEnabled()) {
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-07-01 13:58:36 UTC (rev 3194)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2011-07-01 14:03:16 UTC (rev 3195)
@@ -31,7 +31,8 @@
lima.charts.fiscalperiod.block=Block fiscalperiod
lima.charts.fiscalperiod.create=Create fiscalperiod
lima.charts.fiscalperiod.question.blocked=Block fiscalperiod
-lima.charts.fiscalperiod.question.morethan12=This period is longer than 12 months. Do you really create this ?
+lima.charts.fiscalperiod.question.morethan12=This period is longer than 12 months. Do you really create this ?
+lima.charts.fiscalperiod.question.newyear=Do you want to create a new fiscal year ?
lima.charts.fiscalyear=Fiscal Years
lima.common.account=Account
lima.common.amount=Amount
@@ -82,6 +83,7 @@
lima.config.ui.fullscreen.description=FullScreen
lima.daily=Daily
lima.documents=Documents\u2026
+lima.documents.error=Can't create document on an open fiscal year
lima.entries=Entries
lima.entries.addEntry=Add entry
lima.entries.addTransaction=Add transaction
@@ -213,6 +215,8 @@
lima.tab.home=Home
lima.table.account=Account
lima.table.balance=Balance
+lima.table.begin.credit=Beginning Balance Credit
+lima.table.begin.debit=Beginning Balance Debit
lima.table.closure=Closed
lima.table.code=Code
lima.table.collectedvat=Collected VAT
@@ -250,3 +254,4 @@
lima.tooltip.lettering=<html>Add a letter on many entries <br/>Select many rows with combination ctrl + click</html>
lima.warning.nimbus.landf=Could not find Numbus Look&Feel
limma.config.thousandseparator.description=
+nuitonutil.error.applicationconfig.save=
1
0
r3194 - in trunk/lima-business/src/main/java/org/chorem/lima/business: ejb ejbinterface
by vsalaun@users.chorem.org 01 Jul '11
by vsalaun@users.chorem.org 01 Jul '11
01 Jul '11
Author: vsalaun
Date: 2011-07-01 15:58:36 +0200 (Fri, 01 Jul 2011)
New Revision: 3194
Url: http://chorem.org/repositories/revision/lima/3194
Log:
Service refactoring
(\ /)
(O.o)
(> <) Bunny approves these changes.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2011-07-01 13:50:35 UTC (rev 3193)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2011-07-01 13:58:36 UTC (rev 3194)
@@ -29,8 +29,6 @@
import java.math.BigDecimal;
import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -41,9 +39,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.FinancialStatementWayEnum;
-import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.FinancialTransactionSearch;
-import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
@@ -53,17 +49,13 @@
import org.chorem.lima.business.ejbinterface.FinancialTransactionServiceLocal;
import org.chorem.lima.business.ejbinterface.ReportService;
import org.chorem.lima.business.ejbinterface.OptionsService;
-import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
-import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
-import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodDAO;
-import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.Letter;
import org.chorem.lima.entity.LetterDAO;
@@ -470,12 +462,9 @@
}
- @Override
public Entry createEntryWithTransaction(Entry entry,
- TopiaContext topiaContext) throws LimaException {
+ TopiaContext topiaContext) throws LimaException, TopiaException {
Entry newEntry = null;
- try {
-
//check if the financial period is blocked
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
entry.getFinancialTransaction(), topiaContext);
@@ -518,11 +507,7 @@
financialTransaction, topiaContext);
- commitTransaction(topiaContext);
- }
- catch (TopiaException ex) {
- doCatch(topiaContext, ex, log);
- }
+ //commitTransaction(topiaContext);
return newEntry;
}
@@ -540,7 +525,11 @@
try {
topiaContext = beginTransaction();
- return createEntryWithTransaction(entry, topiaContext);
+ Entry newEntry = createEntryWithTransaction(entry, topiaContext);
+
+ commitTransaction(topiaContext);
+
+ return newEntry;
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
@@ -687,135 +676,6 @@
}
}
- @Override
- public void addRetainedEarnings(FiscalPeriod previousFiscalPeriod, FiscalPeriod fiscalPeriod, EntryBook entryBook, Date date) throws LimaException {
- TopiaContext topiaContext = null;
- try {
-
-
- BalanceTrial results = reportService.generateBalanceTrial(previousFiscalPeriod.getBeginDate(), previousFiscalPeriod.getEndDate(), null, false, false);
-
- List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
-
- topiaContext = beginTransaction();
-
- //Sets entryBook
- //search for the entryBook to use using param
- boolean found = false;
- List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks();
- for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode()) && entry.getLabel().equals(entryBook.getLabel())) {
- entryBook = entry;
- found = true;
- }
- }
- //if entrybook is not found
- //then create it
- if (!found) {
- entryBookService.createEntryBook(entryBook);
- entryBooksList = entryBookService.getAllEntryBooks();
- for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode()) && entry.getLabel().equals(entryBook.getLabel())) {
- entryBook = entry;
- found = true;
- }
- }
- }
-
- //Sets the financialTransaction
- FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- financialTransaction.setAmountDebit(BigDecimal.ZERO);
- financialTransaction.setAmountCredit(BigDecimal.ZERO);
- financialTransaction.setEntryBook(entryBook);
-
- FinancialPeriod financialPeriod = null;
-
- //Sets date for description
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(previousFiscalPeriod.getEndDate());
-
-
- found = false;
-
- //look for the first financial period on the current fiscal year with is unlocked
- List<ClosedPeriodicEntryBook> resultsArray =
- new ArrayList<ClosedPeriodicEntryBook>();
- List<ClosedPeriodicEntryBook> closedPeriodicEntryBook =
- financialPeriodService.getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod();
- Collections.sort(closedPeriodicEntryBook, new FinancialPeriodComparator());
- resultsArray.addAll(closedPeriodicEntryBook);
-
- for (ClosedPeriodicEntryBook cPeriodicEntryBook : resultsArray) {
- if (!found && (cPeriodicEntryBook.getFinancialPeriod().getBeginDate().compareTo(date) <= 0)
- && (cPeriodicEntryBook.getFinancialPeriod().getEndDate().compareTo(date) >= 1)) {
- if (cPeriodicEntryBook.getFinancialPeriod().getLocked() || cPeriodicEntryBook.getLocked()) {
- throw new LimaException("Can't set financialPeriod");
- }
- if (cPeriodicEntryBook.getEntryBook().getCode().equals(entryBook.getCode())
- && cPeriodicEntryBook.getEntryBook().getLabel().equals(entryBook.getLabel())) {
- found = true;
- financialPeriod = cPeriodicEntryBook.getFinancialPeriod();
- }
- }
- }
- if (!found) {
- throw new LimaException("Can't set financialPeriod");
- }
- financialTransaction.setFinancialPeriod(financialPeriod);
- financialTransaction.setTransactionDate(date);
- // create it
- createFinancialTransactionWithTransaction(financialTransaction, topiaContext);
- commitTransaction(topiaContext);
-
- //Sets entries
- Entry entry = null;
-
-
-
- for (ReportsDatas report : reportsDatasList) {
- //Account class from 1 to 7
- if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 8) {
- if (report.getSoldeDebit()){
- if (!report.getAmountDebit().equals(BigDecimal.ZERO)) {
- entry = new EntryImpl();
- entry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
- entry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- entry.setFinancialTransaction(financialTransaction);
- entry.setAccount(report.getAccount());
- entry.setAmount(report.getAmountDebit().abs());
- entry.setDebit(true);
- topiaContext = beginTransaction();
- createEntryWithTransaction(entry, topiaContext);
- commitTransaction(topiaContext);
- }
- }
- if (!report.getSoldeDebit()){
- if (!report.getAmountCredit().equals(BigDecimal.ZERO)) {
- entry = new EntryImpl();
- entry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
- entry.setVoucher(_("lima-business.financialtransaction.retainedearnings.voucher"));
- entry.setFinancialTransaction(financialTransaction);
- entry.setAccount(report.getAccount());
- entry.setAmount(report.getAmountCredit().abs());
- entry.setDebit(false);
- topiaContext = beginTransaction();
- createEntryWithTransaction(entry, topiaContext);
- commitTransaction(topiaContext);
- }
- }
- }
- }
-
- //commit
- commitTransaction(topiaContext);
- }
- catch (TopiaException ex) {
- doCatch(topiaContext, ex, log);
- }
- finally {
- doFinally(topiaContext, log);
- }
- }
/**
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2011-07-01 13:50:35 UTC (rev 3193)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2011-07-01 13:58:36 UTC (rev 3194)
@@ -91,18 +91,9 @@
void updateEntry(Entry entry) throws LimaException;
- void removeEntry(Entry entry) throws LimaException;
+ void removeEntry(Entry entry) throws LimaException;
/**
- * Methods for report retained earnings
- * @param previousFiscalPeriod, fiscalPeriod, entryBook
- * @throws LimaException
- */
-
- void addRetainedEarnings(FiscalPeriod previousFiscalPeriod, FiscalPeriod fiscalPeriod, EntryBook entryBook, Date date) throws LimaException;
-
-
- /**
* Methods for create, update and remove the letter
* @param entry
* @throws LimaException
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java 2011-07-01 13:50:35 UTC (rev 3193)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java 2011-07-01 13:58:36 UTC (rev 3194)
@@ -30,6 +30,7 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FinancialTransaction;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
/**
* Transaction service.
@@ -48,6 +49,8 @@
void updateFinancialTransactionWithTransaction(FinancialTransaction financialtransaction, TopiaContext topiaContext) throws LimaException;
- Entry createEntryWithTransaction(Entry entry, TopiaContext topiaContext) throws LimaException;
+ Entry createEntryWithTransaction(Entry entry, TopiaContext topiaContext) throws LimaException, TopiaException;
+
+
}
1
0
r3193 - in trunk/lima-business/src/main/java/org/chorem/lima/business: ejb ejbinterface
by vsalaun@users.chorem.org 01 Jul '11
by vsalaun@users.chorem.org 01 Jul '11
01 Jul '11
Author: vsalaun
Date: 2011-07-01 15:50:35 +0200 (Fri, 01 Jul 2011)
New Revision: 3193
Url: http://chorem.org/repositories/revision/lima/3193
Log:
add search by number account method
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2011-07-01 09:52:07 UTC (rev 3192)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2011-07-01 13:50:35 UTC (rev 3193)
@@ -231,6 +231,23 @@
return account;
}
+
+ /**
+ * Permet d'obtenir un compte suivant son numero
+ */
+ @Override
+ public Account getAccountByNumber(String number) throws LimaException {
+
+ List<Account> accountsList = new ArrayList<Account>();
+ accountsList = getAllAccountByProperty(Account.ACCOUNT_NUMBER, number);
+
+ if (accountsList.size() > 0) {
+ return accountsList.get(0);
+ } else {
+ return null;
+ }
+
+ }
/**
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java 2011-07-01 09:52:07 UTC (rev 3192)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java 2011-07-01 13:50:35 UTC (rev 3193)
@@ -44,6 +44,8 @@
public interface AccountService {
List<Account> getAllAccountByProperty(String propertyName, String value) throws LimaException;
+
+ Account getAccountByNumber(String number) throws LimaException;
List<Account> getAllAccounts() throws LimaException;
1
0
r3192 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction
by vsalaun@users.chorem.org 01 Jul '11
by vsalaun@users.chorem.org 01 Jul '11
01 Jul '11
Author: vsalaun
Date: 2011-07-01 11:52:07 +0200 (Fri, 01 Jul 2011)
New Revision: 3192
Url: http://chorem.org/repositories/revision/lima/3192
Log:
#413 ajout automatique d'une ligne ?\195?\160 l'autre des pieces comptables si deja presente
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-06-30 09:47:13 UTC (rev 3191)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-07-01 09:52:07 UTC (rev 3192)
@@ -415,11 +415,14 @@
* @return int: indexOf new Entry
* @throws LimaException
*/
- public int addEmptyEntry(Object value, String description, int row) throws LimaException {
+ public int addEmptyEntry(Object value, String voucher, String description, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
Object currentRow = cacheDataList.get(row);
Entry entry = new EntryImpl();
entry.setAmount(BigDecimal.ZERO);
+ if (voucher != null) {
+ entry.setVoucher(voucher);
+ }
if (description != null) {
entry.setDescription(description);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2011-06-30 09:47:13 UTC (rev 3191)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2011-07-01 09:52:07 UTC (rev 3192)
@@ -146,9 +146,10 @@
if (indexSelectedRow != -1) {
Object selectedValue = tableModel.getElementAt(indexSelectedRow);
try {
- //copy + paste the description
+ //copy + paste the voucher and the description
+ String voucher = (String) tableModel.getValueAt(indexSelectedRow, 2);
String description = (String) tableModel.getValueAt(indexSelectedRow, 4);
- int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
+ int index = tableModel.addEmptyEntry(selectedValue, voucher, description, indexSelectedRow);
//select the new line
ListSelectionModel selectionModel =
table.getSelectionModel();
1
0