- public LedgerTransaction(Integer id, Date date, String description) {
- this.profile = Data.profile.get().getUuid();
- this.id = id;
+ 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) {
+ this.profile = profile.getId();
+ this.ledgerId = ledgerId;