Completed
Branch develop (dabda4)
by
unknown
21:55
created
htdocs/fourn/class/fournisseur.commande.class.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 			$this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty
555 555
 
556 556
 			$this->fourn_id = $obj->fk_soc;
557
-			$this->statut = $obj->status;	// deprecated
557
+			$this->statut = $obj->status; // deprecated
558 558
 			$this->status = $obj->status;
559 559
 			$this->billed = $obj->billed;
560 560
 			$this->last_main_doc = $obj->last_main_doc;
@@ -687,9 +687,9 @@  discard block
 block discarded – undo
687 687
 				$line->localtax1_type	   = $objp->localtax1_type;
688 688
 				$line->localtax2_type	   = $objp->localtax2_type;
689 689
 				$line->subprice            = $objp->subprice;
690
-				$line->pu_ht 			   = $objp->subprice;	// deprecated
690
+				$line->pu_ht = $objp->subprice; // deprecated
691 691
 				$line->subprice_ttc        = $objp->subprice_ttc;
692
-				$line->pu_ttc 			   = $objp->subprice_ttc;	// deprecated
692
+				$line->pu_ttc = $objp->subprice_ttc; // deprecated
693 693
 				$line->remise_percent      = $objp->remise_percent;
694 694
 
695 695
 				$line->vat_src_code        = $objp->vat_src_code;
@@ -722,10 +722,10 @@  discard block
 block discarded – undo
722 722
 					$sqlsearchpackage .= ' WHERE entity IN ('.getEntity('productsupplierprice').")";
723 723
 					$sqlsearchpackage .= " AND fk_product = ".((int) $objp->fk_product);
724 724
 					$sqlsearchpackage .= " AND ref_fourn = '".$this->db->escape($objp->ref_supplier)."'";
725
-					$sqlsearchpackage .= " AND quantity <= ".((float) $objp->qty);	// required to be qualified
726
-					$sqlsearchpackage .= " AND (packaging IS NULL OR packaging = 0 OR packaging <= ".((float) $objp->qty).")";	// required to be qualified
725
+					$sqlsearchpackage .= " AND quantity <= ".((float) $objp->qty); // required to be qualified
726
+					$sqlsearchpackage .= " AND (packaging IS NULL OR packaging = 0 OR packaging <= ".((float) $objp->qty).")"; // required to be qualified
727 727
 					$sqlsearchpackage .= " AND fk_soc = ".((int) $this->socid);
728
-					$sqlsearchpackage .= " ORDER BY packaging ASC";		// Take the smaller package first
728
+					$sqlsearchpackage .= " ORDER BY packaging ASC"; // Take the smaller package first
729 729
 					$sqlsearchpackage .= " LIMIT 1";
730 730
 
731 731
 					$resqlsearchpackage = $this->db->query($sqlsearchpackage);
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 				$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
757 757
 				$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
758 758
 
759
-				$line->info_bits      	   = $objp->info_bits;
759
+				$line->info_bits = $objp->info_bits;
760 760
 				$line->special_code        = $objp->special_code;
761 761
 				$line->fk_parent_line      = $objp->fk_parent_line;
762 762
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 			if (!$error) {
888 888
 				$result = 1;
889 889
 				$this->status = self::STATUS_VALIDATED;
890
-				$this->statut = self::STATUS_VALIDATED;	// deprecated
890
+				$this->statut = self::STATUS_VALIDATED; // deprecated
891 891
 				$this->ref = $num;
892 892
 			}
893 893
 
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 		}
1131 1131
 
1132 1132
 		global $action;
1133
-		$hookmanager->initHooks(array($this->element . 'dao'));
1133
+		$hookmanager->initHooks(array($this->element.'dao'));
1134 1134
 		$parameters = array('id' => $this->id, 'getnomurl' => &$result);
1135 1135
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1136 1136
 		if ($reshook > 0) {
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 		$this->entity = setEntity($this);
1626 1626
 
1627 1627
 		// We set order into draft status
1628
-		$this->statut = self::STATUS_DRAFT;	// deprecated
1628
+		$this->statut = self::STATUS_DRAFT; // deprecated
1629 1629
 		$this->status = self::STATUS_DRAFT;
1630 1630
 
1631 1631
 		$sql = "INSERT INTO ".$this->db->prefix()."commande_fournisseur (";
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
 		$sql .= ", ".((int) $this->source);
1667 1667
 		$sql .= ", '".$this->db->escape(getDolGlobalString('COMMANDE_SUPPLIER_ADDON_PDF'))."'";
1668 1668
 		$sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null');
1669
-		$sql .= ", ".(!empty($this->deposit_percent) ? "'" . $this->db->escape($this->deposit_percent) . "'" : "null");
1669
+		$sql .= ", ".(!empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null");
1670 1670
 		$sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null');
1671 1671
 		$sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL');
1672 1672
 		$sql .= ", ".(int) $this->fk_incoterms;
@@ -1702,7 +1702,7 @@  discard block
 block discarded – undo
1702 1702
 						$line->localtax2_tx,
1703 1703
 						$line->fk_product,
1704 1704
 						0,
1705
-						$line->ref_supplier ? $line->ref_supplier : $line->ref_fourn, 			// $line->ref_fourn comes from field ref into table of lines. Value may be a ref that does not exists anymore, so we first try with value of product
1705
+						$line->ref_supplier ? $line->ref_supplier : $line->ref_fourn, // $line->ref_fourn comes from field ref into table of lines. Value may be a ref that does not exists anymore, so we first try with value of product
1706 1706
 						$line->remise_percent,
1707 1707
 						'HT',
1708 1708
 						0,
@@ -1713,10 +1713,10 @@  discard block
 block discarded – undo
1713 1713
 						$line->date_end,
1714 1714
 						$line->array_options,
1715 1715
 						$line->fk_unit,
1716
-						$line->multicurrency_subprice,  // pu_ht_devise
1717
-						$line->origin,     // origin
1718
-						$line->origin_id,  // origin_id
1719
-						$line->rang,       // rang
1716
+						$line->multicurrency_subprice, // pu_ht_devise
1717
+						$line->origin, // origin
1718
+						$line->origin_id, // origin_id
1719
+						$line->rang, // rang
1720 1720
 						$line->special_code
1721 1721
 					);
1722 1722
 					if ($result < 0) {
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
 			if ($objsoc->fetch($socid) > 0) {
1936 1936
 				$this->socid = $objsoc->id;
1937 1937
 				$this->cond_reglement_id	= (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
1938
-				$this->deposit_percent		= (!empty($objsoc->deposit_percent) ? $objsoc->deposit_percent : 0);
1938
+				$this->deposit_percent = (!empty($objsoc->deposit_percent) ? $objsoc->deposit_percent : 0);
1939 1939
 				$this->mode_reglement_id	= (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
1940 1940
 				$this->fk_project = 0;
1941 1941
 				$this->fk_delivery_address = 0;
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
 			$this->db->begin();
2092 2092
 
2093 2093
 			$product_type = $type;
2094
-			$label = '';	// deprecated
2094
+			$label = ''; // deprecated
2095 2095
 
2096 2096
 			if ($fk_product > 0) {
2097 2097
 				if (getDolGlobalInt('SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY') == 1) {	// Not the common case
@@ -2153,7 +2153,7 @@  discard block
 block discarded – undo
2153 2153
 					if ($qty < $prod->packaging) {
2154 2154
 						$qty = (float) $prod->packaging;
2155 2155
 					} else {
2156
-						if (!empty($prod->packaging) && (fmod((float) $qty, (float) $prod->packaging)  > 0.000001)) {
2156
+						if (!empty($prod->packaging) && (fmod((float) $qty, (float) $prod->packaging) > 0.000001)) {
2157 2157
 							$coeff = intval((float) $qty / $prod->packaging) + 1;
2158 2158
 							$qty = (float) $prod->packaging * $coeff;
2159 2159
 							setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'mesgs');
@@ -2246,8 +2246,8 @@  discard block
 block discarded – undo
2246 2246
 			// Multicurrency
2247 2247
 			$this->line->fk_multicurrency = $this->fk_multicurrency;
2248 2248
 			$this->line->multicurrency_code = $this->multicurrency_code;
2249
-			$this->line->multicurrency_subprice	= (float) $pu_ht_devise;
2250
-			$this->line->multicurrency_total_ht 	= (float) $multicurrency_total_ht;
2249
+			$this->line->multicurrency_subprice = (float) $pu_ht_devise;
2250
+			$this->line->multicurrency_total_ht = (float) $multicurrency_total_ht;
2251 2251
 			$this->line->multicurrency_total_tva 	= (float) $multicurrency_total_tva;
2252 2252
 			$this->line->multicurrency_total_ttc 	= (float) $multicurrency_total_ttc;
2253 2253
 
@@ -3336,7 +3336,7 @@  discard block
 block discarded – undo
3336 3336
 		$this->status = 0;
3337 3337
 
3338 3338
 		// Lines
3339
-		$nbp = min(1000, GETPOSTINT('nblines') ? GETPOSTINT('nblines') : 5);	// We can force the nb of lines to test from command line (but not more than 1000)
3339
+		$nbp = min(1000, GETPOSTINT('nblines') ? GETPOSTINT('nblines') : 5); // We can force the nb of lines to test from command line (but not more than 1000)
3340 3340
 		$xnbp = 0;
3341 3341
 		while ($xnbp < $nbp) {
3342 3342
 			$line = new CommandeFournisseurLigne($this->db);
@@ -3563,7 +3563,7 @@  discard block
 block discarded – undo
3563 3563
 		global $langs;
3564 3564
 
3565 3565
 		if (!dol_strlen($modele)) {
3566
-			$modele = '';	// No doc template/generation by default
3566
+			$modele = ''; // No doc template/generation by default
3567 3567
 
3568 3568
 			if (!empty($this->model_pdf)) {
3569 3569
 				$modele = $this->model_pdf;
Please login to merge, or discard this patch.
test/phpunit/CommandeFournisseurTest.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *      \remarks    To run this script as CLI:  phpunit filename.php
26 26
  */
27 27
 
28
-global $conf,$user,$langs,$db;
28
+global $conf, $user, $langs, $db;
29 29
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
30 30
 //require_once 'PHPUnit/Autoload.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function testCommandeFournisseurCreate()
60 60
 	{
61
-		global $conf,$user,$langs,$db;
61
+		global $conf, $user, $langs, $db;
62 62
 		$conf = $this->savconf;
63 63
 		$user = $this->savuser;
64 64
 		$langs = $this->savlangs;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		// TODO
84 84
 
85 85
 		// Create 1 supplier price with min qty = 10;
86
-		$result = $product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity);    // This insert record with no value for price. Values are update later with update_buyprice
86
+		$result = $product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice
87 87
 		print __METHOD__." add_fournisseur result=".$result."\n";
88 88
 		$this->assertGreaterThanOrEqual(0, $result, 'Create 1 supplier price with min qty = 10 if not exists');
89 89
 		$result = $product->update_buyprice($quantity, 20, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0);
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 		$localobject = new CommandeFournisseur($db);
97 97
 		$param = array('tobuy' => 1);
98 98
 		$localobject->initAsSpecimen($param);
99
-		$localobject->lines = array();    // Overwrite lines of order
99
+		$localobject->lines = array(); // Overwrite lines of order
100 100
 		$line = new CommandeFournisseurLigne($db);
101 101
 		$line->desc = $langs->trans("Description")." specimen line with qty too low";
102
-		$line->qty = 1;                   // So lower than $quantity
102
+		$line->qty = 1; // So lower than $quantity
103 103
 		$line->subprice = 100;
104 104
 		$line->fk_product = $product->id;
105 105
 		$line->ref_fourn = $ref_fourn;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
 		$result = $localobject->create($user);
110 110
 		print __METHOD__." result=".$result."\n";
111
-		$this->assertEquals(-1, $result, 'Creation of too low quantity');   // must be -1 because quantity is lower than minimum of supplier price
111
+		$this->assertEquals(-1, $result, 'Creation of too low quantity'); // must be -1 because quantity is lower than minimum of supplier price
112 112
 
113 113
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref IN ('', '(PROV)')";
114 114
 		$db->query($sql);
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 		// Create purchase order
117 117
 		$localobject2 = new CommandeFournisseur($db);
118 118
 		$param = array('tobuy' => 1);
119
-		$localobject2->initAsSpecimen($param);    // This create 5 lines of first product found for socid 1
120
-		$localobject2->lines = array();       // Overwrite lines of order
119
+		$localobject2->initAsSpecimen($param); // This create 5 lines of first product found for socid 1
120
+		$localobject2->lines = array(); // Overwrite lines of order
121 121
 		$line = new CommandeFournisseurLigne($db);
122 122
 		$line->desc = $langs->trans("Description")." specimen line ok";
123
-		$line->qty = 10;                      // So enough quantity
123
+		$line->qty = 10; // So enough quantity
124 124
 		$line->subprice = 100;
125 125
 		$line->fk_product = $product->id;
126 126
 		$line->ref_supplier = $ref_fourn;
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 		$localobject3 = new CommandeFournisseur($db);
138 138
 		$param = array('tobuy' => 1);
139 139
 		$localobject3->initAsSpecimen($param);
140
-		$localobject3->lines = array();    // Overwrite lines of order
140
+		$localobject3->lines = array(); // Overwrite lines of order
141 141
 		$line = new CommandeFournisseurLigne($db);
142 142
 		$line->desc = $langs->trans("Description")." specimen line with qty too low";
143
-		$line->qty = 1;                   // So lower than $quantity
143
+		$line->qty = 1; // So lower than $quantity
144 144
 		$line->subprice = 100;
145 145
 		$line->fk_product = $product->id;
146 146
 		$line->ref_supplier = $ref_fourn;
@@ -148,18 +148,18 @@  discard block
 block discarded – undo
148 148
 
149 149
 		$result = $localobject3->create($user);
150 150
 		print __METHOD__." result=".$result."\n";
151
-		$this->assertGreaterThan(0, $result, 'Creation of too low quantity should be ok');   // must be id of line because there is no test on minimum quantity
151
+		$this->assertGreaterThan(0, $result, 'Creation of too low quantity should be ok'); // must be id of line because there is no test on minimum quantity
152 152
 
153 153
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''";
154 154
 		$db->query($sql);
155 155
 
156 156
 		// Create purchase order
157 157
 		$localobject4 = new CommandeFournisseur($db);
158
-		$localobject4->initAsSpecimen();    // This create 5 lines of first product found for socid 1
159
-		$localobject4->lines = array();       // Overwrite lines of order
158
+		$localobject4->initAsSpecimen(); // This create 5 lines of first product found for socid 1
159
+		$localobject4->lines = array(); // Overwrite lines of order
160 160
 		$line = new CommandeFournisseurLigne($db);
161 161
 		$line->desc = $langs->trans("Description")." specimen line ok";
162
-		$line->qty = 10;                      // So enough quantity
162
+		$line->qty = 10; // So enough quantity
163 163
 		$line->subprice = 100;
164 164
 		$line->fk_product = $product->id;
165 165
 		$localobject4->lines[] = $line;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public function testCommandeFournisseurFetch($id)
185 185
 	{
186
-		global $conf,$user,$langs,$db;
186
+		global $conf, $user, $langs, $db;
187 187
 		$conf = $this->savconf;
188 188
 		$user = $this->savuser;
189 189
 		$langs = $this->savlangs;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function testCommandeFournisseurValid($localobject)
210 210
 	{
211
-		global $conf,$user,$langs,$db;
211
+		global $conf, $user, $langs, $db;
212 212
 		$conf = $this->savconf;
213 213
 		$user = $this->savuser;
214 214
 		$langs = $this->savlangs;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	public function testCommandeFournisseurApprove($localobject)
234 234
 	{
235
-		global $conf,$user,$langs,$db;
235
+		global $conf, $user, $langs, $db;
236 236
 		$conf = $this->savconf;
237 237
 		$user = $this->savuser;
238 238
 		$langs = $this->savlangs;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	public function testCommandeFournisseurCancel($localobject)
258 258
 	{
259
-		global $conf,$user,$langs,$db;
259
+		global $conf, $user, $langs, $db;
260 260
 		$conf = $this->savconf;
261 261
 		$user = $this->savuser;
262 262
 		$langs = $this->savlangs;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 */
281 281
 	public function testCommandeFournisseurOther($localobject)
282 282
 	{
283
-		global $conf,$user,$langs,$db;
283
+		global $conf, $user, $langs, $db;
284 284
 		$conf = $this->savconf;
285 285
 		$user = $this->savuser;
286 286
 		$langs = $this->savlangs;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 */
312 312
 	public function testCommandeFournisseurDelete($id)
313 313
 	{
314
-		global $conf,$user,$langs,$db;
314
+		global $conf, $user, $langs, $db;
315 315
 		$conf = $this->savconf;
316 316
 		$user = $this->savuser;
317 317
 		$langs = $this->savlangs;
Please login to merge, or discard this patch.