import androidx.lifecycle.ViewModel;
import net.ktnx.mobileledger.BuildConfig;
+import net.ktnx.mobileledger.db.Currency;
import net.ktnx.mobileledger.db.DB;
import net.ktnx.mobileledger.db.Profile;
import net.ktnx.mobileledger.db.TemplateAccount;
if (amount != null && acc.getNegateAmount() != null && acc.getNegateAmount())
amount = -amount;
- // TODO currency
TransactionAccount accRow = new TransactionAccount(accountName);
accRow.setComment(accountComment);
if (amount != null)
accRow.setAmount(amount);
+ accRow.setCurrency(
+ extractCurrencyFromMatches(matchResult, acc.getCurrencyMatchGroup(),
+ acc.getCurrencyObject()));
newItems.add(accRow);
}
Misc.onMainThread(() -> replaceItems(newItems));
});
}
+ private String extractCurrencyFromMatches(MatchResult m, Integer group, Currency literal) {
+ return extractStringFromMatches(m, group, (literal == null) ? "" : literal.getName());
+ }
private int extractIntFromMatches(MatchResult m, Integer group, Integer literal) {
if (literal != null)
return literal;
if (group != null) {
int grp = group;
- if (grp > 0 & grp <= m.groupCount())
+ if (grp > 0 && grp <= m.groupCount())
try {
return Integer.parseInt(m.group(grp));
}
if (group != null) {
int grp = group;
- if (grp > 0 & grp <= m.groupCount())
+ if (grp > 0 && grp <= m.groupCount())
return m.group(grp);
}
if (group != null) {
int grp = group;
- if (grp > 0 & grp <= m.groupCount())
+ if (grp > 0 && grp <= m.groupCount())
try {
return Float.valueOf(m.group(grp));
}
List<Item> newList = new ArrayList<>();
Item.resetIdDispenser();
+ Item currentHead = items.getValue()
+ .get(0);
TransactionHead head = new TransactionHead(tr.transaction.getDescription());
head.setComment(tr.transaction.getComment());
+ if (currentHead instanceof TransactionHead)
+ head.setDate(((TransactionHead) currentHead).date);
newList.add(head);