use of com.axelor.apps.bankpayment.db.BankStatementLine in project axelor-open-suite by axelor.
the class BankReconciliationValidateService method updateBankReconciledAmounts.
protected void updateBankReconciledAmounts(BankReconciliationLine bankReconciliationLine) {
bankReconciliationLine.setIsPosted(true);
BigDecimal bankReconciledAmount = bankReconciliationLine.getDebit().add(bankReconciliationLine.getCredit());
BankStatementLine bankStatementLine = bankReconciliationLine.getBankStatementLine();
if (bankStatementLine != null) {
bankStatementLine.setAmountRemainToReconcile(bankStatementLine.getAmountRemainToReconcile().subtract(bankReconciledAmount));
}
MoveLine moveLine = bankReconciliationLine.getMoveLine();
moveLine.setBankReconciledAmount(bankReconciledAmount);
}
use of com.axelor.apps.bankpayment.db.BankStatementLine 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;
}
use of com.axelor.apps.bankpayment.db.BankStatementLine in project axelor-open-suite by axelor.
the class BankReconciliationValidateService method validateMultipleBankReconciles.
@Transactional(rollbackOn = { Exception.class })
public void validateMultipleBankReconciles(BankReconciliation bankReconciliation, BankReconciliationLine bankReconciliationLine, List<HashMap<String, Object>> moveLinesToReconcileContext) throws AxelorException {
LocalDate effectDate = bankReconciliationLine.getEffectDate();
String name = bankReconciliationLine.getName();
String reference = bankReconciliationLine.getReference();
BankStatementLine bankStatementLine = bankReconciliationLine.getBankStatementLine();
BigDecimal bankStatementAmountRemaining = bankStatementLine.getAmountRemainToReconcile();
boolean isDebit = bankReconciliationLine.getDebit().compareTo(BigDecimal.ZERO) == 1;
boolean firstLine = true;
if ((moveLinesToReconcileContext != null && !moveLinesToReconcileContext.isEmpty())) {
for (HashMap<String, Object> moveLineToReconcile : moveLinesToReconcileContext) {
if (bankStatementAmountRemaining.compareTo(BigDecimal.ZERO) != 1) {
break;
}
MoveLine moveLine = moveLineRepository.find(((Integer) moveLineToReconcile.get("id")).longValue());
BigDecimal debit;
BigDecimal credit;
if (isDebit) {
debit = (moveLine.getCredit().subtract(moveLine.getBankReconciledAmount())).min(bankStatementAmountRemaining);
credit = BigDecimal.ZERO;
} else {
debit = BigDecimal.ZERO;
credit = (moveLine.getDebit().subtract(moveLine.getBankReconciledAmount())).min(bankStatementAmountRemaining);
}
if (firstLine) {
bankReconciliationLine.setDebit(debit);
bankReconciliationLine.setCredit(credit);
bankReconciliationLine.setMoveLine(moveLine);
firstLine = false;
} else {
bankReconciliation.addBankReconciliationLineListItem(bankReconciliationLineService.createBankReconciliationLine(effectDate, debit, credit, name, reference, bankStatementLine, moveLine));
}
bankStatementAmountRemaining = bankStatementAmountRemaining.subtract(debit.add(credit));
}
if (bankStatementAmountRemaining.compareTo(BigDecimal.ZERO) == 1) {
BigDecimal debit;
BigDecimal credit;
if (isDebit) {
debit = bankStatementAmountRemaining;
credit = BigDecimal.ZERO;
} else {
debit = BigDecimal.ZERO;
credit = bankStatementAmountRemaining;
}
bankReconciliation.addBankReconciliationLineListItem(bankReconciliationLineService.createBankReconciliationLine(effectDate, debit, credit, name, reference, bankStatementLine, null));
}
bankReconciliationRepository.save(bankReconciliation);
}
}
use of com.axelor.apps.bankpayment.db.BankStatementLine in project axelor-open-suite by axelor.
the class BankReconciliationLoadAFB120Service method loadBankStatement.
@Transactional
public void loadBankStatement(BankReconciliation bankReconciliation, boolean includeBankStatement) {
BankStatementLine initialBalanceBankStatementLine = getInitialBalanceBankStatementLine(bankReconciliation, includeBankStatement);
BankStatementLine finalBalanceBankStatementLine = getFinalBalanceBankStatementLine(bankReconciliation, includeBankStatement);
if (initialBalanceBankStatementLine != null) {
bankReconciliation.setStartingBalance(initialBalanceBankStatementLine.getCredit().subtract(initialBalanceBankStatementLine.getDebit()));
}
if (finalBalanceBankStatementLine != null) {
bankReconciliation.setEndingBalance(finalBalanceBankStatementLine.getCredit().subtract(finalBalanceBankStatementLine.getDebit()));
}
this.loadBankStatementLines(bankReconciliation, includeBankStatement);
}
use of com.axelor.apps.bankpayment.db.BankStatementLine in project axelor-open-suite by axelor.
the class BankStatementLineService method createBankStatementLine.
public BankStatementLine 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) {
BankStatementLine bankStatementLine = new BankStatementLine();
bankStatementLine.setBankStatement(bankStatement);
bankStatementLine.setSequence(sequence);
bankStatementLine.setBankDetails(bankDetails);
bankStatementLine.setDebit(debit);
bankStatementLine.setCredit(credit);
bankStatementLine.setCurrency(currency);
bankStatementLine.setDescription(description);
bankStatementLine.setOperationDate(operationDate);
bankStatementLine.setValueDate(valueDate);
bankStatementLine.setOperationInterbankCodeLine(operationInterbankCodeLine);
bankStatementLine.setRejectInterbankCodeLine(rejectInterbankCodeLine);
bankStatementLine.setOrigin(origin);
bankStatementLine.setReference(reference);
// Used for Bank reconcile process
bankStatementLine.setAmountRemainToReconcile(bankStatementLine.getDebit().add(bankStatementLine.getCredit()));
return bankStatementLine;
}
Aggregations