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
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=
participants (1)
-
vsalaun@users.chorem.org