+ @Nullable
+ public static String extractParentName(@NonNull String accName) {
+ int colonPos = accName.lastIndexOf(ACCOUNT_DELIMITER);
+ if (colonPos < 0)
+ return null; // no parent account -- this is a top-level account
+ else
+ return accName.substring(0, colonPos);
+ }
+ public static boolean isParentOf(@NonNull String possibleParent, @NonNull String accountName) {
+ return accountName.startsWith(possibleParent + ':');
+ }
+ @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()));
+ }