Initial commit: Horux Backend API
- API REST para gestion de facturas electronicas mexicanas (CFDI) - Laravel 9 con autenticacion OAuth 2.0 (Passport) - Integracion con Syntage, Clerk y Facturama - 30 modelos Eloquent, 39 controladores - Documentacion completa en /docs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
85
app/Http/Controllers/CancellationTypeController.php
Normal file
85
app/Http/Controllers/CancellationTypeController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\CancellationType;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CancellationTypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\CancellationType $cancellationType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(CancellationType $cancellationType)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\CancellationType $cancellationType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(CancellationType $cancellationType)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\CancellationType $cancellationType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, CancellationType $cancellationType)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\CancellationType $cancellationType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(CancellationType $cancellationType)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/ConciliationController.php
Normal file
85
app/Http/Controllers/ConciliationController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Conciliation;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ConciliationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Conciliation $conciliation
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Conciliation $conciliation)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Conciliation $conciliation
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Conciliation $conciliation)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Conciliation $conciliation
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Conciliation $conciliation)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Conciliation $conciliation
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Conciliation $conciliation)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
88
app/Http/Controllers/CurrencyController.php
Normal file
88
app/Http/Controllers/CurrencyController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Currency;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CurrencyController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Currency $currency
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(Currency $currency)
|
||||
{
|
||||
//
|
||||
$currencies = Currency::all();
|
||||
|
||||
return($currencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Currency $currency
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Currency $currency)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Currency $currency
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Currency $currency)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Currency $currency
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Currency $currency)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/DimensionController.php
Normal file
85
app/Http/Controllers/DimensionController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Dimension;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DimensionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Dimension $dimension
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Dimension $dimension)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Dimension $dimension
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Dimension $dimension)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Dimension $dimension
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Dimension $dimension)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Dimension $dimension
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Dimension $dimension)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/EconomicActivityController.php
Normal file
85
app/Http/Controllers/EconomicActivityController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\EconomicActivity;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EconomicActivityController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\EconomicActivity $economicActivity
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(EconomicActivity $economicActivity)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\EconomicActivity $economicActivity
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(EconomicActivity $economicActivity)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\EconomicActivity $economicActivity
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, EconomicActivity $economicActivity)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\EconomicActivity $economicActivity
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(EconomicActivity $economicActivity)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/ExpenditureController.php
Normal file
85
app/Http/Controllers/ExpenditureController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Expenditure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ExpenditureController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Expenditure $expenditure
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Expenditure $expenditure)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Expenditure $expenditure
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Expenditure $expenditure)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Expenditure $expenditure
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Expenditure $expenditure)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Expenditure $expenditure
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Expenditure $expenditure)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/IndustryController.php
Normal file
85
app/Http/Controllers/IndustryController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Industry;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IndustryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Industry $industry
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Industry $industry)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Industry $industry
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Industry $industry)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Industry $industry
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Industry $industry)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Industry $industry
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Industry $industry)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
1811
app/Http/Controllers/InvoiceController.php
Normal file
1811
app/Http/Controllers/InvoiceController.php
Normal file
File diff suppressed because it is too large
Load Diff
287
app/Http/Controllers/InvoiceLineController.php
Normal file
287
app/Http/Controllers/InvoiceLineController.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\InvoiceLine;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceRequest;
|
||||
use App\Models\User;
|
||||
use App\Models\Rfc;
|
||||
use App\Models\InvoiceType;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\Status;
|
||||
use Carbon\Carbon;
|
||||
use App\Imports\LineItemsImport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
|
||||
class InvoiceLineController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function obtenerLineasFacturas(Request $request)
|
||||
{
|
||||
$start = microtime(true);
|
||||
set_time_limit(1800);
|
||||
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
$now = Carbon::now();
|
||||
$invoice_request = InvoiceRequest::where('rfc_id', $rfc->id)->where('type', 'line')->first();
|
||||
if ($invoice_request) {
|
||||
$last_request = new Carbon($invoice_request->requested_at);
|
||||
$min_days = ($last_request->diff($now)->days > 1) ? true : null;
|
||||
} else {
|
||||
$min_days = true;
|
||||
$invoice_request = new InvoiceRequest();
|
||||
}
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray()) && $min_days == true) {
|
||||
$dataCounter = 1;
|
||||
$arrayCount = 999;
|
||||
$header_id = null;
|
||||
do {
|
||||
try {
|
||||
if (isset($header_id) && $dataCounter >= $arrayCount) {
|
||||
$dataCounter = 1;
|
||||
// Realizar una petición GET con encabezados
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/ld+json',
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/taxpayers/'. $request->rfc .'/invoices/line-items?id[lt]='. $header_id .'&itemsPerPage=1000');
|
||||
} else {
|
||||
// Realizar una petición GET con encabezados
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/ld+json',
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/taxpayers/'. $request->rfc .'/invoices/line-items?itemsPerPage=1000');
|
||||
}
|
||||
|
||||
// Verificar si la petición fue exitosa
|
||||
if ($response->successful()) {
|
||||
// Manejar la respuesta exitosa
|
||||
$data = $response->json();
|
||||
$invoiceLines = $data['hydra:member'];
|
||||
$arrayCount = count($invoiceLines);
|
||||
|
||||
foreach ($invoiceLines as $invoiceLine_data) {
|
||||
// code...
|
||||
$invoiceLine = $this->setInvoiceLine($invoiceLine_data, $rfc);
|
||||
$dataCounter++;
|
||||
if ($dataCounter == 999) {
|
||||
$header_id = $invoiceLine_data['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$time = microtime(true) - $start;
|
||||
} else {
|
||||
// Manejar la respuesta fallida
|
||||
return response()->json(['error' => 'Error al obtener los datos'], $response->status());
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
// Manejar excepciones específicas de solicitudes HTTP
|
||||
return response()->json(['error' => 'Excepción al obtener los datos: ' . $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
} while ($arrayCount >= 999);
|
||||
|
||||
$invoice_request->rfc_id = $rfc->id;
|
||||
$invoice_request->type = 'line';
|
||||
$invoice_request->requested_at = Carbon::now();
|
||||
$invoice_request->save();
|
||||
|
||||
return response()->json(['success' => 'Datos almacenados con exito', 'time' => $time]);
|
||||
} else {
|
||||
$time = microtime(true) - $start;
|
||||
return response()->json(['success' => 'Datos almacenados con exito', 'time' => $time]);
|
||||
}
|
||||
}
|
||||
|
||||
public function importarLineasFacturas(Request $request) {
|
||||
// Validar que se ha subido un archivo y que es un Excel
|
||||
$request->validate([
|
||||
'file' => 'required|mimes:xlsx,xls,csv|max:20480', // Limitar el tamaño del archivo a 10MB
|
||||
'rfc' => 'required|string', // Validación para el parámetro adicional
|
||||
]);
|
||||
|
||||
$rfc = $request->rfc;
|
||||
|
||||
set_time_limit(1000);
|
||||
//ini_set('memory_limit', '-1');
|
||||
|
||||
try {
|
||||
// Procesar el archivo usando la clase de importación
|
||||
Excel::import(new LineItemsImport($rfc), $request->file('file'));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Excel importado correctamente'
|
||||
], 200);
|
||||
} catch (\Exception $e) {
|
||||
// Manejar errores durante la importación
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Error al importar el archivo: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function obtenerFacturasConceptos(Request $request) {
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray())) {
|
||||
return response()->json(Invoice::where('rfc_id', $rfc->id)->with('invoiceLines')->get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceLine $invoiceLine
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(InvoiceLine $invoiceLine)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceLine $invoiceLine
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(InvoiceLine $invoiceLine)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\InvoiceLine $invoiceLine
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, InvoiceLine $invoiceLine)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\InvoiceLine $invoiceLine
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(InvoiceLine $invoiceLine)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function setInvoiceLine($invoiceLine_data, $rfc)
|
||||
{
|
||||
//
|
||||
$invoiceLine = InvoiceLine::firstOrNew(['id' => $invoiceLine_data['id']]);
|
||||
|
||||
$invoiceLine->rfc_id = $rfc->id;
|
||||
$invoice = Invoice::where('id', $invoiceLine_data['invoice']['uuid'])->first();
|
||||
if($invoice) {
|
||||
$invoiceLine->invoice_id = $invoiceLine_data['invoice']['uuid'];
|
||||
} else {
|
||||
$invoiceLine->invoice_id = null;
|
||||
}
|
||||
$type = InvoiceType::where('id', $invoiceLine_data['invoice']['type'])->first();
|
||||
if (!$type) {
|
||||
$type = new InvoiceType();
|
||||
$type->id = $invoiceLine_data['invoice']['type'];
|
||||
$type->save();
|
||||
}
|
||||
$invoiceLine->invoice_type_id = $invoiceLine_data['invoice']['type'];
|
||||
if ($invoiceLine_data['invoice']['paymentType']) {
|
||||
$payment_method = PaymentType::where('id', strip_tags($invoiceLine_data['invoice']['paymentType']))->first();
|
||||
if (!$payment_method) {
|
||||
$payment_method = new PaymentType();
|
||||
$payment_method->id = $invoiceLine_data['invoice']['paymentType'];
|
||||
$payment_method->save();
|
||||
}
|
||||
}
|
||||
$invoiceLine->payment_type_id = $invoiceLine_data['invoice']['paymentType'];
|
||||
if ($invoiceLine_data['invoice']['status']) {
|
||||
$status = Status::where('description', strip_tags($invoiceLine_data['invoice']['status']))->first();
|
||||
if (!$status) {
|
||||
$status = new Status();
|
||||
$status->description = $invoiceLine_data['invoice']['status'];
|
||||
$status->save();
|
||||
}
|
||||
}
|
||||
$invoiceLine->status_id = $status->id;
|
||||
$rfc = Rfc::where('rfc', strip_tags($invoiceLine_data['invoice']['issuer']['rfc']))->first();
|
||||
if (!$rfc) {
|
||||
$rfc = new Rfc();
|
||||
$rfc->rfc = $invoiceLine_data['invoice']['issuer']['rfc'];
|
||||
$rfc->save();
|
||||
}
|
||||
$invoiceLine->issuer_rfc_id = $rfc->id;
|
||||
$invoiceLine->issuer_name = $invoiceLine_data['invoice']['issuer']['name'];
|
||||
$rfc = Rfc::where('rfc', strip_tags($invoiceLine_data['invoice']['receiver']['rfc']))->first();
|
||||
if (!$rfc) {
|
||||
$rfc = new Rfc();
|
||||
$rfc->rfc = $invoiceLine_data['invoice']['receiver']['rfc'];
|
||||
$rfc->save();
|
||||
}
|
||||
$invoiceLine->receiver_rfc_id = $rfc->id;
|
||||
$invoiceLine->receiver_name = $invoiceLine_data['invoice']['receiver']['name'];
|
||||
$invoiceLine->issued_at = Carbon::createFromFormat('Y-m-d H:i:s', $invoiceLine_data['invoice']['issuedAt']);
|
||||
$invoiceLine->identification_number = $invoiceLine_data['identificationNumber'];
|
||||
$invoiceLine->product_identification = $invoiceLine_data['productIdentification'];
|
||||
$invoiceLine->description = $invoiceLine_data['description'];
|
||||
$invoiceLine->description = $invoiceLine_data['description'];
|
||||
$invoiceLine->unit_amount = $invoiceLine_data['unitAmount'];
|
||||
$invoiceLine->unit_code = $invoiceLine_data['unitCode'];
|
||||
$invoiceLine->quantity = $invoiceLine_data['quantity'];
|
||||
$invoiceLine->discount_amount = $invoiceLine_data['discountAmount'];
|
||||
$invoiceLine->total_amount = $invoiceLine_data['totalAmount'];
|
||||
$invoiceLine->retained_vat = $invoiceLine_data['retainedTaxes']['valueAddedTax'];
|
||||
$invoiceLine->retained_income_tax = $invoiceLine_data['retainedTaxes']['incomeTax'];
|
||||
$invoiceLine->retained_sin_tax = $invoiceLine_data['retainedTaxes']['sinTax'];
|
||||
$invoiceLine->transferred_vat = $invoiceLine_data['transferredTaxes']['valueAddedTax'];
|
||||
$invoiceLine->transferred_sin_tax = $invoiceLine_data['transferredTaxes']['sinTax'];
|
||||
$invoiceLine->save();
|
||||
return $invoiceLine;
|
||||
}
|
||||
}
|
||||
460
app/Http/Controllers/InvoicePaymentController.php
Normal file
460
app/Http/Controllers/InvoicePaymentController.php
Normal file
@@ -0,0 +1,460 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\InvoicePayment;
|
||||
use App\Models\User;
|
||||
use App\Models\Rfc;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceRequest;
|
||||
use App\Models\InvoiceType;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\Currency;
|
||||
use App\Models\Usage;
|
||||
use App\Models\CancellationType;
|
||||
use App\Models\Taxpayer;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
|
||||
class InvoicePaymentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function obtenerComplementosPago(Request $request)
|
||||
{
|
||||
$start = microtime(true);
|
||||
set_time_limit(900);
|
||||
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
$now = Carbon::now();
|
||||
$invoice_request = InvoiceRequest::where('rfc_id', $rfc->id)->where('type', 'payment')->first();
|
||||
if ($invoice_request) {
|
||||
$last_request = new Carbon($invoice_request->requested_at);
|
||||
$min_days = ($last_request->diff($now)->days > 1) ? true : null;
|
||||
} else {
|
||||
$first_time = true;
|
||||
$min_days = true;
|
||||
$invoice_request = new InvoiceRequest();
|
||||
}
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray()) && $min_days == true) {
|
||||
$dataCounter = 1;
|
||||
$arrayCount = 999;
|
||||
$header_id = null;
|
||||
do {
|
||||
try {
|
||||
if (isset($header_id) && $dataCounter >= $arrayCount) {
|
||||
$dataCounter = 1;
|
||||
// Realizar una petición GET con encabezados
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/ld+json',
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/taxpayers/'. $request->rfc .'/invoices/payments?id[lt]='. $header_id .'&itemsPerPage=1000');
|
||||
} else {
|
||||
// Realizar una petición GET con encabezados
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/ld+json',
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/taxpayers/'. $request->rfc .'/invoices/payments?itemsPerPage=1000');
|
||||
}
|
||||
|
||||
// Verificar si la petición fue exitosa
|
||||
if ($response->successful()) {
|
||||
// Manejar la respuesta exitosa
|
||||
$data = $response->json();
|
||||
$invoicePayments = $data['hydra:member'];
|
||||
$arrayCount = count($invoicePayments);
|
||||
|
||||
foreach ($invoicePayments as $invoicePayment_data) {
|
||||
// code...
|
||||
$invoicePayment = $this->setInvoicePayment($invoicePayment_data, $rfc);
|
||||
$dataCounter++;
|
||||
if ($dataCounter == 999) {
|
||||
$header_id = $invoicePayment_data['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$time = microtime(true) - $start;
|
||||
} else {
|
||||
// Manejar la respuesta fallida
|
||||
return response()->json(['error' => 'Error al obtener los datos'], $response->status());
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
// Manejar excepciones específicas de solicitudes HTTP
|
||||
return response()->json(['error' => 'Excepción al obtener los datos: ' . $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
|
||||
} while ($arrayCount >= 999);
|
||||
|
||||
$invoice_request->rfc_id = $rfc->id;
|
||||
$invoice_request->type = 'payment';
|
||||
$invoice_request->requested_at = Carbon::now();
|
||||
$invoice_request->save();
|
||||
|
||||
return response()->json(['success' => 'Datos almacenados con exito', 'time' => $time]);
|
||||
} else {
|
||||
$time = microtime(true) - $start;
|
||||
return response()->json(['success' => 'Datos almacenados con exito', 'time' => $time]);
|
||||
}
|
||||
}
|
||||
|
||||
public function ingresoPpd(Request $request) {
|
||||
$start = microtime(true);
|
||||
set_time_limit(1000);
|
||||
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
$dateCST = Carbon::createFromFormat('Y-m-d H:i:s', $request->date, 'CST');
|
||||
|
||||
// Definir inicio y fin en CST (Central Standard Time)
|
||||
$startDateCST = $dateCST->copy()->firstOfMonth();
|
||||
$endDateCST = $dateCST->copy()->endOfMonth();
|
||||
// Convertir las fechas a UTC
|
||||
$startDateUTC = $startDateCST->copy()->setTimezone('UTC');
|
||||
$endDateUTC = $endDateCST->copy()->setTimezone('UTC');
|
||||
|
||||
$taxpayer = Taxpayer::where('rfc_id', $rfc->id)->first();
|
||||
|
||||
$naturalPerson = ['612', '621', '626'];
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray())) {
|
||||
if(count(array_intersect($naturalPerson, $taxpayer->taxRegimes->pluck('id')->toArray())) > 0) {
|
||||
if ($request->conciliated) {
|
||||
$invoicePayments = InvoicePayment::where('rfc_id', $rfc->id)
|
||||
->whereNull('cancelled_at')
|
||||
->whereHas('invoice', function($query) use ($rfc, $startDateUTC, $endDateUTC) {
|
||||
$query->where('issuer_rfc_id', $rfc->id)
|
||||
//Para Gasto PPD es cuando es receptor
|
||||
//->where('receiver_rfc_id', $rfc->id);
|
||||
->whereIn('cancellation_status_id', ['1', '6', '7'])
|
||||
->whereHas('conciliations', function($query) use ($rfc, $startDateUTC, $endDateUTC) {
|
||||
$query->where('rfc_id', $rfc->id);
|
||||
$query->where('is_conciliated', true);
|
||||
$query->whereBetween('conciliated_at', [$startDateUTC, $endDateUTC]);
|
||||
});
|
||||
})
|
||||
->get();
|
||||
} else {
|
||||
$invoicePayments = InvoicePayment::where('rfc_id', $rfc->id)
|
||||
->whereNull('cancelled_at')
|
||||
->whereBetween('date', [$startDateUTC, $endDateUTC])
|
||||
->whereHas('invoice', function($query) use ($rfc) {
|
||||
$query->where('issuer_rfc_id', $rfc->id)
|
||||
//Para Gasto PPD es cuando es receptor
|
||||
//->where('receiver_rfc_id', $rfc->id);
|
||||
->whereIn('cancellation_status_id', ['1', '6', '7']);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
} else {
|
||||
return response()->json([
|
||||
'total' => 0,
|
||||
'amount' => 0,
|
||||
'transferred_vat' => 0,
|
||||
'transferred_vat_ppd' => 0,
|
||||
'retained_vat' => 0,
|
||||
'retained_vat_ppd' => 0,
|
||||
'no_natural' => 'No es persona fisica'
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'total' => round($invoicePayments->sum('total_in_mxn'), 2),
|
||||
'transferred_vat' => round($invoicePayments->sum('transferred_vat_in_mxn'), 2),
|
||||
'retained_vat' => round($invoicePayments->sum('retained_vat_in_mxn'), 2),
|
||||
'amount' => round($invoicePayments->sum('amount_in_mxn'), 2),
|
||||
'transferred_vat_ppd' => round($invoicePayments->sum('transferred_vat_ppd'), 2),
|
||||
'retained_vat_ppd' => round($invoicePayments->sum('retained_vat_ppd'), 2),
|
||||
'invoicesPpd' => $invoicePayments
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function gastoPpd(Request $request) {
|
||||
$start = microtime(true);
|
||||
set_time_limit(1000);
|
||||
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
$dateCST = Carbon::createFromFormat('Y-m-d H:i:s', $request->date, 'CST');
|
||||
|
||||
// Definir inicio y fin en CST (Central Standard Time)
|
||||
$startDateCST = $dateCST->copy()->firstOfMonth();
|
||||
$endDateCST = $dateCST->copy()->endOfMonth();
|
||||
// Convertir las fechas a UTC
|
||||
$startDateUTC = $startDateCST->copy()->setTimezone('UTC');
|
||||
$endDateUTC = $endDateCST->copy()->setTimezone('UTC');
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray())) {
|
||||
if ($request->conciliated) {
|
||||
$invoicePayments = InvoicePayment::where('rfc_id', $rfc->id)
|
||||
->whereHas('invoice', function($query) use ($rfc, $startDateUTC, $endDateUTC) {
|
||||
$query->where('receiver_rfc_id', $rfc->id)
|
||||
->whereIn('cancellation_status_id', ['1', '6', '7'])
|
||||
->whereHas('conciliations', function($query) use ($rfc, $startDateUTC, $endDateUTC) {
|
||||
$query->where('rfc_id', $rfc->id);
|
||||
$query->where('is_conciliated', true);
|
||||
$query->whereBetween('conciliated_at', [$startDateUTC, $endDateUTC]);
|
||||
});
|
||||
})
|
||||
->get();
|
||||
} else {
|
||||
$invoicePayments = InvoicePayment::where('rfc_id', $rfc->id)
|
||||
->whereBetween('date', [$startDateUTC, $endDateUTC])
|
||||
->whereHas('invoice', function($query) use ($rfc) {
|
||||
$query->where('receiver_rfc_id', $rfc->id)
|
||||
->whereIn('cancellation_status_id', ['1', '6', '7']);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'total' => round($invoicePayments->sum('total_in_mxn'), 2),
|
||||
'transferred_vat' => round($invoicePayments->sum('transferred_vat_in_mxn'), 2),
|
||||
'retained_vat' => round($invoicePayments->sum('retained_vat_in_mxn'), 2),
|
||||
'amount' => round($invoicePayments->sum('amount_in_mxn'), 2),
|
||||
'transferred_vat_ppd' => round($invoicePayments->sum('transferred_vat_ppd'), 2),
|
||||
'retained_vat_ppd' => round($invoicePayments->sum('retained_vat_ppd'), 2),
|
||||
'retained_income_tax' => round($invoicePayments->sum('retained_income_tax_in_mxn'), 2),
|
||||
'invoicesPpd' => $invoicePayments,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function adquisicionPpd(Request $request) {
|
||||
$start = microtime(true);
|
||||
set_time_limit(1000);
|
||||
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
$dateCST = Carbon::createFromFormat('Y-m-d H:i:s', $request->date, 'CST');
|
||||
|
||||
// Definir inicio y fin en CST (Central Standard Time)
|
||||
$startDateCST = $dateCST->copy()->firstOfMonth();
|
||||
$endDateCST = $dateCST->copy()->endOfMonth();
|
||||
// Convertir las fechas a UTC
|
||||
$startDateUTC = $startDateCST->copy()->setTimezone('UTC');
|
||||
$endDateUTC = $endDateCST->copy()->setTimezone('UTC');
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray())) {
|
||||
if ($request->conciliated) {
|
||||
$invoicePayments = InvoicePayment::where('rfc_id', $rfc->id)
|
||||
->whereHas('invoice', function($query) use ($rfc, $startDateUTC, $endDateUTC) {
|
||||
$query->where('receiver_rfc_id', $rfc->id)
|
||||
->whereIn('cancellation_status_id', ['1', '6', '7'])
|
||||
->where('usage_id', 'G01')
|
||||
->whereHas('conciliations', function($query) use ($rfc, $startDateUTC, $endDateUTC) {
|
||||
$query->where('rfc_id', $rfc->id);
|
||||
$query->where('is_conciliated', true);
|
||||
$query->whereBetween('conciliated_at', [$startDateUTC, $endDateUTC]);
|
||||
});
|
||||
})
|
||||
->get();
|
||||
} else {
|
||||
$invoicePayments = InvoicePayment::where('rfc_id', $rfc->id)
|
||||
->whereBetween('date', [$startDateUTC, $endDateUTC])
|
||||
->whereHas('invoice', function($query) use ($rfc) {
|
||||
$query->where('receiver_rfc_id', $rfc->id)
|
||||
->whereIn('cancellation_status_id', ['1', '6', '7'])
|
||||
->where('usage_id', 'G01');
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'total' => round($invoicePayments->sum('total_in_mxn'), 2),
|
||||
'tax' => round($invoicePayments->sum('tax_in_mxn'), 2),
|
||||
'transferred_vat' => round($invoicePayments->sum('transferred_vat_in_mxn'), 2),
|
||||
'retained_vat' => round($invoicePayments->sum('retained_vat_in_mxn'), 2),
|
||||
'amount' => round($invoicePayments->sum('amount_in_mxn'), 2),
|
||||
'vat_ppd' => round($invoicePayments->sum('vat_ppd'), 2),
|
||||
'invoicesPpd' => $invoicePayments
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function ivaIngresoPpd(Request $request) {
|
||||
$start = microtime(true);
|
||||
set_time_limit(1000);
|
||||
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
$dateCST = Carbon::createFromFormat('Y-m-d H:i:s', $request->date, 'CST');
|
||||
|
||||
// Definir inicio y fin en CST (Central Standard Time)
|
||||
$startDateCST = $dateCST->copy()->firstOfMonth();
|
||||
$endDateCST = $dateCST->copy()->endOfMonth();
|
||||
// Convertir las fechas a UTC
|
||||
$startDateUTC = $startDateCST->copy()->setTimezone('UTC');
|
||||
$endDateUTC = $endDateCST->copy()->setTimezone('UTC');
|
||||
|
||||
$taxpayer = Taxpayer::where('rfc_id', $rfc->id)->first();
|
||||
|
||||
$naturalPerson = ['612', '621', '626'];
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray())) {
|
||||
if ($request->conciliated) {
|
||||
$invoicePayments = InvoicePayment::where('rfc_id', $rfc->id)
|
||||
->whereNull('cancelled_at')
|
||||
->whereHas('invoice', function($query) use ($rfc, $startDateUTC, $endDateUTC) {
|
||||
$query->where('issuer_rfc_id', $rfc->id)
|
||||
//Para Gasto PPD es cuando es receptor
|
||||
//->where('receiver_rfc_id', $rfc->id);
|
||||
->whereIn('cancellation_status_id', ['1', '6', '7'])
|
||||
->whereHas('conciliations', function($query) use ($rfc, $startDateUTC, $endDateUTC) {
|
||||
$query->where('rfc_id', $rfc->id);
|
||||
$query->where('is_conciliated', true);
|
||||
$query->whereBetween('conciliated_at', [$startDateUTC, $endDateUTC]);
|
||||
});
|
||||
})
|
||||
->get();
|
||||
} else {
|
||||
$invoicePayments = InvoicePayment::where('rfc_id', $rfc->id)
|
||||
->whereNull('cancelled_at')
|
||||
->whereBetween('date', [$startDateUTC, $endDateUTC])
|
||||
->whereHas('invoice', function($query) use($rfc) {
|
||||
$query->where('issuer_rfc_id', $rfc->id)
|
||||
//Para Gasto PPD es cuando es receptor
|
||||
//->where('receiver_rfc_id', $rfc->id);
|
||||
->whereIn('cancellation_status_id', ['1', '6', '7']);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'total' => round($invoicePayments->sum('total_in_mxn'), 2),
|
||||
'transferred_vat' => round($invoicePayments->sum('transferred_vat_in_mxn'), 2),
|
||||
'retained_vat' => round($invoicePayments->sum('retained_vat_in_mxn'), 2),
|
||||
'amount' => round($invoicePayments->sum('amount_in_mxn'), 2),
|
||||
'transferred_vat_ppd' => round($invoicePayments->sum('transferred_vat_ppd'), 2),
|
||||
'retained_vat_ppd' => round($invoicePayments->sum('retained_vat_ppd'), 2)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoicePayment $invoicePayment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(InvoicePayment $invoicePayment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoicePayment $invoicePayment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(InvoicePayment $invoicePayment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\InvoicePayment $invoicePayment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, InvoicePayment $invoicePayment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\InvoicePayment $invoicePayment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(InvoicePayment $invoicePayment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function setInvoicePayment($invoicePayment_data, $rfc)
|
||||
{
|
||||
//
|
||||
$invoicePayment = InvoicePayment::firstOrNew(['id' => $invoicePayment_data['id']]);
|
||||
|
||||
$invoicePayment->rfc_id = $rfc->id;
|
||||
$invoicePayment->date = $invoicePayment_data['date'];
|
||||
$invoice = Invoice::where('id', $invoicePayment_data['invoiceUuid'])->first();
|
||||
if($invoice) {
|
||||
$invoicePayment->invoice_id = $invoicePayment_data['invoiceUuid'];
|
||||
} else {
|
||||
$invoicePayment->invoice_id = null;
|
||||
}
|
||||
if ($invoicePayment_data['paymentMethod']) {
|
||||
$payment_method = PaymentMethod::where('id', strip_tags($invoicePayment_data['paymentMethod']))->first();
|
||||
if (!$payment_method) {
|
||||
$payment_method = new PaymentMethod();
|
||||
$payment_method->id = $invoicePayment_data['paymentMethod'];
|
||||
$payment_method->save();
|
||||
}
|
||||
}
|
||||
$invoicePayment->payment_method_id = $invoicePayment_data['paymentMethod'];
|
||||
if ($invoicePayment_data['currency']) {
|
||||
$currency = Currency::where('id', strip_tags($invoicePayment_data['currency']))->first();
|
||||
if (!$currency) {
|
||||
$currency = new Currency();
|
||||
$currency->id = $invoicePayment_data['currency'];
|
||||
$currency->save();
|
||||
}
|
||||
}
|
||||
$invoicePayment->currency_id = $invoicePayment_data['currency'];
|
||||
$invoicePayment->exchange_rate = $invoicePayment_data['exchangeRate'];
|
||||
$invoicePayment->installment = $invoicePayment_data['installment'];
|
||||
$invoicePayment->previous_balance = $invoicePayment_data['previousBalance'];
|
||||
$invoicePayment->amount = $invoicePayment_data['amount'];
|
||||
$invoicePayment->outstanding_balance = $invoicePayment_data['outstandingBalance'];
|
||||
if ($invoicePayment_data['canceledAt']){
|
||||
$invoicePayment->cancelled_at = Carbon::createFromFormat('Y-m-d H:i:s', $invoicePayment_data['canceledAt']);
|
||||
}
|
||||
$invoicePayment->save();
|
||||
return $invoicePayment;
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/InvoiceRequestController.php
Normal file
85
app/Http/Controllers/InvoiceRequestController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\InvoiceRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoiceRequestController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceRequest $invoiceRequest
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(InvoiceRequest $invoiceRequest)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceRequest $invoiceRequest
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(InvoiceRequest $invoiceRequest)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\InvoiceRequest $invoiceRequest
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, InvoiceRequest $invoiceRequest)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\InvoiceRequest $invoiceRequest
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(InvoiceRequest $invoiceRequest)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/InvoiceTypeController.php
Normal file
88
app/Http/Controllers/InvoiceTypeController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\InvoiceType;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoiceTypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceType $invoiceType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(InvoiceType $invoiceType)
|
||||
{
|
||||
//
|
||||
$invoiceTypes = InvoiceType::all();
|
||||
|
||||
return($invoiceTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceType $invoiceType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(InvoiceType $invoiceType)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\InvoiceType $invoiceType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, InvoiceType $invoiceType)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\InvoiceType $invoiceType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(InvoiceType $invoiceType)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/ManagerOTPController.php
Normal file
85
app/Http/Controllers/ManagerOTPController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ManagerOTP;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagerOTPController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\ManagerOTP $managerOTP
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(ManagerOTP $managerOTP)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\ManagerOTP $managerOTP
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(ManagerOTP $managerOTP)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\ManagerOTP $managerOTP
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, ManagerOTP $managerOTP)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\ManagerOTP $managerOTP
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(ManagerOTP $managerOTP)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/PaymentMethodController.php
Normal file
88
app/Http/Controllers/PaymentMethodController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PaymentMethodController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\PaymentMethod $paymentMethod
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(PaymentMethod $paymentMethod)
|
||||
{
|
||||
//
|
||||
$paymentMethods = PaymentMethod::all();
|
||||
|
||||
return($paymentMethods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\PaymentMethod $paymentMethod
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(PaymentMethod $paymentMethod)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\PaymentMethod $paymentMethod
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, PaymentMethod $paymentMethod)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\PaymentMethod $paymentMethod
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(PaymentMethod $paymentMethod)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/PaymentTypeController.php
Normal file
88
app/Http/Controllers/PaymentTypeController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PaymentType;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PaymentTypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\PaymentType $paymentType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(PaymentType $paymentType)
|
||||
{
|
||||
//
|
||||
$paymentTypes = PaymentType::all();
|
||||
|
||||
return($paymentTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\PaymentType $paymentType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(PaymentType $paymentType)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\PaymentType $paymentType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, PaymentType $paymentType)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\PaymentType $paymentType
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(PaymentType $paymentType)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/PostalCodeController.php
Normal file
88
app/Http/Controllers/PostalCodeController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PostalCode;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PostalCodeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\PostalCode $postalCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(PostalCode $postalCode)
|
||||
{
|
||||
//
|
||||
$postalcodes = PostalCode::all();
|
||||
|
||||
return($postalcodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\PostalCode $postalCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(PostalCode $postalCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\PostalCode $postalCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, PostalCode $postalCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\PostalCode $postalCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(PostalCode $postalCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
117
app/Http/Controllers/ProdServCodeController.php
Normal file
117
app/Http/Controllers/ProdServCodeController.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ProdServCode;
|
||||
use App\Imports\ProdServCodesImport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProdServCodeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
public function importarCodigosProdServ(Request $request) {
|
||||
// Validar que se ha subido un archivo y que es un Excel
|
||||
$request->validate([
|
||||
'file' => 'required|mimes:xlsx,xls,csv|max:20480', // Limitar el tamaño del archivo a 10MB
|
||||
]);
|
||||
|
||||
set_time_limit(1000);
|
||||
//ini_set('memory_limit', '-1');
|
||||
|
||||
try {
|
||||
// Procesar el archivo usando la clase de importación
|
||||
Excel::import(new ProdServCodesImport(), $request->file('file'));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Excel importado correctamente'
|
||||
], 200);
|
||||
} catch (\Exception $e) {
|
||||
// Manejar errores durante la importación
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Error al importar el archivo: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\ProdServCode $prodServCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(ProdServCode $prodServCode)
|
||||
{
|
||||
//
|
||||
$prodservcodes = ProdServCode::all();
|
||||
|
||||
return($prodservcodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\ProdServCode $prodServCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(ProdServCode $prodServCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\ProdServCode $prodServCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, ProdServCode $prodServCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\ProdServCode $prodServCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(ProdServCode $prodServCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
116
app/Http/Controllers/RfcController.php
Normal file
116
app/Http/Controllers/RfcController.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Rfc;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RfcController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el RFC del frontend y lo registra en el usuario correspondiente
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function insertarRfc(Request $request)
|
||||
{
|
||||
//
|
||||
$user = $request->user();
|
||||
$rfc = Rfc::where('rfc', $request->rfc)->firstOrCreate([
|
||||
'rfc' => $request->rfc
|
||||
],
|
||||
);
|
||||
$user->rfcs()->attach($rfc);
|
||||
$user->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'RFC agregado con exito'
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function obtenerRfcs(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
$rfcs = $user->rfcs->pluck('rfc');
|
||||
|
||||
return $rfcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Rfc $rfc
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Rfc $rfc)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Rfc $rfc
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Rfc $rfc)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Rfc $rfc
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Rfc $rfc)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Rfc $rfc
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Rfc $rfc)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
107
app/Http/Controllers/RiskController.php
Normal file
107
app/Http/Controllers/RiskController.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Risk;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
|
||||
class RiskController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Risk $risk
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Risk $risk)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Risk $risk
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Risk $risk)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Risk $risk
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Risk $risk)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Risk $risk
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Risk $risk)
|
||||
{
|
||||
//
|
||||
}
|
||||
public function consultarRisk(Request $request){
|
||||
$response = Http::withHeaders([
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/insights/'.$request["rfc"].'/risks');
|
||||
|
||||
// Verificar si la petición fue exitosa
|
||||
if ($response->successful()) {
|
||||
// Manejar la respuesta exitosa
|
||||
$data = $response->json();
|
||||
|
||||
// Filtrar los datos y eliminar claves numéricas
|
||||
|
||||
return response()->json([
|
||||
'data' => $data["data"]
|
||||
]);
|
||||
} else {
|
||||
// Manejar la respuesta fallida
|
||||
return response()->json(['error' => 'Error al obtener los datos'], $response->status());
|
||||
}
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/RoleController.php
Normal file
85
app/Http/Controllers/RoleController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Role;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Role $role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Role $role)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Role $role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Role $role)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Role $role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Role $role)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Role $role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Role $role)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/SalesRevenueController.php
Normal file
85
app/Http/Controllers/SalesRevenueController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\SalesRevenue;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SalesRevenueController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\SalesRevenue $salesRevenue
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(SalesRevenue $salesRevenue)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\SalesRevenue $salesRevenue
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(SalesRevenue $salesRevenue)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\SalesRevenue $salesRevenue
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, SalesRevenue $salesRevenue)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\SalesRevenue $salesRevenue
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(SalesRevenue $salesRevenue)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/StatusController.php
Normal file
85
app/Http/Controllers/StatusController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Status;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StatusController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Status $status
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Status $status)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Status $status
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Status $status)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Status $status
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Status $status)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Status $status
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Status $status)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/TaxController.php
Normal file
88
app/Http/Controllers/TaxController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Tax;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TaxController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Tax $tax
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(Tax $tax)
|
||||
{
|
||||
//
|
||||
$taxes = Tax::all();
|
||||
|
||||
return($taxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Tax $tax
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Tax $tax)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Tax $tax
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Tax $tax)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Tax $tax
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Tax $tax)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/TaxRateController.php
Normal file
88
app/Http/Controllers/TaxRateController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\TaxRate;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TaxRateController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\TaxRate $taxRate
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(Request $request)
|
||||
{
|
||||
//
|
||||
$taxRates = TaxRate::where('tax_id', $request->id)->get();
|
||||
|
||||
return($taxRates);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\TaxRate $taxRate
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(TaxRate $taxRate)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\TaxRate $taxRate
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, TaxRate $taxRate)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\TaxRate $taxRate
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(TaxRate $taxRate)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/TaxRegimeController.php
Normal file
88
app/Http/Controllers/TaxRegimeController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\TaxRegime;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TaxRegimeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\TaxRegime $taxRegime
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(TaxRegime $taxRegime)
|
||||
{
|
||||
//
|
||||
$taxRegimes = TaxRegime::all();
|
||||
|
||||
return($taxRegimes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\TaxRegime $taxRegime
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(TaxRegime $taxRegime)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\TaxRegime $taxRegime
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, TaxRegime $taxRegime)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\TaxRegime $taxRegime
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(TaxRegime $taxRegime)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
312
app/Http/Controllers/TaxpayerController.php
Normal file
312
app/Http/Controllers/TaxpayerController.php
Normal file
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Rfc;
|
||||
use App\Models\Taxpayer;
|
||||
use App\Models\EconomicActivity;
|
||||
use App\Models\TaxRegime;
|
||||
use App\Models\Risk;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
|
||||
class TaxpayerController extends Controller
|
||||
{
|
||||
|
||||
public function obtenerContribuyente(Request $request)
|
||||
{
|
||||
$start = microtime(true);
|
||||
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
$taxpayer = Taxpayer::where('rfc_id', $rfc->id)->first();
|
||||
if ($taxpayer) {
|
||||
$last_request = new Carbon($taxpayer->updated_at);
|
||||
$now = Carbon::now();
|
||||
$min_days = ($last_request->diff($now)->days > 7) ? true : null;
|
||||
} else {
|
||||
$min_days = true;
|
||||
}
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray()) && $min_days == true) {
|
||||
|
||||
try {
|
||||
// Realizar una petición GET con encabezados
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/ld+json',
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/insights/'. $request->rfc .'/summary');
|
||||
|
||||
// Verificar si la petición fue exitosa
|
||||
if ($response->successful()) {
|
||||
// Manejar la respuesta exitosa
|
||||
$data = $response->json();
|
||||
$taxpayer_data = $data;
|
||||
|
||||
// code...
|
||||
$taxpayer = TaxPayer::firstOrNew(['rfc_id' => $rfc->id]);
|
||||
|
||||
$taxpayer->name = $taxpayer_data['name'];
|
||||
$taxpayer->fiscal_address = $taxpayer_data['fiscalAddress'];
|
||||
$taxpayer->fiscal_address_status = $taxpayer_data['fiscalAddressStatusRaw'];
|
||||
|
||||
$taxpayer->save();
|
||||
|
||||
$economic_activities = $taxpayer_data['economicActivities'];
|
||||
|
||||
foreach ($economic_activities as $economic_activity_data) {
|
||||
$economic_activity = EconomicActivity::where('description', $economic_activity_data['name'])->first();
|
||||
if (!$economic_activity) {
|
||||
$economic_activity = new EconomicActivity();
|
||||
$economic_activity->description = $economic_activity_data['name'];
|
||||
$economic_activity->save();
|
||||
}
|
||||
$taxpayer->economicActivities()->attach($economic_activity, [
|
||||
'order' => $economic_activity_data['order'],
|
||||
'percentage' => $economic_activity_data['percentage'],
|
||||
'started_at' => $economic_activity_data['startDate'],
|
||||
'ended_at' => $economic_activity_data['endDate']
|
||||
]);
|
||||
$taxpayer->save();
|
||||
}
|
||||
|
||||
$tax_regimes = $taxpayer_data['taxRegimes'];
|
||||
|
||||
foreach ($tax_regimes as $tax_regime_data) {
|
||||
$tax_regime = TaxRegime::where('id', $tax_regime_data['code'])->first();
|
||||
if (!$tax_regime) {
|
||||
$tax_regime = new TaxRegime();
|
||||
$tax_regime->id = $tax_regime_data['code'];
|
||||
$tax_regime->description = $tax_regime_data['name'];
|
||||
$tax_regime->save();
|
||||
}
|
||||
$taxpayer->taxRegimes()->attach($tax_regime, [
|
||||
'started_at' => $tax_regime_data['startDate']
|
||||
]);
|
||||
$taxpayer->save();
|
||||
}
|
||||
|
||||
$taxpayer->total_employees = $taxpayer_data['totalEmployees'];
|
||||
$taxpayer->last_year_net_income = $taxpayer_data['lastYearNetIncome'];
|
||||
$taxpayer->last_year_total_income = $taxpayer_data['lastYearTotalIncome'];
|
||||
$taxpayer->total_revenue_last_tax_return = $taxpayer_data['totalRevenueLastTaxReturn'];
|
||||
$taxpayer->total_net_profit_last_tax_return = $taxpayer_data['totalNetProfitLastTaxReturn'];
|
||||
$taxpayer->last_tax_return_year = $taxpayer_data['lastTaxReturnYear'];
|
||||
$taxpayer->total_sales_revenue_current_year = $taxpayer_data['totalSalesRevenueCurrentYear'];
|
||||
$taxpayer->registration_date = Carbon::parse(substr($taxpayer_data['registrationDate'], 0, 21));
|
||||
$taxpayer->save();
|
||||
|
||||
$time = microtime(true) - $start;
|
||||
return response()->json(Taxpayer::where('rfc_id', $rfc->id)->get());
|
||||
} else {
|
||||
// Manejar la respuesta fallida
|
||||
return response()->json(['error' => 'Error al obtener los datos'], $response->status());
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
// Manejar excepciones específicas de solicitudes HTTP
|
||||
return response()->json(['error' => 'Excepción al obtener los datos: ' . $e->getMessage()], 500);
|
||||
} catch (\Exception $e) {
|
||||
// Manejar otras excepciones
|
||||
return response()->json(['error' => 'Error inesperado: ' . $e->getMessage()], 500);
|
||||
}
|
||||
} else if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray())) {
|
||||
return response()->json(Taxpayer::where('rfc_id', $rfc->id)->get());
|
||||
}
|
||||
}
|
||||
|
||||
public function generarCSD(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
//$user = User::where('email', strip_tags($request->email))->first();
|
||||
$rfc = Rfc::where('rfc', strip_tags($request->rfc))->first();
|
||||
|
||||
if (in_array($rfc->id, $user->rfcs->pluck('id')->toArray())) {
|
||||
$facturama = new Facturama\Client('pruebas', 'pruebas2011');
|
||||
|
||||
$params = [
|
||||
'Rfc' => $rfc->rfc,
|
||||
'Certificate' => $request->certificate,
|
||||
'PrivateKey' => $request->privateKey,
|
||||
'PrivateKeyPassword' => $request->privateKeyPassword
|
||||
];
|
||||
|
||||
$result = $facturama->post('api-lite/csds', $params );
|
||||
}
|
||||
}
|
||||
|
||||
//Obtener SalesRevenues/Ingresos y copiarlos a la base de datos
|
||||
public function ingresos(Request $request){
|
||||
try {
|
||||
$postdate = Carbon::parse($request->date)->addMonth()->format('Y-m');
|
||||
// Realizar una petición GET con encabezados
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/ld+json',
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/insights/'. $request->rfc .'/sales-revenue?options[from]='.$request->date.'-01T06%3A00%3A00&options[to]='.$postdate.'-01T05%3A59%3A59&options[periodicity]=monthly&options[type]=total');
|
||||
|
||||
// Verificar si la petición fue exitosa
|
||||
if ($response->successful()) {
|
||||
// Manejar la respuesta exitosa
|
||||
$egresos = $this->egresos($request);
|
||||
$data = $response->json();
|
||||
|
||||
// Filtrar los datos y eliminar claves numéricas
|
||||
$filteredData = array_values(collect($data['data'])
|
||||
->where('date', $request->date)
|
||||
->all());
|
||||
|
||||
$filteredEgresos = array_values(collect($egresos['data'])
|
||||
->where('date', $request->date)
|
||||
->all());
|
||||
|
||||
return response()->json([
|
||||
'ingresos' => $filteredData,
|
||||
'egresos' => $filteredEgresos,
|
||||
'datos' => $data
|
||||
]);
|
||||
} else {
|
||||
// Manejar la respuesta fallida
|
||||
return response()->json(['error' => 'Error al obtener los datos'], $response->status());
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
// Manejar excepciones específicas de solicitudes HTTP
|
||||
return response()->json(['error' => 'Excepción al obtener los datos: ' . $e->getMessage()], 500);
|
||||
} catch (\Exception $e) {
|
||||
// Manejar otras excepciones
|
||||
return response()->json(['error' => 'Error inesperado: ' . $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function egresos(Request $request){
|
||||
try {
|
||||
$postdate = Carbon::parse($request->date)->addMonth()->format('Y-m');
|
||||
// Realizar una petición GET con encabezados
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/ld+json',
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/insights/'. $request->rfc .'/expenditures?options[from]='.$request->date.'-01T06%3A00%3A00&options[to]='.$postdate.'-01T05%3A59%3A59&options[periodicity]=monthly&options[type]=total');
|
||||
|
||||
// Verificar si la petición fue exitosa
|
||||
if ($response->successful()) {
|
||||
// Manejar la respuesta exitosa
|
||||
$data = $response->json();
|
||||
return $data;
|
||||
} else {
|
||||
// Manejar la respuesta fallida
|
||||
return response()->json(['error' => 'Error al obtener los datos'], $response->status());
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
// Manejar excepciones específicas de solicitudes HTTP
|
||||
return response()->json(['error' => 'Excepción al obtener los datos: ' . $e->getMessage()], 500);
|
||||
} catch (\Exception $e) {
|
||||
// Manejar otras excepciones
|
||||
return response()->json(['error' => 'Error inesperado: ' . $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function utilidadBrutaVsIndustria(Request $request){
|
||||
try {
|
||||
// Realizar una petición GET con encabezados
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/ld+json',
|
||||
'X-API-Key' => 'b16ec9be960cdf3a8302e92a7aec84d2'
|
||||
])->get('https://api.syntage.com/taxpayers/'.$request->rfc.'/invoices?itemsPerPage=20');
|
||||
|
||||
// Verificar si la petición fue exitosa
|
||||
if ($response->successful()) {
|
||||
// Manejar la respuesta exitosa
|
||||
$data = $response->json();
|
||||
return $data;
|
||||
} else {
|
||||
// Manejar la respuesta fallida
|
||||
return response()->json(['error' => 'Error al obtener los datos'], $response->status());
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
// Manejar excepciones específicas de solicitudes HTTP
|
||||
return response()->json(['error' => 'Excepción al obtener los datos: ' . $e->getMessage()], 500);
|
||||
} catch (\Exception $e) {
|
||||
// Manejar otras excepciones
|
||||
return response()->json(['error' => 'Error inesperado: ' . $e->getMessage()], 500);
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Taxpayer $taxpayer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Taxpayer $taxpayer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Taxpayer $taxpayer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Taxpayer $taxpayer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Taxpayer $taxpayer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Taxpayer $taxpayer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Taxpayer $taxpayer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Taxpayer $taxpayer)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
117
app/Http/Controllers/UnitCodeController.php
Normal file
117
app/Http/Controllers/UnitCodeController.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\UnitCode;
|
||||
use App\Imports\UnitCodesImport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UnitCodeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
public function importarCodigosUnidad(Request $request) {
|
||||
// Validar que se ha subido un archivo y que es un Excel
|
||||
$request->validate([
|
||||
'file' => 'required|mimes:xlsx,xls,csv|max:20480', // Limitar el tamaño del archivo a 10MB
|
||||
]);
|
||||
|
||||
set_time_limit(1000);
|
||||
//ini_set('memory_limit', '-1');
|
||||
|
||||
try {
|
||||
// Procesar el archivo usando la clase de importación
|
||||
Excel::import(new UnitCodesImport(), $request->file('file'));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Excel importado correctamente'
|
||||
], 200);
|
||||
} catch (\Exception $e) {
|
||||
// Manejar errores durante la importación
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Error al importar el archivo: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\UnitCode $unitCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(UnitCode $unitCode)
|
||||
{
|
||||
//
|
||||
$unitcodes = UnitCode::all();
|
||||
|
||||
return($unitcodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\UnitCode $unitCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(UnitCode $unitCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\UnitCode $unitCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, UnitCode $unitCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\UnitCode $unitCode
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(UnitCode $unitCode)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/UsageController.php
Normal file
88
app/Http/Controllers/UsageController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Usage;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UsageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Usage $usage
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function get(Usage $usage)
|
||||
{
|
||||
//
|
||||
$usages = Usage::all();
|
||||
|
||||
return($usages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Usage $usage
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Usage $usage)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Usage $usage
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Usage $usage)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Usage $usage
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Usage $usage)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
69
app/Http/Kernel.php
Normal file
69
app/Http/Kernel.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\Cors::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'throttleEndpoint' => \App\Http\Middleware\ThrottleEndpoint::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
||||
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
}
|
||||
24
app/Http/Middleware/Cors.php
Normal file
24
app/Http/Middleware/Cors.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Cors
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
return $next($request)
|
||||
->header('Access-Control-Allow-Origin', '*')
|
||||
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, OPTIONS')
|
||||
->header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, X-XSRF-TOKEN');
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @param string|null ...$guards
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
33
app/Http/Middleware/ThrottleEndpoint.php
Normal file
33
app/Http/Middleware/ThrottleEndpoint.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
|
||||
class ThrottleEndpoint
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
// Aquí puedes poner el origen de la URL o dominio que deseas
|
||||
$allowedOrigins = ['https://cx1n8n.ext.consultoria-as.com/', 'http://cx1n8n.ext.consultoria-as.com/'];
|
||||
|
||||
// Verificar si el origen de la solicitud es uno de los permitidos
|
||||
if (in_array($request->header('Origin'), $allowedOrigins)) {
|
||||
// Si la solicitud proviene de un origen permitido, deshabilitamos el throttle
|
||||
$request->headers->set('X-RateLimit-Limit', PHP_INT_MAX); // Establece un límite muy alto
|
||||
$request->headers->set('X-RateLimit-Remaining', 10000); // Establece un límite muy alto
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user