Cuotas con detalle de UF y de Pies asociados
This commit is contained in:
@ -5,6 +5,29 @@
|
|||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('venta_content')
|
@section('venta_content')
|
||||||
|
@if (count($asociadas) > 0)
|
||||||
|
<div class="ui grid">
|
||||||
|
<div class="two wide column">Asociados</div>
|
||||||
|
<div class="six wide column">
|
||||||
|
{!! implode(' - ', array_map(function(Incoviba\Model\Venta $venta) use ($urls) {
|
||||||
|
return "<a href=\"{$urls->base}/venta/{$venta->id}\">{$venta->propiedad()->departamentos()[0]->descripcion}</a>";
|
||||||
|
}, $asociadas)) !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<div class="ui grid">
|
||||||
|
<div class="column">Valor</div>
|
||||||
|
<div class="four wide column">
|
||||||
|
{{$format->ufs($venta->formaPago()->pie->valor)}}
|
||||||
|
@if (count($asociadas) > 0)
|
||||||
|
[{{$format->ufs($venta->formaPago()->pie->valor + array_reduce($asociadas, function(float $sum, Incoviba\Model\Venta $venta) {
|
||||||
|
return $sum + $venta->formaPago()->pie->valor;
|
||||||
|
}, 0.0))}}]
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="column">Cuotas</div>
|
||||||
|
<div class="column">{{$venta->formaPago()->pie->cuotas}}</div>
|
||||||
|
</div>
|
||||||
<table class="ui table" id="cuotas">
|
<table class="ui table" id="cuotas">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -37,8 +60,10 @@
|
|||||||
<td>{{$cuota->pago->identificador}}</td>
|
<td>{{$cuota->pago->identificador}}</td>
|
||||||
<td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
|
<td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
|
||||||
<td class="right aligned">
|
<td class="right aligned">
|
||||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' and $cuota->pago->currentEstado->fecha <= $now)
|
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['depositado', 'abonado']) and $cuota->pago->currentEstado->fecha <= $now)
|
||||||
{{$format->ufs($cuota->pago->valor())}}
|
{{$format->ufs($cuota->pago->valor())}}
|
||||||
|
@else
|
||||||
|
~{{$format->ufs($cuota->pago->valor / $uf_venta)}}
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
@ -115,7 +140,7 @@
|
|||||||
}, 0.0))}}
|
}, 0.0))}}
|
||||||
</th>
|
</th>
|
||||||
<th class="right aligned">
|
<th class="right aligned">
|
||||||
{{$format->number($pagado / $total * 100, 2)}}%
|
{{$format->number(($total > 0) ? $pagado / $total * 100 : 0, 2)}}%
|
||||||
</th>
|
</th>
|
||||||
<th colspan="3"></th>
|
<th colspan="3"></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -128,7 +153,7 @@
|
|||||||
{{$format->ufs($total - $pagado)}}
|
{{$format->ufs($total - $pagado)}}
|
||||||
</th>
|
</th>
|
||||||
<th class="right aligned">
|
<th class="right aligned">
|
||||||
{{$format->number(($total - $pagado) / $total * 100, 2)}}%
|
{{$format->number(($total > 0) ? ($total - $pagado) / $total * 100 : 0, 2)}}%
|
||||||
</th>
|
</th>
|
||||||
<th colspan="3"></th>
|
<th colspan="3"></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -98,10 +98,21 @@ class Ventas
|
|||||||
return $view->render($response, 'ventas.add', compact('regiones', 'proyectos'));
|
return $view->render($response, 'ventas.add', compact('regiones', 'proyectos'));
|
||||||
}
|
}
|
||||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||||
|
Repository\Venta $ventaRepository,
|
||||||
View $view, int $venta_id): ResponseInterface
|
View $view, int $venta_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$venta = $ventaService->getById($venta_id);
|
$venta = $ventaService->getById($venta_id);
|
||||||
return $view->render($response, 'ventas.pies.cuotas', compact('venta'));
|
$asociadas = [];
|
||||||
|
if (isset($venta->formaPago()->pie->asociado)) {
|
||||||
|
$asociadas []= $ventaService->getByPie($venta->formaPago()->pie->asociado->id);
|
||||||
|
foreach ($venta->formaPago()->pie->asociado->asociados() as $asociado) {
|
||||||
|
if ($venta->formaPago()->pie->id === $asociado->id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$asociadas []= $ventaService->getByPie($asociado->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $view->render($response, 'ventas.pies.cuotas', compact('venta', 'asociadas'));
|
||||||
}
|
}
|
||||||
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||||
Repository\Contabilidad\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
|
Repository\Contabilidad\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
|
||||||
|
@ -10,7 +10,9 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||||||
|
|
||||||
class Pies
|
class Pies
|
||||||
{
|
{
|
||||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
|
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService,
|
||||||
|
Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository,
|
||||||
|
View $view, int $pie_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$pie = $pieService->getById($pie_id);
|
$pie = $pieService->getById($pie_id);
|
||||||
$venta = $ventaRepository->fetchByPie($pie_id);
|
$venta = $ventaRepository->fetchByPie($pie_id);
|
||||||
@ -18,6 +20,6 @@ class Pies
|
|||||||
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
||||||
return strcmp($a->nombre, $b->nombre);
|
return strcmp($a->nombre, $b->nombre);
|
||||||
});
|
});
|
||||||
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos'));
|
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos', 'ventaRepository'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,10 @@ class Venta extends Service
|
|||||||
{
|
{
|
||||||
return $this->ventaRepository->fetchByIdForList($venta_id);
|
return $this->ventaRepository->fetchByIdForList($venta_id);
|
||||||
}
|
}
|
||||||
|
public function getByPie(int $pie_id): Model\Venta
|
||||||
|
{
|
||||||
|
return $this->process($this->ventaRepository->fetchByPie($pie_id));
|
||||||
|
}
|
||||||
|
|
||||||
protected function process(Model\Venta $venta): Model\Venta
|
protected function process(Model\Venta $venta): Model\Venta
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@ class Pago
|
|||||||
try {
|
try {
|
||||||
$estado = $this->estadoPagoRepository->create($data);
|
$estado = $this->estadoPagoRepository->create($data);
|
||||||
$this->estadoPagoRepository->save($estado);
|
$this->estadoPagoRepository->save($estado);
|
||||||
|
$this->getUF($pago);
|
||||||
return true;
|
return true;
|
||||||
} catch (PDOException) {
|
} catch (PDOException) {
|
||||||
return false;
|
return false;
|
||||||
@ -162,7 +163,7 @@ class Pago
|
|||||||
protected function getUF(Model\Venta\Pago $pago): ?float
|
protected function getUF(Model\Venta\Pago $pago): ?float
|
||||||
{
|
{
|
||||||
if (($pago->uf === null or $pago->uf === 0.0)
|
if (($pago->uf === null or $pago->uf === 0.0)
|
||||||
and $pago->currentEstado->tipoEstadoPago->descripcion === 'abonado'
|
and in_array($pago->currentEstado->tipoEstadoPago->descripcion, ['depositado', 'abonado'])
|
||||||
and $pago->currentEstado->fecha <= new DateTimeImmutable()) {
|
and $pago->currentEstado->fecha <= new DateTimeImmutable()) {
|
||||||
$uf = $this->moneyService->getUF($pago->currentEstado->fecha);
|
$uf = $this->moneyService->getUF($pago->currentEstado->fecha);
|
||||||
if ($uf !== 0.0) {
|
if ($uf !== 0.0) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
namespace Incoviba\Service\Venta;
|
namespace Incoviba\Service\Venta;
|
||||||
|
|
||||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||||
|
use Incoviba\Common\Implement\Repository\Factory;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Model;
|
use Incoviba\Model;
|
||||||
|
|
||||||
@ -47,6 +48,9 @@ class Pie
|
|||||||
try {
|
try {
|
||||||
$pie->asociados = $this->pieRepository->fetchAsociados($pie->id);
|
$pie->asociados = $this->pieRepository->fetchAsociados($pie->id);
|
||||||
} catch (EmptyResult) {}
|
} catch (EmptyResult) {}
|
||||||
|
if (isset($pie->asociado)) {
|
||||||
|
$pie->asociado = $this->getById($pie->asociado->id);
|
||||||
|
}
|
||||||
return $pie;
|
return $pie;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ services:
|
|||||||
service: web
|
service: web
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs/test:/logs
|
- ./logs/test:/logs
|
||||||
command: [ '/code/vendor/bin/phpunit-watcher', 'watch' ]
|
command: [ '/code/bin/phpunit-watcher', 'watch' ]
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
dbdata: {}
|
dbdata: {}
|
||||||
|
Reference in New Issue
Block a user