FIX: Fechas revisadas.
This commit is contained in:
@ -117,13 +117,14 @@ class Pago
|
||||
return $this->process($this->pagoRepository->fetchDevolucionByVenta($venta_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function add(array $data): Model\Venta\Pago
|
||||
{
|
||||
if (!isset($data['uf'])) {
|
||||
$data['uf'] = $this->ufService->get(new DateTimeImmutable($data['fecha']));
|
||||
try {
|
||||
$data['uf'] = $this->ufService->get(new DateTimeImmutable($data['fecha']));
|
||||
} catch (\DateMalformedStringException) {
|
||||
$data['uf'] = 0;
|
||||
}
|
||||
}
|
||||
$filtered_data = $this->pagoRepository->filterData($data);
|
||||
$filtered_data['valor'] = round($this->valorService->clean($filtered_data['valor']));
|
||||
@ -141,16 +142,21 @@ class Pago
|
||||
return $pago;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function edit(Model\Venta\Pago $pago, array $data): Model\Venta\Pago
|
||||
{
|
||||
if (array_key_exists('fecha', $data)) {
|
||||
$data['fecha'] = (new DateTimeImmutable($data['fecha']))->format('Y-m-d');
|
||||
try {
|
||||
$data['fecha'] = (new DateTimeImmutable($data['fecha']))->format('Y-m-d');
|
||||
} catch (\DateMalformedStringException) {
|
||||
$data['fecha'] = (new DateTimeImmutable())->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
if (array_key_exists('uf', $data)) {
|
||||
$data['uf'] = $this->ufService->get(new DateTimeImmutable($data['fecha']));
|
||||
try {
|
||||
$data['uf'] = $this->ufService->get(new DateTimeImmutable($data['fecha']));
|
||||
} catch (\DateMalformedStringException) {
|
||||
$data['uf'] = 0;
|
||||
}
|
||||
}
|
||||
$filteredData = $this->pagoRepository->filterData($data);
|
||||
if (array_key_exists('valor', $filteredData)) {
|
||||
|
Reference in New Issue
Block a user