Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix #1510
James Cole96b482dac51e
diff --git a/app/Support/Import/Routine/File/ImportableConverter.php b/app/Support/Import/Routine/File/ImportableConverter.phpindex 6cc4f65141..f4a6870501 100644--- a/app/Support/Import/Routine/File/ImportableConverter.php+++ b/app/Support/Import/Routine/File/ImportableConverter.php@@ -129,6 +129,28 @@ class ImportableConverter$this->mappedValues = $mappedValues;}+ /**+ * @param string|null $date+ *+ * @return string|null+ */+ private function convertDateValue(string $date = null): ?string+ {+ if (null === $date) {+ return null;+ }+ try {+ $object = Carbon::createFromFormat($this->config['date-format'] ?? 'Ymd', $date);+ } catch (InvalidDateException|InvalidArgumentException $e) {+ Log::error($e->getMessage());+ Log::error($e->getTraceAsString());++ return null;+ }++ return $object->format('Y-m-d');+ }+/*** @param ImportTransaction $importable*@@ -224,19 +246,13 @@ class ImportableConverterthrow new FireflyException($message);}- // throw error when both are he same-- try {- $date = Carbon::createFromFormat($this->config['date-format'] ?? 'Ymd', $importable->date);- } catch (InvalidDateException|InvalidArgumentException $e) {- Log::error($e->getMessage());- Log::error($e->getTraceAsString());- $date = new Carbon;+ $dateStr = $this->convertDateValue($importable->date);+ if (null === $dateStr) {+ $date = new Carbon;+ $dateStr = $date->format('Y-m-d');+ unset($date);}-- $dateStr = $date->format('Y-m-d');-return ['type' => $transactionType,'date' => $dateStr,@@ -253,12 +269,12 @@ class ImportableConverter'sepa-country' => $importable->meta['sepa-countru'] ?? null,'sepa-ep' => $importable->meta['sepa-ep'] ?? null,'sepa-ci' => $importable->meta['sepa-ci'] ?? null,- 'interest_date' => $importable->meta['date-interest'] ?? null,- 'book_date' => $importable->meta['date-book'] ?? null,- 'process_date' => $importable->meta['date-process'] ?? null,- 'due_date' => $importable->meta['date-due'] ?? null,- 'payment_date' => $importable->meta['date-payment'] ?? null,- 'invoice_date' => $importable->meta['date-invoice'] ?? null,+ 'interest_date' => $this->convertDateValue($importable->meta['date-interest'] ?? null),+ 'book_date' => $this->convertDateValue($importable->meta['date-book'] ?? null),+ 'process_date' => $this->convertDateValue($importable->meta['date-process'] ?? null),+ 'due_date' => $this->convertDateValue($importable->meta['date-due'] ?? null),+ 'payment_date' => $this->convertDateValue($importable->meta['date-payment'] ?? null),+ 'invoice_date' => $this->convertDateValue($importable->meta['date-invoice'] ?? null),'external_id' => $importable->externalId,// journal data: