Agregando o buscando el cliente primero
This commit is contained in:
@ -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([
|
||||
|
Reference in New Issue
Block a user