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=f759114954532b50b32d5baddfa9a2cb058e9774;hp=ad6c94c26f2948368f06c725cd6913c91f9140d8;hb=832915f331975d285df89c547537aae3e4300739;hpb=04f4085aad9982912b5061d3c0fb67892089816a 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..f7591149 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java @@ -19,6 +19,13 @@ package net.ktnx.mobileledger.model; import androidx.annotation.NonNull; +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; + public class LedgerTransactionAccount { private String accountName; private String shortAccountName; @@ -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; + } }