use of com.axelor.apps.account.db.AccountType in project axelor-open-suite by axelor.
the class ImportJournal method importAccountType.
public Object importAccountType(Object bean, Map<String, Object> values) {
assert bean instanceof Journal;
Journal journal = (Journal) bean;
// Only 'Manual misc ops' Journal
String importId = journal.getImportId();
if (!"24".equals(importId)) {
return bean;
}
Set<AccountType> accountTypesSet = new HashSet<AccountType>(Beans.get(AccountTypeRepository.class).all().fetch());
journal.setValidAccountTypeSet(accountTypesSet);
return journal;
}
use of com.axelor.apps.account.db.AccountType in project axelor-open-suite by axelor.
the class ImportAccountingReportConfigLine method setAccounts.
@Transactional(rollbackOn = { Exception.class })
public Object setAccounts(Object bean, Map<String, Object> values) throws AxelorException {
assert bean instanceof AccountingReportConfigLine;
AccountingReportConfigLine configLine = (AccountingReportConfigLine) bean;
if (configLine.getRuleTypeSelect() == AccountingReportConfigLineRepository.RULE_TYPE_SUM_OF_ACCOUNTS) {
String accountTypeValues = (String) values.get("accountType");
if (accountTypeValues != null && !accountTypeValues.isEmpty()) {
String[] types = accountTypeValues.split("\\|");
Set<AccountType> accountTypes = new HashSet<>();
AccountType typeToAdd;
for (String type : types) {
typeToAdd = accountTypeRepo.all().filter("self.importId = :importId").bind("importId", type).fetchOne();
if (typeToAdd != null) {
accountTypes.add(typeToAdd);
}
}
configLine.setAccountTypeSet(accountTypes);
}
String accountValues = (String) values.get("accountCode");
if (accountValues != null && !accountValues.isEmpty()) {
String[] codes = accountValues.split("\\|");
Set<Account> accounts = new HashSet<>();
Account accountToAdd;
List<Account> fetched;
for (String code : codes) {
accountToAdd = accountRepo.all().filter("self.code = :code").bind("code", code).fetchOne();
if (accountToAdd == null) {
fetched = accountRepo.all().fetch();
for (Account account : fetched) {
if (compareCodes(account.getCode(), code)) {
accountToAdd = account;
break;
}
}
}
if (accountToAdd != null) {
accounts.add(accountToAdd);
}
}
configLine.setAccountSet(accounts);
}
accountingReportConfigLineRepo.save(configLine);
}
return configLine;
}
Aggregations