diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php index a5de54011c..61f30ef5c1 100644 --- a/app/Services/Internal/Support/JournalServiceTrait.php +++ b/app/Services/Internal/Support/JournalServiceTrait.php @@ -95,19 +95,13 @@ trait JournalServiceTrait */ protected function storeMeta(TransactionJournal $journal, array $data, string $field): void { - - if (!isset($data[$field])) { - Log::debug(sprintf('Want to store meta-field "%s", but no value.', $field)); - - return; - } $set = [ 'journal' => $journal, 'name' => $field, - 'data' => (string)$data[$field], + 'data' => (string)($data[$field] ?? ''), ]; - Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $field, (string)$data[$field])); + Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data'])); /** @var TransactionJournalMetaFactory $factory */ $factory = app(TransactionJournalMetaFactory::class); diff --git a/app/Support/Import/Placeholder/ImportTransaction.php b/app/Support/Import/Placeholder/ImportTransaction.php index 3847c7553c..0d397561f7 100644 --- a/app/Support/Import/Placeholder/ImportTransaction.php +++ b/app/Support/Import/Placeholder/ImportTransaction.php @@ -183,7 +183,9 @@ class ImportTransaction $meta = ['sepa-ct-id', 'sepa-ct-op', 'sepa-db', 'sepa-cc', 'sepa-country', 'sepa-batch-id', 'sepa-ep', 'sepa-ci', 'internal-reference', 'date-interest', 'date-invoice', 'date-book', 'date-payment', 'date-process', 'date-due',]; + Log::debug(sprintf('Now going to check role "%s".', $role)); if (\in_array($role, $meta, true)) { + Log::debug(sprintf('Role "%s" is in allowed meta roles, so store its value %s.', $role, $columnValue->getValue())); $this->meta[$role] = $columnValue->getValue(); return; diff --git a/app/Support/Import/Routine/File/ImportableConverter.php b/app/Support/Import/Routine/File/ImportableConverter.php index 17fcfe2b46..43445e96e6 100644 --- a/app/Support/Import/Routine/File/ImportableConverter.php +++ b/app/Support/Import/Routine/File/ImportableConverter.php @@ -133,9 +133,9 @@ class ImportableConverter /** * @param string|null $date * - * @return string + * @return string|null */ - private function convertDateValue(string $date = null): string + private function convertDateValue(string $date = null): ?string { $result = null; if (null !== $date) { @@ -147,11 +147,6 @@ class ImportableConverter Log::error($e->getTraceAsString()); } } - if (null === $result) { - $object = new Carbon; - $result = $object->format('Y-m-d'); - } - return $result; } @@ -167,6 +162,8 @@ class ImportableConverter $foreignAmount = $importable->calculateForeignAmount(); $amount = $importable->calculateAmount(); + Log::debug('All meta data: ', $importable->meta); + if ('' === $amount) { $amount = $foreignAmount; } @@ -215,7 +212,7 @@ class ImportableConverter return [ 'type' => $transactionType, - 'date' => $this->convertDateValue($importable->date), + 'date' => $this->convertDateValue($importable->date) ?? Carbon::create()->format('Y-m-d'), 'tags' => $importable->tags, 'user' => $this->importJob->user_id, 'notes' => $importable->note,