mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This should fix #693.
This commit is contained in:
parent
71eed45b77
commit
dd508dbc49
@ -77,7 +77,7 @@ class ImportCurrency
|
|||||||
'decimal_places' => 2,
|
'decimal_places' => 2,
|
||||||
];
|
];
|
||||||
if (is_null($data['code'])) {
|
if (is_null($data['code'])) {
|
||||||
Log::info('Need at least a code to create currency, return nothing.');
|
Log::debug('Need at least a code to create currency, return nothing.');
|
||||||
|
|
||||||
return new TransactionCurrency();
|
return new TransactionCurrency();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ use FireflyIII\Import\Converter\ConverterInterface;
|
|||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Log;
|
||||||
use Steam;
|
use Steam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,22 +32,26 @@ class ImportJournal
|
|||||||
{
|
{
|
||||||
/** @var ImportAccount */
|
/** @var ImportAccount */
|
||||||
public $asset;
|
public $asset;
|
||||||
|
/** @var ImportBill */
|
||||||
|
public $bill;
|
||||||
/** @var ImportBudget */
|
/** @var ImportBudget */
|
||||||
public $budget;
|
public $budget;
|
||||||
|
/** @var ImportCategory */
|
||||||
|
public $category;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $description = '';
|
public $description = '';
|
||||||
/** @var Collection */
|
/** @var Collection */
|
||||||
public $errors;
|
public $errors;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $hash;
|
public $hash;
|
||||||
|
/** @var array */
|
||||||
|
public $metaDates = [];
|
||||||
|
/** @var string */
|
||||||
|
public $notes = '';
|
||||||
/** @var ImportAccount */
|
/** @var ImportAccount */
|
||||||
public $opposing;
|
public $opposing;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $amount = '0';
|
private $amount = '0';
|
||||||
/** @var ImportBill */
|
|
||||||
public $bill;
|
|
||||||
/** @var ImportCategory */
|
|
||||||
public $category;
|
|
||||||
/** @var ImportCurrency */
|
/** @var ImportCurrency */
|
||||||
private $currency;
|
private $currency;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@ -57,13 +63,9 @@ class ImportJournal
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
private $tags = [];
|
private $tags = [];
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $notes = '';
|
|
||||||
/** @var string */
|
|
||||||
private $transactionType = '';
|
private $transactionType = '';
|
||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
/** @var array */
|
|
||||||
public $metaDates = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ImportEntry constructor.
|
* ImportEntry constructor.
|
||||||
@ -133,7 +135,15 @@ class ImportJournal
|
|||||||
*/
|
*/
|
||||||
public function getDate(string $format): Carbon
|
public function getDate(string $format): Carbon
|
||||||
{
|
{
|
||||||
return Carbon::createFromFormat($format, $this->date);
|
$date = new Carbon;
|
||||||
|
try {
|
||||||
|
$date = Carbon::createFromFormat($format, $this->date);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
// don't care, just log.
|
||||||
|
Log::error(sprintf('Import journal cannot parse date "%s" from value "%s" so will return current date instead.', $format, $this->date));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,7 +233,7 @@ class ImportJournal
|
|||||||
case 'sepa-ct-op':
|
case 'sepa-ct-op':
|
||||||
case 'sepa-ct-id':
|
case 'sepa-ct-id':
|
||||||
case 'sepa-db':
|
case 'sepa-db':
|
||||||
$this->notes .= ' '.$array['value'];
|
$this->notes .= ' ' . $array['value'];
|
||||||
$this->notes = trim($this->notes);
|
$this->notes = trim($this->notes);
|
||||||
break;
|
break;
|
||||||
case 'external-id':
|
case 'external-id':
|
||||||
|
@ -86,6 +86,7 @@ class ImportRoutine
|
|||||||
|
|
||||||
Log::info(sprintf('Done with import job %s', $this->job->key));
|
Log::info(sprintf('Done with import job %s', $this->job->key));
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Rules\Processor;
|
use FireflyIII\Rules\Processor;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Steam;
|
use Steam;
|
||||||
|
|
||||||
@ -107,6 +106,7 @@ class ImportStorage
|
|||||||
$this->storeImportJournal($index, $object);
|
$this->storeImportJournal($index, $object);
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
$this->errors->push($e->getMessage());
|
$this->errors->push($e->getMessage());
|
||||||
|
Log::error(sprintf('Cannot import row #%d because: %s', $index, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,6 +351,13 @@ class ImportStorage
|
|||||||
|
|
||||||
$this->journals->push($journal);
|
$this->journals->push($journal);
|
||||||
|
|
||||||
|
Log::info(
|
||||||
|
sprintf(
|
||||||
|
'Imported new journal #%d with description "%s" and amount %s %s.', $journal->id, $journal->description, $journal->transactionCurrency->code,
|
||||||
|
$amount
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,18 @@ class Roles implements ConfigurationInterface
|
|||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return ConfigurationInterface
|
||||||
|
*/
|
||||||
|
public function setJob(ImportJob $job): ConfigurationInterface
|
||||||
|
{
|
||||||
|
$this->job = $job;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store the result.
|
* Store the result.
|
||||||
*
|
*
|
||||||
@ -220,13 +232,17 @@ class Roles implements ConfigurationInterface
|
|||||||
$config = $this->job->configuration;
|
$config = $this->job->configuration;
|
||||||
$count = $config['column-count'];
|
$count = $config['column-count'];
|
||||||
$assigned = 0;
|
$assigned = 0;
|
||||||
|
$hasAmount = false;
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
$role = $config['column-roles'][$i] ?? '_ignore';
|
$role = $config['column-roles'][$i] ?? '_ignore';
|
||||||
if ($role !== '_ignore') {
|
if ($role !== '_ignore') {
|
||||||
$assigned++;
|
$assigned++;
|
||||||
}
|
}
|
||||||
|
if ($role === 'amount') {
|
||||||
|
$hasAmount = true;
|
||||||
}
|
}
|
||||||
if ($assigned > 0) {
|
}
|
||||||
|
if ($assigned > 0 && $hasAmount) {
|
||||||
$config['column-roles-complete'] = true;
|
$config['column-roles-complete'] = true;
|
||||||
$this->job->configuration = $config;
|
$this->job->configuration = $config;
|
||||||
$this->job->save();
|
$this->job->save();
|
||||||
@ -248,16 +264,4 @@ class Roles implements ConfigurationInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ImportJob $job
|
|
||||||
*
|
|
||||||
* @return ConfigurationInterface
|
|
||||||
*/
|
|
||||||
public function setJob(ImportJob $job): ConfigurationInterface
|
|
||||||
{
|
|
||||||
$this->job = $job;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user