Search in sources :

Example 1 with BankStatementFileFormat

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

the class BankReconciliationService method loadBankStatement.

@Transactional
public void loadBankStatement(BankReconciliation bankReconciliation, boolean includeBankStatement) {
    BankStatement bankStatement = bankReconciliation.getBankStatement();
    BankStatementFileFormat bankStatementFileFormat = bankStatement.getBankStatementFileFormat();
    switch(bankStatementFileFormat.getStatementFileFormatSelect()) {
        case BankStatementFileFormatRepository.FILE_FORMAT_CAMT_XXX_CFONB120_REP:
        case BankStatementFileFormatRepository.FILE_FORMAT_CAMT_XXX_CFONB120_STM:
            Beans.get(BankReconciliationLoadAFB120Service.class).loadBankStatement(bankReconciliation, includeBankStatement);
            break;
        default:
            Beans.get(BankReconciliationLoadService.class).loadBankStatement(bankReconciliation, includeBankStatement);
    }
    compute(bankReconciliation);
    bankReconciliationRepository.save(bankReconciliation);
}
Also used : BankReconciliationLoadAFB120Service(com.axelor.apps.bankpayment.service.bankreconciliation.load.afb120.BankReconciliationLoadAFB120Service) BankStatement(com.axelor.apps.bankpayment.db.BankStatement) BankReconciliationLoadService(com.axelor.apps.bankpayment.service.bankreconciliation.load.BankReconciliationLoadService) BankStatementFileFormat(com.axelor.apps.bankpayment.db.BankStatementFileFormat) Transactional(com.google.inject.persist.Transactional)

Example 2 with BankStatementFileFormat

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

the class EbicsController method sendFDLRequest.

public void sendFDLRequest(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    try {
        BankStatementFileFormat bankStatementFileFormat = ebicsUser.getTestBankStatementFileFormat();
        if (ebicsUser.getEbicsPartner().getTestMode() && bankStatementFileFormat != null) {
            Beans.get(EbicsService.class).sendFDLRequest(ebicsUser, null, null, null, bankStatementFileFormat.getStatementFileFormatSelect());
            downloadFile(response, ebicsUser);
        } 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) BankStatementFileFormat(com.axelor.apps.bankpayment.db.BankStatementFileFormat) 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 BankStatementFileFormat

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

the class EbicsPartnerServiceImpl method getBankStatements.

@Transactional
public List<BankStatement> getBankStatements(EbicsPartner ebicsPartner, Collection<BankStatementFileFormat> bankStatementFileFormatCollection) throws AxelorException, IOException {
    List<BankStatement> bankStatementList = Lists.newArrayList();
    EbicsUser transportEbicsUser = ebicsPartner.getTransportEbicsUser();
    if (ebicsPartner.getBsEbicsPartnerServiceList() == null || ebicsPartner.getBsEbicsPartnerServiceList().isEmpty() || transportEbicsUser == null) {
        return bankStatementList;
    }
    LocalDateTime executionDateTime = LocalDateTime.now();
    Date startDate = null;
    Date endDate = null;
    LocalDate bankStatementStartDate = null;
    LocalDate bankStatementToDate = null;
    if (ebicsPartner.getBankStatementGetModeSelect() == EbicsPartnerRepository.GET_MODE_PERIOD) {
        bankStatementStartDate = ebicsPartner.getBankStatementStartDate();
        if (bankStatementStartDate != null) {
            startDate = DateTool.toDate(bankStatementStartDate);
        }
        bankStatementToDate = ebicsPartner.getBankStatementEndDate();
        if (bankStatementToDate != null) {
            endDate = DateTool.toDate(bankStatementToDate);
        }
    } else {
        if (ebicsPartner.getBankStatementLastExeDateT() != null) {
            bankStatementStartDate = ebicsPartner.getBankStatementLastExeDateT().toLocalDate();
        }
        bankStatementToDate = executionDateTime.toLocalDate();
    }
    for (com.axelor.apps.bankpayment.db.EbicsPartnerService bsEbicsPartnerService : ebicsPartner.getBsEbicsPartnerServiceList()) {
        BankStatementFileFormat bankStatementFileFormat = bsEbicsPartnerService.getBankStatementFileFormat();
        if (bankStatementFileFormatCollection != null && !bankStatementFileFormatCollection.isEmpty() && !bankStatementFileFormatCollection.contains(bankStatementFileFormat)) {
            continue;
        }
        try {
            File file = ebicsService.sendFDLRequest(transportEbicsUser, null, startDate, endDate, bsEbicsPartnerService.getEbicsCodification());
            BankStatement bankStatement = bankStatementCreateService.createBankStatement(file, bankStatementStartDate, bankStatementToDate, bankStatementFileFormat, ebicsPartner, executionDateTime);
            bankStatementRepository.save(bankStatement);
            bankStatementList.add(bankStatement);
        } catch (Exception e) {
            TraceBackService.trace(e);
        }
    }
    ebicsPartner.setBankStatementLastExeDateT(executionDateTime);
    Beans.get(EbicsPartnerRepository.class).save(ebicsPartner);
    return bankStatementList;
}
Also used : LocalDateTime(java.time.LocalDateTime) BankStatement(com.axelor.apps.bankpayment.db.BankStatement) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) LocalDate(java.time.LocalDate) Date(java.util.Date) LocalDate(java.time.LocalDate) BankStatementFileFormat(com.axelor.apps.bankpayment.db.BankStatementFileFormat) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) File(java.io.File) EbicsPartnerRepository(com.axelor.apps.bankpayment.db.repo.EbicsPartnerRepository) Transactional(com.google.inject.persist.Transactional)

Example 4 with BankStatementFileFormat

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

the class BankStatementService method runImport.

public void runImport(BankStatement bankStatement, boolean alertIfFormatNotSupported) throws IOException, AxelorException {
    bankStatement = find(bankStatement);
    if (bankStatement.getBankStatementFile() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.BANK_STATEMENT_MISSING_FILE));
    }
    if (bankStatement.getBankStatementFileFormat() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.BANK_STATEMENT_MISSING_FILE_FORMAT));
    }
    BankStatementFileFormat bankStatementFileFormat = bankStatement.getBankStatementFileFormat();
    switch(bankStatementFileFormat.getStatementFileFormatSelect()) {
        case BankStatementFileFormatRepository.FILE_FORMAT_CAMT_XXX_CFONB120_REP:
        case BankStatementFileFormatRepository.FILE_FORMAT_CAMT_XXX_CFONB120_STM:
            Beans.get(BankStatementFileAFB120Service.class).process(bankStatement);
            updateStatus(bankStatement);
            break;
        default:
            if (alertIfFormatNotSupported) {
                throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BANK_STATEMENT_FILE_UNKNOWN_FORMAT));
            }
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) BankStatementFileFormat(com.axelor.apps.bankpayment.db.BankStatementFileFormat) BankStatementFileAFB120Service(com.axelor.apps.bankpayment.service.bankstatement.file.afb120.BankStatementFileAFB120Service)

Aggregations

BankStatementFileFormat (com.axelor.apps.bankpayment.db.BankStatementFileFormat)4 AxelorException (com.axelor.exception.AxelorException)3 BankStatement (com.axelor.apps.bankpayment.db.BankStatement)2 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)2 Transactional (com.google.inject.persist.Transactional)2 IOException (java.io.IOException)2 EbicsPartnerRepository (com.axelor.apps.bankpayment.db.repo.EbicsPartnerRepository)1 EbicsUserRepository (com.axelor.apps.bankpayment.db.repo.EbicsUserRepository)1 EbicsService (com.axelor.apps.bankpayment.ebics.service.EbicsService)1 BankReconciliationLoadService (com.axelor.apps.bankpayment.service.bankreconciliation.load.BankReconciliationLoadService)1 BankReconciliationLoadAFB120Service (com.axelor.apps.bankpayment.service.bankreconciliation.load.afb120.BankReconciliationLoadAFB120Service)1 BankStatementFileAFB120Service (com.axelor.apps.bankpayment.service.bankstatement.file.afb120.BankStatementFileAFB120Service)1 File (java.io.File)1 GeneralSecurityException (java.security.GeneralSecurityException)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1 CertificateException (java.security.cert.CertificateException)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 Date (java.util.Date)1