noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Tva_Rate_MTable Class Reference

Configure the tva : code , rate, label ... When using Manage_Table_SQL. More...

+ Inheritance diagram for Tva_Rate_MTable:
+ Collaboration diagram for Tva_Rate_MTable:

Public Member Functions

 __construct (V_Tva_rate_SQL $p_table)
 
 check ()
 Check data are valid.
 
 delete ()
 delete if not used anywhere
 
 from_request ()
 add the TVA_REVERSE_ACCOUNT
 
 getPreviousId ()
 
 input ()
 display into a dialog box the datarow in order to be appended or modified.
 
 save ()
 save the data in TVA_RATE if tva_both_side is 1 and tva_purchase or tva_sale is empty then it is equal to the other value
 
 setPreviousId ($previous_id)
 
- Public Member Functions inherited from Manage_Table_SQL
 __construct (Data_SQL $p_table)
 
 add_json_param ($p_attribute, $p_value)
 Add json parameter to the current one.
 
 ajax_delete ()
 Delete a record and return an XML answer for ajax.
 
 ajax_input ($p_status="OK")
 send an xml with input of the object, create an xml answer.
 
 ajax_save ()
 Save the record from Request into the DB and returns an XML to update the Html Element.
 
 can_append_row ()
 return false if the append of the row is forbidden
 
 can_delete_row ()
 return false if the delete of the row is forbidden
 
 can_update_row ()
 return false if the update of the row is forbidden
 
 count_error ()
 returns the nb of errors found
 
 create_js_script ()
 we must create first the javascript if we want to update, insert or delete rows.
 
 display_error ()
 Display a list of the error collected.
 
 display_icon_custom ($p_row)
 usually contain a link and calls another page, it must be overriden
 
 display_icon_del ($p_row)
 
 display_icon_mod ($p_row)
 
 display_row ($p_row)
 display a data row in the table, with the order defined in a_order and depending of the visibility of the column, all the rows contains the attribute ctl_pk_id , to retrieve in javascript , ie with the function afterSaveFct (see managetable.js)
 
 display_row_custom ($p_key, $p_value, $p_id=0)
 When displaying a row, if a column has the type "custom" , we can call this function to display properly the value including the tag "<td>".
 
 display_table ($p_order="", $p_array=NULL)
 display the data of the table
 
 display_table_header ()
 display the column header excepted the not visible one and in the order defined with $this->a_order
 
 execute_query ($p_order="", $p_array=NULL)
 execute the query (Data_SQL.seek), called by display_table
 
 get_button_add_top ()
 
 get_col_option ($p_key)
 add extra to column, normally class , javascript or style
 
 get_col_sort ()
 When adding an element , it is column we checked to insert before,.
 
 get_col_type ($p_key)
 return the type of a column
 
 get_current_pos ($p_key)
 get the position of a column
 
 get_current_row ()
 Return the current row printed in display_row.
 
 get_dialog_box ()
 
 get_dialogbox_style ()
 return the db_style
 
 get_error ($p_col)
 retrieve the error message
 
 get_header_option ($p_key)
 add extra to column Header, normally class , javascript or style
 
 get_icon_del ()
 
 get_icon_mod ()
 
 get_js_variable ()
 Get the object name.
 
 get_json ()
 
 get_object_name ()
 
 get_order ()
 
 get_property_updatable ($p_key)
 return True if the column is updatable otherwise false
 
 get_property_visible ($p_key)
 return True if the column is visible otherwise false
 
 get_search_table ()
 Get if we can search in the table.
 
 get_sort_column ()
 return the column to sort
 
 get_table ()
 
 getCssClass ()
 
 getTitle ()
 
 input_custom ($p_key, $p_value)
 this function let you create your own input , for example for a ITEXT , a IRADIO , ... it must be override , there is not default
 
 insert ()
 insert a new value
 
 move ($p_key, $p_idx)
 if we change a column order , the order of the other columns is impacted.
 
 param_set ($p_json)
 Set the parameter of the object (gDossier, ac, plugin_code...) @detail By default , only gDossier will be set .
 
 send_header ()
 send the XML headers for the ajax call
 
 set_append_row ($p_value)
 Enable or disable the appending of rows.
 
 set_button_add_top ($button_add_top)
 
 set_callback ($p_file)
 set the callback function that is passed to javascript
 
 set_col_label ($p_key, $p_display)
 set the name to display for a column
 
 set_col_option ($p_key, $p_value)
 add extra to column, normally class or style
 
 set_col_sort ($p_num)
 When adding an element ,we place it thanks the DOM Attribute sort_value set it to -1 if you want one to append.
 
 set_col_tips ($p_key, $p_comment)
 Set the info for a column, use Icon_Action\infobulle the message are in message_javascript.php.
 
 set_col_type ($p_key, $p_value, $p_array=NULL)
 set the type of a column , it will change in the input db box , the select must supply an array of possible values [val=> , label=>] with the variable $this->key_name->a_value
 
 set_current_row ($current_row)
 set the current row printed in display_row
 
 set_delete_row ($p_value)
 Enable or disable the deletion of rows.
 
 set_dialog_box ($dialog_box)
 
 set_dialogbox_style ($db_style)
 Dialog box style , by default {position: "fixed", top: '15', width: "auto", "margin-left": "20%"}.
 
 set_error ($p_col, $p_message)
 set the error message for a wrong input
 
 set_header_option ($p_key, $p_value)
 add extra to column Header, normally class or style
 
 set_icon_del ($pString)
 Set the icon to delete at the right or left of the row.
 
 set_icon_mod ($pString)
 Set the icon to modify at the right ,the first col or left of the row, if the mod if custom , you have to override the function display_icon_custom.
 
 set_json ($p_json)
 Set the parameter of the object (gDossier, ac, plugin_code...) @detail By default , only gDossier will be set .
 
 set_object_name ($p_object_name)
 Set the object_name.
 
 set_order ($p_order)
 
 set_pk ($p_id)
 set the id value of a data row and load from the db
 
 set_property_updatable ($p_key, $p_value)
 set a column of the data row updatable or not
 
 set_property_visible ($p_key, $p_value)
 set a column of the data row visible or not
 
 set_search_table ($search_table)
 Set the table searchable or not.
 
 set_sort_column ($p_col)
 set the column to sort by default
 
 set_table (Data_SQL $p_noalyss_sql)
 
 set_update_row ($p_value)
 Enable or disable the updating of rows.
 
 set_value ($p_key, $p_value)
 
 setCssClass ($p_class)
 
 setTitle ($p_title)
 Set the title of the diabox , default is Donnée.
 
 show_error ($p_col)
 
 update ()
 

Private Attributes

 $a_comment
 Supplemental explanation.
 
 $previous_id
 < previous tva_id, used to know if we update or insert,
 

Additional Inherited Members

- Data Fields inherited from Manage_Table_SQL
const UPDATABLE =1
 
const VISIBLE =2
 
- Protected Attributes inherited from Manage_Table_SQL
 $a_col_option
 in display_row and display_custom_row, it is the current row which is used
 
 $a_header_option
 Extra to add to the column Header : CSS Style , CSS class, javascript ,...
 
 $a_info
 Array with the infotip.
 
 $a_label_displaid
 Label of the col. of the datarow.
 
 $a_order
 order of the col
 
 $a_prop
 property for each col.
 
 $a_select
 Possible value if a_type is a SELECT.
 
 $a_type
 Type of the column : date , select ... Only in input.
 
 $aerror
 Array containing the error of the input data.
 
 $button_add_top
 place of the button add on the top, by default true
 
 $callback
 Callback function.
 
 $col_sort
 when inserting, it is the column to sort,-1 to disable it and append only
 
 $cssclass
 < give the title of the diabox , default is Data
 
 $current_row
 CSS class for the dialog box.
 
 $dialog_box
 ID of the dialog box which display the result of the ajax calls.
 
 $dialogbox_style
 style of the dialog box
 
 $icon_del
 place of right or left the icon update or mod, default right, accepted value=left,right
 
 $icon_mod
 place of right or left the icon update or mod, default right, accepted value=left,right,first,custom column for mod
 
 $json_parameter
 Default parameter to add (gDossier...), sent to the ajax callback.
 
 $object_name
 Object_name is used for the javascript , it is the row id to update or delete.
 
 $row_append
 Flag to indicate if rows can be added.
 
 $row_delete
 Flag to indicate if rows can be deleted.
 
 $row_update
 Flag to indicate if rows can be updated.
 
 $search_table
 boolean , by default true ,it is possible to search in the table,
 
 $sort_column
 javascript sort on this column , if empty there is no js sort
 
 $table
 Object Data_SQL.
 
 $title
 

Detailed Description

Configure the tva : code , rate, label ... When using Manage_Table_SQL.

Examples
tva_parameter.php.

Definition at line 34 of file tva_rate_mtable.class.php.

Constructor & Destructor Documentation

◆ __construct()

Tva_Rate_MTable::__construct ( V_Tva_rate_SQL $p_table)

Definition at line 46 of file tva_rate_mtable.class.php.

47 {
48 parent::__construct($p_table);
49 $this->set_col_label("tva_id", _("id"));
50 $this->set_col_label("tva_code", _("Code"));
51 $this->set_col_label("tva_label", _("label"));
52 $this->set_col_label("tva_rate", _("taux"));
53 $this->set_col_label("tva_comment", _("Description"));
54 $this->set_col_label("tva_both_side", _("Autoliquidation"));
55 $this->set_col_label("tva_reverse_account", _('Poste comptable autoliquidation'));
56 $this->set_col_label("tva_sale", _("TVA Vente (C)"));
57 $this->set_col_label("tva_purchase", _("TVA Achat (D)"));
58
59 $this->set_property_visible('tva_reverse_account', false);
60
61 $this->set_col_type("tva_both_side", "select",
62 array(
63 ["value"=>0, "label"=>_("Non")],
64 ["value"=>1, "label"=>_("Oui")]
65 ));
66 $this->set_col_type("tva_reverse_account", 'custom');
67 $this->set_property_updatable("tva_id", true);
68 $this->set_col_label("tva_payment_purchase",_("Exigible achat"));
69 $this->set_col_type("tva_payment_purchase","select",
70 array(
71 array("value"=>'O',"label"=>"Opération"),
72 array("value"=>'P',"label"=>"Paiement")
73 )
74 );
75 $this->set_col_label("tva_payment_sale",_("Exigible vente"));
76 $this->set_col_type("tva_payment_sale","select",
77 array(
78 array("value"=>'O',"label"=>"Opération"),
79 array("value"=>'P',"label"=>"Paiement")
80 )
81 );
82 $this->a_info=[
83 "tva_purchase"=>44,"tva_both_side"=>43,"tva_sale"=>45
84 ,"tva_payment_sale"=>74,"tva_payment_purchase"=>74,'tva_reverse_account'=>88];
85 $this->previous_id=null;
86 $this->a_comment=array(
87 'tva_purchase'=>_("Ne donnez pas ce poste comptable si ce code n'est pas utilisé à l'achat"),
88 'tva_both_side'=>_("Autoliquidation : Utilisé en même temps au crédit et au débit"),
89 'tva_sale'=>_("Ne donnez pas ce poste comptable si ce code n'est pas utilisé à la vente"),
90 'tva_payment_purchase'=>_('TVA due ou récupérable quand l\'opération est payée ou exécutée'),
91 'tva_payment_sale'=>_('TVA due ou récupérable quand l\'opération est payée ou exécutée'),
92 'tva_reverse_account'=>_("Forcer ce poste comptable pour autoliquidation : par défault, le poste d'autoliquidation est calculé : soit celui qui est en contrepartie, soit le même (voir manuel)")
93 );
94 }
_("actif, passif,charge,...")
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
set_col_type($p_key, $p_value, $p_array=NULL)
set the type of a column , it will change in the input db box , the select must supply an array of po...
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
set_col_label($p_key, $p_display)
set the name to display for a column

References _, Manage_Table_SQL\set_col_label(), Manage_Table_SQL\set_col_type(), Manage_Table_SQL\set_property_updatable(), and Manage_Table_SQL\set_property_visible().

+ Here is the call graph for this function:

Member Function Documentation

◆ check()

Tva_Rate_MTable::check ( )

Check data are valid.

  1. tva_rate between 0 & 1
  2. label is uniq
  3. accounting must exist
    Returns
    boolean

auto reverse VAT : check that the accounting is used

Reimplemented from Manage_Table_SQL.

Definition at line 298 of file tva_rate_mtable.class.php.

299 {
301 if ( $this->previous_id === null ) {
302 throw new \Exception ("TVA184: no previous TVA id");
303 }
304 // both accounting can not be empty
305 if (trim($this->table->tva_purchase??"")==""&&trim($this->table->tva_sale??"")=="")
306 {
307 $this->set_error("tva_purchase",
308 _("Les 2 postes comptables ne peuvent être nuls"));
309 $this->set_error("tva_sale",
310 _("Les 2 postes comptables ne peuvent être nuls"));
311 }
312
313 // Check the tva rate
314 if (trim($this->table->tva_rate??"")==""||isNumber($this->table->tva_rate)==0||$this->table->tva_rate>1)
315 {
316 $this->set_error("tva_rate", _("Taux de TVA invalide"));
317 }
318
319 //Check the label must be unique
320 $count=$cn->get_value("select count(*) from tva_rate where tva_id<>$1 and lower(tva_label)=lower($2)",
321 [$this->getPreviousId(), $this->table->tva_label]);
322 if ($count>0)
323 {
324 $this->set_error("tva_label", _("Ce nom est déjà utilisé"));
325 }
326
327 // Check accounting exists for purchase
328 if (trim($this->table->tva_purchase??"")!=""&&$this->table->tva_purchase!="#")
329 {
330 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1",
331 [$this->table->tva_purchase]);
332 if ($count==0)
333 {
334 $this->set_error("tva_purchase", _("Poste comptable inexistant"));
335 }
336 }
337 // Check accounting exists for sale
338 if (trim($this->table->tva_sale??"")!=""&&$this->table->tva_sale!="#")
339 {
340 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1",
341 [$this->table->tva_sale]);
342 if ($count==0)
343 {
344 $this->set_error("tva_sale", _("Poste comptable inexistant"));
345 }
346 }
347
348 // check if tva_both_side is valid
349 if ($this->table->tva_both_side!=0&&$this->table->tva_both_side!=1)
350 {
351 $this->set_error("tva_both_side", _("Choix incorrect"));
352 }
353 $flag = true;
354 // Check that tva_id is a integer not a float (TVA_ID is an integer)
355 if ( isNumber($this->table->tva_id) == 0 || $this->table->tva_id != round($this->table->tva_id) )
356 {
357 $this->set_error("tva_id",_("Valeur invalide"));
358 $flag=false;
359 }
360 // Check if old tva_id was not overwritting something
361 if ( $flag && $this->previous_id != $this->table->tva_id && $cn->get_value("select count(*) from tva_rate where tva_id=$1",[$this->table->tva_id]) > 0)
362 {
363 $this->set_error("tva_id",_("Code TVA déjà utilisé"));
364 }
365 // Check that tva code is unique and remove not letter
366 $this->table->tva_code=strtoupper(trim( $this->table->tva_code));
367 $tva_code=$this->table->tva_code;
368
369 $tva_code=strtoupper($tva_code);
370 $tva_code=preg_replace("/[A-Z]/", "", $tva_code);
371 $tva_code=preg_replace("/[0-9]/", "", $tva_code);
372
373 if (strlen($tva_code)>0){
374 $this->set_error("tva_code", _("code tva : Uniquement des chiffres et des lettres"));
375 }
376
377 if (strlen($this->table->tva_code)>5){
378 $this->set_error("tva_code", _("code tva : Maximum 5 caractères"));
379 }
380 if (isNumber($this->table->tva_code) == 1){
381 $this->set_error("tva_code", _("code tva : doit aussi contenir des lettres"));
382 }
383 /**
384 * auto reverse VAT : check that the accounting is used
385 */
386 if ( $this->table->tva_both_side==0 && trim($this->table->tva_reverse_account??"") != "")
387 {
388 $this->set_error("tva_reverse_account", _("Pas d'autoliquidation demandé"));
389 }
390 if ( $this->table->tva_both_side==1 && trim($this->table->tva_reverse_account??"") != "")
391 {
392 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1",
393 [$this->table->tva_reverse_account]);
394 if ($count==0)
395 {
396 $this->set_error("tva_reverse_account", _("Poste comptable inexistant"));
397 }
398 }
399 // label cannot be empty
400 if ( trim($this->table->tva_label??"")=="") {
401 $this->set_error("tva_label", _('Le label ne peut être vide'));
402 }
403 if ($this->count_error()!=0)
404 return false;
405 return true;
406 }
isNumber($p_int)
static connect()
count_error()
returns the nb of errors found
set_error($p_col, $p_message)
set the error message for a wrong input
$all table
$count
$flag
Definition install.php:536

References $cn, $count, $flag, _, Manage_Table_SQL\count_error(), getPreviousId(), isNumber(), Manage_Table_SQL\set_error(), and table.

+ Here is the call graph for this function:

◆ delete()

Tva_Rate_MTable::delete ( )

delete if not used anywhere

Reimplemented from Manage_Table_SQL.

Definition at line 410 of file tva_rate_mtable.class.php.

411 {
413 $count_purchase=$cn->get_value("select count(*) from quant_purchase where qp_vat_code = $1",[$this->table->tva_id]);
414 $count_sale=$cn->get_value("select count(*) from quant_sold where qs_vat_code = $1",[$this->table->tva_id]);
415 if ( $count_purchase > 0 || $count_sale > 0) {
416 throw new Exception(_("Effacement interdit : TVA utilisée"));
417 }
418
419 // Forbid to remove all tva
420 $count=$cn->get_value("select count(*) from tva_rate");
421 if ( $count < 2) {
422 throw new Exception(_("Vous ne pouvez pas effacer tous les taux. Si votre société n'utilise pas la TVA, changer dans le menu société"));
423 }
424 $cn->exec_sql("delete from tva_rate where tva_id=$1", [$this->table->tva_id]);
425 }

References $cn, $count, _, and table.

◆ from_request()

Tva_Rate_MTable::from_request ( )

add the TVA_REVERSE_ACCOUNT

Returns
void

Reimplemented from Manage_Table_SQL.

Definition at line 231 of file tva_rate_mtable.class.php.

232 {
233 parent::from_request();
234 $http=new \HttpInput();
235 $this->table->tva_reverse_account=$http->request('tva_reverse_account');
236 }

References $http, and table.

◆ getPreviousId()

Tva_Rate_MTable::getPreviousId ( )
Returns
int or null

Definition at line 99 of file tva_rate_mtable.class.php.

100 {
101 return $this->previous_id;
102 }
$previous_id
< previous tva_id, used to know if we update or insert,

References $previous_id.

Referenced by check().

◆ input()

Tva_Rate_MTable::input ( )

display into a dialog box the datarow in order to be appended or modified.

Can be override if you need a more complex form

Reimplemented from Manage_Table_SQL.

Definition at line 119 of file tva_rate_mtable.class.php.

120 {
121 $nb_order=count($this->a_order);
122 $this->set_property_visible('tva_reverse_account', true);
123 echo "<table>";
124 for ($i=0; $i<$nb_order; $i++)
125 {
126 echo "<tr>";
127 $key=$this->a_order[$i];
128 $label=$this->a_label_displaid[$key];
129 $value=$this->table->get($key);
130 $error=$this->get_error($key);
131 $error=($error=="")?"":HtmlInput::errorbulle($error);
132
133 if ($this->get_property_visible($key)===TRUE)
134 {
135 $info="";
136 if ( isset($this->a_info[$key])) {
137 $info=Icon_Action::infobulle($this->a_info[$key]);
138 }
139 // Label
140 echo "<td> {$label} {$info} {$error}</td>";
141
142 if ($this->get_property_updatable($key)==TRUE)
143 {
144 echo "<td>";
145 if ($this->a_type[$key]=="select")
146 {
147 $select=new ISelect($key);
148 $select->value=$this->a_select[$key];
149 $select->selected=$value;
150 echo $select->input();
151 }
152 elseif ($key=="tva_rate")
153 {
154 $text=new INum($key);
155 $text->value=$value;
156 $text->prec=4;
157 $min_size=(strlen($value??"")<10)?10:strlen($value)+1;
158 $text->size=$min_size;
159 echo $text->input();
160 }
161 elseif ($key=='tva_purchase')
162 {
163 $text=new IPoste("tva_purchase");
164 $text->value=$value;
165 $min_size=10;
166 $text->size=$min_size;
167 $text->set_attribute('gDossier', Dossier::id());
168 $text->set_attribute('jrn', 0);
169 $text->set_attribute('account', 'tva_purchase');
170 echo $text->input();
171 $url="do.php?".http_build_query(array("gDossier"=>Dossier::id(),"ac"=>'C0PCMN','p_start'=>4));
172 echo HtmlInput::anchor(_("Configuration poste comptable"),$url,"",'target="_blank"');
173 }
174 elseif ($key=='tva_sale')
175 {
176 $text=new IPoste("tva_sale");
177 $text->value=$value;
178 $min_size=10;
179 $text->set_attribute('gDossier', Dossier::id());
180 $text->set_attribute('jrn', 0);
181 $text->set_attribute('account', 'tva_sale');
182 $text->size=$min_size;
183 echo $text->input();
184 }
185 elseif ($this->a_type[$key]=="text")
186 {
187 $text=new IText($key);
188 $text->value=$value;
189 $min_size=(strlen($value??"")<30)?30:strlen($value)+5;
190 $text->size=$min_size;
191 echo $text->input();
192 } elseif ($key == "tva_id") {
193 $inum=new INum($key,$value);
194 echo $inum->input();
195 echo \HtmlInput::hidden("old_tva_id",$value);
196
197 } elseif ($key=='tva_reverse_account')
198 {
199 $text=new IPoste("tva_reverse_account");
200 $text->value=$value;
201 $min_size=10;
202 $text->set_attribute('gDossier', Dossier::id());
203 $text->set_attribute('jrn', 0);
204 $text->set_attribute('account', 'tva_reverse_account');
205 $text->size=$min_size;
206 echo $text->input();
207 }
208 echo "</td>";
209 }
210 else
211 {
212 printf('<td>%s %s</td>', h($value),
213 HtmlInput::hidden($key, $value)
214 );
215 }
216 echo '<td class="text-muted">';
217 if (isset ($this->a_comment[$key])) {
218 echo $this->a_comment[$key];
219 }
220 echo '</td>';
221 }
222 echo "</tr>";
223 }
224 echo "</table>";
225 }
h( $row[ 'oa_description'])
static anchor($p_text, $p_url="", $p_js="", $p_style=' class="line" ', $p_title="click", array $p_attribute=[])
Return a simple LINK with a url or a javascript if $p_js is not null then p_url will be javascript:vo...
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
get_property_updatable($p_key)
return True if the column is updatable otherwise false
get_property_visible($p_key)
return True if the column is visible otherwise false
get_error($p_col)
retrieve the error message
if( $delta< 0) elseif( $delta==0)

References $error, $i, $label, $select, $text, $url, $value, _, elseif, Manage_Table_SQL\get_error(), Manage_Table_SQL\get_property_updatable(), Manage_Table_SQL\get_property_visible(), h, Icon_Action\infobulle(), Manage_Table_SQL\set_property_visible(), and table.

+ Here is the call graph for this function:

◆ save()

Tva_Rate_MTable::save ( )

save the data in TVA_RATE if tva_both_side is 1 and tva_purchase or tva_sale is empty then it is equal to the other value

Reimplemented from Manage_Table_SQL.

Definition at line 244 of file tva_rate_mtable.class.php.

245 {
246 if ( $this->previous_id === null ) {
247 throw new \Exception ("TVA184: no previous TVA id");
248 }
250 // if tva_both_side is 1 and tva_purchase or tva_sale is empty then
251 // it is equal to the other value
252 if ($this->table->tva_both_side==1)
253 {
254 if ($this->table->tva_purchase=="#"||trim($this->table->tva_purchase)
255 =="#")
256 {
257 $this->table->tva_purchase=$this->table->tva_sale;
258 }
259 if ($this->table->tva_sale=="#"||trim($this->table->tva_sale)=="#")
260 {
261 $this->table->tva_sale=$this->table->tva_purchase;
262 }
263 }
264 $new_tva_id=$this->table->tva_id;
265 $tva_rate=new Tva_rate_SQL($cn);
266 $tva_rate->setp("tva_id",$new_tva_id);
267 $tva_rate->setp("tva_rate", $this->table->tva_rate);
268 $tva_rate->setp("tva_code", $this->table->tva_code);
269 $tva_rate->setp("tva_label", $this->table->tva_label);
270 $tva_rate->setp("tva_comment", $this->table->tva_comment);
271 $tva_rate->setp("tva_both_side", $this->table->tva_both_side);
272 $tva_rate->setp("tva_reverse_account", $this->table->tva_reverse_account);
273
274 // TVA accounting must be joined and separated with a comma
275 $tva_purchase=(trim($this->table->tva_purchase)=="")?"#":$this->table->tva_purchase;
276 $tva_sale=(trim($this->table->tva_sale)=="")?"#":$this->table->tva_sale;
277 $tva_rate->setp("tva_poste", $tva_purchase.",".$tva_sale);
278 $tva_rate->setp("tva_payment_sale", $this->table->tva_payment_sale);
279 $tva_rate->setp("tva_payment_purchase", $this->table->tva_payment_purchase);
280 if ( $this->previous_id == -1 ) {
281 $tva_rate->insert();
282 } else {
283 $tva_rate->update();
284 }
285 if ( $this->previous_id != - 1 && $this->previous_id != $new_tva_id) {
286 $cn->exec_sql("update tva_rate set tva_id = $1 where tva_id = $2",[$new_tva_id,$this->previous_id]);
287 $this->table->setp("tva_id",$new_tva_id);
288 }else $this->table->setp("tva_id",$tva_rate->getp("tva_id"));
289
290 }
catch(Exception $e) $tva_rate

References $cn, $tva_rate, and table.

◆ setPreviousId()

Tva_Rate_MTable::setPreviousId ( $previous_id)
Parameters
int$previous_id

Definition at line 108 of file tva_rate_mtable.class.php.

108 : Tva_Rate_MTable
109 {
110 $this->previous_id = $previous_id;
111 return $this;
112 }

References $previous_id.

Field Documentation

◆ $a_comment

Tva_Rate_MTable::$a_comment
private

Supplemental explanation.

Definition at line 39 of file tva_rate_mtable.class.php.

◆ $previous_id

Tva_Rate_MTable::$previous_id
private

< previous tva_id, used to know if we update or insert,

Definition at line 38 of file tva_rate_mtable.class.php.

Referenced by getPreviousId(), and setPreviousId().


The documentation for this class was generated from the following file: