Skip to content

Commit

Permalink
Merge pull request #1149 from Luis-Cruz/feature/AddOptionToFinancialR…
Browse files Browse the repository at this point in the history
…eport

Add option to financial report ACDM-1265 #resolve
  • Loading branch information
Luis-Cruz authored Apr 12, 2017
2 parents 6ac0d46 + d630c48 commit a267a57
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/main/dml/fenixedu-academic.dml
Original file line number Diff line number Diff line change
Expand Up @@ -4421,6 +4421,7 @@ class accounting.report.events.EventReportQueueJob extends QueueJobWithFile {
Boolean forMasterDegreeAdministrativeOffice;
LocalDate beginDate;
LocalDate endDate;
DateTime dateToConsiderInformation;
}
class accounting.report.events.EventReportQueueJobFile extends .org.fenixedu.bennu.io.domain.GenericFile {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.fenixedu.academic.domain.accounting;

import org.fenixedu.academic.domain.Country;
import org.fenixedu.academic.domain.Person;

public class VatNumberResolver {

public static VatNumberResolver RESOLVER = new VatNumberResolver(){};

public String uVATNumberFor(final Person person) {
final Country country = person.getCountry();
final String ssn = person.getSocialSecurityNumber();
return country.getCode() + ssn;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.fenixedu.academic.domain.accounting.Event;
import org.fenixedu.academic.domain.accounting.Exemption;
import org.fenixedu.academic.domain.accounting.ResidenceEvent;
import org.fenixedu.academic.domain.accounting.VatNumberResolver;
import org.fenixedu.academic.domain.accounting.events.AdministrativeOfficeFeeAndInsuranceEvent;
import org.fenixedu.academic.domain.accounting.events.candidacy.IndividualCandidacyEvent;
import org.fenixedu.academic.domain.accounting.events.gratuity.GratuityEvent;
Expand All @@ -52,6 +53,7 @@
import org.fenixedu.academic.domain.phd.debts.PhdEvent;
import org.fenixedu.academic.predicate.AccessControl;
import org.fenixedu.academic.util.ConnectionManager;
import org.fenixedu.academic.util.Money;
import org.fenixedu.bennu.core.domain.Bennu;
import org.fenixedu.commons.spreadsheet.SheetData;
import org.fenixedu.commons.spreadsheet.SpreadsheetBuilder;
Expand Down Expand Up @@ -89,6 +91,7 @@ private EventReportQueueJob(final EventReportQueueJobBean bean) {
setExportOthers(bean.getExportOthers());
setBeginDate(bean.getBeginDate());
setEndDate(bean.getEndDate());
setDateToConsiderInformation(bean.getDateToConsiderInformation());

setForExecutionYear(bean.getExecutionYear());
setForAdministrativeOffice(bean.getAdministrativeOffice());
Expand Down Expand Up @@ -257,6 +260,7 @@ public void run() {
protected void makeLine(EventBean bean) {
addCell("Identificador", bean.externalId);
addCell("Aluno", bean.studentNumber);
addCell("uVATNumber", bean.uVatNumber);
addCell("Nome", bean.studentName);
addCell("Email", bean.email);
addCell("Data inscrição", bean.registrationStartDate);
Expand Down Expand Up @@ -287,7 +291,7 @@ protected void makeLine(EventBean bean) {
for (InstallmentWrapper installment : list) {
addCell(installment.getExpirationDateLabel(), installment.getExpirationDate());
addCell(installment.getAmountToPayLabel(), installment.getAmountToPay());
addCell(installment.getRemainingAmountLabel(), installment.getRemainingAmount());
addCell(installment.getRemainingAmountLabel(), installment.getRemainingAmount(getDateToConsiderInformation()));
}
}
}
Expand Down Expand Up @@ -371,6 +375,7 @@ private EventBean writeEvent(final Event event) {

bean.externalId = event.getExternalId();
bean.studentNumber = wrapper.getStudentNumber();
bean.uVatNumber = uVatNumberFor(event);
bean.studentName = wrapper.getStudentName();
bean.email = wrapper.getStudentEmail();
bean.registrationStartDate = wrapper.getRegistrationStartDate();
Expand All @@ -387,9 +392,10 @@ private EventBean writeEvent(final Event event) {

bean.description = event.getDescription().toString();
bean.whenOccured = event.getWhenOccured().toString("dd/MM/yyyy");
bean.totalAmount = event.getTotalAmountToPay() != null ? event.getTotalAmountToPay().toPlainString() : "-";
bean.payedAmount = event.getPayedAmount().toPlainString();
bean.amountToPay = event.getAmountToPay().toPlainString();
final Money totalAmountToPay = event.getTotalAmountToPay(getDateToConsiderInformation());
bean.totalAmount = totalAmountToPay != null ? totalAmountToPay.toPlainString() : "-";
bean.payedAmount = event.getPayedAmount(getDateToConsiderInformation()).toPlainString();
bean.amountToPay = event.calculateAmountToPay(getDateToConsiderInformation()).toPlainString();
bean.reimbursableAmount = event.getReimbursableAmount().toPlainString();
bean.totalDiscount = event.getTotalDiscount().toPlainString();
bean.relatedEvent = wrapper.getRelatedEventExternalId();
Expand All @@ -403,9 +409,15 @@ private EventBean writeEvent(final Event event) {
return bean;
}

private static class EventBean {
private String uVatNumberFor(final Event event) {
final Person person = event.getPerson();
return VatNumberResolver.RESOLVER.uVATNumberFor(person);
}

private static class EventBean {
public String externalId;
public String studentNumber;
public String uVatNumber;
public String studentName;
public String email;
public String registrationStartDate;
Expand Down Expand Up @@ -531,7 +543,8 @@ private StringBuilder getExceptionLine(Throwable e) {
final PrintWriter printWriter = new PrintWriter(result);
e.printStackTrace(printWriter);
String[] exceptionLines = result.toString().split(LINE_BREAK);
exceptionLine.append(exceptionLines[0]).append(" - ").append(exceptionLines[1].replace(FIELD_SEPARATOR, ""));
exceptionLine.append(exceptionLines[0]).append(" - ")
.append(exceptionLines.length > 1 ? exceptionLines[1].replace(FIELD_SEPARATOR, "") : "");
return exceptionLine;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.fenixedu.academic.domain.administrativeOffice.AdministrativeOffice;
import org.fenixedu.bennu.core.domain.Bennu;
import org.fenixedu.bennu.core.security.Authenticate;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;

public class EventReportQueueJobBean implements Serializable {
Expand All @@ -43,8 +44,10 @@ public class EventReportQueueJobBean implements Serializable {
private Boolean exportOthers;
private LocalDate beginDate;
private LocalDate endDate;
private DateTime dateToConsiderInformation;


private AdministrativeOffice administrativeOffice;
private AdministrativeOffice administrativeOffice;

private ExecutionYear executionYear;

Expand Down Expand Up @@ -143,6 +146,14 @@ public void setExecutionYear(ExecutionYear executionYear) {
this.executionYear = executionYear;
}

public DateTime getDateToConsiderInformation() {
return dateToConsiderInformation;
}

public void setDateToConsiderInformation(DateTime dateToConsiderInformation) {
this.dateToConsiderInformation = dateToConsiderInformation;
}

public Set<AdministrativeOffice> getAvailableOffices() {
return AcademicAccessRule.getOfficesAccessibleToFunction(AcademicOperationType.MANAGE_EVENT_REPORTS,
Authenticate.getUser()).collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public String getAmountToPay() {
}

@Override
public String getRemainingAmount() {
public String getRemainingAmount(final DateTime when) {
Map<Installment, Money> calculateInstallmentRemainingAmounts =
event.getGratuityPaymentPlan().calculateInstallmentRemainingAmounts(event, new DateTime(),
event.getGratuityPaymentPlan().calculateInstallmentRemainingAmounts(event, when,
event.getPostingRule().getDiscountPercentage(event));

for (Map.Entry<Installment, Money> entry : calculateInstallmentRemainingAmounts.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.fenixedu.academic.domain.accounting.report.events;

import org.joda.time.DateTime;

public interface InstallmentWrapper {

public String getExpirationDateLabel();
Expand All @@ -30,6 +32,6 @@ public interface InstallmentWrapper {

public String getAmountToPay();

public String getRemainingAmount();
public String getRemainingAmount(final DateTime when);

}
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ label.org.fenixedu.academic.domain.accounting.paymentCodes.IndividualCandidacyPa
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJob.beginDate = Begin date
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJob.endDate = End date
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJob.executionYear.name = Execution Year
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJobBean.dateToConsiderInformation = Date to report
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJobBean.exportAcademicServiceRequestEvents = Academic services
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJobBean.exportAdminOfficeFeeAndInsuranceEvents = Academic office fee and insurance
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJob.exportGratuityEvents = Tuitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ label.org.fenixedu.academic.domain.accounting.paymentCodes.IndividualCandidacyPa
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJob.beginDate = Data de inicio
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJob.endDate = Data de fim
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJob.executionYear.name = Ano Lectivo
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJobBean.dateToConsiderInformation = Data a reportar
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJobBean.exportAcademicServiceRequestEvents = Serviços académicos
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJobBean.exportAdminOfficeFeeAndInsuranceEvents = Taxas de secretaria e seguro escolar
label.org.fenixedu.academic.domain.accounting.report.events.EventReportQueueJob.exportGratuityEvents = Propinas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<fr:slot name="endDate" required="true" >
<fr:validator name="pt.ist.fenixWebFramework.renderers.validators.DateValidator" />
</fr:slot>
<fr:slot name="dateToConsiderInformation" required="true" >
<fr:validator name="org.fenixedu.academic.ui.renderers.validators.DateTimeValidator" />
</fr:slot>
<fr:slot name="administrativeOffice" layout="menu-select-postback" key="label.academicAdminOffice" required="true">
<fr:property name="from" value="availableOffices" />
<fr:property name="format" value="${unit.name}" />
Expand Down

0 comments on commit a267a57

Please sign in to comment.