Search in sources :

Example 1 with BankReconciliationLine

use of com.axelor.apps.bankpayment.db.BankReconciliationLine in project axelor-open-suite by axelor.

the class BankReconciliationLineService method createBankReconciliationLine.

public BankReconciliationLine createBankReconciliationLine(LocalDate effectDate, BigDecimal debit, BigDecimal credit, String name, String reference, BankStatementLine bankStatementLine, MoveLine moveLine) {
    BankReconciliationLine bankReconciliationLine = new BankReconciliationLine();
    bankReconciliationLine.setEffectDate(effectDate);
    bankReconciliationLine.setDebit(debit);
    bankReconciliationLine.setCredit(credit);
    bankReconciliationLine.setName(name);
    bankReconciliationLine.setReference(reference);
    bankReconciliationLine.setBankStatementLine(bankStatementLine);
    bankReconciliationLine.setMoveLine(moveLine);
    bankReconciliationLine.setIsPosted(false);
    return bankReconciliationLine;
}
Also used : BankReconciliationLine(com.axelor.apps.bankpayment.db.BankReconciliationLine)

Example 2 with BankReconciliationLine

use of com.axelor.apps.bankpayment.db.BankReconciliationLine in project axelor-open-suite by axelor.

the class BankReconciliationValidateService method validate.

@Transactional(rollbackOn = { Exception.class })
public void validate(BankReconciliation bankReconciliation) throws AxelorException {
    for (BankReconciliationLine bankReconciliationLine : bankReconciliation.getBankReconciliationLineList()) {
        if (!bankReconciliationLine.getIsPosted()) {
            if (bankReconciliationLine.getMoveLine() == null && bankReconciliationLine.getAccount() != null) {
                this.validate(bankReconciliationLine);
            } else if (bankReconciliationLine.getMoveLine() != null) {
                bankReconciliationLineService.checkAmount(bankReconciliationLine);
                updateBankReconciledAmounts(bankReconciliationLine);
            }
        }
    }
    bankReconciliation.setStatusSelect(BankReconciliationRepository.STATUS_VALIDATED);
    bankReconciliation.setValidatedByUser(AuthUtils.getUser());
    bankReconciliation.setValidatedDate(Beans.get(AppBaseService.class).getTodayDate(bankReconciliation.getCompany()));
    bankReconciliationRepository.save(bankReconciliation);
}
Also used : BankReconciliationLine(com.axelor.apps.bankpayment.db.BankReconciliationLine) Transactional(com.google.inject.persist.Transactional)

Example 3 with BankReconciliationLine

use of com.axelor.apps.bankpayment.db.BankReconciliationLine in project axelor-open-suite by axelor.

the class BankReconciliationController method validateMultipleReconcile.

public void validateMultipleReconcile(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        Map<String, Object> bankReconciliationContext = (Map<String, Object>) context.get("_bankReconciliation");
        BankReconciliation bankReconciliation = Beans.get(BankReconciliationRepository.class).find(((Integer) bankReconciliationContext.get("id")).longValue());
        List<HashMap<String, Object>> moveLinesToReconcileContext = (List<HashMap<String, Object>>) context.get("toReconcileMoveLineSet");
        Map<String, Object> selectedBankReconciliationLineContext = (Map<String, Object>) context.get("_selectedBankReconciliationLine");
        BankReconciliationLine bankReconciliationLine = Beans.get(BankReconciliationLineRepository.class).find(((Integer) selectedBankReconciliationLineContext.get("id")).longValue());
        Beans.get(BankReconciliationValidateService.class).validateMultipleBankReconciles(bankReconciliation, bankReconciliationLine, moveLinesToReconcileContext);
        response.setCanClose(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) BankReconciliationLineRepository(com.axelor.apps.bankpayment.db.repo.BankReconciliationLineRepository) BankReconciliationRepository(com.axelor.apps.bankpayment.db.repo.BankReconciliationRepository) HashMap(java.util.HashMap) BankReconciliationValidateService(com.axelor.apps.bankpayment.service.bankreconciliation.BankReconciliationValidateService) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation) BankReconciliationLine(com.axelor.apps.bankpayment.db.BankReconciliationLine) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with BankReconciliationLine

use of com.axelor.apps.bankpayment.db.BankReconciliationLine in project axelor-open-suite by axelor.

the class BankReconciliationService method compute.

@Transactional
public void compute(BankReconciliation bankReconciliation) {
    BigDecimal totalPaid = BigDecimal.ZERO;
    BigDecimal totalCashed = BigDecimal.ZERO;
    for (BankReconciliationLine bankReconciliationLine : bankReconciliation.getBankReconciliationLineList()) {
        totalPaid = totalPaid.add(bankReconciliationLine.getDebit());
        totalCashed = totalCashed.add(bankReconciliationLine.getCredit());
    }
    bankReconciliation.setTotalPaid(totalPaid);
    bankReconciliation.setTotalCashed(totalCashed);
    Account cashAccount = bankReconciliation.getCashAccount();
    if (cashAccount != null) {
        bankReconciliation.setAccountBalance(accountService.computeBalance(cashAccount, AccountService.BALANCE_TYPE_DEBIT_BALANCE));
    }
    bankReconciliation.setComputedBalance(bankReconciliation.getAccountBalance().add(totalCashed).subtract(totalPaid));
}
Also used : Account(com.axelor.apps.account.db.Account) BankReconciliationLine(com.axelor.apps.bankpayment.db.BankReconciliationLine) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Aggregations

BankReconciliationLine (com.axelor.apps.bankpayment.db.BankReconciliationLine)4 Transactional (com.google.inject.persist.Transactional)2 Account (com.axelor.apps.account.db.Account)1 BankReconciliation (com.axelor.apps.bankpayment.db.BankReconciliation)1 BankReconciliationLineRepository (com.axelor.apps.bankpayment.db.repo.BankReconciliationLineRepository)1 BankReconciliationRepository (com.axelor.apps.bankpayment.db.repo.BankReconciliationRepository)1 BankReconciliationValidateService (com.axelor.apps.bankpayment.service.bankreconciliation.BankReconciliationValidateService)1 Context (com.axelor.rpc.Context)1 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1