74 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_creditorref.lib.php';
110 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_creditorref.lib.php';
111 $alreadycomplete = ($mode ==
'company'
114 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_gr.lib.php';
115 $diascode = preg_replace(
'/[^0-9]/',
'',
getDolGlobalString(
'MAIN_INFO_SOCIETE_DIAS_CODE'));
119 if ($mode ==
'thirdparty') {
120 return 'WarningPaymentRefDIASCodeMissingThirdparty';
122 return 'WarningPaymentRefDIASCodeMissing';
127 return 'WarningPaymentRefPaymentIdMissing';
133 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_gr.lib.php';
135 return 'ErrorDIASReferenceAmountChecked';
163 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_creditorref.lib.php';
168 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_gr.lib.php';
170 dol_syslog(
'dolPayRefBuild: greek reference '.$payment_id.
' checks a fixed amount, not used', LOG_WARNING);
180 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_fi.lib.php';
188 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
192 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_fi.lib.php';
193 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_creditorref.lib.php';
201 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_gr.lib.php';
205 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_creditorref.lib.php';
239 if (empty($mode) || $mode ===
'disabled' || !is_object(
$object)) {
244 $country_code = empty(
$mysoc->country_code) ?
'' :
$mysoc->country_code;
249 if (!is_object(
$object->thirdparty)) {
255 if ($mode ===
'company') {
258 } elseif ($mode ===
'thirdparty') {
260 if (!empty(
$object->thirdparty->tp_payment_reference)) {
261 $ref =
$object->thirdparty->tp_payment_reference;
269 if ($ref !==
'' && $store) {
270 $object->thirdparty->setValueFrom(
'tp_payment_reference', $ref,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
271 $object->thirdparty->tp_payment_reference = $ref;
274 } elseif ($mode ===
'invoice') {
280 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_creditorref.lib.php';
283 $ref =
dolPayRefBuild(implode(
'', $parts), $statut, $country_code, $type);
288 dol_syslog(
'dolPayRefGenerateForInvoice: no reference produced for '.
$object->ref.
' mode '.$mode, LOG_WARNING);
294 dol_syslog(
'dolPayRefGenerateForInvoice: reference longer than 25 chars, not stored', LOG_WARNING);
298 if ($store && $statut >= 1) {
299 $object->setValueFrom(
'payment_reference', $ref,
'',
null,
'text',
'', $user,
'BILL_MODIFY');
300 $object->payment_reference = $ref;
320 if ($field ==
'code_fournisseur' && !empty($thirdparty->code_fournisseur)) {
321 return (
string) $thirdparty->code_fournisseur;
323 if ($field ==
'code_client' && !empty($thirdparty->code_client)) {
324 return (
string) $thirdparty->code_client;
326 if ($field ==
'rowid') {
327 return (
string) $thirdparty->id;
331 if (!empty($thirdparty->code_client)) {
332 return (
string) $thirdparty->code_client;
334 if (!empty($thirdparty->code_fournisseur)) {
335 return (
string) $thirdparty->code_fournisseur;
338 return (
string) $thirdparty->id;
353 $allowed = array(
'customer_code',
'contract_ref',
'invoice_ref');
356 foreach (explode(
',', $wanted) as $part) {
358 if (!in_array($part, $allowed)) {
363 if ($part ===
'customer_code' && is_object(
$object->thirdparty)) {
364 $value = (string)
$object->thirdparty->code_client;
365 } elseif ($part ===
'contract_ref') {
367 } elseif ($part ===
'invoice_ref') {
368 $value = (string)
$object->ref;
391 $sql =
"SELECT c.ref";
392 $sql .=
" FROM ".$object->db->prefix().
"contrat as c";
393 $sql .=
" INNER JOIN ".$object->db->prefix().
"element_element as ee ON ee.fk_source = c.rowid";
394 $sql .=
" WHERE ee.sourcetype = 'contrat'";
395 $sql .=
" AND ee.targettype = 'facture'";
396 $sql .=
" AND ee.fk_target = ".((int)
$object->id);
397 $sql .=
" AND c.entity IN (".getEntity(
'contract').
")";
398 $sql .=
" ORDER BY c.rowid ASC";
399 $sql .=
$object->db->plimit(1);
401 $resql =
$object->db->query($sql);
403 $obj =
$object->db->fetch_object($resql);
406 return (
string) $obj->ref;
if(! $sortfield) if(! $sortorder) $object
Superclass for invoice classes.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dolBECalculateStructuredCommunication($invoice_number, $invoice_type)
Calculate Structured Communication / BE Bank payment reference number.
dolCreditorRefIsValid($ref)
Check that a string is a valid ISO 11649 Structured Creditor Reference.
dolCreditorRefGenerateFromParts($parts, $statut)
Generate an ISO 11649 reference from an ordered list of parts.
dolPayRefStrip($ref)
Remove formatting spaces from a payment reference (machine form).
dolPayRefDetectScheme($ref)
Detect which structured payment reference scheme a stored value belongs to.
dolCreditorRefGenerate($payload, $statut)
Generate an ISO 11649 Structured Creditor Reference from a payload.
dolPayRefFormat($ref)
Format a payment reference into groups of 4 characters (human form).
dolFIIsValidReference($reference)
Check that a string is a valid finnish national reference.
dolFICalculatePaymentReference($invoice_number, $statut, $use_rf)
Calculate Creditor Reference RF / FI Bank payment reference number.
dolGRCalculateCreditorReference($payment_id, $statut, $dias_code='', $usage='')
Calculate a greek DIAS RF Structured Creditor Reference.
dolGRIsValidDiasCode($dias_code)
Check a DIAS creditor code.
dolGRIsAmountCheckedReference($ref)
Tell if a greek DIAS reference asks the paying bank for an amount check.
dolPayRefGetLinkedContractRef($object)
Return the reference of the first contract linked to an invoice.
dolPayRefBuild($payment_id, $statut, $country_code, $invoice_type=0)
Build a structured payment reference from a payment id, for a country.
dolPayRefGetThirdpartyBase($thirdparty)
Return the value a third party builds its payment reference from.
dolPayRefCollectParts($object)
Collect the ordered parts used to build a per invoice reference.
dolPayRefGetSetupWarning($country_code, $mode='')
Return the setup that is still missing before references can be generated.
dolPayRefGetSchemeForCountry($country_code)
Return the payment reference scheme to use for a country.
dolPayRefGenerateForInvoice($object, $user, $store=1)
Generate and optionally store the payment reference of an invoice.
dolPayRefFormatForDisplay($ref, $country_code='')
Format a payment reference the way its country prints it.