LedgerTransactionAccount: add copy constructor
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 26 Nov 2019 21:58:15 +0000 (23:58 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 26 Nov 2019 21:58:15 +0000 (23:58 +0200)
app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java

index 1446be7..801e016 100644 (file)
@@ -30,7 +30,7 @@ public class LedgerTransactionAccount {
     private String accountName;
     private String shortAccountName;
     private float amount;
-    private boolean amountSet;
+    private boolean amountSet = false;
     private String currency;
 
     public LedgerTransactionAccount(String accountName, float amount) {
@@ -46,6 +46,13 @@ public class LedgerTransactionAccount {
     public LedgerTransactionAccount(String accountName) {
         this.accountName = accountName;
     }
+    public LedgerTransactionAccount(LedgerTransactionAccount origin) {
+        // copy constructor
+        setAccountName(origin.getAccountName());
+        if (origin.isAmountSet())
+            setAmount(origin.getAmount());
+        currency = origin.getCurrency();
+    }
 
     public String getAccountName() {
         return accountName;