use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class BatchEbicsCertificate method process.
@Override
protected void process() {
Template template = templateRepo.find(bankPaymentBatch.getTemplate().getId());
List<EbicsUser> users = Beans.get(EbicsUserRepository.class).all().filter("self.a005Certificate != null OR self.e002Certificate != null OR self.x002Certificate != null").fetch();
Set<EbicsCertificate> certificatesSet = new HashSet<>();
LocalDate today = Beans.get(AppBaseService.class).getTodayDate(bankPaymentBatch.getCompany());
LocalDate commingDay = today.plusDays(bankPaymentBatch.getDaysNbr());
for (EbicsUser user : users) {
if (user.getA005Certificate() != null && user.getA005Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getA005Certificate());
}
if (user.getE002Certificate() != null && user.getE002Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getE002Certificate());
}
if (user.getX002Certificate() != null && user.getX002Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getX002Certificate());
}
}
certificatesSet.addAll(Beans.get(EbicsCertificateRepository.class).all().filter("self.ebicsBank != null AND self.validTo <= ?1", commingDay).fetch());
for (EbicsCertificate certificate : certificatesSet) {
certificate.addBatchSetItem(batchRepo.find(batch.getId()));
try {
templateMessageService.generateMessage(certificate, template);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | AxelorException | IOException e) {
e.printStackTrace();
}
}
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class BankOrderController method validate.
public void validate(ActionRequest request, ActionResponse response) throws AxelorException {
Context context = request.getContext();
BankOrderService bankOrderService = Beans.get(BankOrderService.class);
BankOrder bankOrder = context.asType(BankOrder.class);
bankOrder = Beans.get(BankOrderRepository.class).find(bankOrder.getId());
try {
EbicsUser ebicsUser = bankOrder.getSignatoryEbicsUser();
if (ebicsUser == null) {
response.setError(I18n.get(IExceptionMessage.EBICS_MISSING_NAME));
} else {
if (ebicsUser.getEbicsPartner().getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS) {
bankOrderService.validate(bankOrder);
} else {
if (context.get("password") == null) {
response.setError(I18n.get(IExceptionMessage.EBICS_WRONG_PASSWORD));
}
if (context.get("password") != null) {
String password = (String) context.get("password");
if (ebicsUser.getPassword() == null || !ebicsUser.getPassword().equals(password)) {
response.setValue("password", "");
response.setError(I18n.get(IExceptionMessage.EBICS_WRONG_PASSWORD));
} else {
bankOrderService.validate(bankOrder);
}
}
response.setReload(true);
}
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class EbicsController method updateEditionDate.
public void updateEditionDate(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = request.getContext().asType(EbicsUser.class);
ebicsUser = Beans.get(EbicsUserRepository.class).find(ebicsUser.getId());
Beans.get(EbicsCertificateService.class).updateEditionDate(ebicsUser);
response.setReload(true);
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class EbicsController method sendHPBRequest.
public void sendHPBRequest(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
try {
X509Certificate[] certificates = Beans.get(EbicsService.class).sendHPBRequest(ebicsUser, null);
confirmCertificates(ebicsUser, certificates, response);
} 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 EbicsController method sendSPRRequest.
public void sendSPRRequest(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
try {
Beans.get(EbicsService.class).sendSPRRequest(ebicsUser, null);
} catch (Exception e) {
e.printStackTrace();
response.setFlash(stripClass(e.getLocalizedMessage()));
}
response.setReload(true);
}
Aggregations