/** * Get billing history * * @param card * @param limit * @param start * @return */ public String getHistory(Card card, Integer limit, Integer start) { this.currentCard = card; JSONObject json = new JSONObject(); List<Invoice> history = invoiceService.getIncome(currentCard); history.addAll(invoiceService.getOutcome(currentCard)); try { json.put("total", history.size()); for (int i = start; i <= start + limit && i < history.size(); i++) { json.accumulate("history", history.get(i).toJson()); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return json.toString(); }