r2897 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui/transaction lima-swing/src/main/java/org/chorem/lima/ui/transaction/table
Author: jpepin Date: 2010-05-14 13:22:26 +0200 (Fri, 14 May 2010) New Revision: 2897 Url: http://chorem.org/repositories/revision/lima/2897 Log: Cr?\195?\169ation d'une entr?\195?\169e : v?\195?\169rification que le journal de la p?\195?\169riode courante est ouvert. Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-callao/src/main/xmi/accounting.properties trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-12 17:06:24 UTC (rev 2896) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-05-14 11:22:26 UTC (rev 2897) @@ -35,9 +35,9 @@ public void createAccountRules(Account masterAccount, Account account) throws LimaException; public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException; public void createFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException; + public void updateEntryRules(Entry entry, TopiaContext topiaTransaction) throws LimaException; public void blockFiscalPeriodRules(FiscalPeriod fiscalPeriod, TopiaContext transaction) throws LimaException; public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException; public void removeEntryBookRules(EntryBook entryBook, TopiaContext topiaTransaction) throws LimaException; - public void checkFinancialPeriodBlockedWithEntry(Entry entry) throws LimaException; - public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException; + public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction, TopiaContext topiaContext) throws LimaException; } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-12 17:06:24 UTC (rev 2896) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-05-14 11:22:26 UTC (rev 2897) @@ -23,18 +23,26 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountingRules; +import org.chorem.lima.business.FinancialPeriodService; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ejb.AccountServiceImpl; +import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl; import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryDAO; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FinancialPeriodDAO; import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.FinancialTransactionDAO; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; +import org.nuiton.topia.framework.TopiaQuery; /** * Defaults rules, if no localized rules classes is instantiated * this default class contain the strict minimum rules to check the data integrity @@ -45,6 +53,9 @@ protected static final Log log = LogFactory.getLog(DefaultAccountingRules.class); + + private FinancialPeriodServiceImpl financialPeriodService = + new FinancialPeriodServiceImpl(); /** * Rules to check before create accounts @@ -66,7 +77,6 @@ throws LimaException { // check the number account is not empty if (StringUtils.isBlank(account.getAccountNumber())) { - log.debug("TEST"); throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber()); } @@ -89,6 +99,29 @@ } } + @Override + public void updateEntryRules(Entry entry, TopiaContext topiaTransaction) throws LimaException { + if (entry.getFinancialTransaction().getFinancialPeriod().getLocked()){ + throw new LimaBusinessException("The financial period is blocked"); + } + ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl(); + try { + EntryBook entryBook = entry.getEntryBook(); + FinancialPeriod financialPeriod = + entry.getFinancialTransaction().getFinancialPeriod(); + + closedPeriodicEntryBook = + financialPeriodService.getClosedPeriodicEntryBook(entryBook, financialPeriod); + } + catch (LimaException eee) { + doCatch(topiaTransaction, eee, log); + } + // Check if closedperiodicentrybook is locked + if (closedPeriodicEntryBook.getLocked()){ + throw new LimaBusinessException("Can't update entry : financialperiod of this entrybook is closed"); + } + } + /** * Rules to check before block fiscals periods */ @@ -137,22 +170,14 @@ } } - - /** - * check if financial period of an entry is blocked - */ - @Override - public void checkFinancialPeriodBlockedWithEntry(Entry entry) throws LimaException { - if (entry.getFinancialTransaction().getFinancialPeriod().getLocked()){ - throw new LimaBusinessException("The financial period is blocked"); - } - } /** * check if financial period of a financial transaction is blocked */ @Override - public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction) throws LimaException { + public void checkFinancialPeriodBlockedWithFinancialTransaction(FinancialTransaction financialTransaction, TopiaContext topiaContext) throws LimaException { + + if (financialTransaction.getFinancialPeriod().getLocked()){ throw new LimaBusinessException("The financial period is blocked"); } 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 2010-05-12 17:06:24 UTC (rev 2896) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-05-14 11:22:26 UTC (rev 2897) @@ -113,14 +113,7 @@ ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(transaction); for (FinancialPeriod financialPeriod : financialPeriodService.getUnblockedFinancialPeriods()) { - //new closedperiodentrybook - //set financial - - //set entrybook - - //create it - //new closed periodic entrybook ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl(); // set entrybook 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 2010-05-12 17:06:24 UTC (rev 2896) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-14 11:22:26 UTC (rev 2897) @@ -29,6 +29,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; 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.FinancialTransactionService; @@ -84,14 +85,14 @@ @Override public void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException { - //check if the financial period is blocked - accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction); - TopiaContext topiaContext = null; try { // basic check done, make check in database // TODO move it into JTA topiaContext = rootContext.beginTransaction(); + + //check if the financial period is blocked + accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction, topiaContext); FinancialTransactionDAO financialtransactionDAO = LimaCallaoDAOHelper .getFinancialTransactionDAO(topiaContext); @@ -238,12 +239,14 @@ @Override public void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException { - //check if the financial period is blocked - accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction); - TopiaContext topiaTransaction = null; try { topiaTransaction = rootContext.beginTransaction(); + + //check if the financial period is blocked + accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction, topiaTransaction); + + FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction); transactionDAO.update(financialtransaction); // commit @@ -261,12 +264,13 @@ @Override public void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException { - //check if the financial period is blocked - accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction); - TopiaContext topiaTransaction = null; try { topiaTransaction = rootContext.beginTransaction(); + + //check if the financial period is blocked + accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction, topiaTransaction); + FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction); FinancialTransaction financialTransaction2 = transactionDAO.findByTopiaId(financialtransaction.getTopiaId()); transactionDAO.delete(financialTransaction2); @@ -287,14 +291,15 @@ @Override public void removeEntry(Entry entry) throws LimaException { - //check if the financial period is blocked - accountingRules.checkFinancialPeriodBlockedWithEntry(entry); - TopiaContext topiaContext = null; try { // basic check done, make check in database // TODO move it into JTA topiaContext = rootContext.beginTransaction(); + + //check if the financial period is blocked + accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(entry.getFinancialTransaction(), topiaContext); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); //delete entryDAO.delete(entry); @@ -312,13 +317,13 @@ @Override public void updateEntry(Entry entry) throws LimaException { - //check if the financial period is blocked - accountingRules.checkFinancialPeriodBlockedWithEntry(entry); - TopiaContext topiaContext = null; try { // TODO move it into JTA topiaContext = rootContext.beginTransaction(); + + //check rules + accountingRules.updateEntryRules(entry, topiaContext); EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); //delete entryDAO.update(entry); @@ -342,16 +347,17 @@ @Override public void createEntry(Entry entry) throws LimaException { - - //check if the financial period is blocked - accountingRules.checkFinancialPeriodBlockedWithEntry(entry); - + TopiaContext topiaContext = null; try { // basic check done, make check in database // TODO move it into JTA topiaContext = rootContext.beginTransaction(); + + //check if the financial period is blocked + accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(entry.getFinancialTransaction(), topiaContext); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); entryDAO.create(entry); Modified: trunk/lima-callao/src/main/xmi/accounting.properties =================================================================== --- trunk/lima-callao/src/main/xmi/accounting.properties 2010-05-12 17:06:24 UTC (rev 2896) +++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-05-14 11:22:26 UTC (rev 2897) @@ -3,6 +3,7 @@ org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false org.chorem.lima.entity.Account.attribute.identity.tagvalue.lazy=false +org.chorem.lima.entity.FinancialTransaction.attribute.financialPeriod.tagvalue.lazy=false org.chorem.lima.entity.FiscalPeriod.attribute.financialPeriod.tagvalue.lazy=false #model.tagvalue.dbSchema=Callao Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-05-12 17:06:24 UTC (rev 2896) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-05-14 11:22:26 UTC (rev 2897) @@ -80,7 +80,7 @@ if (indexSelectedRow != -1) { Object selectedValue = model.getElementAt(indexSelectedRow); try { - model.addEmptyEntry(selectedValue, indexSelectedRow); + model.addEmptyEntry(selectedValue, indexSelectedRow); } catch (LimaException ex){ if (log.isWarnEnabled()) { log.warn("Can't add empty entry"); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-05-12 17:06:24 UTC (rev 2896) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-05-14 11:22:26 UTC (rev 2897) @@ -53,8 +53,6 @@ private static final Log log = LogFactory.getLog(FinancialTransactionTable.class); protected FinancialTransactionViewHandler handler; - - private ColorHighlighter colorEmptyLine; private Highlighter colorTransaction; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-12 17:06:24 UTC (rev 2896) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-14 11:22:26 UTC (rev 2897) @@ -20,7 +20,6 @@ import static org.nuiton.i18n.I18n._; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -28,7 +27,6 @@ import javax.swing.table.AbstractTableModel; -import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -55,12 +53,6 @@ * Le modele est filtré sur {@link #selectedEntryBook} et * {@link #selectedFinancialPeriod} (montée en charge !). * - * TODO EC20100408 revoir le modele, avoir des transactions et des entries - * c'est pas gérables. - * Le mieux serait d'avoir un "mega component transaction par ligne" et - * que ce composant puisse editer les entries. - * Ou autre chose. - * * @author ore * @author chatellier * @version $Revision$ @@ -114,7 +106,6 @@ /** * Le model est une combinaison de Transaction/Entries. * - * TODO EC20100408 c'est pas evident a manipuler via une table * * @return */ @@ -245,7 +236,6 @@ // just prevent too much result if (selectedFinancialPeriod != null) { - // TODO EC-20100407 remove this ugly code result = cacheDataList.get(row); if (result instanceof FinancialTransaction) { @@ -367,7 +357,6 @@ */ public void addFinancialTransaction() throws LimaException{ /* Calling transaction service */ - //TODO transaction = currentdate, current periode, current journal FinancialTransaction financialTransaction = new FinancialTransactionImpl(); //if a period and an entrybook is selected if (selectedFinancialPeriod != null){ @@ -420,7 +409,6 @@ fireTableDataChanged(); } - /** * to modifiy financialtransaction or entry */ @@ -429,7 +417,6 @@ // just prevent too much result if (selectedFinancialPeriod != null) { - // TODO EC-20100407 remove this ugly code Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentFinancialTransaction =
participants (1)
-
jpepin@users.chorem.org