Search in sources :

Example 1 with BankStatementLineAFB120

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

the class BankStatementFileAFB120Service method createBankStatementLine.

@Transactional
public BankStatementLineAFB120 createBankStatementLine(Map<String, Object> structuredContentLine, int sequence) {
    String description = (String) structuredContentLine.get("description");
    if (structuredContentLine.containsKey("additionalInformation") && structuredContentLine.get("additionalInformation") != null) {
        description += "\n" + (String) structuredContentLine.get("additionalInformation");
    }
    BankDetails bankDetails = null;
    if (structuredContentLine.containsKey("bankDetails") && structuredContentLine.get("bankDetails") != null) {
        bankDetails = bankDetailsRepository.find(((BankDetails) structuredContentLine.get("bankDetails")).getId());
    }
    Currency currency = null;
    if (structuredContentLine.containsKey("currency") && structuredContentLine.get("currency") != null) {
        currency = currencyRepository.find(((Currency) structuredContentLine.get("currency")).getId());
    }
    InterbankCodeLine operationInterbankCodeLine = null;
    if (structuredContentLine.containsKey("operationInterbankCodeLine") && structuredContentLine.get("operationInterbankCodeLine") != null) {
        operationInterbankCodeLine = interbankCodeLineRepository.find(((InterbankCodeLine) structuredContentLine.get("operationInterbankCodeLine")).getId());
    }
    InterbankCodeLine rejectInterbankCodeLine = null;
    if (structuredContentLine.containsKey("rejectInterbankCodeLine") && structuredContentLine.get("rejectInterbankCodeLine") != null) {
        rejectInterbankCodeLine = interbankCodeLineRepository.find(((InterbankCodeLine) structuredContentLine.get("rejectInterbankCodeLine")).getId());
    }
    BankStatementLineAFB120 bankStatementLineAFB120 = bankStatementLineAFB120Service.createBankStatementLine(findBankStatement(), sequence, bankDetails, (BigDecimal) structuredContentLine.get("debit"), (BigDecimal) structuredContentLine.get("credit"), currency, description, (LocalDate) structuredContentLine.get("operationDate"), (LocalDate) structuredContentLine.get("valueDate"), operationInterbankCodeLine, rejectInterbankCodeLine, (String) structuredContentLine.get("origin"), (String) structuredContentLine.get("reference"), (int) structuredContentLine.get("lineType"), (String) structuredContentLine.get("unavailabilityIndexSelect"), (String) structuredContentLine.get("commissionExemptionIndexSelect"));
    return bankStatementLineAFB120Repository.save(bankStatementLineAFB120);
}
Also used : BankDetails(com.axelor.apps.base.db.BankDetails) InterbankCodeLine(com.axelor.apps.account.db.InterbankCodeLine) Currency(com.axelor.apps.base.db.Currency) BankStatementLineAFB120(com.axelor.apps.bankpayment.db.BankStatementLineAFB120) Transactional(com.google.inject.persist.Transactional)

Example 2 with BankStatementLineAFB120

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

the class BankStatementLineAFB120Service method createBankStatementLine.

public BankStatementLineAFB120 createBankStatementLine(BankStatement bankStatement, int sequence, BankDetails bankDetails, BigDecimal debit, BigDecimal credit, Currency currency, String description, LocalDate operationDate, LocalDate valueDate, InterbankCodeLine operationInterbankCodeLine, InterbankCodeLine rejectInterbankCodeLine, String origin, String reference, int lineType, String unavailabilityIndexSelect, String commissionExemptionIndexSelect) {
    BankStatementLine bankStatementLine = super.createBankStatementLine(bankStatement, sequence, bankDetails, debit, credit, currency, description, operationDate, valueDate, operationInterbankCodeLine, rejectInterbankCodeLine, origin, reference);
    BankStatementLineAFB120 bankStatementLineAFB120 = Mapper.toBean(BankStatementLineAFB120.class, Mapper.toMap(bankStatementLine));
    bankStatementLineAFB120.setLineTypeSelect(lineType);
    if (lineType != BankStatementLineAFB120Repository.LINE_TYPE_MOVEMENT) {
        bankStatementLineAFB120.setAmountRemainToReconcile(BigDecimal.ZERO);
    }
    if (!Strings.isNullOrEmpty(unavailabilityIndexSelect)) {
        bankStatementLineAFB120.setUnavailabilityIndexSelect(Integer.parseInt(unavailabilityIndexSelect));
    }
    if (!Strings.isNullOrEmpty(commissionExemptionIndexSelect)) {
        bankStatementLineAFB120.setCommissionExemptionIndexSelect(Integer.parseInt(commissionExemptionIndexSelect));
    }
    if (bankDetails != null && lineType == BankStatementLineAFB120Repository.LINE_TYPE_FINAL_BALANCE) {
        bankDetails.setBalance((credit.subtract(debit)));
        bankDetails.setBalanceUpdatedDate(operationDate);
    }
    return bankStatementLineAFB120;
}
Also used : BankStatementLine(com.axelor.apps.bankpayment.db.BankStatementLine) BankStatementLineAFB120(com.axelor.apps.bankpayment.db.BankStatementLineAFB120)

Aggregations

BankStatementLineAFB120 (com.axelor.apps.bankpayment.db.BankStatementLineAFB120)2 InterbankCodeLine (com.axelor.apps.account.db.InterbankCodeLine)1 BankStatementLine (com.axelor.apps.bankpayment.db.BankStatementLine)1 BankDetails (com.axelor.apps.base.db.BankDetails)1 Currency (com.axelor.apps.base.db.Currency)1 Transactional (com.google.inject.persist.Transactional)1