Browse Source

Merge pull request #3380 from FHenry/3.8

FIX : Fix demo dump data, date '0000-00-00 00:00:00' is not valid, replace by NOW()
Laurent Destailleur 10 years ago
parent
commit
cfc7658399

File diff suppressed because it is too large
+ 0 - 0
dev/initdata/mysqldump_dolibarr_3.8.0.sql


+ 3 - 2
htdocs/accountancy/customer/list.php

@@ -53,6 +53,7 @@ $search_desc = GETPOST('search_desc', 'alpha');
 $search_amount = GETPOST('search_amount', 'alpha');
 $search_account = GETPOST('search_account', 'alpha');
 $search_vat = GETPOST('search_vat', 'alpha');
+$btn_ventil = GETPOST('ventil', 'alpha');
 
 // Getpost Order and column and limit page
 $sortfield = GETPOST('sortfield', 'alpha');
@@ -129,7 +130,7 @@ print '<script type="text/javascript">
  * Action
  */
 
-if ($action == 'ventil') {
+if ($action == 'ventil' && !empty($btn_ventil)) {
 	print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
 	if (! empty($codeventil) && ! empty($mesCasesCochees)) {
 		print '<div><font color="red">' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
@@ -337,7 +338,7 @@ if ($result) {
 	}
 	
 	print '</table>';
-	print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '"></div>';
+	print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
 	print '</form>';
 } else {
 	print $db->error();

+ 17 - 10
htdocs/accountancy/journal/sellsjournal.php

@@ -89,8 +89,8 @@ $idpays = $p[0];
 $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,";
 $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,";
 $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
-$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte, ";
-$sql .= " ct.accountancy_code_sell as account_tva";
+$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
+$sql .= " fd.situation_percent,ct.accountancy_code_sell as account_tva";
 $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation";
@@ -102,16 +102,18 @@ if (! empty($conf->multicompany->enabled)) {
 	$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
 }
 $sql .= " AND f.fk_statut > 0";
-if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
-	$sql .= " AND f.type IN (0,1,2,5)";
-else
-	$sql .= " AND f.type IN (0,1,2,3,5)";
+if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+	$sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
+}
+else {
+	$sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
+}
 $sql .= " AND fd.product_type IN (0,1)";
 if ($date_start && $date_end)
 	$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
 $sql .= " ORDER BY f.datef";
 
-dol_syslog('accountancy/journal/sellsjournal.php:: $sql=' . $sql);
+dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
 $result = $db->query($sql);
 if ($result) {
 	$tabfac = array ();
@@ -143,10 +145,15 @@ if ($result) {
 		$line = new FactureLigne($db);
 		$line->fetch($obj->rowid);
 		$prev_progress = $line->get_prev_progress();
-		if ($obj->situation_percent == 0) { // Avoid divide by 0
-			$situation_ratio = 0;
+		if ($obj->type==Facture::TYPE_SITUATION) {
+			// Avoid divide by 0
+			if ($obj->situation_percent == 0) {
+				$situation_ratio = 0;
+			} else {
+				$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
+			}
 		} else {
-			$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
+			$situation_ratio = 1;
 		}
 
 		// Invoice lines

+ 15 - 5
htdocs/compta/journal/sellsjournal.php

@@ -114,8 +114,13 @@ $sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
 $sql.= " WHERE f.entity = ".$conf->entity;
 $sql.= " AND f.fk_statut > 0";
-if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
-else $sql.= " AND f.type IN (0,1,2,3,5)";
+if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+	$sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
+}
+else {
+	$sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
+}
+
 $sql.= " AND fd.product_type IN (0,1)";
 if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
 $sql.= " ORDER BY f.rowid";
@@ -163,10 +168,15 @@ if ($result)
 		$line = new FactureLigne($db);
 		$line->fetch($obj->id);
 		$prev_progress = $line->get_prev_progress();
-		if ($obj->situation_percent == 0) { // Avoid divide by 0
-			$situation_ratio = 0;
+		if ($obj->type==Facture::TYPE_SITUATION) {
+			// Avoid divide by 0
+			if ($obj->situation_percent == 0) { 
+				$situation_ratio = 0;
+			} else {
+				$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
+			}
 		} else {
-			$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
+			$situation_ratio = 1;
 		}
 
     	//la ligne facture

Some files were not shown because too many files changed in this diff