joaomfrebelo/saft-pt_4_php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

joaomfrebelo/saft-pt_4_php

Composer 安装命令:

composer require joaomfrebelo/saft-pt_4_php

包简介

PHP core lib to work with SAF-T (PT). A library/framework to generate, parse, import and validate programmatically or cli the Portuguese Tax Audit file SAF-T (PT)

README 文档

README

Rebelo SAFT-PT is a PHP library/framework to lead with the Portuguese tax audit file. The community edition lets to generate, parse, import and validate programmatically or CLI the Portuguese Tax Audit file SAFT-PT. This library also create the digital signature that is impose by law to all invoice, transport documents and working documents issued im Portugal. The enterprise edition also submit the SAFT-PT file to the Portuguese Tax Authority e-fatura web site.

Install

composer require joaomfrebelo/saft-pt_4_php

Examples

https://github.com/joaomfrebelo/Saft-PT_4_PHP/tree/master/examples

Legal documentation, portuguse tax law

https://github.com/joaomfrebelo/Saft-PT_4_PHP/tree/master/legal_documentation

Parse and validate a SAFT-PT file:

$auditFile = \Rebelo\SaftPt\AuditFile\AuditFile::loadFile("/path/to/file");
$auditFile->validate();
if ($auditFile->getErrorRegistor()->hasErrors()) {
    // Do stuff
} else {
    // read and integrate data to you database ERP
}

Create the signature hash

$sign = new Rebelo\SaftPt\Sign\Sign();
$sign->setPrivateKey($privatekey);
$hash = $sign->createSignature($docDate, $systemEntryDate, $doc, $grossTotal, $lastHash);

Validate the hash signature

$sign = new Rebelo\SaftPt\Sign\Sign();
$sign->setPublicKey($publicKey);
$isValid = $sign->verifySignature($hash, $docDate, $systemEntryDate, $doc, $grossTotal, $lastHash);

Create a SAFT-PT file

$audit = new AuditFile();
$header = $audit->getHeader();
$header->setCompanyID($companyID);
$header->setTaxRegistrationNumber($taxRegistrationNumber);
$header->setTaxAccountingBasis(Rebelo\SaftPt\AuditFile\TaxAccountingBasis::FACTURACAO());
$header->setCompanyName($companyName);
$header->setBusinessName($businessName);
(...)
// Expoert to file
$audit->toFile("/path/to/file");

CLI file validation

./vendor/bin/saft4php validate -g=en -p=/path/to/Public_Key.txt" -- /path/saft.xml
./vendor/bin/saft4php validate /path/saft.xml

To more options like delta, help

./vendor/bin/saft4php validate --help

Using as stand alone SAFT-PT validator

First clone or download the project

git clone https://github.com/joaomfrebelo/Saft-PT_4_PHP.git

In the project root (php >= 7.4 installed)

php saft4php validate /path/saft.xml

Some type of validations

  • XML scheme

  • Document values

  • Total values

  • Documents number sequence

  • Signature

  • Address where are mandatory

  • Dates

  • And other stuff

API documentation

https://joaomfrebelo.github.io/Saft-PT_4_PHP/

Professional support:

https://www.pchouse.pt

joao.rebelo@pchouse.pt

Features CE EE
Generate SAFT yes yes
Parse SAFT yes yes
Create hash signature yes yes
Validate file programmatically yes yes
Validate file CLI yes yes
Validate hash signature yes yes
Submit file to e-fatura no yes
Create XML file in memory yes yes
Create XML file with StreamWriter to save memory no yes
Integration with DataSource no yes
Easy to integrate with Unit test yes yes
Integration with other languages (With midleware) yes

License

MIT License

统计信息

  • 总下载量: 210
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固