mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-03 14:51:31 -04:00
Implementation of UBL 2.1 invoice generation to comply with Belgium's 2026 Peppol mandate. Key changes: - Add num-num/ubl-invoice dependency via composer.json - Create Ubl_generator library to convert OSPOS sale data to UBL format - Create country_helper.php to map country names to ISO 3166-1 alpha-2 codes - Extend Email_lib to support multiple attachments for PDF+UBL emails - Add getUblInvoice() method in Sales controller for UBL download - Modify getSendPdf() to optionally attach UBL based on invoice_format config - Add database migration for invoice_format configuration (pdf_only/ubl_only/both) - Add UBL download button to invoice view - Add UBL download link to sales manage table - Add language keys for UBL-related UI elements Data mapping: - Company name/address -> Supplier Party - account_number -> Company VAT number - Customer address/country -> Customer Party with ISO country code - Customer tax_id -> Customer VAT number - Cart items -> InvoiceLines - Taxes -> TaxCategory and TaxTotal - Totals -> LegalMonetaryTotal Features: - Generate valid UBL 2.1 XML invoices - Download UBL from invoice view and manage table - Email with PDF, UBL, or both based on configuration - Support for multiple customer countries with ISO code mapping - Graceful handling of missing optional customer fields
40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Libraries\InvoiceAttachment;
|
|
|
|
interface InvoiceAttachment
|
|
{
|
|
/**
|
|
* Generate the attachment content and write to a temp file.
|
|
*
|
|
* @param array $saleData The sale data from _load_sale_data()
|
|
* @param string $type The document type (invoice, tax_invoice, quote, work_order, receipt)
|
|
* @return string|null Absolute path to generated file, or null on failure
|
|
*/
|
|
public function generate(array $saleData, string $type): ?string;
|
|
|
|
/**
|
|
* Check if this attachment type is applicable for the document type.
|
|
* E.g., UBL only works for invoice/tax_invoice
|
|
*
|
|
* @param string $type The document type
|
|
* @param array $saleData The sale data (to check invoice_number existence)
|
|
* @return bool
|
|
*/
|
|
public function isApplicableForType(string $type, array $saleData): bool;
|
|
|
|
/**
|
|
* Get the file extension for this attachment.
|
|
*
|
|
* @return string E.g., 'pdf', 'xml'
|
|
*/
|
|
public function getFileExtension(): string;
|
|
|
|
/**
|
|
* Get the config values that enable this attachment.
|
|
* Returns array of config values that should generate this attachment.
|
|
*
|
|
* @return array E.g., ['pdf_only', 'both'] for PDF
|
|
*/
|
|
public function getEnabledConfigValues(): array;
|
|
} |