settings
This commit is contained in:
@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Koneko\SatCatalogs\Imports\SatCatalogsImport;
|
||||
use Koneko\SatCatalogs\Models\Banco;
|
||||
use Koneko\SatCatalogs\Models\RegimenContratacion;
|
||||
use Koneko\SatCatalogs\Models\Deduccion;
|
||||
use Koneko\SatCatalogs\Models\Percepcion;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class SATCatalogsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$file_path = database_path("data/catCFDI_V_4_20250213.xls");
|
||||
|
||||
$import = new SatCatalogsImport();
|
||||
|
||||
$import->onlySheets('c_ClaveProdServ');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_ClaveUnidad');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_CodigoPostal_Parte_1');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_CodigoPostal_Parte_2');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Colonia_1');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Colonia_2');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Colonia_3');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_Estado');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_FormaPago');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Localidad');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_Moneda');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Municipio');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_Pais');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_RegimenFiscal');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_UsoCFDI');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
|
||||
// Lee el archivo JSON desde el storage
|
||||
$json = File::get(database_path('data/catalogo_sat_bancos.json'));
|
||||
|
||||
// Convierte el contenido JSON a un array asociativo
|
||||
$bancos = json_decode($json, true);
|
||||
|
||||
// Inserta cada banco en la base de datos
|
||||
foreach ($bancos as $banco) {
|
||||
Banco::create([
|
||||
'c_banco' => $banco['c_banco'],
|
||||
'descripcion' => $banco['descripcion'],
|
||||
'razon_social' => $banco['razon_social'],
|
||||
'rfc' => null,
|
||||
'status' => Banco::STATUS_ENABLED
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Leer el archivo JSON desde la ruta especificada
|
||||
$json = File::get(database_path('data/catalogo_sat_regimenes_contratacion.json'));
|
||||
|
||||
// Decodificar el JSON en un array asociativo
|
||||
$regimenes = json_decode($json, true);
|
||||
|
||||
// Insertar cada régimen en la base de datos
|
||||
foreach ($regimenes as $c_tipo_regimen => $descripcion) {
|
||||
RegimenContratacion::create([
|
||||
'c_tipo_regimen' => $c_tipo_regimen,
|
||||
'descripcion' => $descripcion,
|
||||
'fecha_inicio_de_vigencia' => null,
|
||||
'fecha_fin_de_vigencia' => null
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Leer el archivo JSON desde la ruta especificada
|
||||
$json = File::get(database_path('data/catalogo_sat_percepciones_deducciones.json'));
|
||||
|
||||
// Decodificar el JSON en un array asociativo
|
||||
$catalogo = json_decode($json, true);
|
||||
|
||||
// Insertar percepciones
|
||||
foreach ($catalogo['percepciones'] as $percepcion) {
|
||||
Percepcion::create([
|
||||
'c_percepcion' => $percepcion['clave'],
|
||||
'descripcion' => $percepcion['descripcion'],
|
||||
'fecha_inicio_de_vigencia' => null,
|
||||
'fecha_fin_de_vigencia' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
// Insertar deducciones
|
||||
foreach ($catalogo['deducciones'] as $deduccion) {
|
||||
Deduccion::create([
|
||||
'c_deduccion' => $deduccion['clave'],
|
||||
'descripcion' => $deduccion['descripcion'],
|
||||
'fecha_inicio_de_vigencia' => null,
|
||||
'fecha_fin_de_vigencia' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user