mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Small fixes for import routine.
This commit is contained in:
parent
34fd8cf751
commit
d1b2e63950
@ -105,11 +105,14 @@ class JobStatusController extends Controller
|
|||||||
$json['report_txt'] = trans('import.result_no_transactions');
|
$json['report_txt'] = trans('import.result_no_transactions');
|
||||||
}
|
}
|
||||||
if ($count === 1 && null !== $importJob->tag_id) {
|
if ($count === 1 && null !== $importJob->tag_id) {
|
||||||
$json['report_txt'] = trans('import.result_one_transaction', ['route' => route('tags.show', [$importJob->tag_id]), 'tag' => $importJob->tag->tag]);
|
$json['report_txt'] = trans(
|
||||||
|
'import.result_one_transaction', ['route' => route('tags.show', [$importJob->tag_id, 'all']), 'tag' => $importJob->tag->tag]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($count > 1 && null !== $importJob->tag_id) {
|
if ($count > 1 && null !== $importJob->tag_id) {
|
||||||
$json['report_txt'] = trans(
|
$json['report_txt'] = trans(
|
||||||
'import.result_many_transactions', ['count' => $count, 'route' => route('tags.show', [$importJob->tag_id]), 'tag' => $importJob->tag->tag]
|
'import.result_many_transactions',
|
||||||
|
['count' => $count, 'route' => route('tags.show', [$importJob->tag_id, 'all']), 'tag' => $importJob->tag->tag]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,14 +36,6 @@ use View;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TagController.
|
* Class TagController.
|
||||||
*
|
|
||||||
* Remember: a balancingAct takes at most one expense and one transfer.
|
|
||||||
* an advancePayment takes at most one expense, infinite deposits and NO transfers.
|
|
||||||
*
|
|
||||||
* transaction can only have one advancePayment OR balancingAct.
|
|
||||||
* Other attempts to put in such a tag are blocked.
|
|
||||||
* also show an error when editing a tag and it becomes either
|
|
||||||
* of these two types. Or rather, block editing of the tag.
|
|
||||||
*/
|
*/
|
||||||
class TagController extends Controller
|
class TagController extends Controller
|
||||||
{
|
{
|
||||||
@ -79,7 +71,6 @@ class TagController extends Controller
|
|||||||
{
|
{
|
||||||
$subTitle = trans('firefly.new_tag');
|
$subTitle = trans('firefly.new_tag');
|
||||||
$subTitleIcon = 'fa-tag';
|
$subTitleIcon = 'fa-tag';
|
||||||
$apiKey = env('GOOGLE_MAPS_API_KEY', '');
|
|
||||||
|
|
||||||
// put previous url in session if not redirect from store (not "create another").
|
// put previous url in session if not redirect from store (not "create another").
|
||||||
if (true !== session('tags.create.fromStore')) {
|
if (true !== session('tags.create.fromStore')) {
|
||||||
@ -87,7 +78,7 @@ class TagController extends Controller
|
|||||||
}
|
}
|
||||||
session()->forget('tags.create.fromStore');
|
session()->forget('tags.create.fromStore');
|
||||||
|
|
||||||
return view('tags.create', compact('subTitle', 'subTitleIcon', 'apiKey'));
|
return view('tags.create', compact('subTitle', 'subTitleIcon'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,7 +125,6 @@ class TagController extends Controller
|
|||||||
{
|
{
|
||||||
$subTitle = trans('firefly.edit_tag', ['tag' => $tag->tag]);
|
$subTitle = trans('firefly.edit_tag', ['tag' => $tag->tag]);
|
||||||
$subTitleIcon = 'fa-tag';
|
$subTitleIcon = 'fa-tag';
|
||||||
$apiKey = env('GOOGLE_MAPS_API_KEY', '');
|
|
||||||
|
|
||||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||||
if (true !== session('tags.edit.fromUpdate')) {
|
if (true !== session('tags.edit.fromUpdate')) {
|
||||||
@ -142,7 +132,7 @@ class TagController extends Controller
|
|||||||
}
|
}
|
||||||
session()->forget('tags.edit.fromUpdate');
|
session()->forget('tags.edit.fromUpdate');
|
||||||
|
|
||||||
return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon', 'apiKey'));
|
return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,7 +191,6 @@ class TagController extends Controller
|
|||||||
$start = null;
|
$start = null;
|
||||||
$end = null;
|
$end = null;
|
||||||
$periods = new Collection;
|
$periods = new Collection;
|
||||||
$apiKey = env('GOOGLE_MAPS_API_KEY', '');
|
|
||||||
$path = route('tags.show', [$tag->id]);
|
$path = route('tags.show', [$tag->id]);
|
||||||
|
|
||||||
// prep for "all" view.
|
// prep for "all" view.
|
||||||
@ -310,7 +299,8 @@ class TagController extends Controller
|
|||||||
// get first and last tag date from tag:
|
// get first and last tag date from tag:
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
$start = app('navigation')->startOfPeriod($this->repository->firstUseDate($tag), $range);
|
$start = app('navigation')->startOfPeriod($this->repository->firstUseDate($tag), $range);
|
||||||
$end = app('navigation')->startOfPeriod($this->repository->lastUseDate($tag), $range);
|
$end = app('navigation')->endOfPeriod($this->repository->lastUseDate($tag), $range);
|
||||||
|
|
||||||
// properties for entries with their amounts.
|
// properties for entries with their amounts.
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
|
@ -144,15 +144,19 @@ class ImportArrayStorage
|
|||||||
*/
|
*/
|
||||||
private function countTransfers(): void
|
private function countTransfers(): void
|
||||||
{
|
{
|
||||||
|
Log::debug('Now in count transfers.');
|
||||||
/** @var array $array */
|
/** @var array $array */
|
||||||
$array = $this->importJob->transactions;
|
$array = $this->importJob->transactions;
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($array as $transaction) {
|
foreach ($array as $index => $transaction) {
|
||||||
if (strtolower(TransactionType::TRANSFER) === $transaction['type']) {
|
if (strtolower(TransactionType::TRANSFER) === $transaction['type']) {
|
||||||
$count++;
|
$count++;
|
||||||
|
Log::debug(sprintf('Row #%d is a transfer, increase count to %d', ($index + 1), $count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Log::debug('Count is zero.');
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
|
Log::debug(sprintf('Count is %d', $count));
|
||||||
$this->checkForTransfers = true;
|
$this->checkForTransfers = true;
|
||||||
|
|
||||||
// get users transfers. Needed for comparison.
|
// get users transfers. Needed for comparison.
|
||||||
@ -199,6 +203,7 @@ class ImportArrayStorage
|
|||||||
*/
|
*/
|
||||||
private function getTransfers(): void
|
private function getTransfers(): void
|
||||||
{
|
{
|
||||||
|
app('preferences')->mark();
|
||||||
/** @var JournalCollectorInterface $collector */
|
/** @var JournalCollectorInterface $collector */
|
||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setUser($this->importJob->user);
|
$collector->setUser($this->importJob->user);
|
||||||
@ -408,7 +413,8 @@ class ImportArrayStorage
|
|||||||
$requiredHits = count($transaction['transactions']) * 4;
|
$requiredHits = count($transaction['transactions']) * 4;
|
||||||
$totalHits = 0;
|
$totalHits = 0;
|
||||||
Log::debug(sprintf('Required hits for transfer comparison is %d', $requiredHits));
|
Log::debug(sprintf('Required hits for transfer comparison is %d', $requiredHits));
|
||||||
|
Log::debug(sprintf('Array has %d transactions.', \count($transaction['transactions'])));
|
||||||
|
Log::debug(sprintf('System has %d existing transfers', \count($this->transfers)));
|
||||||
// loop over each split:
|
// loop over each split:
|
||||||
foreach ($transaction['transactions'] as $current) {
|
foreach ($transaction['transactions'] as $current) {
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ use FireflyIII\Models\RuleAction;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Rule.
|
* Class Rule.
|
||||||
|
* @property bool $stop_processing
|
||||||
|
* @property int $id
|
||||||
*/
|
*/
|
||||||
class Rule extends Model
|
class Rule extends Model
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,8 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
/**
|
/**
|
||||||
* Class Tag.
|
* Class Tag.
|
||||||
* @property Collection $transactionJournals
|
* @property Collection $transactionJournals
|
||||||
|
* @property string $tag
|
||||||
|
* @property int $id
|
||||||
*/
|
*/
|
||||||
class Tag extends Model
|
class Tag extends Model
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user