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