Search in sources :

Example 1 with BankOrderFileFormat

use of com.axelor.apps.bankpayment.db.BankOrderFileFormat 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;
}
Also used : BankOrderFileAFB320XCTService(com.axelor.apps.bankpayment.service.bankorder.file.transfer.BankOrderFileAFB320XCTService) AxelorException(com.axelor.exception.AxelorException) MetaFiles(com.axelor.meta.MetaFiles) BankOrderFile00100102Service(com.axelor.apps.bankpayment.service.bankorder.file.transfer.BankOrderFile00100102Service) BankOrderFile00100103Service(com.axelor.apps.bankpayment.service.bankorder.file.transfer.BankOrderFile00100103Service) BankOrderFileAFB160ICTService(com.axelor.apps.bankpayment.service.bankorder.file.transfer.BankOrderFileAFB160ICTService) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) BankOrderFile00800101Service(com.axelor.apps.bankpayment.service.bankorder.file.directdebit.BankOrderFile00800101Service) BankOrderFile00800102Service(com.axelor.apps.bankpayment.service.bankorder.file.directdebit.BankOrderFile00800102Service) BankOrderFileFormat(com.axelor.apps.bankpayment.db.BankOrderFileFormat) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with BankOrderFileFormat

use of com.axelor.apps.bankpayment.db.BankOrderFileFormat in project axelor-open-suite by axelor.

the class EbicsController method sendFULRequest.

public void sendFULRequest(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    try {
        MetaFile testDataMetaFile = ebicsUser.getTestDataFile();
        MetaFile testSignatureMetaFile = ebicsUser.getTestSignatureFile();
        BankOrderFileFormat bankOrderFileFormat = ebicsUser.getTestBankOrderFileFormat();
        if (testDataMetaFile != null && bankOrderFileFormat != null) {
            File testSignatureFile = null;
            if (ebicsUser.getEbicsPartner().getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS && testSignatureMetaFile != null) {
                testSignatureFile = MetaFiles.getPath(testSignatureMetaFile).toFile();
            }
            Beans.get(EbicsService.class).sendFULRequest(ebicsUser, ebicsUser.getTestSignatoryEbicsUser(), null, MetaFiles.getPath(testDataMetaFile).toFile(), bankOrderFileFormat, testSignatureFile);
        } else {
            response.setFlash(I18n.get(IExceptionMessage.EBICS_TEST_MODE_NOT_ENABLED));
        }
    } catch (Exception e) {
        response.setFlash(stripClass(e.getLocalizedMessage()));
    }
    response.setReload(true);
}
Also used : EbicsUserRepository(com.axelor.apps.bankpayment.db.repo.EbicsUserRepository) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) MetaFile(com.axelor.meta.db.MetaFile) BankOrderFileFormat(com.axelor.apps.bankpayment.db.BankOrderFileFormat) File(java.io.File) MetaFile(com.axelor.meta.db.MetaFile) EbicsService(com.axelor.apps.bankpayment.ebics.service.EbicsService) GeneralSecurityException(java.security.GeneralSecurityException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) CertificateEncodingException(java.security.cert.CertificateEncodingException)

Example 3 with BankOrderFileFormat

use of com.axelor.apps.bankpayment.db.BankOrderFileFormat in project axelor-open-suite by axelor.

the class BankOrderCreateService method createBankOrder.

/**
 * Créer un ordre bancaire avec tous les paramètres
 *
 * @param
 * @return
 * @throws AxelorException
 */
public BankOrder createBankOrder(PaymentMode paymentMode, Integer partnerType, LocalDate bankOrderDate, Company senderCompany, BankDetails senderBankDetails, Currency currency, String senderReference, String senderLabel, int technicalOriginSelect) throws AxelorException {
    BankOrderFileFormat bankOrderFileFormat = paymentMode.getBankOrderFileFormat();
    BankOrder bankOrder = new BankOrder();
    bankOrder.setOrderTypeSelect(paymentMode.getOrderTypeSelect());
    bankOrder.setPaymentMode(paymentMode);
    bankOrder.setPartnerTypeSelect(partnerType);
    if (!bankOrderFileFormat.getIsMultiDate()) {
        bankOrder.setBankOrderDate(bankOrderDate);
    }
    bankOrder.setStatusSelect(BankOrderRepository.STATUS_DRAFT);
    bankOrder.setRejectStatusSelect(BankOrderRepository.REJECT_STATUS_NOT_REJECTED);
    bankOrder.setSenderCompany(senderCompany);
    bankOrder.setSenderBankDetails(senderBankDetails);
    EbicsUser signatoryEbicsUser = bankOrderService.getDefaultEbicsUserFromBankDetails(senderBankDetails);
    User signatoryUser = null;
    if (signatoryEbicsUser != null) {
        signatoryUser = signatoryEbicsUser.getAssociatedUser();
        bankOrder.setSignatoryEbicsUser(signatoryEbicsUser);
    }
    if (signatoryUser != null) {
        bankOrder.setSignatoryUser(signatoryUser);
    }
    if (!bankOrderFileFormat.getIsMultiCurrency()) {
        bankOrder.setBankOrderCurrency(currency);
    }
    bankOrder.setCompanyCurrency(senderCompany.getCurrency());
    bankOrder.setSenderReference(senderReference);
    bankOrder.setSenderLabel(senderLabel);
    bankOrder.setBankOrderLineList(new ArrayList<BankOrderLine>());
    bankOrder.setBankOrderFileFormat(bankOrderFileFormat);
    bankOrder.setTechnicalOriginSelect(technicalOriginSelect);
    return bankOrder;
}
Also used : EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) User(com.axelor.auth.db.User) BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) BankOrderFileFormat(com.axelor.apps.bankpayment.db.BankOrderFileFormat) BankOrder(com.axelor.apps.bankpayment.db.BankOrder)

Aggregations

BankOrderFileFormat (com.axelor.apps.bankpayment.db.BankOrderFileFormat)3 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)2 AxelorException (com.axelor.exception.AxelorException)2 File (java.io.File)2 BankOrder (com.axelor.apps.bankpayment.db.BankOrder)1 BankOrderLine (com.axelor.apps.bankpayment.db.BankOrderLine)1 EbicsUserRepository (com.axelor.apps.bankpayment.db.repo.EbicsUserRepository)1 EbicsService (com.axelor.apps.bankpayment.ebics.service.EbicsService)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 User (com.axelor.auth.db.User)1 MetaFiles (com.axelor.meta.MetaFiles)1 MetaFile (com.axelor.meta.db.MetaFile)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1