use of com.axelor.apps.account.service.AccountingReportService in project axelor-open-suite by axelor.
the class AccountingReportController method printExportMoveLine.
/**
* @param request
* @param response
*/
public void printExportMoveLine(ActionRequest request, ActionResponse response) {
AccountingReport accountingReport = request.getContext().asType(AccountingReport.class);
accountingReport = Beans.get(AccountingReportRepository.class).find(accountingReport.getId());
AccountingReportService accountingReportService = Beans.get(AccountingReportService.class);
try {
int typeSelect = accountingReport.getReportType().getTypeSelect();
if (accountingReport.getExportTypeSelect() == null || accountingReport.getExportTypeSelect().isEmpty() || typeSelect == 0) {
response.setFlash(I18n.get(IExceptionMessage.ACCOUNTING_REPORT_4));
response.setReload(true);
return;
}
if (accountingReportService.isThereTooManyLines(accountingReport)) {
response.setAlert(I18n.get("A large number of recording has been fetched in this period. Edition can take a while. Do you want to proceed ?"));
}
logger.debug("Type selected : {}", typeSelect);
if ((typeSelect >= AccountingReportRepository.EXPORT_ADMINISTRATION && typeSelect < AccountingReportRepository.REPORT_ANALYTIC_BALANCE)) {
MoveLineExportService moveLineExportService = Beans.get(MoveLineExportService.class);
MetaFile accesssFile = moveLineExportService.exportMoveLine(accountingReport);
if (typeSelect == AccountingReportRepository.EXPORT_ADMINISTRATION && accesssFile != null) {
response.setView(ActionView.define(I18n.get("Export file")).model(App.class.getName()).add("html", "ws/rest/com.axelor.meta.db.MetaFile/" + accesssFile.getId() + "/content/download?v=" + accesssFile.getVersion()).param("download", "true").map());
}
} else {
accountingReportService.setPublicationDateTime(accountingReport);
String name = accountingReport.getReportType().getName() + " " + accountingReport.getRef();
String fileLink = accountingReportService.getReportFileLink(accountingReport, name);
logger.debug("Printing " + name);
response.setView(ActionView.define(name).add("html", fileLink).map());
accountingReportService.setStatus(accountingReport);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.service.AccountingReportService in project axelor-open-suite by axelor.
the class AccountingReportController method searchMoveLine.
/**
* @param request
* @param response
*/
public void searchMoveLine(ActionRequest request, ActionResponse response) {
AccountingReport accountingReport = request.getContext().asType(AccountingReport.class);
AccountingReportService accountingReportService = Beans.get(AccountingReportService.class);
try {
accountingReport = Beans.get(AccountingReportRepository.class).find(accountingReport.getId());
String query = accountingReportService.getMoveLineList(accountingReport);
BigDecimal debitBalance = accountingReportService.getDebitBalance();
BigDecimal creditBalance = accountingReportService.getCreditBalance();
response.setValue("totalDebit", debitBalance);
response.setValue("totalCredit", creditBalance);
response.setValue("balance", debitBalance.subtract(creditBalance));
ActionViewBuilder actionViewBuilder = ActionView.define(I18n.get(IExceptionMessage.ACCOUNTING_REPORT_3));
actionViewBuilder.model(MoveLine.class.getName());
actionViewBuilder.add("grid", "move-line-grid");
actionViewBuilder.add("form", "move-line-form");
actionViewBuilder.param("search-filters", "move-line-filters");
actionViewBuilder.domain(query);
response.setView(actionViewBuilder.map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations