use of com.axelor.apps.bankpayment.service.bankorder.file.directdebit.BankOrderFile00800102Service in project axelor-open-suite by axelor.
the class BankOrderServiceImpl method generateFile.
@Override
public File generateFile(BankOrder bankOrder) throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
if (bankOrder.getBankOrderLineList() == null || bankOrder.getBankOrderLineList().isEmpty()) {
return null;
}
bankOrder.setFileGenerationDateTime(LocalDateTime.now());
BankOrderFileFormat bankOrderFileFormat = bankOrder.getBankOrderFileFormat();
File file = null;
switch(bankOrderFileFormat.getOrderFileFormatSelect()) {
case BankOrderFileFormatRepository.FILE_FORMAT_PAIN_001_001_02_SCT:
file = new BankOrderFile00100102Service(bankOrder).generateFile();
break;
case BankOrderFileFormatRepository.FILE_FORMAT_PAIN_001_001_03_SCT:
file = new BankOrderFile00100103Service(bankOrder).generateFile();
break;
case BankOrderFileFormatRepository.FILE_FORMAT_PAIN_XXX_CFONB320_XCT:
file = new BankOrderFileAFB320XCTService(bankOrder).generateFile();
break;
case BankOrderFileFormatRepository.FILE_FORMAT_PAIN_XXX_CFONB160_ICT:
file = new BankOrderFileAFB160ICTService(bankOrder).generateFile();
break;
case BankOrderFileFormatRepository.FILE_FORMAT_PAIN_008_001_01_SDD:
file = new BankOrderFile00800101Service(bankOrder, BankOrderFile008Service.SEPA_TYPE_CORE).generateFile();
break;
case BankOrderFileFormatRepository.FILE_FORMAT_PAIN_008_001_01_SBB:
file = new BankOrderFile00800101Service(bankOrder, BankOrderFile008Service.SEPA_TYPE_SBB).generateFile();
break;
case BankOrderFileFormatRepository.FILE_FORMAT_PAIN_008_001_02_SDD:
file = new BankOrderFile00800102Service(bankOrder, BankOrderFile008Service.SEPA_TYPE_CORE).generateFile();
break;
case BankOrderFileFormatRepository.FILE_FORMAT_PAIN_008_001_02_SBB:
file = new BankOrderFile00800102Service(bankOrder, BankOrderFile008Service.SEPA_TYPE_SBB).generateFile();
break;
default:
throw new AxelorException(bankOrder, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BANK_ORDER_FILE_UNKNOWN_FORMAT));
}
if (file == null) {
throw new AxelorException(bankOrder, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BANK_ORDER_ISSUE_DURING_FILE_GENERATION), bankOrder.getBankOrderSeq());
}
MetaFiles metaFiles = Beans.get(MetaFiles.class);
try (InputStream is = new FileInputStream(file)) {
metaFiles.attach(is, file.getName(), bankOrder);
bankOrder.setGeneratedMetaFile(metaFiles.upload(file));
}
return file;
}
Aggregations