this.sumOfMoneyPresenter = moneyPresenter;
}
public XmlsonObject present(ImmutableMap<Interval, MonetarySummaryWithSplits> summaries, Locale locale) {
final XmlsonObject root = new XmlsonObject("interval-summary");
final XmlsonArray array = new XmlsonArray("summaries");
for (Map.Entry<Interval, MonetarySummaryWithSplits> summary : summaries.entrySet()) {
final XmlsonObject item = new XmlsonObject("summary");
final XmlsonObject interval = new XmlsonObject("interval");
interval.addProperty("start", ISO_BASIC.print(summary.getKey().getStart()));
interval.addProperty("end", ISO_BASIC.print(summary.getKey().getEnd()));
item.add(interval);
item.add(sumOfMoneyPresenter.present("spending", summary.getValue().getSpending(), locale));
item.add(sumOfMoneyPresenter.present("earnings", summary.getValue().getEarnings(), locale));
item.add(sumOfMoneyPresenter.present("net", summary.getValue().getNet(), locale));
final XmlsonArray splits = new XmlsonArray("splits");
for (Entry<Tag, MonetarySummary> entry : summary.getValue().getSplitSummaries().entrySet()) {
final XmlsonObject splitsSummary = new XmlsonObject("split");
final XmlsonObject tagName = new XmlsonObject("tag");
tagName.addProperty("name", entry.getKey().toString());
splitsSummary.add(tagName);
splitsSummary.add(sumOfMoneyPresenter.present("spending", entry.getValue().getSpending(), locale));
splitsSummary.add(sumOfMoneyPresenter.present("earnings", entry.getValue().getEarnings(), locale));
splitsSummary.add(sumOfMoneyPresenter.present("net", entry.getValue().getNet(), locale));
splits.add(splitsSummary);
}
item.add(splits);
array.add(item);
}