Editar desistimiento venta
This commit is contained in:
@ -30,6 +30,7 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) {
|
||||
});
|
||||
$app->get('/escriturar[/]', [Ventas::class, 'escriturar']);
|
||||
$app->get('/desistir[/]', [Ventas::class, 'desistir']);
|
||||
$app->get('/desistida[/]', [Ventas::class, 'desistida']);
|
||||
$app->get('/edit[/]', [Ventas::class, 'edit']);
|
||||
$app->get('[/]', [Ventas::class, 'show']);
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Pagos;
|
||||
use Incoviba\Controller\API\Ventas\Pagos;
|
||||
|
||||
$app->group('/pagos', function($app) {
|
||||
$app->get('/pendientes', [Pagos::class, 'para_pendientes']);
|
||||
@ -9,4 +9,5 @@ $app->group('/pagos', function($app) {
|
||||
$app->group('/pago/{pago_id:[0-9]+}', function($app) {
|
||||
$app->put('/depositar[/]', [Pagos::class, 'depositar']);
|
||||
$app->put('/abonar[/]', [Pagos::class, 'abonar']);
|
||||
$app->post('[/]', [Pagos::class, 'edit']);
|
||||
});
|
||||
|
78
app/resources/views/ventas/desistida.blade.php
Normal file
78
app/resources/views/ventas/desistida.blade.php
Normal file
@ -0,0 +1,78 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">
|
||||
Desistida - {{$venta->proyecto()->descripcion}} -
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}">
|
||||
{{$venta->propiedad()->summary()}}
|
||||
</a>
|
||||
</h1>
|
||||
<form class="ui form" id="desistida_form">
|
||||
<div class="three wide field">
|
||||
<label for="fecha">Fecha</label>
|
||||
<div class="ui calendar" id="fecha">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="devolucion">Devolución</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" id="devolucion" value="{{$venta->resciliacion()->valor}}" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
function alertResponse(message, color = 'green') {
|
||||
$.toast({
|
||||
message,
|
||||
showProgress: 'bottom',
|
||||
progressUp: true,
|
||||
class: color,
|
||||
showIcon: 'check circle',
|
||||
classProgress: 'blue'
|
||||
})
|
||||
}
|
||||
$(document).ready(() => {
|
||||
const url = '{{$urls->api}}/ventas/pago/{{$venta->resciliacion()->id}}'
|
||||
let old = new Date({{$venta->resciliacion()->fecha->format('Y')}},
|
||||
{{$venta->resciliacion()->fecha->format('n')}}-1, {{$venta->resciliacion()->fecha->format('j')}})
|
||||
calendar_date_options['initialDate'] = old
|
||||
calendar_date_options['onChange'] = function(date, text, mode) {
|
||||
if (date.getTime() === old.getTime()) {
|
||||
return
|
||||
}
|
||||
const body = new FormData()
|
||||
body.set('fecha', date.toISOString())
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
old = date
|
||||
alertResponse('Fecha cambiada correctamente.')
|
||||
})
|
||||
}
|
||||
$('#fecha').calendar(calendar_date_options)
|
||||
$('#devolucion').change(event => {
|
||||
console.debug(event)
|
||||
const val = $(event.currentTarget).val()
|
||||
const body = new FormData()
|
||||
body.set('valor', val)
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
alertResponse('Devolución cambiada correctamente.')
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
85
app/src/Controller/API/Ventas/Pagos.php
Normal file
85
app/src/Controller/API/Ventas/Pagos.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Ventas;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Pagos
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Pago $pagoRepository, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'pago_id' => $pago_id,
|
||||
'pago' => null
|
||||
];
|
||||
try {
|
||||
$pago = $pagoRepository->fetchById($pago_id);
|
||||
if (isset($body['fecha'])) {
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$body['fecha'] = $fecha->format('Y-m-d');
|
||||
}
|
||||
$output['pago'] = $pagoRepository->edit($pago, $body);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
// NOT IMPLEMENTED
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$body = $request->getBody();
|
||||
$json = json_decode($body->getContents());
|
||||
$date = new DateTimeImmutable($json->fecha);
|
||||
$response->getBody()->write(json_encode(['fecha' => $date->format('d-m-Y'), 'message' => 'Not implemented']));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
// NOT IMPLEMENTED
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$body = $request->getBody();
|
||||
$json = json_decode($body->getContents());
|
||||
$date = new DateTimeImmutable($json->fecha);
|
||||
$response->getBody()->write(json_encode(['fecha' => $date->format('d-m-Y'), 'message' => 'Not implemented']));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
public function para_pendientes(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getPendientes();
|
||||
$pagos_pendientes = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$pagos_pendientes []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, ['pagos' => $pagos_pendientes, 'total' => count($pagos_pendientes)]);
|
||||
}
|
||||
public function para_abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getDepositados();
|
||||
$pagos_depositados = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$pagos_depositados []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, ['pagos' => $pagos_depositados, 'total' => count($pagos_depositados)]);
|
||||
}
|
||||
public function rebotes(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getRebotes();
|
||||
$rebotes = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$rebotes []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, ['pagos' => $rebotes, 'total' => count($rebotes)]);
|
||||
}
|
||||
}
|
@ -114,4 +114,10 @@ class Ventas
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.desistir', compact('venta'));
|
||||
}
|
||||
public function desistida(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
View $view, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.desistida', compact('venta'));
|
||||
}
|
||||
}
|
||||
|
@ -13,56 +13,4 @@ class Pagos
|
||||
{
|
||||
return $view->render($response, 'ventas.pagos.pendientes');
|
||||
}
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$body = $request->getBody();
|
||||
$json = json_decode($body->getContents());
|
||||
$date = new DateTimeImmutable($json->fecha);
|
||||
$response->getBody()->write(json_encode(['fecha' => $date->format('d-m-Y'), 'message' => 'Not implemented']));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$body = $request->getBody();
|
||||
$json = json_decode($body->getContents());
|
||||
$date = new DateTimeImmutable($json->fecha);
|
||||
$response->getBody()->write(json_encode(['fecha' => $date->format('d-m-Y'), 'message' => 'Not implemented']));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
public function para_pendientes(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getPendientes();
|
||||
$pagos_pendientes = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$pagos_pendientes []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
$response->getBody()->write(json_encode(['pagos' => $pagos_pendientes, 'total' => count($pagos_pendientes)]));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
public function para_abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getDepositados();
|
||||
$pagos_depositados = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$pagos_depositados []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
$response->getBody()->write(json_encode(['pagos' => $pagos_depositados, 'total' => count($pagos_depositados)]));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
public function rebotes(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService): ResponseInterface
|
||||
{
|
||||
$pagos = $pagoService->getRebotes();
|
||||
$rebotes = [];
|
||||
foreach ($pagos as $pago) {
|
||||
$rebotes []= [
|
||||
'id' => $pago->id
|
||||
];
|
||||
}
|
||||
$response->getBody()->write(json_encode(['pagos' => $rebotes, 'total' => count($rebotes)]));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Pago extends Model
|
||||
'banco' => $this->banco ?? '',
|
||||
'tipo_pago' => $this->tipoPago ?? '',
|
||||
'identificador' => $this->identificador ?? '',
|
||||
'fecha' => $this->fecha->format('Y-m-d H:i:S') ?? '',
|
||||
'fecha' => $this->fecha->format('Y-m-d H:i:s') ?? '',
|
||||
'uf' => $this->uf ?? 1,
|
||||
'pagador' => $this->pagador ?? '',
|
||||
'asociado' => $this->asociado ?? ''
|
||||
|
Reference in New Issue
Block a user