private ParsedQuantity aquantity;
private boolean aismultiplier;
private ParsedStyle astyle;
+ private ParsedPrice aprice = new ParsedPrice();
public ParsedAmount() {
}
+ public ParsedPrice getAprice() {
+ return aprice;
+ }
+ public void setAprice(ParsedPrice aprice) {
+ this.aprice = aprice;
+ }
public String getAcommodity() {
return acommodity;
}
import net.ktnx.mobileledger.utils.Globals;
import java.text.ParseException;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ParsedLedgerTransaction {
- private String tdate, tdate2, tdescription, tcomment;
+ private String tdate;
+ private String tdate2;
+ private String tdescription;
+ private String tcomment;
+ private String tcode = "";
+ private String tstatus = "Unmarked";
+ private String tprecedingcomment;
private int tindex;
private List<ParsedPosting> tpostings;
+ private List<String> ttags = new ArrayList<>();
+ private ParsedSourcePos tsourcepos = new ParsedSourcePos();
public ParsedLedgerTransaction() {
}
+ public String getTcode() {
+ return tcode;
+ }
+ public void setTcode(String tcode) {
+ this.tcode = tcode;
+ }
+ public String getTstatus() {
+ return tstatus;
+ }
+ public void setTstatus(String tstatus) {
+ this.tstatus = tstatus;
+ }
+ public List<String> getTtags() {
+ return ttags;
+ }
+ public void setTtags(List<String> ttags) {
+ this.ttags = ttags;
+ }
+ public ParsedSourcePos getTsourcepos() {
+ return tsourcepos;
+ }
+ public void setTsourcepos(ParsedSourcePos tsourcepos) {
+ this.tsourcepos = tsourcepos;
+ }
+ public String getTprecedingcomment() {
+ return tprecedingcomment;
+ }
+ public void setTprecedingcomment(String tprecedingcomment) {
+ this.tprecedingcomment = tprecedingcomment;
+ }
public String getTdate() {
return tdate;
}
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
+import java.util.ArrayList;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ParsedPosting {
+ private Void pbalanceassertion;
+ private String pstatus = "Unmarked";
private String paccount;
private List<ParsedAmount> pamount;
+ private String pdate = null;
+ private String ptype = "RegularPosting";
+ private String pcomment = "";
+ private ArrayList<String> ptags = new ArrayList<>();
+ private String poriginal = null;
public ParsedPosting() {
}
+ public String getPdate() {
+ return pdate;
+ }
+ public void setPdate(String pdate) {
+ this.pdate = pdate;
+ }
+ public String getPtype() {
+ return ptype;
+ }
+ public void setPtype(String ptype) {
+ this.ptype = ptype;
+ }
+ public String getPcomment() {
+ return pcomment;
+ }
+ public void setPcomment(String pcomment) {
+ this.pcomment = pcomment;
+ }
+ public ArrayList<String> getPtags() {
+ return ptags;
+ }
+ public void setPtags(ArrayList<String> ptags) {
+ this.ptags = ptags;
+ }
+ public String getPoriginal() {
+ return poriginal;
+ }
+ public void setPoriginal(String poriginal) {
+ this.poriginal = poriginal;
+ }
+ public String getPstatus() {
+ return pstatus;
+ }
+ public void setPstatus(String pstatus) {
+ this.pstatus = pstatus;
+ }
+ public Void getPbalanceassertion() {
+ return pbalanceassertion;
+ }
+ public void setPbalanceassertion(Void pbalanceassertion) {
+ this.pbalanceassertion = pbalanceassertion;
+ }
public String getPaccount() {
return paccount;
}
--- /dev/null
+/*
+ * Copyright © 2019 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.json;
+
+class ParsedPrice {
+ private String tag;
+ public ParsedPrice() {
+ tag = "NoPrice";
+ }
+ public String getTag() {
+ return tag;
+ }
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2019 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.json;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class ParsedSourcePos {
+ private String tag = "JournalSourcePos";
+ private List<Object> contents;
+ public ParsedSourcePos() {
+ contents = new ArrayList<>();
+ contents.add("");
+ contents.add(new Integer[]{1, 1});
+ }
+ public String getTag() {
+ return tag;
+ }
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+ public List<Object> getContents() {
+ return contents;
+ }
+ public void setContents(List<Object> contents) {
+ this.contents = contents;
+ }
+}
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
+import net.ktnx.mobileledger.json.ParsedLedgerTransaction;
+import net.ktnx.mobileledger.json.ParsedPosting;
import net.ktnx.mobileledger.utils.Digest;
import net.ktnx.mobileledger.utils.Globals;
public void finishLoading() {
dataLoaded = true;
}
+ public ParsedLedgerTransaction toParsedLedgerTransaction() {
+ ParsedLedgerTransaction result = new ParsedLedgerTransaction();
+ result.setTcomment("");
+ result.setTprecedingcomment("");
+
+ ArrayList<ParsedPosting> postings = new ArrayList<>();
+ for (LedgerTransactionAccount acc : accounts) {
+ if (!acc.getAccountName().isEmpty()) postings.add(acc.asParsedPosting());
+ }
+
+ result.setTpostings(postings);
+ result.setTdate(Globals.formatIsoDate(date));
+ result.setTdate2(null);
+ result.setTindex(1);
+ result.setTdescription(description);
+ return result;
+ }
}
package net.ktnx.mobileledger.model;
+import net.ktnx.mobileledger.json.ParsedAmount;
+import net.ktnx.mobileledger.json.ParsedPosting;
+import net.ktnx.mobileledger.json.ParsedQuantity;
+import net.ktnx.mobileledger.json.ParsedStyle;
+
+import java.util.ArrayList;
+
import androidx.annotation.NonNull;
public class LedgerTransactionAccount {
return sb.toString();
}
+ public ParsedPosting asParsedPosting() {
+ ParsedPosting result = new ParsedPosting();
+ result.setPaccount(accountName);
+ ArrayList<ParsedAmount> amounts = new ArrayList<>();
+ ParsedAmount amt = new ParsedAmount();
+ amt.setAcommodity((currency == null) ? "" : currency);
+ amt.setAismultiplier(false);
+ ParsedQuantity qty = new ParsedQuantity();
+ qty.setDecimalPlaces(2);
+ qty.setDecimalMantissa(Math.round(amount * 100));
+ amt.setAquantity(qty);
+ ParsedStyle style = new ParsedStyle();
+ style.setAscommodityside('L');
+ style.setAscommodityspaced(false);
+ style.setAsprecision(2);
+ style.setAsdecimalpoint('.');
+ amt.setAstyle(style);
+ amounts.add(amt);
+ result.setPamount(amounts);
+ return result;
+ }
}