Search in sources :

Example 1 with BankReconciliation

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

the class BankReconciliationCreateService method createAllFromBankStatement.

@Transactional(rollbackOn = { Exception.class })
public List<BankReconciliation> createAllFromBankStatement(BankStatement bankStatement) throws IOException {
    List<BankReconciliation> bankReconciliationList = new ArrayList<>();
    List<BankDetails> bankDetailsList = getDistinctBankDetails(bankStatement);
    if (bankDetailsList == null) {
        return bankReconciliationList;
    }
    LocalDate fromDate = bankStatement.getFromDate();
    LocalDate toDate = bankStatement.getToDate();
    for (BankDetails bankDetails : bankDetailsList) {
        Company company = companyRepository.all().filter("?1 member of self.bankDetailsList", bankDetails).fetchOne();
        Currency currency = bankDetails.getCurrency();
        if (currency == null) {
            currency = company.getCurrency();
        }
        BankReconciliation bankReconciliation = createBankReconciliation(company, fromDate, toDate, currency, bankDetails, bankStatement);
        bankReconciliationRepository.save(bankReconciliation);
        bankReconciliationList.add(bankReconciliation);
    }
    return bankReconciliationList;
}
Also used : Company(com.axelor.apps.base.db.Company) BankDetails(com.axelor.apps.base.db.BankDetails) Currency(com.axelor.apps.base.db.Currency) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation) Transactional(com.google.inject.persist.Transactional)

Example 2 with BankReconciliation

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

the class BankReconciliationCreateService method createBankReconciliation.

public BankReconciliation createBankReconciliation(Company company, LocalDate fromDate, LocalDate toDate, Currency currency, BankDetails bankDetails, BankStatement bankStatement) throws IOException {
    BankReconciliation bankReconciliation = new BankReconciliation();
    bankReconciliation.setCompany(company);
    bankReconciliation.setFromDate(fromDate);
    bankReconciliation.setToDate(toDate);
    bankReconciliation.setCurrency(currency);
    bankReconciliation.setBankDetails(bankDetails);
    bankReconciliation.setBankStatement(bankStatement);
    bankReconciliation.setName(this.computeName(bankReconciliation));
    bankReconciliation.setJournal(bankReconciliationService.getJournal(bankReconciliation));
    bankReconciliation.setCashAccount(bankReconciliationService.getCashAccount(bankReconciliation));
    return bankReconciliation;
}
Also used : BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Example 3 with BankReconciliation

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

the class BankReconciliationController method setJournalDomain.

public void setJournalDomain(ActionRequest request, ActionResponse response) {
    BankReconciliation bankReconciliation = request.getContext().asType(BankReconciliation.class);
    String journalIds = null;
    if (EntityHelper.getEntity(bankReconciliation).getBankDetails() != null) {
        journalIds = Beans.get(BankReconciliationService.class).getJournalDomain(bankReconciliation);
    }
    if (Strings.isNullOrEmpty(journalIds)) {
        response.setAttr("journal", "domain", "self.id IN (0)");
    } else {
        response.setAttr("journal", "domain", "self.id IN(" + journalIds + ")");
    }
}
Also used : BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Example 4 with BankReconciliation

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

the class BankReconciliationController method setCashAccount.

public void setCashAccount(ActionRequest request, ActionResponse response) {
    BankReconciliation bankReconciliation = request.getContext().asType(BankReconciliation.class);
    Account cashAccount = null;
    if (EntityHelper.getEntity(bankReconciliation).getBankDetails() != null) {
        cashAccount = Beans.get(BankReconciliationService.class).getCashAccount(bankReconciliation);
    }
    response.setValue("cashAccount", cashAccount);
}
Also used : Account(com.axelor.apps.account.db.Account) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Example 5 with BankReconciliation

use of com.axelor.apps.bankpayment.db.BankReconciliation 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)

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