Set default date

This commit is contained in:
Juan Pablo Vial
2025-11-24 19:07:56 -03:00
parent a0019b51a5
commit 07a1607554

View File

@ -61,7 +61,12 @@ class Precios
{ {
$body = $request->getParsedBody(); $body = $request->getParsedBody();
$projectId = $body['project_id']; $projectId = $body['project_id'];
$date = $body['date']; if (array_key_exists('date', $body)) {
$date = $body['date'];
$date = DateTime::createFromFormat('Y-m-d', $date);
} else {
$date = new DateTime();
}
$file = $request->getUploadedFiles()['file']; $file = $request->getUploadedFiles()['file'];
$output = [ $output = [
'input' => $body, 'input' => $body,
@ -69,7 +74,6 @@ class Precios
'precios' => [], 'precios' => [],
'status' => false 'status' => false
]; ];
$date = DateTime::createFromFormat('Y-m-d', $date);
try { try {
$output['precios'] = $precioService->import($projectId, $date, $file); $output['precios'] = $precioService->import($projectId, $date, $file);
$output['total'] = count($output['precios']); $output['total'] = count($output['precios']);