codelko / ciberfactura
0.4.0
2022-01-05 01:21 UTC
Requires
- genkgo/xsl: ^0.6.11
- dev-master
- 0.4.0
- 0.1.85
- 0.1.84
- 0.1.83
- 0.1.82
- 0.1.81
- 0.1.80
- 0.1.79
- 0.1.78
- 0.1.77
- 0.1.76
- 0.1.75
- 0.1.74
- 0.1.73
- 0.1.72
- 0.1.71
- 0.1.70
- 0.1.69
- 0.1.68
- 0.1.67
- 0.1.66
- 0.1.64
- 0.1.63
- 0.1.62
- 0.1.61
- 0.1.60
- 0.1.59
- 0.1.58
- 0.1.57
- 0.1.56
- 0.1.55
- 0.1.54
- 0.1.53
- 0.1.52
- 0.1.51
- 0.1.50
- 0.1.49
- 0.1.48
- 0.1.47
- 0.1.46
- 0.1.45
- 0.1.44
- 0.1.43
- 0.1.42
- 0.1.41
- 0.1.40
- 0.1.39
- 0.1.38
- 0.1.37
- 0.1.36
- 0.1.35
- 0.1.34
- 0.1.33
- 0.1.32
- 0.1.31
- 0.1.30
- 0.1.29
- 0.1.28
- 0.1.27
- 0.1.26
- 0.1.25
- 0.1.24
- 0.1.23
- 0.1.22
- 0.1.21
- 0.1.20
- 0.1.19
- 0.1.18
- 0.1.17
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-cfdi40
- dev-pagos20
- dev-ORS-923
This package is auto-updated.
Last update: 2024-09-19 18:12:12 UTC
README
简化CFDI v3.3创建和盖章过程的库
安装
要开始安装库,需要在Laravel根目录的composer.json中添加依赖。
{
"require": {
"codelko/ciberfactura": "0.1.*"
}
}
Laravel 5.4
注册以下Service Provider和Alias
// config/app.php
'providers' => [
Codelko\Ciberfactura\CiberfacturaServiceProvider::class,
];
'aliases' => [
'Cfdi' => Codelko\Ciberfactura\Facades\Cfdi::class,
];
接下来,发布默认配置。
php artisan vendor:publish --provider="Codelko\Ciberfactura\CiberfacturaServiceProvider"
此命令除了创建配置文件config/packages/codelko/ciberfactura/config.php
外,还会创建一组文件,包含创建CFDI所需表的迁移。
为了使配置正确工作,我们需要在.env文件中定义环境变量及其适当的值。
此库可用来通过Smarter Web发出发票,Smarter Web是SAT认证的授权提供商。
迁移
在测试库功能之前,需要执行创建存储CFDI的表的迁移。
php artisan migrate
执行此命令后,将创建集成库所需的所有必要表,以及SAT提供的目录,这些目录对于版本3.3的发票发行是必需的。
- 凭证类型
- 税务制度
- 支付方式
- 支付方法
- 税种
- 货币
- 州
- 国家
- 因素类型
- 关系类型
- CFDI用途
- 单位
- 产品和/或服务
- 类型
- 分段
- 家族
- 类别
代码示例
DB::beginTransaction();
$cfdi_factura = CfdiFactura::create([
'version' => 3.3,
'serie' => 'AS',
'folio' => '3972',
'fecha' => str_replace(" ", "T", date("Y-m-d H:i:s")),
'forma_pago' => "03",
'sub_total' => 1000,
'descuento' => 0,
'moneda' => 'MXN',
'total' => 1000,
'tipo_de_comprobante' => 'I',
'metodo_pago' => 'PUE',
'lugar_expedicion' => '46600',
'condiciones_de_pago' => 'Condiciones No Definidas'
]);
$cfdi_factura->addEmisor([
'rfc' => 'AAA010101AAA',
'nombre' => 'ACCEM SERVICIOS EMPRESARIALES SC',
'regimen_fiscal' => '601'
]);
$cfdi_factura->addReceptor([
'rfc' => 'VECR8307073J1',
'nombre' => 'Ramiro Alonso Vera Contreras',
'residencia_fiscal' => 'MEX',
'num_reg_id_trib' => '',
'uso_cfdi' => 'G03'
]);
$cfdi_concepto = $cfdi_factura->addConcepto([
'cfdi_id' => $cfdi_factura->id,
'clave_prod_serv' => '10151810',
'no_identificacion' => '',
'cantidad' => 5,
'clave_unidad' => 'E49',
'unidad' => 'Litro',
'descripcion' => 'Concepto de Prueba 1',
'valor_unitario' => 100.00,
'importe' => 500.00,
'descuento' => 0.00
]);
$cfdi_concepto->addImpuesto([
'cfdi_id' => $cfdi_factura->id,
'type' => 'retencion',
'base' => 500.00,
'impuesto' => '001',
'tipo_factor' => 'Tasa',
'tasa_o_cuota' => 0.1600,
'importe' => 80.00
]);
$cfdi_concepto = $cfdi_factura->addConcepto([
'cfdi_id' => $cfdi_factura->id,
'clave_prod_serv' => '10151810',
'no_identificacion' => '',
'cantidad' => 5,
'clave_unidad' => 'E49',
'unidad' => 'Litro',
'descripcion' => 'Concepto de Prueba 2',
'valor_unitario' => 100.00,
'importe' => 500.00,
'descuento' => 0.00
]);
$cfdi_concepto->addImpuesto([
'type' => 'traslado',
'base' => 500.00,
'impuesto' => '002',
'tipo_factor' => 'Tasa',
'tasa_o_cuota' => 0.1600,
'importe' => 80.00
]);
$cfdi = new Cfdi();
$cfdi->setTimbrador(new CfdiTimbrador($cfdi->rfc, $cfdi->certificate, $cfdi->production));
$cfdi->load($cfdi_factura);
$sello = $cfdi->sellar();
$uuid = $cfdi->timbrar();
$xml = $cfdi->xml();
DB::commit();