Search in sources :

Example 11 with EbicsUser

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

the class EbicsController method sendINIRequest.

public void sendINIRequest(ActionRequest request, ActionResponse response) {
    EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
    try {
        Beans.get(EbicsService.class).sendINIRequest(ebicsUser, null);
    } catch (Exception e) {
        e.printStackTrace();
        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) 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 12 with EbicsUser

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

the class NoPubKeyDigestsRequestElement method build.

@Override
public void build() throws AxelorException {
    EbicsNoPubKeyDigestsRequest request;
    Body body;
    Header header;
    EmptyMutableHeaderType mutable;
    NoPubKeyDigestsRequestStaticHeaderType xstatic;
    ProductElementType product;
    OrderDetailsType orderDetails;
    EbicsUser ebicsUser = session.getUser();
    EbicsPartner ebicsPartner = ebicsUser.getEbicsPartner();
    OrderAttribute orderAttribute = new OrderAttribute(OrderType.HPB, ebicsPartner.getEbicsTypeSelect());
    orderAttribute.build();
    product = EbicsXmlFactory.creatProductElementType(session.getProduct().getLanguage(), session.getProduct().getName());
    orderDetails = EbicsXmlFactory.createOrderDetailsType(orderAttribute.getOrderAttributes(), null, OrderType.HPB.getOrderType());
    xstatic = EbicsXmlFactory.createNoPubKeyDigestsRequestStaticHeaderType(session.getBankID(), EbicsUtils.generateNonce(), Calendar.getInstance(), ebicsPartner.getPartnerId(), ebicsUser.getUserId(), product, orderDetails, ebicsUser.getSecurityMedium());
    mutable = EbicsXmlFactory.createEmptyMutableHeaderType();
    header = EbicsXmlFactory.createDigestsRequestHeader(true, mutable, xstatic);
    body = EbicsXmlFactory.createDigestsRequestBody();
    request = EbicsXmlFactory.createEbicsNoPubKeyDigestsRequest(1, "H003", header, body);
    document = EbicsXmlFactory.createEbicsNoPubKeyDigestsRequestDocument(request);
}
Also used : OrderDetailsType(com.axelor.apps.account.ebics.schema.h003.OrderDetailsType) Header(com.axelor.apps.account.ebics.schema.h003.EbicsNoPubKeyDigestsRequestDocument.EbicsNoPubKeyDigestsRequest.Header) EbicsNoPubKeyDigestsRequest(com.axelor.apps.account.ebics.schema.h003.EbicsNoPubKeyDigestsRequestDocument.EbicsNoPubKeyDigestsRequest) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) OrderAttribute(com.axelor.apps.bankpayment.ebics.client.OrderAttribute) ProductElementType(com.axelor.apps.account.ebics.schema.h003.ProductElementType) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner) Body(com.axelor.apps.account.ebics.schema.h003.EbicsNoPubKeyDigestsRequestDocument.EbicsNoPubKeyDigestsRequest.Body) NoPubKeyDigestsRequestStaticHeaderType(com.axelor.apps.account.ebics.schema.h003.NoPubKeyDigestsRequestStaticHeaderType) EmptyMutableHeaderType(com.axelor.apps.account.ebics.schema.h003.EmptyMutableHeaderType)

Example 13 with EbicsUser

use of com.axelor.apps.bankpayment.db.EbicsUser 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 14 with EbicsUser

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

the class EbicsService method makeDN.

public String makeDN(EbicsUser ebicsUser) {
    String email = null;
    String companyName = defaultProduct.getInstituteID();
    User user = ebicsUser.getAssociatedUser();
    if (user != null) {
        email = user.getEmail();
        if (user.getActiveCompany() != null) {
            companyName = user.getActiveCompany().getName();
        }
    }
    return makeDN(ebicsUser.getName(), email, "FR", companyName);
}
Also used : EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) User(com.axelor.auth.db.User)

Example 15 with EbicsUser

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

the class EbicsUserService method getNextOrderId.

@Transactional
public String getNextOrderId(EbicsUser user) throws AxelorException {
    String orderId = user.getNextOrderId();
    if (orderId == null) {
        EbicsPartner partner = user.getEbicsPartner();
        EbicsUser otherUser = ebicsUserRepo.all().filter("self.ebicsPartner = ?1 and self.id != ?2 and self.nextOrderId != null", partner, user.getId()).order("-nextOrderId").fetchOne();
        char firstLetter = 'A';
        if (otherUser != null) {
            String otherOrderId = otherUser.getNextOrderId();
            firstLetter = otherOrderId.charAt(0);
            firstLetter++;
        }
        orderId = String.valueOf(firstLetter) + "000";
        user.setNextOrderId(orderId);
        ebicsUserRepo.save(user);
    } else {
        orderId = getNextOrderNumber(orderId);
        user.setNextOrderId(orderId);
        ebicsUserRepo.save(user);
    }
    return orderId;
}
Also used : EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner) Transactional(com.google.inject.persist.Transactional)

Aggregations

EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)27 AxelorException (com.axelor.exception.AxelorException)13 EbicsUserRepository (com.axelor.apps.bankpayment.db.repo.EbicsUserRepository)12 IOException (java.io.IOException)12 GeneralSecurityException (java.security.GeneralSecurityException)10 EbicsService (com.axelor.apps.bankpayment.ebics.service.EbicsService)9 CertificateEncodingException (java.security.cert.CertificateEncodingException)9 CertificateException (java.security.cert.CertificateException)9 EbicsPartner (com.axelor.apps.bankpayment.db.EbicsPartner)6 OrderAttribute (com.axelor.apps.bankpayment.ebics.client.OrderAttribute)4 EbicsRequest (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest)3 Body (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)3 Header (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header)3 MutableHeaderType (com.axelor.apps.account.ebics.schema.h003.MutableHeaderType)3 StaticHeaderOrderDetailsType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType)3 OrderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType.OrderType)3 StaticHeaderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType)3 BankPubKeyDigests (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests)3 Authentication (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Authentication)3 Encryption (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Encryption)3