Browse Source

Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0

Laurent Destailleur 7 months ago
parent
commit
b099e103b3

+ 1 - 0
htdocs/comm/action/class/actioncomm.class.php

@@ -2546,6 +2546,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 = '';

+ 15 - 0
htdocs/commande/list.php

@@ -2713,6 +2713,21 @@ while ($i < $imaxinloop) {
 							}
 						}
 					}
+
+					// 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').'<br>'.$text_info;

+ 3 - 0
htdocs/compta/facture/card.php

@@ -4543,6 +4543,9 @@ if ($action == 'create') {
 	$morehtmlref .= '</div>';
 
 	$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, '', '');
 

+ 2 - 2
htdocs/compta/facture/list.php

@@ -436,8 +436,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) {

+ 13 - 0
htdocs/compta/facture/tpl/linkedobjectblock.tpl.php

@@ -86,11 +86,24 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
 
 	print '</td>';
 	print '<td class="linkedcol-statut right">';
+	$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 '</td>';
 	print '<td class="linkedcol-action right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&token='.newToken().'&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
 	print "</tr>\n";

+ 6 - 1
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 '<tr class="oddeven">';
 				print '<td class="nowrap">';
 
@@ -247,7 +250,7 @@ if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) {
 
 				print '<td class="right" title="'.dol_escape_htmltag($langs->trans("DateModificationShort").' : '.dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel')).'">'.dol_print_date($db->jdate($obj->tms), 'day', 'tzuserrel').'</td>';
 
-				print '<td>'.$tmpinvoice->getLibStatut(3, $obj->am).'</td>';
+				print '<td>'.$tmpinvoice->getLibStatut(3, $totalallpayments).'</td>';
 
 				print '</tr>';
 
@@ -377,6 +380,8 @@ if ((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMO
 				print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).'</span></td>';
 				print '<td class="right" title="'.dol_escape_htmltag($langs->trans("DateModificationShort").' : '.dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel')).'">'.dol_print_date($db->jdate($obj->tms), 'day', 'tzuserrel').'</td>';
 				$alreadypaid = $facstatic->getSommePaiement();
+				$alreadypaid += $facstatic->getSumCreditNotesUsed();
+				$alreadypaid += $facstatic->getSumDepositsUsed();
 				print '<td>'.$facstatic->getLibStatut(3, $alreadypaid).'</td>';
 				print '</tr>';
 				$total_ht += $obj->total_ht;

+ 1 - 1
htdocs/compta/paiement/class/paiement.class.php

@@ -1270,7 +1270,7 @@ class Paiement extends CommonObject
 				$facturestatic = new Facture($this->db);
 				foreach ($arraybill as $billid) {
 					$facturestatic->fetch($billid);
-					$label .= '<br> '.$facturestatic->getNomUrl(1, '', 0, 0, '', 1).' '.$facturestatic->getLibStatut(2, 1);
+					$label .= '<br> '.$facturestatic->getNomUrl(1, '', 0, 0, '', 1).' '.$facturestatic->getLibStatut(2, -1);
 				}
 			}
 		}

+ 7 - 4
htdocs/compta/prelevement/index.php

@@ -101,7 +101,7 @@ print '</span></td></tr></table></div><br>';
 /*
  * 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 '</td>';
 
 			print '<td class="right">';
-			print $invoicestatic->getLibStatut(3, $alreadypayed);
+			print $invoicestatic->getLibStatut(3, $totalallpayments);
 			print '</td>';
 			print '</tr>';
 			$i++;

+ 4 - 2
htdocs/compta/recap-compta.php

@@ -159,7 +159,9 @@ if ($id > 0) {
 					print $fac->error."<br>";
 					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)
 				);

+ 2 - 1
htdocs/compta/tva/list.php

@@ -724,7 +724,8 @@ while ($i < $imaxinloop) {
 		}
 
 		if (!empty($arrayfields['t.status']['checked'])) {
-			print '<td class="nowrap right">' . $tva_static->getLibStatut(5, $obj->alreadypayed) . '</td>';
+			$totalallpayments = $obj->alreadypayed;
+			print '<td class="nowrap right">' . $tva_static->getLibStatut(5, $totalallpayments) . '</td>';
 			if (!$i) {
 				$totalarray['nbfield']++;
 			}

+ 10 - 1
htdocs/core/lib/functions.lib.php

@@ -2533,7 +2533,16 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
 			$tmptxt = $object->getLibStatut(5, $object->alreadypaid);
 		}
 		$morehtmlstatus .= $tmptxt;
-	} elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva'))) {	// TODO Move this to use ->alreadypaid
+	} elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier'))) {	// TODO Move this to use ->alreadypaid
+		$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'))) {	// TODO Move this to use ->alreadypaid
 		$tmptxt = $object->getLibStatut(6, $object->totalpaid);
 		if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
 			$tmptxt = $object->getLibStatut(5, $object->totalpaid);

+ 7 - 0
htdocs/holiday/class/holiday.class.php

@@ -1080,6 +1080,13 @@ class Holiday extends CommonObject
 			$this->errors[] = "Error ".$this->db->lasterror();
 		}
 
+		if (!$error) {
+			$result = $this->insertExtraFields();
+			if ($result < 0) {
+				$error++;
+			}
+		}
+
 		if (!$error) {
 			if (!$notrigger) {
 				// Call trigger

+ 9 - 6
htdocs/product/stock/replenish.php

@@ -196,17 +196,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;