noalyss Version-10
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

- Static Public Member Functions inherited from Manage_Table_SQL
static ajax_error ($p_message)
 returns an XML object for error message as unauthorized access.
 
- 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->icon_mod='left';
50 $this->set_col_label("tva_id", _("id"));
51 $this->set_col_label("tva_code", _("Code"));
52 $this->set_col_label("tva_label", _("label"));
53 $this->set_col_label("tva_rate", _("taux"));
54 $this->set_col_label("tva_comment", _("Description"));
55 $this->set_col_label("tva_both_side", _("Autoliquidation"));
56 $this->set_col_label("tva_reverse_account", _('Poste comptable autoliquidation'));
57 $this->set_col_label("tva_sale", _("TVA Vente (C)"));
58 $this->set_col_label("tva_purchase", _("TVA Achat (D)"));
59 $this->set_col_label("tva_peppol_code", _("Code Facture électronique UBL"));
60 $this->set_col_label("vx_code", _("Code Exemption TVA (vatex)"));
61
62 $this->set_property_visible('tva_reverse_account', false);
63 $this->set_property_visible('tva_peppol_code', false);
64
65 $this->set_col_type("tva_both_side", "select",
66 array(
67 ["value"=>0, "label"=>_("Non")],
68 ["value"=>1, "label"=>_("Oui")]
69 ));
70 $this->set_col_type("tva_reverse_account", 'custom');
71 $this->set_property_updatable("tva_id", true);
72 $this->set_col_label("tva_payment_purchase",_("Exigible achat"));
73 $this->set_col_type("tva_payment_purchase","select",
74 array(
75 array("value"=>'O',"label"=>"Opération"),
76 array("value"=>'P',"label"=>"Paiement")
77 )
78 );
79 $this->set_col_label("tva_payment_sale",_("Exigible vente"));
80 $this->set_col_type("tva_payment_sale","select",
81 array(
82 array("value"=>'O',"label"=>"Opération"),
83 array("value"=>'P',"label"=>"Paiement")
84 )
85 );
86 $this->a_info=[
87 "tva_purchase"=>44,"tva_both_side"=>43,"tva_sale"=>45
88 ,"tva_payment_sale"=>74,"tva_payment_purchase"=>74,'tva_reverse_account'=>88];
89 $this->previous_id=null;
90 $this->a_comment=array(
91 'tva_purchase'=>_("Ne donnez pas ce poste comptable si ce code n'est pas utilisé à l'achat"),
92 'tva_both_side'=>_("Autoliquidation : Utilisé en même temps au crédit et au débit"),
93 'tva_sale'=>_("Ne donnez pas ce poste comptable si ce code n'est pas utilisé à la vente"),
94 'tva_payment_purchase'=>_('TVA due ou récupérable quand l\'opération est payée ou exécutée'),
95 'tva_payment_sale'=>_('TVA due ou récupérable quand l\'opération est payée ou exécutée'),
96 '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)"),
97 'tva_peppol_code'=>_("Code TVA est utilisé pour les factures électroniques, plus d'information dans le manuel"),
98 'vx_code'=>_("Code exemption pour facture PEPPOL (ubl)")
99 );
100 $this->setTitle(_("Détail TVA"));
101 }
_("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...
setTitle($p_title)
Set the title of the diabox , default is Donnée.
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(), Manage_Table_SQL\set_property_visible(), and Manage_Table_SQL\setTitle().

+ 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 349 of file tva_rate_mtable.class.php.

350 {
351 global $g_parameter;
353 if ( $this->previous_id === null ) {
354 throw new \Exception ("TVA184: no previous TVA id");
355 }
356 // both accounting can not be empty
357 if (trim($this->table->tva_purchase??"")==""&&trim($this->table->tva_sale??"")=="")
358 {
359 $this->set_error("tva_purchase",
360 _("Les 2 postes comptables ne peuvent être nuls"));
361 $this->set_error("tva_sale",
362 _("Les 2 postes comptables ne peuvent être nuls"));
363 }
364
365 // Check the tva rate
366 if (trim($this->table->tva_rate??"")==""||isNumber($this->table->tva_rate)==0||$this->table->tva_rate>1)
367 {
368 $this->set_error("tva_rate", _("Taux de TVA invalide"));
369 }
370
371 //Check the label must be unique
372 $count=$cn->get_value("select count(*) from tva_rate where tva_id<>$1 and lower(tva_label)=lower($2)",
373 [$this->getPreviousId(), $this->table->tva_label]);
374 if ($count>0)
375 {
376 $this->set_error("tva_label", _("Ce nom est déjà utilisé"));
377 }
378
379 // Check accounting exists for purchase
380 if (trim($this->table->tva_purchase??"")!=""&&$this->table->tva_purchase!="#")
381 {
382 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1",
383 [$this->table->tva_purchase]);
384 if ($count==0)
385 {
386 $this->set_error("tva_purchase", _("Poste comptable inexistant"));
387 }
388 }
389 // Check accounting exists for sale
390 if (trim($this->table->tva_sale??"")!=""&&$this->table->tva_sale!="#")
391 {
392 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1",
393 [$this->table->tva_sale]);
394 if ($count==0)
395 {
396 $this->set_error("tva_sale", _("Poste comptable inexistant"));
397 }
398 }
399
400 // check if tva_both_side is valid
401 if ($this->table->tva_both_side!=0&&$this->table->tva_both_side!=1)
402 {
403 $this->set_error("tva_both_side", _("Choix incorrect"));
404 }
405 $flag = true;
406 // Check that tva_id is a integer not a float (TVA_ID is an integer)
407 if ( isNumber($this->table->tva_id) == 0 || $this->table->tva_id != round($this->table->tva_id) )
408 {
409 $this->set_error("tva_id",_("Valeur invalide"));
410 $flag=false;
411 }
412 // Check if old tva_id was not overwritting something
413 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)
414 {
415 $this->set_error("tva_id",_("Code TVA déjà utilisé"));
416 }
417 // Check that tva code is unique and remove not letter
418 $this->table->tva_code=strtoupper(trim( $this->table->tva_code));
419 $tva_code=$this->table->tva_code;
420
421 $tva_code=strtoupper($tva_code);
422 $tva_code=preg_replace("/[A-Z]/", "", $tva_code);
423 $tva_code=preg_replace("/[0-9]/", "", $tva_code);
424
425 if (strlen($tva_code)>0){
426 $this->set_error("tva_code", _("code tva : Uniquement des chiffres et des lettres"));
427 }
428
429 if (strlen($this->table->tva_code)>5){
430 $this->set_error("tva_code", _("code tva : Maximum 5 caractères"));
431 }
432 if (isNumber($this->table->tva_code) == 1){
433 $this->set_error("tva_code", _("code tva : doit aussi contenir des lettres"));
434 }
435 /**
436 * auto reverse VAT : check that the accounting is used
437 */
438 if ( $this->table->tva_both_side==0 && trim($this->table->tva_reverse_account??"") != "")
439 {
440 $this->set_error("tva_reverse_account", _("Pas d'autoliquidation demandé"));
441 }
442 if ( $this->table->tva_both_side==1 && trim($this->table->tva_reverse_account??"") != "")
443 {
444 $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1",
445 [$this->table->tva_reverse_account]);
446 if ($count==0)
447 {
448 $this->set_error("tva_reverse_account", _("Poste comptable inexistant"));
449 }
450 }
451 // label cannot be empty
452 if ( trim($this->table->tva_label??"")=="") {
453 $this->set_error("tva_label", _('Le label ne peut être vide'));
454 }
455
456 // if vatex is set then code invoice must be different from S and Z
457 if ( $g_parameter->MY_INVOICE_FORMAT == 'UBL21BE' && trim($this->table->vx_code??"") != "" && in_array($this->table->tva_peppol_code,['S','Z'] ))
458 {
459 $this->set_error("vx_code",_("Le code d'exemption TVA ne peut être utilisé avec ce code Facture électronique UBL "));
460 }
461 // if vatex is set then code invoice must be different from S and Z
462 if ( $g_parameter->MY_INVOICE_FORMAT == 'UBL21BE' && trim($this->table->vx_code??"") != "" && $this->table->tva_peppol_code=="")
463 {
464 $this->set_error("vx_code",_("Le code d'exemption TVA n' pas de sens sans code Facture électronique"));
465 }
466 // if tva_peppol_code is not S or Z then a VATEX code must be supplied
467 if ( $g_parameter->MY_INVOICE_FORMAT == 'UBL21BE'
468 && ! in_array($this->table->tva_peppol_code??"",["Z","S"])
469 && trim($this->table->vx_code??"" ) =="")
470 {
471 $this->set_error("vx_code",_("Un code d'exemption de TVA doit être fourni, voyez le manuel"));
472
473 }
474 if ($this->count_error()!=0)
475 return false;
476 return true;
477 }
isNumber($p_int)
global $g_parameter
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:535

References $cn, $count, $flag, $g_parameter, _, 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 481 of file tva_rate_mtable.class.php.

482 {
484 $count_purchase=$cn->get_value("select count(*) from quant_purchase where qp_vat_code = $1",[$this->table->tva_id]);
485 $count_sale=$cn->get_value("select count(*) from quant_sold where qs_vat_code = $1",[$this->table->tva_id]);
486 if ( $count_purchase > 0 || $count_sale > 0) {
487 throw new Exception(_("Effacement interdit : TVA utilisée"));
488 }
489
490 // Forbid to remove all tva
491 $count=$cn->get_value("select count(*) from tva_rate");
492 if ( $count < 2) {
493 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é"));
494 }
495 $cn->exec_sql("delete from tva_rate where tva_id=$1", [$this->table->tva_id]);
496 }

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 276 of file tva_rate_mtable.class.php.

277 {
278 parent::from_request();
279 $http=new \HttpInput();
280 $this->table->tva_reverse_account=$http->request('tva_reverse_account');
281 $this->table->tva_peppol_code=$http->request('tva_peppol_code');
282 $this->table->vx_code=$http->request('vx_code');
283 }

References $http, and table.

◆ getPreviousId()

Tva_Rate_MTable::getPreviousId ( )
Returns
int or null

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

107 {
108 return $this->previous_id;
109 }
$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 126 of file tva_rate_mtable.class.php.

127 {
128 $nb_order=count($this->a_order);
129 $this->set_property_visible('tva_reverse_account', true);
130 $this->set_property_visible('tva_peppol_code', true);
131 echo "<table>";
132 for ($i=0; $i<$nb_order; $i++)
133 {
134 echo "<tr>";
135 $key=$this->a_order[$i];
136 $label=$this->a_label_displaid[$key];
137 $value=$this->table->get($key);
138 $error=$this->get_error($key);
139 $error=($error=="")?"":HtmlInput::errorbulle($error);
140
141 if ($this->get_property_visible($key)===TRUE)
142 {
143 $info="";
144 if ( isset($this->a_info[$key])) {
145 $info=Icon_Action::infobulle($this->a_info[$key]);
146 }
147 // Label
148 echo "<td> {$label} {$info} {$error}</td>";
149
150 if ($this->get_property_updatable($key)==TRUE)
151 {
152 echo "<td>";
153 if ($this->a_type[$key]=="select")
154 {
155 $select=new ISelect($key);
156 $select->value=$this->a_select[$key];
157 $select->selected=$value;
158 echo $select->input();
159 }
160 elseif ($key=="tva_rate")
161 {
162 $text=new INum($key);
163 $text->value=$value;
164 $text->prec=4;
165 $min_size=(strlen($value??"")<10)?10:strlen($value)+1;
166 $text->size=$min_size;
167 echo $text->input();
168 }
169 elseif ($key=='tva_purchase')
170 {
171 $text=new IPoste("tva_purchase");
172 $text->value=$value;
173 $min_size=10;
174 $text->size=$min_size;
175 $text->set_attribute('gDossier', Dossier::id());
176 $text->set_attribute('jrn', 0);
177 $text->set_attribute('account', 'tva_purchase');
178 echo $text->input();
179 $url="do.php?".http_build_query(array("gDossier"=>Dossier::id(),"ac"=>'C0PCMN','p_start'=>4));
180 echo HtmlInput::anchor(_("Configuration poste comptable"),$url,"",'target="_blank"');
181 }
182 elseif ($key=='tva_sale')
183 {
184 $text=new IPoste("tva_sale");
185 $text->value=$value;
186 $min_size=10;
187 $text->set_attribute('gDossier', Dossier::id());
188 $text->set_attribute('jrn', 0);
189 $text->set_attribute('account', 'tva_sale');
190 $text->size=$min_size;
191 echo $text->input();
192 }elseif ($key=='tva_peppol_code') {
193 $text=new ISelect('tva_peppol_code');
194 $text->selected=$value;
195 $text->transform(array(
196 null=>_('-')
197 ,"S"=>_('S Taux standard')
198 ,'AE'=>_('AE Autoliquidate mais pas INTRACOMM.')
199 ,'Z'=>_("Z TVA à 0%")
200 ,'K'=>_('K Autoliquidation INTRACOMM.')
201 ,'G'=>_('G TVA exempt pour export hors Europe')
202 ,'O'=>_('O TVA Hors périmètre application')
203 ,'E'=>_('E Exempté de TVA')
204 ));
205 echo $text->input();
206 } elseif ($key == 'vx_code')
207 {
208 $text=\HtmlInput::hidden("vx_code",$value);
209 echo $text;
210 if ( $value !="") {
211 $value= \Icon_Action::trash(uniqid(),"vat_code.select_value('xx')").$value;
212 }
213 echo span($value,'id="vx_value"');
214 $js=sprintf("vat_code.list_vatex()");
215 echo \Icon_Action::icon_magnifier(uniqid(),$js );
216
217 }
218 elseif ($key == "tva_id") {
219 $inum=new INum($key,$value);
220 echo $inum->input();
221 echo \HtmlInput::hidden("old_tva_id",$value);
222
223 } elseif ($key=='tva_reverse_account')
224 {
225 $text=new IPoste("tva_reverse_account");
226 $text->value=$value;
227 $min_size=10;
228 $text->set_attribute('gDossier', Dossier::id());
229 $text->set_attribute('jrn', 0);
230 $text->set_attribute('account', 'tva_reverse_account');
231 $text->size=$min_size;
232 echo $text->input();
233 }elseif ($this->a_type[$key]=="text")
234 {
235 $text=new IText($key);
236 $text->value=$value;
237 $min_size=(strlen($value??"")<30)?30:strlen($value)+5;
238 $text->size=$min_size;
239 echo $text->input();
240 }
241 echo "</td>";
242 }
243 else
244 {
245 printf('<td>%s %s</td>', h($value),
246 HtmlInput::hidden($key, $value)
247 );
248 }
249 echo '<td >';
250 if (isset ($this->a_comment[$key])) {
251 print '<p class="text-muted">';
252 echo $this->a_comment[$key];
253 print '</p>';
254 }
255 if( $key == 'vx_code') {
256 echo '<span id="vx_code_description">';
257 $row=$this->table->cn->get_row("select vx_code,vx_code_name,vx_description,vx_remark from vatex_code where vx_code=$1",
258 [$value]);
259 if ( ! empty ($row)) {
260 echo $row['vx_description'].span($row['vx_remark'],' class="text-muted" ');
261
262 }
263 echo '</span>';
264 }
265 echo '</td>';
266 }
267 echo "</tr>";
268 }
269 echo "</table>";
270 }
span($p_string, $p_extra='')
Definition ac_common.php:43
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
print
Type of printing.
if( $delta< 0) elseif( $delta==0)

References $error, $i, $js, $label, $row, $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(), print, Manage_Table_SQL\set_property_visible(), span(), table, and Icon_Action\trash().

+ 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 291 of file tva_rate_mtable.class.php.

292 {
293 if ( $this->previous_id === null ) {
294 throw new \Exception ("TVA184: no previous TVA id");
295 }
297 // if tva_both_side is 1 and tva_purchase or tva_sale is empty then
298 // it is equal to the other value
299 if ($this->table->tva_both_side==1)
300 {
301 if ($this->table->tva_purchase=="#"||trim($this->table->tva_purchase)
302 =="#")
303 {
304 $this->table->tva_purchase=$this->table->tva_sale;
305 }
306 if ($this->table->tva_sale=="#"||trim($this->table->tva_sale)=="#")
307 {
308 $this->table->tva_sale=$this->table->tva_purchase;
309 }
310 }
311 $new_tva_id=$this->table->tva_id;
312 $tva_rate=new Tva_rate_SQL($cn);
313 $tva_rate->setp("tva_id",$new_tva_id);
314 $tva_rate->setp("tva_rate", $this->table->tva_rate);
315 $tva_rate->setp("tva_code", $this->table->tva_code);
316 $tva_rate->setp("tva_label", $this->table->tva_label);
317 $tva_rate->setp("tva_comment", $this->table->tva_comment);
318 $tva_rate->setp("tva_both_side", $this->table->tva_both_side);
319 $tva_rate->setp("tva_reverse_account", $this->table->tva_reverse_account);
320 $tva_rate->setp("tva_peppol_code", $this->table->tva_peppol_code);
321 $tva_rate->setp("vx_code", $this->table->vx_code);
322
323 // TVA accounting must be joined and separated with a comma
324 $tva_purchase=(trim($this->table->tva_purchase)=="")?"#":$this->table->tva_purchase;
325 $tva_sale=(trim($this->table->tva_sale)=="")?"#":$this->table->tva_sale;
326 $tva_rate->setp("tva_poste", $tva_purchase.",".$tva_sale);
327 $tva_rate->setp("tva_payment_sale", $this->table->tva_payment_sale);
328 $tva_rate->setp("tva_payment_purchase", $this->table->tva_payment_purchase);
329 if ( $this->previous_id == -1 ) {
330 $tva_rate->insert();
331 } else {
332 $tva_rate->update();
333 }
334 if ( $this->previous_id != - 1 && $this->previous_id != $new_tva_id) {
335 $cn->exec_sql("update tva_rate set tva_id = $1 where tva_id = $2",[$new_tva_id,$this->previous_id]);
336 $this->table->setp("tva_id",$new_tva_id);
337 }else {
338 $this->table->setp("tva_id",$tva_rate->getp("tva_id"));
339 }
340
341 }
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 115 of file tva_rate_mtable.class.php.

115 : Tva_Rate_MTable
116 {
117 $this->previous_id = $previous_id;
118 return $this;
119 }

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: