Sumar cuotas.
This commit is contained in:
@ -6,9 +6,20 @@
|
||||
|
||||
@section('venta_content')
|
||||
@if (count($venta->formaPago()->cuotasAbono) > 0)
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas" class="ui small green button">Ver Cuotas</a>
|
||||
<p>{{$format->pesos(array_reduce($venta->formaPago()->cuotas, function($sum, $cuota) {return $sum + $cuota->pago->valor;}, 0))}}</p>
|
||||
<p>{{$format->ufs(array_reduce($venta->formaPago()->cuotas, function($sum, $cuota) {return $sum + $cuota->pago->valor();}, 0.0))}}</p>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas" class="ui tertiary green button">Ver Cuotas</a>
|
||||
<div class="ui compact segment">
|
||||
<div class="header">
|
||||
Cuotas
|
||||
</div>
|
||||
<div class="ui horizontal list">
|
||||
<div class="item">
|
||||
{{$format->pesos($venta->formaPago()->cuotasAbono('pesos'))}}
|
||||
</div>
|
||||
<div class="item">
|
||||
{{$format->ufs($venta->formaPago()->cuotasAbono())}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas" class="ui small green button"><i class="plus icon"></i> Agregar Cuotas</a>
|
||||
@endif
|
||||
|
@ -15,8 +15,18 @@
|
||||
</td>
|
||||
@if ($escritura !== null)
|
||||
<td></td>
|
||||
<td class="right aligned">{{$format->ufs($escritura->pago->valor())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($escritura->pago->valor)}}</td>
|
||||
<td class="right aligned">
|
||||
{{$format->ufs($escritura->pago->valor())}}
|
||||
@if (count($venta->formaPago()->cuotasAbono) > 0)
|
||||
<br /> + (<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas">{{$format->ufs($venta->formaPago()->cuotasAbono())}}</a>)
|
||||
@endif
|
||||
</td>
|
||||
<td class="right aligned">
|
||||
{{$format->pesos($escritura->pago->valor)}}
|
||||
@if (count($venta->formaPago()->cuotasAbono) > 0)
|
||||
<br /> + (<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas">{{$format->pesos($venta->formaPago()->cuotasAbono('pesos'))}}</a>)
|
||||
@endif
|
||||
</td>
|
||||
<td id="escritura_pago" class="{{$escritura->pago->currentEstado->tipoEstadoPago->descripcion === 'no pagado' ? 'warning' : ($escritura->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado' ? 'positive' : '')}}">
|
||||
<span class="text">{{$escritura->pago->currentEstado->fecha->format('d-m-Y')}}</span>
|
||||
@if ($escritura->pago->currentEstado->tipoEstadoPago->descripcion === 'no pagado')
|
||||
|
@ -25,6 +25,9 @@ class FormaPago implements JsonSerializable
|
||||
if ($this->escritura !== null) {
|
||||
$sum += $this->escritura->pago->valor($moneda);
|
||||
}
|
||||
if (count($this->cuotasAbono) > 0) {
|
||||
$sum += $this->cuotasAbono($moneda);
|
||||
}
|
||||
return $sum;
|
||||
}
|
||||
public function prometido(string $moneda = Pago::UF): float
|
||||
@ -53,6 +56,15 @@ class FormaPago implements JsonSerializable
|
||||
}
|
||||
return $sum;
|
||||
}
|
||||
public function cuotasAbono(string $moneda = Pago::UF): float
|
||||
{
|
||||
return array_reduce($this->cuotasAbono, function($sum, $cuota) use ($moneda) {
|
||||
if ($cuota->currentEstado->tipoEstadoPago->descripcion === 'abonado') {
|
||||
return $sum + $cuota->pago->valor($moneda);
|
||||
}
|
||||
return $sum;
|
||||
}, 0);
|
||||
}
|
||||
public function ids(): array
|
||||
{
|
||||
return [
|
||||
|
Reference in New Issue
Block a user