//
// SortComparator comparator = new SortComparator();
// Collections.sort(list, comparator);
Map<String, Incoming> map = (Map<String, Incoming>) system.query(new GetIncoming());
List<Incoming> list = new ArrayList<Incoming>();
for (Incoming incoming : map.values()) {
if (incoming.isActive()) {
GDDate date = new GDDate(incoming.getNextPaymentDate());
int frequency = incoming.getFrequency();
if(incoming.getNumberOfOcurrencies() > 0){
int i = 1;
while (i <= incoming.getNumberOfOcurrencies()) {
if ( date.afterOrEqualsDay(fromDate) && date.beforeOrEqualsDay(toDate) ){
// Incoming myBill = new Incoming(incoming.getId(), incoming.getDescription(), new GDDate(date), incoming.getFrequency(), incoming.getNumberOfOcurrencies(), incoming.getValue(), incoming.isFixedValue(), incoming.getCategoryId(), incoming.getObservation());
Incoming myBill = new Incoming(incoming.getId(), incoming.getDescription(), new GDDate(date), incoming.getFrequency(), incoming.getNumberOfOcurrencies(), incoming.getValue(), incoming.isFixedValue(), incoming.getCategoryId(), incoming.getObservation(),incoming.getFirstPaymentDate(),incoming.getLastPaymentDate());
list.add(myBill);
}
date = skip(date, frequency);
if (date == null) {
break;
}
i++;
}
}else{
while (date.beforeOrEqualsDay(toDate)){
if ( date.afterOrEqualsDay(fromDate) && date.beforeOrEqualsDay(toDate) ){
Incoming myBill = new Incoming(incoming.getId(), incoming.getDescription(), new GDDate(date), incoming.getFrequency(), incoming.getNumberOfOcurrencies(), incoming.getValue(), incoming.isFixedValue(), incoming.getCategoryId(), incoming.getObservation(),incoming.getFirstPaymentDate(),incoming.getLastPaymentDate());
list.add(myBill);
}
date = skip(date, frequency);
if (date == null) {
break;
}
}
}
}
}
SortComparator comparator = new SortComparator();
Collections.sort(list, comparator);
int bgColorControl = 0;
for (Incoming incoming : list) {
if (incoming.isActive()) {
TableItem item = new TableItem(incomingTable, SWT.NONE | SWT.MULTI | SWT.WRAP);
if (bgColorControl == 1) {
item.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
bgColorControl = 0;
} else {
bgColorControl = 1;
}
GDDate todayPlusOneWeek = new GDDate();
todayPlusOneWeek.addDays(7);
GDDate nextIncomingDate = incoming.getNextPaymentDate();
GDDate today = new GDDate();
Incoming incomingToCompare = (Incoming) system.query(new GetIncoming(incoming.getId()));
GDDate paymentDayBill = incomingToCompare.getNextPaymentDate();
if (paymentDayBill.beforeDay(nextIncomingDate) && paymentDayBill.beforeDay(today)) {
item.setImage(new Image(null, "img/icoExpiradNotPayed.png"));
} else if (nextIncomingDate.beforeOrEqualsDay(todayPlusOneWeek) && nextIncomingDate.afterOrEqualsDay(today)) {