r3176 - in trunk/lima-business/src/main/java/org/chorem/lima/business: ejb ejbinterface utils
Author: vsalaun Date: 2011-06-14 12:39:00 +0200 (Tue, 14 Jun 2011) New Revision: 3176 Url: http://chorem.org/repositories/revision/lima/3176 Log: #347 update VAT services 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/HttpServerServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 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-06-14 10:33:02 UTC (rev 3175) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2011-06-14 10:39:00 UTC (rev 3176) @@ -26,20 +26,29 @@ package org.chorem.lima.business.ejb; import static org.nuiton.i18n.I18n._; + import java.awt.Color; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; + import javax.ejb.EJB; import javax.ejb.Stateless; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.pdfbox.examples.fdf.PrintFields; +import org.apache.pdfbox.examples.fdf.SetField; +import org.apache.pdfbox.exceptions.COSVisitorException; +import org.apache.pdfbox.pdmodel.PDDocument; import org.chorem.lima.beans.BalanceTrial; import org.chorem.lima.beans.FinancialStatementAmounts; import org.chorem.lima.beans.GeneralEntryBooksDatas; @@ -72,6 +81,7 @@ import org.nuiton.topia.TopiaNotFoundException; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; + import com.lowagie.text.BadElementException; import com.lowagie.text.Cell; import com.lowagie.text.Chapter; @@ -1439,7 +1449,37 @@ } return t; } - + + //############## VAT ############## + + @Override + public void createVatDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException, IOException, COSVisitorException { + try { + String filePath = + path+File.separator+DocumentsEnum.VAT.getFileName()+format.getExtension(); + + PDDocument doc = null; + InputStream reportsStream = + DocumentServiceImpl.class.getResourceAsStream("/reports/vat_form_fr.pdf"); + // load the document + doc = PDDocument.load(reportsStream); + + PrintFields printFields = new PrintFields(); + printFields.printFields(doc); + SetField fields = new SetField(); + + //address TextField + fields.setField(doc, "a4.a4", "address"); + + // save the updated document to the new file and close + doc.save(filePath); + doc.close(); + + } catch (Exception eee) { + log.error("Can't create VAT form", eee); + } + } + 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/ejb/HttpServerServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2011-06-14 10:33:02 UTC (rev 3175) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/HttpServerServiceImpl.java 2011-06-14 10:39:00 UTC (rev 3176) @@ -46,6 +46,7 @@ import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.pdfbox.exceptions.COSVisitorException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ejbinterface.DocumentService; @@ -168,11 +169,17 @@ documentService.createLedgerDocuments( beginDateFormat, endDateFormat, formatsEnum); break; + case VAT: + documentService.createVatDocuments( + beginDateFormat, endDateFormat, formatsEnum); + break; } } catch (LimaException eeeLE) { log.error("Can't call document service for create html document", eeeLE); } catch (ParseException eeePE) { log.error("Can't parse date", eeePE); + } catch (COSVisitorException eeeCOSVE) { + log.error("Can't create document", eeeCOSVE); } resp.setContentType(formatsEnum.getMimeType()); InputStream in = doc.openStream(); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2011-06-14 10:33:02 UTC (rev 3175) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/DocumentService.java 2011-06-14 10:39:00 UTC (rev 3176) @@ -25,8 +25,11 @@ package org.chorem.lima.business.ejbinterface; +import java.io.IOException; import java.util.Date; import javax.ejb.Remote; + +import org.apache.pdfbox.exceptions.COSVisitorException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.utils.FormatsEnum; @@ -44,5 +47,6 @@ void createEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; void createBalanceDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; void createGeneralEntryBooksDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException; + void createVatDocuments(Date beginDate, Date endDate, FormatsEnum format) throws LimaException, IOException, COSVisitorException;; } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java 2011-06-14 10:33:02 UTC (rev 3175) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java 2011-06-14 10:39:00 UTC (rev 3176) @@ -44,6 +44,7 @@ * <ul> * <li>Balance</li> * <li>Bilan</li> + * <li>TVA</li> * </ul> * * @author chatellier Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2011-06-14 10:33:02 UTC (rev 3175) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/DocumentsEnum.java 2011-06-14 10:39:00 UTC (rev 3176) @@ -34,7 +34,8 @@ ENTRYBOOKS(_("lima-business.document.entrybook"),"lima_entrybooks"), BALANCE(_("lima-business.document.balance"),"lima_balance"), LEDGER(_("lima-business.document.ledger"),"lima_ledger"), - FINANCIALSTATEMENT(_("lima-business.document.financialstatement"),"lima_financialstatements"); + FINANCIALSTATEMENT(_("lima-business.document.financialstatement"),"lima_financialstatements"), + VAT(_("lima-business.document.vat"),"lima_vat"); private final String fileName;
participants (1)
-
vsalaun@users.chorem.org