2 * Copyright © 2019 Damyan Ivanov.
3 * This file is part of MoLe.
4 * MoLe is free software: you can distribute it and/or modify it
5 * under the term of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your opinion), any later version.
9 * MoLe is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License terms for details.
14 * You should have received a copy of the GNU General Public License
15 * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
18 package net.ktnx.mobileledger.json;
20 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
22 import net.ktnx.mobileledger.model.LedgerTransaction;
23 import net.ktnx.mobileledger.utils.Globals;
25 import java.text.ParseException;
26 import java.util.ArrayList;
27 import java.util.Date;
28 import java.util.List;
30 @JsonIgnoreProperties(ignoreUnknown = true)
31 public class ParsedLedgerTransaction {
33 private String tdate2;
34 private String tdescription;
35 private String tcomment;
36 private String tcode = "";
37 private String tstatus = "Unmarked";
38 private String tprecedingcomment;
40 private List<ParsedPosting> tpostings;
41 private List<String> ttags = new ArrayList<>();
42 private ParsedSourcePos tsourcepos = new ParsedSourcePos();
43 public ParsedLedgerTransaction() {
45 public String getTcode() {
48 public void setTcode(String tcode) {
51 public String getTstatus() {
54 public void setTstatus(String tstatus) {
55 this.tstatus = tstatus;
57 public List<String> getTtags() {
60 public void setTtags(List<String> ttags) {
63 public ParsedSourcePos getTsourcepos() {
66 public void setTsourcepos(ParsedSourcePos tsourcepos) {
67 this.tsourcepos = tsourcepos;
69 public String getTprecedingcomment() {
70 return tprecedingcomment;
72 public void setTprecedingcomment(String tprecedingcomment) {
73 this.tprecedingcomment = tprecedingcomment;
75 public String getTdate() {
78 public void setTdate(String tdate) {
81 public String getTdate2() {
84 public void setTdate2(String tdate2) {
87 public String getTdescription() {
90 public void setTdescription(String tdescription) {
91 this.tdescription = tdescription;
93 public String getTcomment() {
96 public void setTcomment(String tcomment) {
97 this.tcomment = tcomment;
99 public int getTindex() {
102 public void setTindex(int tindex) {
103 this.tindex = tindex;
105 public List<ParsedPosting> getTpostings() {
108 public void setTpostings(List<ParsedPosting> tpostings) {
109 this.tpostings = tpostings;
111 public LedgerTransaction asLedgerTransaction() throws ParseException {
112 Date date = Globals.parseIsoDate(tdate);
113 LedgerTransaction tr = new LedgerTransaction(tindex, date, tdescription);
115 List<ParsedPosting> postings = tpostings;
117 if (postings != null) {
118 for (ParsedPosting p : postings) {
119 tr.addAccount(p.asLedgerAccount());