From 08f3fbd5fd248e5ef619dabcb33885ffb822b55f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Jan 2026 13:59:09 +0100 Subject: [PATCH] Fix maxi debug blockedlog --- .../blockedlog/admin/blockedlog_archives.php | 81 +++++++++++-------- htdocs/blockedlog/admin/blockedlog_list.php | 8 +- htdocs/blockedlog/class/blockedlog.class.php | 28 ++++--- htdocs/blockedlog/lib/blockedlog.lib.php | 42 +++++----- htdocs/langs/en_US/blockedlog.lang | 4 +- 5 files changed, 94 insertions(+), 69 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_archives.php b/htdocs/blockedlog/admin/blockedlog_archives.php index 0ad8db08e92..b9287a34f8d 100644 --- a/htdocs/blockedlog/admin/blockedlog_archives.php +++ b/htdocs/blockedlog/admin/blockedlog_archives.php @@ -270,6 +270,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / .';'.$langs->transnoentities('Id') .';'.$langs->transnoentities('DateCreation') .';'.$langs->transnoentities('Action') + .';'.$langs->transnoentities('Origin') .';'.$langs->transnoentities('AmountHT') .';'.$langs->transnoentities('AmountTTC') .';'.$langs->transnoentities('Ref') @@ -288,6 +289,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $loweridinerror = 0; $i = 0; + $refinvoicefound = array(); $totalhtamount = array(); $totalvatamount = array(); $totalamount = array(); @@ -300,6 +302,8 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $block_static->date_creation = $db->jdate($obj->date_creation); // jdate(date_creation) is UTC + $block_static->module_source = $obj->module_source; + $block_static->amounts_excl = (float) $obj->amounts_excl; // Database store value with 8 digits, we cut ending 0 them with (flow) $block_static->amounts = (float) $obj->amounts; // Database store value with 8 digits, we cut ending 0 them with (flow) @@ -359,13 +363,14 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / // Define $totalhtamount, $totalvatamount, $totalamount for $block->action event code $total_ht = $total_vat = $total_ttc = 0; - sumAmountsForUnalterableEvent($block_static, $totalhtamount, $totalvatamount, $totalamount, $total_ht, $total_vat, $total_ttc); + sumAmountsForUnalterableEvent($block_static, $refinvoicefound, $totalhtamount, $totalvatamount, $totalamount, $total_ht, $total_vat, $total_ttc); fwrite($fh, ";" .csvClean($block_static->id).';' .csvClean($block_static->date_creation).';' .csvClean($block_static->action).';' + .csvClean($block_static->module_source).';' .csvClean($block_static->amounts_taxexcl).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->amounts).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->ref_object).';' @@ -373,7 +378,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / .csvClean($block_static->user_fullname).';' .csvClean($block_static->linktoref).';' .csvClean($block_static->linktype).';' - .csvClean($obj->object_data).';' // We must the string to decode into object with dolDecodeBlockedData + .csvClean($obj->object_data).';' // We must use the string (so $obj->object_data) and not the array decoded with dolDecodeBlockedData .csvClean($block_static->object_version).';' .csvClean($block_static->object_format).';' .csvClean($block_static->signature).';' @@ -392,7 +397,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / // Now calculate cumulative total of all invoices validated if (array_key_exists('BILL_VALIDATE', $totalhtamount)) { - foreach ($totalhtamount['BILL_VALIDATE'] as $key => $val) { + foreach ($totalhtamount['BILL_VALIDATE'] as $key => $val) { // Loop on each module $totalhtamountalllines['BILL_VALIDATE'] += $val; } foreach ($totalvatamount['BILL_VALIDATE'] as $key => $val) { @@ -419,6 +424,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $block_static->id = ''; $block_static->date_creation = ''; $block_static->action = 'BILL_VALIDATE'; + $block_static->module_source = '*'; $block_static->amounts_taxexcl = $totalhtamountalllines['BILL_VALIDATE']; $block_static->amounts = $totalamountalllines['BILL_VALIDATE']; $block_static->ref_object = $langs->transnoentitiesnoconv("VAT").': '.$totalvatamountalllines['BILL_VALIDATE']; @@ -426,19 +432,19 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $block_static->user_fullname = ''; $block_static->linktoref = ''; $block_static->linktype = ''; - $block_static->object_data = ''; $block_static->object_version = ''; + $block_static->object_format = ''; $block_static->signature = ''; $statusofrecord = ''; $signatureexport = ''; - $block_static->object_format = ''; - fwrite($fh, 'Cumulative total - Invoice validations;' + fwrite($fh, 'Cumulative total - Invoice validations (all invoices);' .csvClean($block_static->id).';' .csvClean($block_static->date_creation).';' .csvClean($block_static->action).';' + .csvClean($block_static->module_source).';' .csvClean($block_static->amounts_taxexcl).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->amounts).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->ref_object).';' @@ -446,7 +452,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / .csvClean($block_static->user_fullname).';' .csvClean($block_static->linktoref).';' .csvClean($block_static->linktype).';' - .csvClean($obj->object_data).';' // We must the string to decode into object with dolDecodeBlockedData + .csvClean($obj->object_data).';' // We must use the string (so $obj->object_data) and not the array decoded with dolDecodeBlockedData .csvClean($block_static->object_version).';' .csvClean($block_static->object_format).';' .csvClean($block_static->signature).';' @@ -458,6 +464,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $block_static->id = ''; $block_static->date_creation = ''; $block_static->action = 'PAYMENT_CUSTOMER_CREATE'; + $block_static->module_source = '*'; $block_static->amounts_taxexcl = ''; $block_static->amounts = $totalamountalllines['PAYMENT_CUSTOMER_CREATE']; $block_static->ref_object = ''; @@ -465,19 +472,17 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $block_static->user_fullname = ''; $block_static->linktoref = ''; $block_static->linktype = ''; - $block_static->object_data = ''; $block_static->object_version = ''; + $block_static->object_format = ''; $block_static->signature = ''; - $statusofrecord = ''; $signatureexport = ''; - $block_static->object_format = ''; - - fwrite($fh, 'Cumulative total - Invoice payments;' + fwrite($fh, 'Cumulative total - Invoice payments (all payments);' .csvClean($block_static->id).';' .csvClean($block_static->date_creation).';' .csvClean($block_static->action).';' + .csvClean($block_static->module_source).';' .csvClean($block_static->amounts_taxexcl).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->amounts).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->ref_object).';' @@ -485,7 +490,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / .csvClean($block_static->user_fullname).';' .csvClean($block_static->linktoref).';' .csvClean($block_static->linktype).';' - .csvClean($obj->object_data).';' // We must the string to decode into object with dolDecodeBlockedData + .csvClean($obj->object_data).';' // We must use the string (so $obj->object_data) and not the array decoded with dolDecodeBlockedData .csvClean($block_static->object_version).';' .csvClean($block_static->object_format).';' .csvClean($block_static->signature).';' @@ -493,24 +498,34 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / .csvClean($signatureexport).';'."\n"); - // Calculate perpetual totals - $sql = "SELECT action, object_format, MIN(date_creation) as datemin, SUM(amounts_taxexcl) as sumamounts_taxexcl, SUM(amounts) as sumamounts"; + // Calculate lifetime totals (with date of first record) + $sql = "SELECT action, module_source, object_format, MIN(date_creation) as datemin, SUM(amounts_taxexcl) as sumamounts_taxexcl, SUM(amounts) as sumamounts"; $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog"; $sql .= " WHERE entity = ".((int) $conf->entity); $sql .= " AND action IN ('BILL_VALIDATE', 'PAYMENT_CUSTOMER_CREATE')"; - $sql .= " GROUP BY action, object_format"; + $sql .= " GROUP BY action, module_source, object_format"; $foundoldformat = 0; - $firstrecorddate = array(); + $firstrecorddatearray = array(); + $firstrecorddate = 0; $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { - if (!empty($firstrecorddate[$obj->action])) { - $firstrecorddate[$obj->action] = min($firstrecorddate[$obj->action], $db->jdate($obj->datemin)); + // First record date per action code and module + if (!empty($firstrecorddatearray[$obj->action][$obj->module_source])) { + $firstrecorddatearray[$obj->action][$obj->module_source] = min($firstrecorddatearray[$obj->action][$obj->module_source], $db->jdate($obj->datemin)); } else { - $firstrecorddate[$obj->action] = $db->jdate($obj->datemin); + $firstrecorddatearray[$obj->action] = array(); + $firstrecorddatearray[$obj->action][$obj->module_source] = $db->jdate($obj->datemin); } - $totalamountlifetime[$obj->action] += $obj->sumamounts; + // First record for all actions code + if (!empty($firstrecorddate)) { + $firstrecorddate = min($firstrecorddate, $db->jdate($obj->datemin)); + } else { + $firstrecorddate = $obj->datemin; + } + // Total per action code and module + $totalamountlifetime[$obj->action][$obj->module_source] += $obj->sumamounts; // If format of line is old, the sumamounts_taxexcl was not recorded. So we flag this case. if (empty($obj->object_format) || $obj->object_format == 'V1') { $foundoldformat = 1; @@ -528,7 +543,9 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $block_static->id = ''; $block_static->date_creation = ''; $block_static->action = 'BILL_VALIDATE'; + $block_static->module_source = '*'; // if an old format was found, we do not have reliable amount excluding tax for lifetime value, we do not show it + $block_static->amounts_taxexcl = ($foundoldformat ? '' : $totalhtamountlifetime['BILL_VALIDATE']); $block_static->amounts = $totalamountlifetime['BILL_VALIDATE']; // if an old format was found, we do not have reliable VAT amount for lifetime value, we do not show it @@ -537,19 +554,18 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $block_static->user_fullname = ''; $block_static->linktoref = ''; $block_static->linktype = ''; - $block_static->object_data = ''; $block_static->object_version = ''; + $block_static->object_format = ''; $block_static->signature = ''; $statusofrecord = ''; $signatureexport = ''; - $block_static->object_format = ''; - - fwrite($fh, 'Lifetime total (>= '.dol_print_date($firstrecorddate['BILL_VALIDATE'], 'standard').') - Invoice validations;' + fwrite($fh, 'Lifetime total (>= '.dol_print_date($firstrecorddate, 'standard').') - Invoice validations (all invoices);' .csvClean($block_static->id).';' .csvClean($block_static->date_creation).';' .csvClean($block_static->action).';' + .csvClean($block_static->module_source).';' .csvClean($block_static->amounts_taxexcl).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->amounts).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->ref_object).';' @@ -557,17 +573,19 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / .csvClean($block_static->user_fullname).';' .csvClean($block_static->linktoref).';' .csvClean($block_static->linktype).';' - .csvClean($obj->object_data).';' // We must the string to decode into object with dolDecodeBlockedData + .csvClean($obj->object_data).';' // We must use the string (so $obj->object_data) and not the array decoded with dolDecodeBlockedData .csvClean($block_static->object_version).';' .csvClean($block_static->object_format).';' .csvClean($block_static->signature).';' .csvClean($statusofrecord).';' .csvClean($signatureexport).';'."\n"); + // Add a final line with perpetual total for customer payments $block_static->id = ''; $block_static->date_creation = ''; $block_static->action = 'PAYMENT_CUSTOMER_CREATE'; + $block_static->module_source = '*'; $block_static->amounts_taxtecl = ''; $block_static->amounts = $totalamountlifetime['PAYMENT_CUSTOMER_CREATE']; $block_static->ref_object = ''; @@ -575,19 +593,18 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / $block_static->user_fullname = ''; $block_static->linktoref = ''; $block_static->linktype = ''; - $block_static->object_data = ''; $block_static->object_version = ''; + $block_static->object_format = ''; $block_static->signature = ''; $statusofrecord = ''; $signatureexport = ''; - $block_static->object_format = ''; - - fwrite($fh, 'Lifetime total (>= '.dol_print_date($firstrecorddate['PAYMENT_CUSTOMER_CREATE'], 'standard').') - Invoice payments;' + fwrite($fh, 'Lifetime total (>= '.dol_print_date($firstrecorddate, 'standard').') - Invoice payments (all payments);' .csvClean($block_static->id).';' .csvClean($block_static->date_creation).';' .csvClean($block_static->action).';' + .csvClean($block_static->module_source).';' .csvClean($block_static->amounts_taxexcl).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->amounts).';' // Can be 1.20000000 with 8 digits. TODO Clean to have 8 digits in V1 .csvClean($block_static->ref_object).';' @@ -595,7 +612,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / .csvClean($block_static->user_fullname).';' .csvClean($block_static->linktoref).';' .csvClean($block_static->linktype).';' - .csvClean($obj->object_data).';' // We must the string to decode into object with dolDecodeBlockedData + .csvClean($obj->object_data).';' // We must use the string (so $obj->object_data) and not the array decoded with dolDecodeBlockedData .csvClean($block_static->object_version).';' .csvClean($block_static->object_format).';' .csvClean($block_static->signature).';' @@ -604,7 +621,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / fclose($fh); - // Calculate the md5 of the file (the last line has a return line) + // Calculate the signature of the file (the last line has a return line) $algo = 'sha256'; $sha256 = hash_file($algo, $tmpfile); $hmacsha256 = hash_hmac_file($algo, $tmpfile, $secretkey); diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 468c50e14d8..05d4f4c1a4f 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -636,6 +636,7 @@ if (getDolGlobalString('BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR')) { } } +$refinvoicefound = array(); $totalhtamount = array(); $totalvatamount = array(); $totalamount = array(); @@ -703,9 +704,9 @@ if (is_array($blocks)) { //$tmpobj = json_decode($block->object_data); - // Define $totalhtamount, $totalvatamount, $totalamount for $block->action event code + // Define $totalhtamount, $totalvatamount, $totalamount for $block action code and module $total_ht = $total_vat = $total_ttc = 0; - sumAmountsForUnalterableEvent($block, $totalhtamount, $totalvatamount, $totalamount, $total_ht, $total_vat, $total_ttc); + sumAmountsForUnalterableEvent($block, $refinvoicefound, $totalhtamount, $totalvatamount, $totalamount, $total_ht, $total_vat, $total_ttc); // Amount print ''; @@ -780,6 +781,7 @@ if (is_array($blocks)) { } } + // Show total line if ($nbshown == 0) { $colspan = 11; if (getDolGlobalString('MAIN_FEATURES_LEVEL') > 0) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs. @@ -818,7 +820,7 @@ if (is_array($blocks)) { // Amount (HT) print ''; $totalhttoshow = 0; - foreach ($totalhtamount[$key] as $value) { + foreach ($totalhtamount[$key] as $value) { // Loop on each module $totalhttoshow += $value; } print $langs->trans("HT").': '; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 8724ad0c5ee..71e23949651 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -76,17 +76,18 @@ class BlockedLog */ public $amounts_taxexcl = null; - /** - * @var float|string|null - */ - public $vat = null; - /** * trigger action * @var string */ public $action = ''; + /** + * Module source + * @var string + */ + public $module_source = ''; + /** * @var string $linktype. Example 'paymentofinvoice' */ @@ -532,8 +533,10 @@ class BlockedLog '@phan-var-force Subscription $object'; $this->date_object = $object->dateh; } elseif ($object->element == 'cashcontrol') { + /** var CashControl $object */ '@phan-var-force CashControl $object'; $this->date_object = $object->date_creation; + $this->module_source = $object->posmodule; } elseif (property_exists($object, 'date')) { // Generic case $this->date_object = $object->date; // @phan-suppress-current-line PhanUndeclaredProperty @@ -552,6 +555,7 @@ class BlockedLog $this->linktype = 'credit_note_of'; $this->linktoref = $invoice->ref; } + //$this->module_source = $invoice->module_source; } } if ($object->element == 'facture') { @@ -563,6 +567,7 @@ class BlockedLog $this->linktype = 'credit_note_of'; $this->linktoref = $invoice->ref; } + $this->module_source = $invoice->module_source; } } @@ -1033,7 +1038,7 @@ class BlockedLog return -1; } - $sql = "SELECT b.rowid, b.date_creation, b.signature, b.amounts_taxexcl, b.amounts, b.action, b.element, b.fk_object, b.entity,"; + $sql = "SELECT b.rowid, b.date_creation, b.signature, b.amounts_taxexcl, b.amounts, b.action, b.module_source, b.element, b.fk_object, b.entity,"; $sql .= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data, b.object_version, b.object_format"; $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; if ($id) { @@ -1050,10 +1055,11 @@ class BlockedLog $this->date_creation = $this->db->jdate($obj->date_creation); // jdate(date_creation)is UTC $this->date_modification = $this->db->jdate($obj->tms); // jdate(tms) is UTC + $this->action = $obj->action; + $this->module_source = $obj->module_source; + $this->amounts_taxecl = (is_null($obj->amounts_taxexcl) ? null : (float) $obj->amounts); $this->amounts = (float) $obj->amounts; - $this->action = $obj->action; - $this->element = $obj->element; $this->fk_object = $obj->fk_object; $this->date_object = $this->db->jdate($obj->date_object); // jdate(date_object) is UTC @@ -1066,6 +1072,8 @@ class BlockedLog $this->object_version = $obj->object_version; $this->object_format = $obj->object_format; + $this->element = $obj->element; + $this->signature = $obj->signature; $this->certified = ($obj->certified == 1); @@ -1225,6 +1233,7 @@ class BlockedLog $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; $sql .= " date_creation,"; $sql .= " action,"; + $sql .= " module_source,"; $sql .= " amounts_taxexcl,"; $sql .= " amounts,"; $sql .= " signature,"; @@ -1243,6 +1252,7 @@ class BlockedLog $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->date_creation)."',"; $sql .= "'".$this->db->escape($this->action)."',"; + $sql .= "'".$this->db->escape((string) $this->module_source)."',"; $sql .= (is_null($this->amounts_taxexcl) ? "null" : (float) $this->amounts_taxexcl).","; $sql .= (float) $this->amounts.","; $sql .= "'".$this->db->escape($this->signature)."',"; @@ -1361,7 +1371,7 @@ class BlockedLog return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname; } elseif ($this->object_format == 'V2') { $s = $this->entity; - $s .= '|'.$this->date_creation.'|'.$this->action.'|'.$this->amounts_taxexcl.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname; + $s .= '|'.$this->date_creation.'|'.$this->action.'|'.$this->module_source.'|'.$this->amounts_taxexcl.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname; $s .= '|'.(string) $this->linktoref; $s .= '|'.(string) $this->linktype; return $s; diff --git a/htdocs/blockedlog/lib/blockedlog.lib.php b/htdocs/blockedlog/lib/blockedlog.lib.php index 61e30710ae4..f0c33e3ee42 100644 --- a/htdocs/blockedlog/lib/blockedlog.lib.php +++ b/htdocs/blockedlog/lib/blockedlog.lib.php @@ -255,19 +255,24 @@ function pdfCertifMentionblockedLog(&$pdf, $outputlangs, $seller, $default_font_ * sumAmountsForUnalterableEvent * * @param BlockedLog $block Object BlockedLog - * @param array $totalhtamount Array of total per code event - * @param array $totalvatamount Array of total per code event - * @param array $totalamount Array of total per code event + * @param array $refinvoicefound Array of ref of invoice already found (to avoid duplicates. Should be useless but just in case of) + * @param array $totalhtamount Array of total per code event and module + * @param array $totalvatamount Array of total per code event and module + * @param array $totalamount Array of total per code event and module * @param float $total_ht Total HT * @param float $total_vat Total VAT * @param float $total_ttc Total TTC * @return int Return > 0 */ -function sumAmountsForUnalterableEvent($block, &$totalhtamount, &$totalvatamount, &$totalamount, &$total_ht, &$total_vat, &$total_ttc) +function sumAmountsForUnalterableEvent($block, &$refinvoicefound, &$totalhtamount, &$totalvatamount, &$totalamount, &$total_ht, &$total_vat, &$total_ttc) { - if (empty($totalamount[$block->action])) { - $totalamount[$block->action] = array(); + // Init to avoid warnings if not initialized yet + if (!isset($totalamount[$block->action][$block->module_source])) { + $totalhtamount[$block->action][$block->module_source] = 0; + $totalvatamount[$block->action][$block->module_source] = 0; + $totalamount[$block->action][$block->module_source] = 0; } + if ($block->action == 'BILL_VALIDATE') { $total_ht = $block->object_data->total_ht; $total_vat = $block->object_data->total_tva; @@ -275,32 +280,23 @@ function sumAmountsForUnalterableEvent($block, &$totalhtamount, &$totalvatamount // We add total for the invoice if "invoice validate event" not yet met. // If we already met the event for this object, we keep only first one but this should not happen because edition of validated invoice is not allowed on secured versions. - if (empty($totalamount[$block->action][$block->ref_object])) { - $totalhtamount[$block->action][$block->ref_object] = $total_ht; - $totalvatamount[$block->action][$block->ref_object] = $total_vat; - $totalamount[$block->action][$block->ref_object] = $total_ttc; + if (empty($refinvoicefound[$block->ref_object])) { + $totalhtamount[$block->action][$block->module_source] += $total_ht; + $totalvatamount[$block->action][$block->module_source] += $total_vat; + $totalamount[$block->action][$block->module_source] += $total_ttc; } + $refinvoicefound[$block->ref_object] = 1; } elseif ($block->action == 'PAYMENT_CUSTOMER_CREATE') { $total_ht = $block->object_data->amount; $total_vat = 0; $total_ttc = $block->object_data->amount; - if (empty($totalhtamount[$block->action][$block->ref_object])) { - $totalhtamount[$block->action][$block->ref_object] = 0; - } - if (empty($totalvatamount[$block->action][$block->ref_object])) { - $totalvatamount[$block->action][$block->ref_object] = 0; - } - if (empty($totalamount[$block->action][$block->ref_object])) { - $totalamount[$block->action][$block->ref_object] = 0; - } - $totalhtamount[$block->action][$block->ref_object] = $total_ht; - $totalvatamount[$block->action][$block->ref_object] = $total_vat; - $totalamount[$block->action][$block->ref_object] = $total_ttc; + $totalhtamount[$block->action][$block->module_source] += $total_ht; + $totalvatamount[$block->action][$block->module_source] += $total_vat; + $totalamount[$block->action][$block->module_source] += $total_ttc; } else { $total_ttc = $block->amounts; } - return 1; } diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 69328bf32d2..0ea44fdd468 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -19,7 +19,7 @@ OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to prev AddedByAuthority=Stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority BlockedLogBillDownload=Customer invoice download -BlockedLogBillPreview=Customer invoice preview +BlockedLogBillPreview=Customer invoice preview or print BlockedlogInfoDialog=Log Details ListOfTrackedEvents=List of tracked events Fingerprint=Signature @@ -62,7 +62,7 @@ logBILL_PAYED=Customer invoice paid logBILL_SENTBYMAIL=Customer invoice send by mail logBILL_UNPAYED=Customer invoice set unpaid logBILL_VALIDATE=Customer invoice validated -logCASHCONTROL_VALIDATE=Cash desk closing recording +logCASHCONTROL_VALIDATE=Cash register closing logDOC_DOWNLOAD=Download of a validated document in order to print or send logDOC_PREVIEW=Preview of a validated document in order to print or download logDONATION_PAYMENT_CREATE=Donation payment created