use of com.axelor.apps.account.service.payment.PaymentService in project axelor-open-suite by axelor.
the class MoveLineServiceImpl method reconcileMoveLinesWithCacheManagement.
/**
* Method used to reconcile the move line list passed as a parameter
*
* @param moveLineList
*/
@Override
public void reconcileMoveLinesWithCacheManagement(List<MoveLine> moveLineList) {
List<MoveLine> reconciliableCreditMoveLineList = getReconciliableCreditMoveLines(moveLineList);
List<MoveLine> reconciliableDebitMoveLineList = getReconciliableDebitMoveLines(moveLineList);
Map<List<Object>, Pair<List<MoveLine>, List<MoveLine>>> moveLineMap = new HashMap<>();
populateCredit(moveLineMap, reconciliableCreditMoveLineList);
populateDebit(moveLineMap, reconciliableDebitMoveLineList);
Comparator<MoveLine> byDate = Comparator.comparing(MoveLine::getDate);
PaymentService paymentService = Beans.get(PaymentService.class);
for (Pair<List<MoveLine>, List<MoveLine>> moveLineLists : moveLineMap.values()) {
try {
moveLineLists = this.findMoveLineLists(moveLineLists);
this.useExcessPaymentOnMoveLinesDontThrow(byDate, paymentService, moveLineLists);
} catch (Exception e) {
TraceBackService.trace(e);
log.debug(e.getMessage());
} finally {
JPA.clear();
}
}
}
use of com.axelor.apps.account.service.payment.PaymentService in project axelor-open-suite by axelor.
the class MoveLineServiceImpl method reconcileMoveLines.
@Override
@Transactional
public void reconcileMoveLines(List<MoveLine> moveLineList) {
List<MoveLine> reconciliableCreditMoveLineList = getReconciliableCreditMoveLines(moveLineList);
List<MoveLine> reconciliableDebitMoveLineList = getReconciliableDebitMoveLines(moveLineList);
Map<List<Object>, Pair<List<MoveLine>, List<MoveLine>>> moveLineMap = new HashMap<>();
populateCredit(moveLineMap, reconciliableCreditMoveLineList);
populateDebit(moveLineMap, reconciliableDebitMoveLineList);
Comparator<MoveLine> byDate = Comparator.comparing(MoveLine::getDate);
PaymentService paymentService = Beans.get(PaymentService.class);
for (Pair<List<MoveLine>, List<MoveLine>> moveLineLists : moveLineMap.values()) {
List<MoveLine> companyPartnerCreditMoveLineList = moveLineLists.getLeft();
List<MoveLine> companyPartnerDebitMoveLineList = moveLineLists.getRight();
companyPartnerCreditMoveLineList.sort(byDate);
companyPartnerDebitMoveLineList.sort(byDate);
paymentService.useExcessPaymentOnMoveLinesDontThrow(companyPartnerDebitMoveLineList, companyPartnerCreditMoveLineList);
}
}
Aggregations