<commit_before>package org.mifos.application.accounts.savings.struts.tag;

import java.io.IOException;
import java.sql.Date;
import java.util.List;
import java.util.Locale;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.mifos.application.accounts.business.AccountActionDateEntity;
import org.mifos.application.accounts.savings.business.SavingsBO;
import org.mifos.framework.security.util.UserContext;
import org.mifos.framework.struts.tags.DateHelper;
import org.mifos.framework.util.helpers.Constants;
import org.mifos.framework.util.helpers.Money;

public class SavingsOverDueDepositsTag extends BodyTagSupport {

	public SavingsOverDueDepositsTag() {
	}

	@Override
	public int doStartTag() throws JspException {
		Object obj = pageContext.getSession().getAttribute(
				Constants.BUSINESS_KEY);

		if (null != obj) {
			List<AccountActionDateEntity> installmentsInArrears = ((SavingsBO) obj)
					.getDetailsOfInstallmentsInArrears();
			Date actionDate = null;
			Money totalAmount = new Money();
			int currentSize = 0;
			int listSize = installmentsInArrears.size();
			Locale locale = ((UserContext) pageContext.getSession()
					.getAttribute(Constants.USERCONTEXT)).getPereferedLocale();
			StringBuilder builder = new StringBuilder();
			for (AccountActionDateEntity installment : installmentsInArrears) {
				currentSize = currentSize + 1;
				if (actionDate == null)
					actionDate = installment.getActionDate();
				if (actionDate.compareTo(installment.getActionDate()) != 0
						|| currentSize == listSize) {
					
					builder.append("<tr>");
					builder.append(buildDateUI(locale, actionDate));
					if (currentSize == listSize)
						builder.append(buildAmountUI(totalAmount
								.add(installment.getTotalDepositDue())));
					else
						builder.append(buildAmountUI(totalAmount));
					builder.append("</tr>");
					totalAmount = installment.getTotalDepositDue();
					actionDate = installment.getActionDate();
				} else
					totalAmount = totalAmount.add(installment
							.getTotalDepositDue());
			}
			try {
				pageContext.getOut().write(builder.toString());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		

		return SKIP_BODY;
	}

	private StringBuilder buildDateUI(Locale locale, Date actionDate) {
		StringBuilder builder = new StringBuilder();
		builder
				.append("<td class=\"drawtablerow\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		builder.append(DateHelper.getUserLocaleDate(locale, actionDate
				.toString()));
		builder.append("</td>");
		return builder;
	}

	private StringBuilder buildAmountUI(Money amount) {
		StringBuilder builder = new StringBuilder();
		builder.append("<td align=\"right\" class=\"drawtablerow\">");
		builder.append(amount);
		builder.append("</td>");
		builder.append("<td align=\"right\" class=\"drawtablerow\">");
		builder.append("&nbsp;");
		builder.append("</td>");
		return builder;
	}

}<commit_msg>Issue 459 resolved. UI issue.  M2 code. No test cases added/modified.<commit_after>package org.mifos.application.accounts.savings.struts.tag;

import java.io.IOException;
import java.sql.Date;
import java.util.List;
import java.util.Locale;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.mifos.application.accounts.business.AccountActionDateEntity;
import org.mifos.application.accounts.savings.business.SavingsBO;
import org.mifos.framework.security.util.UserContext;
import org.mifos.framework.struts.tags.DateHelper;
import org.mifos.framework.util.helpers.Constants;
import org.mifos.framework.util.helpers.Money;

public class SavingsOverDueDepositsTag extends BodyTagSupport {

	public SavingsOverDueDepositsTag() {
	}

	@Override
	public int doStartTag() throws JspException {
		Object obj = pageContext.getSession().getAttribute(
				Constants.BUSINESS_KEY);

		if (null != obj) {
			List<AccountActionDateEntity> installmentsInArrears = ((SavingsBO) obj)
					.getDetailsOfInstallmentsInArrears();
			Date actionDate = null;
			Money totalAmount = new Money();
			int currentSize = 0;
			int listSize = installmentsInArrears.size();
			Locale locale = ((UserContext) pageContext.getSession()
					.getAttribute(Constants.USERCONTEXT)).getPereferedLocale();
			StringBuilder builder = new StringBuilder();
			for (AccountActionDateEntity installment : installmentsInArrears) {
				currentSize++;
				if (actionDate == null)
					actionDate = installment.getActionDate();
				if (actionDate.compareTo(installment.getActionDate()) != 0
						|| currentSize == listSize) {
					if (currentSize == listSize
							&& actionDate
									.compareTo(installment.getActionDate()) == 0) {
						builder.append(buildDepositDueUIRow(locale, actionDate,
								totalAmount.add(installment
										.getTotalDepositDue())));
					} else if (actionDate
							.compareTo(installment.getActionDate()) != 0
							&& currentSize != listSize) {
						builder.append(buildDepositDueUIRow(locale, actionDate,
								totalAmount));
					} else {
						builder.append(buildDepositDueUIRow(locale, actionDate,
								totalAmount));
						builder.append(buildDepositDueUIRow(locale, installment
								.getActionDate(), installment
								.getTotalDepositDue()));
					}
					totalAmount = installment.getTotalDepositDue();
					actionDate = installment.getActionDate();
				} else
					totalAmount = totalAmount.add(installment
							.getTotalDepositDue());
			}
			try {
				pageContext.getOut().write(builder.toString());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		return SKIP_BODY;
	}

	private StringBuilder buildDateUI(Locale locale, Date actionDate) {
		StringBuilder builder = new StringBuilder();
		builder
				.append("<td class=\"drawtablerow\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		builder.append(DateHelper.getUserLocaleDate(locale, actionDate
				.toString()));
		builder.append("</td>");
		return builder;
	}

	private StringBuilder buildAmountUI(Money amount) {
		StringBuilder builder = new StringBuilder();
		builder.append("<td align=\"right\" class=\"drawtablerow\">");
		builder.append(amount);
		builder.append("</td>");
		builder.append("<td align=\"right\" class=\"drawtablerow\">");
		builder.append("&nbsp;");
		builder.append("</td>");
		return builder;
	}

	private StringBuilder buildDepositDueUIRow(Locale locale, Date actionDate,
			Money dueAmount) {
		StringBuilder builder = new StringBuilder();
		builder.append("<tr>");
		builder.append(buildDateUI(locale, actionDate));
		builder.append(buildAmountUI(dueAmount));
		builder.append("</tr>");
		return builder;
	}

}
{'fraction_non_alphanumeric': 0.12800726282342262, 'fraction_numerical': 0.0016643970343471024, 'mean_word_length': 4.458298926507019, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3407734', 'n_tokens_mistral': 2389, 'n_tokens_neox': 1956, 'n_words': 357}