use of com.axelor.apps.account.db.AccountChart in project axelor-open-suite by axelor.
the class AccountChartController method installChart.
public void installChart(ActionRequest request, ActionResponse response) throws AxelorException {
AccountConfig accountConfig = request.getContext().asType(AccountConfig.class);
AccountChart act = Beans.get(AccountChartRepository.class).find(accountConfig.getAccountChart().getId());
Company company = Beans.get(CompanyRepository.class).find(accountConfig.getCompany().getId());
accountConfig = Beans.get(AccountConfigRepository.class).find(accountConfig.getId());
List<? extends Account> accountList = Beans.get(AccountRepository.class).all().filter("self.company.id = ?1 AND self.parentAccount != null", company.getId()).fetch();
if (accountList.isEmpty()) {
if (Beans.get(AccountChartService.class).installAccountChart(act, company, accountConfig))
response.setFlash(I18n.get(IExceptionMessage.ACCOUNT_CHART_1));
else
response.setFlash(I18n.get(IExceptionMessage.ACCOUNT_CHART_2));
response.setReload(true);
} else
response.setFlash(I18n.get(IExceptionMessage.ACCOUNT_CHART_3));
}
use of com.axelor.apps.account.db.AccountChart in project axelor-open-suite by axelor.
the class ImportAccountChart method importAccountChart.
public Object importAccountChart(Object bean, Map<String, Object> values) throws IOException {
assert bean instanceof AccountChart;
AccountChart accountChart = (AccountChart) bean;
File zipFile = this.getZipFile(accountChart);
try {
final MetaFile metaFile = metaFiles.upload(zipFile);
accountChart.setMetaFile(metaFile);
} catch (Exception e) {
e.printStackTrace();
LOG.warn("Can't load file {} for accountChart {}", zipFile.getName(), accountChart.getName());
}
FileUtils.deleteDirectory(zipFile.getParentFile());
return accountChart;
}
Aggregations