Skip to content

Commit 1970665

Browse files
authored
Merge pull request xorum-io#33 from JanaHoch/dev
Export account_id as well. to fix not able to edit imported records
2 parents 3f7f1fe + 06445a8 commit 1970665

File tree

8 files changed

+23
-13
lines changed

8 files changed

+23
-13
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public List<String> getRecordsForExport(long fromDate, long toDate) {
3131
@SuppressWarnings("StringBufferReplaceableByString")
3232
StringBuilder sb = new StringBuilder();
3333
sb.append(Head.TIME).append(Head.DELIMITER);
34+
sb.append(Head.ACCOUNT_ID).append(Head.DELIMITER);
3435
sb.append(Head.TITLE).append(Head.DELIMITER);
3536
sb.append(Head.CATEGORY).append(Head.DELIMITER);
3637
sb.append(Head.PRICE).append(Head.DELIMITER);
@@ -46,6 +47,12 @@ public List<String> getRecordsForExport(long fromDate, long toDate) {
4647
for (Record record : recordList) {
4748
sb = new StringBuilder();
4849
sb.append(record.getTime()).append(Head.DELIMITER);
50+
51+
long account_id = -1;
52+
if (record.getAccount() != null)
53+
account_id = record.getAccount().getId();
54+
55+
sb.append(account_id).append(Head.DELIMITER);
4956
sb.append(record.getTitle()).append(Head.DELIMITER);
5057

5158
Category category = null;

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
@@ -8,10 +8,11 @@
88
*/
99
public interface Head {
1010
String TIME = "time";
11+
String ACCOUNT_ID = "account_id";
1112
String TITLE = "title";
1213
String CATEGORY = "category";
1314
String PRICE = "price";
1415
String CURRENCY = "currency";
1516
String DELIMITER = ";";
16-
int COLUMN_COUNT = 5;
17+
int COLUMN_COUNT = 6;
1718
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ 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 priceCol = words[4];
42+
String currencyCol = words[5];
4243

4344
try {
4445
long time = Long.parseLong(timeCol);
46+
long accountId = Long.parseLong(accountIdCol);
4547
String title = titleCol.trim();
4648
String categoryName = categoryCol.trim();
4749
double price = Double.parseDouble(priceCol);
@@ -55,7 +57,7 @@ public List<Record> importRecordsFromCsv(@Nullable String csv) {
5557
else type = Record.TYPE_INCOME;
5658

5759
Category category = new Category(categoryName);
58-
Account account = new Account(-1, "MOCK", -1, currency, 0, -1, false, 0);
60+
Account account = new Account(accountId, "MOCK", -1, currency, 0, -1, false, 0);
5961

6062
Record record = new Record(time, type, title, category, Math.abs(price), account, currency);
6163
Record createdRecord = recordController.create(record);

app/src/main/res/values-fr/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
2. Copier son contenu dans le champ de saisie.\n
7171
3. Appuyer sur importer. Au bout de quelques secondes, le nombre d\'opérations importées est affiché.\n
7272
\n
73-
<b>Note :</b> date - horodatage en millisecondes ; devise - code devise à 3 lettres.\n
73+
<b>Note :</b> date - horodatage en millisecondes ;Le account_id par défaut est 1 et pour chaque nouveau compte, il augmente de 1;Assurez-vous que tous les comptes existent déjà; devise - code devise à 3 lettres.\n
7474
<b>Exemple :</b> 1466948795712;métro;transport;-20.0;EUR</string>
7575

7676
<string name="bank_sells">Banque achète</string>

app/src/main/res/values-pt-rBR/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
2. Copie o seu conteúdo para o campo de texto.\n
8383
3. Pressione o botão de importar. Em alguns segundos você verá quantos registros foram importados.\n
8484
\n
85-
<b>Nota:</b> hora - o valor deve ser em milissegundos; moeda - código de 3 símbolos da moeda.\n
85+
<b>Nota:</b> hora - o valor deve ser em milissegundos;Account_id padrão é 1 e para cada nova conta aumenta em 1; Verifique se todas as contas já existem; moeda - código de 3 símbolos da moeda.\n
8686
<b>Exemplo:</b> 1466948795712;metrô;transporte;-20.0;BRL</string>
8787

8888
<string name="slash" translatable="false">/</string>

app/src/main/res/values-ru/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
2. Скопируйте его контент в текстовое поле.\n
7575
3. Нажмите кнопку импорта. Через несколько секунд Вы увидите сколько записей было импортировано.\n
7676
\n
77-
<b>Важно:</b> время - метка времени в миллисекундах; валюта - 3-х символьный код валюты.\n
77+
<b>Важно:</b> время - метка времени в миллисекундах;По умолчанию account_id равен 1, и для каждой новой учетной записи он увеличивается на 1; Убедитесь, что все учетные записи уже существуют; валюта - 3-х символьный код валюты.\n
7878
<b>Пример:</b> 1466948795712;метро;транспорт;-20.0;UAH</string>
7979

8080
<string name="bank_sells">Банк продает</string>

app/src/main/res/values-uk/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
2. Скопіюйте його контент до текстового поля.\n
7575
3. Натисніть кнопку імпорту. Через дікілька секунд Ви побачите скільки записів було імпортовано.\n
7676
\n
77-
<b>Важливо:</b> час - мітка часу у мілісекундах; валюта - 3-х символьний код валюти.\n
77+
<b>Важливо:</b> час - мітка часу у мілісекундах;За замовчуванням account_id дорівнює 1 і для кожного нового облікового запису він збільшується на 1; Переконайтеся, що всі облікові записи вже існують; валюта - 3-х символьний код валюти.\n
7878
<b>Приклад:</b> 1466948795712;метро;транспорт;-20.0;UAH</string>
7979

8080
<string name="bank_sells">Банк продає</string>

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@
7878
<string name="help">Help</string>
7979
<string name="import_help">To import records into application:\n
8080
1. Create CSV file in format - \n
81-
<b>time;title;category;price;currency.</b>\n
81+
<b>time;account_id;title;category;price;currency.</b>\n
8282
2. Copy its content to text field.\n
8383
3. Press import button. In few seconds you will see how much records has been imported.\n
8484
\n
85-
<b>Note:</b> time - timestamp value in milliseconds; currency - 3 symbols code of currency.\n
86-
<b>Example:</b> 1466948795712;metro;transport;-20.0;UAH</string>
85+
<b>Note:</b> time - timestamp value in milliseconds; Default account_id is 1 and for every new account it increases by 1; Make sure all the accounts already exists; currency - 3 symbols code of currency.\n
86+
<b>Example:</b> 1466948795712;1;metro;transport;-20.0;UAH</string>
8787

8888
<string name="slash" translatable="false">/</string>
8989
<string name="bank_sells">Bank sells</string>

0 commit comments

Comments
 (0)