Search in sources :

Example 6 with MetaFiles

use of com.axelor.meta.MetaFiles in project axelor-open-suite by axelor.

the class InvoicePrintServiceImpl method printAndSave.

public File printAndSave(Invoice invoice, Integer reportType, String format, String locale) throws AxelorException {
    ReportSettings reportSettings = prepareReportSettings(invoice, reportType, format, locale);
    MetaFile metaFile;
    reportSettings.toAttach(invoice);
    File file = reportSettings.generate().getFile();
    try {
        MetaFiles metaFiles = Beans.get(MetaFiles.class);
        metaFile = metaFiles.upload(file);
        metaFile.setFileName(String.format("%s.%s", reportSettings.getOutputName(), format));
        invoice.setPrintedPDF(metaFile);
        return MetaFiles.getPath(metaFile).toFile();
    } catch (IOException e) {
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVOICE_PRINTING_IO_ERROR) + " " + e.getLocalizedMessage());
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) MetaFiles(com.axelor.meta.MetaFiles) ReportSettings(com.axelor.apps.report.engine.ReportSettings) MetaFile(com.axelor.meta.db.MetaFile) IOException(java.io.IOException) File(java.io.File) MetaFile(com.axelor.meta.db.MetaFile)

Aggregations

MetaFiles (com.axelor.meta.MetaFiles)6 MetaFile (com.axelor.meta.db.MetaFile)5 File (java.io.File)4 ReportSettings (com.axelor.apps.report.engine.ReportSettings)2 AxelorException (com.axelor.exception.AxelorException)2 Transactional (com.google.inject.persist.Transactional)2 ArrayList (java.util.ArrayList)2 Invoice (com.axelor.apps.account.db.Invoice)1 BankOrderFileFormat (com.axelor.apps.bankpayment.db.BankOrderFileFormat)1 BankOrderFile00800101Service (com.axelor.apps.bankpayment.service.bankorder.file.directdebit.BankOrderFile00800101Service)1 BankOrderFile00800102Service (com.axelor.apps.bankpayment.service.bankorder.file.directdebit.BankOrderFile00800102Service)1 BankOrderFile00100102Service (com.axelor.apps.bankpayment.service.bankorder.file.transfer.BankOrderFile00100102Service)1 BankOrderFile00100103Service (com.axelor.apps.bankpayment.service.bankorder.file.transfer.BankOrderFile00100103Service)1 BankOrderFileAFB160ICTService (com.axelor.apps.bankpayment.service.bankorder.file.transfer.BankOrderFileAFB160ICTService)1 BankOrderFileAFB320XCTService (com.axelor.apps.bankpayment.service.bankorder.file.transfer.BankOrderFileAFB320XCTService)1 Print (com.axelor.apps.base.db.Print)1 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 EmploymentContract (com.axelor.apps.hr.db.EmploymentContract)1 EmploymentContractService (com.axelor.apps.hr.service.EmploymentContractService)1 Message (com.axelor.apps.message.db.Message)1