Code cleanup.

This commit is contained in:
James Cole
2016-04-26 21:40:15 +02:00
parent 1d2a4e707e
commit da202317c0
41 changed files with 167 additions and 197 deletions

View File

@@ -18,10 +18,10 @@ use FireflyIII\Models\Account;
*/
class EntryAccount
{
/** @var int */
public $accountId;
/** @var string */
public $iban;
/** @var int */
public $id;
/** @var string */
public $name;
/** @var int */
@@ -36,10 +36,10 @@ class EntryAccount
*/
public function __construct(Account $account)
{
$this->id = $account->id;
$this->name = $account->name;
$this->iban = $account->iban;
$this->type = $account->accountType->type;
$this->number = $account->getMeta('accountNumber');
$this->accountId = $account->id;
$this->name = $account->name;
$this->iban = $account->iban;
$this->type = $account->accountType->type;
$this->number = $account->getMeta('accountNumber');
}
}

View File

@@ -19,7 +19,7 @@ use FireflyIII\Models\Bill;
class EntryBill
{
/** @var string */
public $id = '';
public $billId = '';
/** @var string */
public $name = '';
@@ -31,8 +31,8 @@ class EntryBill
public function __construct(Bill $bill = null)
{
if (!is_null($bill)) {
$this->id = $bill->id;
$this->name = $bill->name;
$this->billId = $bill->id;
$this->name = $bill->name;
}
}

View File

@@ -19,7 +19,7 @@ use FireflyIII\Models\Budget;
class EntryBudget
{
/** @var string */
public $id = '';
public $budgetId = '';
/** @var string */
public $name = '';
@@ -31,8 +31,8 @@ class EntryBudget
public function __construct(Budget $budget = null)
{
if (!is_null($budget)) {
$this->id = $budget->id;
$this->name = $budget->name;
$this->budgetId = $budget->id;
$this->name = $budget->name;
}
}

View File

@@ -19,7 +19,7 @@ use FireflyIII\Models\Category;
class EntryCategory
{
/** @var string */
public $id = '';
public $categoryId = '';
/** @var string */
public $name = '';
@@ -31,8 +31,8 @@ class EntryCategory
public function __construct(Category $category = null)
{
if (!is_null($category)) {
$this->id = $category->id;
$this->name = $category->name;
$this->categoryId = $category->id;
$this->name = $category->name;
}
}
}

View File

@@ -69,10 +69,10 @@ class CsvExporter extends BasicExporter implements ExporterInterface
foreach ($this->getEntries() as $entry) {
// order is defined in Entry::getFieldsAndTypes.
$rows[] = [
$entry->description, $entry->amount, $entry->date, $entry->sourceAccount->id, $entry->sourceAccount->name, $entry->sourceAccount->iban,
$entry->sourceAccount->type, $entry->sourceAccount->number, $entry->destinationAccount->id, $entry->destinationAccount->name,
$entry->destinationAccount->iban, $entry->destinationAccount->type, $entry->destinationAccount->number, $entry->budget->id,
$entry->budget->name, $entry->category->id, $entry->category->name, $entry->bill->id, $entry->bill->name,
$entry->description, $entry->amount, $entry->date, $entry->sourceAccount->accountId, $entry->sourceAccount->name, $entry->sourceAccount->iban,
$entry->sourceAccount->type, $entry->sourceAccount->number, $entry->destinationAccount->accountId, $entry->destinationAccount->name,
$entry->destinationAccount->iban, $entry->destinationAccount->type, $entry->destinationAccount->number, $entry->budget->budgetId,
$entry->budget->name, $entry->category->categoryId, $entry->category->name, $entry->bill->billId, $entry->bill->name,
];
}

View File

@@ -11,12 +11,12 @@ declare(strict_types = 1);
namespace FireflyIII\Export;
use Auth;
use Config;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Export\Entry\Entry;
use FireflyIII\Models\ExportJob;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalCollector;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Collection;
use Log;
use Storage;
@@ -174,10 +174,7 @@ class Processor
$zip->close();
// delete the files:
foreach ($this->getFiles() as $file) {
Log::debug('Will now delete file "' . $file . '".');
$disk->delete($file);
}
$this->deleteFiles($disk);
Log::debug('Done!');
return true;
@@ -188,7 +185,7 @@ class Processor
*/
public function exportJournals(): bool
{
$exporterClass = Config::get('firefly.export_formats.' . $this->exportFormat);
$exporterClass = config('firefly.export_formats.' . $this->exportFormat);
$exporter = app($exporterClass, [$this->job]);
Log::debug('Going to export ' . $this->exportEntries->count() . ' export entries into ' . $this->exportFormat . ' format.');
$exporter->setEntries($this->exportEntries);
@@ -206,4 +203,16 @@ class Processor
{
return $this->files;
}
/**
* @param FilesystemAdapter $disk
*/
private function deleteFiles(FilesystemAdapter $disk)
{
Log::debug('Class of $disk: ' . get_class($disk));
foreach ($this->getFiles() as $file) {
Log::debug('Will now delete file "' . $file . '".');
$disk->delete($file);
}
}
}