+ public LedgerTransaction(TransactionWithAccounts dbo) {
+ this(dbo.transaction.getLedgerId(), dbo.transaction.getProfileId());
+ dbId = dbo.transaction.getId();
+ date = new SimpleDate(dbo.transaction.getYear(), dbo.transaction.getMonth(),
+ dbo.transaction.getDay());
+ description = dbo.transaction.getDescription();
+ comment = dbo.transaction.getComment();
+ dataHash = dbo.transaction.getDataHash();
+ if (dbo.accounts != null)
+ for (TransactionAccount acc : dbo.accounts) {
+ accounts.add(new LedgerTransactionAccount(acc));
+ }
+ dataLoaded = true;
+ }
+ public TransactionWithAccounts toDBO() {
+ TransactionWithAccounts o = new TransactionWithAccounts();
+ o.transaction = new Transaction();
+ o.transaction.setId(dbId);
+ o.transaction.setProfileId(profile);
+ o.transaction.setLedgerId(ledgerId);
+ o.transaction.setYear(date.year);
+ o.transaction.setMonth(date.month);
+ o.transaction.setDay(date.day);
+ o.transaction.setDescription(description);
+ o.transaction.setComment(comment);
+ fillDataHash();
+ o.transaction.setDataHash(dataHash);
+
+ o.accounts = new ArrayList<>();
+ int orderNo = 1;
+ for (LedgerTransactionAccount acc : accounts) {
+ TransactionAccount a = acc.toDBO();
+ a.setOrderNo(orderNo++);
+ a.setTransactionId(dbId);
+ o.accounts.add(a);
+ }
+ return o;
+ }
+ public LedgerTransaction(long ledgerId, SimpleDate date, String description, Profile profile) {