Professional Documents
Culture Documents
6 Julio Commit
6 Julio Commit
app/Http/Controllers/Admin/PaymentController.php 0 → 100644
1 + <?php
2 +
3 + namespace App\Http\Controllers\Admin;
4 +
5 + use App\Http\Controllers\Controller;
6 + use App\Invoice;
7 + use App\InvoicePaid;
8 + use App\Service;
9 + use Illuminate\Http\Request;
10 +
11 + class PaymentController extends Controller
12 +{
13 + public function index()
14 + {
15 + $invoicesPaid = InvoicePaid::getMostRecent(\State::get('branch.id'));
16 +
17 + $invoicesIds = $invoicesPaid->map(fn($ip) => $ip->field('idInvoice'))->toArray();
18 + $invoices = Invoice::whereIdIn($invoicesIds);
19 +
20 + $servicesIds = $invoicesPaid->map(fn($ip) => $ip->field('idService'))->toArray();
21 + $services = Service::whereIdIn($servicesIds);
22 +
23 + return view('admin.payments.index', compact('invoicesPaid', 'invoices', 'services'));
24 + }
25 +
26 + public function updateInfo(Request $request)
27 + {
28 + $request->validate([
29 + 'ref1' => 'required',
30 + 'ref2' => 'required',
31 + 'ref3' => 'required'
32 + ]);
33 +
34 +
35 + }
36 +}
app/Http/Controllers/Portal/PaymentController.php
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Portal;
5 5 use App\Company;
6 6 use App\Http\Controllers\Controller;
7 7 use App\Invoice;
8 + use App\InvoicePaid;
8 9 use App\Service;
9 10 use Illuminate\Http\Request;
10 11
... ... @@ -13,10 +14,12 @@ class PaymentController extends Controller
13 14 public function index()
14 15 {
15 16 $invoices = Invoice::whereGetInstances([
16 - ['state', '=', \InvoiceState::ACTIVO],
17 + ['state', 'in', [\InvoiceState::ACTIVO, \InvoiceState::PAGADO]],
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 1/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 2/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
95 + $description = $request->get('extra1');
96 +
97 + return view('portal.payments.payment-response', compact(
98 + 'transactionStatus',
99 + 'statusMessage',
100 + 'invoice',
101 + 'description'
102 + ));
103 + }
104 +
105 + public function paymentConfirmation(Request $request) {
106 + // \Log::info($request->all());
107 + $invoiceId = explode('-', $request->get('reference_sale'))[2];
108 + $invoice = Invoice::findOrFail($invoiceId);
109 +
110 + if($request->get('state_pol') == '4') { // APPROVED
111 + $invoice->updateInstance([
112 + ['path' => 'state', 'value' => \InvoiceState::PAGADO]
113 + ]);
114 +
115 + InvoicePaid::create([
116 + 'createAt' => date_create(),
117 + 'creteBy' => null,
118 + 'idBranch' => $invoice->field('idBranch'),
119 + 'idClient' => $invoice->field('idClient'),
120 + 'idCompany' => $invoice->field('idCompany'),
121 + 'idInvoice' => $invoice->id(),
122 + 'idService' => $invoice->field('idService'),
123 + 'numConfirmation' => $request->get('reference_pol'),
124 + 'state' => \InvoiceState::ACTIVO,
125 + 'valor' => $invoice->field('valor')
126 + ]);
127 + }
128 +
129 + // \Log::info($invoice->toArray());
130 + }
32 131 }
app/Http/Middleware/VerifyCsrfToken.php
app/Invoice.php
... ... @@ -7,4 +7,19 @@ use App\Support\LarafireModel;
7 7 class Invoice extends LarafireModel
8 8 {
9 9 protected $collectionName = 'invoices';
10 +
11 + public function service()
12 + {
13 + return Service::findOrFail($this->field('idService'));
14 + }
15 +
16 + public function company()
17 + {
18 + return Company::findOrFail($this->field('idCompany'));
19 + }
20 +
21 + public function details()
22 + {
23 + return InvoiceDetail::whereGetInstances('idInvoice', '=', $this->id());
24 + }
10 25 }
app/InvoicePaid.php 0 → 100644
1 + <?php
2 +
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 3/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
3 + namespace App;
4 +
5 + use App\Support\LarafireModel;
6 +
7 + class InvoicePaid extends LarafireModel
8 +{
9 + protected $collectionName = 'invoicesPaids';
10 +
11 + public static function getMostRecent($branchId)
12 + {
13 + $invoices = InvoicePaid::where('idBranch', '=', $branchId)
14 + ->orderBy('createAt', 'DESC')
15 + ->limit(10)
16 + ->documents()
17 + ->rows();
18 +
19 + return InvoicePaid::rowsToInstances($invoices);
20 + }
21 +}
app/PaymentServiceInfo.php 0 → 100644
1 + <?php
2 +
3 + namespace App;
4 +
5 + use App\Support\LarafireModel;
6 +
7 + class PaymentServiceInfo extends LarafireModel
8 +{
9 + protected $collectionName = 'invoicesDetails';
10 +}
app/Support/Globals.php
... ... @@ -34,6 +34,7 @@ abstract class Roles
34 34 abstract class InvoiceState
35 35 {
36 36 const ACTIVO = 'Activo';
37 + const PENDIENTE = 'Pendiente';
37 38 const PAGADO = 'Pagado';
38 39 const INACTIVO = 'Inactivo';
39 40 }
... ...
config/services.php
notas.txt
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 4/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
15 16 fix
17 + . usuario final no puede agendar para mañana si lo hace tarde en la noche
16 18
17 19 largo
18 20 . que cuando recupere un turno pendiente en estado 'atendiendo' en pantalla turno, muestre el tiempo
transcurrido desde que empezo el turno en el timer
... ...
resources/views/admin/dashboard.blade.php
... ... @@ -38,6 +38,9 @@
38 38 <i class="fa fa-file-invoice-dollar text-info"></i>
39 39 Administrar Facturas
40 40 </a>
41 + <a class="btn btn-outline-primary btn-xl mb-3" href="{{ route('admin.payments.index') }}">
42 + <i class="fa fa-money-bill-alt text-danger"></i> Configurar Recaudo En línea
43 + </a>
41 44 @endadmin
42 45 </div>
43 46
... ...
resources/views/admin/payments/index.blade.php 0 → 100644
1 + @extends('layouts.app', ['title' => 'Configurar Recaudos en Línea'])
2 + @section('content')
3 + <div class="container">
4 +
5 + <h2>Recaudos en línea mas recientes</h2>
6 + <div class="w-100 mt-3 mb-5" style="overflow-x: scroll">
7 + <table class="table">
8 + <thead>
9 + <th class="text-center">#Factura</th>
10 + <th>Trámite</th>
11 + <th>Periodo</th>
12 + <th class="text-center">Valor</th>
13 + <th class="text-center">Estado</th>
14 + </thead>
15 + <tbody>
16 + @forelse($invoicesPaid as $invoice)
17 + <tr>
18 + <td class="text-center">
19 + {{$invoice->foreign($invoices, 'idInvoice')->field('companyIdInvoice')}}
20 + </td>
21 + <td>{{$invoice->foreign($services, 'idService')->field('name')}}</td>
22 + <td>
23 + {{$invoice->foreign($invoices, 'idInvoice')->field('month')}} /
24 + {{$invoice->foreign($invoices, 'idInvoice')->field('year')}}
25 + </td>
26 + <td class="text-right">
27 + @money($invoice->foreign($invoices, 'idInvoice')->field('valor'))
28 + </td>
29 + <td class="text-center">
30 + <span class="badge badge-success">
31 + {{$invoice->foreign($invoices, 'idInvoice')->field('state')}}
32 + </span>
33 + </td>
34 + </tr>
35 + @empty
36 + <tr>
37 + <td colspan="4">No hay facturas pagadas que mostrar</td>
38 + </tr>
39 + @endforelse
40 + </tbody>
41 + </table>
42 + </div>
43 +
44 +
45 + <h3 class="mb-0">Datos de la pasarela de pago PayULatam</h3>
46 + <p class="mb-1">
47 + Estos datos son los que usará la app para registrar los recaudos a nombre de esta sucursal.
48 + Busque esta información en las configuraciones de su cuenta PayULatam
49 + </p>
50 + <form class="form-inline" action="{{route('admin.payments.info')}}" method="post">
51 + @csrf
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 5/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
resources/views/layouts/navbars/navs/auth.blade.php
... ... @@ -38,10 +38,10 @@
38 38 <div class=" dropdown-header noti-title">
39 39 <h6 class="text-overflow m-0">Bienvenido/a</h6>
40 40 </div>
41 - <a href="{{ route('profile.edit') }}" class="dropdown-item">
42 - <i class="ni ni-single-02"></i>
43 - <span>Mi perfil</span>
44 - </a>
41 + {{-- <a href="{{ route('profile.edit') }}" class="dropdown-item"> --}}
42 + {{-- <i class="ni ni-single-02"></i> --}}
43 + {{-- <span>Mi perfil</span> --}}
44 + {{-- </a> --}}
45 45 <div class="dropdown-divider"></div>
46 46 <a href="{{ route('logout') }}" class="dropdown-item" onclick="event.preventDefault();
47 47 document.getElementById('logout-form').submit();">
... ...
resources/views/layouts/navbars/sidebar.blade.php
... ... @@ -29,10 +29,10 @@
29 29 <div class=" dropdown-header noti-title">
30 30 <h6 class="text-overflow m-0">Bienvenido/a!</h6>
31 31 </div>
32 - <a href="{{ route('profile.edit') }}" class="dropdown-item">
33 - <i class="ni ni-single-02"></i>
34 - <span>Mi perfil</span>
35 - </a>
32 + {{-- <a href="{{ route('profile.edit') }}" class="dropdown-item"> --}}
33 + {{-- <i class="ni ni-single-02"></i> --}}
34 + {{-- <span>Mi perfil</span> --}}
35 + {{-- </a> --}}
36 36 <!-- <a href="#" class="dropdown-item"> -->
37 37 <!-- <i class="ni ni-settings-gear-65"></i> -->
38 38 <!-- <span>Opciones</span> -->
... ... @@ -154,6 +154,11 @@
154 154 <i class="fa fa-file-invoice-dollar text-info"></i>Facturas
155 155 </a>
156 156 </li>
157 + <li class="nav-item">
158 + <a class="nav-link" href="{{ route('admin.payments.index') }}">
159 + <i class="fa fa-money-bill-alt text-danger"></i>Recaudo En línea
160 + </a>
161 + </li>
157 162 @endadmin
158 163 @endif
159 164
... ...
resources/views/portal/payments/index.blade.php
... ... @@ -19,7 +19,7 @@
19 19 <th class="text-center">Acciones</th>
20 20 </thead>
21 21 <tbody>
22 - @forelse($invoices as $invoice)
22 + @forelse($invoices->filter(fn($i) => $i->field('state') == \InvoiceState::ACTIVO) as
$invoice)
23 23 <tr>
24 24 <td>{{$invoice->foreign($services, 'idService')->field('name')}}</td>
25 25 <td>{{$invoice->field('companyIdInvoice')}}</td>
... ... @@ -33,24 +33,24 @@
33 33 title="Ver detalles de factura"
34 34 @click.prevent="details('{{$invoice->id()}}',
35 35 '{{$invoice->field('companyIdInvoice')}}',
36 - '{{$invoice->field('valor')}}')">
36 + '{{$invoice->field('valor')}}',
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 6/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
37 + '{{$invoice->field('state')}}')">
37 38 <i class="fa fa-file-invoice"></i> Detalles
38 39 </a>
39 40
40 41 <a href="#"
41 42 class="btn btn-primary btn-sm"
42 - title="Pagar Factura"
43 - @click.prevent="pay('{{$invoice->id()}}')">
43 + @click.prevent="pay('{{$invoice->id()}}')"
44 + title="Pagar Factura">
44 45 <i class="fa fa-credit-card"></i> Pagar
45 46 </a>
46 47
47 - {{-- <form action="#" --}}
48 - {{-- method="post" --}}
49 - {{-- class="d-none" --}}
50 - {{-- id="cancel-form-{{$queue->id()}}"> --}}
51 - {{-- @csrf --}}
52 - {{-- @method('put') --}}
53 - {{-- </form> --}}
48 + <form action="{{route('portal.payments.pay', $invoice->id())}}"
49 + method="post"
50 + class="d-none"
51 + id="pay-form-{{$invoice->id()}}">
52 + @csrf
53 + </form>
54 54 </td>
55 55 </tr>
56 56 @empty
... ... @@ -62,6 +62,51 @@
62 62 </table>
63 63 </div>
64 64
65 + @php $invoicesPaid = $invoices->filter(fn($i) => $i->field('state') == \InvoiceState::PAGADO);
@endphp
66 + @if(count($invoicesPaid) > 0)
67 + <h2 class="mt-5">Facturas pagadas</h2>
68 +
69 + <div class="w-100" style="overflow-x: scroll">
70 + <table class="table table-hover">
71 + <thead>
72 + <th>Trámite</th>
73 + <th>#Factura</th>
74 + <th>Nombre</th>
75 + <th>Periodo</th>
76 + <th class="text-center">Valor</th>
77 + <th>Entidad</th>
78 + <th class="text-center">Acciones</th>
79 + </thead>
80 + <tbody>
81 + @forelse($invoicesPaid as $invoice)
82 + <tr>
83 + <td>{{$invoice->foreign($services, 'idService')->field('name')}}</td>
84 + <td>{{$invoice->field('companyIdInvoice')}}</td>
85 + <td>{{$invoice->field('companyName')}}</td>
86 + <td>{{$invoice->field('month')}}/{{$invoice->field('year')}}</td>
87 + <td class="text-right">@money($invoice->field('valor'))</td>
88 + <td>{{$invoice->foreign($companies, 'idCompany')->field('name')}}</td>
89 + <td class="text-center">
90 + <a href="#"
91 + class="btn btn-sm"
92 + title="Ver detalles de factura"
93 + @click.prevent="details('{{$invoice->id()}}',
94 + '{{$invoice->field('companyIdInvoice')}}',
95 + '{{$invoice->field('valor')}}',
96 + '{{$invoice->field('state')}}')">
97 + <i class="fa fa-file-invoice"></i> Detalles
98 + </a>
99 + </td>
100 + </tr>
101 + @empty
102 + <tr>
103 + <td colspan="4">No hay facturas pagadas en el momento</td>
104 + </tr>
105 + @endforelse
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 7/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
106 + </tbody>
107 + </table>
108 + </div>
109 + @endif
65 110 <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-
labelledby="detailsModalLabel" aria-hidden="true">
66 111 <div class="modal-dialog" role="document">
67 112 <div class="modal-content">
... ... @@ -95,9 +140,13 @@
95 140 </div>
96 141 <div class="modal-footer">
97 142 <button type="button" class="btn btn-secondary" data-
dismiss="modal">Cerrar</button>
98 - <button type="button" class="btn btn-primary">
143 + <a href="#"
144 + type="button"
145 + class="btn btn-primary"
146 + v-show="state != 'Pagado'"
147 + @click.prevent="pay(invoiceId)">
99 148 <i class="fa fa-credit-card"></i> Pagar
100 - </button>
149 + </a>
101 150 </div>
102 151 </div>
103 152 </div>
... ... @@ -112,28 +161,33 @@
112 161 el: '#payments',
113 162 data() {
114 163 return {
164 + invoiceId: null,
115 165 invoiceNumber: null,
116 166 value: null,
167 + state: null,
117 168 concepts: [],
118 169 }
119 170 },
120 171 methods: {
121 - pay(invoiceId) {
122 - console.log('paying')
123 - },
124 - details(invoiceId, invoiceNumber, value) {
172 + details(invoiceId, invoiceNumber, value, state) {
173 + console.log(state)
125 174 Progress.start()
126 175 axios.get('/api/invoice-details/by-invoice-id/'+invoiceId)
127 176 .then(res => {
128 177 if (res.data.status == 'success') {
178 + this.invoiceId = invoiceId
129 179 this.invoiceNumber = invoiceNumber
130 180 this.value = value
181 + this.state = state
131 182 this.concepts = res.data.data.concepts
132 183 $('#detailsModal').modal('show')
133 184 }
134 185 }).catch(err => {
135 186 console.log(err)
136 187 }).then(() => Progress.done())
188 + },
189 + pay(invoiceId) {
190 + $('#pay-form-'+invoiceId).submit()
137 191 }
138 192 },
139 193 filters: {
... ...
resources/views/portal/payments/payment-redirect.blade.php 0 → 100644
1 + <html>
2 + <body>
3 + <!-- <form method="post" action="https://checkout.payulatam.com/ppp-web-gateway-payu/"
id="checkout-form"> -->
4 + <form method="post" action="https://sandbox.checkout.payulatam.com/ppp-web-gateway-payu/">
5 + @foreach($data as $name => $value)
6 + <input type="hidden" name="{{$name}}" value="{{$value}}">
7 + @endforeach
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 8/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
8 + </form>
9 + <script>
10 + document.querySelector('form').submit()
11 + </script>
12 + </body>
13 + </html>
resources/views/portal/payments/payment-response.blade.php 0 → 100644
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 9/10
1/8/2020 Usuario final puede pagar con PayU (ddddde31) · Commits · Guillermo Agudelo / transito-frontend · GitLab
67 +
68 + <div class="d-flex justify-content-center">
69 + <a class="mt-3 btn btn-outline-primary" href="{{route('portal.payments.index')}}">
70 + Volver a lista de facturas
71 + </a>
72 + </div>
73 +
74 + </div>
75 + @endsection
routes/web.php
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/ddddde3195ed51b059f7e4c36dfef230b82f0303 10/10