Fixes de telefono y apellido de persona
This commit is contained in:
@ -38,7 +38,9 @@ class Toku extends Controller
|
||||
} else {
|
||||
$output['success'] = true;
|
||||
}
|
||||
} catch (Read | InvalidResult) {}
|
||||
} catch (Read | InvalidResult $exception) {
|
||||
$this->logger->debug($exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function success(ServerRequestInterface $request, ResponseInterface $response,
|
||||
|
@ -19,8 +19,8 @@ class Persona extends Ideal\Repository
|
||||
public function create(?array $data = null): Model\Persona
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['rut', 'digito', 'nombres']))
|
||||
->register('apellido_paterno', (new Implement\Repository\Mapper())->setProperty('apellidoPaterno'))
|
||||
->register('apellido_materno', (new Implement\Repository\Mapper())->setProperty('apellidoMaterno'))
|
||||
->register('apellido_paterno', (new Implement\Repository\Mapper())->setProperty('apellidoPaterno')->setDefault(''))
|
||||
->register('apellido_materno', (new Implement\Repository\Mapper())->setProperty('apellidoMaterno')->setDefault(''))
|
||||
;
|
||||
return $this->parseData(new Model\Persona(), $data, $map);
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
use InvalidArgumentException;
|
||||
use OutOfRangeException;
|
||||
use PDOException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
@ -65,9 +65,9 @@ class Job extends Ideal\Service
|
||||
*/
|
||||
public function add(array $configuration): Model\Job
|
||||
{
|
||||
$now = (new DateTimeImmutable());
|
||||
$now = (new DateTimeImmutable('now', new DateTimeZone($_ENV['TZ'] ?? 'America/Santiago')));
|
||||
$data = [
|
||||
'id' => $now->getTimestamp(),
|
||||
'id' => $now->format('Uu'),
|
||||
'configuration' => $configuration,
|
||||
'executed' => false,
|
||||
'created_at' => $now->format('Y-m-d H:i:s'),
|
||||
@ -129,8 +129,10 @@ class Job extends Ideal\Service
|
||||
*/
|
||||
protected function findJob(array $jobs, int $id): int
|
||||
{
|
||||
$idx = array_find_key($jobs, fn($job) => $job['id'] === $id);
|
||||
if ($idx === false) {
|
||||
$idx = array_find_key($jobs, function($job) use ($id) {
|
||||
return (int) $job['id'] === $id;
|
||||
});
|
||||
if ($idx === null) {
|
||||
throw new EmptyResult("SELECT * FROM jobs WHERE id = ?");
|
||||
}
|
||||
return $idx;
|
||||
|
@ -70,7 +70,7 @@ class Persona extends Ideal\Service
|
||||
$data['digito'] = $propietario->dv;
|
||||
$data['nombres'] = $propietario->nombres;
|
||||
$data['apellido_paterno'] = $propietario->apellidos['paterno'];
|
||||
$data['apellido_materno'] = $propietario->apellidos['materno'];
|
||||
$data['apellido_materno'] = $propietario->apellidos['materno'] ?? '';
|
||||
$persona = $this->personaRepository->create($data);
|
||||
try {
|
||||
$persona = $this->personaRepository->save($persona);
|
||||
|
@ -113,9 +113,11 @@ class Toku extends Ideal\Service
|
||||
$invoice = array_find($customerInvoices, function($invoiceRow) use ($cuota) {
|
||||
return $invoiceRow['invoice_external_id'] === $cuota->id;
|
||||
});
|
||||
$invoices []= $invoice;
|
||||
$this->invoice->save($invoice);
|
||||
continue;
|
||||
if ($invoice !== null) {
|
||||
$invoices []= $invoice;
|
||||
$this->invoice->save($invoice);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$invoices []= $this->invoice->getById($cuota->id);
|
||||
|
@ -72,6 +72,17 @@ class Customer extends AbstractEndPoint
|
||||
if ($ref === null) {
|
||||
continue;
|
||||
}
|
||||
if ($ref === 'telefono') {
|
||||
$value = $data[$ref];
|
||||
if ($value === '' or $value === null or $value === '0') {
|
||||
continue;
|
||||
}
|
||||
if (!str_starts_with($value, '+')) {
|
||||
$value = "+56{$value}";
|
||||
}
|
||||
$params[$key] = $value;
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($ref, $data) and $data[$ref] !== '' and $data[$ref] !== null) {
|
||||
$params[$key] = $data[$ref];
|
||||
}
|
||||
|
Reference in New Issue
Block a user