Search in sources :

Example 1 with TimetableTemplateLine

use of com.axelor.apps.supplychain.db.TimetableTemplateLine in project axelor-open-suite by axelor.

the class TimetableServiceImpl method applyTemplate.

public List<Timetable> applyTemplate(TimetableTemplate template, BigDecimal exTaxTotal, LocalDate computationDate) {
    List<Timetable> timetables = new ArrayList<>();
    for (TimetableTemplateLine templateLine : template.getTimetableTemplateLineList()) {
        Timetable timetable = new Timetable();
        timetable.setEstimatedDate(InvoiceToolService.getDueDate(templateLine.getPaymentCondition(), computationDate));
        timetable.setPercentage(templateLine.getPercentage());
        timetable.setAmount(exTaxTotal.multiply(templateLine.getPercentage()).divide(BigDecimal.valueOf(100)));
        timetables.add(timetable);
    }
    timetables.sort(Comparator.comparing(Timetable::getEstimatedDate));
    return timetables;
}
Also used : Timetable(com.axelor.apps.supplychain.db.Timetable) ArrayList(java.util.ArrayList) TimetableTemplateLine(com.axelor.apps.supplychain.db.TimetableTemplateLine)

Aggregations

Timetable (com.axelor.apps.supplychain.db.Timetable)1 TimetableTemplateLine (com.axelor.apps.supplychain.db.TimetableTemplateLine)1 ArrayList (java.util.ArrayList)1