diff --git a/include/class/tax_summary.class.php b/include/class/tax_summary.class.php index 933751621..afc9f33ca 100644 --- a/include/class/tax_summary.class.php +++ b/include/class/tax_summary.class.php @@ -1,4 +1,5 @@ db=$db; $this->set_date_start($p_start); $this->set_date_end($p_end); + // By default the TVA is computed by parameter in tva_rate.tva_payment_purchase or tva_rate.tva_payment_sale + $this->set_tva_type("T"); + } + + public function get_tva_type() + { + return $this->tva_type; + } + + public function set_tva_type($tva_type) + { + $this->tva_type=$tva_type; + return $this; } /** @@ -53,7 +69,7 @@ class Tax_Summary */ public function set_db($db) { - $this->db = $db; + $this->db=$db; return $this; } @@ -71,8 +87,9 @@ class Tax_Summary */ public function set_date_start($date_start) { - if (isDate($date_start) == NULL) throw Exception(_("Format date invalide") . $date_start); - $this->date_start = $date_start; + if (isDate($date_start)==NULL) + throw Exception(_("Format date invalide").$date_start); + $this->date_start=$date_start; return $this; } @@ -90,8 +107,9 @@ class Tax_Summary */ public function set_date_end($date_end) { - if (isDate($date_end) == NULL) throw Exception(_("Format date invalide") . $date_end); - $this->date_end = $date_end; + if (isDate($date_end)==NULL) + throw Exception(_("Format date invalide").$date_end); + $this->date_end=$date_end; return $this; } @@ -101,7 +119,7 @@ class Tax_Summary */ function check() { - /*-------------SALE ---------------------------------*/ + /* -------------SALE --------------------------------- */ $sql="select count(*) from quant_sold @@ -113,11 +131,12 @@ class Tax_Summary and j_date <= to_date($2,'DD.MM.YYYY') ) "; - $cnt=$this->db->get_value($sql,[$this->date_start,$this->date_end]); - if ($cnt == 0) { - throw new Exception(_("Données manquantes"),100); + $cnt=$this->db->get_value($sql, [$this->date_start, $this->date_end]); + if ($cnt==0) + { + throw new Exception(_("Données manquantes"), 100); } - /*-------------Purchase ---------------------------------*/ + /* -------------Purchase --------------------------------- */ $sql="select count(*) from quant_purchase @@ -129,65 +148,33 @@ class Tax_Summary and j_date <= to_date($2,'DD.MM.YYYY') ) "; - $cnt=$this->db->get_value($sql,[$this->date_start,$this->date_end]); - if ($cnt > 0) { - throw new Exception(_("Données manquantes"),100); + $cnt=$this->db->get_value($sql, [$this->date_start, $this->date_end]); + if ($cnt>0) + { + throw new Exception(_("Données manquantes"), 100); } } - - /** - * Total for each sales ledger - * @return array - */ - function get_row_sale() + private function build_exigibility() { global $g_user; - $sql_ledger=$g_user->get_ledger_sql('ALL',3); - $sql="with detail_tva as ( - select - sum(qs_vat) as amount_vat, - sum(qs_vat_sided) as amount_sided, - sum(qs_price) as amount_wovat, - qs_vat_code, - j_jrn_def - from - quant_sold - join tva_rate on (qs_vat_code=tva_rate.tva_id) - join jrnx on (quant_sold.j_id=jrnx.j_id) - join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def) - where - j_date >= to_date($1,'DD.MM.YYYY') - and j_date <= to_date($2,'DD.MM.YYYY') - and {$sql_ledger} - group by j_jrn_def,qs_vat_code) - select jrn_def_name, - tva_label , - qs_vat_code, - tva_rate, - tva_both_side, - amount_vat, - amount_wovat, - amount_sided - from - detail_tva - join tva_rate on (tva_rate.tva_id=qs_vat_code) - join jrn_def on (jrn_def.jrn_def_id=j_jrn_def) - - order by jrn_def_name,tva_label"; - $array=$this->db->get_array($sql,[$this->date_start,$this->date_end]); - return $array; - + $sql_ledger=$g_user->get_ledger_sql('ALL', 3); + } - - /** - * Total for each purchase ledger - * @return array + * Build the SQL for sale vat + * @return string + * */ - function get_row_purchase() + private function build_sql_purchase($p_group_ledger) { global $g_user; - $sql_ledger=$g_user->get_ledger_sql('ALL',3); + $sql_ledger=$g_user->get_ledger_sql('ACH', 3); + $group_ledger=""; + if ( $p_group_ledger ) + { + $group_ledger='j_jrn_def,'; + } + $sql="with detail_tva as ( select sum(qp_vat) as amount_vat, @@ -197,18 +184,163 @@ class Tax_Summary sum(qp_nd_tva) as amount_noded_tax, sum(qp_nd_tva_recup) as amount_noded_return, sum(qp_dep_priv) as amount_private, - qp_vat_code, - j_jrn_def + {$group_ledger} + qp_vat_code from quant_purchase join tva_rate on (qp_vat_code=tva_rate.tva_id) join jrnx on (quant_purchase.j_id=jrnx.j_id) join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def) + join jrn on (jrn.jr_grpt_id=jrnx.j_grpt) + "; + if ( $this->tva_type=="O") + { + $sql=$sql." where j_date >= to_date($1,'DD.MM.YYYY') and j_date <= to_date($2,'DD.MM.YYYY') and {$sql_ledger} - group by j_jrn_def,qp_vat_code) + group by {$group_ledger} qp_vat_code) "; + } elseif ($this->tva_type=="P") { + $sql=$sql." + where + coalesce(to_char(jr_date_paid,'YYYYMMDD'),'00000000') >= + to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD') + and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'99999999') <= + to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD') + and {$sql_ledger} + group by {$group_ledger} qp_vat_code) "; + }elseif ($this->tva_type=="T") { + $sql=$sql." where + ( tva_rate.tva_payment_purchase='P' + and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'00000000') >= + to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD') + and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'99999999') <= + to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD') + ) + or + ( tva_rate.tva_payment_purchase='O' + and coalesce(to_char(jr_date,'YYYYMMDD'),'00000000') >= + to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD') + and coalesce(to_char(jr_date,'YYYYMMDD'),'99999999') <= + to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD') + ) + and {$sql_ledger} + group by {$group_ledger} qp_vat_code) "; + + } else { + throw new Exception(_("Exig TVA invalide"),1001); + } + return $sql; + } + /** + * Build the SQL for sale vat + * + * @param group by ledger + * + * @return string + * + */ + private function build_sql_sale($p_group_ledger=TRUE) + { + global $g_user; + $sql_ledger=$g_user->get_ledger_sql('VEN', 3); + $group_ledger=""; + if ( $p_group_ledger ) + { + $group_ledger='j_jrn_def,'; + } + $sql="with detail_tva as ( + select + sum(qs_vat) as amount_vat, + sum(qs_vat_sided) as amount_sided, + sum(qs_price) as amount_wovat, + {$group_ledger} + qs_vat_code + from + quant_sold + join tva_rate on (qs_vat_code=tva_rate.tva_id) + join jrnx on (quant_sold.j_id=jrnx.j_id) + join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def) + join jrn on (jrn.jr_grpt_id=jrnx.j_grpt)"; + if ( $this->tva_type=="O") + { + $sql=$sql." + where + j_date >= to_date($1,'DD.MM.YYYY') + and j_date <= to_date($2,'DD.MM.YYYY') + and {$sql_ledger} + group by {$group_ledger} qs_vat_code) "; + + } elseif ($this->tva_type=="P") { + $sql=$sql." + where + coalesce(to_char(jr_date_paid,'YYYYMMDD'),'00000000') >= + to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD') + and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'99999999') <= + to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD') + and {$sql_ledger} + group by {$group_ledger} qs_vat_code) "; + + } elseif ($this->tva_type=="T") { + $sql=$sql." + where + ( tva_rate.tva_payment_sale='P' + and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'00000000') >= + to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD') + and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'99999999') <= + to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD') + ) + or + ( tva_rate.tva_payment_sale='O' + and coalesce(to_char(jr_date,'YYYYMMDD'),'00000000') >= + to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD') + and coalesce(to_char(jr_date,'YYYYMMDD'),'99999999') <= + to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD') + ) + and {$sql_ledger} + group by {$group_ledger} qs_vat_code) + "; + } + else { + throw new Exception(_("Exig TVA invalide"),1001); + } + return $sql; + } + /** + * Total for each sales ledger + * @return array + */ + function get_row_sale() + { + $sql=$this->build_sql_sale(TRUE); + $sql.=" + select jrn_def_name, + tva_label , + qs_vat_code, + tva_rate, + tva_both_side, + amount_vat, + amount_wovat, + amount_sided, + tva_payment_sale as tva_type + from + detail_tva + join tva_rate on (tva_rate.tva_id=qs_vat_code) + join jrn_def on (jrn_def.jrn_def_id=j_jrn_def) + order by jrn_def_name,tva_label"; + + $array=$this->db->get_array($sql, [$this->date_start, $this->date_end]); + return $array; + } + + /** + * Total for each purchase ledger + * @return array + */ + function get_row_purchase() + { + $sql=$this->build_sql_purchase(TRUE)." select jrn_def_name, tva_label , tva_rate, @@ -226,7 +358,7 @@ class Tax_Summary join tva_rate on (tva_rate.tva_id=qp_vat_code) join jrn_def on (jrn_def.jrn_def_id=j_jrn_def) order by jrn_def_name,tva_label"; - $array=$this->db->get_array($sql,[$this->date_start,$this->date_end]); + $array=$this->db->get_array($sql, [$this->date_start, $this->date_end]); return $array; } @@ -235,66 +367,31 @@ class Tax_Summary */ function get_summary_sale() { - global $g_user; - $sql_ledger=$g_user->get_ledger_sql('ALL',3); - $sql="with detail_tva as ( - select - sum(qs_vat) as amount_vat, - sum(qs_vat_sided) as amount_sided, - sum(qs_price) as amount_wovat, - qs_vat_code - from - quant_sold - join tva_rate on (qs_vat_code=tva_rate.tva_id) - join jrnx on (quant_sold.j_id=jrnx.j_id) - join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def) - where - j_date >= to_date($1,'DD.MM.YYYY') - and j_date <= to_date($2,'DD.MM.YYYY') - and {$sql_ledger} - group by qs_vat_code) - select - tva_label , - qs_vat_code, - tva_rate, + $sql=$this->build_sql_sale(FALSE); + $sql.="select + tva_label , + qs_vat_code, + tva_rate, tva_both_side, - amount_vat, - amount_wovat, - amount_sided - from - detail_tva - join tva_rate on (tva_rate.tva_id=qs_vat_code) + amount_vat, + amount_wovat, + amount_sided, + tva_rate.tva_payment_sale + from + detail_tva + join tva_rate on (tva_rate.tva_id=qs_vat_code) order by tva_label"; - $array=$this->db->get_array($sql,[$this->date_start,$this->date_end]); + $array=$this->db->get_array($sql, [$this->date_start, $this->date_end]); return $array; } + /** * Summary for all purchase ledger */ function get_summary_purchase() { - global $g_user; - $sql_ledger=$g_user->get_ledger_sql('ALL',3); - $sql="with detail_tva as ( - select - sum(qp_vat) as amount_vat, - sum(qp_vat_sided) as amount_sided, - sum(qp_price) as amount_wovat, - sum(qp_nd_amount) as amount_noded_amount, - sum(qp_nd_tva) as amount_noded_tax, - sum(qp_nd_tva_recup) as amount_noded_return, - sum(qp_dep_priv) as amount_private, - qp_vat_code - from - quant_purchase - join tva_rate on (qp_vat_code=tva_rate.tva_id) - join jrnx on (quant_purchase.j_id=jrnx.j_id) - join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def) - where - j_date >= to_date($1,'DD.MM.YYYY') - and j_date <= to_date($2,'DD.MM.YYYY') - and {$sql_ledger} - group by qp_vat_code) + + $sql=$this->build_sql_purchase(FALSE)." select tva_label , tva_rate, @@ -311,10 +408,11 @@ class Tax_Summary detail_tva join tva_rate on (tva_rate.tva_id=qp_vat_code) order by tva_label"; - $array=$this->db->get_array($sql,[$this->date_start,$this->date_end]); + $array=$this->db->get_array($sql, [$this->date_start, $this->date_end]); return $array; } + /** * @brief display the summary of VAT in the range of date */ @@ -322,6 +420,7 @@ class Tax_Summary { require_once NOALYSS_INCLUDE."/template/tax_summary_display.php"; } + /** * @brief display a form to export in CSV * @see export_printtva_csv.php @@ -330,11 +429,12 @@ class Tax_Summary { echo '
'; echo Dossier::hidden(); - echo HtmlInput::hidden("act",'CSV:printtva'); - echo HtmlInput::hidden("date_start",$this->date_start); - echo HtmlInput::hidden("date_end",$this->date_end); + echo HtmlInput::hidden("act", 'CSV:printtva'); + echo HtmlInput::hidden("date_start", $this->date_start); + echo HtmlInput::hidden("date_end", $this->date_end); + echo HtmlInput::hidden("tva_type", $this->tva_type); - echo HtmlInput::submit("CSV:printtva",_("Export CSV")); + echo HtmlInput::submit("CSV:printtva", _("Export CSV")); echo '
'; } @@ -346,13 +446,12 @@ class Tax_Summary { echo '
'; echo Dossier::hidden(); - echo HtmlInput::hidden("act",'PDF:printtva'); - echo HtmlInput::hidden("date_start",$this->date_start); - echo HtmlInput::hidden("date_end",$this->date_end); - - echo HtmlInput::submit("PDF:printtva",_("Export PDF")); + echo HtmlInput::hidden("act", 'PDF:printtva'); + echo HtmlInput::hidden("date_start", $this->date_start); + echo HtmlInput::hidden("date_end", $this->date_end); + echo HtmlInput::hidden("tva_type", $this->tva_type); + echo HtmlInput::submit("PDF:printtva", _("Export PDF")); echo '
'; } - } diff --git a/include/class/tva_rate_mtable.class.php b/include/class/tva_rate_mtable.class.php index 6e21d10e4..4ffba15ac 100644 --- a/include/class/tva_rate_mtable.class.php +++ b/include/class/tva_rate_mtable.class.php @@ -57,7 +57,22 @@ class Tva_Rate_MTable extends Manage_Table_SQL ["value"=>1, "label"=>_("Autoliquidation")] )); $this->set_property_updatable("tva_id", FALSE); - $this->a_info=["tva_purchase"=>44,"tva_both_side"=>43,"tva_sale"=>45]; + $this->set_col_label("tva_payment_purchase",_("Exigible achat")); + $this->set_col_type("tva_payment_purchase","select", + array( + array("value"=>'O',"label"=>"Opération"), + array("value"=>'P',"label"=>"Paiement") + ) + ); + $this->set_col_label("tva_payment_sale",_("Exigible vente")); + $this->set_col_type("tva_payment_sale","select", + array( + array("value"=>'O',"label"=>"Opération"), + array("value"=>'P',"label"=>"Paiement") + ) + ); + $this->a_info=["tva_purchase"=>44,"tva_both_side"=>43,"tva_sale"=>45 + ,"tva_payment_sale"=>74,"tva_payment_purchase"=>74]; } /** @@ -183,6 +198,8 @@ class Tva_Rate_MTable extends Manage_Table_SQL $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->setp("tva_payment_sale", $this->table->tva_payment_sale); + $tva_rate->setp("tva_payment_purchase", $this->table->tva_payment_purchase); $tva_rate->save(); // reload the row diff --git a/include/constant.php b/include/constant.php index cb856c36b..5d0fc867e 100644 --- a/include/constant.php +++ b/include/constant.php @@ -108,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",138); +define ("DBVERSION",139); 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 index da6c95c55..f23d98b52 100644 --- a/include/database/tva_rate_sql.class.php +++ b/include/database/tva_rate_sql.class.php @@ -45,6 +45,8 @@ class Tva_rate_SQL extends Noalyss_SQL , "tva_comment"=>"tva_comment" , "tva_poste"=>"tva_poste" , "tva_both_side"=>"tva_both_side" + ,"tva_payment_purchase"=>"tva_payment_purchase" + ,"tva_payment_sale"=>"tva_payment_sale" ); /* * Type of columns @@ -56,6 +58,9 @@ class Tva_rate_SQL extends Noalyss_SQL , "tva_comment"=>"text" , "tva_poste"=>"text" , "tva_both_side"=>"numeric" + ,"tva_payment_purchase"=>"text" + ,"tva_payment_sale"=>"text" + ); diff --git a/include/database/v_tva_rate_sql.class.php b/include/database/v_tva_rate_sql.class.php index 701bdc3ea..19c63fe3c 100644 --- a/include/database/v_tva_rate_sql.class.php +++ b/include/database/v_tva_rate_sql.class.php @@ -46,6 +46,9 @@ class V_Tva_Rate_SQL extends Noalyss_SQL , "tva_purchase"=>"tva_purchase" , "tva_sale"=>"tva_sale" , "tva_both_side"=>"tva_both_side" + ,'tva_payment_purchase'=>'tva_payment_purchase' + ,'tva_payment_sale'=>'tva_payment_sale' + ); /* * Type of columns @@ -58,6 +61,8 @@ class V_Tva_Rate_SQL extends Noalyss_SQL , "tva_purchase"=>"text" , "tva_sale"=>"text" , "tva_both_side"=>"numeric" + , 'tva_payment_purchase'=>'text' + , 'tva_payment_sale'=>'text' ); diff --git a/include/export/export_printtva_csv.php b/include/export/export_printtva_csv.php index ebe8ddde4..b5c75196d 100644 --- a/include/export/export_printtva_csv.php +++ b/include/export/export_printtva_csv.php @@ -30,6 +30,9 @@ require_once NOALYSS_INCLUDE."/class/tax_summary.class.php"; require_once NOALYSS_INCLUDE."/lib/noalyss_csv.class.php"; $http=new HttpInput(); $tax_summary = new Tax_Summary($cn,$http->get("date_start"),$http->get("date_end")); +$tva_type = $http->request("tva_type"); +$tax_summary->set_tva_type($tva_type); + try { $tax_summary->check(); }catch (Exception $e) diff --git a/include/export/export_printtva_pdf.php b/include/export/export_printtva_pdf.php index 028db71e2..19203c331 100644 --- a/include/export/export_printtva_pdf.php +++ b/include/export/export_printtva_pdf.php @@ -34,6 +34,7 @@ $http = new HttpInput(); $from_periode = $http->request("date_start"); $to_periode = $http->request("date_end"); +$tva_type = $http->request("tva_type"); $gDossier = dossier::id(); @@ -41,6 +42,7 @@ $gDossier = dossier::id(); /* Security */ $cn = Dossier::connect(); $tax_summary = new Tax_Summary($cn, $from_periode, $to_periode); +$tax_summary->set_tva_type($tva_type); $pdf = new PDFLand($cn); $pdf->setDossierInfo(sprintf(_("Date") . " : %s %s", $from_periode, $to_periode)); $pdf->AliasNbPages(); diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php index 9333a2dd2..fb03d36b2 100644 --- a/include/lib/message_javascript.php +++ b/include/lib/message_javascript.php @@ -104,4 +104,5 @@ content[70]=""; content[72]=""; content[73]=""; +content[74]=""; \ No newline at end of file diff --git a/include/sql/patch/upgrade138.sql b/include/sql/patch/upgrade138.sql new file mode 100644 index 000000000..f7e341f99 --- /dev/null +++ b/include/sql/patch/upgrade138.sql @@ -0,0 +1,36 @@ +begin; +ALTER TABLE public.tva_rate ADD tva_payment_sale char(1) NULL DEFAULT 'O'; +update public.tva_rate set tva_payment_sale='O'; +ALTER TABLE public.tva_rate ADD CONSTRAINT tva_rate_sale_check CHECK (tva_payment in ('O','P')); +comment on column public.tva_rate.tva_payment_sale is 'Check if the VAT on Sale must be declared when at the date of payment (P) or the date of operation (O)'; + + +ALTER TABLE public.tva_rate ADD tva_payment_purchase char(1) NULL DEFAULT 'O'; +update public.tva_rate set tva_payment_purchase='O'; +ALTER TABLE public.tva_rate ADD CONSTRAINT tva_rate_purchase_check CHECK (tva_payment in ('O','P')); +comment on column public.tva_rate.tva_payment_purchase is 'Check if the VAT on Purchase must be declared when at the date of payment (P) or the date of operation (O)'; + + +drop VIEW public.v_tva_rate; + +CREATE OR REPLACE VIEW public.v_tva_rate +AS SELECT tva_rate.tva_id, + tva_rate.tva_rate, + tva_rate.tva_label, + tva_rate.tva_comment, + split_part(tva_rate.tva_poste, ','::text, 1) AS tva_purchase, + split_part(tva_rate.tva_poste, ','::text, 2) AS tva_sale, + tva_rate.tva_both_side, + tva_payment_purchase, + tva_payment_sale + FROM tva_rate; + +COMMENT ON VIEW public.v_tva_rate IS 'Show this table to be easily used by Tva_Rate_MTable'; +COMMENT ON COLUMN public.v_tva_rate.tva_purchase IS ' VAT used for purchase'; +COMMENT ON COLUMN public.v_tva_rate.tva_sale IS ' VAT used for sale'; +COMMENT ON COLUMN public.v_tva_rate.tva_both_side IS 'if 1 , VAT avoided '; +comment on column public.v_tva_rate.tva_payment_purchase is 'Check if the VAT on Purchase must be declared when at the date of payment (P) or the date of operation (O)'; +comment on column public.v_tva_rate.tva_payment_sale is 'Check if the VAT on Sale must be declared when at the date of payment (P) or the date of operation (O)'; + +insert into version (val,v_description) values (139,'Add VAT exigibility'); +commit ; \ No newline at end of file diff --git a/include/tax_summary.inc.php b/include/tax_summary.inc.php index 7da2ad2d5..c60e8b5b5 100644 --- a/include/tax_summary.inc.php +++ b/include/tax_summary.inc.php @@ -36,6 +36,15 @@ $end_periode = new IDate("end_date", $end); echo '
'; echo HtmlInput::array_to_hidden(['gDossier','ac'],$_GET); echo HtmlInput::hidden("do","display"); +$select_tva=new ISelect("tva_type"); +$select_tva->value=array( + array("value"=>'O',"label"=>_("Opération")), + array("value"=>'P',"label"=>_("Paiement")), + array("value"=>'T',"label"=>_("TVA")) +); +$select_tva->selected=$http->get('tva_type','string','O'); +printf(_("Calcul d'après la date")); +echo $select_tva->input(); printf(_("Période du %s au %s"), $start_periode->input(), $end_periode->input()); @@ -46,6 +55,7 @@ echo '
'; if ( $http->get("do","string","no") == "display") { $tax_summary=new Tax_Summary($cn,$start_periode->value,$end_periode->value); + $tax_summary->set_tva_type($select_tva->selected); try { try { $tax_summary->check(); diff --git a/unit-test/include/class/data/tax_summary_getrow_purchase_o.php b/unit-test/include/class/data/tax_summary_getrow_purchase_o.php new file mode 100644 index 000000000..f75c5bc60 --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getrow_purchase_o.php @@ -0,0 +1,199 @@ + + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '0%', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '4', + 'amount_vat' => '0.0000', + 'amount_wovat' => '658.2500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 1 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '12%', + 'tva_rate' => '0.1200', + 'tva_both_side' => '0', + 'qp_vat_code' => '2', + 'amount_vat' => '109.8000', + 'amount_wovat' => '915.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 2 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '44.5300', + 'amount_wovat' => '212.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 3 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '6%', + 'tva_rate' => '0.0600', + 'tva_both_side' => '0', + 'qp_vat_code' => '3', + 'amount_vat' => '5.2800', + 'amount_wovat' => '88.3200', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 4 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => 'ART44', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '8', + 'amount_vat' => '0.0000', + 'amount_wovat' => '315.2000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 5 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => 'EXPORT', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '6', + 'amount_vat' => '0.0000', + 'amount_wovat' => '286.9500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 6 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => 'IMMO', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1002', + 'amount_vat' => '319.2400', + 'amount_wovat' => '1520.2000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 7 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => 'VOIT', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1003', + 'amount_vat' => '21.0000', + 'amount_wovat' => '100.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 8 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '244.5500', + 'amount_wovat' => '1164.5400', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 9 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => 'EXPORT', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '6', + 'amount_vat' => '0.0000', + 'amount_wovat' => '259.8000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 10 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => 'IMMO', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1002', + 'amount_vat' => '319.2400', + 'amount_wovat' => '1520.2000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 11 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => 'INTRA', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '5', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1250.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 12 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => 'VOIT', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1003', + 'amount_vat' => '42.0000', + 'amount_wovat' => '200.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getrow_purchase_p.php b/unit-test/include/class/data/tax_summary_getrow_purchase_p.php new file mode 100644 index 000000000..71caa2136 --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getrow_purchase_p.php @@ -0,0 +1,48 @@ + + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '0%', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '4', + 'amount_vat' => '0.0000', + 'amount_wovat' => '658.2500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 1 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '38.4300', + 'amount_wovat' => '183.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 2 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '140.0400', + 'amount_wovat' => '666.8600', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getrow_purchase_t.php b/unit-test/include/class/data/tax_summary_getrow_purchase_t.php new file mode 100644 index 000000000..5bed31568 --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getrow_purchase_t.php @@ -0,0 +1,183 @@ + + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '0%', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '4', + 'amount_vat' => '0.0000', + 'amount_wovat' => '658.2500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 1 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '12%', + 'tva_rate' => '0.1200', + 'tva_both_side' => '0', + 'qp_vat_code' => '2', + 'amount_vat' => '109.8000', + 'amount_wovat' => '915.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 2 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '38.4300', + 'amount_wovat' => '183.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 3 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => 'ART44', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '8', + 'amount_vat' => '0.0000', + 'amount_wovat' => '315.2000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 4 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => 'EXPORT', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '6', + 'amount_vat' => '0.0000', + 'amount_wovat' => '286.9500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 5 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => 'IMMO', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1002', + 'amount_vat' => '319.2400', + 'amount_wovat' => '1520.2000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 6 => + array ( + 'jrn_def_name' => 'Achat', + 'tva_label' => 'VOIT', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1003', + 'amount_vat' => '21.0000', + 'amount_wovat' => '100.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 7 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '140.0400', + 'amount_wovat' => '666.8600', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 8 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => 'EXPORT', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '6', + 'amount_vat' => '0.0000', + 'amount_wovat' => '259.8000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 9 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => 'IMMO', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1002', + 'amount_vat' => '319.2400', + 'amount_wovat' => '1520.2000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 10 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => 'INTRA', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '5', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1250.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 11 => + array ( + 'jrn_def_name' => 'Frais Divers', + 'tva_label' => 'VOIT', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1003', + 'amount_vat' => '42.0000', + 'amount_wovat' => '200.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getrow_sale_o.php b/unit-test/include/class/data/tax_summary_getrow_sale_o.php new file mode 100644 index 000000000..03674e9ab --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getrow_sale_o.php @@ -0,0 +1,63 @@ + + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => '21%', + 'qs_vat_code' => '1', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '219.5700', + 'amount_wovat' => '1045.6000', + 'amount_sided' => '0.0000', + 'tva_type' => 'P', + ), + 1 => + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => 'EXPORT', + 'qs_vat_code' => '6', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1047.9000', + 'amount_sided' => '0.0000', + 'tva_type' => 'O', + ), + 2 => + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => 'INTRA', + 'qs_vat_code' => '5', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1800.0000', + 'amount_sided' => '0.0000', + 'tva_type' => 'O', + ), + 3 => + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => 'VOIT', + 'qs_vat_code' => '1003', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '19.1500', + 'amount_wovat' => '91.2000', + 'amount_sided' => '0.0000', + 'tva_type' => 'P', + ), + 4 => + array ( + 'jrn_def_name' => 'Vente différée', + 'tva_label' => 'EXPORT', + 'qs_vat_code' => '6', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '150.5600', + 'amount_sided' => '0.0000', + 'tva_type' => 'O', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getrow_sale_p.php b/unit-test/include/class/data/tax_summary_getrow_sale_p.php new file mode 100644 index 000000000..4c611e3b7 --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getrow_sale_p.php @@ -0,0 +1,28 @@ + + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => '21%', + 'qs_vat_code' => '1', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '16.8000', + 'amount_wovat' => '80.0000', + 'amount_sided' => '0.0000', + 'tva_type' => 'P', + ), + 1 => + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => 'VOIT', + 'qs_vat_code' => '1003', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '10.7500', + 'amount_wovat' => '51.2000', + 'amount_sided' => '0.0000', + 'tva_type' => 'P', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getrow_sale_t.php b/unit-test/include/class/data/tax_summary_getrow_sale_t.php new file mode 100644 index 000000000..2a0aa767b --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getrow_sale_t.php @@ -0,0 +1,64 @@ + + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => '21%', + 'qs_vat_code' => '1', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '16.8000', + 'amount_wovat' => '80.0000', + 'amount_sided' => '0.0000', + 'tva_type' => 'P', + ), + 1 => + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => 'EXPORT', + 'qs_vat_code' => '6', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1047.9000', + 'amount_sided' => '0.0000', + 'tva_type' => 'O', + ), + 2 => + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => 'INTRA', + 'qs_vat_code' => '5', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1800.0000', + 'amount_sided' => '0.0000', + 'tva_type' => 'O', + ), + 3 => + array ( + 'jrn_def_name' => 'Vente', + 'tva_label' => 'VOIT', + 'qs_vat_code' => '1003', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '10.7500', + 'amount_wovat' => '51.2000', + 'amount_sided' => '0.0000', + 'tva_type' => 'P', + ), + 4 => + array ( + 'jrn_def_name' => 'Vente différée', + 'tva_label' => 'EXPORT', + 'qs_vat_code' => '6', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '150.5600', + 'amount_sided' => '0.0000', + 'tva_type' => 'O', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getsummary_purchase_o.php b/unit-test/include/class/data/tax_summary_getsummary_purchase_o.php new file mode 100644 index 000000000..dc6ef6766 --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getsummary_purchase_o.php @@ -0,0 +1,130 @@ + + array ( + 'tva_label' => '0%', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '4', + 'amount_vat' => '0.0000', + 'amount_wovat' => '658.2500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 1 => + array ( + 'tva_label' => '12%', + 'tva_rate' => '0.1200', + 'tva_both_side' => '0', + 'qp_vat_code' => '2', + 'amount_vat' => '109.8000', + 'amount_wovat' => '915.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 2 => + array ( + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '289.0800', + 'amount_wovat' => '1376.5400', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 3 => + array ( + 'tva_label' => '6%', + 'tva_rate' => '0.0600', + 'tva_both_side' => '0', + 'qp_vat_code' => '3', + 'amount_vat' => '5.2800', + 'amount_wovat' => '88.3200', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 4 => + array ( + 'tva_label' => 'ART44', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '8', + 'amount_vat' => '0.0000', + 'amount_wovat' => '315.2000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 5 => + array ( + 'tva_label' => 'EXPORT', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '6', + 'amount_vat' => '0.0000', + 'amount_wovat' => '546.7500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 6 => + array ( + 'tva_label' => 'IMMO', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1002', + 'amount_vat' => '638.4800', + 'amount_wovat' => '3040.4000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 7 => + array ( + 'tva_label' => 'INTRA', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '5', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1250.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 8 => + array ( + 'tva_label' => 'VOIT', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1003', + 'amount_vat' => '63.0000', + 'amount_wovat' => '300.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getsummary_purchase_p.php b/unit-test/include/class/data/tax_summary_getsummary_purchase_p.php new file mode 100644 index 000000000..b0a9258f7 --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getsummary_purchase_p.php @@ -0,0 +1,31 @@ + + array ( + 'tva_label' => '0%', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '4', + 'amount_vat' => '0.0000', + 'amount_wovat' => '658.2500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 1 => + array ( + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '178.4700', + 'amount_wovat' => '849.8600', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getsummary_purchase_t.php b/unit-test/include/class/data/tax_summary_getsummary_purchase_t.php new file mode 100644 index 000000000..2f628bcf0 --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getsummary_purchase_t.php @@ -0,0 +1,116 @@ + + array ( + 'tva_label' => '0%', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '4', + 'amount_vat' => '0.0000', + 'amount_wovat' => '658.2500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 1 => + array ( + 'tva_label' => '12%', + 'tva_rate' => '0.1200', + 'tva_both_side' => '0', + 'qp_vat_code' => '2', + 'amount_vat' => '109.8000', + 'amount_wovat' => '915.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 2 => + array ( + 'tva_label' => '21%', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1', + 'amount_vat' => '178.4700', + 'amount_wovat' => '849.8600', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 3 => + array ( + 'tva_label' => 'ART44', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '8', + 'amount_vat' => '0.0000', + 'amount_wovat' => '315.2000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 4 => + array ( + 'tva_label' => 'EXPORT', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '6', + 'amount_vat' => '0.0000', + 'amount_wovat' => '546.7500', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 5 => + array ( + 'tva_label' => 'IMMO', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1002', + 'amount_vat' => '638.4800', + 'amount_wovat' => '3040.4000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 6 => + array ( + 'tva_label' => 'INTRA', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'qp_vat_code' => '5', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1250.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), + 7 => + array ( + 'tva_label' => 'VOIT', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'qp_vat_code' => '1003', + 'amount_vat' => '63.0000', + 'amount_wovat' => '300.0000', + 'amount_sided' => '0.0000', + 'amount_noded_amount' => '0.0000', + 'amount_noded_tax' => '0.0000', + 'amount_noded_return' => '0.0000', + 'amount_private' => '0.0000', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getsummary_sale_o.php b/unit-test/include/class/data/tax_summary_getsummary_sale_o.php new file mode 100644 index 000000000..64abaf88a --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getsummary_sale_o.php @@ -0,0 +1,48 @@ + + array ( + 'tva_label' => '21%', + 'qs_vat_code' => '1', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '219.5700', + 'amount_wovat' => '1045.6000', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'P', + ), + 1 => + array ( + 'tva_label' => 'EXPORT', + 'qs_vat_code' => '6', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1198.4600', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'O', + ), + 2 => + array ( + 'tva_label' => 'INTRA', + 'qs_vat_code' => '5', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1800.0000', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'O', + ), + 3 => + array ( + 'tva_label' => 'VOIT', + 'qs_vat_code' => '1003', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '19.1500', + 'amount_wovat' => '91.2000', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'P', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getsummary_sale_p.php b/unit-test/include/class/data/tax_summary_getsummary_sale_p.php new file mode 100644 index 000000000..efd438775 --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getsummary_sale_p.php @@ -0,0 +1,26 @@ + + array ( + 'tva_label' => '21%', + 'qs_vat_code' => '1', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '16.8000', + 'amount_wovat' => '80.0000', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'P', + ), + 1 => + array ( + 'tva_label' => 'VOIT', + 'qs_vat_code' => '1003', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '10.7500', + 'amount_wovat' => '51.2000', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'P', + ), +); diff --git a/unit-test/include/class/data/tax_summary_getsummary_sale_t.php b/unit-test/include/class/data/tax_summary_getsummary_sale_t.php new file mode 100644 index 000000000..b5adb41eb --- /dev/null +++ b/unit-test/include/class/data/tax_summary_getsummary_sale_t.php @@ -0,0 +1,48 @@ + + array ( + 'tva_label' => '21%', + 'qs_vat_code' => '1', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '16.8000', + 'amount_wovat' => '80.0000', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'P', + ), + 1 => + array ( + 'tva_label' => 'EXPORT', + 'qs_vat_code' => '6', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1198.4600', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'O', + ), + 2 => + array ( + 'tva_label' => 'INTRA', + 'qs_vat_code' => '5', + 'tva_rate' => '0.0000', + 'tva_both_side' => '0', + 'amount_vat' => '0.0000', + 'amount_wovat' => '1800.0000', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'O', + ), + 3 => + array ( + 'tva_label' => 'VOIT', + 'qs_vat_code' => '1003', + 'tva_rate' => '0.2100', + 'tva_both_side' => '0', + 'amount_vat' => '10.7500', + 'amount_wovat' => '51.2000', + 'amount_sided' => '0.0000', + 'tva_payment_sale' => 'P', + ), +); diff --git a/unit-test/include/class/tax_summaryTest.class.php b/unit-test/include/class/tax_summaryTest.class.php index 1b1643c97..6719d3b85 100644 --- a/unit-test/include/class/tax_summaryTest.class.php +++ b/unit-test/include/class/tax_summaryTest.class.php @@ -85,571 +85,183 @@ class Tax_SummaryTest extends TestCase $this->expectOutputRegex("/\object->form_export_pdf(); } - - function testGet_row_purchase() + private function check_result ($p_scenario , $p_array,$p_array_expected,$jrn_type) { - $array=$this->object->get_row_purchase(); - //-- For creating the array - Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_purchase.txt", print_r($array, TRUE)); - $a_result=array - ( - "0"=>array - ( - "jrn_def_name"=>"Achat", - "tva_label"=>"0%", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>4, - "amount_vat"=>0.0000, - "amount_wovat"=>658.2500, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "1"=>array - ( - "jrn_def_name"=>"Achat", - "tva_label"=>"12%", - "tva_rate"=>0.1200, - "tva_both_side"=>0, - "qp_vat_code"=>2, - "amount_vat"=>109.8000, - "amount_wovat"=>915.0000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "2"=>array - ( - "jrn_def_name"=>"Achat", - "tva_label"=>"21%", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1, - "amount_vat"=>6.1000, - "amount_wovat"=>29.0000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "3"=>array - ( - "jrn_def_name"=>"Achat", - "tva_label"=>"6%", - "tva_rate"=>0.0600, - "tva_both_side"=>0, - "qp_vat_code"=>3, - "amount_vat"=>5.2800, - "amount_wovat"=>88.3200, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "4"=>array - ( - "jrn_def_name"=>"Achat", - "tva_label"=>"ART44", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>8, - "amount_vat"=>0.0000, - "amount_wovat"=>315.2000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "5"=>array - ( - "jrn_def_name"=>"Achat", - "tva_label"=>"EXPORT", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>6, - "amount_vat"=>0.0000, - "amount_wovat"=>286.9500, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "6"=>array - ( - "jrn_def_name"=>"Achat", - "tva_label"=>"IMMO", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1002, - "amount_vat"=>319.2400, - "amount_wovat"=>1520.2000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "7"=>array - ( - "jrn_def_name"=>"Achat", - "tva_label"=>"VOIT", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1003, - "amount_vat"=>21.0000, - "amount_wovat"=>100.0000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "8"=>array - ( - "jrn_def_name"=>"Frais Divers", - "tva_label"=>"21%", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1, - "amount_vat"=>244.5500, - "amount_wovat"=>1164.5400, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "9"=>array - ( - "jrn_def_name"=>"Frais Divers", - "tva_label"=>"EXPORT", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>6, - "amount_vat"=>0.0000, - "amount_wovat"=>259.8000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "10"=>array - ( - "jrn_def_name"=>"Frais Divers", - "tva_label"=>"IMMO", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1002, - "amount_vat"=>319.2400, - "amount_wovat"=>1520.2000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "11"=>array - ( - "jrn_def_name"=>"Frais Divers", - "tva_label"=>"INTRA", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>5, - "amount_vat"=>0.0000, - "amount_wovat"=>1250.0000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "12"=>array - ( - "jrn_def_name"=>"Frais Divers", - "tva_label"=>"VOIT", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1003, - "amount_vat"=>42.0000, - "amount_wovat"=>200.0000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000, - ) - ); - $nb_result=count($a_result); - $nb_array=count($array); + $nb_result=count($p_array_expected); + $nb_array=count($p_array); $this->assertEquals($nb_result, $nb_array); $ix=0; + switch ($jrn_type) + { + case "ACH": + $vat_code="qp_vat_code"; + break; + case "SMRACH": + $vat_code="qp_vat_code"; + break; + case "VEN": + $vat_code="qs_vat_code"; + break; + case "SMRVEN": + $vat_code="qs_vat_code"; + break; + + default: + throw new Exception(_("unknow jrn_type")); + break; + } for ($i=0; $i<$nb_result; $i++) { - $row=$a_result[$i]; + $row=$p_array_expected[$i]; for ($e=0; $e<$nb_array; $e++) { + $test_jrn_expected=""; + $test_jrn_result=""; + if ( in_array($jrn_type, ['ACH','VEN'])) + { + $test_jrn_expected=$row['jrn_def_name'] ; + $test_jrn_result=$p_array[$e]["jrn_def_name"]; + } if ( - $row['qp_vat_code']==$array[$e]['qp_vat_code'] - && $row['jrn_def_name'] == $array[$e]["jrn_def_name"] + $row[$vat_code]==$p_array[$e][$vat_code] + && $test_jrn_expected == $test_jrn_result ) { - $this->assertEquals($row['amount_vat'], $array[$e]['amount_vat'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_wovat'], $array[$e]['amount_wovat'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_sided'], $array[$e]['amount_sided'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_noded_amount'], $array[$e]['amount_noded_amount'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_noded_tax'], $array[$e]['amount_noded_tax'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_noded_return'], $array[$e]['amount_noded_return'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_private'], $array[$e]['amount_private'] - ,sprintf("Code %s ",$row['qp_vat_code'])); + $this->assertEquals($row['amount_vat'], $p_array[$e]['amount_vat'] + ,sprintf("%s Code %s ",$p_scenario,$row[$vat_code])); + + $this->assertEquals($row['amount_sided'], $p_array[$e]['amount_sided'] + ,sprintf("%s Code %s ",$p_scenario,$row[$vat_code])); + + $this->assertEquals($row['amount_wovat'], $p_array[$e]['amount_wovat'] + ,sprintf("%s Code %s ",$p_scenario,$row[$vat_code])); + + if ( $jrn_type=="ACH") { + + $this->assertEquals($row['amount_noded_amount'], $p_array[$e]['amount_noded_amount'] + ,sprintf("%s Code %s ",$p_scenario,$row[$vat_code])); + $this->assertEquals($row['amount_noded_tax'], $p_array[$e]['amount_noded_tax'] + ,sprintf("%s Code %s ",$p_scenario,$row[$vat_code])); + $this->assertEquals($row['amount_noded_return'], $p_array[$e]['amount_noded_return'] + ,sprintf("%s Code %s ",$p_scenario,$row[$vat_code])); + $this->assertEquals($row['amount_private'], $p_array[$e]['amount_private'] + ,sprintf("%s Code %s ",$p_scenario,$row[$vat_code])); + } $ix++; } } } $this->assertEquals($nb_array, $ix, 'Not all VAT CODE found'); + } + function testGet_row_purchase() + { + // Operation date + $this->object->set_tva_type("O"); + $array=$this->object->get_row_purchase(); + //-- For creating the array + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_purchase.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getrow_purchase_o.php"; + $this->check_result("tva_type = O , get_row_purchase",$array,$a_result,'ACH'); + + // Operation date + $this->object->set_tva_type("P"); + $array=$this->object->get_row_purchase(); + //-- For creating the array + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_purchase.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getrow_purchase_p.php"; + $this->check_result("tva_type = P , get_row_purchase",$array,$a_result,'ACH'); + + $this->object->set_tva_type("T"); + $array=$this->object->get_row_purchase(); + //-- For creating the array + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_purchase.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getrow_purchase_t.php"; + $this->check_result("tva_type = T , get_row_purchase",$array,$a_result,'ACH'); + + + + } function testGet_row_sale() { + $this->object->set_tva_type("O"); $array=$this->object->get_row_sale(); //-- For creating the array - //Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale.txt", print_r($array, TRUE)); - $a_result=array - ( - "0"=>array - ( - "jrn_def_name"=>"Vente", - "tva_label"=>"21%", - "qs_vat_code"=>1, - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "amount_vat"=>219.5700, - "amount_wovat"=>1045.6000, - "amount_sided"=>0.0000 - ), - "1"=>array - ( - "jrn_def_name"=>"Vente", - "tva_label"=>"EXPORT", - "qs_vat_code"=>6, - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "amount_vat"=>0.0000, - "amount_wovat"=>1047.9000, - "amount_sided"=>0.0000 - ), - "2"=>array - ( - "jrn_def_name"=>"Vente", - "tva_label"=>"INTRA", - "qs_vat_code"=>5, - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "amount_vat"=>0.0000, - "amount_wovat"=>1800.0000, - "amount_sided"=>0.0000 - ), - "3"=>array - ( - "jrn_def_name"=>"Vente", - "tva_label"=>"VOIT", - "qs_vat_code"=>1003, - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "amount_vat"=>8.4000, - "amount_wovat"=>40.0000, - "amount_sided"=>0.0000 - ), - "4"=>Array - ( - "jrn_def_name"=>"Vente différée", - "tva_label"=>"EXPORT", - "qs_vat_code"=>6, - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "amount_vat"=>0.0000, - "amount_wovat"=>150.5600, - "amount_sided"=>0.0000 - ) - ); - $nb_result=count($a_result); - $nb_array=count($array); - $this->assertEquals($nb_result, $nb_array); - $ix=0; - for ($i=0; $i<$nb_result; $i++) - { - $row=$a_result[$i]; - for ($e=0; $e<$nb_array; $e++) - { - if ( - $row['qs_vat_code']==$array[$e]['qs_vat_code']&&$row['jrn_def_name']==$array[$e]["jrn_def_name"] - ) - { - $this->assertEquals($row['amount_vat'], $array[$e]['amount_vat'] - , sprintf("Code %s ", $row['qs_vat_code'])); - $this->assertEquals($row['amount_wovat'], $array[$e]['amount_wovat'] - , sprintf("Code %s ", $row['qs_vat_code'])); - $this->assertEquals($row['amount_sided'], $array[$e]['amount_sided'] - , sprintf("Code %s ", $row['qs_vat_code'])); - $ix++; - } - } - } - $this->assertEquals($nb_array, $ix, 'Not all VAT CODE found'); + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_o.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getrow_sale_o.php"; + $this->check_result("tva_type = O , get_row_sale",$array,$a_result,'VEN'); + + + $this->object->set_tva_type("P"); + $array=$this->object->get_row_sale(); + //-- For creating the array + //Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_p.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getrow_sale_p.php"; + $this->check_result("tva_type = P , get_row_sale",$array,$a_result,'VEN'); + + + $this->object->set_tva_type("T"); + $array=$this->object->get_row_sale(); + //-- For creating the array + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_t.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getrow_sale_t.php"; + $this->check_result("tva_type = T , get_row_sale",$array,$a_result,'VEN'); + } function testget_summary_purchase() { + $this->object->set_tva_type("T"); $array=$this->object->get_summary_purchase(); //-- For creating the array - // \Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_summary_purchase.txt", print_r($array, TRUE)); - $a_result=array - ( - "0"=>array - ( - "tva_label"=>"0%", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>4, - "amount_vat"=>0.0000, - "amount_wovat"=>658.2500, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "1"=>array - ( - "tva_label"=>"12%", - "tva_rate"=>0.1200, - "tva_both_side"=>0, - "qp_vat_code"=>2, - "amount_vat"=>109.8000, - "amount_wovat"=>915.0000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "2"=>array - ( - "tva_label"=>"21%", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1, - "amount_vat"=>250.6500, - "amount_wovat"=>1193.5400, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "3"=>array - ( - "tva_label"=>"6%", - "tva_rate"=>0.0600, - "tva_both_side"=>0, - "qp_vat_code"=>3, - "amount_vat"=>5.2800, - "amount_wovat"=>88.3200, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "4"=>array - ( - "tva_label"=>"ART44", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>8, - "amount_vat"=>0.0000, - "amount_wovat"=>315.2000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "5"=>array - ( - "tva_label"=>"EXPORT", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>6, - "amount_vat"=>0.0000, - "amount_wovat"=>546.7500, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "6"=>array - ( - "tva_label"=>"IMMO", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1002, - "amount_vat"=>638.4800, - "amount_wovat"=>3040.4000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "7"=>array - ( - "tva_label"=>"INTRA", - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "qp_vat_code"=>5, - "amount_vat"=>0.0000, - "amount_wovat"=>1250.0000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ), - "8"=>array - ( - "tva_label"=>"VOIT", - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "qp_vat_code"=>1003, - "amount_vat"=>63.0000, - "amount_wovat"=>300.0000, - "amount_sided"=>0.0000, - "amount_noded_amount"=>0.0000, - "amount_noded_tax"=>0.0000, - "amount_noded_return"=>0.0000, - "amount_private"=>0.0000 - ) - ); - $nb_result=count($a_result); - $nb_array=count($array); - $this->assertEquals($nb_result, $nb_array); - $ix=0; - for ($i=0; $i<$nb_result; $i++) - { - $row=$a_result[$i]; - for ($e=0; $e<$nb_array; $e++) - { - if ($row['qp_vat_code']==$array[$e]['qp_vat_code']) - { - $this->assertEquals($row['amount_vat'], $array[$e]['amount_vat'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_wovat'], $array[$e]['amount_wovat'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_sided'], $array[$e]['amount_sided'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_noded_amount'], $array[$e]['amount_noded_amount'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_noded_tax'], $array[$e]['amount_noded_tax'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_noded_return'], $array[$e]['amount_noded_return'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $this->assertEquals($row['amount_private'], $array[$e]['amount_private'] - ,sprintf("Code %s ",$row['qp_vat_code'])); - $ix++; - } - } - } - $this->assertEquals($nb_array, $ix, 'Not all VAT CODE found'); + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_purchase_t.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getsummary_purchase_t.php"; + $this->check_result("tva_type = T , get_summary_purchase",$array,$a_result,'SMRACH'); + + $this->object->set_tva_type("O"); + $array=$this->object->get_summary_purchase(); + //-- For creating the array + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_purchase_o.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getsummary_purchase_o.php"; + $this->check_result("tva_type = O , get_summary_purchase",$array,$a_result,'SMRACH'); + + $this->object->set_tva_type("P"); + $array=$this->object->get_summary_purchase(); + //-- For creating the array + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_purchase_p.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getsummary_purchase_p.php"; + $this->check_result("tva_type = P , get_summary_purchase",$array,$a_result,'SMRACH'); + + } function testget_summary_sale() { + $this->object->set_tva_type("O"); $array=$this->object->get_summary_sale(); //-- For creating the array - // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_summary_sale.txt", print_r($array, TRUE)); + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_sale_o.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getsummary_sale_o.php"; + $this->check_result("tva_type = O , get_summary_sale",$array,$a_result,'SMRVEN'); + + $this->object->set_tva_type("P"); + $array=$this->object->get_summary_sale(); + //-- For creating the array + // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_sale_p.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getsummary_sale_p.php"; + $this->check_result("tva_type = P , get_summary_sale",$array,$a_result,'SMRVEN'); + + + $this->object->set_tva_type("T"); + $array=$this->object->get_summary_sale(); + //-- For creating the array + //Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_sale_t.txt", var_export($array, TRUE)); + require __DIR__."/data/tax_summary_getsummary_sale_t.php"; + $this->check_result("tva_type = T , get_summary_sale",$array,$a_result,'SMRVEN'); - $a_result=array - ( - array - ( - "tva_label"=>"21%", - "qs_vat_code"=>1, - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "amount_vat"=>219.5700, - "amount_wovat"=>1045.6000, - "amount_sided"=>0.0000 - ), - array - ( - "tva_label"=>"EXPORT", - "qs_vat_code"=>6, - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "amount_vat"=>0.0000, - "amount_wovat"=>1198.4600, - "amount_sided"=>0.0000 - ), - array - ( - "tva_label"=>"INTRA", - "qs_vat_code"=>5, - "tva_rate"=>0.0000, - "tva_both_side"=>0, - "amount_vat"=>0.0000, - "amount_wovat"=>1800.0000, - "amount_sided"=>0.0000 - ), - array - ( - "tva_label"=>"VOIT", - "qs_vat_code"=>1003, - "tva_rate"=>0.2100, - "tva_both_side"=>0, - "amount_vat"=>8.4000, - "amount_wovat"=>40.0000, - "amount_sided"=>0.0000 - ) - ); - $nb_result=count($a_result); - $nb_array=count($array); - $this->assertEquals($nb_result, $nb_array); - $ix=0; - for ($i=0; $i<$nb_result; $i++) - { - $row=$a_result[$i]; - for ($e=0; $e<$nb_array; $e++) - { - if ($row['qs_vat_code']==$array[$e]['qs_vat_code']) - { - $this->assertEquals($row['amount_vat'], $array[$e]['amount_vat'] - ,sprintf("Code %s ",$row['qs_vat_code'])); - $this->assertEquals($row['amount_wovat'], $array[$e]['amount_wovat'] - ,sprintf("Code %s ",$row['qs_vat_code'])); - $this->assertEquals($row['amount_sided'], $array[$e]['amount_sided'] - ,sprintf("Code %s ",$row['qs_vat_code'])); - $ix++; - } - } - } - $this->assertEquals($nb_array, $ix, 'Not all VAT CODE found'); + + } }