Changes

Jump to navigation Jump to search
→‎Change subprice in database: update overloading function, should work now
Line 371: Line 371:  
     // Fetch the new posted values
 
     // Fetch the new posted values
 
     // All $_POST data are generically appended into the $object properties
 
     // All $_POST data are generically appended into the $object properties
     $coefficient = $object->{$customfields->varprefix.'coefficient'};
+
     $coefficient = $object->{$customfields->varprefix.'coefficient'}; // you could also use $coefficient = $value;
 
+
 
     // Clean parameters
 
     // Clean parameters
 
     include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
 
     include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
 
     $coefficient = price2num($coefficient);
 
     $coefficient = price2num($coefficient);
 
+
 
     // Get the original subprices (it's not automatic when we edit remise_percent and update, we have to recompute manually the prices before calling $object->update())
 
     // Get the original subprices (it's not automatic when we edit remise_percent and update, we have to recompute manually the prices before calling $object->update())
 
     global $mysoc;
 
     global $mysoc;
 
     $localtaxes_type=getLocalTaxesFromRate($object->tva_tx,0,$mysoc);
 
     $localtaxes_type=getLocalTaxesFromRate($object->tva_tx,0,$mysoc);
     $tabprice=calcul_price_total($object->qty, $object->price, $object->remise_percent, $object->tva_tx, $object->localtax1_tx, $object->localtax2_tx, 0, 'HT', $object->info_bits, $object->type, '', $localtaxes_type);
+
     $tabprice=calcul_price_total($object->qty, $object->subprice, $object->remise_percent, $object->tva_tx, $object->localtax1_tx, $object->localtax2_tx, 0, 'HT', $object->info_bits, $object->type, '', $localtaxes_type);
 
     $object->total_ht  = $tabprice[0];
 
     $object->total_ht  = $tabprice[0];
 
     $object->total_tva = $tabprice[1];
 
     $object->total_tva = $tabprice[1];
Line 386: Line 386:  
     $object->total_localtax1 = $tabprice[9];
 
     $object->total_localtax1 = $tabprice[9];
 
     $object->total_localtax2 = $tabprice[10];
 
     $object->total_localtax2 = $tabprice[10];
 
+
 
     // Update the subprices with the coefficient
 
     // Update the subprices with the coefficient
 
     $object->total_ht = $object->total_ht * $coefficient; // compute no tax price
 
     $object->total_ht = $object->total_ht * $coefficient; // compute no tax price
 
     $object->total_tva = $object->total_tva * $coefficient; // compute tax amount
 
     $object->total_tva = $object->total_tva * $coefficient; // compute tax amount
 
     $object->total_ttc = $object->total_ttc * $coefficient; // compute tax included price
 
     $object->total_ttc = $object->total_ttc * $coefficient; // compute tax included price
 
+
 
     // Update into database
 
     // Update into database
     $object->update(true); // true to disable the trigger, else it will recall customfields, which will call this overloading function, etc. in an infinite loop.
+
     $object->update('',true); // true to disable the trigger, else it will recall customfields, which will call this overloading function, etc. in an infinite loop.
 
     $object->update_total();
 
     $object->update_total();
 
+
 
     // Finally, cleanup POST data to avoid conflicts next time, reinserting the same discount. Else the fields will remember these values and it may mistakenly reuse the same values.
 
     // Finally, cleanup POST data to avoid conflicts next time, reinserting the same discount. Else the fields will remember these values and it may mistakenly reuse the same values.
 
     unset($_POST[$customfields->varprefix."coefficient"]);
 
     unset($_POST[$customfields->varprefix."coefficient"]);
439

edits

Navigation menu