Search in sources :

Example 1 with PaymentService

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();
        }
    }
}
Also used : HashMap(java.util.HashMap) TaxPaymentMoveLine(com.axelor.apps.account.db.TaxPaymentMoveLine) MoveLine(com.axelor.apps.account.db.MoveLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) List(java.util.List) ArrayList(java.util.ArrayList) PaymentService(com.axelor.apps.account.service.payment.PaymentService) AxelorException(com.axelor.exception.AxelorException) Pair(org.apache.commons.lang3.tuple.Pair)

Example 2 with PaymentService

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);
    }
}
Also used : HashMap(java.util.HashMap) TaxPaymentMoveLine(com.axelor.apps.account.db.TaxPaymentMoveLine) MoveLine(com.axelor.apps.account.db.MoveLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) List(java.util.List) ArrayList(java.util.ArrayList) PaymentService(com.axelor.apps.account.service.payment.PaymentService) Pair(org.apache.commons.lang3.tuple.Pair) Transactional(com.google.inject.persist.Transactional)

Aggregations

AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)2 MoveLine (com.axelor.apps.account.db.MoveLine)2 TaxPaymentMoveLine (com.axelor.apps.account.db.TaxPaymentMoveLine)2 PaymentService (com.axelor.apps.account.service.payment.PaymentService)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Pair (org.apache.commons.lang3.tuple.Pair)2 AxelorException (com.axelor.exception.AxelorException)1 Transactional (com.google.inject.persist.Transactional)1