+ @NonNull
+ static public LedgerAccount fromDBO(AccountWithAmounts in, LedgerAccount parent) {
+ LedgerAccount res = new LedgerAccount(in.account.getName(), parent);
+ res.dbId = in.account.getId();
+ res.profileId = in.account.getProfileId();
+ res.setName(in.account.getName());
+ res.setExpanded(in.account.isExpanded());
+ res.setAmountsExpanded(in.account.isAmountsExpanded());
+
+ res.amounts = new ArrayList<>();
+ for (AccountValue val : in.amounts) {
+ res.amounts.add(new LedgerAmount(val.getValue(), val.getCurrency()));
+ }
+
+ return res;
+ }
+ public static int determineLevel(String accName) {
+ int level = 0;
+ int delimiterPosition = accName.indexOf(ACCOUNT_DELIMITER);
+ while (delimiterPosition >= 0) {
+ level++;
+ delimiterPosition = accName.indexOf(ACCOUNT_DELIMITER, delimiterPosition + 1);
+ }
+ return level;