dolibarr 25.0.0-alpha
functions_creditorref.lib.php File Reference

ISO 11649 Structured Creditor Reference (RF) functions. More...

Go to the source code of this file.

Functions

 dolCreditorRefAlphaToDigits ($str)
 Convert an alphanumeric string to its all-digit form for ISO 7064 mod-97.
 
 dolCreditorRefCheckDigits ($raw)
 Calculate the two ISO 11649 (ISO 7064 mod-97-10) check digits.
 
 dolCreditorRefMod97 ($digits)
 Remainder of a long decimal string divided by 97.
 
 dolPayRefStrip ($ref)
 Remove formatting spaces from a payment reference (machine form).
 
 dolPayRefFormat ($ref)
 Format a payment reference into groups of 4 characters (human form).
 
 dolCreditorRefGenerate ($payload, $statut)
 Generate an ISO 11649 Structured Creditor Reference from a payload.
 
 dolCreditorRefGenerateFromParts ($parts, $statut)
 Generate an ISO 11649 reference from an ordered list of parts.
 
 dolCreditorRefIsValid ($ref)
 Check that a string is a valid ISO 11649 Structured Creditor Reference.
 
 dolPayRefDetectScheme ($ref)
 Detect which structured payment reference scheme a stored value belongs to.
 

Detailed Description

ISO 11649 Structured Creditor Reference (RF) functions.

Shared by all countries that use the RF standard (DE, GR, CH, NL, AT, FI, and any other SEPA country). Country-specific variants live in functions_<cc>.lib.php.

Definition in file functions_creditorref.lib.php.

Function Documentation

◆ dolCreditorRefAlphaToDigits()

dolCreditorRefAlphaToDigits ( $str)

Convert an alphanumeric string to its all-digit form for ISO 7064 mod-97.

Letters A-Z map to 10-35. Digits are kept. Anything else is dropped.

Parameters
string$strInput string
Returns
string All-digit string suitable for dolCreditorRefMod97()

Definition at line 35 of file functions_creditorref.lib.php.

References $c, dol_strlen(), and dol_strtoupper().

Referenced by dolCreditorRefCheckDigits().

◆ dolCreditorRefCheckDigits()

dolCreditorRefCheckDigits ( $raw)

Calculate the two ISO 11649 (ISO 7064 mod-97-10) check digits.

Leading zeros in the payload do not change the result, so a padded and an unpadded payload give the same check digits.

Parameters
string$rawRaw alphanumeric payload, no spaces
Returns
string Two-digit check string, '02' to '98'

Definition at line 62 of file functions_creditorref.lib.php.

References dolCreditorRefAlphaToDigits(), and dolCreditorRefMod97().

Referenced by dolCreditorRefIsValid().

◆ dolCreditorRefGenerate()

dolCreditorRefGenerate ( $payload,
$statut )

Generate an ISO 11649 Structured Creditor Reference from a payload.

Result is 'RF' + 2 check digits + payload, at most 25 characters. The payload must be 1 to 21 alphanumeric characters after sanitisation.

Parameters
string$payloadAlphanumeric payload, max 21 chars after cleaning
int<0,3>$statut Object status. Returns '' when lower than 1.
Returns
string Compact RF reference, or '' on error

Definition at line 121 of file functions_creditorref.lib.php.

References dol_strlen(), dol_strtoupper(), and dol_syslog().

Referenced by dolCreditorRefGenerateFromParts(), and dolPayRefBuild().

◆ dolCreditorRefGenerateFromParts()

dolCreditorRefGenerateFromParts ( $parts,
$statut )

Generate an ISO 11649 reference from an ordered list of parts.

Parts are cleaned and concatenated in order. The combined payload is truncated to 21 characters if needed.

Parameters
string[]$partsOrdered parts to combine
int<0,3>$statut Object status
Returns
string Compact RF reference, or '' on error

Definition at line 149 of file functions_creditorref.lib.php.

References dol_strlen(), dol_strtoupper(), dol_substr(), dol_syslog(), and dolCreditorRefGenerate().

Referenced by dolPayRefGenerateForInvoice().

◆ dolCreditorRefIsValid()

dolCreditorRefIsValid ( $ref)

Check that a string is a valid ISO 11649 Structured Creditor Reference.

Parameters
string$refReference to validate, with or without spaces
Returns
bool True when the format and check digits are correct

Definition at line 175 of file functions_creditorref.lib.php.

References dol_strlen(), dol_substr(), dolCreditorRefCheckDigits(), and dolPayRefStrip().

Referenced by CompanyBankAccount\checkPaymentReference(), dolGRIsAmountCheckedReference(), dolPayRefBuild(), and dolPayRefGetSetupWarning().

◆ dolCreditorRefMod97()

dolCreditorRefMod97 ( $digits)

Remainder of a long decimal string divided by 97.

The numbers used by ISO 7064 are far larger than an integer can hold, so the string is consumed in small pieces and only the remainder is carried over. Pieces of 7 digits keep every intermediate value below 2^31, so this works on a 32 bit build and needs no extension.

Parameters
string$digitsDecimal string, digits only
Returns
int<0,96> Remainder

Definition at line 79 of file functions_creditorref.lib.php.

Referenced by dolCreditorRefCheckDigits(), and dolFICalculatePaymentReference().

◆ dolPayRefDetectScheme()

dolPayRefDetectScheme ( $ref)

Detect which structured payment reference scheme a stored value belongs to.

Used by the SEPA XML builder and the QR code builders so no extra database column is needed to remember how a reference was produced.

Parameters
string$refStored payment reference
Returns
string 'SCOR' for ISO 11649, 'BBA' for Belgian OGM-VCS, 'QRR' for a Swiss QR reference, 'FI' for a Finnish national reference, '' if unknown

Definition at line 200 of file functions_creditorref.lib.php.

References dol_substr(), and dolPayRefStrip().

Referenced by CommonInvoice\buildSwitzerlandQRString(), CompanyBankAccount\checkPaymentReference(), dolPayRefFormatForDisplay(), and BonPrelevement\EnregDestinataireSEPA().

◆ dolPayRefFormat()

dolPayRefFormat ( $ref)

Format a payment reference into groups of 4 characters (human form).

Parameters
string$refReference without spaces
Returns
string Reference with a space every 4 characters

Definition at line 106 of file functions_creditorref.lib.php.

Referenced by dolPayRefFormatForDisplay().

◆ dolPayRefStrip()

dolPayRefStrip ( $ref)

Remove formatting spaces from a payment reference (machine form).

Parameters
string$refReference, with or without spaces
Returns
string Reference without spaces

Definition at line 95 of file functions_creditorref.lib.php.

Referenced by CommonInvoice\buildSwitzerlandQRString(), CompanyBankAccount\cleanPaymentReference(), dolCreditorRefIsValid(), dolGRIsAmountCheckedReference(), dolPayRefBuild(), dolPayRefDetectScheme(), dolPayRefFormatForDisplay(), and BonPrelevement\EnregDestinataireSEPA().