X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FLedgerTransactionAccount.java;h=6f8c3b4476a5136dcb787ec2f25f4ae05f8380d5;hp=ad6c94c26f2948368f06c725cd6913c91f9140d8;hb=d7feaff3ca4490495ca721b29b77c1646591a34c;hpb=e58a4542d0054772b1939b3eeb1b97f1384c60e6 diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java index ad6c94c2..6f8c3b44 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java @@ -17,6 +17,13 @@ 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 { @@ -85,4 +92,25 @@ public class LedgerTransactionAccount { return sb.toString(); } + public ParsedPosting asParsedPosting() { + ParsedPosting result = new ParsedPosting(); + result.setPaccount(accountName); + ArrayList 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; + } }