Blesta Source Documentation

ElectronicInvoices extends AppModel

Electronic Invoice management

Table of Contents

Methods

__construct() Initialize ElectronicInvoices
clearCache() Clears the electronic invoice cache
download() Downloads an electronic invoice in the specified format Checks cache first, then generates if not cached
fetchCache() Fetches a cached electronic invoice
generate() Generates an electronic invoice in the specified format
generateAll() Generates all enabled electronic invoice formats for a given invoice
updateCache() Updates the cache for an invoice by clearing old cache and regenerating all formats
writeCache() Writes an electronic invoice to cache
getEnabledFormats() Gets the list of enabled electronic invoice formats for the current company
isCacheEnabled() Checks if caching is enabled for electronic invoices
isFormatEnabled() Checks if a format is enabled for the current company
Methods

clearCache()

Clears the electronic invoice cache

public clearCache(int $invoice_id[, string $format = null ]) : bool
Parameters
$invoice_id : int

The ID of the invoice to clear

$format : string = null

The format to clear, or null to clear all formats for this invoice

Return values
bool

True if the cache has been deleted successfully, false otherwise

download()

Downloads an electronic invoice in the specified format Checks cache first, then generates if not cached

public download(int $invoice_id, string $format) : bool
Parameters
$invoice_id : int

The ID of the invoice to download

$format : string

The format to download (e.g., 'ubl')

Return values
bool

True on success, false on error

fetchCache()

Fetches a cached electronic invoice

public fetchCache(int $invoice_id, string $format) : string|false
Parameters
$invoice_id : int

The ID of the invoice to fetch

$format : string

The format of the invoice to fetch

Return values
string|false

The cached content on success, false if not found

generate()

Generates an electronic invoice in the specified format

public generate(int $invoice_id, string $format) : string|false
Parameters
$invoice_id : int

The ID of the invoice to generate

$format : string

The format to generate (e.g., 'ubl')

Return values
string|false

The generated content on success, false on error

generateAll()

Generates all enabled electronic invoice formats for a given invoice

public generateAll(int $invoice_id) : array<string|int, mixed>
Parameters
$invoice_id : int

The ID of the invoice to generate

Return values
array<string|int, mixed>

An array of format => content pairs, empty array on error

updateCache()

Updates the cache for an invoice by clearing old cache and regenerating all formats

public updateCache(int $invoice_id) : bool
Parameters
$invoice_id : int

The ID of the invoice to update cache for

Return values
bool

True if cache was updated successfully, false otherwise

writeCache()

Writes an electronic invoice to cache

public writeCache(int $invoice_id, string $format, string $data) : bool
Parameters
$invoice_id : int

The ID of the invoice to cache

$format : string

The format of the invoice to cache

$data : string

The data to cache

Return values
bool

True if the invoice has been saved to cache successfully, false on error

getEnabledFormats()

Gets the list of enabled electronic invoice formats for the current company

private getEnabledFormats(array<string|int, mixed> $company_settings) : array<string|int, mixed>
Parameters
$company_settings : array<string|int, mixed>

The company settings array

Return values
array<string|int, mixed>

List of enabled format keys

isCacheEnabled()

Checks if caching is enabled for electronic invoices

private isCacheEnabled(array<string|int, mixed> $company_settings) : bool
Parameters
$company_settings : array<string|int, mixed>

The company settings array

Return values
bool

True if caching is enabled, false otherwise

isFormatEnabled()

Checks if a format is enabled for the current company

private isFormatEnabled(string $format, array<string|int, mixed> $company_settings) : bool
Parameters
$format : string

The format to check

$company_settings : array<string|int, mixed>

The company settings array

Return values
bool

True if the format is enabled, false otherwise

Tags
subpackage

app.models

copyright

Copyright (c) 2025, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results