40 $invoice_number = preg_replace(
'/[^0-9]/',
'', $invoice_number);
41 $invoice_number = ltrim($invoice_number,
'0');
42 $coefficients = array(7, 3, 1);
44 $stlen_invoice_number = (int) strlen($invoice_number);
46 for ($i = 0; $i < $stlen_invoice_number; $i++) {
47 $sum += (int) $invoice_number[$stlen_invoice_number - $i - 1] * $coefficients[$i % 3];
49 $check_digit = (10 - ($sum % 10)) % 10;
50 $bank_reference_fi = $invoice_number . $check_digit;
52 $reference_with_suffix = $bank_reference_fi .
"271500";
53 $remainder = (int) bcmod($reference_with_suffix,
'97');
54 $check_digit = 98 - $remainder;
55 if ($check_digit < 10) {
56 $check_digit =
'0' . $check_digit;
58 $bank_reference =
"RF" . $check_digit . $bank_reference_fi;
60 $bank_reference = $bank_reference_fi;
65 return wordwrap($bank_reference, 4,
' ',
true);
80 if ($amount >= 0 && !empty($bank_reference)) {
81 if (substr($bank_reference, 0, 2) ===
"RF") {
82 $recipient_account = preg_replace(
'/[^0-9]/',
'', $recipient_account);
83 $recipient_account = str_pad($recipient_account, 16,
'0', STR_PAD_LEFT);
84 $referencetobarcode = preg_replace(
'/[^0-9]/',
'', $bank_reference);
85 $referencetobarcode = substr($referencetobarcode, 0, 2) . str_pad(substr($referencetobarcode, 2), 21,
'0', STR_PAD_LEFT);
86 $euros = floor(floatval($amount));
87 $cents = round((floatval($amount) - $euros) * 100);
88 $due_date = date(
'ymd', (
int) $due_date);
90 $barcodeData .= $recipient_account;
91 $barcodeData .= sprintf(
'%06d', (
int) $euros);
92 $barcodeData .= sprintf(
'%02d', (
int) $cents);
93 $barcodeData .= $referencetobarcode;
94 $barcodeData .= (int) $due_date;
95 } elseif (substr($bank_reference, 0, 2) !==
"RF") {
96 $recipient_account = preg_replace(
'/[^0-9]/',
'', $recipient_account);
97 $recipient_account = str_pad($recipient_account, 16,
'0', STR_PAD_LEFT);
98 $referencetobarcode = preg_replace(
'/[^0-9]/',
'', $bank_reference);
99 $euros = floor(floatval($amount));
100 $cents = round((floatval($amount) - $euros) * 100);
101 $due_date = date(
'ymd', (
int) $due_date);
103 $barcodeData .= $recipient_account;
104 $barcodeData .= sprintf(
'%06d', (
int) $euros);
105 $barcodeData .= sprintf(
'%02d', (
int) $cents);
106 $barcodeData .=
'000';
107 $barcodeData .= str_pad($referencetobarcode, 20,
'0', STR_PAD_LEFT);
108 $barcodeData .= (int) $due_date;
dolFIGenerateInvoiceBarcodeData($recipient_account, $amount, $bank_reference, $due_date)
Calculate payment Barcode data with FI/RF bank payment reference number.