--- /dev/null
+package net.ktnx.mobileledger;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+class LedgerTransaction {
+ private String date;
+ private String description;
+ private List<LedgerTransactionItem> items;
+
+ LedgerTransaction(String date, String description) {
+ this.date = date;
+ this.description = description;
+ this.items = new ArrayList<LedgerTransactionItem>();
+ }
+
+ void add_item(LedgerTransactionItem item) {
+ items.add(item);
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Iterator<LedgerTransactionItem> getItemsIterator() {
+ return new Iterator<LedgerTransactionItem>() {
+ private int pointer = 0;
+ @Override
+ public boolean hasNext() {
+ return pointer < items.size();
+ }
+
+ @Override
+ public LedgerTransactionItem next() {
+ return hasNext() ? items.get(pointer++) : null;
+ }
+ };
+ }
+}
--- /dev/null
+package net.ktnx.mobileledger;
+
+class LedgerTransactionItem {
+ private String account_name;
+ private float amount;
+ private boolean amount_set;
+
+ LedgerTransactionItem(String account_name, float amount) {
+ this.account_name = account_name;
+ this.amount = amount;
+ this.amount_set = true;
+ }
+
+ public LedgerTransactionItem(String account_name) {
+ this.account_name = account_name;
+ }
+
+ public String get_account_name() {
+ return account_name;
+ }
+
+ public void set_account_name(String account_name) {
+ this.account_name = account_name;
+ }
+
+ public float get_amount() {
+ if (!amount_set)
+ throw new IllegalStateException("Account amount is not set");
+
+ return amount;
+ }
+
+ public void set_amount(float account_amount) {
+ this.amount = account_amount;
+ this.amount_set = true;
+ }
+
+ public void reset_amount() {
+ this.amount_set = false;
+ }
+
+ public boolean is_amount_set() {
+ return amount_set;
+ }
+}