{"id":37975595,"url":"https://github.com/csarcrr/invoicing-integration","last_synced_at":"2026-03-10T00:02:36.157Z","repository":{"id":321488040,"uuid":"1085294734","full_name":"csarcrr/invoicing-integration","owner":"csarcrr","description":"Simplified invoicing for the Portuguese industry. Multiple providers, one integration.","archived":false,"fork":false,"pushed_at":"2026-01-10T18:53:15.000Z","size":500,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-11T05:33:35.973Z","etag":null,"topics":["invoicing-tool","legaltools","portuguese-invoicing","saft-pt"],"latest_commit_sha":null,"homepage":"https://csarcrr.github.io/invoicing-integration/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csarcrr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"vendor_name"}},"created_at":"2025-10-28T21:00:38.000Z","updated_at":"2026-01-10T18:51:30.000Z","dependencies_parsed_at":"2025-10-29T23:40:39.352Z","dependency_job_id":null,"html_url":"https://github.com/csarcrr/invoicing-integration","commit_stats":null,"previous_names":["csarcrr/invoicing-integration"],"tags_count":9,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/csarcrr/invoicing-integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csarcrr%2Finvoicing-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csarcrr%2Finvoicing-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csarcrr%2Finvoicing-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csarcrr%2Finvoicing-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csarcrr","download_url":"https://codeload.github.com/csarcrr/invoicing-integration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csarcrr%2Finvoicing-integration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28480835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["invoicing-tool","legaltools","portuguese-invoicing","saft-pt"],"created_at":"2026-01-16T18:29:56.245Z","updated_at":"2026-03-10T00:02:36.147Z","avatar_url":"https://github.com/csarcrr.png","language":"PHP","funding_links":["https://github.com/sponsors/vendor_name"],"categories":[],"sub_categories":[],"readme":"# Invoicing Integration\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/csarcrr/invoicing-integration.svg?style=flat-square)](https://packagist.org/packages/csarcrr/invoicing-integration)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/csarcrr/invoicing-integration/full-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/csarcrr/invoicing-integration/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/csarcrr/invoicing-integration.svg?style=flat-square)](https://packagist.org/packages/csarcrr/invoicing-integration)\n\n**Invoicing Integration** is a Laravel package that aggregates invoicing software providers in Portugal. It offers a fluent, provider-agnostic API so you can issue compliant documents without re-learning each vendor's HTTP contract.\n\n\u003e **Supported provider (today):** Cegid Vendus. The package architecture allows more providers to be added without changing your application code.\n\n## Why Invoicing Integration?\n\nIssuing fiscally compliant invoices in Portugal can be challenging. Each provider has its own API, authentication flow, and data formats.\n\nThis package solves that by giving you:\n\n- **One API for all providers** - Switch providers without rewriting your integration\n- **Fluent builders** - Intuitive, chainable methods that read like natural language\n- **Built-in validation** - Catch errors before they reach the provider\n- **Type safety** - Strongly typed DTOs powered by `spatie/laravel-data`\n\n## Highlights\n\n- Fluent builders for all fiscal document types (FT, FR, FS, RG, NC, GT)\n- DTO-first workflows via `InvoiceData`, so requests/responses share the same typed object\n- First-class client management via the `Client` facade (create, get, find)\n- Strongly typed DTOs powered by `spatie/laravel-data`\n- Built-in PDF / ESC/POS outputs with secure file persistence helpers\n- Centralized HTTP error handling and provider configuration facades\n\n## Table of Contents\n\n- [Important Legal Disclaimer](#important-legal-disclaimer)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n- [Quick Start](#quick-start)\n- [Error Handling](#error-handling)\n- [Testing \u0026 Quality](#testing--quality)\n- [Documentation](#documentation)\n- [Contributing](#contributing)\n- [Security](#security)\n- [License](#license)\n\n## Important Legal Disclaimer\n\n**This package facilitates invoicing provider API usage and is not intended to serve as legal guidance.**\n\nIt is **your responsibility** to:\n\n- Comply with all invoicing laws and regulations in your jurisdiction\n- Understand each provider's specific requirements\n- Ensure proper invoicing practices according to your legal obligations\n- Validate that your usage complies with tax laws and accounting standards\n\nAlways consult with legal and accounting professionals when implementing invoicing solutions.\n\n## Requirements\n\n- PHP 8.2+\n- Laravel 11.x or 12.x (`illuminate/contracts: ^11.0 || ^12.0`)\n\n## Installation\n\n```bash\ncomposer require csarcrr/invoicing-integration\n```\n\nPublish the configuration file once the package is installed:\n\n```bash\nphp artisan vendor:publish --tag=\"invoicing-integration-config\"\n```\n\nSee the documentation section: Getting Started - 4. Configuration File for detailed configuration instructions.\n\n### Runtime access to provider configuration\n\nUse the `ProviderConfiguration` facade when you need to inspect or cache the active provider during runtime:\n\n```php\nuse CsarCrr\\InvoicingIntegration\\Facades\\ProviderConfiguration;\n\n$activeProvider = ProviderConfiguration::getProvider();\n$config = ProviderConfiguration::getConfig();\n```\n\n### Environment reference\n\n| Variable                         | Description                                                  |\n| -------------------------------- | ------------------------------------------------------------ |\n| `INVOICING_INTEGRATION_PROVIDER` | Provider key (`CegidVendus` for now)                         |\n| `CEGID_VENDUS_API_KEY`           | API token generated in Vendus                                |\n| `CEGID_VENDUS_MODE`              | `tests` (sandbox) or `normal` (fiscal)                       |\n| `CEGID_VENDUS_PAYMENT_*`         | Mapping between `PaymentMethod` enums and Vendus payment IDs |\n\n\u003e The package validates configuration lazily when you issue invoices or clients, so misconfigured payment IDs will raise descriptive exceptions before the HTTP call is sent.\n\n## Usage\n\n### Creating an invoice\n\nEvery invoice now starts with a populated `InvoiceData` DTO. Pass the DTO to the\n`Invoice` facade and the package handles provider translation for you.\n\n```php\nuse CsarCrr\\InvoicingIntegration\\Data\\ClientData;\nuse CsarCrr\\InvoicingIntegration\\Data\\InvoiceData;\nuse CsarCrr\\InvoicingIntegration\\Data\\ItemData;\nuse CsarCrr\\InvoicingIntegration\\Data\\PaymentData;\nuse CsarCrr\\InvoicingIntegration\\Enums\\InvoiceType;\nuse CsarCrr\\InvoicingIntegration\\Enums\\PaymentMethod;\nuse CsarCrr\\InvoicingIntegration\\Facades\\Invoice;\n\n$invoiceData = InvoiceData::make([\n    'type' =\u003e InvoiceType::InvoiceReceipt,\n    'client' =\u003e ClientData::make([\n        'name' =\u003e 'Maria Silva',\n        'vat' =\u003e 'PT123456789',\n        'email' =\u003e 'maria.silva@email.pt',\n        'address' =\u003e 'Rua Augusta, 25',\n        'city' =\u003e 'Lisboa',\n        'postalCode' =\u003e '1100-053',\n        'country' =\u003e 'PT',\n    ]),\n    'items' =\u003e [\n        ItemData::make([\n            'reference' =\u003e 'HEADPHONES-PRO',\n            'note' =\u003e 'Wireless Noise-Cancelling Headphones',\n            'price' =\u003e 14999, // 149.99 in cents\n            'quantity' =\u003e 1,\n        ]),\n        ItemData::make([\n            'reference' =\u003e 'SHIPPING-STD',\n            'note' =\u003e 'Standard Delivery (2-3 business days)',\n            'price' =\u003e 499, // 4.99 in cents\n        ]),\n    ],\n    'payments' =\u003e [\n        PaymentData::make([\n            'method' =\u003e PaymentMethod::CREDIT_CARD,\n            'amount' =\u003e 15498, // Total: 154.98\n        ]),\n    ],\n]);\n\n$invoice = Invoice::create($invoiceData)-\u003eexecute()-\u003egetInvoice();\n\nif ($invoice-\u003eoutput) {\n    $invoice-\u003eoutput-\u003esave('invoices/' . $invoice-\u003eoutput-\u003efileName());\n}\n```\n\nThe result contains everything you need:\n\n```json\n{\n    \"id\": 4567,\n    \"sequence\": \"FR 01P2025/1\",\n    \"total\": 15498,\n    \"totalNet\": 12600,\n    \"atcudHash\": \"FR 01P2025/1 ABC123\"\n}\n```\n\n\u003e `ClientData`, `ItemData`, `PaymentData`, and other value objects extend `spatie/laravel-data\\Data`. Instantiate them with `::make([...])` (or via dependency injection) so validation and transformers run before each HTTP request.\n\n\u003e Prefer the `Invoice` facade for day-to-day usage. If you need to resolve the underlying action for dependency injection (e.g., in jobs), bind `CsarCrr\\InvoicingIntegration\\InvoiceAction` from the container.\n\n**Key rules:**\n\n- At least one item is required for FT/FR/FS/NC documents\n- Payments are required for FR, FS, RG, and NC types\n- Tax exemptions require `ItemTax::EXEMPT` plus a valid `TaxExemptionReason`\n\n### Manage clients via the facade\n\nYou can register customers in the provider so they can be reused across orders:\n\n```php\nuse CsarCrr\\InvoicingIntegration\\Data\\ClientData;\nuse CsarCrr\\InvoicingIntegration\\Facades\\Client;\n\n// Register a new customer\n$client = Client::create(\n    ClientData::make([\n        'name' =\u003e 'TechStore Portugal Lda',\n        'vat' =\u003e 'PT509876543',\n        'email' =\u003e 'invoices@techstore.pt',\n        'address' =\u003e 'Zona Industrial do Porto, Lote 15',\n        'city' =\u003e 'Porto',\n        'postalCode' =\u003e '4100-000',\n        'country' =\u003e 'PT',\n    ])\n)-\u003eexecute()-\u003egetClient();\n\n// Retrieve the customer later by their provider ID\n$fetched = Client::get(ClientData::make(['id' =\u003e $client-\u003eid]))-\u003eexecute()-\u003egetClient();\n\n// Search for customers by email domain\n$filters = ClientData::make(['email' =\u003e 'techstore.pt']);\n$results = Client::find($filters)-\u003eexecute();\n```\n\nSee [docs/clients/README.md](docs/clients/README.md) for pagination and filtering options.\n\n\u003e All DTOs expose public typed properties. Access values via `$client-\u003ename`,\n\u003e `$invoice-\u003esequence`, etc. - legacy getter methods no longer exist.\n\n### Common validation rules\n\n- Receipts (RG) are the only document without items\n- Credit notes require related document references, payments, and a reason\n- Transport details require a client, origin date, and valid ISO 3166-1 codes\n- Output formats (`PDF_BASE64`, `ESCPOS`) can be persisted via the `Output` value object (`save()`, `getPath()`, etc.)\n\n## Quick Start\n\nFor detailed workflows per document type, visit:\n\n- [Creating an Invoice](docs/invoices/creating-an-invoice.md)\n- [Creating a Receipt (RG)](docs/invoices/creating-a-RG-for-an-invoice.md)\n- [Credit Notes (NC)](docs/invoices/creating-a-nc-invoice.md)\n- [Outputting documents (PDF/ESC-POS)](docs/invoices/outputting-invoice.md)\n\n## Error Handling\n\nThe `Http::handleUnwantedFailures()` macro maps HTTP status codes to package-specific exceptions:\n\n- `UnauthorizedException` - invalid or missing credentials (401)\n- `FailedReachingProviderException` - provider error/unreachable (500)\n- `RequestFailedException` - provider returned structured errors\n\nRefer to [docs/handling-errors.md](docs/handling-errors.md) for the full exception matrix and troubleshooting steps.\n\n## Testing \u0026 Quality\n\n```bash\ncomposer test        # Pest (parallel) test suite\ncomposer analyse     # PHPStan (Larastan) analysis\ncomposer format      # Laravel Pint code style\ncomposer complete    # Format + analyse + test\n```\n\n## Documentation\n\nBrowse the full documentation at [csarcrr.github.io/invoicing-integration](https://csarcrr.github.io/invoicing-integration/#/).\n\n- [Features Matrix](docs/features.md)\n- [API Reference](docs/api-reference.md)\n- [Clients](docs/clients/README.md)\n- [Provider Guides](docs/providers/README.md)\n\n## Contributing\n\nPlease see [CONTRIBUTING.md](CONTRIBUTING.md) for coding standards, branching strategy, and release process.\n\n## Security\n\nPlease review [the security policy](../../security/policy) to learn how to report vulnerabilities.\n\n## License\n\nThe MIT License (MIT). See [LICENSE.md](LICENSE.md) for the full text.\n\n---\n\n_Last updated: February 2026_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsarcrr%2Finvoicing-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsarcrr%2Finvoicing-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsarcrr%2Finvoicing-integration/lists"}