added first and last fields for invoices (#3594)

This commit is contained in:
Kevin Papst
2022-10-24 11:46:13 +02:00
committed by GitHub
parent 006de60f66
commit f5b725e32b
4 changed files with 35 additions and 8 deletions

View File

@@ -90,6 +90,27 @@ class InvoiceModelDefaultHydrator implements InvoiceModelHydrator
]);
}
$entries = $model->getEntries();
$min = null;
$max = null;
foreach ($entries as $entry) {
if ($min === null || $min->getBegin()->getTimestamp() > $entry->getBegin()->getTimestamp()) {
$min = $entry;
}
if ($max === null || $max->getBegin()->getTimestamp() < $entry->getBegin()->getTimestamp()) {
$max = $entry;
}
}
if ($min !== null && $max !== null) {
$values = array_merge($values, [
'invoice.first' => $formatter->getFormattedDateTime($min->getBegin()),
'invoice.last' => $formatter->getFormattedDateTime($max->getEnd()),
]);
}
return $values;
}
}