+ if (amounts != null)
+ amounts.clear();
+ }
+ public boolean amountsExpanded() { return amountsExpanded; }
+ public void setAmountsExpanded(boolean flag) { amountsExpanded = flag; }
+ public void toggleAmountsExpanded() { amountsExpanded = !amountsExpanded; }
+ public void propagateAmountsTo(LedgerAccount acc) {
+ for (LedgerAmount a : amounts)
+ a.propagateToAccount(acc);
+ }
+ public List<LedgerAmount> getAmounts() {
+ return amounts;
+ }
+ @NonNull
+ public Account toDBO() {
+ Account dbo = new Account();
+ dbo.setName(name);
+ dbo.setNameUpper(name.toUpperCase());
+ dbo.setParentName(extractParentName(name));
+ dbo.setLevel(level);
+ dbo.setId(dbId);
+ dbo.setProfileId(profileId);
+ dbo.setExpanded(expanded);
+ dbo.setAmountsExpanded(amountsExpanded);
+
+ return dbo;
+ }
+ @NonNull
+ public AccountWithAmounts toDBOWithAmounts() {
+ AccountWithAmounts dbo = new AccountWithAmounts();
+ dbo.account = toDBO();
+
+ dbo.amounts = new ArrayList<>();
+ for (LedgerAmount amt : getAmounts()) {
+ AccountValue val = new AccountValue();
+ val.setCurrency(amt.getCurrency());
+ val.setValue(amt.getAmount());
+ dbo.amounts.add(val);
+ }
+
+ return dbo;
+ }
+ public long getId() {
+ return dbId;