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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations