use of com.axelor.apps.account.db.AccountingBatch in project axelor-open-suite by axelor.
the class BatchCreditTransferPartnerReimbursement method process.
@Override
protected void process() {
AccountingBatch accountingBatch = batch.getAccountingBatch();
// Fetch all partners that have a credit balance for the specified company.
TypedQuery<Partner> partnerQuery = JPA.em().createQuery("SELECT self FROM Partner self JOIN self.accountingSituationList accountingSituation " + "WHERE accountingSituation.company = :company AND accountingSituation.balanceCustAccount < 0", Partner.class);
partnerQuery.setParameter("company", accountingBatch.getCompany());
List<Partner> partnerList = partnerQuery.getResultList();
for (Partner partner : partnerList) {
try {
partner = partnerRepo.find(partner.getId());
Reimbursement reimbursement = createReimbursement(partner, accountingBatch.getCompany());
if (reimbursement != null) {
incrementDone();
}
} catch (Exception ex) {
incrementAnomaly();
TraceBackService.trace(ex, ExceptionOriginRepository.CREDIT_TRANSFER, batch.getId());
ex.printStackTrace();
log.error(String.format("Credit transfer batch for partner credit balance reimbursement: anomaly for partner %s", partner.getName()));
}
JPA.clear();
}
}
Aggregations