Compare commits
4 Commits
933e652dac
...
b9c2972fe9
Author | SHA1 | Date | |
---|---|---|---|
b9c2972fe9 | |||
37015f7e95 | |||
c3b36dcdf7 | |||
c68b773cbb |
@ -16,7 +16,7 @@
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
|
||||
<span data-tooltip="Pagadas">{{count($pie->cuotas(true))}}</span>/{{$pie->cuotas}}
|
||||
</a>
|
||||
@if (count($pie->cuotas(false, true)) < $pie->cuotas)
|
||||
@if (count($pie->cuotas(vigentes: true)) < $pie->cuotas)
|
||||
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">
|
||||
<i class="plus icon"></i>
|
||||
</a>
|
||||
|
@ -84,7 +84,7 @@ class Cuotas
|
||||
return $view->render($response, 'ventas.pies.cuotas.add', compact('pie', 'venta', 'bancos'));
|
||||
}
|
||||
public function doAdd(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService,
|
||||
Repository\Venta $ventaRepository, int $pie_id): ResponseInterface
|
||||
Repository\Venta $ventaRepository, Service\Valor $valorService, int $pie_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$pie = $pieService->getById($pie_id);
|
||||
@ -92,12 +92,15 @@ class Cuotas
|
||||
$start = count($pie->cuotas(vigentes: true));
|
||||
$total = $pie->cuotas;
|
||||
for ($i = $start; $i < $total; $i ++) {
|
||||
if ($body["banco{$i}"] === '') {
|
||||
continue;
|
||||
}
|
||||
$data = [
|
||||
'pie' => $pie->id,
|
||||
'fecha' => $body["fecha{$i}"],
|
||||
'banco' => $body["banco{$i}"],
|
||||
'banco' => (int) $body["banco{$i}"],
|
||||
'identificador' => $body["identificador{$i}"],
|
||||
'valor' => str_replace(['.', ','], ['', ''], $body["valor{$i}"]),
|
||||
'valor' => $valorService->clean($body["valor{$i}"]),
|
||||
'numero' => $i + 1,
|
||||
];
|
||||
$pieService->addCuota($data);
|
||||
|
@ -18,7 +18,8 @@ class Pie extends Model
|
||||
public function cuotas(bool $pagadas = false, bool $vigentes = false): array
|
||||
{
|
||||
if ($this->asociado !== null) {
|
||||
return $this->asociado->cuotas($pagadas, $vigentes);
|
||||
$cuotas = $this->asociado->cuotas($pagadas, $vigentes);
|
||||
$this->cuotasArray = array_merge($this->cuotasArray, $cuotas);
|
||||
}
|
||||
if (!$pagadas and !$vigentes) {
|
||||
return $this->cuotasArray;
|
||||
|
@ -4,16 +4,21 @@ namespace Incoviba\Service\Venta;
|
||||
use DateTimeImmutable;
|
||||
use DateInterval;
|
||||
use IntlDateFormatter;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Cuota
|
||||
class Cuota extends Ideal\Service
|
||||
{
|
||||
public function __construct(
|
||||
LoggerInterface $logger,
|
||||
protected Repository\Venta\Cuota $cuotaRepository,
|
||||
protected Pago $pagoService,
|
||||
protected Repository\Venta\TipoPago $tipoPagoRepository
|
||||
) {}
|
||||
) {
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function pendientes(): array
|
||||
{
|
||||
@ -75,11 +80,11 @@ class Cuota
|
||||
}
|
||||
public function getByPie(int $pie_id): array
|
||||
{
|
||||
try {
|
||||
return $this->cuotaRepository->fetchByPie($pie_id);
|
||||
} catch (EmptyResult) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
return $this->cuotaRepository->fetchByPie($pie_id);
|
||||
} catch (EmptyResult) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
public function getVigenteByPie(int $pie_id): array
|
||||
{
|
||||
@ -89,13 +94,14 @@ class Cuota
|
||||
public function add(array $data): Model\Venta\Cuota
|
||||
{
|
||||
$tipoPago = $this->tipoPagoRepository->fetchByDescripcion('cheque');
|
||||
$fields = array_fill_keys([
|
||||
$fields = array_flip([
|
||||
'fecha',
|
||||
'banco',
|
||||
'valor',
|
||||
'identificador'
|
||||
], 0);
|
||||
]);
|
||||
$filtered_data = array_intersect_key($data, $fields);
|
||||
|
||||
$pago_data = array_merge($filtered_data, ['tipo' => $tipoPago->id]);
|
||||
$pago = $this->pagoService->add($pago_data);
|
||||
|
||||
|
Reference in New Issue
Block a user