r3233 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui java/org/chorem/lima/ui/vatreports resources/i18n
Author: vsalaun Date: 2011-07-25 11:02:55 +0200 (Mon, 25 Jul 2011) New Revision: 3233 Url: http://chorem.org/repositories/revision/lima/3233 Log: #347 update vat report table + add import/export for vat to menu Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 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-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2011-07-25 08:07:59 UTC (rev 3232) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2011-07-25 09:02:55 UTC (rev 3233) @@ -125,12 +125,14 @@ <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT)'/> <JMenuItem text="lima.common.entrybooks" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_ENTRYBOOKS_IMPORT)'/> <JMenuItem text="lima.importexport.financialstatements" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT)'/> + <JMenuItem text="lima.importexport.vatstatements" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_VAT_IMPORT)'/> </JMenu> <JMenu text="lima.importexport.export" actionIcon='export-element'> <JMenuItem text="lima.importexport.all" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_ALL_EXPORT)'/> <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_ACCOUNTCHARTS_EXPORT)'/> <JMenuItem text="lima.common.entrybooks" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_ENTRYBOOKS_EXPORT)'/> <JMenuItem text="lima.importexport.financialstatements" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_FINANCIALSTATEMENTS_EXPORT)'/> + <JMenuItem text="lima.importexport.vatstatements" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.CSV_VAT_EXPORT)'/> </JMenu> </JMenu> <JMenu text="lima.importexport.ebp"> 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-07-25 08:07:59 UTC (rev 3232) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2011-07-25 09:02:55 UTC (rev 3233) @@ -26,25 +26,19 @@ import static org.nuiton.i18n.I18n._; -import java.text.SimpleDateFormat; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.swing.table.AbstractTableModel; 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.beans.VatStatementAmounts; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ReportServiceMonitorable; import org.chorem.lima.business.ServiceListener; -import org.chorem.lima.business.utils.EntryComparator; -import org.chorem.lima.entity.Account; -import org.chorem.lima.entity.Entry; -import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.business.VatStatementServiceMonitorable; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; @@ -61,13 +55,25 @@ /** Services. */ protected ReportServiceMonitorable reportService; + protected VatStatementServiceMonitorable vatStatementService; /** selected financial period */ protected FiscalPeriod selectedFiscalPeriod; /** data cache */ - protected List<Object> cacheDataList; + protected List<VatStatementAmounts> cacheDataList; + /** + * list of BigDecimal, save the difference between the number given by the VAT chart + * and the number given by the user afterwards + */ + private List<BigDecimal> diffBigDecimalList = new ArrayList<BigDecimal>(); //list of 38 elements + + /** + * variable used for the document edition, + * if "true" then the document will be automatically filled in + * if "false" the the document will be empty + */ protected String autocomplete; @@ -75,37 +81,22 @@ reportService = LimaServiceFactory.getInstance().getService( ReportServiceMonitorable.class); + vatStatementService = + LimaServiceFactory.getInstance().getService( + VatStatementServiceMonitorable.class); + vatStatementService.addListener(this); autocomplete = "true"; } - protected List<Object> getDataList() throws TopiaException { - List<Object> finalresults = new ArrayList<Object>(); + protected List<VatStatementAmounts> getDataList() throws TopiaException { + List<VatStatementAmounts> list = null; + if (selectedFiscalPeriod != null) { try { - List<Object> results = reportService.generateVat(selectedFiscalPeriod); - - for (int index=0; index<results.size(); index++) { - if (results.get(index) instanceof BalanceTrial) { - if (((BalanceTrial)results.get(index)).getReportsDatas() != null){ - for (ReportsDatas reportsDatas : ((BalanceTrial)results.get(index)).getReportsDatas()) { - //reports datas - finalresults.add(reportsDatas); - List<Entry> entries = (List<Entry>) reportsDatas.getListEntry(); - if (entries != null){ - Collections.sort(entries, new EntryComparator()); - for (Entry entry : entries) { - //entry - finalresults.add(entry); - } - } - } - } - } else { - //financial period - finalresults.add(results.get(index)); - } - } + list = vatStatementService.vatStatementReport( + selectedFiscalPeriod.getBeginDate(), + selectedFiscalPeriod.getEndDate()); } catch (LimaException eee) { if (log.isErrorEnabled()) { @@ -114,7 +105,7 @@ ErrorHelper.showErrorDialog(_("lima.vatreport.listerror"), eee); } } - return finalresults; + return list; } public void refresh(){ @@ -126,6 +117,15 @@ } ErrorHelper.showErrorDialog("Can't get VAT list", eee); } + + if (cacheDataList != null) { + for (int index = 0; index < cacheDataList.size(); index++) { + //sets the BigDecimal difference list + if (diffBigDecimalList.size() != 38) { + diffBigDecimalList.add(BigDecimal.ZERO); + } + } + } fireTableDataChanged(); } @@ -136,26 +136,11 @@ switch (column) { case 0: - result = String.class; + result = String.class; //libellé break; case 1: - result = Account.class; + result = BigDecimal.class; //solde break; - case 2: - result = String.class; - break; - case 3: - result = String.class; - break; - case 4: - result = BigDecimal.class; - break; - case 5: - result = BigDecimal.class; - break; - case 6: - result = BigDecimal.class; - break; } return result; @@ -167,26 +152,11 @@ switch (column) { case 0: - result = _("lima.table.date"); //date + result = _("lima.table.label"); //label break; case 1: - result = "compte"; //tva collectee + result = _("lima.table.solde"); //solde break; - case 2: - result = "piece comptable"; //tva due - break; - case 3: - result = "description"; //credit de tva - break; - case 4: - result = "debit"; //remboursemments - break; - case 5: - result = "credit"; //credit restant - break; - case 6: - result = "solde"; //tva a payer - break; } return result; @@ -205,11 +175,11 @@ @Override public int getColumnCount() { - return 7; + return 2; } - public Object getElementAt(int row){ - Object currentRow = cacheDataList.get(row); + public VatStatementAmounts getElementAt(int row){ + VatStatementAmounts currentRow = cacheDataList.get(row); return currentRow; } @@ -218,112 +188,37 @@ Object result = null; // just prevent too much result if (cacheDataList != null) { - result = cacheDataList.get(row); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy"); - if (result instanceof FinancialPeriod) { - FinancialPeriod fp = (FinancialPeriod) result; - - switch (column) { + VatStatementAmounts value = cacheDataList.get(row); + switch (column) { case 0: - result = simpleDateFormat.format(fp.getBeginDate()) - + " - " + simpleDateFormat.format(fp.getEndDate()); + result = value.getLabel(); break; case 1: - result = null; - break; - case 2: - result = null; // voucher - break; - case 3: - result = null; // description - break; - case 4: - result = null; // position - break; - case 5: - result = null; - break; - case 6: - result = null; - break; - } - } - else if (result instanceof ReportsDatas) { - ReportsDatas currentRow = (ReportsDatas)result; - BigDecimal amountDebit = currentRow.getAmountDebit(); - BigDecimal amountCredit = currentRow.getAmountCredit(); - - switch (column) { - case 0: - result = null; // date - break; - case 1: - if (currentRow.getAccount() != null){ - result = currentRow.getAccount().getAccountNumber() - + " - " + currentRow.getAccount().getLabel(); - } - else { + if (value.getAmount() != null) { + //the number showed is the number given by the chart plus + //the number calculated from the diffBigDecimalList + //diffBigDecimalList can be a negative number ! + result = value.getAmount() + .add(diffBigDecimalList.get(row)); + } else { result = null; } break; - case 2: - result = null; // voucher - break; - case 3: - result = null; // description - break; - case 4: - result = amountDebit; // position - break; - case 5: - result = amountCredit; - break; - case 6: - result = amountDebit.subtract(amountCredit); - break; - } } - else if (result instanceof Entry) { - Entry currentRow = (Entry)result; - BigDecimal amountDebit = BigDecimal.ZERO, - amountCredit = BigDecimal.ZERO; - if (currentRow.getDebit()){ - amountDebit = currentRow.getAmount(); - } - else { - amountCredit = currentRow.getAmount(); - } - - switch (column) { - case 0: // date - result = simpleDateFormat. - format(currentRow.getFinancialTransaction().getTransactionDate()); - break; - case 1 : // account - result = null; - break; - case 2: // description - result = currentRow.getVoucher(); - break; - case 3: - result = currentRow.getDescription(); - break; - case 4: - result = amountDebit; - break; - case 5: - result = amountCredit; - break; - case 6: - result = amountDebit.subtract(amountCredit); - break; - } - } } return result; } + @Override + public void setValueAt(Object value, int row, int column) { + //check first if the user has changed the number value + if (!getValueAt(row, column).equals((BigDecimal)value)) { + //if so set the difference between the values inside diffBigDecimalList + diffBigDecimalList.set(row, ((BigDecimal) value).subtract((BigDecimal)getValueAt(row, column))); + } + } + public FiscalPeriod getFiscalPeriod() { return selectedFiscalPeriod; } @@ -344,11 +239,19 @@ autocomplete = "true"; } } + + @Override + public boolean isCellEditable(int row, int column) { + //only the second column can be editable, and also if it contains a number + return ((column ==1) && (getValueAt(row, column) != null)); + } @Override public void notifyMethod(String serviceName, String methodeName) { - // TODO Auto-generated method stub - + //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")) { + 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-07-25 08:07:59 UTC (rev 3232) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2011-07-25 09:02:55 UTC (rev 3233) @@ -193,6 +193,7 @@ lima.importexport.import.terminated=Import terminated lima.importexport.importcsv=Import CSV lima.importexport.importebp=Import EBP +lima.importexport.vatstatements=VAT chart lima.importexport.wait=Job in progress… lima.init.closed=Lima closed at %1$s lima.init.errorclosing=Error during Lima close 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-25 08:07:59 UTC (rev 3232) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2011-07-25 09:02:55 UTC (rev 3233) @@ -193,6 +193,7 @@ lima.importexport.import.terminated=Import terminé lima.importexport.importcsv=Import CSV lima.importexport.importebp=Import EBP +lima.importexport.vatstatements=Plan TVA lima.importexport.wait=Traitement en cours … lima.init.closed=Lima fermé à %1$s lima.init.errorclosing=Erreur lors de la fermeture
participants (1)
-
vsalaun@users.chorem.org