From 07a1607554b3f839512ea048bf60dfa4b1b90d3d Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Mon, 24 Nov 2025 19:07:56 -0300 Subject: [PATCH] Set default date --- app/src/Controller/API/Ventas/Precios.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/Controller/API/Ventas/Precios.php b/app/src/Controller/API/Ventas/Precios.php index 169a5c8..61f594d 100644 --- a/app/src/Controller/API/Ventas/Precios.php +++ b/app/src/Controller/API/Ventas/Precios.php @@ -61,7 +61,12 @@ class Precios { $body = $request->getParsedBody(); $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']; $output = [ 'input' => $body, @@ -69,7 +74,6 @@ class Precios 'precios' => [], 'status' => false ]; - $date = DateTime::createFromFormat('Y-m-d', $date); try { $output['precios'] = $precioService->import($projectId, $date, $file); $output['total'] = count($output['precios']);