]> git.ktnx.net Git - mobile-ledger.git/commitdiff
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 1446be790fd21b3264370ce0355c8cc08ed3b170..801e0169845f8c2ff2daedb06177eec7d62ba3d6 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;