Fix: [ bug #1400 ] Silent Warning create a draft invoice

This commit is contained in:
Laurent Destailleur 2014-05-25 05:01:14 +02:00
parent 1690da2369
commit 8e7b310fb6
3 changed files with 24 additions and 14 deletions

View File

@ -798,7 +798,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
$object->fetch_thirdparty();
// If creation from another object of another module (Example: origin=propal, originid=1)
if ($_POST['origin'] && $_POST['originid']) {
if ($_POST['origin'] && $_POST['originid'])
{
// Parse element/subelement (ex: project_task)
$element = $subelement = $_POST['origin'];
if (preg_match('/^([^_]+)_([^_]+)/i', $_POST['origin'], $regs)) {
@ -835,15 +836,20 @@ else if ($action == 'add' && $user->rights->facture->creer)
$id = $object->create($user);
if ($id > 0) {
if ($id > 0)
{
// If deposit invoice
if ($_POST['type'] == 3) {
if ($_POST['type'] == 3)
{
$typeamount = GETPOST('typedeposit', 'alpha');
$valuedeposit = GETPOST('valuedeposit', 'int');
if ($typeamount == 'amount') {
if ($typeamount == 'amount')
{
$amountdeposit = $valuedeposit;
} else {
}
else
{
$amountdeposit = 0;
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
@ -853,7 +859,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add deposit lines");
$result = $srcobject->fetch($object->origin_id);
if ($result > 0) {
if ($result > 0)
{
$totalamount = 0;
$lines = $srcobject->lines;
$numlines=count($lines);
@ -898,7 +905,9 @@ else if ($action == 'add' && $user->rights->facture->creer)
0,
$langs->trans('Deposit')
);
} else {
}
else
{
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
@ -907,10 +916,10 @@ else if ($action == 'add' && $user->rights->facture->creer)
dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
$result = $srcobject->fetch($object->origin_id);
if ($result > 0) {
if ($result > 0)
{
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
$lines = $srcobject->fetch_lines();
if (empty($lines) && method_exists($srcobject, 'fetch_lines')) $lines = $srcobject->fetch_lines();
$fk_parent_line=0;
$num=count($lines);
@ -919,7 +928,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
$label=(! empty($lines[$i]->label)?$lines[$i]->label:'');
$desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
if ($lines [$i]->subprice < 0) {
if ($lines [$i]->subprice < 0)
{
// Negative line, we create a discount line
$discount = new DiscountAbsolute($db);
$discount->fk_soc = $object->socid;

View File

@ -2056,7 +2056,7 @@ class Facture extends CommonInvoice
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, '', $localtaxes_type);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
@ -2133,7 +2133,7 @@ class Facture extends CommonInvoice
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la facture meme
$result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
$result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
if ($result > 0)
{
$this->db->commit();

View File

@ -1518,7 +1518,7 @@ abstract class CommonObject
* @param int $exclspec >0 = Exclude special product (product_type=9)
* @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total
* @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
* @param Societe $seller If roundingadjust is 0, it means we recalculate total for lines before calculating total for object. For this, we need seller object.
* @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object. For this, we need seller object.
* @return int <0 if KO, >0 if OK
*/
function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller='')