use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class EbicsController method generateDn.
public void generateDn(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
response.setValue("dn", Beans.get(EbicsService.class).makeDN(ebicsUser));
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class DInitializationRequestElement 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;
OrderType orderType;
StaticHeaderOrderDetailsType orderDetails;
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());
EbicsUser ebicsUser = session.getUser();
EbicsPartner ebicsPartner = ebicsUser.getEbicsPartner();
OrderAttribute orderAttribute = new OrderAttribute(type, ebicsPartner.getEbicsTypeSelect());
orderAttribute.build();
if (type.equals(com.axelor.apps.bankpayment.ebics.client.OrderType.FDL)) {
FDLOrderParamsType fDLOrderParamsType;
FileFormatType fileFormat;
fileFormat = EbicsXmlFactory.createFileFormatType(Locale.FRANCE.getCountry().toUpperCase(), session.getSessionParam("FORMAT"));
fDLOrderParamsType = EbicsXmlFactory.createFDLOrderParamsType(fileFormat);
if (startRange != null && endRange != null) {
DateRange range;
range = EbicsXmlFactory.createDateRange(startRange, endRange);
fDLOrderParamsType.setDateRange(range);
}
if (Boolean.getBoolean(session.getSessionParam("TEST"))) {
Parameter parameter;
Value value;
value = EbicsXmlFactory.createValue("String", "TRUE");
parameter = EbicsXmlFactory.createParameter("TEST", value);
fDLOrderParamsType.setParameterArray(new Parameter[] { parameter });
}
orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, fDLOrderParamsType);
} else {
StandardOrderParamsType standardOrderParamsType;
standardOrderParamsType = EbicsXmlFactory.createStandardOrderParamsType();
// FIXME Some banks cannot handle OrderID element in download process. Add parameter in
// configuration!!!
orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(// session.getUser().getPartner().nextOrderId(),
ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, standardOrderParamsType);
}
xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), nonce, ebicsPartner.getPartnerId(), product, ebicsUser.getSecurityMedium(), ebicsUser.getUserId(), Calendar.getInstance(), orderDetails, bankPubKeyDigests);
header = EbicsXmlFactory.createEbicsRequestHeader(true, mutable, xstatic);
body = EbicsXmlFactory.createEbicsRequestBody();
request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
document = EbicsXmlFactory.createEbicsRequestDocument(request);
}
use of com.axelor.apps.bankpayment.db.EbicsUser 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;
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class BankOrderServiceImpl method sendFile.
protected void sendFile(BankOrder bankOrder, File dataFileToSend, File signatureFileToSend) throws AxelorException {
PaymentMode paymentMode = bankOrder.getPaymentMode();
if (paymentMode != null && !paymentMode.getAutomaticTransmission()) {
return;
}
EbicsUser signatoryEbicsUser = bankOrder.getSignatoryEbicsUser();
ebicsService.sendFULRequest(signatoryEbicsUser.getEbicsPartner().getTransportEbicsUser(), signatoryEbicsUser, null, dataFileToSend, bankOrder.getBankOrderFileFormat(), signatureFileToSend);
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class BankOrderServiceImpl method makeEbicsUserFollow.
/**
* The signatory ebics user will follow the bank order record
*
* @param bankOrder
*/
protected void makeEbicsUserFollow(BankOrder bankOrder) {
EbicsUser ebicsUser = bankOrder.getSignatoryEbicsUser();
if (ebicsUser != null) {
User signatoryUser = ebicsUser.getAssociatedUser();
Beans.get(MailFollowerRepository.class).follow(bankOrder, signatoryUser);
}
}
Aggregations