Skip to content

Commit 2d2bc9e

Browse files
author
Jana Hoch
committed
Export Import notes as well
1 parent 6ea6992 commit 2d2bc9e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/external/ExportController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public List<String> getRecordsForExport(long fromDate, long toDate) {
3333
sb.append(Head.TIME).append(Head.DELIMITER);
3434
sb.append(Head.TITLE).append(Head.DELIMITER);
3535
sb.append(Head.CATEGORY).append(Head.DELIMITER);
36+
sb.append(Head.NOTES).append(Head.DELIMITER);
3637
sb.append(Head.PRICE).append(Head.DELIMITER);
3738
sb.append(Head.CURRENCY);
3839

@@ -53,6 +54,7 @@ public List<String> getRecordsForExport(long fromDate, long toDate) {
5354
category = categoryController.read(record.getCategory().getId());
5455

5556
sb.append(category == null ? "NONE" : category.getName()).append(Head.DELIMITER);
57+
sb.append(record.getNotes()).append(Head.DELIMITER);
5658
sb.append(record.getType() == 0 ? record.getFullPrice()
5759
: -record.getFullPrice()).append(Head.DELIMITER);
5860
sb.append(record.getCurrency() == null ? DbHelper.DEFAULT_ACCOUNT_CURRENCY

app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/external/Head.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ public interface Head {
1010
String TIME = "time";
1111
String TITLE = "title";
1212
String CATEGORY = "category";
13+
String NOTES = "notes";
1314
String PRICE = "price";
1415
String CURRENCY = "currency";
1516
String DELIMITER = ";";
16-
int COLUMN_COUNT = 5;
17+
int COLUMN_COUNT = 7;
1718
}

app/src/main/java/com/blogspot/e_kanivets/moneytracker/controller/external/ImportController.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@ public List<Record> importRecordsFromCsv(@Nullable String csv) {
3535
if (words.length != Head.COLUMN_COUNT) continue;
3636

3737
String timeCol = words[0];
38-
String titleCol = words[1];
39-
String categoryCol = words[2];
40-
String priceCol = words[3];
41-
String currencyCol = words[4];
38+
String accountIdCol = words[1];
39+
String titleCol = words[2];
40+
String categoryCol = words[3];
41+
String notesCol = words[4];
42+
String priceCol = words[5];
43+
String currencyCol = words[6];
44+
4245

4346
try {
4447
long time = Long.parseLong(timeCol);
4548
String title = titleCol.trim();
4649
String categoryName = categoryCol.trim();
50+
String notes = notesCol.trim();
4751
double price = Double.parseDouble(priceCol);
4852
String currency = currencyCol.trim();
4953

@@ -57,7 +61,7 @@ public List<Record> importRecordsFromCsv(@Nullable String csv) {
5761
Category category = new Category(categoryName);
5862
Account account = new Account(-1, "MOCK", -1, currency, 0, -1, false, 0);
5963

60-
Record record = new Record(time, type, title, category, Math.abs(price), account, currency);
64+
Record record = new Record(time, type, title, category, notes, Math.abs(price), account, currency);
6165
Record createdRecord = recordController.create(record);
6266
if (createdRecord != null) recordList.add(createdRecord);
6367
} catch (Exception e) {

0 commit comments

Comments
 (0)