mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Fix data export.
This commit is contained in:
@@ -46,7 +46,7 @@ final class Entry
|
|||||||
{
|
{
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $journal_id;
|
public $journal_id;
|
||||||
/**
|
/**
|
||||||
@@ -55,20 +55,20 @@ final class Entry
|
|||||||
public $transaction_id = 0;
|
public $transaction_id = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $date;
|
public $date;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $description;
|
public $description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $currency_code;
|
public $currency_code;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $amount;
|
public $amount;
|
||||||
/**
|
/**
|
||||||
@@ -81,94 +81,94 @@ final class Entry
|
|||||||
public $foreign_amount = '0';
|
public $foreign_amount = '0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $transaction_type;
|
public $transaction_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $asset_account_id;
|
public $asset_account_id;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $asset_account_name;
|
public $asset_account_name;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $asset_account_iban;
|
public $asset_account_iban;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $asset_account_bic;
|
public $asset_account_bic;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $asset_account_number;
|
public $asset_account_number;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $asset_currency_code;
|
public $asset_currency_code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $opposing_account_id;
|
public $opposing_account_id;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $opposing_account_name;
|
public $opposing_account_name;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $opposing_account_iban;
|
public $opposing_account_iban;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $opposing_account_bic;
|
public $opposing_account_bic;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $opposing_account_number;
|
public $opposing_account_number;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $opposing_currency_code;
|
public $opposing_currency_code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $budget_id;
|
public $budget_id;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $budget_name;
|
public $budget_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $category_id;
|
public $category_id;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $category_name;
|
public $category_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $bill_id;
|
public $bill_id;
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $bill_name;
|
public $bill_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $notes;
|
public $notes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $tags;
|
public $tags;
|
||||||
|
|
||||||
|
@@ -32,8 +32,8 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
|||||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||||
use FireflyIII\Models\AccountMeta;
|
use FireflyIII\Models\AccountMeta;
|
||||||
use FireflyIII\Models\ExportJob;
|
use FireflyIII\Models\ExportJob;
|
||||||
|
use FireflyIII\Models\Note;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournalMeta;
|
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -114,7 +114,7 @@ class ExpandedProcessor implements ProcessorInterface
|
|||||||
$notes = $this->getNotes($ids);
|
$notes = $this->getNotes($ids);
|
||||||
$tags = $this->getTags($ids);
|
$tags = $this->getTags($ids);
|
||||||
/** @var array $ibans */
|
/** @var array $ibans */
|
||||||
$ibans = $this->getIbans($assetIds) + $this->getIbans($opposingIds);
|
$ibans = array_merge($this->getIbans($assetIds), $this->getIbans($opposingIds));
|
||||||
$currencies = $this->getAccountCurrencies($ibans);
|
$currencies = $this->getAccountCurrencies($ibans);
|
||||||
$transactions->each(
|
$transactions->each(
|
||||||
function (Transaction $transaction) use ($notes, $tags, $ibans, $currencies) {
|
function (Transaction $transaction) use ($notes, $tags, $ibans, $currencies) {
|
||||||
@@ -310,17 +310,16 @@ class ExpandedProcessor implements ProcessorInterface
|
|||||||
private function getNotes(array $array): array
|
private function getNotes(array $array): array
|
||||||
{
|
{
|
||||||
$array = array_unique($array);
|
$array = array_unique($array);
|
||||||
$set = TransactionJournalMeta::whereIn('journal_meta.transaction_journal_id', $array)
|
$notes = Note::where('notes.noteable_type', 'FireflyIII\\Models\\TransactionJournal')
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
|
->whereIn('notes.noteable_id', $array)
|
||||||
->where('transaction_journals.user_id', $this->job->user_id)
|
->get(['notes.*']);
|
||||||
->where('journal_meta.name', 'notes')->get(
|
|
||||||
['journal_meta.transaction_journal_id', 'journal_meta.data', 'journal_meta.id']
|
|
||||||
);
|
|
||||||
$return = [];
|
$return = [];
|
||||||
/** @var TransactionJournalMeta $meta */
|
/** @var Note $note */
|
||||||
foreach ($set as $meta) {
|
foreach ($notes as $note) {
|
||||||
$id = intval($meta->transaction_journal_id);
|
if (strlen(trim(strval($note->text))) > 0) {
|
||||||
$return[$id] = $meta->data;
|
$id = intval($note->noteable_id);
|
||||||
|
$return[$id] = $note->text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
@@ -25,6 +25,8 @@ namespace FireflyIII\Export\Exporter;
|
|||||||
use FireflyIII\Export\Entry\Entry;
|
use FireflyIII\Export\Entry\Entry;
|
||||||
use League\Csv\Writer;
|
use League\Csv\Writer;
|
||||||
use SplFileObject;
|
use SplFileObject;
|
||||||
|
use SplTempFileObject;
|
||||||
|
use Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CsvExporter.
|
* Class CsvExporter.
|
||||||
@@ -62,7 +64,13 @@ class CsvExporter extends BasicExporter implements ExporterInterface
|
|||||||
|
|
||||||
// necessary for CSV writer:
|
// necessary for CSV writer:
|
||||||
$fullPath = storage_path('export') . DIRECTORY_SEPARATOR . $this->fileName;
|
$fullPath = storage_path('export') . DIRECTORY_SEPARATOR . $this->fileName;
|
||||||
$writer = Writer::createFromPath(new SplFileObject($fullPath, 'a+'), 'w');
|
|
||||||
|
|
||||||
|
|
||||||
|
//we create the CSV into memory
|
||||||
|
//$writer = Writer::createFromFileObject(new SplTempFileObject());
|
||||||
|
$writer = Writer::createFromPath($fullPath);
|
||||||
|
//$writer = Writer::createFromPath(new SplFileObject($fullPath, 'a+'), 'w');
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
|
||||||
// get field names for header row:
|
// get field names for header row:
|
||||||
@@ -83,6 +91,8 @@ class CsvExporter extends BasicExporter implements ExporterInterface
|
|||||||
$rows[] = $line;
|
$rows[] = $line;
|
||||||
}
|
}
|
||||||
$writer->insertAll($rows);
|
$writer->insertAll($rows);
|
||||||
|
//$writer->output($fullPath);
|
||||||
|
//$writer->
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -90,5 +100,8 @@ class CsvExporter extends BasicExporter implements ExporterInterface
|
|||||||
private function tempFile()
|
private function tempFile()
|
||||||
{
|
{
|
||||||
$this->fileName = $this->job->key . '-records.csv';
|
$this->fileName = $this->job->key . '-records.csv';
|
||||||
|
// touch file in export directory:
|
||||||
|
$disk = Storage::disk('export');
|
||||||
|
$disk->put($this->fileName,'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -305,7 +305,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'account_type_id' => $accountType->id,
|
'account_type_id' => $accountType->id,
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
'virtual_balance' => $data['virtualBalance'],
|
'virtual_balance' => strlen(strval($data['virtualBalance'])) === 0 ? '0' : $data['virtualBalance'],
|
||||||
'active' => true === $data['active'] ? true : false,
|
'active' => true === $data['active'] ? true : false,
|
||||||
'iban' => $data['iban'],
|
'iban' => $data['iban'],
|
||||||
];
|
];
|
||||||
|
2
public/js/ff/export/index.js
vendored
2
public/js/ff/export/index.js
vendored
@@ -44,6 +44,7 @@ $(function () {
|
|||||||
|
|
||||||
function startExport() {
|
function startExport() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('startExport');
|
||||||
hideForm();
|
hideForm();
|
||||||
showLoading();
|
showLoading();
|
||||||
hideError();
|
hideError();
|
||||||
@@ -95,7 +96,6 @@ function showError(text) {
|
|||||||
function callExport() {
|
function callExport() {
|
||||||
"use strict";
|
"use strict";
|
||||||
var data = $('#export').serialize();
|
var data = $('#export').serialize();
|
||||||
data['_token'] = token;
|
|
||||||
|
|
||||||
// call status, keep calling it until response is "finished"?
|
// call status, keep calling it until response is "finished"?
|
||||||
intervalId = window.setInterval(checkStatus, 500);
|
intervalId = window.setInterval(checkStatus, 500);
|
||||||
|
Reference in New Issue
Block a user