Skip to content
Snippets Groups Projects
Commit 5f1e0190 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #79

rest is not calculated if database doesn't contain at least one normal
and one repeating payment
parent 13dc2af9
No related branches found
No related tags found
1 merge request!104merge v_1_2_0 into master
......@@ -55,10 +55,18 @@ public class DatabaseHandler
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String min = rs.getString("min");
if(min == null)
{
dateTime = null;
}
else
{
dateTime = formatter.parseDateTime(rs.getString("min"));
}
}
}
catch(SQLException e)
{
Logger.error(e);
......@@ -91,10 +99,18 @@ public class DatabaseHandler
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String min = rs.getString("min");
if(min == null)
{
dateTime = null;
}
else
{
dateTime = formatter.parseDateTime(rs.getString("min"));
}
}
}
catch(SQLException e)
{
Logger.error(e);
......@@ -118,8 +134,20 @@ public class DatabaseHandler
public int getRestForAllPreviousMonths(int year, int month)
{
DateTimeFormatter formatter = DateTimeFormat.forPattern("MM.yyyy");
String dateString = String.valueOf(month) + "." + year;
DateTime currentDate = formatter.parseDateTime(dateString);
DateTime firstNormalPaymentDate = getFirstNormalPaymentDate();
if(firstNormalPaymentDate == null)
{
firstNormalPaymentDate = currentDate;
}
DateTime firstRepeatingPaymentDate = getFirstRepeatingPaymentDate();
if(firstRepeatingPaymentDate == null)
{
firstRepeatingPaymentDate = currentDate;
}
DateTime firstDate = firstNormalPaymentDate;
if(firstRepeatingPaymentDate.isBefore(firstNormalPaymentDate))
......@@ -127,10 +155,6 @@ public class DatabaseHandler
firstDate = firstRepeatingPaymentDate;
}
DateTimeFormatter formatter = DateTimeFormat.forPattern("MM.yyyy");
String dateString = String.valueOf(month) + "." + year;
DateTime currentDate = formatter.parseDateTime(dateString);//
if(firstDate.isAfter(currentDate))
{
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment