1e90ff/cfdi-helper

一个用于提取和验证墨西哥CFDI状态和完整性的库。

dev-main 2022-03-27 22:58 UTC

This package is auto-updated.

Last update: 2024-09-28 04:47:55 UTC


README

一个用于提取和验证墨西哥CFDI状态和完整性的库。

用法

初始化

<?php

use _1e90ff\CfdiHelper\Cfdi;

$cfdi = new Cfdi($element); // accepts a SimpleXMLElement object
$cfdiFromFile = Cfdi::loadFromFile('cfdi.xml');
$cfdiFromString = Cfdi::loadFromString('<?xml ...');

通用数据访问

$cfdi->version();
// returns declared CFDI version (like 3.3 or 4.0)

$cfdi->valid();
// returns true or false depending on a signature integrity check success

$cfdi->type();
// returns I (Ingreso), E (Egreso), T (Traslado), P (Pago) or N (Nómina)

$cfdi->date();
// returns date of issue

$cfdi->total();
// returns total amount of the CFDI

$cfdi->currency();
// returns currency code of the total amount

$cfdi->exchangeRate();
// returns exchange rate of the currency in mexican peso (MXN)

$cfdi->signature();
// returns base64-encoded signature

$cfdi->certificate();
// returns base64-encoded certificate

发行者数据访问

$cfdi->issuer()->rfc();
// returns RFC (Registro Federal del Contribuyente) of the issuer

$cfdi->issuer()->name();
// returns name of the issuer

接收者数据访问

$cfdi->receiver()->rfc();
// returns RFC (Registro Federal del Contribuyente) of the receiver

$cfdi->receiver()->name();
// returns name of the receiver

数字税票数据访问(如有)

$cfdi->digitalTaxStamp()->uuid();
// returns unique identifier of the CFDI

$cfdi->digitalTaxStamp()->date();
// returns date of stamp

$cfdi->digitalTaxStamp()->signature();
// returns base64-encoded signature

获取当前CFDI状态(如有数字税票数据)

<?php

use _1e90ff\CfdiHelper\Cfdi;
use _1e90ff\CfdiHelper\Utils\CfdiStatusRequest;

$cfdi = new Cfdi($element);

$request = new CfdiStatusRequest();

$cfdi = $request->update($cfdi);

// Helper functions

$cfdi->status->isValid();
// returns true or false depending if the CFDI is still valid for tax purposes

$cfdi->status->isCancelable();
// returns true or false depending if the CFDI is cancelable

$cfdi->status->isCancelableWithConfirmation();
// returns true or false depending if the cancelation requires receiver confirmation

$cfdi->status->isBlacklistedIssuer();
// returns true or false depending if the issuer is marked as EFOS (Empresa que Factura Operaciones Simuladas)

// Raw data

$cfdi->status->date();
// returns request date

$cfdi->status->status();
// returns Vigente (valid), Cancelado (cancelled) or No encontrado (not found)

$cfdi->status->cancelable();
// returns Cancelable (cancelable), No cancelable (not cancelable), Cancelable con aceptación (cancelable with confirmation)

$cfdi->status->issuerStatus();
// returns 100 (EFOS code) or 200 (good issuer)