';
- echo h2(_("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer"),' class="notice"');
+ echo span(_("Vous devez encore confirmer"),' class="notice"');
echo '
';
echo '';
@@ -152,7 +150,7 @@ show_tabs(a_tab,'facturation_div_id');
$Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
try
{
- $Ledger->verify($_POST);
+ $Ledger->verify_operation($_POST);
}
catch (Exception $e)
{
@@ -272,7 +270,7 @@ echo $op->form_get('do.php?'.$url);
echo '
';
*/
echo '';
-echo '
'.$p_msg.'
';
+echo '
'.$p_msg.'';
try
{
$payment=$http->request("e_mp","string", 0);
@@ -316,7 +314,7 @@ try
else
{
echo HtmlInput::hidden("ledger_type", "VEN");
- echo HtmlInput::hidden("ac", $_REQUEST['ac']);
+ echo HtmlInput::hidden("ac", $strac);
echo HtmlInput::hidden("sa", "p");
echo $Ledger->input($array);
diff --git a/include/database/jrn_def_sql.class.php b/include/database/jrn_def_sql.class.php
index 4f7afc406..413e4d267 100644
--- a/include/database/jrn_def_sql.class.php
+++ b/include/database/jrn_def_sql.class.php
@@ -1,5 +1,7 @@
column_name,"email"=>"column_name_email","val3"=>0); */
- protected $variable = array(
- "jrn_def_id" => "jrn_def_id",
- "jrn_def_name" => "jrn_def_name"
- , "jrn_def_class_deb" => "jrn_def_class_deb"
- , "jrn_def_class_cred" => "jrn_def_class_cred"
- , "jrn_def_fiche_deb" => "jrn_def_fiche_deb"
- , "jrn_def_fiche_cred" => "jrn_def_fiche_cred"
- , "jrn_deb_max_line" => "jrn_deb_max_line"
- , "jrn_cred_max_line" => "jrn_cred_max_line"
- , "jrn_def_ech" => "jrn_def_ech"
- , "jrn_def_ech_lib" => "jrn_def_ech_lib"
- , "jrn_def_type" => "jrn_def_type"
- , "jrn_def_code" => "jrn_def_code"
- , "jrn_def_pj_pref" => "jrn_def_pj_pref"
- , "jrn_def_bank" => "jrn_def_bank"
- , "jrn_def_num_op" => "jrn_def_num_op"
- , "jrn_def_description" => "jrn_def_description"
- );
+ function __construct(Database $p_cn, $p_id=-1)
+ {
+ $this->table="public.jrn_def";
+ $this->primary_key="jrn_def_id";
+ /*
+ * List of columns
+ */
+ $this->name=array(
+ "jrn_def_id"=>"jrn_def_id"
+ , "jrn_def_name"=>"jrn_def_name"
+ , "jrn_def_class_deb"=>"jrn_def_class_deb"
+ , "jrn_def_class_cred"=>"jrn_def_class_cred"
+ , "jrn_def_fiche_deb"=>"jrn_def_fiche_deb"
+ , "jrn_def_fiche_cred"=>"jrn_def_fiche_cred"
+ , "jrn_deb_max_line"=>"jrn_deb_max_line"
+ , "jrn_cred_max_line"=>"jrn_cred_max_line"
+ , "jrn_def_ech"=>"jrn_def_ech"
+ , "jrn_def_ech_lib"=>"jrn_def_ech_lib"
+ , "jrn_def_type"=>"jrn_def_type"
+ , "jrn_def_code"=>"jrn_def_code"
+ , "jrn_def_pj_pref"=>"jrn_def_pj_pref"
+ , "jrn_def_bank"=>"jrn_def_bank"
+ , "jrn_def_num_op"=>"jrn_def_num_op"
+ , "jrn_def_description"=>"jrn_def_description"
+ , "jrn_enable"=>"jrn_enable"
+ , "currency_id"=>"currency_id"
+ , "jrn_def_negative_amount"=>"jrn_def_negative_amount"
+ , "jrn_def_negative_warning"=>"jrn_def_negative_warning"
+ );
+ /*
+ * Type of columns
+ */
+ $this->type=array(
+ "jrn_def_id"=>"numeric"
+ , "jrn_def_name"=>"text"
+ , "jrn_def_class_deb"=>"text"
+ , "jrn_def_class_cred"=>"text"
+ , "jrn_def_fiche_deb"=>"text"
+ , "jrn_def_fiche_cred"=>"text"
+ , "jrn_deb_max_line"=>"numeric"
+ , "jrn_cred_max_line"=>"numeric"
+ , "jrn_def_ech"=>"boolean"
+ , "jrn_def_ech_lib"=>"text"
+ , "jrn_def_type"=>"text"
+ , "jrn_def_code"=>"text"
+ , "jrn_def_pj_pref"=>"text"
+ , "jrn_def_bank"=>"numeric"
+ , "jrn_def_num_op"=>"numeric"
+ , "jrn_def_description"=>"text"
+ , "jrn_enable"=>"numeric"
+ , "currency_id"=>"numeric"
+ , "jrn_def_negative_amount"=>"text"
+ ,"jrn_def_negative_warning"=>"text"
+ );
- function __construct(& $p_cn, $p_id=-1)
- {
- $this->db = $p_cn;
- $this->jrn_def_id = $p_id;
- if ($p_id == -1)
- {
- /* Initialize an empty object */
- foreach ($this->variable as $key => $value)
- $this->$value = null;
- $this->jrn_def_id = $p_id;
- }
- else
- {
- /* load it */
+ $this->default=array(
+ "jrn_def_id"=>"auto"
+ );
- $this->load();
- }
- }
-
- public function get_parameter($p_string)
- {
- if (array_key_exists($p_string, $this->variable))
- {
- $idx = $this->variable[$p_string];
- return $this->$idx;
- }
- else
- throw new Exception(__FILE__ . ":" . __LINE__ . $p_string . 'Erreur attribut inexistant');
- }
-
- public function set_parameter($p_string, $p_value)
- {
- if (array_key_exists($p_string, $this->variable))
- {
- $idx = $this->variable[$p_string];
- $this->$idx = $p_value;
- }
- else
- throw new Exception(__FILE__ . ":" . __LINE__ . $p_string . 'Erreur attribut inexistant');
- }
-
- public function get_info()
- {
- return var_export($this, true);
- }
-
- public function verify_sql()
- {
- // Verify that the elt we want to add is correct
- /* verify only the datatype */
- if (trim($this->jrn_def_name) == '')
- $this->jrn_def_name = null;
- if (trim($this->jrn_def_class_deb) == '')
- $this->jrn_def_class_deb = null;
- if (trim($this->jrn_def_class_cred) == '')
- $this->jrn_def_class_cred = null;
- if (trim($this->jrn_def_fiche_deb) == '')
- $this->jrn_def_fiche_deb = null;
- if (trim($this->jrn_def_fiche_cred) == '')
- $this->jrn_def_fiche_cred = null;
- if (trim($this->jrn_deb_max_line) == '')
- $this->jrn_deb_max_line = null;
- if ($this->jrn_deb_max_line !== null && settype($this->jrn_deb_max_line, 'float') == false)
- throw new Exception('DATATYPE jrn_deb_max_line $this->jrn_deb_max_line non numerique');
- if (trim($this->jrn_cred_max_line) == '')
- $this->jrn_cred_max_line = null;
- if ($this->jrn_cred_max_line !== null && settype($this->jrn_cred_max_line, 'float') == false)
- throw new Exception('DATATYPE jrn_cred_max_line $this->jrn_cred_max_line non numerique');
- if (trim($this->jrn_def_ech) == '')
- $this->jrn_def_ech = null;
- if (trim($this->jrn_def_ech_lib) == '')
- $this->jrn_def_ech_lib = null;
- if (trim($this->jrn_def_type) == '')
- $this->jrn_def_type = null;
- if (trim($this->jrn_def_code) == '')
- $this->jrn_def_code = null;
- if (trim($this->jrn_def_pj_pref) == '')
- $this->jrn_def_pj_pref = null;
- if (trim($this->jrn_def_bank) == '')
- $this->jrn_def_bank = null;
- if ($this->jrn_def_bank !== null && settype($this->jrn_def_bank, 'float') == false)
- throw new Exception('DATATYPE jrn_def_bank $this->jrn_def_bank non numerique');
- if (trim($this->jrn_def_num_op) == '')
- $this->jrn_def_num_op = null;
- if ($this->jrn_def_num_op !== null && settype($this->jrn_def_num_op, 'float') == false)
- throw new Exception('DATATYPE jrn_def_num_op $this->jrn_def_num_op non numerique');
- }
-
- public function save($p_string='')
- {
- /* please adapt */
- if ($this->jrn_def_id == -1)
- $this->insert();
- else
- $this->update();
- }
-
- /**
- * @brief retrieve array of object thanks a condition
- * @param $cond condition (where clause) (optional by default all the rows are fetched)
- * you can use this parameter for the order or subselect
- * @param $p_array array for the SQL stmt
- * @see Database::exec_sql get_object Database::num_row
- * @return the return value of exec_sql
- */
- public function seek($cond='', $p_array=null)
- {
- $sql = "select * from public.jrn_def $cond";
- $aobj = array();
- $ret = $this->db->exec_sql($sql, $p_array);
- return $ret;
- }
-
- /**
- * get_seek return the next object, the return of the query must have all the column
- * of the object
- * @param $p_ret is the return value of an exec_sql
- * @param $idx is the index
- * @see seek
- * @return object
- */
- public function get_object($p_ret, $idx)
- {
- // map each row in a object
- $oobj = new Jrn_Def_sql($this->db);
- $array = Database::fetch_array($p_ret, $idx);
- foreach ($array as $idx => $value)
- {
- $oobj->$idx = $value;
- }
- return $oobj;
- }
-
- public function insert($p_array=null)
- {
- if ($this->verify_sql() != 0)
- return;
- if ($this->jrn_def_id == -1)
- {
- /* please adapt */
- $sql = "insert into public.jrn_def(jrn_def_name
-,jrn_def_class_deb
-,jrn_def_class_cred
-,jrn_def_fiche_deb
-,jrn_def_fiche_cred
-,jrn_deb_max_line
-,jrn_cred_max_line
-,jrn_def_ech
-,jrn_def_ech_lib
-,jrn_def_type
-,jrn_def_code
-,jrn_def_pj_pref
-,jrn_def_bank
-,jrn_def_num_op
-,jrn_def_description
-) values ($1
-,$2
-,$3
-,$4
-,$5
-,$6
-,$7
-,$8
-,$9
-,$10
-,$11
-,$12
-,$13
-,$14
-,$15
-) returning jrn_def_id";
-
- $this->jrn_def_id = $this->db->get_value(
- $sql, array($this->jrn_def_name
- , $this->jrn_def_class_deb
- , $this->jrn_def_class_cred
- , $this->jrn_def_fiche_deb
- , $this->jrn_def_fiche_cred
- , $this->jrn_deb_max_line
- , $this->jrn_cred_max_line
- , $this->jrn_def_ech
- , $this->jrn_def_ech_lib
- , $this->jrn_def_type
- , $this->jrn_def_code
- , $this->jrn_def_pj_pref
- , $this->jrn_def_bank
- , $this->jrn_def_num_op
- , strip_tags($this->jrn_def_description)
- )
- );
- }
- else
- {
- $sql = "insert into public.jrn_def(jrn_def_name
-,jrn_def_class_deb
-,jrn_def_class_cred
-,jrn_def_fiche_deb
-,jrn_def_fiche_cred
-,jrn_deb_max_line
-,jrn_cred_max_line
-,jrn_def_ech
-,jrn_def_ech_lib
-,jrn_def_type
-,jrn_def_code
-,jrn_def_pj_pref
-,jrn_def_bank
-,jrn_def_num_op
-,jrn_def_id
-,jrn_def_description,
-jrn_enable) values ($1
-,$2
-,$3
-,$4
-,$5
-,$6
-,$7
-,$8
-,$9
-,$10
-,$11
-,$12
-,$13
-,$14
-,$15
-,$16
-,1
-) returning jrn_def_id";
-
- $this->jrn_def_id = $this->db->get_value(
- $sql, array($this->jrn_def_name
- , $this->jrn_def_class_deb
- , $this->jrn_def_class_cred
- , $this->jrn_def_fiche_deb
- , $this->jrn_def_fiche_cred
- , $this->jrn_deb_max_line
- , $this->jrn_cred_max_line
- , $this->jrn_def_ech
- , $this->jrn_def_ech_lib
- , $this->jrn_def_type
- , $this->jrn_def_code
- , $this->jrn_def_pj_pref
- , $this->jrn_def_bank
- , $this->jrn_def_num_op
- , $this->jrn_def_id
- , strip_tags($this->jrn_def_description))
- );
- }
- }
-
- public function update($p_string='')
- {
- if ($this->verify_sql() != 0)
- return;
- /* please adapt */
- $sql = " update public.jrn_def set jrn_def_name = $1
-,jrn_def_class_deb = $2
-,jrn_def_class_cred = $3
-,jrn_def_fiche_deb = $4
-,jrn_def_fiche_cred = $5
-,jrn_deb_max_line = $6
-,jrn_cred_max_line = $7
-,jrn_def_ech = $8
-,jrn_def_ech_lib = $9
-,jrn_def_type = $10
-,jrn_def_code = $11
-,jrn_def_pj_pref = $12
-,jrn_def_bank = $13
-,jrn_def_num_op = $14
-,jrn_def_description = $15
-,jrn_enable=$17
- where jrn_def_id= $16";
- $res = $this->db->exec_sql(
- $sql, array($this->jrn_def_name
- , $this->jrn_def_class_deb
- , $this->jrn_def_class_cred
- , $this->jrn_def_fiche_deb
- , $this->jrn_def_fiche_cred
- , $this->jrn_deb_max_line
- , $this->jrn_cred_max_line
- , $this->jrn_def_ech
- , $this->jrn_def_ech_lib
- , $this->jrn_def_type
- , $this->jrn_def_code
- , $this->jrn_def_pj_pref
- , $this->jrn_def_bank
- , $this->jrn_def_num_op
- , strip_tags($this->jrn_def_description)
- , $this->jrn_def_id
- , $this->jrn_enable
- )
- );
- }
-
- /**
- * @brief load a object
- * @return 0 on success -1 the object is not found
- */
- public function load()
- {
-
- $sql = "select jrn_def_name
-,jrn_def_class_deb
-,jrn_def_class_cred
-,jrn_def_fiche_deb
-,jrn_def_fiche_cred
-,jrn_deb_max_line
-,jrn_cred_max_line
-,jrn_def_ech
-,jrn_def_ech_lib
-,jrn_def_type
-,jrn_def_code
-,jrn_def_pj_pref
-,jrn_def_bank
-,jrn_def_num_op
-,jrn_def_description
-,jrn_enable
- from public.jrn_def where jrn_def_id=$1";
- /* please adapt */
- $res = $this->db->get_array(
- $sql, array($this->jrn_def_id)
- );
-
- if (count($res) == 0)
- {
- /* Initialize an empty object */
- foreach ($this->variable as $key => $value)
- $this->$key = '';
-
- return -1;
- }
- foreach ($res[0] as $idx => $value)
- {
- $this->$idx = $value;
- }
- return 0;
- }
-
- public function delete()
- {
- $sql = "delete from public.jrn_def where jrn_def_id=$1";
- $res = $this->db->exec_sql($sql, array($this->jrn_def_id));
- }
-
- /**
- * Unit test for the class
- */
- static function test_me()
- {
- }
+ $this->date_format="DD.MM.YYYY";
+ parent::__construct($p_cn, $p_id);
+ }
}
-
-// Jrn_Def_sql::test_me();
-?>
diff --git a/include/export/export_printtva_csv.php b/include/export/export_printtva_csv.php
new file mode 100644
index 000000000..c84ffe267
--- /dev/null
+++ b/include/export/export_printtva_csv.php
@@ -0,0 +1,83 @@
+get("date_start"),$http->get("date_end"));
+$tax_summary->check();
+
+$csv=new Noalyss_Csv("summary_tva");
+$csv->send_header();
+// Sale
+$csv->write_header([
+ _("Journal"),
+ ("Code TVA"),
+ _("Taux"),
+ _("Montant HT"),
+ _("Montant TVA"),
+ _("Montant Autoliquidation")]);
+$array=$tax_summary->get_row_sale();
+$nb_array=count($array);
+for ($i=0;$i < $nb_array;$i++) {
+ $csv->add ($array[$i]['jrn_def_name']);
+ $csv->add ($array[$i]['tva_label']);
+ $csv->add ($array[$i]['tva_rate'],'number');
+ $csv->add ($array[$i]['amount_wovat'],'number');
+ $csv->add ($array[$i]['amount_vat'],'number');
+ $csv->add ($array[$i]['amount_sided'],'number');
+ $csv->write();
+}
+//Purchase
+$csv->write_header([
+ _("Journal"),
+ ("Code TVA"),
+ _("Taux"),
+ _("Montant HT"),
+ _("Privée"),
+ _("Montant TVA"),
+ _("Montant Autoliquidation"),
+ _("Montant ND"),
+ _("TVA Non Déd"),
+ _("TVA Non Déd & récup")
+ ]);
+$array=$tax_summary->get_row_purchase();
+$nb_array=count($array);
+for ($i=0;$i < $nb_array;$i++) {
+ $csv->add ($array[$i]['jrn_def_name']);
+ $csv->add ($array[$i]['tva_label']);
+ $csv->add ($array[$i]['tva_rate'],'number');
+ $csv->add ($array[$i]['amount_wovat'],'number');
+ $csv->add ($array[$i]['amount_private'],'number');
+ $csv->add ($array[$i]['amount_vat'],'number');
+ $csv->add ($array[$i]['amount_sided'],'number');
+ $csv->add ($array[$i]['amount_noded_amount'],'number');
+ $csv->add ($array[$i]['amount_noded_tax'],'number');
+ $csv->add ($array[$i]['amount_noded_return'],'number');
+ $csv->write();
+}
diff --git a/include/export/export_printtva_pdf.php b/include/export/export_printtva_pdf.php
new file mode 100644
index 000000000..ab337ea0a
--- /dev/null
+++ b/include/export/export_printtva_pdf.php
@@ -0,0 +1,353 @@
+request("date_start");
+$to_periode = $http->request("date_end");
+
+
+$gDossier = dossier::id();
+
+/* Security */
+$cn = Dossier::connect();
+$tax_summary = new Tax_Summary($cn, $from_periode, $to_periode);
+$pdf = new PDFLand($cn);
+$pdf->setDossierInfo(sprintf(_("Date") . " : %s %s", $from_periode, $to_periode));
+$pdf->AliasNbPages();
+$pdf->AddPage();
+$pdf->SetAuthor('NOALYSS');
+$pdf->setTitle(_("Résumé TVA"), true);
+
+
+
+
+//-------------------------------------------------------------------------
+// Sales
+//-------------------------------------------------------------------------
+$a_sale_header = [_("Code TVA"), _("Taux"), _("Montant HT"), _("Montant TVA"),
+ _("Montant Autoliquidation")];
+$nb_sale = count($a_sale_header);
+$array = $tax_summary->get_row_sale();
+// Table header
+$nb_array = count($array);
+$tot_vat = 0;
+$tot_wovat = 0;
+$tot_sided = 0;
+$ledger_name = "";
+//-------------------------------------------------------------------------
+// For each sale ledger
+//-------------------------------------------------------------------------
+// Table with total
+$a_col=['tva_label','tva_rate','amount_wovat','amount_vat','amount_sided'];
+$nb_col=count($a_col);
+$a_tot=[];
+// initialize totals
+for ($e=2;$e<$nb_col;$e++){
+ $a_tot[$a_col[$e]]=0;
+}
+
+for ($i = 0; $i < $nb_array; $i++) {
+ for ($e=2;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ $a_tot[$colname]=bcadd($a_tot[$colname],$array[$i][$colname]);
+ }
+
+ if ($i == 0) {
+ // Display ledger name
+
+ $ledger_name = $array[$i]['jrn_def_name'];
+ $pdf->SetFont('DejaVuCond', 'B', 10);
+ $pdf->write_cell(50, 8, $ledger_name);
+ $pdf->line_new();
+
+ // Display Header
+ $pdf->SetFont('DejaVuCond', 'B', 7);
+ for ($e=0;$e<$nb_col;$e++){
+ if ( $e == 0 ) {
+ $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'L');
+ } else {
+ $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'R');
+ }
+ $a_tot[$colname]=0;
+ }
+ $pdf->line_new();
+ $pdf->SetFont('DejaVuCond', '', 7);
+ }
+ if ($ledger_name != $array[$i]['jrn_def_name']) {
+ // Display totals
+ $pdf->SetFont('DejaVuCond', 'B', 7);
+ $pdf->line_new();
+ $pdf->write_cell(70, 5, "");
+ for ($e=2;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 0, 0, 'R');
+ $a_tot[$colname]=0;
+ }
+ $pdf->line_new();
+ $pdf->SetFont('DejaVuCond', 'B', 7);
+
+ // Display ledger name
+ $ledger_name = $array[$i]['jrn_def_name'];
+ $pdf->SetFont('DejaVuCond', 'B', 10);
+ $pdf->write_cell(50, 8, $ledger_name);
+ $pdf->line_new();
+
+ // Display Header
+ for ($e=0;$e<$nb_col;$e++){
+ if ( $e == 0 ) {
+ $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'L');
+ } else {
+ $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'R');
+ }
+ $a_tot[$colname]=0;
+ }
+ }
+ for ($e=0;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ if ( $e ==0 ) {
+ $pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
+ } elseif ($e == 1 ){
+ $pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
+ }else {
+ $pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
+ }
+ }
+ $pdf->line_new();
+}
+$pdf->SetFont('DejaVuCond', 'B', 7);
+$pdf->write_cell(80, 5, "");
+for ($e=2;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
+}
+
+//-------------------------------------------------------------------------
+// Summary sales
+//-------------------------------------------------------------------------
+$a_sum = $tax_summary->get_summary_sale();
+$pdf->line_new();
+$pdf->SetFont('DejaVuCond', 'B', 10);
+$pdf->write_cell(50, 8, _("Résumé TVA vente"));
+$pdf->line_new();
+
+$pdf->SetFont('DejaVuCond', 'B', 7);
+for ($i = 0; $i < $nb_sale; $i++) {
+ if ($i > 0 ) {
+ $pdf->write_cell(40, 5, $a_sale_header[$i], 1, 0, 'R');
+ } else {
+ $pdf->write_cell(40, 5, $a_sale_header[$i], 1, 0, 'L');
+ }
+}
+$pdf->line_new();
+
+$nb_array = count($array);
+// initialize totals
+for ($e=2;$e<$nb_col;$e++){
+ $a_tot[$a_col[$e]]=0;
+}
+$pdf->SetFont('DejaVuCond', '', 7);
+
+for ($i = 0; $i < $nb_array; $i++) {
+ // display each row
+ for ($e=0;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ if ( $e ==0 ) {
+ // first column TVA_LABEL
+ $pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
+ } elseif ($e == 1 ){
+ // Secund col. tva rate
+ $pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
+ }else {
+ // Other cols,display amount and compute total
+ $a_tot[$colname] = bcadd($a_tot[$colname], $array[$i][$colname]);
+ $pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
+ }
+ }
+ $pdf->line_new();
+}
+$pdf->SetFont('DejaVuCond', 'B', 7);
+$pdf->write_cell(80, 5, "");
+for ($e=2;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
+}
+$pdf->line_new();
+
+//------------------------------------------------------------------------------------------
+// Purchase
+//------------------------------------------------------------------------------------------
+$array = $tax_summary->get_row_purchase();
+$a_colp=['tva_label','tva_rate','amount_wovat','amount_private','amount_vat','amount_sided',
+ 'amount_noded_amount','amount_noded_tax','amount_noded_return'];
+$a_purchase_header = [_("Code TVA"), _("Taux"), _("Montant HT"), _("Privée"), _("Montant TVA"),
+ _("Montant Autoliquidation"), _("Montant Non Déd"), _("TVA Non Déd"), _("TVA Non Déd & récup")];
+$nb_purchase = count($a_purchase_header);
+
+for ($e=2;$e<$nb_col;$e++){
+ $a_tot[$a_col[$e]]=0;
+}
+
+for ($i = 0; $i < $nb_array; $i++) {
+ for ($e=2;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ $a_tot[$colname]=bcadd($a_tot[$colname],$array[$i][$colname]);
+ }
+
+ if ($i == 0) {
+ // Display ledger name
+
+ $ledger_name = $array[$i]['jrn_def_name'];
+ $pdf->SetFont('DejaVuCond', 'B', 10);
+ $pdf->write_cell(50, 8, $ledger_name);
+ $pdf->line_new();
+
+ // Display Header
+ $pdf->SetFont('DejaVuCond', 'B', 7);
+ for ($e=0;$e<$nb_col;$e++){
+ if ( $e == 0 ) {
+ $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
+ } else {
+ $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
+ }
+ $a_tot[$colname]=0;
+ }
+ $pdf->line_new();
+ $pdf->SetFont('DejaVuCond', '', 7);
+ }
+ if ($ledger_name != $array[$i]['jrn_def_name']) {
+ // Display totals
+ $pdf->SetFont('DejaVuCond', 'B', 7);
+ $pdf->line_new();
+ $pdf->write_cell(70, 5, "");
+ for ($e=2;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 0, 0, 'R');
+ $a_tot[$colname]=0;
+ }
+ $pdf->line_new();
+ $pdf->SetFont('DejaVuCond', 'B', 7);
+
+ // Display ledger name
+ $ledger_name = $array[$i]['jrn_def_name'];
+ $pdf->SetFont('DejaVuCond', 'B', 10);
+ $pdf->write_cell(50, 8, $ledger_name);
+ $pdf->line_new();
+
+ // Display Header
+ for ($e=0;$e<$nb_col;$e++){
+ if ( $e == 0 ) {
+ $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
+ } else {
+ $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
+ }
+ $a_tot[$colname]=0;
+ }
+ }
+ for ($e=0;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ if ( $e ==0 ) {
+ $pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
+ } elseif ($e == 1 ){
+ $pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
+ }else {
+ $pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
+ }
+ }
+ $pdf->line_new();
+}
+$pdf->SetFont('DejaVuCond', 'B', 7);
+$pdf->write_cell(80, 5, "");
+for ($e=2;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
+}
+
+//-------------------------------------------------------------------------
+// Summary sales
+//-------------------------------------------------------------------------
+$a_sum = $tax_summary->get_summary_sale();
+$pdf->line_new();
+$pdf->SetFont('DejaVuCond', 'B', 10);
+$pdf->write_cell(50, 8, _("Résumé TVA Achat"));
+$pdf->line_new();
+
+$pdf->SetFont('DejaVuCond', 'B', 7);
+for ($e=0;$e<$nb_col;$e++){
+ if ( $e == 0 ) {
+ $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
+ } else {
+ $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
+ }
+ $a_tot[$colname]=0;
+}
+$pdf->line_new();
+
+$nb_array = count($array);
+// initialize totals
+for ($e=2;$e<$nb_col;$e++){
+ $a_tot[$a_col[$e]]=0;
+}
+$pdf->SetFont('DejaVuCond', '', 7);
+
+for ($i = 0; $i < $nb_array; $i++) {
+ // display each row
+ for ($e=0;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ if ( $e ==0 ) {
+ // first column TVA_LABEL
+ $pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
+ } elseif ($e == 1 ){
+ // Secund col. tva rate
+ $pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
+ }else {
+ // Other cols,display amount and compute total
+ $a_tot[$colname] = bcadd($a_tot[$colname], $array[$i][$colname]);
+ $pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
+ }
+ }
+ $pdf->line_new();
+}
+$pdf->SetFont('DejaVuCond', 'B', 7);
+$pdf->write_cell(80, 5, "");
+for ($e=2;$e<$nb_col;$e++){
+ $colname=$a_col[$e];
+ $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
+}
+$pdf->line_new();
+
+
+//---------------------------------- Output --------------------------------------------------
+
+$fDate = date('Ymd-Hi');
+
+$pdf->Output('tva-' . $fDate . '.pdf', 'D');
\ No newline at end of file
diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php
index 03c3f3fb0..9333a2dd2 100644
--- a/include/lib/message_javascript.php
+++ b/include/lib/message_javascript.php
@@ -103,5 +103,5 @@ content[69]="";
content[70]="";
content[71]="";
content[72]="";
-
+content[73]="";
\ No newline at end of file
diff --git a/include/operation_ods_new.inc.php b/include/operation_ods_new.inc.php
index f3dcacdc7..9396314ad 100644
--- a/include/operation_ods_new.inc.php
+++ b/include/operation_ods_new.inc.php
@@ -63,7 +63,7 @@ if ( isset ($_GET['action']) && ! isset($_POST['correct']) && ! isset($correct)
$p_post=null;
if ( isset($_REQUEST['pre_def']) && $_REQUEST['pre_def'] != '')
{
- $op->set_od_id($_REQUEST['pre_def']);
+ $op->set_od_id($http->request('pre_def','number'));
$p_post=$op->compute_array();
}
}
diff --git a/include/tax_summary.inc.php b/include/tax_summary.inc.php
new file mode 100644
index 000000000..650ddbe0c
--- /dev/null
+++ b/include/tax_summary.inc.php
@@ -0,0 +1,72 @@
+get_limit_current_exercice();
+
+$start = $http->request("start_date", "date", $limit[0]);
+$end = $http->request("end_date", "date", $limit[1]);
+
+$start_periode = new IDate("start_date", $start);
+$end_periode = new IDate("end_date", $end);
+echo '
';
+echo '
';
+if ( $http->get("do","string","no") == "display")
+{
+ $tax_summary=new Tax_Summary($cn,$start_periode->value,$end_periode->value);
+ try {
+ $tax_summary->check();
+ echo '
';
+ echo '- ';
+ echo $tax_summary->form_export_csv();
+ echo '
';
+ echo '- ';
+ echo $tax_summary->form_export_pdf();
+ echo '
';
+ echo '
';
+ $tax_summary->display();
+ echo '
';
+ echo '- ';
+ echo $tax_summary->form_export_csv();
+ echo '
';
+ echo '- ';
+ echo $tax_summary->form_export_pdf();
+ echo '
';
+ echo '
';
+
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ }
+}
diff --git a/include/template/param_jrn.php b/include/template/param_jrn.php
index 4e9e5058b..b5af8cec9 100644
--- a/include/template/param_jrn.php
+++ b/include/template/param_jrn.php
@@ -16,10 +16,13 @@
|
-|
+ |
|
@@ -33,46 +36,87 @@ if ( $new || $type=='ODS' ):
endif;
?>
- |
-|
-
- |
-
- input();?>
- |
-
-
-|
-
- |
-
-name='bank';
-$card->extra=$cn->make_list('select fd_id from fiche_def where frd_id=4');
-$card->set_dblclick("fill_ipopcard(this);");
-$card->set_function('fill_data');
-$card->set_attribute('ipopup','ipop_card');
-$list=$cn->make_list('select fd_id from fiche_def where frd_id=4');
-$card->set_attribute('typecard',$list);
+ |
+ |
+
+ |
+
+ input();?>
+ |
+
+
+ |
+
+ |
+
+ name='bank';
+ $card->extra=$cn->make_list('select fd_id from fiche_def where frd_id=4');
+ $card->set_dblclick("fill_ipopcard(this);");
+ $card->set_function('fill_data');
+ $card->set_attribute('ipopup','ipop_card');
+ $list=$cn->make_list('select fd_id from fiche_def where frd_id=4');
+ $card->set_attribute('typecard',$list);
-$card->value=$qcode_bank;
-echo $card->search();
-echo $card->input();
-echo $str_add_button;
+ $card->value=$qcode_bank;
+ echo $card->search();
+ echo $card->input();
+ echo $str_add_button;
+ ?>
+ |
+
+
+ |
+
+
-
-
-
- |
+
+
+
+ |
+
+
+ |
+
+ javascript="toggle_row_warning_enable('negative_amount','row_warning')";
+ $negative->input();
+ ?>
+ |
+
+
+ |
+
+ |
+
+ input();?>
+ |
+
+
-
+
+
+
- |
+ |
input()?> |
@@ -103,32 +147,33 @@ echo $str_add_button;
-
-|
-
-
- |
-
-
- |
-
+
+ |
+
+
+ |
+
+
+ |
+
-
-|
-
- |
-
-
-
- |
-
-
- |
- =_("Journal actif")?>
- |
-
- =$actif->input()?>
- |
+
+ |
+
+ |
+
+
+
+ |
+
+
+ |
+ =_("Journal actif")?>
+ |
+
+ =$actif->input()?>
+ |
+
@@ -365,6 +410,8 @@ echo $str_add_button;
$('type_ods').style.display='none';
$('type_fin').style.display='none';
$('type_fin2').style.display='none';
+ $('neg_amount').style.display='none';
+ $('row_warning').style.display='none';
}
function show_ledger_div()
{
@@ -381,6 +428,19 @@ echo $str_add_button;
hide_row();
$('type_ods').style.display='table-row';
break;
+ case 'ACH':
+ hide_row();
+ $('neg_amount').style.display='table-row';
+ toggle_row_warning_enable('negative_amount','row_warning');
+
+ break;
+ case 'VEN':
+ hide_row();
+ $('neg_amount').style.display='table-row';
+ toggle_row_warning_enable('negative_amount','row_warning');
+
+ break;
+
default:
hide_row();
}
@@ -396,3 +456,10 @@ echo $str_add_button;
?>
+
+
+
\ No newline at end of file
diff --git a/include/template/tax_summary_display.php b/include/template/tax_summary_display.php
new file mode 100644
index 000000000..84bb1b530
--- /dev/null
+++ b/include/template/tax_summary_display.php
@@ -0,0 +1,375 @@
+
+
+
+get_row_sale();
+$nb_array=count($array);
+$ledger="";
+$r=0;
+$tot_vat=0;$tot_wovat=0;$tot_sided=0;
+
+for ($i=0;$i < $nb_array;$i++):
+
+ if ( $ledger != $array[$i]['jrn_def_name']):
+ if ( $ledger != "") :
+ // last row with total
+ echo '
';
+ echo td();
+ echo td();
+ echo td(nbm($tot_wovat),' class="num" ');
+ echo td(nbm($tot_vat),' class="num" ');
+ echo td(nbm($tot_sided),' class="num" ');
+ echo '
';
+ echo '';
+ endif;
+ $ledger=$array[$i]['jrn_def_name'];
+ //reinitialize sum
+ $tot_vat=0;$tot_wovat=0;$tot_sided=0;
+
+ printf("
%s
",$ledger);
+ echo '
';
+ echo '';
+ echo th(_("Code TVA"));
+ echo th(_("Taux"),'class="num"');
+ echo th(_("Montant HT"),'class="num"');
+ echo th(_("Montant TVA"),'class="num"');
+ echo th(_("Montant Autoliquidation"),'class="num"');
+ echo '
';
+ $r=0;
+ endif;
+ $color=($r%2==0)?"even":"odd";
+?>
+
+ |
+ =$array[$i]['tva_label']?>
+ |
+
+ =$array[$i]['tva_rate']*100?>%
+ |
+
+ =nbm($array[$i]['amount_wovat'])?>
+ |
+
+ =nbm($array[$i]['amount_vat'])?>
+ |
+
+ =nbm($array[$i]['amount_sided'])?>
+ |
+
+
+
+ 0):
+// last row with total
+ echo '';
+ echo td();
+ echo td();
+ echo td(nbm($tot_wovat),' class="num" ');
+ echo td(nbm($tot_vat),' class="num" ');
+ echo td(nbm($tot_sided),' class="num" ');
+ echo '
';
+else:
+ echo _("Aucune donnée");
+endif;
+ echo '
';
+?>
+
=_("Résumé tous les journaux de vente")?>
+get_summary_sale();
+?>
+
+
+ |
+ =_("Code TVA")?>
+ |
+
+ =_("Taux")?>
+ |
+
+ =_("Montant HT")?>
+ |
+
+ =_("Montant TVA")?>
+ |
+
+ =_("Montant Autoliquidation")?>
+ |
+
+
+
+
+ |
+ =$a_sum[$e]['tva_label']?>
+ |
+
+ =$a_sum[$e]['tva_rate']*100?>%
+ |
+
+ =nbm($a_sum[$e]['amount_wovat'])?>
+ |
+
+ =nbm($a_sum[$e]['amount_vat'])?>
+ |
+
+ =nbm($a_sum[$e]['amount_sided'])?>
+ |
+
+';
+ echo td();
+ echo td();
+ echo td(nbm($tot_wovat),' class="num" ');
+ echo td(nbm($tot_vat),' class="num" ');
+ echo td(nbm($tot_sided),' class="num" ');
+ echo '';
+ ?>
+
+get_summary_sale();
+
+
+?>
+
+get_row_purchase();
+$nb_array=count($array);
+$ledger="";
+$r=0;
+$tot_vat=0;$tot_wovat=0;$tot_sided=0;$tot_noded_amount=0;$tot_noded_tax=0;$tot_noded_return=0;$tot_private=0;
+for ($i=0;$i < $nb_array;$i++):
+
+ if ( $ledger != $array[$i]['jrn_def_name']):
+ if ( $ledger != "") :
+ // last row with total
+ echo '
';
+ echo td();
+ echo td();
+ echo td(nbm($tot_wovat),' class="num" ');
+ echo td(nbm($tot_private),' class="num" ');
+ echo td(nbm($tot_vat),' class="num" ');
+ echo td(nbm($tot_sided),' class="num" ');
+ echo td(nbm($tot_noded_amount),' class="num" ');
+ echo td(nbm($tot_noded_tax),' class="num" ');
+ echo td(nbm($tot_noded_return),' class="num" ');
+ echo '
';
+ echo '';
+ endif;
+ $ledger=$array[$i]['jrn_def_name'];
+ //reinitialize sum
+ $tot_vat=0;$tot_wovat=0;$tot_sided=0;$tot_noded_amount=0;$tot_noded_tax=0;$tot_noded_return=0;$tot_private=0;
+
+ printf("
%s
",$ledger);
+ echo '
';
+ echo '';
+ echo th(_("Code TVA"));
+ echo th(_("Taux"),'class="num"');
+ echo th(_("Montant HT"),'class="num"');
+ echo th(_("Privée"),'class="num"');
+ echo th(_("Montant TVA"),'class="num"');
+ echo th(_("Montant Autoliquidation"),'class="num"');
+ echo th(_("Montant Non Déd"),'class="num"');
+ echo th(_("TVA Non Déd"),'class="num"');
+ echo th(_("TVA Non Déd & récup"),'class="num"');
+ echo '
';
+ $r=0;
+ endif;
+ $color=($r%2==0)?"even":"odd";
+ ?>
+
+ |
+ =$array[$i]['tva_label']?>
+ |
+
+ =$array[$i]['tva_rate']*100?>%
+ |
+
+ =nbm($array[$i]['amount_wovat'])?>
+ |
+
+ =nbm($array[$i]['amount_private'])?>
+ |
+
+ =nbm($array[$i]['amount_vat'])?>
+ |
+
+ =nbm($array[$i]['amount_sided'])?>
+ |
+
+ =nbm($array[$i]['amount_noded_amount'])?>
+ |
+
+ =nbm($array[$i]['amount_noded_tax'])?>
+ |
+
+ =nbm($array[$i]['amount_noded_return'])?>
+ |
+
+
+
+ 0):
+ echo '';
+ echo td();
+ echo td();
+ echo td(nbm($tot_wovat),' class="num" ');
+ echo td(nbm($tot_private),' class="num" ');
+ echo td(nbm($tot_vat),' class="num" ');
+ echo td(nbm($tot_sided),' class="num" ');
+ echo td(nbm($tot_noded_amount),' class="num" ');
+ echo td(nbm($tot_noded_tax),' class="num" ');
+ echo td(nbm($tot_noded_return),' class="num" ');
+ echo '
';
+else:
+ echo _("Aucune donnée");
+endif;
+echo '
';
+?>
+
=_("Résumé tous les journaux d'achat")?>
+get_summary_purchase();
+?>
+
+
+ |
+ =_("Code TVA")?>
+ |
+
+ =_("Taux")?>
+ |
+
+ =_("Montant HT")?>
+ |
+
+ =_("Privée")?>
+ |
+
+ =_("Montant TVA")?>
+ |
+
+ =_("Montant Autoliquidation")?>
+ |
+
+ =_("Montant Non Déd")?>
+ |
+
+ =_("TVA Non Déd")?>
+ |
+
+ =_("TVA Non Déd & récup")?>
+ |
+
+
+
+
+ |
+ =$a_sum[$e]['tva_label']?>
+ |
+
+ =$a_sum[$e]['tva_rate']*100?>%
+ |
+
+ =nbm($a_sum[$e]['amount_wovat'])?>
+ |
+
+ =nbm($a_sum[$e]['amount_private'])?>
+ |
+
+ =nbm($a_sum[$e]['amount_vat'])?>
+ |
+
+ =nbm($a_sum[$e]['amount_sided'])?>
+ |
+
+ =nbm($a_sum[$e]['amount_noded_amount'])?>
+ |
+
+ =nbm($a_sum[$e]['amount_noded_tax'])?>
+ |
+
+ =nbm($a_sum[$e]['amount_noded_return'])?>
+ |
+
+ ';
+ echo td();
+ echo td();
+ echo td(nbm($tot_wovat),' class="num" ');
+ echo td(nbm($tot_private),' class="num" ');
+ echo td(nbm($tot_vat),' class="num" ');
+ echo td(nbm($tot_sided),' class="num" ');
+ echo td(nbm($tot_noded_amount),' class="num" ');
+ echo td(nbm($tot_noded_tax),' class="num" ');
+ echo td(nbm($tot_noded_return),' class="num" ');
+ echo '';
+ ?>
+
diff --git a/unit-test/include/class/acc_balanceTest.class.php b/unit-test/include/class/acc_balanceTest.class.php
index 0799c9b48..0cb572496 100644
--- a/unit-test/include/class/acc_balanceTest.class.php
+++ b/unit-test/include/class/acc_balanceTest.class.php
@@ -18,11 +18,13 @@ class Acc_BalanceTest extends TestCase
*/
protected function setUp()
{
- global $g_connection, $g_parameter;
+ global $g_connection, $g_parameter,$g_user;
$_REQUEST['gDossier']=DOSSIER;
$g_connection=new Database(DOSSIER);
$g_parameter=new Noalyss_Parameter_Folder($g_connection);
$this->object=new Acc_Balance($g_connection);
+
+
}
/**
@@ -40,11 +42,12 @@ class Acc_BalanceTest extends TestCase
*/
public function testGet_row()
{
- $this->object->get_row(1,200);
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'DATA : cannot be tested'
- );
+ global $g_connection,$g_user;
+ $g_user=new User($g_connection,1);
+
+ $max=$g_connection->get_value("select max(p_id) from parm_periode");
+ $min=$g_connection->get_value("select min(p_id) from parm_periode");
+ $this->object->get_row($min,$max);
}
/**
diff --git a/unit-test/include/class/acc_ledgerTest.class.php b/unit-test/include/class/acc_ledgerTest.class.php
index efc81cb63..1c91653d3 100644
--- a/unit-test/include/class/acc_ledgerTest.class.php
+++ b/unit-test/include/class/acc_ledgerTest.class.php
@@ -17,6 +17,32 @@ class Acc_LedgerTest extends TestCase
$dataSet->addTable('jrn', dirname(__FILE__)."/jrn.csv");
return $dataSet;
}
+ /**
+ * Get an operation
+ * @global type $g_connection
+ * @return type
+ */
+ private function get_jrn_id($p_ledger='ODS')
+ {
+ global $g_connection;
+ $jr_id=$g_connection->get_value("select max(jr_id) from jrn join jrn_def "
+ . "on (jrn_def_id=jr_def_id) "
+ . " where "
+ . " jrn_def_type=$1",[$p_ledger]);
+ return $jr_id;
+ }
+ /**
+ * Return 1 if operation does exist otherwise zero
+ * @global type $g_connection
+ * @param type $p_jr_id
+ * @return type
+ */
+ private function exist_operation($p_jr_id)
+ {
+ global $g_connection;
+ $jr_id=$g_connection->get_value("select count(*) from jrn where jr_id=$1",[$p_jr_id]);
+ return $jr_id;
+ }
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@@ -43,9 +69,10 @@ class Acc_LedgerTest extends TestCase
public function testGet_last_pj()
{
- $this->object->id=1;
- $array=$this->object->get_last(2);
- $this->assertEquals(2,count($array));
+ $this->object->id=2;
+ $sPj=$this->object->get_last_pj(2);
+ print_r("get_last_pj $sPj");
+ $this->assertEquals(5,$sPj);
}
@@ -78,16 +105,51 @@ class Acc_LedgerTest extends TestCase
*/
public function testDelete()
{
+ global $g_connection;
+ $jr_id=$g_connection->get_value("select max(jr_id) from jrn");
+ $this->object->jr_id=$jr_id;
$this->object->delete();
+ $count=$g_connection->get_value("select count(*) from jrn where jr_id=$1",[$jr_id]);
+ $this->assertEquals($count,0);
+ }
+ public function delete_ledger()
+ {
+ global $g_connection;
+ // a . create a ledger and delete it
+ $array=["p_jrn_def_name"=>"UNITTEST","p_ech_lib"=>"","p_jrn_deb_max_line"=>7,'p_jrn_type'=>'ODS','jrn_def_pj_pref'=>'TT/','min_row'=>5,'p_description'=>'LEDGER UNIT TEST','jrn_def_negative_amount'=>0,'jrn_def_negative_warning'=>'Warning'];
+ $this->object->save_new($array);
+
+ // Get it
+ $last_ledger_inserted=$g_connection->get_value("select max(jrn_def_id) from jrn_def");
+ $name=$g_connection->get_value("select jrn_def_name from jrn_def where jrn_def_id=$1",[$last_ledger_inserted]);
+ $this->assertEquals($name,'UNITTEST');
+
+ // drop it
+ $this->object->delete_ledger();
+ $cnt=$g_connection->get_value("select count(*) from jrn_def where jrn_def_id=$1",[$last_ledger_inserted]);
+ $this->assertEquals($cnt,0);
+ $ok=0;
+ // Try to delete a ledger which is used
+ try {
+ $jr_id=$g_connection->get_value("select max(jr_id) from jrn");
+ $ledger_id=$g_connection->get_value("select jr_def_id from jrn where jr_id=$1",[$jr_id]);
+ $ledger=new Acc_Legder($g_connection,$ledger_id);
+ $ledger->delete_ledger();
+ } catch (Exception $ex) {
+ $ok=1;
+ }
+ $this->assertEquals($ok,1);
+ $cnt=$g_connection->get_value("select count(*) from jrn_def where jrn_def_id=$1",[$ledger_id]);
+ $this->assertEquals($cnt,1);
}
-
/**
* @covers Acc_Ledger::display_warning
* @todo Implement testDisplay_warning().
*/
public function testDisplay_warning()
{
- $this->object->display_warning("Alert", "warning");
+ $str=$this->object->display_warning(["First Line","Second Line"], "warning");
+ $this->assertEquals('
warning
- First Line
- Second Line
',$str);
}
/**
@@ -96,7 +158,22 @@ class Acc_LedgerTest extends TestCase
*/
public function testReverse()
{
- $this->object->reverse('01.01.2014');
+ global $g_connection;
+ $this->object->jr_id=$g_connection->get_value("select max(jr_id) from jrn ");
+ $this->assertLessThan($this->object->jr_id,"0","found jr_id ".$this->object->jr_id);
+ $this->assertFalse(empty($this->object->jr_id),"not found jr_id ");
+
+ $this->object->id=$g_connection->get_value("select jr_def_id from jrn where jr_id=$1",[$this->object->jr_id]);
+ $this->assertGreaterThan($this->object->id,"0","found id ".$this->object->id);
+ $this->assertFalse(empty($this->object->id),"not found id ");
+ print_r("jr_id = ".$this->object->jr_id);
+ print_r("id = ".$this->object->id);
+ $date=$g_connection->get_value ("select to_char(max(p_start),'DD.MM.YYYY') from parm_periode where p_closed='f'");
+ $this->object->reverse($date,'unit test'.$date);
+ $check=$g_connection->get_value("select jr_id from jrn where jr_comment=$1",["unit test".$date]);
+ $this->assertFalse(empty($check),"NOT REVERSED" );
+ $this->object->jr_id=$check;
+ $this->object->delete();
}
/**
@@ -110,28 +187,22 @@ class Acc_LedgerTest extends TestCase
$this->assertEquals('Achat',$name);
}
- /**
- * @covers Acc_Ledger::get_row
- * @todo Implement testGet_row().
- */
- public function testGet_row()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
/**
* @covers Acc_Ledger::get_rowSimple
* @todo Implement testGet_rowSimple().
*/
public function testGet_rowSimple()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $last=$g_connection->get_value("select max(p_id) from parm_periode");
+ $first=$g_connection->get_value("select min(p_id) from parm_periode");
+ $id=$this->object->id;
+ $this->object->id=2;
+ $array=$this->object->get_rowSimple($first,$last);
+ $this->assertTrue(is_array($array),"get_rowSimple does not return an array");
+ $this->assertGreaterThan(0,count($array));
+ $this->object->id=$id;
+
}
/**
@@ -140,46 +211,9 @@ class Acc_LedgerTest extends TestCase
*/
public function testGuess_pj()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::list_operation_to_reconcile
- * @todo Implement testList_operation_to_reconcile().
- */
- public function testList_operation_to_reconcile()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::list_operation
- * @todo Implement testList_operation().
- */
- public function testList_operation()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Ledger::get_detail
- * @todo Implement testGet_detail().
- */
- public function testGet_detail()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->object->id=2;
+ $r=$this->object->guess_pj();
+ $this->assertEquals("VEN6",$r);
}
/**
@@ -188,10 +222,11 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_propertie()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $this->object->id=2;
+ $array=$this->object->get_propertie();
+ // there are 16 columns in jrn_def
+ $this->assertEquals(count($array),20);
}
/**
@@ -205,7 +240,38 @@ class Acc_LedgerTest extends TestCase
'This test has not been implemented yet.'
);
}
-
+ /**
+ * @covers Acc_Ledger::display_negative_warning
+ */
+ public function testDisplay_negative_warning()
+ {
+ global $g_connection;
+ $msg="WARNING ! WARNING !";
+ $acc_ledger=new Jrn_def_SQL($g_connection,2);
+ $acc_ledger_old=clone $acc_ledger;
+ $acc_ledger->setp("jrn_def_negative_amount",1);
+ $acc_ledger->setp("jrn_def_negative_warning",$msg);
+ $acc_ledger->save();
+ $this->object->set_ledger_id(2);
+ $result=$this->object->display_negative_warning(-1);
+ $this->assertEquals($result,"");
+ $result=$this->object->display_negative_warning(1);
+ $this->assertEquals($result,$msg);
+
+ $acc_ledger_old->save();
+ $id=$this->object->get_ledger_id();
+ $ok=0;
+ try {
+ $this->object->set_ledger_id(0);
+ $result=$this->object->display_negative_warning(1);
+ } catch (Exception $e) {
+ $this->assertEquals($e->getCode(),1);
+ $ok=1;
+ }
+ $this->assertEquals($ok,1);
+ $this->object->set_ledger_id($id);
+
+ }
/**
* @covers Acc_Ledger::get_solde
* @todo Implement testGet_solde().
@@ -666,9 +732,36 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_tiers()
{
- $this->object->get_tiers($p_jrn_type, $jr_id);
- }
+ global $g_connection;
+ $jr_id=$this->get_jrn_id();
+ $this->assertEquals($this->object->get_tiers("ODS", $jr_id)," ");
+ $jr_id=$this->get_jrn_id("ACH");
+ $this->assertTrue($this->object->get_tiers("ACH",$jr_id)!=' ');
+
+ $jr_id=$this->get_jrn_id("FIN");
+ $this->assertTrue($this->object->get_tiers('FIN',$jr_id)!=' ');
+
+ $jr_id=$this->get_jrn_id("VEN");
+ $this->assertTrue($this->object->get_tiers("VEN",$jr_id)!=' ');
+
+ }
+ public function testGet_tiers_id()
+ {
+ global $g_connection;
+ $jr_id=$this->get_jrn_id();
+ $this->assertEquals($this->object->get_tiers_id("ODS", $jr_id),0);
+
+ $jr_id=$this->get_jrn_id("ACH");
+ $this->assertGreaterThan(0,$this->object->get_tiers_id("ACH",$jr_id));
+
+ $jr_id=$this->get_jrn_id("FIN");
+ $this->assertGreaterThan(0,$this->object->get_tiers_id("FIN",$jr_id));
+
+ $jr_id=$this->get_jrn_id("VEN");
+ $this->assertGreaterThan(0,$this->object->get_tiers_id("VEN",$jr_id));
+
+ }
/**
* @covers Acc_Ledger::listing
* @todo Implement testListing().
@@ -719,14 +812,12 @@ class Acc_LedgerTest extends TestCase
/**
* @covers Acc_Ledger::input_paid
- * @todo Implement testInput_paid().
*/
public function testInput_paid()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $r=$this->object->input_paid(0);
+ $this->assertStringStartsWith('
',$r);
+ $this->assertStringEndsWith('
',$r);
}
/**
@@ -743,14 +834,30 @@ class Acc_LedgerTest extends TestCase
/**
* @covers Acc_Ledger::save_new
- * @todo Implement testSave_new().
*/
public function testSave_new()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+
+ $array=["p_jrn_name"=>"UNITTEST",
+ "p_ech_lib"=>"",
+ "p_jrn_deb_max_line"=>7,
+ 'p_jrn_class_deb'=>'4*',
+ 'p_jrn_type'=>'ODS',
+ 'jrn_def_pj_pref'=>'TT/',
+ 'min_row'=>5,
+ 'p_description'=>'LEDGER UNIT TEST',
+ 'jrn_def_negative_amount'=>0,
+ 'jrn_def_negative_warning'=>'Warning'];
+
+
+ $this->object->save_new($array);
+ $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]);
+ $this->assertGreaterThan($jrn_def_id,0);
+ $ledger=new Acc_Ledger($g_connection,$jrn_def_id);
+ $ledger->delete_ledger();
+ $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]);
+ $this->assertEquals($jrn_def_id,"");
}
/**
@@ -759,10 +866,23 @@ class Acc_LedgerTest extends TestCase
*/
public function testDelete_ledger()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ global $g_connection;
+ $array=["p_jrn_name"=>"UNITTEST",
+ "p_ech_lib"=>"",
+ "p_jrn_deb_max_line"=>7,
+ 'p_jrn_class_deb'=>'4*',
+ 'p_jrn_type'=>'ODS',
+ 'jrn_def_pj_pref'=>'TT/',
+ 'min_row'=>5,
+ 'p_description'=>'LEDGER UNIT TEST'];
+
+ $this->object->save_new($array);
+ $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]);
+ $this->assertGreaterThan($jrn_def_id,0);
+ $ledger=new Acc_Ledger($g_connection,$jrn_def_id);
+ $ledger->delete_ledger();
+ $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def where jrn_def_name=$1",[$array['p_jrn_name']]);
+ $this->assertEquals($jrn_def_id,"");
}
/**
@@ -771,10 +891,15 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_operation_date()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $res=$this->object->get_operation_date('01.01.2010','VEN','>');
+ $this->assertGreaterThan(0,count($res),'Failed VEN');
+ $res=$this->object->get_operation_date('01.01.2010','ACH','>');
+ $this->assertGreaterThan(0,count($res),'Failed ACH ');
+ $res=$this->object->get_operation_date('01.01.2000','VEN','<');
+ $this->assertEquals(count($res),0,'Failed VEN before ');
+ $res=$this->object->get_operation_date('01.01.2000','ACH','<');
+ $this->assertEquals(count($res),0,'Failed ACH before');
+
}
/**
@@ -783,10 +908,7 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_supplier_now()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->assertTrue(is_array($this->object->get_supplier_now()));
}
/**
@@ -795,10 +917,7 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_supplier_late()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->assertTrue(is_array($this->object->get_supplier_late()));
}
/**
@@ -807,10 +926,7 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_customer_now()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->assertTrue(is_array($this->object->get_customer_now()));
}
/**
@@ -819,10 +935,7 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_customer_late()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->assertTrue(is_array($this->object->get_customer_late()));
}
/**