InterfaceTalerBarrTriggers
extends DolibarrTriggers
in package
Class of triggers for TalerBarr module
Table of Contents
Methods
- __construct() : mixed
- Constructor
- billValidate() : int
- On credit-note validation, attempt native Taler refund and annotate the note.
- orderValidate() : int
- Push a validated Dolibarr order to GNU Taler via TalerOrderLink helper.
- runTrigger() : int
- Function called when a Dolibarr business event is done.
- appendInvoiceNoteLine() : void
- Append a line to credit-note public note without duplication.
- deleteProduct() : int
- Delete the mapping row when a Dolibarr product is deleted.
- extractCurrencyFromAmountString() : string
- Extract currency prefix from CUR:value amount strings.
- extractHttpHint() : string
- Extract optional "hint/detail" from JSON payload embedded in exception text.
- extractHttpStatus() : int
- Extract HTTP status code from merchant exception messages.
- fetchVerifiedConfigForInstance() : TalerConfig|null
- Resolve a verified Taler config, preferring the instance if provided.
- getActiveTalerConfig() : array<string|int, mixed>
- Resolve active Taler config (username + syncdirection).
- invoiceNoteContains() : bool
- Check if a note already contains a marker (plain or entity-decoded).
- invoiceNoteHasSuccessfulRefundMarker() : bool
- Detect whether note already contains a successful refund marker for this credit note.
- isCurrencyConflictHint() : bool
- Detect whether a refund conflict hint indicates currency/state mismatch.
- mapRefundCurrencyForTaler() : string
- Map a Dolibarr-facing currency to the Taler-facing one for refund calls.
- resolveSourceInvoiceId() : int
- Resolve the source invoice for a credit note.
- summarizeCreditNotePayoutFromStatus() : array<string, float>|null
- Build per-credit-note payout summary from Taler order status payload.
- touchProductFromMovement() : int
- When a stock movement occurs we refresh the product snapshot so that the quantity cached in TalerProductLink stays coherent (optional but handy).
- upsertInvoiceNoteLineByPrefix() : void
- Upsert a note line identified by a stable prefix.
- upsertProduct() : int
- Upsert or refresh a TalerProductLink row that corresponds to a Dolibarr Product (create if missing, update snapshot otherwise).
Methods
__construct()
Constructor
public
__construct(DoliDB $db) : mixed
Parameters
- $db : DoliDB
-
Database handler
billValidate()
On credit-note validation, attempt native Taler refund and annotate the note.
public
billValidate(string $action, CommonObject $object, User $user, Translate $langs, Conf $conf) : int
Parameters
- $action : string
-
Triggered action code.
- $object : CommonObject
-
Invoice object.
- $user : User
-
Current user.
- $langs : Translate
-
Translation handler.
- $conf : Conf
-
Global configuration.
Return values
int —1 if handled/refund created, 0 if ignored or blocked.
orderValidate()
Push a validated Dolibarr order to GNU Taler via TalerOrderLink helper.
public
orderValidate(string $action, CommonObject $object, User $user, Translate $langs, Conf $conf) : int
Parameters
- $action : string
-
Triggered action code
- $object : CommonObject
-
Loaded business object (Commande expected)
- $user : User
-
Current user executing the trigger
- $langs : Translate
-
Translation handler
- $conf : Conf
-
Global configuration
Return values
int —0 if ignored or an error prevented sync, >0 if handled
runTrigger()
Function called when a Dolibarr business event is done.
public
runTrigger(string $action, CommonObject $object, User $user, Translate $langs, Conf $conf) : int
All functions "runTrigger" are triggered if the file is inside the directory core/triggers
Parameters
- $action : string
-
Event action code
- $object : CommonObject
-
Object
- $user : User
-
Object user
- $langs : Translate
-
Object langs
- $conf : Conf
-
Object conf
Return values
int —Return integer <0 if KO, 0 if no triggered ran, >0 if OK
appendInvoiceNoteLine()
Append a line to credit-note public note without duplication.
private
appendInvoiceNoteLine(Facture $invoice, string $line) : void
Parameters
- $invoice : Facture
-
Invoice object.
- $line : string
-
Line to append.
deleteProduct()
Delete the mapping row when a Dolibarr product is deleted.
private
deleteProduct(Product $prod, User $user) : int
Parameters
- $prod : Product
-
Dolibarr product
- $user : User
-
User performing the action
Return values
int —1 OK, 0 not found, <0 error
extractCurrencyFromAmountString()
Extract currency prefix from CUR:value amount strings.
private
static extractCurrencyFromAmountString(string $amountString) : string
Parameters
- $amountString : string
-
Amount candidate.
Return values
stringextractHttpHint()
Extract optional "hint/detail" from JSON payload embedded in exception text.
private
static extractHttpHint(Throwable $e) : string
Parameters
- $e : Throwable
-
Exception to inspect.
Return values
stringextractHttpStatus()
Extract HTTP status code from merchant exception messages.
private
static extractHttpStatus(Throwable $e) : int
Parameters
- $e : Throwable
-
Exception to inspect.
Return values
intfetchVerifiedConfigForInstance()
Resolve a verified Taler config, preferring the instance if provided.
private
fetchVerifiedConfigForInstance(string $instance[, string|null &$error = null ]) : TalerConfig|null
Parameters
- $instance : string
-
Taler instance name.
- $error : string|null = null
-
Filled with error details on failure.
Return values
TalerConfig|nullgetActiveTalerConfig()
Resolve active Taler config (username + syncdirection).
private
getActiveTalerConfig() : array<string|int, mixed>
Returns ['username'=>'', 'syncdirection'=>null] if none found. We might want to change it to the fetchSingletonVerified from TalerConfig
Return values
array<string|int, mixed>invoiceNoteContains()
Check if a note already contains a marker (plain or entity-decoded).
private
invoiceNoteContains(Facture $invoice, string $marker) : bool
Parameters
- $invoice : Facture
-
Invoice object.
- $marker : string
-
Marker text.
Return values
boolinvoiceNoteHasSuccessfulRefundMarker()
Detect whether note already contains a successful refund marker for this credit note.
private
invoiceNoteHasSuccessfulRefundMarker(Facture $invoice, string $marker) : bool
Failed attempts should not block retries after config/code fixes.
Parameters
- $invoice : Facture
-
Invoice object.
- $marker : string
-
Marker text.
Return values
boolisCurrencyConflictHint()
Detect whether a refund conflict hint indicates currency/state mismatch.
private
static isCurrencyConflictHint(string $hint) : bool
Parameters
- $hint : string
-
Hint extracted from backend error.
Return values
boolmapRefundCurrencyForTaler()
Map a Dolibarr-facing currency to the Taler-facing one for refund calls.
private
mapRefundCurrencyForTaler(string $currency[, TalerConfig|null $config = null ]) : string
Parameters
- $currency : string
-
Input currency candidate.
- $config : TalerConfig|null = null
-
Active configuration (for alias).
Return values
stringresolveSourceInvoiceId()
Resolve the source invoice for a credit note.
private
resolveSourceInvoiceId(Facture $creditNote) : int
Parameters
- $creditNote : Facture
-
Credit note object.
Return values
int —Source invoice id (0 if unknown).
summarizeCreditNotePayoutFromStatus()
Build per-credit-note payout summary from Taler order status payload.
private
static summarizeCreditNotePayoutFromStatus(array<string, mixed> $statusPayload, string $creditRef, float $creditAmount) : array<string, float>|null
Parameters
- $statusPayload : array<string, mixed>
-
Latest status payload.
- $creditRef : string
-
Credit-note reference.
- $creditAmount : float
-
Credit-note amount to refund.
Return values
array<string, float>|nulltouchProductFromMovement()
When a stock movement occurs we refresh the product snapshot so that the quantity cached in TalerProductLink stays coherent (optional but handy).
private
touchProductFromMovement(MouvementStock $mvmt, User $user) : int
Parameters
- $mvmt : MouvementStock
-
Movement of stock from Dolibarr
- $user : User
-
User performing the action
Return values
int —same semantics as upsertProduct()
upsertInvoiceNoteLineByPrefix()
Upsert a note line identified by a stable prefix.
private
upsertInvoiceNoteLineByPrefix(Facture $invoice, string $prefix, string $line) : void
Existing lines starting with the same prefix are replaced.
Parameters
- $invoice : Facture
-
Invoice object.
- $prefix : string
-
Stable line prefix.
- $line : string
-
Full line to store.
upsertProduct()
Upsert or refresh a TalerProductLink row that corresponds to a Dolibarr Product (create if missing, update snapshot otherwise).
private
upsertProduct(Product $prod, User $user) : int
Parameters
- $prod : Product
-
Dolibarr product
- $user : User
-
User performing the action
Return values
int —1 OK, 0 nothing done, <0 SQL / functional error