boldStyle.setPdfEncoding("Cp1252");
boldStyle.setPdfEmbedded(false);
jasperPrint.addStyle(boldStyle);
page = new JRBasePrintPage();
posY = convert(10);
int posX = convert(10);
page.addElement(printImage("titleReport.gif", posX, posY, 535, 45));
page.addElement(printImage("corporateLogo.jpg", posX+11, posY, 65, 45));
page.addElement(insertTitle(contTitle, posX+200, posY+11, 330));
posY += 50;
try {
//---------------------------------------
String obs = " - (*) Referente a taxa de matr�cula.";
Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
int index = 0;
for (Registration registration : registrationMap.values()) {
Person person = (Person) system.query(new GetPerson(registration.getIdPerson()));
int numberOfParcel = 1;
for (Parcel parcel : registration.getParcels()) {
if(parcel.isPayed()) {
parcelPayDate = new GDDate(parcel.getPayDate());
if (parcelPayDate.afterOrEqualsDay(startDate) && parcelPayDate.beforeOrEqualsDay(finishDate)) {
createParcelsMap(person, parcel, index , numberOfParcel, registration.isActive(), registration.getIdRegistration());
index++;
}
}
numberOfParcel++;
}
}
///------------------------------------------
// gambiarra para ordenar a segunda coluna huauhahauha
Comparator<ParcelData> comparator = new Comparator<ParcelData>() {
@Override
public int compare(ParcelData o1, ParcelData o2) {
int result = -1;
Calendar calendar1 = Calendar.getInstance();
calendar1.set(o1.getParcel().getPayDate().getYear(), o1.getParcel().getPayDate().getMonth(), o1.getParcel().getPayDate().getDayOfMonth());
Calendar calendar2 = Calendar.getInstance();
calendar2.set(o2.getParcel().getPayDate().getYear(), o2.getParcel().getPayDate().getMonth(), o2.getParcel().getPayDate().getDayOfMonth());
// Date date = new Date(o1.getParcel().getPayDate().getYear(), o1.getParcel().getPayDate().getMonth(), o1.getParcel().getPayDate().getDayOfMonth());
// Date date2 = new Date(o2.getParcel().getPayDate().getYear(), o2.getParcel().getPayDate().getMonth(), o2.getParcel().getPayDate().getDayOfMonth());
result = calendar1.compareTo(calendar2);
return result;
}
};
//metodo original
// MergeSortAlgorithm sortAlgorithm= new MergeSortAlgorithm();
// if(parcelDataListRegistrated.size() > 1){
// sortAlgorithm.sortParcelByDate(parcelDataListRegistrated);
// }
// if(parcelDataListFinalization.size() > 1){
// sortAlgorithm.sortParcelByDate(parcelDataListFinalization);
// }
Collections.sort(parcelDataListRegistrated, comparator);
Collections.sort(parcelDataListFinalization, comparator);
int allTotalOfParcels = 0;
int allValueTotalOfParcels = 0;
int totalOfParcels = 0;
int valueTotalOfParcels = 0;
posY += 5;
page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
page.addElement(insertTitleBox("Alunos Matriculados" + obs));
posY += 25;
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertCenterBoldText("Nome", posX, 170));
page.addElement(divLine(posX+170));
page.addElement(insertCenterBoldText("Data de Pgto", posX+170, 70));
page.addElement(divLine(posX+240));
page.addElement(insertCenterBoldText("Data de Vcto", posX+240, 70));
page.addElement(divLine(posX+310));
page.addElement(insertCenterBoldText("Parcela", posX+310, 45));
page.addElement(divLine(posX+355));
page.addElement(insertCenterBoldText("Multa", posX+355, 45));
page.addElement(divLine(posX+400));
page.addElement(insertCenterBoldText("Mora", posX+400, 45));
page.addElement(divLine(posX+445));
page.addElement(insertCenterBoldText("Desc.", posX+445, 45));
page.addElement(divLine(posX+490));
page.addElement(insertCenterBoldText("Valor", posX+490, 40));
posY += 15;
for(ParcelData parcel : parcelDataListRegistrated){
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertText((parcel.isRegistrationTax() ? "(*) " : "") + parcel.getStudentName(), posX+5, 165));
page.addElement(divLine(posX+170));
page.addElement(insertText(parcel.getParcel().getPayDate().getFormatedDate(), posX+175, 65));
page.addElement(divLine(posX+240));
page.addElement(insertText(parcel.getParcel().getDate(), posX+245, 65));
page.addElement(divLine(posX+310));
page.addElement(insertText(parcel.getNumberOfParcel(), posX+315, 40));
page.addElement(divLine(posX+355));
page.addElement(insertRightText(new Money(parcel.getParcel().getTicket()).getFormatedValue(), posX+360, 35));
page.addElement(divLine(posX+400));
page.addElement(insertRightText(new Money(parcel.getParcel().getMora()).getFormatedValue(), posX+405, 35));
page.addElement(divLine(posX+445));
page.addElement(insertRightText(new Money(parcel.getParcel().getDiscount()).getFormatedValue(), posX+450, 35));
page.addElement(divLine(posX+490));
page.addElement(insertRightText(new Money(parcel.getParcel().getPayValue()).getFormatedValue(), posX+495, 35));
posY += 15;
totalOfParcels++;
valueTotalOfParcels += parcel.getParcelValue();
allTotalOfParcels ++;
allValueTotalOfParcels += parcel.getParcelValue();
if(posY > (convert(290)-25)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
}
page.addElement(insertFooterLeft("Total de Parcelas: "+totalOfParcels));
page.addElement(insertFooterRight("Valor Total: "+new Money(valueTotalOfParcels).getFormatedValue()));
posY += 25;
page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
page.addElement(insertTitleBox("Alunos Finalizados" + obs));
posY += 25;
totalOfParcels = 0;
valueTotalOfParcels = 0;
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertCenterBoldText("Nome", posX, 170));
page.addElement(divLine(posX+170));
page.addElement(insertCenterBoldText("Data de Pgto", posX+170, 70));
page.addElement(divLine(posX+240));
page.addElement(insertCenterBoldText("Data de Vcto", posX+240, 70));
page.addElement(divLine(posX+310));
page.addElement(insertCenterBoldText("Parcela", posX+310, 45));
page.addElement(divLine(posX+355));
page.addElement(insertCenterBoldText("Multa", posX+355, 45));
page.addElement(divLine(posX+400));
page.addElement(insertCenterBoldText("Mora", posX+400, 45));
page.addElement(divLine(posX+445));
page.addElement(insertCenterBoldText("Desc.", posX+445, 45));
page.addElement(divLine(posX+490));
page.addElement(insertCenterBoldText("Valor", posX+490, 40));
posY += 15;
for(ParcelData parcel : parcelDataListFinalization){
page.addElement(drawRectangle(posX, posY, 535, 15, 0));
page.addElement(insertText((parcel.isRegistrationTax() ? "(*) " : "") + parcel.getStudentName(), posX+5, 165));
page.addElement(divLine(posX+170));
page.addElement(insertText(parcel.getParcel().getPayDate().getFormatedDate(), posX+175, 65));
page.addElement(divLine(posX+240));
page.addElement(insertText(parcel.getParcel().getDate(), posX+245, 65));
page.addElement(divLine(posX+310));
page.addElement(insertText(parcel.getNumberOfParcel(), posX+315, 40));
page.addElement(divLine(posX+355));
page.addElement(insertRightText(new Money(parcel.getParcel().getTicket()).getFormatedValue(), posX+360, 35));
page.addElement(divLine(posX+400));
page.addElement(insertRightText(new Money(parcel.getParcel().getMora()).getFormatedValue(), posX+405, 35));
page.addElement(divLine(posX+445));
page.addElement(insertRightText(new Money(parcel.getParcel().getDiscount()).getFormatedValue(), posX+450, 35));
page.addElement(divLine(posX+490));
page.addElement(insertRightText(new Money(parcel.getParcel().getPayValue()).getFormatedValue(), posX+495, 35));
posY += 15;
totalOfParcels++;
valueTotalOfParcels += parcel.getParcelValue();
allTotalOfParcels ++;
allValueTotalOfParcels += parcel.getParcelValue();
if(posY > (convert(290)-25)){
jasperPrint.addPage(page);
page = new JRBasePrintPage();
posY = convert(10);
}
}
page.addElement(insertFooterLeft("Total de Parcelas: "+totalOfParcels));