Add timezone fields.

This commit is contained in:
James Cole 2024-11-06 14:10:34 +01:00
parent 225588f3e7
commit 0728668d41
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80

View File

@ -101,7 +101,7 @@ class JournalUpdateService
'external_url',
];
$this->metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date',
'invoice_date', ];
'invoice_date',];
}
public function setData(array $data): void
@ -490,6 +490,7 @@ class JournalUpdateService
}
// do some parsing.
app('log')->debug(sprintf('Create date value from string "%s".', $value));
$this->transactionJournal->date_tz = $value->format('e');
}
event(
new TriggeredAuditLog(
@ -598,7 +599,7 @@ class JournalUpdateService
if ($this->hasFields([$field])) {
try {
$value = '' === (string) $this->data[$field] ? null : new Carbon($this->data[$field]);
} catch (InvalidDateException|InvalidFormatException $e) { // @phpstan-ignore-line
} catch (InvalidDateException | InvalidFormatException $e) { // @phpstan-ignore-line
app('log')->debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));
return;
@ -610,6 +611,13 @@ class JournalUpdateService
'data' => $value,
];
$factory->updateOrCreate($set);
// also set date with timezone.
$set = [
'journal' => $this->transactionJournal,
'name' => sprintf('%s_tz', $field),
'data' => $value->format('e'),
];
$factory->updateOrCreate($set);
}
}
}