From e71631abe0b64037fa3e749186aa326c53319f4e Mon Sep 17 00:00:00 2001 From: thomas-Ngr Date: Thu, 3 Oct 2024 19:33:33 +0200 Subject: [PATCH 1/5] fix : missing update for extrafields on holidays (#31256) --- htdocs/holiday/class/holiday.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 6271f1d43e8..ab1efaa7f90 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -987,6 +987,13 @@ class Holiday extends CommonObject $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$error) { + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; + } + } + if (!$error) { if (!$notrigger) { // Call trigger From 336d3ad8e584bdbbf35f7f60c8f452783de2e692 Mon Sep 17 00:00:00 2001 From: thomas-Ngr Date: Thu, 3 Oct 2024 21:03:13 +0200 Subject: [PATCH 2/5] finish fix (#31203) --- htdocs/product/stock/replenish.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index a1a99523d91..29b02cb0796 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -194,17 +194,20 @@ if ($action == 'order' && GETPOST('valid')) { // TODO Get desc in language of thirdparty } + $line->tva_tx = $productsupplier->vatrate_supplier; + $tva = $line->tva_tx / 100; + // If we use multicurrency if (isModEnabled('multicurrency') && !empty($productsupplier->fourn_multicurrency_code) && $productsupplier->fourn_multicurrency_code != $conf->currency) { - $line->multicurrency_code = $productsupplier->fourn_multicurrency_code; - $line->fk_multicurrency = $productsupplier->fourn_multicurrency_id; - $line->multicurrency_subprice = $productsupplier->fourn_multicurrency_unitprice; + $line->multicurrency_code = $productsupplier->fourn_multicurrency_code; + $line->fk_multicurrency = $productsupplier->fourn_multicurrency_id; + $line->multicurrency_subprice = $productsupplier->fourn_multicurrency_unitprice; + $line->multicurrency_total_ht = $line->multicurrency_subprice * $qty; + $line->multicurrency_total_tva = $line->multicurrency_total_ht * $tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ht + $line->multicurrency_total_tva; } - - $line->tva_tx = $productsupplier->vatrate_supplier; $line->subprice = $productsupplier->fourn_pu; $line->total_ht = $productsupplier->fourn_pu * $qty; - $tva = $line->tva_tx / 100; $line->total_tva = $line->total_ht * $tva; $line->total_ttc = $line->total_ht + $line->total_tva; $line->remise_percent = $productsupplier->remise_percent; From 1e64870a9ec465f090f94e907a4dd3c1a1257305 Mon Sep 17 00:00:00 2001 From: atm-lucas <121817516+atm-lucasmantegari@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:53:43 +0200 Subject: [PATCH 3/5] NEW - Add a new hook on order list (#31315) * Add a new hook on order list * pr correction --- htdocs/commande/list.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index bf39beba029..2d80c7afec5 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -2566,6 +2566,21 @@ if ($resql) { } } } + + // Call Hook modifyTextInfo + $parameters = array('textinfo' => $text_info); + $reshook = $hookmanager->executeHooks('modifyTextInfo', $parameters, $object, $action); + if ($reshook == 1) { + // for add information + $text_info .= $hookmanager->resPrint; + } elseif ($reshook == 0) { + // for replace information + $text_info = $hookmanager->resPrint; + } elseif ($reshook == -1) { + // for errors + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + if ($notshippable == 0) { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; From 33c6d95b1c4d1b0818bcfefebbcceb2987b90c7b Mon Sep 17 00:00:00 2001 From: UltraViolet33 <93035200+UltraViolet33@users.noreply.github.com> Date: Sun, 13 Oct 2024 21:04:17 +0200 Subject: [PATCH 4/5] Backport Fix wrong invoice status when invoice has discount (#31323) Co-authored-by: Ulysse Valdenaire --- htdocs/compta/facture/card.php | 20 ++++++++++++---- htdocs/compta/facture/list.php | 23 +++++++++++-------- .../facture/tpl/linkedobjectblock.tpl.php | 13 +++++++++++ htdocs/compta/index.php | 7 +++++- .../compta/paiement/class/paiement.class.php | 2 +- htdocs/compta/prelevement/index.php | 11 +++++---- htdocs/compta/recap-compta.php | 6 +++-- htdocs/compta/tva/list.php | 3 ++- htdocs/core/lib/functions.lib.php | 11 ++++++++- 9 files changed, 71 insertions(+), 25 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b03f36dfbf0..804451777b8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4487,6 +4487,9 @@ if ($action == 'create') { $morehtmlref .= ''; $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalcreditnotes = $totalcreditnotes; + $object->totaldeposits = $totaldeposits; + $object->remaintopay = price2num($object->total_ttc - $object->totalpaid - $object->totalcreditnotes - $object->totaldeposits, 'MT'); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', ''); @@ -5039,7 +5042,9 @@ if ($action == 'create') { $current_situation_counter = array(); foreach ($object->tab_previous_situation_invoice as $prev_invoice) { - $tmptotalpaidforthisinvoice = $prev_invoice->getSommePaiement(); + $tmptotalallpayments = $prev_invoice->getSommePaiement(0); + $tmptotalallpayments += $prev_invoice->getSumDepositsUsed(0); + $tmptotalallpayments += $prev_invoice->getSumCreditNotesUsed(0); $total_prev_ht += $prev_invoice->total_ht; $total_prev_ttc += $prev_invoice->total_ttc; $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $prev_invoice->situation_counter; @@ -5052,11 +5057,14 @@ if ($action == 'create') { } print ''.price($prev_invoice->total_ht).''; print ''.price($prev_invoice->total_ttc).''; - print ''.$prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice).''; + print ''.$prev_invoice->getLibStatut(3, $tmptotalallpayments).''; print ''; } } + $totalallpayments = $object->getSommePaiement(0); + $totalallpayments += $object->getSumCreditNotesUsed(0); + $totalallpayments += $object->getSumDepositsUsed(0); $total_global_ht += $total_prev_ht; $total_global_ttc += $total_prev_ttc; @@ -5072,7 +5080,7 @@ if ($action == 'create') { } print ''.price($object->total_ht).''; print ''.price($object->total_ttc).''; - print ''.$object->getLibStatut(3, $object->getSommePaiement()).''; + print ''.$object->getLibStatut(3, $totalallpayments).''; print ''; @@ -5114,7 +5122,9 @@ if ($action == 'create') { $total_next_ht = $total_next_ttc = 0; foreach ($object->tab_next_situation_invoice as $next_invoice) { - $totalpaid = $next_invoice->getSommePaiement(); + $totalpaid = $next_invoice->getSommePaiement(0); + $totalcreditnotes = $next_invoice->getSumCreditNotesUsed(0); + $totaldeposits = $next_invoice->getSumDepositsUsed(0); $total_next_ht += $next_invoice->total_ht; $total_next_ttc += $next_invoice->total_ttc; @@ -5127,7 +5137,7 @@ if ($action == 'create') { } print ''.price($next_invoice->total_ht).''; print ''.price($next_invoice->total_ttc).''; - print ''.$next_invoice->getLibStatut(3, $totalpaid).''; + print ''.$next_invoice->getLibStatut(3, $totalpaid + $totalcreditnotes + $totaldeposits).''; print ''; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a6fa25cfd13..d3469f3f74d 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -422,8 +422,8 @@ if ($action == 'makepayment_confirm' && $user->hasRight('facture', 'paiement')) $paiementAmount = $facture->getSommePaiement(); $totalcreditnotes = $facture->getSumCreditNotesUsed(); $totaldeposits = $facture->getSumDepositsUsed(); - $totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits; - $remaintopay = price2num($facture->total_ttc - $totalpay); + $totalallpayments = $paiementAmount + $totalcreditnotes + $totaldeposits; + $remaintopay = price2num($facture->total_ttc - $totalallpayments); if ($remaintopay != 0) { $resultBank = $facture->setBankAccount($bankid); if ($resultBank < 0) { @@ -1821,7 +1821,7 @@ if ($resql) { $totalarray['val']['f.total_tva'] = 0; $totalarray['val']['f.total_ht'] = 0; $totalarray['val']['f.total_ttc'] = 0; - $totalarray['val']['totalam'] = 0; + $totalarray['val']['dynamount_payed'] = 0; $totalarray['val']['rtp'] = 0; @@ -1910,8 +1910,8 @@ if ($resql) { $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1); $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1); - $totalpay = $paiement + $totalcreditnotes + $totaldeposits; - $remaintopay = price2num($facturestatic->total_ttc - $totalpay); + $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits; + $remaintopay = $obj->total_ttc - $totalallpayments; $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits; $multicurrency_remaintopay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay); @@ -1923,13 +1923,16 @@ if ($resql) { if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consumed $remaincreditnote = $discount->getAvailableDiscounts($companystatic, '', 'rc.fk_facture_source='.$facturestatic->id); $remaintopay = -$remaincreditnote; - $totalpay = price2num($facturestatic->total_ttc - $remaintopay); + $totalallpayments = price2num($facturestatic->total_ttc - $remaintopay); $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic, '', 'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1); $multicurrency_remaintopay = -$multicurrency_remaincreditnote; $multicurrency_totalpay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay); } $facturestatic->alreadypaid = $paiement; + $facturestatic->totalpaid = $paiement; + $facturestatic->totalcreditnotes = $totalcreditnotes; + $facturestatic->totaldeposits = $totaldeposits; $marginInfo = array(); if ($with_margin_info === true) { @@ -2382,14 +2385,14 @@ if ($resql) { } if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''.(!empty($totalpay) ? price($totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field + print ''.(!empty($totalallpayments) ? price($totalallpayments, 0, $langs) : ' ').''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + $totalarray['pos'][$totalarray['nbfield']] = 'dynamount_payed'; } - $totalarray['val']['totalam'] += $totalpay; + $totalarray['val']['dynamount_payed'] += $totalallpayments; } // Pending amount @@ -2580,7 +2583,7 @@ if ($resql) { // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; - print $facturestatic->getLibStatut(5, $paiement); + print $facturestatic->getLibStatut(5, $totalallpayments); print ""; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 04d7f97baef..c002e5a7e5f 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -86,11 +86,24 @@ foreach ($linkedObjectBlock as $key => $objectlink) { print ''; print ''; + $totalallpayments = 0; + $totalcalculated = false; if (method_exists($objectlink, 'getSommePaiement')) { print $objectlink->getLibStatut(3, $objectlink->getSommePaiement()); + $totalcalculated = true; + $totalallpayments += $objectlink->getSommePaiement(); } else { print $objectlink->getLibStatut(3); } + if (method_exists($objectlink, 'getSumDepositsUsed')) { + $totalcalculated = true; + $totalallpayments += $objectlink->getSumDepositsUsed(); + } + if (method_exists($objectlink, 'getSumCreditNotesUsed')) { + $totalcalculated = true; + $totalallpayments += $objectlink->getSumCreditNotesUsed(); + } + print $objectlink->getLibStatut(3, ($totalcalculated ? $totalallpayments : -1)); print ''; print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; print "\n"; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index a340d7ef7c3..e7df99729bb 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -215,6 +215,9 @@ if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $thirdpartystatic->code_compta = $obj->code_compta; //$thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + $totalallpayments = $tmpinvoice->getSommePaiement(0); + $totalallpayments += $tmpinvoice->getSumCreditNotesUsed(0); + $totalallpayments += $tmpinvoice->getSumDepositsUsed(0); print ''; print ''; @@ -247,7 +250,7 @@ if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { print 'jdate($obj->tms), 'dayhour', 'tzuserrel')).'">'.dol_print_date($db->jdate($obj->tms), 'day', 'tzuserrel').''; - print ''.$tmpinvoice->getLibStatut(3, $obj->am).''; + print ''.$tmpinvoice->getLibStatut(3, $totalallpayments).''; print ''; @@ -377,6 +380,8 @@ if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO print ''.price($obj->total_ttc).''; print 'jdate($obj->tms), 'dayhour', 'tzuserrel')).'">'.dol_print_date($db->jdate($obj->tms), 'day', 'tzuserrel').''; $alreadypaid = $facstatic->getSommePaiement(); + $alreadypaid += $facstatic->getSumCreditNotesUsed(); + $alreadypaid += $facstatic->getSumDepositsUsed(); print ''.$facstatic->getLibStatut(3, $alreadypaid).''; print ''; $total_ht += $obj->total_ht; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 94e2d570fcf..307d5a41f27 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1269,7 +1269,7 @@ class Paiement extends CommonObject $facturestatic = new Facture($this->db); foreach ($arraybill as $billid) { $facturestatic->fetch($billid); - $label .= '
'.$facturestatic->getNomUrl(1, '', 0, 0, '', 1).' '.$facturestatic->getLibStatut(2, 1); + $label .= '
'.$facturestatic->getNomUrl(1, '', 0, 0, '', 1).' '.$facturestatic->getLibStatut(2, -1); } } } diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 71677f0051c..dbe814569f0 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -101,7 +101,7 @@ print '
'; /* * Invoices waiting for withdraw */ -$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; +$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut as status, f.paye, f.type,"; $sql .= " pfd.date_demande, pfd.amount,"; $sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; @@ -141,10 +141,13 @@ if ($resql) { $invoicestatic->id = $obj->rowid; $invoicestatic->ref = $obj->ref; - $invoicestatic->statut = $obj->fk_statut; + $invoicestatic->statut = $obj->status; + $invoicestatic->status = $obj->status; $invoicestatic->paye = $obj->paye; $invoicestatic->type = $obj->type; - $alreadypayed = $invoicestatic->getSommePaiement(); + $totalallpayments = $invoicestatic->getSommePaiement(0); + $totalallpayments += $invoicestatic->getSumCreditNotesUsed(0); + $totalallpayments += $invoicestatic->getSumDepositsUsed(0); $thirdpartystatic->id = $obj->socid; $thirdpartystatic->name = $obj->name; @@ -177,7 +180,7 @@ if ($resql) { print ''; print ''; - print $invoicestatic->getLibStatut(3, $alreadypayed); + print $invoicestatic->getLibStatut(3, $totalallpayments); print ''; print ''; $i++; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 0808e5a7aab..73ed2069438 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -159,7 +159,9 @@ if ($id > 0) { print $fac->error."
"; continue; } - $totalpaid = $fac->getSommePaiement(); + $alreadypaid = $fac->getSommePaiement(); + $alreadypaid += $fac->getSumDepositsUsed(); + $alreadypaid += $fac->getSumCreditNotesUsed(); $userstatic->id = $objf->userid; $userstatic->login = $objf->login; @@ -169,7 +171,7 @@ if ($id > 0) { 'date' => $fac->date, 'datefieldforsort' => $fac->date.'-'.$fac->ref, 'link' => $fac->getNomUrl(1), - 'status' => $fac->getLibStatut(2, $totalpaid), + 'status' => $fac->getLibStatut(2, $alreadypaid), 'amount' => $fac->total_ttc, 'author' => $userstatic->getLoginUrl(1) ); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 9e5a28b6905..ec2ee333490 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -719,7 +719,8 @@ while ($i < $imaxinloop) { } if (!empty($arrayfields['t.status']['checked'])) { - print '' . $tva_static->getLibStatut(5, $obj->alreadypayed) . ''; + $totalallpayments = $obj->alreadypayed; + print '' . $tva_static->getLibStatut(5, $totalallpayments) . ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0218301af75..d87132dc7a5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2451,7 +2451,16 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } else { $morehtmlstatus .= ''.$object->getLibStatut(6, 1).''; } - } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva', 'salary'))) { + } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier'))) { + $totalallpayments = $object->getSommePaiement(0); + $totalallpayments += $object->getSumCreditNotesUsed(0); + $totalallpayments += $object->getSumDepositsUsed(0); + $tmptxt = $object->getLibStatut(6, $totalallpayments); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) { + $tmptxt = $object->getLibStatut(5, $totalallpayments); + } + $morehtmlstatus .= $tmptxt; + } elseif (in_array($object->element, array('chargesociales', 'loan', 'tva'))) { $tmptxt = $object->getLibStatut(6, $object->totalpaid); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) { $tmptxt = $object->getLibStatut(5, $object->totalpaid); From 70a453a5c2a2ae7dfae7e11b6780947f086bf2d2 Mon Sep 17 00:00:00 2001 From: thomas-Ngr Date: Mon, 14 Oct 2024 11:57:55 +0200 Subject: [PATCH 5/5] FIX: substitutions THIRDPARTY_XXX are not available for actioncomm reminders (#31385) --- htdocs/comm/action/class/actioncomm.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f5e1fe40b1f..9b006c83ab6 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2341,6 +2341,7 @@ class ActionComm extends CommonObject // Load event $res = $this->fetch($actionCommReminder->fk_actioncomm); + if ($res > 0) $res = $this->fetch_thirdparty(); if ($res > 0) { // PREPARE EMAIL $errormesg = '';