Merge pull request #23242 from Easya-Solutions/new-invoice-show-category-operations
NEW - Invoice - Show Category of operations
This commit is contained in:
commit
7027716d1f
@ -743,7 +743,7 @@ print load_fiche_titre($langs->trans("OtherOptions"), '', '');
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Parameter").'</td>';
|
||||
print '<td>'.$langs->trans("Parameters").'</td>';
|
||||
print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
|
||||
print '<td width="80"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks', 'Trips'));
|
||||
$langs->loadLangs(array('admin', 'companies', 'languages', 'members', 'other', 'products', 'stocks', 'trips'));
|
||||
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
@ -276,7 +276,7 @@ print load_fiche_titre($langs->trans("DictionaryPaperFormat"), '', '');
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table summary="more" class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
$selected = (isset($conf->global->MAIN_PDF_FORMAT) ? $conf->global->MAIN_PDF_FORMAT : '');
|
||||
if (empty($selected)) {
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2012-2107 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2021-2022 Anthony Berton <bertonanthony@gmail.com>
|
||||
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* 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
|
||||
@ -35,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks', 'Trips'));
|
||||
$langs->loadLangs(array('admin', 'bills', 'companies', 'languages', 'members', 'other', 'products', 'propal', 'receptions', 'stocks', 'trips'));
|
||||
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
@ -69,6 +70,9 @@ if ($action == 'update') {
|
||||
dolibarr_set_const($db, "INVOICE_ADD_SWISS_QR_CODE", GETPOST("INVOICE_ADD_SWISS_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_del_const($db, "INVOICE_ADD_ZATCA_QR_CODE", $conf->entity);
|
||||
}
|
||||
if (GETPOSTISSET('INVOICE_CATEGORY_OF_OPERATION')) {
|
||||
dolibarr_set_const($db, "INVOICE_CATEGORY_OF_OPERATION", GETPOST("INVOICE_CATEGORY_OF_OPERATION", 'int'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if (GETPOSTISSET('INVOICE_SHOW_SHIPPING_ADDRESS')) {
|
||||
dolibarr_set_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", GETPOST("INVOICE_SHOW_SHIPPING_ADDRESS", 'int'), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_del_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", $conf->entity);
|
||||
@ -135,7 +139,7 @@ if (isModEnabled('facture')) {
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table summary="more" class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans("INVOICE_ADD_ZATCA_QR_CODE"), $langs->trans("INVOICE_ADD_ZATCA_QR_CODEMore"));
|
||||
@ -159,11 +163,21 @@ if (isModEnabled('facture')) {
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Mention category of operations
|
||||
// French Decret n°2099-1299 2022-10-07
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans("INVOICE_SHOW_SHIPPING_ADDRESS"), $langs->trans("INVOICE_SHOW_SHIPPING_ADDRESSMore"));
|
||||
print $form->textwithpicto($langs->trans("InvoiceOptionCategoryOfOperations"), $langs->trans('InvoiceOptionCategoryOfOperationsHelp'), 1);
|
||||
print '</td><td>';
|
||||
$arrval = array('0'=>$langs->trans("No"),
|
||||
'1'=>$langs->trans("InvoiceOptionCategoryOfOperationsYes1"),
|
||||
'2'=>$langs->trans("InvoiceOptionCategoryOfOperationsYes2")
|
||||
);
|
||||
print $form->selectarray("INVOICE_CATEGORY_OF_OPERATION", $arrval, $conf->global->INVOICE_CATEGORY_OF_OPERATION, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").'</td><td>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('INVOICE_SHOW_SHIPPING_ADDRESS');
|
||||
print ajax_constantonoff('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING');
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("INVOICE_SHOW_SHIPPING_ADDRESS", $arrval, $conf->global->INVOICE_SHOW_SHIPPING_ADDRESS);
|
||||
@ -181,7 +195,7 @@ if (isModEnabled('reception')) {
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table summary="more" class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("RECEPTION_PDF_HIDE_ORDERED");
|
||||
|
||||
@ -61,9 +61,9 @@ function pdf_admin_prepare_head()
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'pdf_admin');
|
||||
|
||||
if (isModEnabled("propal")) {
|
||||
if (isModEnabled("propal") || isModEnabled('facture') || isModEnabled('reception')) {
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/pdf_other.php';
|
||||
$head[$h][1] = $langs->trans("Other");
|
||||
$head[$h][1] = $langs->trans("Others");
|
||||
$head[$h][2] = 'other';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
|
||||
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* 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
|
||||
@ -159,6 +160,11 @@ class pdf_sponge extends ModelePDFFactures
|
||||
*/
|
||||
public $cols;
|
||||
|
||||
/**
|
||||
* @var int Category of operation
|
||||
*/
|
||||
public $categoryOfOperation = -1; // unknown by default
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -429,12 +435,35 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
|
||||
// Set $this->atleastonediscount if you have at least one discount
|
||||
// and determine category of operation
|
||||
$categoryOfOperation = 0;
|
||||
$nbProduct = 0;
|
||||
$nbService = 0;
|
||||
for ($i = 0; $i < $nblines; $i++) {
|
||||
if ($object->lines[$i]->remise_percent) {
|
||||
$this->atleastonediscount++;
|
||||
}
|
||||
}
|
||||
|
||||
// determine category of operation
|
||||
$lineProductType = $object->lines[$i]->product_type;
|
||||
if ($lineProductType == Product::TYPE_PRODUCT) {
|
||||
$nbProduct++;
|
||||
} elseif ($lineProductType == Product::TYPE_SERVICE) {
|
||||
$nbService++;
|
||||
}
|
||||
if ($nbProduct > 0 && $nbService > 0) {
|
||||
// mixed products and services
|
||||
$categoryOfOperation = 2;
|
||||
}
|
||||
}
|
||||
// determine category of operation
|
||||
if ($categoryOfOperation <= 0) {
|
||||
// only services
|
||||
if ($nbProduct == 0 && $nbService > 0) {
|
||||
$categoryOfOperation = 1;
|
||||
}
|
||||
}
|
||||
$this->categoryOfOperation = $categoryOfOperation;
|
||||
|
||||
// Situation invoice handling
|
||||
if ($object->situation_cycle_ref) {
|
||||
@ -1241,6 +1270,21 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
|
||||
}
|
||||
|
||||
// Show category of operations
|
||||
if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
|
||||
$pdf->SetFont('', 'B', $default_font_size - 2);
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$categoryOfOperationTitle = $outputlangs->transnoentities("MentionCategoryOfOperations").' : ';
|
||||
$pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0, 'L');
|
||||
|
||||
$pdf->SetFont('', '', $default_font_size - 2);
|
||||
$pdf->SetXY($posxval, $posy);
|
||||
$categoryOfOperationLabel = $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
|
||||
$pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0, 'L');
|
||||
|
||||
$posy = $pdf->GetY() + 3; // for 2 lines
|
||||
}
|
||||
|
||||
if ($object->type != 2) {
|
||||
// Check a payment mode is defined
|
||||
if (empty($object->mode_reglement_code)
|
||||
@ -1967,6 +2011,13 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$pdf->SetFont('', '', $default_font_size - 2);
|
||||
|
||||
if (empty($hidetop)) {
|
||||
// Show category of operations
|
||||
if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
|
||||
$categoryOfOperations = $outputlangs->transnoentities("MentionCategoryOfOperations") . ' : ' . $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
|
||||
$pdf->SetXY($this->marge_gauche, $tab_top - 4);
|
||||
$pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
|
||||
}
|
||||
|
||||
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
|
||||
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
|
||||
$titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
|
||||
|
||||
@ -1442,6 +1442,10 @@ SuppliersPayment=Vendor payments
|
||||
SupplierPaymentSetup=Vendor payments setup
|
||||
InvoiceCheckPosteriorDate=Check facture date before validation
|
||||
InvoiceCheckPosteriorDateHelp=Validating an invoice will be forbidden if its date is anterior to the date of last invoice of same type.
|
||||
InvoiceOptionCategoryOfOperations=Display the mention "category of operations" on the invoice.
|
||||
InvoiceOptionCategoryOfOperationsHelp=Depending on the situation, the mention will appear in the form:<br>- Category of operations: Delivery of goods<br>- Category of operations: Provision of services<br>- Category of operations: Mixed - Delivery of goods & provision of services
|
||||
InvoiceOptionCategoryOfOperationsYes1=Yes, below the address block
|
||||
InvoiceOptionCategoryOfOperationsYes2=Yes, in the lower left-hand corner
|
||||
##### Proposals #####
|
||||
PropalSetup=Commercial proposals module setup
|
||||
ProposalsNumberingModules=Commercial proposal numbering models
|
||||
|
||||
@ -627,3 +627,7 @@ SendEmailsRemindersOnInvoiceDueDate=Send reminder by email for unpaid invoices
|
||||
MakePaymentAndClassifyPayed=Record payment
|
||||
BulkPaymentNotPossibleForInvoice=Bulk payment is not possible for invoice %s (bad type or status)
|
||||
MentionVATDebitOptionIsOn=Option to pay tax based on debits
|
||||
MentionCategoryOfOperations=Category of operations
|
||||
MentionCategoryOfOperations0=Delivery of goods
|
||||
MentionCategoryOfOperations1=Provision of services
|
||||
MentionCategoryOfOperations2=Mixed - Delivery of goods & provision of services
|
||||
|
||||
@ -215,9 +215,13 @@ if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) {
|
||||
$conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
|
||||
}
|
||||
if ($mysoc->country_code == 'FR' && !isset($conf->global->MAIN_PROFID1_IN_ADDRESS)) {
|
||||
// For FR, default value of option to show profid SIRET is on by default
|
||||
// For FR, default value of option to show profid SIRET is on by default. Decret n°2099-1299 2022-10-07
|
||||
$conf->global->MAIN_PROFID1_IN_ADDRESS = 1;
|
||||
}
|
||||
if ($mysoc->country_code == 'FR' && !isset($conf->global->INVOICE_CATEGORY_OF_OPERATION)) {
|
||||
// For FR, default value of option to show category of operations is on by default. Decret n°2099-1299 2022-10-07
|
||||
$conf->global->INVOICE_CATEGORY_OF_OPERATION = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user