pittacusw/parse-bill
Composer 安装命令:
composer require pittacusw/parse-bill
包简介
Wrapper to parse XML Bills and generate a PDF file
README 文档
README
Laravel package for parsing Chilean DTE XML documents and rendering them as PDF files.
The package is designed around the existing printable layout used by this project. The PDF view contract has been kept intact during the optimization pass so margins, page structure, cedible copy rules, and the legal layout behavior continue to follow the current implementation.
What It Does
- Parses XML DTE payloads from either a file path or a raw XML string
- Extracts the
Documentopayload into a PHP object structure that the Blade views can render - Generates the SII TED PDF417 barcode when a TED node is present
- Renders PDF output through
barryvdh/laravel-dompdf - Resolves document type, county/SII branch, and additional tax labels from reference tables
- Exposes helpers for reading the document signature value
Requirements
- PHP
^8.3 - Laravel
^13.2 - Database tables for the reference lookups used by the PDF views
Installation
composer require pittacusw/parse-bill
Publish the package assets and run the migrations:
php artisan vendor:publish --provider="Pittacusw\ParseBill\ParseBillServiceProvider"
php artisan migrate
Seed Required Reference Data
The PDF renderer expects lookup data for:
- document types
- counties and SII branches
- additional taxes
Seed the required tables with the included seeders:
php artisan db:seed --class="Pittacusw\ParseBill\Seeders\SiiBranchesTableSeeder" php artisan db:seed --class="Pittacusw\ParseBill\Seeders\CountiesTableSeeder" php artisan db:seed --class="Pittacusw\ParseBill\Seeders\DocumentsTypesTableSeeder" php artisan db:seed --class="Pittacusw\ParseBill\Seeders\AdditionalTaxesTableSeeder"
Optional seeders are also available for economic activities, reference types, and transfer types.
Configuration
After publishing, the package config file is available at config/pittacusw-parse-bill.php.
By default it points to these models:
return [ 'county' => \Pittacusw\ParseBill\Models\County::class, 'documents_type' => \Pittacusw\ParseBill\Models\DocumentsType::class, 'additional_tax' => \Pittacusw\ParseBill\Models\AdditionalTax::class, ];
Override these entries if your application uses custom models for the same tables.
Usage
Parse XML
use Pittacusw\ParseBill\ReadXml; $document = ReadXml::parse($xmlOrPath);
$xmlOrPath can be:
- an absolute or relative path to an XML file
- a raw XML string
The parser normalizes single Detalle, Referencia, DscRcgGlobal, and ImptoReten nodes into arrays so the renderer can iterate them consistently.
Read the Signature Value
use Pittacusw\ParseBill\ReadXml; $signature = ReadXml::signature($xmlOrPath);
Generate a PDF
use Pittacusw\ParseBill\ParsePdf; $pdf = ParsePdf::render($xmlOrPath); return $pdf->stream('documento.pdf');
You can also save or return the binary output:
$contents = ParsePdf::render($xmlOrPath)->output();
Layout Guarantees
This package intentionally preserves the current visual PDF structure:
- the letter-sized PDF output remains the default
- the existing Blade templates and CSS layout contract are preserved
- fixed margin behavior is unchanged
- cedible second-page behavior for DTE types
33,34, and52is preserved - county/SII branch resolution still comes from the configured reference tables
If you need to change layout rules for another legal regime or document standard, do it through dedicated view changes and add fixture-based tests before shipping.
Testing
The package now includes a PHPUnit + Testbench suite covering:
- XML parsing for both
SetDTEand directDocumentoroots - collection normalization for repeatable DTE nodes
- signature extraction
- Blade lookup directives
- PDF generation smoke tests
- layout-sensitive view contract checks
Run the suite with:
composer test
Notes
- The renderer depends on reference-table data being present. Missing document types, counties, or tax codes will lead to incomplete labels in the PDF.
- TED barcode rendering depends on the XML containing a
TEDnode and on the barcode library being available in the runtime environment. - If you customize the PDF view, keep a close eye on page height and overflow because those directly affect the legal printable layout.
pittacusw/parse-bill 适用场景与选型建议
pittacusw/parse-bill 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 08 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「touchef」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pittacusw/parse-bill 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pittacusw/parse-bill 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pittacusw/parse-bill 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Wrapper to connect a Laravel application to the Touchef API
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
统计信息
- 总下载量: 99
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2022-08-20