Skip to content

Commit

Permalink
Merge branch 'hotfix/patches'
Browse files Browse the repository at this point in the history
  • Loading branch information
codinguser committed Jan 30, 2017
2 parents d1c3103 + a9320cd commit 5a644f0
Show file tree
Hide file tree
Showing 27 changed files with 1,197 additions and 509 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
Change Log
===============================================================================
Version 2.1.4 *(2017-01-30)*
----------------------------
* Fixed: Bugs in execution of some scheduled actions (#604, #609)
* Fixed: Multi-currency transactions not exported when format is QIF (#571)
* Fixed: Incorrect date of last export shown in book manager (#615, #617)
* Fixed: Large exports may be reported as successful even if they didn't complete yet (#616)
* Fixed: Custom date range (in reports) does not select correct ending date (#611)
* Fixed: Account color reset when editing an account (#620)
* Fixed: Export to OwnCloud fails if folder already exists
* Fixed: User not notified if export to external target fails
* Improved translations


Version 2.1.3 *(2016-10-20)*
----------------------------
* Fixed: Scheduled exports execute too often or not at all in some cases
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ The following (incomplete list of) people (in no particular order) contributed (
* Felipe Morato <me@fmorato.com>
* Alceu Rodrigues Neto <alceurneto@gmail.com>
* Salama AB <aksalj@aksalj.me>
* Juan Villa <juan64@gmail.com>

Please visit https://crowdin.com/project/gnucash-android for a more complete list of translation contributions
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ apply plugin: 'io.fabric'

def versionMajor = 2
def versionMinor = 1
def versionPatch = 3
def versionBuild = 1
def versionPatch = 4
def versionBuild = 2

def buildTime() {
def df = new SimpleDateFormat("yyyyMMdd HH:mm 'UTC'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import org.gnucash.android.app.GnuCashApplication;
import org.gnucash.android.model.PeriodType;
import org.gnucash.android.model.Recurrence;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;

import static org.gnucash.android.db.DatabaseSchema.RecurrenceEntry;

Expand Down Expand Up @@ -58,7 +63,7 @@ public Recurrence buildModelInstance(@NonNull Cursor cursor) {
long multiplier = cursor.getLong(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_MULTIPLIER));
String periodStart = cursor.getString(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_PERIOD_START));
String periodEnd = cursor.getString(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_PERIOD_END));
String byDay = cursor.getString(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_BYDAY));
String byDays = cursor.getString(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_BYDAY));

PeriodType periodType = PeriodType.valueOf(type);
periodType.setMultiplier((int) multiplier);
Expand All @@ -67,7 +72,7 @@ public Recurrence buildModelInstance(@NonNull Cursor cursor) {
recurrence.setPeriodStart(Timestamp.valueOf(periodStart));
if (periodEnd != null)
recurrence.setPeriodEnd(Timestamp.valueOf(periodEnd));
recurrence.setByDay(byDay);
recurrence.setByDays(stringToByDays(byDays));

populateBaseModelAttributes(cursor, recurrence);

Expand All @@ -79,8 +84,8 @@ public Recurrence buildModelInstance(@NonNull Cursor cursor) {
stmt.clearBindings();
stmt.bindLong(1, recurrence.getPeriodType().getMultiplier());
stmt.bindString(2, recurrence.getPeriodType().name());
if (recurrence.getByDay() != null)
stmt.bindString(3, recurrence.getByDay());
if (!recurrence.getByDays().isEmpty())
stmt.bindString(3, byDaysToString(recurrence.getByDays()));
//recurrence should always have a start date
stmt.bindString(4, recurrence.getPeriodStart().toString());

Expand All @@ -90,4 +95,87 @@ public Recurrence buildModelInstance(@NonNull Cursor cursor) {

return stmt;
}

/**
* Converts a list of days of week as Calendar constants to an String for
* storing in the database.
*
* @param byDays list of days of week constants from Calendar
* @return String of days of the week or null if {@code byDays} was empty
*/
private static @NonNull String byDaysToString(@NonNull List<Integer> byDays) {
StringBuilder builder = new StringBuilder();
for (int day : byDays) {
switch (day) {
case Calendar.MONDAY:
builder.append("MO");
break;
case Calendar.TUESDAY:
builder.append("TU");
break;
case Calendar.WEDNESDAY:
builder.append("WE");
break;
case Calendar.THURSDAY:
builder.append("TH");
break;
case Calendar.FRIDAY:
builder.append("FR");
break;
case Calendar.SATURDAY:
builder.append("SA");
break;
case Calendar.SUNDAY:
builder.append("SU");
break;
default:
throw new RuntimeException("bad day of week: " + day);
}
builder.append(",");
}
builder.deleteCharAt(builder.length()-1);
return builder.toString();
}

/**
* Converts a String with the comma-separated days of the week into a
* list of Calendar constants.
*
* @param byDaysString String with comma-separated days fo the week
* @return list of days of the week as Calendar constants.
*/
private static @NonNull List<Integer> stringToByDays(@Nullable String byDaysString) {
if (byDaysString == null)
return Collections.emptyList();

List<Integer> byDaysList = new ArrayList<>();
for (String day : byDaysString.split(",")) {
switch (day) {
case "MO":
byDaysList.add(Calendar.MONDAY);
break;
case "TU":
byDaysList.add(Calendar.TUESDAY);
break;
case "WE":
byDaysList.add(Calendar.WEDNESDAY);
break;
case "TH":
byDaysList.add(Calendar.THURSDAY);
break;
case "FR":
byDaysList.add(Calendar.FRIDAY);
break;
case "SA":
byDaysList.add(Calendar.SATURDAY);
break;
case "SU":
byDaysList.add(Calendar.SUNDAY);
break;
default:
throw new RuntimeException("bad day of week: " + day);
}
}
return byDaysList;
}
}
Loading

0 comments on commit 5a644f0

Please sign in to comment.