use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.
the class LoanActivityTag method doStartTag.
@Override
public int doStartTag() throws JspException {
XmlBuilder xmlBuilder = new XmlBuilder();
try {
String currentFlowKey = (String) pageContext.getRequest().getAttribute(Constants.CURRENTFLOWKEY);
HttpSession session = pageContext.getSession();
FlowManager flowManager = (FlowManager) session.getAttribute(Constants.FLOWMANAGER);
Object object = flowManager.getFromFlow(currentFlowKey, LoanConstants.LOAN_ALL_ACTIVITY_VIEW);
if (object == null) {
// for spring/ftl
object = pageContext.getRequest().getAttribute(LoanConstants.LOAN_ALL_ACTIVITY_VIEW);
}
if (null != object) {
UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USER_CONTEXT_KEY);
locale = userContext.getPreferredLocale();
xmlBuilder.startTag("table", "width", "100%", "border", "0", "cellspacing", "0", "cellpadding", "0", "id", "accountActivityTable");
xmlBuilder.startTag("tr");
xmlBuilder.startTag("td", "colspan", "8");
//xmlBuilder.nonBreakingSpace();
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "colspan", "4", "class", "drawtablerowboldnoline");
xmlBuilder.text(getLabel("loan.running_bal", locale));
xmlBuilder.endTag("td");
xmlBuilder.endTag("tr");
xmlBuilder.startTag("tr", "class", "drawtablerowbold");
xmlBuilder.startTag("td", "width", "9%", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.date", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "19%", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.activity", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.principal", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(ConfigurationConstants.INTEREST));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.fees", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.penalty", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "6%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.total", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "4", "align", "right", "class", "fontnormalbold");
//xmlBuilder.nonBreakingSpace();
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.principal", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(ConfigurationConstants.INTEREST));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "8%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.fees", locale));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "width", "6%", "align", "right", "class", "drawtablerowbold");
xmlBuilder.text(getLabel("loan.total", locale));
xmlBuilder.endTag("td");
xmlBuilder.endTag("tr");
List<LoanActivityDto> loanRecentActivityViewSet = (List<LoanActivityDto>) object;
Iterator<LoanActivityDto> it = loanRecentActivityViewSet.iterator();
while (it.hasNext()) {
LoanActivityDto loanActivityDto = it.next();
xmlBuilder.startTag("tr", "valign", "top");
xmlBuilder.append(buildLeftHeaderRows(loanActivityDto));
xmlBuilder.append(buildRightHeaderRows(loanActivityDto));
xmlBuilder.endTag("tr");
}
xmlBuilder.endTag("table");
}
pageContext.getOut().write(xmlBuilder.toString());
} catch (Exception e) {
throw new JspException(e);
}
return SKIP_BODY;
}
use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.
the class LoanActivityTag method buildLeftHeaderRows.
XmlBuilder buildLeftHeaderRows(LoanActivityDto loanRecentActivityView) {
XmlBuilder xmlBuilder = new XmlBuilder();
xmlBuilder.startTag("td", "class", "drawtablerow");
xmlBuilder.text(DateUtils.getUserLocaleDate(locale, loanRecentActivityView.getActionDate().toString()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "class", "drawtablerow");
xmlBuilder.text(loanRecentActivityView.getActivity());
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getPrincipal()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getInterest()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getFees()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getPenalty()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getTotal()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "fontnormalbold");
xmlBuilder.singleTag("br");
xmlBuilder.endTag("td");
return xmlBuilder;
}
use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.
the class LoanActivityTag method buildRightHeaderRows.
XmlBuilder buildRightHeaderRows(LoanActivityDto loanRecentActivityView) {
XmlBuilder xmlBuilder = new XmlBuilder();
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getRunningBalancePrinciple()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getRunningBalanceInterest()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getRunningBalanceFees()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "drawtablerow");
xmlBuilder.text(ConversionUtil.formatNumber(loanRecentActivityView.getRunningBalancePrincipleWithInterestAndFees()));
xmlBuilder.endTag("td");
xmlBuilder.startTag("td", "align", "right", "class", "fontnormalbold");
xmlBuilder.singleTag("br");
xmlBuilder.endTag("td");
return xmlBuilder;
}
use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.
the class LoanRepaymentTag method doStartTag.
@Override
public int doStartTag() throws JspException {
boolean twoTables = false;
XmlBuilder html = new XmlBuilder();
LoanBO loanBO = null;
try {
String currentFlowKey = (String) pageContext.getRequest().getAttribute(Constants.CURRENTFLOWKEY);
HttpSession session = pageContext.getSession();
FlowManager flowManager = (FlowManager) session.getAttribute(Constants.FLOWMANAGER);
loanBO = (LoanBO) flowManager.getFromFlow(currentFlowKey, Constants.BUSINESS_KEY);
if (StringUtils.isNotBlank(memberGlobalNum)) {
loanBO = loanBO.findMemberByGlobalNum(memberGlobalNum);
}
Date viewDate = getViewDate(currentFlowKey, flowManager);
Money totalPrincipal = new Money(loanBO.getCurrency(), "0");
Money totalInterest = new Money(loanBO.getCurrency(), "0");
Money totalFees = new Money(loanBO.getCurrency(), "0");
Money totalPenalties = new Money(loanBO.getCurrency(), "0");
/*
* LoanBO loanBO = (LoanBO) pageContext.getRequest().getAttribute( Constants.BUSINESS_KEY);
*/
List<AccountActionDateEntity> list = new ArrayList<AccountActionDateEntity>();
if (isNewGropLoan) {
List<LoanBO> memberAccounts = getMemberScheduleDetails(loanBO.getAccountId());
list.addAll(generateGroupSchedule(memberAccounts, loanBO));
} else {
list.addAll(loanBO.getAccountActionDates());
}
UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USER_CONTEXT_KEY);
locale = userContext.getPreferredLocale();
if (list.size() != 0) {
// topmost table
html.startTag("table", "width", "100%", "border", "0", "cellspacing", "0", "cellpadding", "0");
// Left side header
XmlBuilder htmlHeader1 = new XmlBuilder();
htmlHeader1.startTag("tr");
htmlHeader1.startTag("td", "width", "6%", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.no", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "15%", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.due_date", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "15%", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.date_paid", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "12%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.principal", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "10%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(ConfigurationConstants.INTEREST));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "10%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.fees", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "11%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.penalty", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "11%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.daysLate", locale));
htmlHeader1.endTag("td");
htmlHeader1.startTag("td", "width", "10%", "align", "right", "class", "drawtablerowbold");
htmlHeader1.text(getLabel("loan.total", locale));
htmlHeader1.endTag("td");
htmlHeader1.endTag("tr");
for (AccountActionDateEntity acctDate : list) {
LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) acctDate;
totalPrincipal = totalPrincipal.add(loanScheduleEntity.getPrincipal());
totalInterest = totalInterest.add(loanScheduleEntity.getEffectiveInterest());
totalFees = totalFees.add(loanScheduleEntity.getTotalScheduledFeeAmountWithMiscFee());
totalPenalties = totalPenalties.add(loanScheduleEntity.getTotalPenalty());
}
// check if at least the first installment is paid
LoanScheduleEntity firstInstallment = (LoanScheduleEntity) list.get(0);
XmlBuilder html1 = new XmlBuilder();
XmlBuilder html2 = new XmlBuilder();
XmlBuilder htmlHeader2 = new XmlBuilder();
if (!firstInstallment.getTotalDueWithFees().equals(firstInstallment.getTotalScheduleAmountWithFees())) {
twoTables = true;
// installments paid and running balance table is
// required
htmlHeader2.startTag("tr");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(getLabel("loan.principal", locale));
htmlHeader2.endTag("td");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(ConfigurationConstants.INTEREST));
htmlHeader2.endTag("td");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(getLabel("loan.fees", locale));
htmlHeader2.endTag("td");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(getLabel("loan.penalty", locale));
htmlHeader2.endTag("td");
htmlHeader2.startTag("td", "width", "20%", "align", "right", "class", "drawtablerowbold");
htmlHeader2.text(getLabel("loan.total", locale));
htmlHeader2.endTag("td");
htmlHeader2.endTag("tr");
}
html1.startTag("tr");
html1.startTag("td", "colspan", "9", "class", "drawtablerowbold");
html1.nonBreakingSpace();
html1.endTag("td");
html1.endTag("tr");
html2.startTag("tr");
html2.startTag("td", "colspan", "5", "class", "drawtablerowbold");
html2.text(getLabel("loan.running_bal", locale));
html2.endTag("td");
html2.endTag("tr");
html1.append(htmlHeader1);
html2.append(htmlHeader2);
if (twoTables) {
html1.startTag("tr");
html1.startTag("td", "colspan", "9", "class", "drawtablerowbold");
html1.text(getLabel("loan.instt_paid", locale));
html1.endTag("td");
html1.endTag("tr");
html2.startTag("tr");
html2.startTag("td", "colspan", "5", "class", "drawtablerowbold");
html2.nonBreakingSpace();
html2.endTag("td");
html2.endTag("tr");
}
int index = 0;
boolean toContinue = true;
LoanScheduleEntity installment = (LoanScheduleEntity) list.get(index);
while (index <= list.size() - 1 && toContinue && !installment.getTotalDueWithFees().equals(installment.getTotalScheduleAmountWithFees())) {
html1.append(createInstallmentRow(installment, true, isNewGropLoan));
html2.append(createRunningBalanceRow(installment, totalPrincipal, totalInterest, totalFees, totalPenalties));
totalPrincipal = totalPrincipal.subtract(installment.getPrincipalPaid());
totalInterest = totalInterest.subtract(installment.getEffectiveInterestPaid());
totalFees = totalFees.subtract(installment.getTotalFeeAmountPaidWithMiscFee());
totalPenalties = totalPenalties.subtract(installment.getPenaltyPaid());
if (index != list.size() - 1 && installment.isPaid()) {
index++;
installment = (LoanScheduleEntity) list.get(index);
} else {
toContinue = false;
}
}
boolean dueInstallments = false;
if (!installment.isPaid() && installment.getActionDate().getTime() <= viewDate.getTime()) {
dueInstallments = true;
}
if (dueInstallments) {
html1.startTag("tr");
html1.startTag("td", "colspan", "9", "class", "drawtablerowbold");
html1.text(getLabel("loan.instt_due", locale));
html1.endTag("td");
html1.endTag("tr");
while (index < list.size() - 1 && !installment.isPaid() && installment.getActionDate().getTime() <= viewDate.getTime()) {
index++;
html1.append(createInstallmentRow(installment, false, isNewGropLoan));
installment = (LoanScheduleEntity) list.get(index);
}
}
boolean futureInstallments = false;
if (!installment.isPaid() && installment.getActionDate().getTime() > viewDate.getTime()) {
futureInstallments = true;
}
if (futureInstallments) {
html1.startTag("tr");
html1.startTag("td", "colspan", "9", "class", "drawtablerowbold");
html1.text(getLabel("loan.future_install", locale));
html1.endTag("td");
html1.endTag("tr");
while (index < list.size() - 1) {
index++;
html1.append(createInstallmentRow(installment, false, isNewGropLoan));
installment = (LoanScheduleEntity) list.get(index);
}
}
// append the last transaction
if (!installment.isPaid()) {
html1.append(createInstallmentRow(installment, false, isNewGropLoan));
}
long totalDaysLate = 0;
for (AccountActionDateEntity accountActionDateEntity : list) {
totalDaysLate += accountActionDateEntity.getDaysLate();
}
XmlBuilder totalDaysLateXmlBuilder = new XmlBuilder();
totalDaysLateXmlBuilder.startTag("tr");
totalDaysLateXmlBuilder.startTag("td", "class", "drawtablerow", "colspan", "8", "align", "right");
totalDaysLateXmlBuilder.text(getLabel("loan.total", locale) + ": " + totalDaysLate);
totalDaysLateXmlBuilder.endTag("td");
totalDaysLateXmlBuilder.startTag("td", "class", "drawtablerow");
totalDaysLateXmlBuilder.nonBreakingSpace();
totalDaysLateXmlBuilder.endTag("td");
totalDaysLateXmlBuilder.endTag("tr");
html1.append(totalDaysLateXmlBuilder);
if (twoTables) {
// add a tr with 2 td for each of the 2 tables
html.startTag("tr");
html.startTag("td", "width", "70%");
html.startTag("table", "width", "95%", "border", "0", "cellspacing", "0", "cellpadding", "5", "id", "repaymentScheduleTable");
html.append(html1);
html.endTag("table");
html.endTag("td");
html.startTag("td", "width", "25%", "valign", "top");
html.startTag("table", "width", "95%", "border", "0", "cellspacing", "0", "cellpadding", "5", "id", "runningBalanceTable");
html.append(html2);
html.endTag("table");
html.endTag("td");
html.endTag("tr");
html.endTag("table");
} else {
html.startTag("tr");
html.startTag("td", "width", "100%");
html.startTag("table", "id", "installments", "width", "95%", "border", "0", "cellspacing", "0", "cellpadding", "5");
html.append(html1);
html.endTag("table");
html.endTag("td");
html.endTag("tr");
html.endTag("table");
}
}
pageContext.getOut().write(html.toString());
} catch (Exception e) {
throw new JspException(e);
}
return SKIP_BODY;
}
use of org.mifos.framework.struts.tags.XmlBuilder in project head by mifos.
the class LoanRepaymentTag method createRunningBalanceRow.
XmlBuilder createRunningBalanceRow(LoanScheduleEntity installment, Money totalPrincipal, Money totalInterest, Money totalFees, Money totalPenalties) {
XmlBuilder html = new XmlBuilder();
html.startTag("tr");
html.startTag("td", "width", "20%", "align", "right", "class", "drawtablerow");
html.text(ConversionUtil.formatNumber(totalPrincipal.subtract(installment.getPrincipalPaid()).toString()));
html.endTag("td");
html.startTag("td", "width", "20%", "align", "right", "class", "drawtablerow");
html.text(ConversionUtil.formatNumber(totalInterest.subtract(installment.getEffectiveInterestPaid()).toString()));
html.endTag("td");
html.startTag("td", "width", "20%", "align", "right", "class", "drawtablerow");
html.text(ConversionUtil.formatNumber(totalFees.subtract(installment.getTotalFeeAmountPaidWithMiscFee()).toString()));
html.endTag("td");
html.startTag("td", "width", "20%", "align", "right", "class", "drawtablerow");
html.text(ConversionUtil.formatNumber(totalPenalties.subtract(installment.getTotalPenaltyPaid()).toString()));
html.endTag("td");
html.startTag("td", "width", "20%", "align", "right", "class", "drawtablerow");
html.text((ConversionUtil.formatNumber(String.valueOf(totalPrincipal.add(totalInterest).add(totalFees).add(totalPenalties).subtract(installment.getPrincipalPaid()).subtract(installment.getEffectiveInterestPaid()).subtract(installment.getTotalFeeAmountPaidWithMiscFee()).subtract(installment.getTotalPenaltyPaid())))).toString());
html.endTag("td");
html.endTag("tr");
return html;
}
Aggregations