use of com.axelor.apps.bankpayment.db.EbicsPartner in project axelor-open-suite by axelor.
the class BankOrderLineService method createDomainForBankDetails.
public String createDomainForBankDetails(BankOrderLine bankOrderLine, BankOrder bankOrder) {
String domain = "";
String bankDetailsIds = "";
if ((bankOrderLine == null) || (bankOrder == null)) {
return domain;
}
// the case where the bank order is for a company
if (bankOrder.getPartnerTypeSelect() == BankOrderRepository.PARTNER_TYPE_COMPANY) {
if (bankOrderLine.getReceiverCompany() != null) {
bankDetailsIds = StringTool.getIdListString(bankOrderLine.getReceiverCompany().getBankDetailsList());
if (bankOrderLine.getReceiverCompany().getDefaultBankDetails() != null) {
bankDetailsIds += bankDetailsIds.equals("") ? "" : ",";
bankDetailsIds += bankOrderLine.getReceiverCompany().getDefaultBankDetails().getId().toString();
}
}
} else // case where the bank order is for a partner
if (bankOrderLine.getPartner() != null) {
bankDetailsIds = StringTool.getIdListString(bankOrderLine.getPartner().getBankDetailsList());
}
if (bankDetailsIds.equals("")) {
return domain = "";
}
domain = "self.id IN(" + bankDetailsIds + ")";
// filter the result on active bank details
domain += " AND self.active = true";
// filter on the result from bankPartner if the option is active.
EbicsPartner ebicsPartner = Beans.get(EbicsPartnerRepository.class).all().filter("? MEMBER OF self.bankDetailsSet", bankOrder.getSenderBankDetails()).fetchOne();
if (ebicsPartnerIsFiltering(ebicsPartner, bankOrder.getOrderTypeSelect())) {
domain += " AND self.id IN (" + StringTool.getIdListString(ebicsPartner.getReceiverBankDetailsSet()) + ")";
}
// filter on the bank details identifier type from the bank order file format
if (bankOrder.getBankOrderFileFormat() != null) {
String acceptedIdentifiers = bankOrder.getBankOrderFileFormat().getBankDetailsTypeSelect();
if (acceptedIdentifiers != null && !acceptedIdentifiers.equals("")) {
domain += " AND self.bank.bankDetailsTypeSelect IN (" + acceptedIdentifiers + ")";
}
}
// filter on the currency if it is set in bank order and in the bankdetails
// and if the bankOrder is not multicurrency
// and if the partner type select is a company
Currency currency = bankOrder.getBankOrderCurrency();
if (!bankOrder.getIsMultiCurrency() && currency != null && bankOrder.getPartnerTypeSelect() == BankOrderRepository.PARTNER_TYPE_COMPANY) {
String fileFormatCurrencyId = currency.getId().toString();
domain += " AND (self.currency IS NULL OR self.currency.id = " + fileFormatCurrencyId + ")";
}
return domain;
}
use of com.axelor.apps.bankpayment.db.EbicsPartner in project axelor-open-suite by axelor.
the class SPRRequestElement method buildInitialization.
@Override
public void buildInitialization() throws AxelorException {
EbicsRequest request;
Header header;
Body body;
MutableHeaderType mutable;
StaticHeaderType xstatic;
Product product;
BankPubKeyDigests bankPubKeyDigests;
Authentication authentication;
Encryption encryption;
DataTransferRequestType dataTransfer;
DataEncryptionInfo dataEncryptionInfo;
SignatureData signatureData;
EncryptionPubKeyDigest encryptionPubKeyDigest;
StaticHeaderOrderDetailsType orderDetails;
OrderType orderType;
StandardOrderParamsType standardOrderParamsType;
UserSignature userSignature;
EbicsUser ebicsUser = session.getUser();
EbicsPartner ebicsPartner = ebicsUser.getEbicsPartner();
userSignature = new UserSignature(ebicsUser, generateName("SIG"), "A005", " ".getBytes(), " ".getBytes());
// TODO Manage the ebics ts case, with an eletronic signature of the user
userSignature.build();
userSignature.validate();
mutable = EbicsXmlFactory.createMutableHeaderType("Initialisation", null);
product = EbicsXmlFactory.createProduct(session.getProduct().getLanguage(), session.getProduct().getName());
authentication = EbicsXmlFactory.createAuthentication("X002", "http://www.w3.org/2001/04/xmlenc#sha256", decodeHex(KeyUtil.getKeyDigest(session.getBankX002Key())));
encryption = EbicsXmlFactory.createEncryption("E002", "http://www.w3.org/2001/04/xmlenc#sha256", decodeHex(KeyUtil.getKeyDigest(session.getBankE002Key())));
bankPubKeyDigests = EbicsXmlFactory.createBankPubKeyDigests(authentication, encryption);
orderType = EbicsXmlFactory.createOrderType(type.getOrderType());
standardOrderParamsType = EbicsXmlFactory.createStandardOrderParamsType();
OrderAttribute orderAttribute = new OrderAttribute(type, ebicsPartner.getEbicsTypeSelect());
orderAttribute.build();
orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, standardOrderParamsType);
xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), nonce, 0, ebicsPartner.getPartnerId(), product, ebicsUser.getSecurityMedium(), ebicsUser.getUserId(), Calendar.getInstance(), orderDetails, bankPubKeyDigests);
header = EbicsXmlFactory.createEbicsRequestHeader(true, mutable, xstatic);
encryptionPubKeyDigest = EbicsXmlFactory.createEncryptionPubKeyDigest("E002", "http://www.w3.org/2001/04/xmlenc#sha256", decodeHex(KeyUtil.getKeyDigest(session.getBankX002Key())));
signatureData = EbicsXmlFactory.createSignatureData(true, EbicsUtils.encrypt(EbicsUtils.zip(userSignature.prettyPrint()), keySpec));
dataEncryptionInfo = EbicsXmlFactory.createDataEncryptionInfo(true, encryptionPubKeyDigest, generateTransactionKey());
dataTransfer = EbicsXmlFactory.createDataTransferRequestType(dataEncryptionInfo, signatureData);
body = EbicsXmlFactory.createEbicsRequestBody(dataTransfer);
request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
document = EbicsXmlFactory.createEbicsRequestDocument(request);
}
use of com.axelor.apps.bankpayment.db.EbicsPartner in project axelor-open-suite by axelor.
the class BatchBankStatement method process.
@Override
protected void process() {
BankPaymentBatch bankPaymentBatch = batch.getBankPaymentBatch();
Collection<EbicsPartner> ebicsPartners = bankPaymentBatch.getEbicsPartnerSet();
// on the batch.
if (ebicsPartners == null || ebicsPartners.isEmpty()) {
ebicsPartners = getAllActiveEbicsPartners();
}
for (EbicsPartner ebicsPartner : ebicsPartners) {
try {
List<BankStatement> bankStatementList = ebicsPartnerService.getBankStatements(ebicsPartnerRepository.find(ebicsPartner.getId()), bankPaymentBatch.getBankStatementFileFormatSet());
bankStatementCount += bankStatementList.size();
for (BankStatement bankStatement : bankStatementList) {
try {
bankStatementService.runImport(bankStatement, false);
} catch (AxelorException e) {
processError(e, e.getCategory(), ebicsPartner);
} finally {
JPA.clear();
}
}
incrementDone();
} catch (AxelorException e) {
processError(e, e.getCategory(), ebicsPartner);
} catch (Exception e) {
processError(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, ebicsPartner);
}
}
}
Aggregations