Fix bug : for new TVA id not taken into account but auto-computed
This commit is contained in:
parent
0ad83ac24b
commit
a76d9d1162
2 changed files with 11 additions and 8 deletions
|
|
@ -220,7 +220,8 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
}
|
||||
}
|
||||
$new_tva_id=$this->table->tva_id;
|
||||
$tva_rate=new Tva_rate_SQL($cn, $this->previous_id);
|
||||
$tva_rate=new Tva_rate_SQL($cn);
|
||||
$tva_rate->setp("tva_id",$new_tva_id);
|
||||
$tva_rate->setp("tva_rate", $this->table->tva_rate);
|
||||
$tva_rate->setp("tva_label", $this->table->tva_label);
|
||||
$tva_rate->setp("tva_comment", $this->table->tva_comment);
|
||||
|
|
@ -232,13 +233,15 @@ class Tva_Rate_MTable extends Manage_Table_SQL
|
|||
$tva_rate->setp("tva_poste", $tva_purchase.",".$tva_sale);
|
||||
$tva_rate->setp("tva_payment_sale", $this->table->tva_payment_sale);
|
||||
$tva_rate->setp("tva_payment_purchase", $this->table->tva_payment_purchase);
|
||||
$tva_rate->save();
|
||||
if ($this->previous_id != $new_tva_id) {
|
||||
if ( $this->previous_id == -1 ) {
|
||||
$tva_rate->insert();
|
||||
} else {
|
||||
$tva_rate->update();
|
||||
}
|
||||
if ( $this->previous_id != - 1 && $this->previous_id != $new_tva_id) {
|
||||
$cn->exec_sql("update tva_rate set tva_id = $1 where tva_id = $2",[$new_tva_id,$this->previous_id]);
|
||||
$tva_rate->setp("tva_id",$new_tva_id);
|
||||
}else
|
||||
$this->table->setp("tva_id",$tva_rate->getp("tva_id"));
|
||||
$this->table->load();
|
||||
$this->table->setp("tva_id",$new_tva_id);
|
||||
}else $this->table->setp("tva_id",$tva_rate->getp("tva_id"));
|
||||
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ abstract class Data_SQL
|
|||
$this->$key=null;
|
||||
}
|
||||
$this->$pk=$p_id;
|
||||
/* load it */
|
||||
/* load it , if the pk id doesn't exist, it will be turned into -1 */
|
||||
if ($p_id != -1 )$this->load();
|
||||
if ( empty($this->date_format) ) $this->date_format="DD.MM.YYYY";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue