]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java
add commodity support to template editor
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / model / TemplateDetailsItem.java
index 67d6a4f374b5b05bcd9d01116e94bbe9e5afbf8a..9a8f04cebf1a4ea9eee17039d12411464bfcc8e1 100644 (file)
@@ -384,6 +384,7 @@ abstract public class TemplateDetailsItem {
         public boolean hasLiteralAccountComment() {
             return accountComment.hasLiteralValue();
         }
+        public boolean hasLiteralCurrency() { return currency.hasLiteralValue(); }
         public boolean equalContents(AccountRow o) {
             if (position != o.position) {
                 Logger.debug("cmpAcc",
@@ -398,6 +399,9 @@ abstract public class TemplateDetailsItem {
         public void switchToLiteralAmount() {
             amount.switchToLiteral();
         }
+        public void switchToLiteralCurrency() {
+            currency.switchToLiteral();
+        }
         public void switchToLiteralAccountName() {
             accountName.switchToLiteral();
         }
@@ -426,6 +430,14 @@ abstract public class TemplateDetailsItem {
                 result.setNegateAmount(negateAmount ? true : null);
             }
 
+            if (currency.hasLiteralValue()) {
+                net.ktnx.mobileledger.db.Currency c = currency.getValue();
+                result.setCurrency((c == null) ? null : c.getId());
+            }
+            else {
+                result.setCurrencyMatchGroup(currency.getMatchGroup());
+            }
+
             return result;
         }
         public boolean isEmpty() {