use of com.axelor.apps.bankpayment.db.BankStatementFileFormat in project axelor-open-suite by axelor.
the class BankReconciliationService method loadBankStatement.
@Transactional
public void loadBankStatement(BankReconciliation bankReconciliation, boolean includeBankStatement) {
BankStatement bankStatement = bankReconciliation.getBankStatement();
BankStatementFileFormat bankStatementFileFormat = bankStatement.getBankStatementFileFormat();
switch(bankStatementFileFormat.getStatementFileFormatSelect()) {
case BankStatementFileFormatRepository.FILE_FORMAT_CAMT_XXX_CFONB120_REP:
case BankStatementFileFormatRepository.FILE_FORMAT_CAMT_XXX_CFONB120_STM:
Beans.get(BankReconciliationLoadAFB120Service.class).loadBankStatement(bankReconciliation, includeBankStatement);
break;
default:
Beans.get(BankReconciliationLoadService.class).loadBankStatement(bankReconciliation, includeBankStatement);
}
compute(bankReconciliation);
bankReconciliationRepository.save(bankReconciliation);
}
use of com.axelor.apps.bankpayment.db.BankStatementFileFormat in project axelor-open-suite by axelor.
the class EbicsController method sendFDLRequest.
public void sendFDLRequest(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
try {
BankStatementFileFormat bankStatementFileFormat = ebicsUser.getTestBankStatementFileFormat();
if (ebicsUser.getEbicsPartner().getTestMode() && bankStatementFileFormat != null) {
Beans.get(EbicsService.class).sendFDLRequest(ebicsUser, null, null, null, bankStatementFileFormat.getStatementFileFormatSelect());
downloadFile(response, ebicsUser);
} else {
response.setFlash(I18n.get(IExceptionMessage.EBICS_TEST_MODE_NOT_ENABLED));
}
} catch (Exception e) {
response.setFlash(stripClass(e.getLocalizedMessage()));
}
response.setReload(true);
}
use of com.axelor.apps.bankpayment.db.BankStatementFileFormat 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.BankStatementFileFormat in project axelor-open-suite by axelor.
the class BankStatementService method runImport.
public void runImport(BankStatement bankStatement, boolean alertIfFormatNotSupported) throws IOException, AxelorException {
bankStatement = find(bankStatement);
if (bankStatement.getBankStatementFile() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.BANK_STATEMENT_MISSING_FILE));
}
if (bankStatement.getBankStatementFileFormat() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.BANK_STATEMENT_MISSING_FILE_FORMAT));
}
BankStatementFileFormat bankStatementFileFormat = bankStatement.getBankStatementFileFormat();
switch(bankStatementFileFormat.getStatementFileFormatSelect()) {
case BankStatementFileFormatRepository.FILE_FORMAT_CAMT_XXX_CFONB120_REP:
case BankStatementFileFormatRepository.FILE_FORMAT_CAMT_XXX_CFONB120_STM:
Beans.get(BankStatementFileAFB120Service.class).process(bankStatement);
updateStatus(bankStatement);
break;
default:
if (alertIfFormatNotSupported) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BANK_STATEMENT_FILE_UNKNOWN_FORMAT));
}
}
}
Aggregations