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);
}
}
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);
}
}
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);
}
}
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);
}
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);
}
Aggregations