NEW Invoice - Generate payment information - Structured communication (#31376)
* NEW Invoice - Generate payment information - Structured communication * fix tabs/space * Add $substitutionarray['__PAYMENT_STRUCTURED_COMMUNICATION__'] * Fix travis * Move to specific file functions_be.lib.php * Fix function use * Fix code --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
9dce6c7689
commit
5dfe870c4c
9 changed files with 151 additions and 29 deletions
|
|
@ -9,6 +9,7 @@
|
|||
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -758,6 +759,17 @@ print "</select>";
|
|||
print ajax_combobox("chq", array(), 0, 0, 'resolve', '-2');
|
||||
|
||||
print "</td></tr>";
|
||||
|
||||
// Structured communication
|
||||
// Specific to Belgium - See core/lib/functions_be.lib.php
|
||||
if ($mysoc->country_code == 'BE') {
|
||||
print '<tr class="oddeven"><td>' . $langs->trans("InvoicePaymentManageStructuredCommunication") . ' ';
|
||||
print $form->textwithpicto('', $langs->trans("InvoicePaymentManageStructuredCommunicationHelp"), 1, 'help') . '</td>';
|
||||
print '<td class="left" colspan="2">';
|
||||
print ajax_constantonoff('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2018 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
* Copyright (C) 2014 Cédric GROSS <c.gross@kreiz-it.fr>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
|
|
@ -9303,6 +9303,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|||
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ? str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)) : '');
|
||||
$substitutionarray['__ONLINE_PAYMENT_URL__'] = $paymenturl;
|
||||
|
||||
// Show structured communication
|
||||
if (getDolGlobalString('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION') && $object->element == 'facture') {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_be.lib.php';
|
||||
$substitutionarray['__PAYMENT_STRUCTURED_COMMUNICATION__'] = dolBECalculateStructuredCommunication($object->ref, $object->type);
|
||||
}
|
||||
|
||||
if (getDolGlobalString('PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD') && is_object($object) && $object->element == 'propal') {
|
||||
$substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
|
||||
} else {
|
||||
|
|
|
|||
77
htdocs/core/lib/functions_be.lib.php
Normal file
77
htdocs/core/lib/functions_be.lib.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/lib/functions_be.lib.php
|
||||
* \brief A set of belgium functions for Dolibarr
|
||||
* This file contains rare functions.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Calculate Structured Communication / BE Bank payment reference number
|
||||
*
|
||||
* @param string $invoice_number Invoice number to generate payment reference
|
||||
* @param int $invoice_type Invoice type
|
||||
* @return string String structured communication for payment
|
||||
*/
|
||||
function dolBECalculateStructuredCommunication($invoice_number, $invoice_type)
|
||||
{
|
||||
$invoice_number = preg_replace('/[^0-9]/', '', $invoice_number); // Keep only numbers
|
||||
|
||||
// We complete with 0 and take the last 8 digits of the number are used to generate the reference base.
|
||||
$invoice_number = substr('00000000'.$invoice_number, -8);
|
||||
|
||||
// Prefix with invoice type
|
||||
switch ($invoice_type) {
|
||||
case '0':
|
||||
$invoice_type = '20'; // invoice type standard
|
||||
break;
|
||||
case '1':
|
||||
$invoice_type = '30'; // invoice type replacement
|
||||
break;
|
||||
case '2':
|
||||
$invoice_type = '40'; // invoice type credit note
|
||||
break;
|
||||
case '3':
|
||||
$invoice_type = '21'; // invoice type deposit
|
||||
break;
|
||||
case '5':
|
||||
$invoice_type = '20'; // invoice type situation, force to standard
|
||||
break;
|
||||
default:
|
||||
$invoice_type = '00';
|
||||
}
|
||||
|
||||
// Calculate module97
|
||||
$invoice_number = $invoice_type.$invoice_number;
|
||||
$mod97 = intval($invoice_number) % 97;
|
||||
$controlKey = ($mod97 === 0) ? 97 : $mod97;
|
||||
|
||||
// Add the check digit at the end of the reference
|
||||
$invoice_number .= $controlKey;
|
||||
|
||||
// Format reference as XXX/XXXX/XXXXX
|
||||
$part1 = '+++'.substr($invoice_number, 0, 3);
|
||||
$part2 = substr($invoice_number, 3, 4);
|
||||
$part3 = substr($invoice_number, 7, 5).'+++'; // Includes last 3 digits + 2 check digits
|
||||
|
||||
$invoice_number = $part1 . '/' . $part2 . '/' . $part3;
|
||||
|
||||
return $invoice_number;
|
||||
}
|
||||
|
|
@ -1,18 +1,19 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
|
||||
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
|
||||
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Nick Fragoulis
|
||||
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -1325,6 +1326,13 @@ class pdf_crabe extends ModelePDFFactures
|
|||
$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
|
||||
|
||||
$posy += 2;
|
||||
|
||||
if (getDolGlobalString('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION')) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_be.lib.php';
|
||||
$invoicePaymentKey = dolBECalculateStructuredCommunication($object->ref, $object->type);
|
||||
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('StructuredCommunication').": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0, 'L', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1528,6 +1528,14 @@ class pdf_octopus extends ModelePDFFactures
|
|||
$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
|
||||
|
||||
$posy += 2;
|
||||
|
||||
// Show structured communication
|
||||
if (getDolGlobalString('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION')) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_be.lib.php';
|
||||
$invoicePaymentKey = dolBECalculateStructuredCommunication($object->ref, $object->type);
|
||||
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('StructuredCommunication').": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0, 'L', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
|
||||
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Nick Fragoulis
|
||||
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
|
||||
* Copyright (C) 2022-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Nick Fragoulis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -1449,6 +1449,14 @@ class pdf_sponge extends ModelePDFFactures
|
|||
$pdf->MultiCell(30, 3, $langs->trans("INVOICE_ADD_EPC_QR_CODEPay"), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 2;
|
||||
}
|
||||
|
||||
// Show structured communication
|
||||
if (getDolGlobalString('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION')) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_be.lib.php';
|
||||
$invoicePaymentKey = dolBECalculateStructuredCommunication($object->ref, $object->type);
|
||||
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('StructuredCommunication').": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0, 'L', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
-- along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
CREATE TABLE llx_webhook_target(
|
||||
CREATE TABLE llx_webhook_target (
|
||||
-- BEGIN MODULEBUILDER FIELDS
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
ref varchar(128) NOT NULL,
|
||||
|
|
|
|||
|
|
@ -1487,6 +1487,8 @@ ForceInvoiceDate=Force invoice date to validation date
|
|||
SuggestedPaymentModesIfNotDefinedInInvoice=Suggested payments mode on invoice by default if not defined on the invoice
|
||||
SuggestPaymentByRIBOnAccount=Suggest payment by withdrawal on account
|
||||
SuggestPaymentByChequeToAddress=Suggest payment by check to
|
||||
InvoicePaymentManageStructuredCommunication=Generate structured communication for invoice payment
|
||||
InvoicePaymentManageStructuredCommunicationHelp=In some countries, it is necessary to display a structured reference to facilitate payments and their reconciliation
|
||||
FreeLegalTextOnInvoices=Free text on invoices
|
||||
WatermarkOnDraftInvoices=Watermark on draft invoices (none if empty)
|
||||
PaymentsNumberingModule=Payments numbering model
|
||||
|
|
|
|||
|
|
@ -514,6 +514,7 @@ PrettyLittleSentence=Accept the amount of payments due by checks issued in my na
|
|||
IntracommunityVATNumber=Intra-Community VAT ID
|
||||
PaymentByChequeOrderedTo=Check payments (including tax) are payable to %s, send to
|
||||
PaymentByChequeOrderedToShort=Check payments (incl. tax) are payable to
|
||||
StructuredCommunication=Structured communication
|
||||
SendTo=sent to
|
||||
PaymentByTransferOnThisBankAccount=Payment by transfer to the following bank account
|
||||
VATIsNotUsedForInvoice=* Non applicable VAT art-293B of CGI
|
||||
|
|
|
|||
Loading…
Reference in a new issue