Documentation

TalerProductLink extends CommonObject
in package

Class TalerProductLink

Link table object between a Dolibarr Product and its representation in the Taler Merchant Backend. Holds mapping keys, last sync info, cached prices/stock and a few denormalized attributes.

Tags
license

https://www.gnu.org/licenses/ GNU Affero General Public License v3 or later

Table of Contents

Properties

$checksum_d_hex  : mixed
$checksum_t_hex  : mixed
$datec  : mixed
$element  : string
$entity  : mixed
$fields  : mixed
$fk_product  : mixed
$fk_unit  : mixed
$isextrafieldmanaged  : int
$ismultientitymanaged  : int|string
$last_error_code  : mixed
$last_error_message  : mixed
$last_sync_at  : mixed
$last_sync_status  : mixed
$lastsync_is_push  : mixed
$module  : string
$picto  : string
$price_is_ttc  : mixed
$product_ref_snap  : mixed
$product_tms_snap  : mixed
$rowid  : mixed
$sync_enabled  : mixed
$syncdirection_override  : mixed
$table_element  : string
$taler_address_json  : mixed
$taler_amount_str  : mixed
$taler_categories_json  : mixed
$taler_currency  : mixed
$taler_description  : mixed
$taler_fraction  : mixed
$taler_image_hash  : mixed
$taler_instance  : mixed
$taler_minimum_age  : mixed
$taler_next_restock  : mixed
$taler_product_id  : mixed
$taler_product_name  : mixed
$taler_taxes_json  : mixed
$taler_total_lost  : mixed
$taler_total_sold  : mixed
$taler_total_stock  : mixed
$taler_value  : mixed
$tms  : mixed

Methods

__construct()  : mixed
Constructor
amountStrFromPrice()  : string
Convert a numeric price to the Taler “amount” string, e.g. 12.5 EUR → "EUR:12.50".
buildVatDiagnosis()  : array<string, mixed>
Derive VAT diagnostics and a safe tax suggestion for UI warnings.
computeSha256Hex()  : string
Compute SHA-256 hex of normalized data
create()  : int
Create record in database
createDolibarrProductFromTalerDetail()  : int
Create a Dolibarr Product from a Taler ProductDetail and (optionally) create the link row.
delete()  : int
Delete object from database
deleteOnTaler()  : bool
Delete the product on the Taler backend.
dolibarrArrayFromTalerDetail()  : array<string|int, mixed>
Create a Dolibarr product "field array" from a Taler ProductDetail.
fetch()  : int
Fetch object from database
fetchByInstancePid()  : int
Fetch by Taler instance and product id
fetchByProductId()  : int
Fetch by Dolibarr product id
fillPriceFromAmountStr()  : void
Populate price fields from taler_amount_str
getLabelForList()  : string
Build a concise label for lists.
getNomUrl()  : string
Get HTML link for this object (standard Dolibarr pattern).
markSyncResult()  : void
Mark synchronization result
parseTalerAmount()  : array<string|int, mixed>
Parse Taler amount string
prepareFromDolibarrAndTalerDetail()  : $this
Prepare this link row from a Dolibarr product AND a Taler ProductDetail (partial or full).
pullFromTaler()  : bool
Pull latest product data from Taler and (optionally) update Dolibarr.
pushToTaler()  : bool
Push (create or update) the linked Dolibarr product to the Taler inventory.
setDolibarrSnapshot()  : void
Save Dolibarr product reference + timestamp snapshot
talerAmountFromFloat()  : string
Build Taler amount string from float
talerDetailFromDolibarrProduct()  : array<string|int, mixed>
Build a Taler ProductDetail array from a Dolibarr Product.
talerPayloadFromDolibarr()  : array<string|int, mixed>
Backward-compatible payload wrapper
update()  : int
Update object into database
upsertFromDolibarr()  : int
Idempotent upsert driven by a *Dolibarr* product.
upsertFromTaler()  : int
Idempotent upsert driven by a *Taler* ProductDetail array/object.
_canon()  : string
Deterministic JSON encoding for hash calculation.
_checksumDoli()  : string
Compute SHA-256 on a subset of Dolibarr product fields (canonicalized).
amountStringToFloat()  : float|null
Convert "CUR:amount" into float, null on error.
applyVatToProduct()  : void
Apply VAT details to a Product object.
buildTaxesForDolibarrProduct()  : array<string|int, mixed>
Build a spec-compliant Tax[] array from a Dolibarr product line.
fetchVatDetails()  : array<string, mixed>|null
Fetch VAT details from c_tva to apply on Product.
findNearestVat()  : array{fk_c_tva: int, rate: float, diff: float}|null
Find the nearest active VAT line in Dolibarr's dictionary.
getMerchantClient()  : TalerMerchantClient|null
Build a ready-to-use TalerMerchantClient for this link.
guessDecimalsFromAmount()  : int
Guess how many decimals are present in a Taler amount string.
log()  : void
Lightweight logger wrapper to keep messages consistent.
logTalerError()  : void
Lightweight wrapper to persist an error row (if the table/class exists).
parseTaxAmountToFloat()  : float|null
Parse a tax amount coming from Taler into float, updating decimals/currency hints.
resolveInstanceFromConfig()  : string
Resolve instance from TalerConfig if available
resolveUnitCodeById()  : string
Get unit code from fk_unit
resolveUnitIdByCode()  : int|null
Get unit id from code
resolveVatFromTalerTaxes()  : array{rate: float|null, fk_c_tva: int|null}
Try to resolve VAT rate/fk_c_tva from Taler taxes + price.

Properties

$fields

public mixed $fields = array('rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'visible' => 0, 'notnull' => 1, 'index' => 1, 'position' => 1), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'visible' => 0, 'notnull' => 1, 'default' => 1, 'index' => 1, 'position' => 5), 'fk_product' => array('type' => 'integer:Product:product/class/product.class.php', 'label' => 'Product', 'visible' => 1, 'notnull' => 0, 'index' => 1, 'position' => 10, 'picto' => 'product'), 'product_ref_snap' => array('type' => 'varchar(64)', 'label' => 'ProductRefSnap', 'visible' => 1, 'notnull' => 0, 'position' => 12, 'enabled' => '1'), 'product_tms_snap' => array('type' => 'datetime', 'label' => 'ProductTMSSnap', 'visible' => 0, 'notnull' => 0, 'position' => 13, 'enabled' => '1'), 'taler_instance' => array('type' => 'varchar(64)', 'label' => 'TalerInstance', 'visible' => 1, 'notnull' => 1, 'index' => 1, 'position' => 20, 'enabled' => '1'), 'taler_product_id' => array('type' => 'varchar(128)', 'label' => 'TalerProductId', 'visible' => 1, 'notnull' => 1, 'index' => 1, 'position' => 21, 'enabled' => '1'), 'taler_product_name' => array('type' => 'varchar(128)', 'label' => 'TalerProdName', 'visible' => 1, 'notnull' => 1, 'position' => 22, 'enabled' => '1'), 'taler_description' => array('type' => 'varchar(2048)', 'label' => 'TalerDescription', 'visible' => 1, 'notnull' => 1, 'position' => 23, 'enabled' => '1'), 'taler_amount_str' => array('type' => 'varchar(64)', 'label' => 'TalerAmountStr', 'visible' => 1, 'notnull' => 0, 'position' => 30, 'help' => 'e.g. EUR:12.34', 'enabled' => '1'), 'taler_currency' => array('type' => 'varchar(16)', 'label' => 'Currency', 'visible' => 1, 'notnull' => 0, 'position' => 31, 'enabled' => '1'), 'taler_value' => array('type' => 'integer', 'label' => 'MajorUnits', 'visible' => 1, 'notnull' => 0, 'position' => 32, 'help' => 'Integer units'), 'taler_fraction' => array('type' => 'integer', 'label' => 'Fraction1e8', 'visible' => 1, 'notnull' => 0, 'position' => 33, 'help' => '0..99,999,999'), 'price_is_ttc' => array('type' => 'boolean', 'label' => 'PriceTTC', 'visible' => 1, 'notnull' => 1, 'default' => 1, 'position' => 34), 'fk_unit' => array('type' => 'integer', 'label' => 'Unit', 'visible' => 1, 'notnull' => 0, 'position' => 40), 'taler_total_stock' => array('type' => 'integer', 'label' => 'TotalStock', 'visible' => 1, 'notnull' => 0, 'position' => 41, 'default' => -1, 'help' => '-1 means infinite', 'enabled' => '1'), 'taler_total_sold' => array('type' => 'integer', 'label' => 'TotalSold', 'visible' => 1, 'notnull' => 0, 'position' => 42, 'enabled' => '1'), 'taler_total_lost' => array('type' => 'integer', 'label' => 'TotalLost', 'visible' => 1, 'notnull' => 0, 'position' => 43, 'enabled' => '1'), 'taler_categories_json' => array('type' => 'text', 'label' => 'TalerCategoriesJSON', 'visible' => 1, 'notnull' => 0, 'position' => 50, 'enabled' => '1'), 'taler_taxes_json' => array('type' => 'text', 'label' => 'TalerTaxesJSON', 'visible' => 1, 'notnull' => 0, 'position' => 51, 'enabled' => '1'), 'taler_address_json' => array('type' => 'text', 'label' => 'TalerAddressJSON', 'visible' => 1, 'notnull' => 0, 'position' => 52, 'enabled' => '1'), 'taler_image_hash' => array('type' => 'varchar(64)', 'label' => 'ImageHash', 'visible' => 0, 'notnull' => 0, 'position' => 53), 'taler_next_restock' => array('type' => 'datetime', 'label' => 'NextRestock', 'visible' => 1, 'notnull' => 0, 'position' => 54, 'enabled' => '1'), 'taler_minimum_age' => array('type' => 'integer', 'label' => 'MinimumAge', 'visible' => 1, 'notnull' => 0, 'position' => 55, 'enabled' => '1'), 'sync_enabled' => array('type' => 'boolean', 'label' => 'SyncEnabled', 'visible' => 1, 'notnull' => 1, 'default' => 1, 'position' => 60, 'index' => 1), 'syncdirection_override' => array('type' => 'integer', 'label' => 'SyncDirectionOverride', 'visible' => 1, 'notnull' => 0, 'position' => 61, 'arrayofkeyval' => array('1' => 'PullTalerToDoli', '0' => 'PushDoliToTaler')), 'lastsync_is_push' => array('type' => 'integer', 'label' => 'LastSyncIsPush', 'visible' => 0, 'notnull' => 0, 'position' => 70, 'arrayofkeyval' => array('0' => 'Pull', '1' => 'Push')), 'last_sync_status' => array('type' => 'varchar(16)', 'label' => 'LastSyncStatus', 'visible' => 1, 'notnull' => 0, 'position' => 71, 'arrayofkeyval' => array('ok' => 'OK', 'error' => 'Error', 'conflict' => 'Conflict')), 'last_sync_at' => array('type' => 'datetime', 'label' => 'LastSyncAt', 'visible' => 1, 'notnull' => 0, 'position' => 72), 'last_error_code' => array('type' => 'varchar(64)', 'label' => 'LastErrorCode', 'visible' => 0, 'notnull' => 0, 'position' => 73), 'last_error_message' => array('type' => 'text', 'label' => 'LastErrorMessage', 'visible' => 0, 'notnull' => 0, 'position' => 74), 'checksum_d_hex' => array('type' => 'varchar(64)', 'label' => 'ChecksumD', 'visible' => 0, 'notnull' => 0, 'position' => 80), 'checksum_t_hex' => array('type' => 'varchar(64)', 'label' => 'ChecksumT', 'visible' => 0, 'notnull' => 0, 'position' => 81), 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'visible' => -2, 'notnull' => 0, 'position' => 500), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'visible' => -2, 'notnull' => 1, 'position' => 501))

Methods

__construct()

Constructor

public __construct(DoliDB $db) : mixed
Parameters
$db : DoliDB

Database handler

amountStrFromPrice()

Convert a numeric price to the Taler “amount” string, e.g. 12.5 EUR → "EUR:12.50".

public static amountStrFromPrice(float $price, string $currency[, int $scale = 2 ]) : string
Parameters
$price : float

Positive decimal amount (major units)

$currency : string

ISO-4217 code, case-insensitive

$scale : int = 2

Max decimals to keep (Taler allows up to 8)

Return values
string —

Formatted "<CUR>:" string

buildVatDiagnosis()

Derive VAT diagnostics and a safe tax suggestion for UI warnings.

public static buildVatDiagnosis(string|null $taxJson, string|null $priceStr, DoliDB $db) : array<string, mixed>
Parameters
$taxJson : string|null

JSON from taler_taxes_json.

$priceStr : string|null

Taler price string (CUR:amount).

$db : DoliDB

DB handler.

Return values
array<string, mixed> —

Diagnostic payload (rates, amounts, suggestion).

computeSha256Hex()

Compute SHA-256 hex of normalized data

public static computeSha256Hex(array<string|int, mixed>|object|string $data) : string
Parameters
$data : array<string|int, mixed>|object|string

Input data

Return values
string —

Hash string

create()

Create record in database

public create(User $user[, int $notrigger = 0 ]) : int
Parameters
$user : User

User performing the action

$notrigger : int = 0

1=do not call triggers

Return values
int —

0 if OK, <0 if error

createDolibarrProductFromTalerDetail()

Create a Dolibarr Product from a Taler ProductDetail and (optionally) create the link row.

public createDolibarrProductFromTalerDetail(array<string|int, mixed>|object $detail, User $user[, array<string|int, mixed> $opts = [] ]) : int

If no config/instance is available, the product is still created and we skip creating the link.

Parameters
$detail : array<string|int, mixed>|object

ProductDetail

$user : User

User performing the action

$opts : array<string|int, mixed> = []

['instance'=>string, 'taler_product_id'=>string, 'create_link'=>bool (true)]

Return values
int —

Product ID (>0) or -1 on error

delete()

Delete object from database

public delete(User $user[, int $notrigger = 0 ]) : int
Parameters
$user : User

User performing the action

$notrigger : int = 0

1=do not call triggers

Return values
int —

0 if OK, <0 if error

deleteOnTaler()

Delete the product on the Taler backend.

public deleteOnTaler(User $user) : bool
Parameters
$user : User

User performing the action

Return values
bool —

true on 204, false otherwise

dolibarrArrayFromTalerDetail()

Create a Dolibarr product "field array" from a Taler ProductDetail.

public static dolibarrArrayFromTalerDetail(array<string|int, mixed>|object $detail[, float|null $vatRate = null ]) : array<string|int, mixed>

Since Taler price is TTC when non-zero, we set price_base_type='TTC' and compute HT if VAT is provided.

Parameters
$detail : array<string|int, mixed>|object

ProductDetail

$vatRate : float|null = null

Optional override VAT rate (percentage) if you want to force a specific VAT

Return values
array<string|int, mixed> —

Dolibarr product fields

fetch()

Fetch object from database

public fetch(int $id[, string|null $ref = null ][, int $noextrafields = 1 ][, int $nolines = 1 ]) : int
Parameters
$id : int

Rowid

$ref : string|null = null

Optional reference

$noextrafields : int = 1

1 = do not load extrafields

$nolines : int = 1

1 = do not load lines

Return values
int —

0 if OK, 0 if not found, <0 if error

fetchByInstancePid()

Fetch by Taler instance and product id

public fetchByInstancePid(string $instance, string $pid) : int
Parameters
$instance : string

Taler instance

$pid : string

Taler product id

Return values
int —

0 if OK, 0 if not found, <0 if error

fetchByProductId()

Fetch by Dolibarr product id

public fetchByProductId(int $fk_product) : int
Parameters
$fk_product : int

Dolibarr product rowid

Return values
int —

0 if OK, 0 if not found, <0 if error

fillPriceFromAmountStr()

Populate price fields from taler_amount_str

public fillPriceFromAmountStr() : void

getLabelForList()

Build a concise label for lists.

public getLabelForList() : string
Return values
string

getNomUrl()

Get HTML link for this object (standard Dolibarr pattern).

public getNomUrl([int $withpicto = 0 ][, string $option = '' ][, int $notooltip = 0 ][, string $morecss = '' ][, int $save_lastsearch_value = -1 ]) : string
Parameters
$withpicto : int = 0

Add picto (0=no, 1=with, 2=only picto)

$option : string = ''

'nolink' to return a span instead of anchor

$notooltip : int = 0

1 to disable tooltip

$morecss : string = ''

Extra CSS classes on the link

$save_lastsearch_value : int = -1

See CommonObject::getNomUrl

Return values
string —

HTML

markSyncResult()

Mark synchronization result

public markSyncResult(bool $isPush, string $status[, string|null $code = null ][, string|null $message = null ][, int|null $ts = null ]) : void
Parameters
$isPush : bool

True if push, false if pull

$status : string

Sync status

$code : string|null = null

Optional error code

$message : string|null = null

Optional error message

$ts : int|null = null

Optional timestamp

parseTalerAmount()

Parse Taler amount string

public static parseTalerAmount(string $amountStr) : array<string|int, mixed>
Parameters
$amountStr : string

Amount string (aka "CUR:12.34")

Return values
array<string|int, mixed> —

['currency'=>string,'value'=>int|null,'fraction'=>int|null]

prepareFromDolibarrAndTalerDetail()

Prepare this link row from a Dolibarr product AND a Taler ProductDetail (partial or full).

public prepareFromDolibarrAndTalerDetail(Product $prod[, array<string|int, mixed>|object|null $detail = null ][, array<string|int, mixed> $opts = [] ]) : $this

Useful if you have both objects and want to mirror extra fields (taxes, address, etc.).

Parameters
$prod : Product

Product from dolibarr

$detail : array<string|int, mixed>|object|null = null

ProductDetail

$opts : array<string|int, mixed> = []

['instance'=>string]

Return values
$this

pullFromTaler()

Pull latest product data from Taler and (optionally) update Dolibarr.

public pullFromTaler(User $user[, bool $writeDoli = true ][, string|null $productId = null ]) : bool
Parameters
$user : User

User performing the action

$writeDoli : bool = true

true = update or create Dolibarr product when missing

$productId : string|null = null

productId which we have to update

Return values
bool —

true on success, false on failure

pushToTaler()

Push (create or update) the linked Dolibarr product to the Taler inventory.

public pushToTaler(User $user, Product $prod) : bool
Parameters
$user : User

User performing the action

$prod : Product

Dolibarr product to export (already loaded)

Return values
bool —

true on success, false on failure (errors logged & set)

setDolibarrSnapshot()

Save Dolibarr product reference + timestamp snapshot

public setDolibarrSnapshot(Product $prod) : void
Parameters
$prod : Product

Dolibarr product

talerAmountFromFloat()

Build Taler amount string from float

public static talerAmountFromFloat(float $price, string $currency) : string
Parameters
$price : float

Price as number

$currency : string

Currency (e.g. EUR)

Return values
string

talerDetailFromDolibarrProduct()

Build a Taler ProductDetail array from a Dolibarr Product.

public talerDetailFromDolibarrProduct(Product $prod[, array<string|int, mixed> $opts = [] ]) : array<string|int, mixed>

Price is exported as TTC Amount (as required by Taler).

Parameters
$prod : Product

Product from dolibarr

$opts : array<string|int, mixed> = []

['instance'=>string] // optional, not embedded in ProductDetail but used for category mapping

Return values
array<string|int, mixed> —

ProductDetail

talerPayloadFromDolibarr()

Backward-compatible payload wrapper

public static talerPayloadFromDolibarr(Product $prod[, TalerConfig|null $cfg = null ][, array<string|int, mixed> $opts = [] ]) : array<string|int, mixed>
Parameters
$prod : Product

Product from dolibarr

$cfg : TalerConfig|null = null

Taler config

$opts : array<string|int, mixed> = []

Options array

Return values
array<string|int, mixed>

update()

Update object into database

public update(User $user[, int $notrigger = 0 ]) : int
Parameters
$user : User

User performing the action

$notrigger : int = 0

1=do not call triggers

Return values
int —

0 if OK, <0 if error

upsertFromDolibarr()

Idempotent upsert driven by a *Dolibarr* product.

public static upsertFromDolibarr(DoliDB $db, Product $prod, User $user[, TalerConfig|null $cfg = null ]) : int
Parameters
$db : DoliDB

db handler

$prod : Product

Product from dolibarr

$user : User

User performing the action

$cfg : TalerConfig|null = null

(optional) pre-loaded config

Return values
int —

1 = OK, 0 = ignored (no active cfg / pull-only), -1 = functional/SQL error (already logged)

upsertFromTaler()

Idempotent upsert driven by a *Taler* ProductDetail array/object.

public static upsertFromTaler(DoliDB $db, object|array<string|int, mixed> $detail, User $user[, array<string|int, mixed> $opts = [] ]) : int
Parameters
$db : DoliDB
  • db handler
$detail : object|array<string|int, mixed>
  • full JSON object returned by the backend
$user : User
  • User performing the action
$opts : array<string|int, mixed> = []
  • ['instance'=>string] REQUIRED, plus optional ['write_dolibarr'=>bool]
Return values
int —

1=OK, 0=ignored, -1=error

_canon()

Deterministic JSON encoding for hash calculation.

private static _canon(array<string|int, mixed> $a) : string
Parameters
$a : array<string|int, mixed>

Input array

Return values
string —

Canonical JSON

_checksumDoli()

Compute SHA-256 on a subset of Dolibarr product fields (canonicalized).

private static _checksumDoli(Product $p) : string
Parameters
$p : Product

Product

Return values
string —

Hex digest

amountStringToFloat()

Convert "CUR:amount" into float, null on error.

private static amountStringToFloat(string|null $amountStr) : float|null
Parameters
$amountStr : string|null

Amount string as returned by Taler (e.g. "KUDOS:12.34")

Return values
float|null —

Parsed amount as float, or null on failure

applyVatToProduct()

Apply VAT details to a Product object.

private static applyVatToProduct(Product $prod, array{rate: float|null, fk_c_tva: int|null} $vatInfo) : void
Parameters
$prod : Product

Product to update.

$vatInfo : array{rate: float|null, fk_c_tva: int|null}

Derived VAT info from Taler.

buildTaxesForDolibarrProduct()

Build a spec-compliant Tax[] array from a Dolibarr product line.

private buildTaxesForDolibarrProduct(Product $prod, string $currency, string $instance) : array<string|int, mixed>
Parameters
$prod : Product

Source Dolibarr product

$currency : string

ISO-4217 currency code (e.g. "EUR")

$instance : string

Taler instance name (used for mapping side effects)

Return values
array<string|int, mixed> —

Array of Tax objects suitable for Taler ProductDetail

fetchVatDetails()

Fetch VAT details from c_tva to apply on Product.

private static fetchVatDetails(int $fkCtvA, DoliDB $db) : array<string, mixed>|null
Parameters
$fkCtvA : int

Rowid in c_tva.

$db : DoliDB

DB handler.

Return values
array<string, mixed>|null —

VAT fields to copy onto the product, or null on failure

findNearestVat()

Find the nearest active VAT line in Dolibarr's dictionary.

private static findNearestVat(float $ratePercent, DoliDB $db[, int|null $countryId = null ]) : array{fk_c_tva: int, rate: float, diff: float}|null
Parameters
$ratePercent : float

Target VAT rate in percent.

$db : DoliDB

DB handler.

$countryId : int|null = null

Optional country filter (fk_pays); defaults to company country.

Return values
array{fk_c_tva: int, rate: float, diff: float}|null —

Nearest VAT info or null if none.

guessDecimalsFromAmount()

Guess how many decimals are present in a Taler amount string.

private static guessDecimalsFromAmount(string $amountStr) : int
Parameters
$amountStr : string

Raw amount string (e.g., "EUR:3.65000000").

Return values
int —

Number of decimals to keep (min 2, max 8).

log()

Lightweight logger wrapper to keep messages consistent.

private log(string $method[, array<string|int, mixed> $ctx = [] ][, int $level = LOG_DEBUG ]) : void
Parameters
$method : string

Method or action name

$ctx : array<string|int, mixed> = []

Context payload to JSON-encode (kept small)

$level : int = LOG_DEBUG

LOG_DEBUG|LOG_INFO|LOG_WARNING|LOG_ERR

logTalerError()

Lightweight wrapper to persist an error row (if the table/class exists).

private logTalerError(string $context, string $operation, string $message) : void
Parameters
$context : string

'product' | 'category' | ...

$operation : string

'push' | 'fetch' | ...

$message : string

human readable

parseTaxAmountToFloat()

Parse a tax amount coming from Taler into float, updating decimals/currency hints.

private static parseTaxAmountToFloat(mixed $rawAmount, int &$decimals, string &$currency) : float|null
Parameters
$rawAmount : mixed

Raw tax amount (string or structured array).

$decimals : int

Current decimals guess (updated in-place).

$currency : string

Current currency guess (updated in-place).

Return values
float|null —

Parsed float amount or null if unavailable.

resolveInstanceFromConfig()

Resolve instance from TalerConfig if available

private resolveInstanceFromConfig() : string
Return values
string —

Instance or ''

resolveUnitCodeById()

Get unit code from fk_unit

private resolveUnitCodeById(int|null $fk_unit) : string
Parameters
$fk_unit : int|null

Foreign key of the unit

Return values
string

resolveUnitIdByCode()

Get unit id from code

private resolveUnitIdByCode(string|null $code) : int|null
Parameters
$code : string|null

code

Return values
int|null

resolveVatFromTalerTaxes()

Try to resolve VAT rate/fk_c_tva from Taler taxes + price.

private static resolveVatFromTalerTaxes(array<string|int, mixed>|object $detail, string $instance, DoliDB $db) : array{rate: float|null, fk_c_tva: int|null}
Parameters
$detail : array<string|int, mixed>|object

Taler product detail

$instance : string

Taler instance name

$db : DoliDB

DB handler

Return values
array{rate: float|null, fk_c_tva: int|null} —

Rate in percent and matching c_tva rowid if found


        
On this page

Search results