diff --git a/app/Export/Collector/UploadCollector.php b/app/Export/Collector/UploadCollector.php index 0b7cca980a..3841a52a9d 100644 --- a/app/Export/Collector/UploadCollector.php +++ b/app/Export/Collector/UploadCollector.php @@ -33,6 +33,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface private $uploadDisk; /** + * * AttachmentCollector constructor. * * @param ExportJob $job @@ -44,6 +45,8 @@ class UploadCollector extends BasicCollector implements CollectorInterface // make storage: $this->uploadDisk = Storage::disk('upload'); $this->exportDisk = Storage::disk('export'); + + // todo needs work for new importer (potentially collect other types as well) $this->expected = 'csv-upload-' . Auth::user()->id . '-'; } diff --git a/app/Handlers/Events/ConnectTransactionToPiggyBank.php b/app/Handlers/Events/ConnectTransactionToPiggyBank.php index 3e09a6fbcf..17507027b1 100644 --- a/app/Handlers/Events/ConnectTransactionToPiggyBank.php +++ b/app/Handlers/Events/ConnectTransactionToPiggyBank.php @@ -32,10 +32,11 @@ class ConnectTransactionToPiggyBank */ public function handle(TransactionStored $event): bool { - echo '
';
+
         /** @var PiggyBankRepositoryInterface $repository */
         $repository  = app(PiggyBankRepositoryInterface::class);
         $transaction = $event->transaction;
+
         $piggyBank   = $repository->find($transaction['piggy_bank_id']);
 
         // valid piggy:
diff --git a/app/Handlers/Events/UpdateJournalConnection.php b/app/Handlers/Events/UpdateJournalConnection.php
index ae9214c08d..15d711e7ec 100644
--- a/app/Handlers/Events/UpdateJournalConnection.php
+++ b/app/Handlers/Events/UpdateJournalConnection.php
@@ -34,6 +34,10 @@ class UpdateJournalConnection
     {
         $journal = $event->journal;
 
+        if (!$journal->isTransfer()) {
+            return true;
+        }
+
         // get the event connected to this journal:
         /** @var PiggyBankEvent $event */
         $event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();
diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php
index 1169383eca..b826da6030 100644
--- a/app/Http/Controllers/CategoryController.php
+++ b/app/Http/Controllers/CategoryController.php
@@ -13,7 +13,9 @@ namespace FireflyIII\Http\Controllers;
 
 use Auth;
 use Carbon\Carbon;
+use FireflyIII\Crud\Account\AccountCrudInterface;
 use FireflyIII\Http\Requests\CategoryFormRequest;
+use FireflyIII\Models\AccountType;
 use FireflyIII\Models\Category;
 use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
 use FireflyIII\Support\CacheProperties;
@@ -156,12 +158,13 @@ class CategoryController extends Controller
     }
 
     /**
-     * @param CRI      $repository
-     * @param Category $category
+     * @param CRI                  $repository
+     * @param AccountCrudInterface $crud
+     * @param Category             $category
      *
-     * @return \Illuminate\View\View
+     * @return View
      */
-    public function show(CRI $repository, Category $category)
+    public function show(CRI $repository, AccountCrudInterface $crud, Category $category)
     {
         /** @var Carbon $carbon */
         $range        = Preferences::get('viewRange', '1M')->data;
@@ -205,12 +208,12 @@ class CategoryController extends Controller
 
 
         $categoryCollection = new Collection([$category]);
-        $empty              = new Collection;
+        $accounts           = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
         while ($end >= $start) {
             $end        = Navigation::startOfPeriod($end, $range);
             $currentEnd = Navigation::endOfPeriod($end, $range);
-            $spent      = $repository->spentInPeriod($categoryCollection, $empty, $end, $currentEnd);
-            $earned     = $repository->earnedInPeriod($categoryCollection, $empty, $end, $currentEnd);
+            $spent      = $repository->spentInPeriod($categoryCollection, $accounts, $end, $currentEnd);
+            $earned     = $repository->earnedInPeriod($categoryCollection, $accounts, $end, $currentEnd);
             $dateStr    = $end->format('Y-m-d');
             $dateName   = Navigation::periodShow($end, $range);
             $entries->push([$dateStr, $dateName, $spent, $earned]);
diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php
new file mode 100644
index 0000000000..0319bdb87f
--- /dev/null
+++ b/app/Http/Controllers/ImportController.php
@@ -0,0 +1,41 @@
+currentRelevantRep()->currentamount;
 
diff --git a/app/Http/routes.php b/app/Http/routes.php
index 977c3fb18c..159931d398 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -157,7 +157,6 @@ Route::group(
     Route::post('/categories/update/{category}', ['uses' => 'CategoryController@update', 'as' => 'categories.update']);
     Route::post('/categories/destroy/{category}', ['uses' => 'CategoryController@destroy', 'as' => 'categories.destroy']);
 
-
     /**
      * CSV controller
      */
@@ -169,9 +168,10 @@ Route::group(
     Route::get('/csv/download-config', ['uses' => 'CsvController@downloadConfig', 'as' => 'csv.download-config']);
     Route::get('/csv/download', ['uses' => 'CsvController@downloadConfigPage', 'as' => 'csv.download-config-page']);
     Route::post('/csv/save_mapping', ['uses' => 'CsvController@saveMapping', 'as' => 'csv.save_mapping']);
-
+    
     Route::get('/csv/process', ['uses' => 'CsvController@process', 'as' => 'csv.process']);
 
+
     /**
      * Currency Controller
      */
@@ -235,6 +235,11 @@ Route::group(
     Route::get('/chart/report/in-out-sum/{reportType}/{start_date}/{end_date}/{accountList}', ['uses' => 'Chart\ReportController@yearInOutSummarized']);
     Route::get('/chart/report/net-worth/{reportType}/{start_date}/{end_date}/{accountList}', ['uses' => 'Chart\ReportController@netWorth']);
 
+    /**
+     * IMPORT CONTROLLER
+     */
+    Route::get('/import', ['uses' => 'ImportController@index', 'as' => 'import.index']);
+    Route::post('/import/upload', ['uses' => 'ImportController@upload', 'as' => 'import.upload']);
 
     /**
      * Help Controller
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index 80315ff5d1..d937f51863 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -87,7 +87,8 @@ class General extends Twig_Extension
             'activeRoutePartial', function () : string {
             $args  = func_get_args();
             $route = $args[0]; // name of the route.
-            if (!(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
+            $name  = Route::getCurrentRoute()->getName() ?? '';
+            if (!(strpos($name, $route) === false)) {
                 return 'active';
             }
 
diff --git a/config/firefly.php b/config/firefly.php
index 4a045e1f6a..78a1b62634 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -4,18 +4,25 @@ declare(strict_types = 1);
 
 return [
     'chart'               => 'chartjs',
-    'version'             => '3.9.0',
+    'version'             => '3.9.1',
     'csv_import_enabled'  => true,
     'maxUploadSize'       => 5242880,
     'allowedMimes'        => ['image/png', 'image/jpeg', 'application/pdf'],
     'resend_confirmation' => 3600,
     'confirmation_age'    => 14400, // four hours
 
-    'export_formats'        => [
+    'export_formats' => [
         'csv' => 'FireflyIII\Export\Exporter\CsvExporter',
         // mt940 FireflyIII Export Exporter MtExporter
     ],
+    'import_formats' => [
+        'csv' => 'FireflyIII\Import\Importer\CsvImporter',
+        // mt940 FireflyIII Import Importer MtImporter
+    ],
+
+
     'default_export_format' => 'csv',
+    'default_import_format' => 'csv',
     'bill_periods'          => ['weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
 
     'accountRoles' => [
@@ -103,7 +110,7 @@ return [
 
     ],
 
-    'bindables'   => [
+    'bindables' => [
         // models
         'account'           => 'FireflyIII\Models\Account',
         'attachment'        => 'FireflyIII\Models\Attachment',
diff --git a/resources/views/import/index.twig b/resources/views/import/index.twig
new file mode 100644
index 0000000000..16ea17886e
--- /dev/null
+++ b/resources/views/import/index.twig
@@ -0,0 +1,52 @@
+{% extends "./layout/default.twig" %}
+
+{% block breadcrumbs %}
+    {{ Breadcrumbs.renderIfExists }}
+{% endblock %}
+{% block content %}
+    
+
+ +
+
+

{{ 'import'|_ }}

+
+
+

+ {{ 'import_intro_text'|_ }} +

+

+   +

+
+
+ + + +
+ {{ ExpandedForm.file('import_file',{helpText: 'import_file_help'|_}) }} + + {{ ExpandedForm.select('import_file_type', importFileTypes, defaultImportType, {'helpText' : 'import_file_type_help'|_}) }} + +
+ + +
+ +
+
+
+
+
+
+
+
+
+{% endblock %} +{% block scripts %} +{% endblock %} +{% block styles %} +{% endblock %} diff --git a/resources/views/partials/menu-sidebar.twig b/resources/views/partials/menu-sidebar.twig index 0f82830fc7..54de5a7a93 100644 --- a/resources/views/partials/menu-sidebar.twig +++ b/resources/views/partials/menu-sidebar.twig @@ -111,14 +111,11 @@
  • + - {% if Config.get('firefly.csv_import_enabled') %} - {{ 'import_and_export'|_ }} - {% else %} - {{ 'export_data'|_ }} - {% endif %} + {{ 'import_and_export'|_ }}