use of com.axelor.apps.bankpayment.db.BankStatement 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.BankStatement in project axelor-open-suite by axelor.
the class EbicsPartnerController method getBankStatement.
public void getBankStatement(ActionRequest request, ActionResponse response) {
try {
EbicsPartner ebicsPartner = request.getContext().asType(EbicsPartner.class);
List<BankStatement> bankStatementList = Beans.get(EbicsPartnerService.class).getBankStatements(Beans.get(EbicsPartnerRepository.class).find(ebicsPartner.getId()));
response.setFlash(String.format(I18n.get("%s bank statements get."), bankStatementList.size()));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
response.setReload(true);
}
use of com.axelor.apps.bankpayment.db.BankStatement 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);
}
}
}
use of com.axelor.apps.bankpayment.db.BankStatement in project axelor-open-suite by axelor.
the class BankStatementController method runImport.
public void runImport(ActionRequest request, ActionResponse response) {
try {
BankStatement bankStatement = request.getContext().asType(BankStatement.class);
bankStatement = Beans.get(BankStatementRepository.class).find(bankStatement.getId());
Beans.get(BankStatementService.class).runImport(bankStatement, true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
response.setReload(true);
}
Aggregations