From 13bda0a264f3a50e234b85ab029c813387056e12 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 08:14:19 +0200 Subject: [PATCH] Mainly layout improvements. --- app/Helpers/Csv/Importer.php | 11 +++++------ app/Helpers/Csv/Mapper/AnyAccount.php | 4 +++- app/Helpers/Csv/Mapper/AssetAccount.php | 9 ++++++++- app/Helpers/Csv/Mapper/Bill.php | 2 ++ app/Helpers/Csv/Mapper/Budget.php | 2 ++ app/Helpers/Csv/Mapper/Category.php | 2 ++ app/Helpers/Csv/Mapper/Tag.php | 2 ++ app/Helpers/Csv/Mapper/TransactionCurrency.php | 4 ++++ resources/lang/en/firefly.php | 4 +++- resources/lang/en/help.php | 1 + resources/twig/csv/column-roles.twig | 12 ++++++------ resources/twig/csv/index.twig | 2 ++ resources/twig/csv/map.twig | 12 ++++++------ 13 files changed, 46 insertions(+), 21 deletions(-) diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index edadb10d8e..14a3e8705e 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -126,14 +126,13 @@ class Importer } // post processing and validating. - $data = $this->postProcess($data, $row); - $result = $this->validateData($data); + $data = $this->postProcess($data, $row); + $result = $this->validateData($data); + $journal = null; if ($result === true) { - $result = $this->createTransactionJournal($data); - } else { - Log::error('Validator: ' . $result); + $journal = $this->createTransactionJournal($data); } - if ($result instanceof TransactionJournal) { + if ($journal instanceof TransactionJournal) { return true; } diff --git a/app/Helpers/Csv/Mapper/AnyAccount.php b/app/Helpers/Csv/Mapper/AnyAccount.php index 37488c1523..f42e64d071 100644 --- a/app/Helpers/Csv/Mapper/AnyAccount.php +++ b/app/Helpers/Csv/Mapper/AnyAccount.php @@ -20,13 +20,15 @@ class AnyAccount implements MapperInterface { $result = Auth::user()->accounts()->with('accountType')->orderBy('accounts.name', 'ASC')->get(['accounts.*']); - $list = []; + $list = []; /** @var Account $account */ foreach ($result as $account) { $list[$account->id] = $account->name . ' (' . $account->accountType->type . ')'; } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/AssetAccount.php b/app/Helpers/Csv/Mapper/AssetAccount.php index cb49177976..6915533ea7 100644 --- a/app/Helpers/Csv/Mapper/AssetAccount.php +++ b/app/Helpers/Csv/Mapper/AssetAccount.php @@ -26,13 +26,20 @@ class AssetAccount implements MapperInterface )->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']); $list = []; + /** @var Account $account */ foreach ($result as $account) { - $list[$account->id] = $account->name; + $name = $account->name; + if (strlen($account->iban) > 0) { + $name .= ' (' . $account->iban . ')'; + } + $list[$account->id] = $name; } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Bill.php b/app/Helpers/Csv/Mapper/Bill.php index 17a9f5b22e..45f2de5897 100644 --- a/app/Helpers/Csv/Mapper/Bill.php +++ b/app/Helpers/Csv/Mapper/Bill.php @@ -27,6 +27,8 @@ class Bill implements MapperInterface } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Budget.php b/app/Helpers/Csv/Mapper/Budget.php index c4bf2064eb..dbe8ebb03c 100644 --- a/app/Helpers/Csv/Mapper/Budget.php +++ b/app/Helpers/Csv/Mapper/Budget.php @@ -27,6 +27,8 @@ class Budget implements MapperInterface } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Category.php b/app/Helpers/Csv/Mapper/Category.php index 81634764f0..7244a65a1a 100644 --- a/app/Helpers/Csv/Mapper/Category.php +++ b/app/Helpers/Csv/Mapper/Category.php @@ -27,6 +27,8 @@ class Category implements MapperInterface } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Tag.php b/app/Helpers/Csv/Mapper/Tag.php index 9ef0d6a2db..559c73089c 100644 --- a/app/Helpers/Csv/Mapper/Tag.php +++ b/app/Helpers/Csv/Mapper/Tag.php @@ -27,6 +27,8 @@ class Tag implements MapperInterface } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/TransactionCurrency.php b/app/Helpers/Csv/Mapper/TransactionCurrency.php index 0945bea416..4d6281acdc 100644 --- a/app/Helpers/Csv/Mapper/TransactionCurrency.php +++ b/app/Helpers/Csv/Mapper/TransactionCurrency.php @@ -23,6 +23,10 @@ class TransactionCurrency implements MapperInterface $list[$currency->id] = $currency->name . ' (' . $currency->code . ')'; } + asort($list); + + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index 85a663d095..c45f5d6ae4 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -25,7 +25,8 @@ return [ 'csv_index_title' => 'Upload and import a CSV file', 'csv_index_text' => 'This form allows you to import a CSV file with transactions into Firefly. It is based on the excellent CSV importer made by' . - ' the folks at Atlassian. Simply upload your CSV file and follow the instructions.', + ' the folks at Atlassian. Simply upload your CSV file and follow the instructions.' . + ' If you would like to learn more, please click on the button at the top of this page.', 'csv_index_beta_warning' => 'This tool is very much in beta. Please proceed with caution', 'csv_header_help' => 'Check this box when your CSV file\'s first row consists of column names, not actual data', 'csv_date_help' => 'Date time format in your CSV. Follow the format like - {{ 'cvs_column_name'|_ }} - {{ 'cvs_column_example'|_ }} - {{ 'cvs_column_role'|_ }} - {{ 'csv_do_map_value'|_ }} + {{ 'cvs_column_name'|_ }} + {{ 'cvs_column_example'|_ }} + {{ 'cvs_column_role'|_ }} + {{ 'csv_do_map_value'|_ }} {% for index,header in headers %} {{ header }} - {{ example[index] }} + {{ example[index] }} - {{ Form.select(('role['~index~']'), availableRoles,roles[index]) }} + {{ Form.select(('role['~index~']'), availableRoles,roles[index],{class: 'form-control'}) }} {{ Form.checkbox(('map['~index~']'),1,map[index]) }} diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig index 7e8e79c97f..e4a465bc9e 100644 --- a/resources/twig/csv/index.twig +++ b/resources/twig/csv/index.twig @@ -61,6 +61,8 @@ {{ ExpandedForm.file('csv_config',{helpText: 'csv_csv_config_file_help'|_}) }} + + {% if not uploadPossible %}
diff --git a/resources/twig/csv/map.twig b/resources/twig/csv/map.twig index 97ce18b582..ccd26c0e50 100644 --- a/resources/twig/csv/map.twig +++ b/resources/twig/csv/map.twig @@ -21,7 +21,7 @@

- {{ 'csv_map_text'|_ }} + {{ 'csv_map_text'|_ }}

@@ -45,18 +45,18 @@ -
- +
+
- + {% for value in values[index] %} - + {% endfor %}
{{ 'cvs_field_value'|_ }}{{ 'cvs_field_value'|_ }} {{ 'csv_field_mapped_to'|_ }}
{{ value }}{{ value }} - {{ Form.select('mapping['~index~']['~value~']',options[index], mapped[index][value]) }} + {{ Form.select('mapping['~index~']['~value~']',options[index], mapped[index][value], {class: 'form-control'}) }}