Matriz facturacion
This commit is contained in:
@ -2,11 +2,12 @@
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use DateInterval;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Venta extends Service
|
||||
{
|
||||
@ -27,6 +28,7 @@ class Venta extends Service
|
||||
protected Venta\Credito $creditoService,
|
||||
protected Venta\BonoPie $bonoPieService,
|
||||
protected Venta\Pago $pagoService,
|
||||
protected Proyecto\Terreno $terrenoService,
|
||||
protected Money $moneyService
|
||||
) {
|
||||
parent::__construct($logger);
|
||||
@ -91,6 +93,33 @@ class Venta extends Service
|
||||
{
|
||||
return $this->process($this->ventaRepository->fetchByPie($pie_id));
|
||||
}
|
||||
public function getFacturacionById(int $venta_id): array
|
||||
{
|
||||
$venta = $this->getById($venta_id);
|
||||
$escritura = (in_array($venta->currentEstado()->tipoEstadoVenta->descripcion, ['escriturando'])) ? $venta->currentEstado()->fecha : $venta->fecha;
|
||||
$data = [
|
||||
'id' => $venta->id,
|
||||
'fecha' => $venta->fecha->format('Y-m-d'),
|
||||
'valor' => $venta->valor,
|
||||
'escritura' => $escritura->format('Y-m-d'),
|
||||
'unidades' => [],
|
||||
];
|
||||
foreach ($venta->propiedad()->unidades as $unidad) {
|
||||
$data['unidades'] []= [
|
||||
'id' => $unidad->id,
|
||||
'tipo' => ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion),
|
||||
'descripcion' => $unidad->descripcion,
|
||||
'prorrateo' => $unidad->prorrateo,
|
||||
'precio' => (isset($unidad->currentPrecio)) ? $unidad->currentPrecio->valor : 0
|
||||
];
|
||||
}
|
||||
$principal = $venta->propiedad()->principal();
|
||||
$data['principal'] = [
|
||||
'id' => $principal->id,
|
||||
'descripcion' => $principal->descripcion
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function process(Model\Venta $venta): Model\Venta
|
||||
{
|
||||
|
Reference in New Issue
Block a user