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.Date;
27 import java.util.List;
29 @JsonIgnoreProperties(ignoreUnknown = true)
30 public class ParsedLedgerTransaction {
31 private String tdate, tdate2, tdescription, tcomment;
33 private List<ParsedPosting> tpostings;
34 public ParsedLedgerTransaction() {
36 public String getTdate() {
39 public void setTdate(String tdate) {
42 public String getTdate2() {
45 public void setTdate2(String tdate2) {
48 public String getTdescription() {
51 public void setTdescription(String tdescription) {
52 this.tdescription = tdescription;
54 public String getTcomment() {
57 public void setTcomment(String tcomment) {
58 this.tcomment = tcomment;
60 public int getTindex() {
63 public void setTindex(int tindex) {
66 public List<ParsedPosting> getTpostings() {
69 public void setTpostings(List<ParsedPosting> tpostings) {
70 this.tpostings = tpostings;
72 public LedgerTransaction asLedgerTransaction() throws ParseException {
73 Date date = Globals.parseIsoDate(tdate);
74 LedgerTransaction tr = new LedgerTransaction(tindex, date, tdescription);
76 List<ParsedPosting> postings = tpostings;
78 if (postings != null) {
79 for (ParsedPosting p : postings) {
80 tr.addAccount(p.asLedgerAccount());