Final code + language for alpha 2.

This commit is contained in:
James Cole
2020-08-20 20:43:23 +02:00
parent 9f80d729a2
commit c63721a15f
33 changed files with 3280 additions and 250 deletions

View File

@@ -253,7 +253,7 @@ class JournalUpdateService
}
$destInfo = [
'id' => (int)($this->data['destination_id'] ?? null),
'id' => (int) ($this->data['destination_id'] ?? null),
'name' => $this->data['destination_name'] ?? null,
'iban' => $this->data['destination_iban'] ?? null,
'number' => $this->data['destination_number'] ?? null,
@@ -287,7 +287,7 @@ class JournalUpdateService
}
$sourceInfo = [
'id' => (int)($this->data['source_id'] ?? null),
'id' => (int) ($this->data['source_id'] ?? null),
'name' => $this->data['source_name'] ?? null,
'iban' => $this->data['source_iban'] ?? null,
'number' => $this->data['source_number'] ?? null,
@@ -547,12 +547,27 @@ class JournalUpdateService
/**
* Update journal generic field. Cannot be set to NULL.
*
* @param $fieldName
* @param string $fieldName
*/
private function updateField($fieldName): void
private function updateField(string $fieldName): void
{
if (array_key_exists($fieldName, $this->data) && '' !== (string)$this->data[$fieldName]) {
$this->transactionJournal->$fieldName = $this->data[$fieldName];
if (array_key_exists($fieldName, $this->data) && '' !== (string) $this->data[$fieldName]) {
$value = $this->data[$fieldName];
if ('date' === $fieldName) {
if($value instanceof Carbon) {
// update timezone.
$value->setTimezone(config('app.timezone'));
}
if(!($value instanceof Carbon)) {
$value = new Carbon($value);
}
// do some parsing.
Log::debug(sprintf('Create date value from string "%s".', $value));
}
$this->transactionJournal->$fieldName = $value;
Log::debug(sprintf('Updated %s', $fieldName));
}
}
@@ -652,7 +667,7 @@ class JournalUpdateService
foreach ($this->metaDate as $field) {
if ($this->hasFields([$field])) {
try {
$value = '' === (string)$this->data[$field] ? null : new Carbon($this->data[$field]);
$value = '' === (string) $this->data[$field] ? null : new Carbon($this->data[$field]);
} catch (Exception $e) {
Log::debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));