mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 17:57:09 +00:00
Some last minute fixes.
This commit is contained in:
@@ -71,6 +71,7 @@ class TransactionJournalMetaFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null === $entry) {
|
if (null === $entry) {
|
||||||
|
Log::debug(sprintf('Going to create new meta-data entry to store "%s".', $data['name']));
|
||||||
$entry = new TransactionJournalMeta();
|
$entry = new TransactionJournalMeta();
|
||||||
$entry->transactionJournal()->associate($data['journal']);
|
$entry->transactionJournal()->associate($data['journal']);
|
||||||
$entry->name = $data['name'];
|
$entry->name = $data['name'];
|
||||||
|
@@ -289,8 +289,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)->startOfMonth();
|
||||||
$end = app('navigation')->endOfPeriod($this->repository->lastUseDate($tag), $range);
|
$end = app('navigation')->endOfPeriod($this->repository->lastUseDate($tag), $range)->endOfMonth();
|
||||||
|
|
||||||
// properties for entries with their amounts.
|
// properties for entries with their amounts.
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
|
@@ -173,12 +173,15 @@ class ImportArrayStorage
|
|||||||
*/
|
*/
|
||||||
private function getHash(array $transaction): string
|
private function getHash(array $transaction): string
|
||||||
{
|
{
|
||||||
|
unset($transaction['importHashV2']);
|
||||||
$json = json_encode($transaction);
|
$json = json_encode($transaction);
|
||||||
if ($json === false) {
|
if ($json === false) {
|
||||||
throw new FireflyException('Could not encode import array. Please see the logs.', $transaction); // @codeCoverageIgnore
|
throw new FireflyException('Could not encode import array. Please see the logs.', $transaction); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
$hash = hash('sha256', $json, false);
|
||||||
|
Log::debug(sprintf('The hash is: %s', $hash));
|
||||||
|
|
||||||
return hash('sha256', $json, false);
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,6 +230,8 @@ class ImportArrayStorage
|
|||||||
{
|
{
|
||||||
$entry = $this->journalRepos->findByHash($hash);
|
$entry = $this->journalRepos->findByHash($hash);
|
||||||
if (null === $entry) {
|
if (null === $entry) {
|
||||||
|
Log::debug(sprintf('Found no transactions with hash %s.', $hash));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Log::info(sprintf('Found a transaction journal with an existing hash: %s', $hash));
|
Log::info(sprintf('Found a transaction journal with an existing hash: %s', $hash));
|
||||||
@@ -380,6 +385,22 @@ class ImportArrayStorage
|
|||||||
// now actually store them:
|
// now actually store them:
|
||||||
$collection = new Collection;
|
$collection = new Collection;
|
||||||
foreach ($toStore as $index => $store) {
|
foreach ($toStore as $index => $store) {
|
||||||
|
|
||||||
|
// do duplicate detection again!
|
||||||
|
$hash = $this->getHash($store);
|
||||||
|
$existingId = $this->hashExists($hash);
|
||||||
|
if (null !== $existingId) {
|
||||||
|
$this->logDuplicateObject($store, $existingId);
|
||||||
|
$this->repository->addErrorMessage(
|
||||||
|
$this->importJob, sprintf(
|
||||||
|
'Row #%d ("%s") could not be imported. It already exists.',
|
||||||
|
$index, $store['description']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Log::debug(sprintf('Going to store entry %d of %d', $index + 1, $count));
|
Log::debug(sprintf('Going to store entry %d of %d', $index + 1, $count));
|
||||||
// convert the date to an object:
|
// convert the date to an object:
|
||||||
$store['date'] = Carbon::createFromFormat('Y-m-d', $store['date']);
|
$store['date'] = Carbon::createFromFormat('Y-m-d', $store['date']);
|
||||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionJournalMeta.
|
* Class TransactionJournalMeta.
|
||||||
|
* @property string $name
|
||||||
*/
|
*/
|
||||||
class TransactionJournalMeta extends Model
|
class TransactionJournalMeta extends Model
|
||||||
{
|
{
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Repositories\Journal;
|
namespace FireflyIII\Repositories\Journal;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use DB;
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Factory\TransactionJournalFactory;
|
use FireflyIII\Factory\TransactionJournalFactory;
|
||||||
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
||||||
@@ -157,11 +158,21 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function findByHash(string $hash): ?TransactionJournalMeta
|
public function findByHash(string $hash): ?TransactionJournalMeta
|
||||||
{
|
{
|
||||||
return TransactionJournalMeta
|
$jsonEncode = json_encode($hash);
|
||||||
|
$hashOfHash = hash('sha256', $jsonEncode);
|
||||||
|
Log::debug(sprintf('JSON encoded hash is: %s', $jsonEncode));
|
||||||
|
Log::debug(sprintf('Hash of hash is: %s', $hashOfHash));
|
||||||
|
|
||||||
|
$result = TransactionJournalMeta
|
||||||
::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
|
::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
|
||||||
->where('data', json_encode($hash))
|
->where('hash', $hashOfHash)
|
||||||
->where('name', 'importHashV2')
|
->where('name', 'importHashV2')
|
||||||
->first(['journal_meta.*']);
|
->first(['journal_meta.*']);
|
||||||
|
if (null === $result) {
|
||||||
|
Log::debug('Result is null');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Factory\TagFactory;
|
|||||||
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
||||||
use FireflyIII\Models\Note;
|
use FireflyIII\Models\Note;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trait JournalServiceTrait
|
* Trait JournalServiceTrait
|
||||||
@@ -89,14 +90,20 @@ trait JournalServiceTrait
|
|||||||
*/
|
*/
|
||||||
protected function storeMeta(TransactionJournal $journal, array $data, string $field): void
|
protected function storeMeta(TransactionJournal $journal, array $data, string $field): void
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!isset($data[$field])) {
|
if (!isset($data[$field])) {
|
||||||
|
Log::debug(sprintf('Want to store meta-field "%s", but no value.', $field));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$set = [
|
$set = [
|
||||||
'journal' => $journal,
|
'journal' => $journal,
|
||||||
'name' => $field,
|
'name' => $field,
|
||||||
'data' => $data[$field],
|
'data' => (string)$data[$field],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $field, (string)$data[$field]));
|
||||||
|
|
||||||
/** @var TransactionJournalMetaFactory $factory */
|
/** @var TransactionJournalMetaFactory $factory */
|
||||||
$factory = app(TransactionJournalMetaFactory::class);
|
$factory = app(TransactionJournalMetaFactory::class);
|
||||||
$factory->updateOrCreate($set);
|
$factory->updateOrCreate($set);
|
||||||
|
@@ -190,10 +190,12 @@ class Navigation
|
|||||||
return $currentEnd;
|
return $currentEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isset($functionMap[$repeatFreq])) {
|
if (!isset($functionMap[$repeatFreq])) {
|
||||||
throw new FireflyException(sprintf('Cannot do endOfPeriod for $repeat_freq "%s"', $repeatFreq));
|
throw new FireflyException(sprintf('Cannot do endOfPeriod for $repeat_freq "%s"', $repeatFreq));
|
||||||
}
|
}
|
||||||
$function = $functionMap[$repeatFreq];
|
$function = $functionMap[$repeatFreq];
|
||||||
|
|
||||||
if (isset($modifierMap[$repeatFreq])) {
|
if (isset($modifierMap[$repeatFreq])) {
|
||||||
$currentEnd->$function($modifierMap[$repeatFreq]);
|
$currentEnd->$function($modifierMap[$repeatFreq]);
|
||||||
|
|
||||||
|
@@ -158,10 +158,6 @@ return [
|
|||||||
'export_formats' => [
|
'export_formats' => [
|
||||||
'csv' => CsvExporter::class,
|
'csv' => CsvExporter::class,
|
||||||
],
|
],
|
||||||
'spectre' => [
|
|
||||||
'server' => 'https://www.saltedge.com',
|
|
||||||
],
|
|
||||||
|
|
||||||
'default_export_format' => 'csv',
|
'default_export_format' => 'csv',
|
||||||
'default_import_format' => 'csv',
|
'default_import_format' => 'csv',
|
||||||
'bill_periods' => ['weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
|
'bill_periods' => ['weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
|
||||||
|
@@ -57,6 +57,7 @@ require __DIR__ . '/../vendor/autoload.php';
|
|||||||
/** @noinspection UsingInclusionOnceReturnValueInspection */
|
/** @noinspection UsingInclusionOnceReturnValueInspection */
|
||||||
$app = require_once __DIR__ . '/../bootstrap/app.php';
|
$app = require_once __DIR__ . '/../bootstrap/app.php';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Run The Application
|
| Run The Application
|
||||||
@@ -74,7 +75,6 @@ $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
|||||||
$response = $kernel->handle(
|
$response = $kernel->handle(
|
||||||
$request = Illuminate\Http\Request::capture()
|
$request = Illuminate\Http\Request::capture()
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->send();
|
$response->send();
|
||||||
|
|
||||||
$kernel->terminate($request, $response);
|
$kernel->terminate($request, $response);
|
||||||
|
Reference in New Issue
Block a user