feature/grabar-factura #11

Merged
aldarien merged 14 commits from feature/grabar-factura into develop 2025-02-04 10:37:34 -03:00
16 changed files with 1427 additions and 1171 deletions
Showing only changes of commit 71615050f3 - Show all commits

View File

@ -7,13 +7,15 @@ use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
class Factura extends Ideal\Service
{
public function __construct(LoggerInterface $logger,
protected Repository\Venta\Factura $facturaRepository,
protected Repository\Venta\Factura\Estado $estadoRepository,
protected Repository\Venta\Factura\Estado\Tipo $tipoRepository)
protected Repository\Venta\Factura\Estado\Tipo $tipoRepository,
protected Service\Persona $personaService)
{
parent::__construct($logger);
}
@ -57,6 +59,11 @@ class Factura extends Ideal\Service
if ($factura !== null) {
return $factura;
}
list($data['cliente']['rut'], $data['cliente']['digito']) = explode('-', $data['cliente']['rut']);
$data['cliente']['rut'] = (int) str_replace('.', '', $data['cliente']['rut']);
$client = $this->personaService->add($data['cliente']);
$data['cliente_rut'] = $client->rut;
unset($data['cliente']);
$factura = $this->facturaRepository->save($this->facturaRepository->create($data));
$tipo = $this->tipoRepository->fetchByDescripcion('generada');
$this->estadoRepository->save($this->estadoRepository->create([