Search in sources :

Example 6 with BankReconciliation

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

the class BankReconciliationController method loadOtherBankStatement.

public void loadOtherBankStatement(ActionRequest request, ActionResponse response) {
    try {
        BankReconciliation bankReconciliation = request.getContext().asType(BankReconciliation.class);
        bankReconciliation = Beans.get(BankReconciliationRepository.class).find(bankReconciliation.getId());
        bankReconciliation.setIncludeOtherBankStatements(true);
        Beans.get(BankReconciliationService.class).loadBankStatement(bankReconciliation, false);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BankReconciliationService(com.axelor.apps.bankpayment.service.bankreconciliation.BankReconciliationService) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Example 7 with BankReconciliation

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

the class BankReconciliationController method printBankReconciliation.

public void printBankReconciliation(ActionRequest request, ActionResponse response) {
    BankReconciliation bankReconciliation = request.getContext().asType(BankReconciliation.class);
    try {
        String fileLink = ReportFactory.createReport(IReport.BANK_RECONCILIATION, "Bank Reconciliation" + "-${date}").addParam("BankReconciliationId", bankReconciliation.getId()).addParam("Locale", ReportSettings.getPrintingLocale(null)).addParam("Timezone", bankReconciliation.getCompany() != null ? bankReconciliation.getCompany().getTimezone() : null).addFormat("pdf").toAttach(bankReconciliation).generate().getFileLink();
        response.setView(ActionView.define("Bank Reconciliation").add("html", fileLink).map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Example 8 with BankReconciliation

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

the class BankReconciliationLineController method setAccountDomain.

public void setAccountDomain(ActionRequest request, ActionResponse response) {
    try {
        Context parentContext = request.getContext().getParent();
        BankReconciliation bankReconciliation = null;
        if (parentContext != null && parentContext.getContextClass().toString().equals(BankReconciliation.class.toString())) {
            bankReconciliation = parentContext.asType(BankReconciliation.class);
        } else if (parentContext == null || !parentContext.getContextClass().toString().equals(BankReconciliation.class.toString())) {
            bankReconciliation = (BankReconciliation) request.getContext().get("bankReconciliation");
        }
        String domain = Beans.get(BankReconciliationService.class).getAccountDomain(bankReconciliation);
        response.setAttr("account", "domain", domain);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) BankReconciliationService(com.axelor.apps.bankpayment.service.bankreconciliation.BankReconciliationService) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Example 9 with BankReconciliation

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

the class BankStatementController method runBankReconciliation.

public void runBankReconciliation(ActionRequest request, ActionResponse response) {
    try {
        BankStatement bankStatement = request.getContext().asType(BankStatement.class);
        bankStatement = Beans.get(BankStatementRepository.class).find(bankStatement.getId());
        List<BankReconciliation> bankReconciliationList = Beans.get(BankReconciliationCreateService.class).createAllFromBankStatement(bankStatement);
        if (bankReconciliationList != null) {
            response.setView(ActionView.define(I18n.get("Bank reconciliations")).model(BankReconciliation.class.getName()).add("grid", "bank-reconciliation-grid").add("form", "bank-reconciliation-form").param("search-filters", "bank-reconciliation-filters").domain("self.id in (" + Joiner.on(",").join(bankReconciliationList.stream().map(BankReconciliation::getId).toArray()) + ")").map());
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
    response.setReload(true);
}
Also used : BankStatement(com.axelor.apps.bankpayment.db.BankStatement) BankReconciliationCreateService(com.axelor.apps.bankpayment.service.bankreconciliation.BankReconciliationCreateService) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Example 10 with BankReconciliation

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

the class BankReconciliationValidateService method validate.

protected void validate(BankReconciliationLine bankReconciliationLine) throws AxelorException {
    BigDecimal debit = bankReconciliationLine.getDebit();
    BigDecimal credit = bankReconciliationLine.getCredit();
    if (debit.compareTo(BigDecimal.ZERO) == 0 && credit.compareTo(BigDecimal.ZERO) == 0) {
        return;
    }
    BankReconciliation bankReconciliation = bankReconciliationLine.getBankReconciliation();
    Company company = bankReconciliation.getCompany();
    LocalDate effectDate = bankReconciliationLine.getEffectDate();
    Partner partner = bankReconciliationLine.getPartner();
    String reference = bankReconciliationLine.getReference();
    String name = bankReconciliationLine.getName();
    if (name != null && name.length() > 255) {
        name = name.substring(0, 255);
    }
    BigDecimal amount = debit.add(credit);
    String origin = bankReconciliation.getName() + reference != null ? " - " + reference : "";
    boolean isDebit = debit.compareTo(BigDecimal.ZERO) > 0;
    Move move = moveService.getMoveCreateService().createMove(bankReconciliation.getJournal(), company, null, partner, effectDate, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    MoveLine partnerMoveLine = moveLineService.createMoveLine(move, partner, bankReconciliationLine.getAccount(), amount, isDebit, effectDate, effectDate, 1, origin, name);
    move.addMoveLineListItem(partnerMoveLine);
    MoveLine cashMoveLine = moveLineService.createMoveLine(move, partner, bankReconciliation.getCashAccount(), amount, !isDebit, effectDate, effectDate, 2, origin, name);
    cashMoveLine.setBankReconciledAmount(amount);
    move.addMoveLineListItem(cashMoveLine);
    moveRepository.save(move);
    moveService.getMoveValidateService().validate(move);
    bankReconciliationLine.setMoveLine(cashMoveLine);
    bankReconciliationLine.setIsPosted(true);
    updateBankReconciledAmounts(bankReconciliationLine);
}
Also used : Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) LocalDate(java.time.LocalDate) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Aggregations

BankReconciliation (com.axelor.apps.bankpayment.db.BankReconciliation)16 BankReconciliationService (com.axelor.apps.bankpayment.service.bankreconciliation.BankReconciliationService)5 BankReconciliationValidateService (com.axelor.apps.bankpayment.service.bankreconciliation.BankReconciliationValidateService)2 Company (com.axelor.apps.base.db.Company)2 Context (com.axelor.rpc.Context)2 LocalDate (java.time.LocalDate)2 Account (com.axelor.apps.account.db.Account)1 Journal (com.axelor.apps.account.db.Journal)1 Move (com.axelor.apps.account.db.Move)1 MoveLine (com.axelor.apps.account.db.MoveLine)1 BankReconciliationLine (com.axelor.apps.bankpayment.db.BankReconciliationLine)1 BankStatement (com.axelor.apps.bankpayment.db.BankStatement)1 BankReconciliationLineRepository (com.axelor.apps.bankpayment.db.repo.BankReconciliationLineRepository)1 BankReconciliationRepository (com.axelor.apps.bankpayment.db.repo.BankReconciliationRepository)1 BankReconciliationCreateService (com.axelor.apps.bankpayment.service.bankreconciliation.BankReconciliationCreateService)1 BankDetails (com.axelor.apps.base.db.BankDetails)1 Currency (com.axelor.apps.base.db.Currency)1 Partner (com.axelor.apps.base.db.Partner)1 Transactional (com.google.inject.persist.Transactional)1 BigDecimal (java.math.BigDecimal)1