Search in sources :

Example 1 with Months

use of org.joda.time.Months in project estatio by estatio.

the class InvoiceAttributesVM method getFrequencyElseNull.

private String getFrequencyElseNull() {
    final SortedSet<InvoiceItem> items = invoice.getItems();
    if (items.isEmpty()) {
        return null;
    }
    final InvoiceItem item = items.first();
    final LocalDate startDate = item.getStartDate();
    final LocalDate endDate = item.getEndDate();
    if (startDate == null || endDate == null) {
        return null;
    }
    Months months = Months.monthsBetween(startDate, endDate.plusDays(1));
    switch(months.getMonths()) {
        case 12:
            return "YEAR";
        case 3:
            return "QUARTER";
        case 1:
            return "MONTH";
    }
    return null;
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Months(org.joda.time.Months) LocalDate(org.joda.time.LocalDate)

Aggregations

InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)1 LocalDate (org.joda.time.LocalDate)1 Months (org.joda.time.Months)1