diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 2d995b4d6..13e11d4a7 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -236,7 +236,9 @@ $path = array( // Attribute for category of card 'template_cat_category'=>'ajax_template_cat_category', // From FollowUp , update a comment on a file - 'update_comment_followUp'=>'ajax_follow_up' + 'update_comment_followUp'=>'ajax_follow_up', + // TVA param + "tva_parameter"=>"ajax_tva_parameter" ) ; if (array_key_exists($op, $path)) { diff --git a/include/class/tva_rate_mtable.class.php b/include/class/tva_rate_mtable.class.php new file mode 100644 index 000000000..19c047fce --- /dev/null +++ b/include/class/tva_rate_mtable.class.php @@ -0,0 +1,278 @@ + + +/** + * @file + * @brief Configure the tva : code , rate, label ... + */ +require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php"; +require_once NOALYSS_INCLUDE."/lib/icon_action.class.php"; +require_once NOALYSS_INCLUDE."/database/v_tva_rate_sql.class.php"; +require_once NOALYSS_INCLUDE."/database/tva_rate_sql.class.php"; + +/** + * @class + * @brief Configure the tva : code , rate, label ... + * When using Manage_Table_SQL + */ +class Tva_Rate_MTable extends Manage_Table_SQL +{ + + /** + * + * @param V_Tva_rate_SQL $p_table + * @example tva_parameter.php + */ + function __construct(V_Tva_rate_SQL $p_table) + { + parent::__construct($p_table); + $this->set_col_label("tva_id", _("id")); + $this->set_col_label("tva_label", _("label")); + $this->set_col_label("tva_rate", _("taux")); + $this->set_col_label("tva_comment", _("Description")); + $this->set_col_label("tva_both_side", _("Autoliquidation")); + $this->set_col_label("tva_sale", _("TVA Vente (C)")); + $this->set_col_label("tva_purchase", _("TVA Achat (D)")); + $this->set_col_type("tva_both_side", "select", + array( + ["value"=>0, "label"=>_("Normal")], + ["value"=>1, "label"=>_("Autoliquidation")] + )); + $this->set_property_updatable("tva_id", FALSE); + $this->a_info=["tva_purchase"=>44,"tva_both_side"=>43,"tva_sale"=>45]; + } + + /** + * @brief display into a dialog box the datarow in order + * to be appended or modified. Can be override if you need + * a more complex form + */ + function input() + { + $nb_order=count($this->a_order); + echo ""; + for ($i=0; $i<$nb_order; $i++) + { + echo ""; + $key=$this->a_order[$i]; + $label=$this->a_label_displaid[$key]; + $value=$this->table->get($key); + $error=$this->get_error($key); + $error=($error=="")?"":HtmlInput::errorbulle($error); + if ($this->get_property_visible($key)===TRUE) + { + $info=""; + if ( isset($this->a_info[$key])) { + $info=Icon_Action::infobulle($this->a_info[$key]); + } + // Label + echo ""; + + if ($this->get_property_updatable($key)==TRUE) + { + echo ""; + } + else + { + printf('', h($value), + HtmlInput::hidden($key, $value) + ); + } + } + echo ""; + } + echo "
{$label} {$info} {$error}"; + if ($this->a_type[$key]=="select") + { + $select=new ISelect($key); + $select->value=$this->a_select[$key]; + $select->selected=$value; + echo $select->input(); + } + elseif ($key=="tva_rate") + { + $text=new INum($key); + $text->value=$value; + $text->prec=4; + $min_size=(strlen($value)<10)?10:strlen($value)+1; + $text->size=$min_size; + echo $text->input(); + } + elseif ($key=='tva_purchase') + { + $text=new IPoste("tva_purchase"); + $text->value=$value; + $min_size=10; + $text->size=$min_size; + $text->set_attribute('gDossier', Dossier::id()); + $text->set_attribute('jrn', 0); + $text->set_attribute('account', 'tva_purchase'); + echo $text->input(); + //@todo ajout infobulle pour prévenir que compte doit exister + } + elseif ($key=='tva_sale') + { + $text=new IPoste("tva_sale"); + $text->value=$value; + $min_size=10; + $text->set_attribute('gDossier', Dossier::id()); + $text->set_attribute('jrn', 0); + $text->set_attribute('account', 'tva_sale'); + $text->size=$min_size; + echo $text->input(); + } + elseif ($this->a_type[$key]=="text") + { + $text=new IText($key); + $text->value=$value; + $min_size=(strlen($value)<30)?30:strlen($value)+5; + $text->size=$min_size; + echo $text->input(); + } + echo "%s %s
"; + } + + /** + * @brief 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 + * + */ + function save() + { + $cn=Dossier::connect(); + // if tva_both_side is 1 and tva_purchase or tva_sale is empty then + // it is equal to the other value + if ($this->table->tva_both_side==1) + { + if ($this->table->tva_purchase=="#"||trim($this->table->tva_purchase) + =="#") + { + $this->table->tva_purchase=$this->table->tva_sale; + } + if ($this->table->tva_sale=="#"||trim($this->table->tva_sale)=="#") + { + $this->table->tva_sale=$this->table->tva_purchase; + } + } + $tva_rate=new Tva_rate_SQL($cn, $this->table->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); + $tva_rate->setp("tva_both_side", $this->table->tva_both_side); + + // TVA accounting must be joined and separated with a comma + $tva_purchase=(trim($this->table->tva_purchase)=="")?"#":$this->table->tva_purchase; + $tva_sale=(trim($this->table->tva_sale)=="")?"#":$this->table->tva_sale; + $tva_rate->setp("tva_poste", $tva_purchase.",".$tva_sale); + $tva_rate->save(); + + // reload the row + $this->table->set_pk_value($tva_rate->tva_id); + $this->table->load(); + } + /** + * Check data are valid + * 1. tva_rate between 0 & 1 + * 2. label is uniq + * 3. accounting must exist + * @return boolean + */ + function check() + { + $cn=Dossier::connect(); + + // both accounting can not be empty + if (trim($this->table->tva_purchase)==""&&trim($this->table->tva_sale)=="") + { + $this->set_error("tva_purchase", + _("Les 2 postes comptables ne peuvent être nuls")); + $this->set_error("tva_sale", + _("Les 2 postes comptables ne peuvent être nuls")); + } + + // Check the tva rate + if (trim($this->table->tva_rate)==""||isNumber($this->table->tva_rate)==0||$this->table->tva_rate>1) + { + $this->set_error("tva_rate", _("Taux de TVA invalide")); + } + + //Check the label must be unique + $count=$cn->get_value("select count(*) from tva_rate where tva_id<>$1 and lower(tva_label)=lower($2)", + [$this->table->tva_id, $this->table->tva_label]); + if ($count>0) + { + $this->set_error("tva_label", _("Ce nom est déjà utilisé")); + } + + // Check accounting exists for purchase + if (trim($this->table->tva_purchase)!=""&&$this->table->tva_purchase!="#") + { + $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1", + [$this->table->tva_purchase]); + if ($count==0) + { + $this->set_error("tva_purchase", _("Poste comptable inexistant")); + } + } + // Check accounting exists for sale + if (trim($this->table->tva_sale)!=""&&$this->table->tva_sale!="#") + { + $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1", + [$this->table->tva_sale]); + if ($count==0) + { + $this->set_error("tva_sale", _("Poste comptable inexistant")); + } + } + + // check if tva_both_side is valid + if ($this->table->tva_both_side!=0&&$this->table->tva_both_side!=1) + { + $this->set_error("tva_both_side", _("Choix incorrect")); + } + + + if ($this->count_error()!=0) + return false; + return true; + } + /** + * delete if not used anywhere + */ + function delete() + { + $cn=Dossier::connect(); + $count_purchase=$cn->get_value("select count(*) from quant_purchase where qp_vat_code = $1",[$this->table->tva_id]); + $count_sale=$cn->get_value("select count(*) from quant_sold where qs_vat_code = $1",[$this->table->tva_id]); + if ( $count_purchase > 0 || $count_sale > 0) { + throw new Exception(_("Effacement interdit : TVA utilisée")); + } + + // Forbid to remove all tva + $count=$cn->get_value("select count(*) from tva_rate"); + if ( $count < 2) { + 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é")); + } + + } + +} diff --git a/include/constant.php b/include/constant.php index 9d32dfe5d..31b88012f 100644 --- a/include/constant.php +++ b/include/constant.php @@ -108,7 +108,7 @@ if ( !defined("SITE_UPDATE_PLUGIN")) if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",127); +define ("DBVERSION",128); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",18); define ('NOTFOUND','--not found--'); diff --git a/include/database/tva_rate_sql.class.php b/include/database/tva_rate_sql.class.php new file mode 100644 index 000000000..94e9b0338 --- /dev/null +++ b/include/database/tva_rate_sql.class.php @@ -0,0 +1,70 @@ +table="public.tva_rate"; + $this->primary_key="tva_id"; + /* + * List of columns + */ + $this->name=array( + "tva_id"=>"tva_id" + , "tva_label"=>"tva_label" + , "tva_rate"=>"tva_rate" + , "tva_comment"=>"tva_comment" + , "tva_poste"=>"tva_poste" + , "tva_both_side"=>"tva_both_side" + ); + /* + * Type of columns + */ + $this->type=array( + "tva_id"=>"numeric" + , "tva_label"=>"text" + , "tva_rate"=>"numeric" + , "tva_comment"=>"text" + , "tva_poste"=>"text" + , "tva_both_side"=>"numeric" + ); + + + $this->default=array( + "tva_id"=>"auto" + ); + + $this->date_format="DD.MM.YYYY"; + parent::__construct($p_cn, $p_id); + } + +} diff --git a/include/database/v_tva_rate_sql.class.php b/include/database/v_tva_rate_sql.class.php new file mode 100644 index 000000000..0bad2214c --- /dev/null +++ b/include/database/v_tva_rate_sql.class.php @@ -0,0 +1,72 @@ +table="public.v_tva_rate"; + $this->primary_key="tva_id"; + /* + * List of columns + */ + $this->name=array( + "tva_id"=>"tva_id" + , "tva_label"=>"tva_label" + , "tva_rate"=>"tva_rate" + , "tva_comment"=>"tva_comment" + , "tva_purchase"=>"tva_purchase" + , "tva_sale"=>"tva_sale" + , "tva_both_side"=>"tva_both_side" + ); + /* + * Type of columns + */ + $this->type=array( + "tva_id"=>"numeric" + , "tva_label"=>"text" + , "tva_rate"=>"numeric" + , "tva_comment"=>"text" + , "tva_purchase"=>"text" + , "tva_sale"=>"text" + , "tva_both_side"=>"numeric" + ); + + + $this->default=array( + "tva_id"=>"auto" + ); + + $this->date_format="DD.MM.YYYY"; + parent::__construct($p_cn, $p_id); + } + +} \ No newline at end of file diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php index 560cf0687..1d88aec14 100644 --- a/include/lib/message_javascript.php +++ b/include/lib/message_javascript.php @@ -71,5 +71,7 @@ content[39]=""; content[41]=" à zéro pour effacer la ligne")?>"; content[42]=""; - +content[43]=""; +content[44]=""; +content[45]=""; \ No newline at end of file diff --git a/include/sql/patch/upgrade127.sql b/include/sql/patch/upgrade127.sql new file mode 100644 index 000000000..bfbc57d69 --- /dev/null +++ b/include/sql/patch/upgrade127.sql @@ -0,0 +1,18 @@ +begin; +create view v_tva_rate as select + tva_id, + tva_rate, + tva_label, + tva_comment, + split_part(tva_poste,',',1) as tva_purchase, + split_part(tva_poste,',',2) as tva_sale, + tva_both_side +from tva_rate; + +comment on view v_tva_rate is 'Show this table to be easily used by Tva_Rate_MTable'; +comment on column v_tva_rate.tva_purchase is ' VAT used for purchase'; +comment on column v_tva_rate.tva_sale is ' VAT used for sale'; +comment on column v_tva_rate.tva_both_side is 'if 1 , VAT avoided '; + +insert into version (val,v_description) values (128,'Add a view to manage VAT'); +commit; \ No newline at end of file diff --git a/include/tva.inc.php b/include/tva.inc.php index 6f9442272..ff832b7f4 100644 --- a/include/tva.inc.php +++ b/include/tva.inc.php @@ -25,317 +25,25 @@ require_once NOALYSS_INCLUDE.'/class/noalyss_parameter_folder.class.php'; require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php'; require_once NOALYSS_INCLUDE.'/lib/itextarea.class.php'; +require_once NOALYSS_INCLUDE."/class/tva_rate_mtable.class.php"; + +$cn=Dossier::connect(); +$own=new Noalyss_Parameter_Folder($cn); + echo '
'; -// Confirm remove -if (isset($_POST['confirm_rm'])) -{ - if ($cn->count_sql('select * from tva_rate') > 1) - $cn->exec_sql('select tva_delete($1)', array($_POST['tva_id'])); - else - echo '

Vous ne pouvez pas effacer tous taux' . - ' Si votre société n\'utilise pas la TVA, changer dans le menu société

'; -} -$both_side=(isset($_REQUEST['both']))?1:0; -//----------------------------------------------------- -// Record Change -if (isset($_POST['confirm_mod']) - || isset($_POST['confirm_add'])) -{ - extract($_POST, EXTR_SKIP); - // remove space - $tva_poste = str_replace(" ", "", $tva_poste); - $err = 0; // Error code - - if (isNumber($tva_rate) == 0) - { - $err = 2; - } - - if ($err == 0) - { - if (isset($_POST['confirm_add'])) - { - $sql = "select tva_insert($1,$2,$3,$4,$5)"; - - $res = $cn->exec_sql( - $sql, array($tva_label, - $tva_rate, - $tva_comment, - $tva_poste, - $both_side) - ); - $err = Database::fetch_result($res); - } - if (isset($_POST['confirm_mod'])) - { - $Res = $cn->exec_sql( - "select tva_modify($1,$2,$3,$4,$5,$6)", array($tva_id, $tva_label, $tva_rate, $tva_comment, $tva_poste,$both_side) - ); - $err = Database::fetch_result($Res); - } - } - if ($err != 0) - { - $err_code = array(1 => "Tva id n\'est pas un nombre", - 2 => "Taux tva invalide", - 3 => "Label ne peut être vide", - 4 => "Poste invalide", - 5 => "Tva id doit être unique"); - $str_err = $err_code[$err]; - alert($str_err); - ; - } -} -// If company not use VAT -$own = new Noalyss_Parameter_Folder($cn); if ($own->MY_TVA_USE == 'N') { echo '

'._("Vous n'êtes pas assujetti à la TVA").'

'; return; } -//----------------------------------------------------- -// Display -$sql = "select tva_id,tva_label,tva_rate,tva_comment,tva_poste,tva_both_side from tva_rate order by tva_label"; -$Res = $cn->exec_sql($sql); -?> - - - - - - - - - - $row['tva_label'], - 'tva_rate' => $row['tva_rate'], - 'tva_comment' => $row['tva_comment'], - 'tva_poste' => $row['tva_poste'], - 'tva_both_side' => $row['tva_both_side'] - ); - echo ""; - echo ''; +$tva_rate=new V_Tva_Rate_SQL($cn); - echo ''; +$manage_table=new Tva_Rate_MTable($tva_rate); - echo ""; - - echo ""; - - echo ""; - - echo ""; - - echo ""; - - echo ""; - - echo ''; - echo ""; -} -?> -
IdLabelTauxCommentairePosteUtilisé en même temps au crédit et au débit
'; - echo $row['tva_id']; - echo '"; - echo HtmlInput::hidden('tva_id', $row['tva_id']); - echo h($row['tva_label']); - echo ""; - echo $row['tva_rate']; - echo ""; - echo h($row['tva_comment']); - echo ""; - echo $row['tva_poste']; - echo ""; - $str_msg=( $row['tva_both_side']==1)?'Employé au crédit et débit':'normal' ; - echo $str_msg; - echo ""; - echo HtmlInput::submit("rm", "Efface"); - echo HtmlInput::submit("mod", "Modifie"); - $w = new IHidden(); - $w->name = "tva_id"; - $w->value = $row['tva_id']; - echo $w->input(); - $w = new IHidden(); - $w->name = "p_action"; - $w->value = "divers"; - echo $w->input(); - $w = new IHidden(); - $w->name = "sa"; - $w->value = "tva"; - echo $w->input(); - - echo "
- -
- - - -
- - - - - - - - - - - - - - - - -
LabelTauxCommentairePosteDouble côté
- '; - echo ''; - echo HtmlInput::submit("confirm_rm", "Confirme"); - echo HtmlInput::submit("Cancel", "no"); - echo ""; - } - //----------------------------------------------------- - // add - if (isset($_REQUEST['add'])) - { - echo "
Ajout d'un taux de tva "; - echo '
'; - ?> - - - - - - - - - - - - - - - - - - - -
Label (ce que vous verrez dans les journaux) size = 20; - echo $w->input('tva_label', '') - ?>
Taux de tva size = 5; - echo $w->input('tva_rate', '') - ?>
Commentaire heigh = 5; - $w->width = 50; - echo $w->input('tva_comment', '') - ?>
Poste comptable utilisés format :debit,credit size = 20; - echo $w->input('tva_poste', '') - ?>
Utilisé au débit et au crédit afin d'annuler cette tva size = 20; - echo $w->input('both', '') - ?>
- - - -
-
- Modification d'un taux de tva "; - echo '
'; - echo ''; - ?> - - - - - - - - - - - - - - - - - - - - - -
Label (ce que vous verrez dans les journaux) size = 20; - echo $w->input('tva_label', $tva_array[$index]['tva_label']) - ?>
Taux de tva size = 5; - echo $w->input('tva_rate', $tva_array[$index]['tva_rate']) - ?>
Commentaire heigh = 5; - $w->width = 50; - echo $w->input('tva_comment', $tva_array[$index]['tva_comment']) - ?>
Poste comptable utilisés format :debit,credit size = 20; - echo $w->input('tva_poste', $tva_array[$index]['tva_poste']) - ?>
Utilisé au débit et au crédit afin d'annuler cette tva selected=$tva_array[$index]['tva_both_side']; - $w->size = 20; - echo $w->input('both', '') - ?>
- - -
- - set_callback("ajax_misc.php"); +$manage_table->add_json_param("op", "tva_parameter"); +$manage_table->create_js_script(); +$manage_table->display_table(); echo '
'; ?> diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 1b7e8d87c..f3ed35a1d 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,119 +1,9 @@ -set search_path=public,comptaproc; - - -alter table action_gestion drop ag_ref_ag_id; -/* --- repository --- add style -insert into theme (the_name,the_filestyle) values ('Classic7','style-classic7.css'); -delete from theme where the_filestyle in ('style-mandarine.css','style-mobile.css'); -update user_global_pref set parameter_value='style-classic7.css' where parameter_value in ('style-mandarine.css','style-mobile.css'); --- add constraint -alter table jnt_use_dos add CONSTRAINT use_id_dos_id_uniq UNIQUE (use_id,dos_id); --- create table to check progress -create table progress -( - p_id varchar(16) primary key, - p_value numeric (5,2) not null , - p_created timestamp default now() -); - -*/ -create sequence tmp_pcmn_id_seq; -ALTER TABLE tmp_pcmn ADD COLUMN id bigint; -update tmp_pcmn set id=nextval('tmp_pcmn_id_seq'); - -ALTER TABLE tmp_pcmn ALTER COLUMN id SET NOT NULL; -ALTER TABLE tmp_pcmn ALTER COLUMN id SET DEFAULT nextval('tmp_pcmn_id_seq'::regclass); -ALTER TABLE tmp_pcmn ADD CONSTRAINT id_ux UNIQUE(id); -COMMENT ON COLUMN tmp_pcmn.id IS 'allow to identify the row, it is unique and not null (pseudo pk)'; -update tmp_pcmn set id=nextval('tmp_pcmn_id_seq'); --- set search_path to public,comptaproc; -alter table tmp_pcmn add column pcm_direct_use varchar(1); -COMMENT ON COLUMN tmp_pcmn.pcm_direct_use IS 'Value are N or Y , N cannot be used directly , not even through a card'; -ALTER TABLE tmp_pcmn ALTER COLUMN pcm_direct_use SET DEFAULT 'Y'; -update tmp_pcmn set pcm_direct_use='Y'; -update tmp_pcmn set pcm_direct_use='N' where length(pcm_val) < 3 and not exists (select j_poste from jrnx where j_poste=pcm_val); -ALTER TABLE tmp_pcmn ALTER COLUMN pcm_direct_use SET NOT NULL; -alter table tmp_pcmn add constraint pcm_direct_use_ck check (pcm_direct_use in ('Y','N')); - -insert into bilan (b_name,b_file_template,b_file_form,b_type) values ('ASBL','document/fr_be/bnb-asbl.rtf','document/fr_be/bnb-asbl.form','RTF'); - -alter table jnt_letter drop jl_amount_deb; - -ALTER TABLE operation_analytique ADD COLUMN f_id bigint; -ALTER TABLE operation_analytique ADD CONSTRAINT operation_analytique_fiche_id_fk FOREIGN KEY (f_id) REFERENCES fiche (f_id) MATCH SIMPLE ON UPDATE cascade ON cascade; -COMMENT ON COLUMN operation_analytique.f_id IS 'FK to fiche.f_id , used only with ODS'; - -drop FUNCTION comptaproc.table_analytic_account(text,text); -drop FUNCTION comptaproc.table_analytic_card(text,text); - -CREATE TABLE public.user_filter ( - id bigserial, - login text NULL, - nb_jrn int4 NULL, - date_start varchar(10) NULL, - date_end varchar(10) NULL, - description text NULL, - amount_min numeric(20,4) NULL, - amount_max numeric(20,4) NULL, - qcode text NULL, - accounting text NULL, - r_jrn text NULL, - date_paid_start varchar(10) NULL, - date_paid_end varchar(10) NULL, - ledger_type varchar(5) NULL, - all_ledger int4 NULL, - filter_name text NOT NULL, - unpaid varchar NULL, - PRIMARY KEY (id) -); - - - - -alter table jrn_periode drop constraint jrn_periode_pk; -create sequence jrn_periode_id_seq; -alter table jrn_periode add id bigint; -alter table jrn_periode alter column id set default nextval('jrn_periode_id_seq'); -update jrn_periode set id=nextval('jrn_periode_id_seq'); -alter table jrn_periode add constraint jrn_periode_pk primary key (id); -alter table jrn_periode add constraint jrn_periode_periode_ledger unique (jrn_def_id,p_id); - -CREATE TABLE public.user_active_security ( - id serial not NULL, - us_login text NOT NULL, - us_ledger varchar(1) not NULL, - us_action varchar(1) not NULL -); -COMMENT ON COLUMN public.user_active_security.us_login IS 'user''s login' ; -COMMENT ON COLUMN public.user_active_security.us_ledger IS 'Flag Security for ledger' ; -COMMENT ON COLUMN public.user_active_security.us_action IS 'Security for action' ; - -ALTER TABLE public.user_active_security ADD CONSTRAINT user_active_security_pk PRIMARY KEY (id) ; -ALTER TABLE public.user_active_security ADD CONSTRAINT user_active_security_ledger_check CHECK (us_ledger in ('Y','N')) ; -ALTER TABLE public.user_active_security ADD CONSTRAINT user_active_security_action_check CHECK (us_action in ('Y','N')) ; - -insert into user_active_security (us_login,us_ledger,us_action) select user_name,'Y','Y' from profile_user; - -alter table jrn_def add jrn_enable int; -alter table jrn_def alter jrn_enable set default 1; -update jrn_def set jrn_enable=1; -comment on column jrn_def.jrn_enable is 'Set to 1 if the ledger is enable '; - - -alter table jrn add jr_optype varchar(3); -alter table jrn alter jr_optype set default 'NOR'; -comment on column jrn.jr_optype is 'Type of operation , NOR = NORMAL , OPE opening , EXT extourne, CLO closing'; -update jrn set jr_optype='NOR'; - --- update quant_sold set qs_vat_sided=round(qs_vat_sided,2); --- update quant_purchase set qp_vat_sided=round(qp_vat_sided,2); - -alter table tags add column t_actif char(1); -update tags set t_actif='Y'; -ALTER TABLE tags ADD CONSTRAINT tags_check CHECK (t_actif in ('N','Y')) ; -alter table tags alter t_actif set default 'Y'; -COMMENT ON COLUMN tags.t_actif is 'Y if the tag is activate and can be used '; - - --- in repo +create view v_tva_rate as select + tva_id, + tva_rate, + tva_label, + tva_comment, + split_part(tva_poste,',',1) as tva_purchase, + split_part(tva_poste,',',2) as tva_sale, + tva_both_side +from tva_rate;