import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
-public class ParsedPosting {
+public class ParsedPosting extends net.ktnx.mobileledger.json.ParsedPosting {
private Void pbalanceassertion;
private String pstatus = "Unmarked";
private String paccount;
public static ParsedPosting fromLedgerAccount(LedgerTransactionAccount acc) {
ParsedPosting result = new ParsedPosting();
result.setPaccount(acc.getAccountName());
+
+ String comment = acc.getComment();
+ if (comment == null)
+ comment = "";
+ result.setPcomment(comment);
+
ArrayList<ParsedAmount> amounts = new ArrayList<>();
ParsedAmount amt = new ParsedAmount();
amt.setAcommodity((acc.getCurrency() == null) ? "" : acc.getCurrency());
qty.setDecimalMantissa(Math.round(acc.getAmount() * 100));
amt.setAquantity(qty);
ParsedStyle style = new ParsedStyle();
- style.setAscommodityside('L');
- style.setAscommodityspaced(false);
+ style.setAscommodityside(getCommoditySide());
+ style.setAscommodityspaced(getCommoditySpaced());
style.setAsprecision(2);
style.setAsdecimalpoint('.');
amt.setAstyle(style);
+ if (acc.getCurrency() != null)
+ amt.setAcommodity(acc.getCurrency());
amounts.add(amt);
result.setPamount(amounts);
return result;
return pcomment;
}
public void setPcomment(String pcomment) {
- this.pcomment = pcomment;
+ this.pcomment = (pcomment == null) ? null : pcomment.trim();
}
public List<List<String>> getPtags() {
return ptags;
public LedgerTransactionAccount asLedgerAccount() {
ParsedAmount amt = pamount.get(0);
return new LedgerTransactionAccount(paccount, amt.getAquantity()
- .asFloat(), amt.getAcommodity());
+ .asFloat(), amt.getAcommodity(),
+ getPcomment());
}
}