Merge branch 'dev7109' into entreprise

This commit is contained in:
Dany De Bontridder 2019-08-26 15:50:46 +02:00
commit 6872a81d8b
64 changed files with 7294 additions and 4743 deletions

View file

@ -3,7 +3,7 @@
export PGUSER=dany
export PGPASSWORD=dany
export PGHOST=localhost
export PGDATABASE=rel671mod1
export PGDATABASE=rel70dossier48
export PGPORT=5432
(
echo "<?php "
@ -26,7 +26,7 @@ psql -A -F" " -t -c "select '\$action[]=_('''||replace(ac_description,'''',E'\\
echo "?>" ) >> ../include/database.item.php
(
echo "<?php "
psql -A -F" " -t -c "select '\$mdp[]=_('''||replace(mp_lib,'''',E'\\\\''')||''');' from mod_payment ;"
psql -A -F" " -t -c "select '\$mdp[]=_('''||replace(mp_lib,'''',E'\\\\''')||''');' from payment_method ;"
echo "?>" ) >> ../include/database.item.php
(
echo "<?php "
@ -41,4 +41,9 @@ echo "<?php "
psql -A -F" " -t -c "select '\$jrn_type[]=_('''||replace(jrn_desc,'''',E'\\\\''')||''');' from jrn_type ;"
echo "?>" ) >> ../include/database.item.php
(
psql -A -F" " -t -c "select '\jrn_def_negative_warning[]=_('''||replace(jrn_def_negative_warning,'''',E'\\\\''')||''');' from jrn_def where coalesce(trim(jrn_def_negative_warning),'')!='';"
echo "?>" ) >> ../include/database.item.php
echo "File ../include/database.item.php is created"

View file

@ -251,6 +251,8 @@ $path = array(
'update_comment_followUp'=>'ajax_follow_up',
// TVA param
"tva_parameter"=>"ajax_tva_parameter",
// Currency , add / remove / update currency
"CurrencyManage"=>"ajax_currency",
// Currency , delete a rate
"CurrencyRateDelete"=>"ajax_currency",
// payment_method
@ -373,30 +375,32 @@ switch ($op)
return;
break;
case "remove_anc":
if ($g_user->check_module('ANCODS') == 0)
exit();
$cn->exec_sql("delete from operation_analytique where oa_group=$1", array($_GET['oa']));
break;
case "rm_stock":
if ($g_user->check_module('STOCK') == 0)
exit();
require_once NOALYSS_INCLUDE.'/constant.security.php';
$cn->exec_sql('delete from stock_goods where sg_id=$1', array($s_id));
$html = escape_xml($s_id);
header('Content-type: text/xml; charset=UTF-8');
printf('{"d_id":"%s"}', $s_id);
exit();
break;
//--------------------------------------------------
// get the last date of a ledger
case 'lastdate':
require_once NOALYSS_INCLUDE.'/class/acc_ledger_fin.class.php';
$ledger = new Acc_Ledger_Fin($cn, $_GET['p_jrn']);
$html = $ledger->get_last_date();
$html = escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
case "remove_anc":
if ($g_user->check_module('ANCODS') == 0)
exit();
$oa_group=$http->get("oa","number");
$cn->exec_sql("delete from operation_analytique where oa_group=$1", array($oa_group));
break;
case "rm_stock":
if ($g_user->check_module('STOCK') == 0)
exit();
require_once NOALYSS_INCLUDE.'/constant.security.php';
$cn->exec_sql('delete from stock_goods where sg_id=$1', array($s_id));
$html = escape_xml($s_id);
header('Content-type: text/xml; charset=UTF-8');
printf('{"d_id":"%s"}', $s_id);
exit();
break;
//--------------------------------------------------
// get the last date of a ledger
case 'lastdate':
require_once NOALYSS_INCLUDE.'/class/acc_ledger_fin.class.php';
$p_jrn=$http->get('p_jrn','number');
$ledger = new Acc_Ledger_Fin($cn, $p_jrn);
$html = $ledger->get_last_date();
$html = escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<code>e_date</code>
@ -404,12 +408,13 @@ switch ($op)
</data>
EOF;
break;
case 'bkname':
require_once NOALYSS_INCLUDE.'/class/acc_ledger_fin.class.php';
$ledger = new Acc_Ledger_Fin($cn, $_GET['p_jrn']);
$html = $ledger->get_bank_name();
$html = escape_xml($html);
break;
case 'bkname':
require_once NOALYSS_INCLUDE.'/class/acc_ledger_fin.class.php';
$p_jrn=$http->get('p_jrn','number');
$ledger = new Acc_Ledger_Fin($cn, $p_jrn);
$html = $ledger->get_bank_name();
$html = escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
@ -420,16 +425,17 @@ EOF;
EOF;
break;
// display new calendar
case 'cal':
require_once NOALYSS_INCLUDE.'/class/calendar.class.php';
/* others report */
$cal = new Calendar();
$cal->set_periode($per);
$notitle=$http->get("notitle", "string",0);
$html = "";
$html = $cal->display($http->get('t'),$notitle);
$html = escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
case 'cal':
require_once NOALYSS_INCLUDE.'/class/calendar.class.php';
/* others report */
$cal = new Calendar();
$per=$http->get("per","number");
$cal->set_periode($per);
$notitle=$http->get("notitle", "string",0);
$html = "";
$html = $cal->display($http->get('t'),$notitle);
$html = escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>

View file

@ -253,7 +253,7 @@ var ManageTable = function (p_table_name)
this.param['ctl'] = p_ctl;
var here=this;
$(p_ctl+"_"+p_id).addClassName("highlight");
smoke.confirm("Confirmez ?",
smoke.confirm(content[47],
function (e)
{
if (e ) {

View file

@ -584,6 +584,7 @@ function set_tva_label(obj)
}
/**
*@brief display the popup with vat and explanations
*@param string req answer from ajax
*/
function success_set_tva_label(req)
{
@ -3622,3 +3623,37 @@ function updatePreference()
remove_waiting_box();
}
/**
* turn on or off , set an domElement to 1 or 0 and change the icon
* @param string icon_domid : id of the domElement which must be changed
* @param string p_value_domid : id of domElement containing 1 or 0
* @see param_jrn.php
*/
function toggle_onoff(icon_domid,p_value_domid)
{
if ( $(p_value_domid).value==0) {
$(p_value_domid).value=1;
$(icon_domid).innerHTML='&#xf205;';
$(icon_domid).style='color:green';
} else {
$(p_value_domid).value=0;
$(icon_domid).innerHTML='&#xf204;';
$(icon_domid).style='color:red';
}
}
/**
* in CFGLED show or hide the row depending if the warning is enable or not
*
* @param {type} p_enable
* @param {type} p_row
* @returns {undefined}
*/
function toggle_row_warning_enable(p_enable,p_row)
{
if ($(p_enable).value==1) {
$(p_row).show();
} else {
$(p_row).hide();
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2305,4 +2305,15 @@ div.progressbar {
background-color:darkblue;
color:antiquewhite;
font-weight: bolder;
}
/**
* Warning
*/
span.warning {
color:red;
font-style: normal;
font-weight: bold;
background-color: #eddadd;
padding:10px;
border:red solid 1px;
}

View file

@ -54,9 +54,7 @@ input:focus {
font-style: italic;
}
span.notice {
font-weight: bold;
}
a.mtitle span.notice {
text-decoration: underline;
}
@ -2284,4 +2282,14 @@ div.progressbar {
}
.nowrap td {
white-space: nowrap;
}
/**
* Warning
*/
span.warning {
color:red;
font-style: normal;
font-weight: bold;
background-color: #eddadd;
padding:10px;
}

View file

@ -2226,3 +2226,13 @@ div.progressbar {
color:antiquewhite;
font-weight: bolder;
}
/**
* Warning
*/
span.warning {
color:red;
font-style: normal;
font-weight: bold;
background-color: #eddadd;
padding:10px;
}

View file

@ -159,6 +159,7 @@ case 'dc':
}
$html.=$card;
$html.='<p style="text-align:center">';
$html.=HtmlInput::button_close($ctl);
if ( $can_modify==1)
{
$html.=HtmlInput::submit('save',_('Sauver'));

View file

@ -122,6 +122,7 @@ if ( isset($_GET['f_id']))
} else {
echo $fiche->filter_history("tb".$div);
echo $table;
echo HtmlInput::button_close($div);
echo $fiche->button_csv($array['from_periode'],$array['to_periode']);
echo $fiche->button_pdf($array['from_periode'],$array['to_periode']);
}
@ -209,6 +210,7 @@ if ( isset($_REQUEST['pcm_val']))
} else {
echo $poste->filter_history('tb'.$div);
echo $table;
echo HtmlInput::button_close($div);
echo $poste->button_csv($array['from_periode'],$array['to_periode']);
echo $poste->button_pdf($array['from_periode'],$array['to_periode']);
}

View file

@ -27,6 +27,7 @@
- load a receipt document
- for reconcialiation
- update of analytic content
*
*/
if ( ! defined('ALLOWED')) die(_('Non authorisé'));
@ -283,7 +284,7 @@ case 'file':
{
// Not possible to remove the file thanks a modal dialog box,
// because of the frameset
$x=sprintf('<a class="smallbutton" style="margin-left:12;margin-right:12" href="ajax_misc.php?op=ledger&gDossier=%d&div=%s&jr_id=%s&act=rmf" onclick="return confirm(\'Effacer le document ?\')">'.SMALLX.'</a>',
$x=sprintf('<a class="smallbutton icon" style="margin-left:12;margin-right:12" href="ajax_misc.php?op=ledger&gDossier=%d&div=%s&jr_id=%s&act=rmf" onclick="return confirm(\'Effacer le document ?\')">'."x".'</a>',
$gDossier,$div,$jr_id);
}

View file

@ -54,7 +54,7 @@ if ( $action_frm == 'update')
{
try
{
$ledger->id=$http->post('p_jrn',"number");
$ledger->set_ledger_id($http->post('p_jrn',"number"));
if ( $ledger->load() == -1) throw new Exception (_('Journal inexistant'));
$ledger->verify_ledger($_POST);
$ledger->update($_POST);
@ -72,7 +72,7 @@ if ( $action_frm == 'update')
//////////////////////////////////////////////////////////////////////////
if ($action_frm == 'delete' )
{
$ledger->id=$http->post('p_jrn',"number");
$ledger->set_ledger_id($http->post('p_jrn',"number"));
$ledger->load();
$name=$ledger->get_name();
try {
@ -104,7 +104,7 @@ if (isset($_POST['add']))
$ledger->verify_ledger($_POST);
$ledger->save_new($_POST);
$sa="detail";
$a[]=["key"=>'p_jrn',"value"=>$ledger->id];
$a[]=["key"=>'p_jrn',"value"=>$ledger->get_ledger_id()];
put_global($a);
$show_menu=1;
}
@ -129,7 +129,7 @@ switch ($sa)
case 'detail': /* detail of a ledger */
try
{
$ledger->id=$http->request('p_jrn',"number");
$ledger->set_ledger_id($http->request('p_jrn',"number"));
echo '<div class="content">';
echo '<form id="cfg_ledger_frm" method="POST">';
echo $ledger->display_ledger();

View file

@ -22,6 +22,7 @@ require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
require_once NOALYSS_INCLUDE.'/lib/icard.class.php';
require_once NOALYSS_INCLUDE.'/lib/ispan.class.php';
require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php';
require_once NOALYSS_INCLUDE.'/lib/input_switch.class.php';
require_once NOALYSS_INCLUDE.'/lib/idate.class.php';
require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
require_once NOALYSS_INCLUDE.'/lib/icheckbox.class.php';
@ -75,12 +76,13 @@ class Acc_Ledger extends jrn_def_sql
function __construct($p_cn, $p_id)
{
$this->id=$p_id;
$this->name=&$this->jrn_def_name;
$this->ledger_name=&$this->jrn_def_name;
$this->jrn_def_id=&$this->id;
$this->db=$p_cn;
$this->row=null;
$this->nb=MAX_ARTICLE;
$this->currency_id=$this->set_currency_id();
parent::__construct($p_cn, $p_id);
parent::__construct($p_cn, $p_id);
}
/**
* retrieve currency_id from database
@ -115,7 +117,23 @@ class Acc_Ledger extends jrn_def_sql
$this->db->create_sequence("s_jrn_pj".$this->id);
return 0;
}
/**
* Set the jrn_def.jrn_def_id
* @param integer $p_id
*/
function set_ledger_id($p_id)
{
$this->id=$p_id;
$this->jrn_def_id=&$this->id;
}
/**
* Set the jrn_def.jrn_def_id
* @return integer
*/
function get_ledger_id()
{
return $this->id;
}
/**
* @brief Return the type of a ledger (ACH,VEN,ODS or FIN) or GL
*
@ -124,7 +142,7 @@ class Acc_Ledger extends jrn_def_sql
{
if ($this->id==0)
{
$this->name=_(" Tous les journaux");
$this->ledger_name=_(" Tous les journaux");
$this->type="GL";
return "GL";
}
@ -386,8 +404,8 @@ class Acc_Ledger extends jrn_def_sql
{
if ($this->id==0)
{
$this->name=_("Grand Livre");
return $this->name;
$this->ledger_name=_("Grand Livre");
return $this->ledger_name;
}
$Res=$this->db->exec_sql("select jrn_def_name from ".
@ -396,7 +414,7 @@ class Acc_Ledger extends jrn_def_sql
if ($Max==0)
return null;
$ret=Database::fetch_array($Res, 0);
$this->name=$ret['jrn_def_name'];
$this->ledger_name=$ret['jrn_def_name'];
return $ret['jrn_def_name'];
}
@ -433,18 +451,15 @@ class Acc_Ledger extends jrn_def_sql
if ($this->id==0)
return;
$Res=$this->db->exec_sql("select jrn_Def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_def_type,
jrn_deb_max_line,jrn_cred_max_line,jrn_def_ech,jrn_def_ech_lib,jrn_def_code,
jrn_def_fiche_deb,jrn_def_fiche_cred,jrn_def_pj_pref
$Res=$this->db->get_row("select *
from jrn_Def
where jrn_def_id=$1", array($this->id));
$Count=Database::num_row($Res);
if ($Count==0)
if ($Res == NULL)
{
echo '<DIV="redcontent"><H2 class="error">'._('Parametres journaux non trouves').'</H2> </DIV>';
return null;
}
return Database::fetch_array($Res, 0);
return $Res;
}
/**
@ -459,7 +474,7 @@ class Acc_Ledger extends jrn_def_sql
$sql="select jrn_deb_max_line as value from jrn_def where jrn_def_id=$1";
$r=$this->db->exec_sql($sql, array($this->id));
$Res=Database::fetch_all($r);
if (sizeof($Res)==0)
if ($Res == FALSE || sizeof($Res)==0)
return 1;
return $Res[0]['value'];
}
@ -485,6 +500,7 @@ class Acc_Ledger extends jrn_def_sql
$array=Database::fetch_all($ret);
$deb=0.0;
$cred=0.0;
if ( $array==FALSE) $array=[];
foreach ($array as $line)
{
@ -549,7 +565,7 @@ class Acc_Ledger extends jrn_def_sql
$r=$this->db->exec_sql($sql, array($this->id));
$res=Database::fetch_all($r);
if (empty($res))
if ($res==FALSE || empty($res))
return null;
return $res[0];
@ -1063,7 +1079,7 @@ class Acc_Ledger extends jrn_def_sql
* permitted card, 5 not in the user's period, 6 closed period
*
*/
function verify($p_array)
function verify_operation($p_array)
{
global $g_parameter;
$http=new HttpInput();
@ -2457,8 +2473,14 @@ class Acc_Ledger extends jrn_def_sql
["label"=>_("Désactivé"),"value"=>0]
];
$actif->selected=$this->jrn_enable;
// -- default currency used : only for financial ledgers
$default_currency=$this->select_default_currency();
$negative=new InputSwitch('negative_amount',$this->jrn_def_negative_amount);
$negative_warning=new IText("negative_warning",_($this->jrn_def_negative_warning));
$negative_warning->size=80;
require_once NOALYSS_TEMPLATE.'/param_jrn.php';
}
@ -2527,6 +2549,12 @@ class Acc_Ledger extends jrn_def_sql
{
throw new Exception(_('Choix du type de journal est obligatoire'));
}
if ($negative_amount == 1 && trim($negative_warning)=="") {
throw new Exception(_("Avertissement ne peut être vide"));
}
if ( $negative_amount <> 0 && $negative_amount <> 1 ){
throw new Exception(_("Valeur invalide"));
}
}
catch (Exception $e)
{
@ -2556,6 +2584,9 @@ class Acc_Ledger extends jrn_def_sql
$this->jrn_def_description=$p_description;
$this->jrn_enable=$jrn_enable;
$this->currency_id=0;
$this->jrn_def_negative_amount=$negative_amount;
$this->jrn_def_negative_warning=$negative_warning;
switch ($this->jrn_def_type)
{
case 'ACH':
@ -2724,8 +2755,12 @@ class Acc_Ledger extends jrn_def_sql
$cn=$this->db;
$min_row=new INum("min_row", MAX_ARTICLE);
$min_row->prec=0;
// -- default currency used : only for financial ledgers
// -- default currency used : only for financial ledgers
$default_currency=$this->select_default_currency();
$negative=new InputSwitch('negative_amount',0);
$negative_warning=new IText('negative_warning',_("Attention, ce journal doit utiliser des montants négatifs"));
$negative_warning->size=80;
require_once NOALYSS_TEMPLATE.'/param_jrn.php';
}
@ -2750,7 +2785,10 @@ class Acc_Ledger extends jrn_def_sql
Acc_Ledger::next_number($this->db, $this->jrn_def_type));
$this->jrn_def_description=$p_description;
$this->currency_id=0;
$this->jrn_def_negative_amount=$negative_amount;
$this->jrn_def_negative_warning=$negative_warning;
$this->jrn_enable=1;
switch ($this->jrn_def_type)
{
case 'ACH':
@ -2785,7 +2823,7 @@ class Acc_Ledger extends jrn_def_sql
$this->currency_id=$defaultCurrency;
break;
}
parent::insert();
}
@ -3138,6 +3176,23 @@ class Acc_Ledger extends jrn_def_sql
$cr=new Acc_Currency($this->db,$this->currency_id);
return $cr;
}
/**
* If the amount is positive and the ledger expects a negative amount, il will return the saved warning
*
* @param int $p_amount amount to check
* @throws Exception 1 if invalid ledger
*/
function display_negative_warning($p_amount)
{
if ($this->id == 0) {
throw new Exception(_("Journal invalide"), 1);
}
$ledger=new Jrn_def_SQL($this->db,$this->id);
if ( $p_amount > 0 && $ledger->getp("jrn_def_negative_amount")==1){
return _($ledger->getp("jrn_def_negative_warning"));
}
return "";
}
}
?>

View file

@ -53,7 +53,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
* @throw Exception on error occurs
*/
public function verify($p_array)
public function verify_operation($p_array)
{
global $g_user;
if (is_array($p_array ) == false || empty($p_array))

View file

@ -225,6 +225,9 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History
$c=0;
// Parse data from jrnx and fill diff. field
if ( $data_jrnx == FALSE ){
$data_jrnx=[];
}
foreach ($data_jrnx as $code)
{
$idx_tva=0;

View file

@ -59,7 +59,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
*\return String
*\throw Exception if an error occurs
*/
public function verify($p_array)
public function verify_operation($p_array)
{
global $g_parameter,$g_user;
@ -1859,7 +1859,13 @@ EOF;
$r.='<br>';
}
// check for upload piece
/*
* warning if the amount is positive and expecting a negative one
*/
$negative=$this->display_negative_warning($tot);
if ( $negative != "") {
$r.=span($negative,'class="warning" ');
}
return $r;
}

View file

@ -62,7 +62,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
* \throw Exception if an error occurs
*/
public function verify($p_array) {
public function verify_operation($p_array) {
global $g_parameter, $g_user;
if (is_array($p_array ) == false || empty($p_array))
@ -1064,6 +1064,8 @@ EOF;
$r.='<br>Total '.hb($tot);
}
$r.='</div>';
/* Add hidden */
$r.=HtmlInput::hidden('e_client', $e_client);
$r.=HtmlInput::hidden('nb_item', $nb_item);
@ -1121,6 +1123,13 @@ EOF;
}
$r.=HtmlInput::hidden("e_quant" . $i, ${"e_quant" . $i});
}
/*
* warning if the amount is positive and expecting a negative one
*/
$negative=$this->display_negative_warning($tot);
if ( $negative != "") {
$r.=span($negative,'class="warning" ');
}
return $r;
}

View file

@ -345,7 +345,7 @@ class Acc_Operation
}
/*!\brief retrieve data from jrnx
*\note the data are filtered by the access of the current user
* \return an array
* \return an array or FALSE if nothing found
*/
function get_jrnx_detail()
{

View file

@ -69,18 +69,18 @@ class Anc_Balance_Simple extends Anc_Print
$a=array();
$count=0;
$array=Database::fetch_all($res);
foreach ($array as $row)
{
$a[$count]['po_id']=$row['po_id'];
$a[$count]['sum_deb']=$row['sum_deb'];
$a[$count]['sum_cred']=$row['sum_cred'];
$a[$count]['po_name']=$row['po_name'];
$a[$count]['ga_description']=$row['ga_description'];
$a[$count]['solde']=abs($row['sum_deb']-$row['sum_cred']);
$a[$count]['debit']=($row['sum_deb']>$row['sum_cred'])?"debit":"credit";
$count++;
}
$this->has_data=$count;
foreach ($array as $row)
{
$a[$count]['po_id']=$row['po_id'];
$a[$count]['sum_deb']=$row['sum_deb'];
$a[$count]['sum_cred']=$row['sum_cred'];
$a[$count]['po_name']=$row['po_name'];
$a[$count]['ga_description']=$row['ga_description'];
$a[$count]['solde']=abs($row['sum_deb']-$row['sum_cred']);
$a[$count]['debit']=($row['sum_deb']>$row['sum_cred'])?"debit":"credit";
$count++;
}
$this->has_data=$count;
return $a;

View file

@ -144,9 +144,10 @@ class Customer extends Fiche
// select the operation
//----
$Res2=$this->cn->exec_sql("select j_poste,j_montant,j_debit from jrnx where j_grpt=".$row1['j_grpt']);
$Res2=$this->cn->exec_sql("select j_poste,j_montant,j_debit from jrnx where j_grpt=$1",[$row1['j_grpt']]);
$a_row=Database::fetch_all($Res2);
if ($a_row==FALSE) $a_row=[];
// Store the amount in the array
//---
foreach ($a_row as $e)

View file

@ -1179,7 +1179,7 @@ class Fiche
$sql="select ad_value from fiche_detail where ad_id=23 and f_id=$1";
$Res=$this->cn->exec_sql($sql,array($this->id));
$r=Database::fetch_all($Res);
if ( sizeof($r) == 0 )
if ( $r == FALSE || sizeof($r) == 0 )
return null;
return $r[0]['ad_value'];
}

View file

@ -772,7 +772,7 @@ class Follow_Up
if ($a_row==false || sizeof($a_row)==0 )
{
$r='<div style="clear:both">';
$r.='<hr>Aucun enregistrement trouvé';
$r.='<hr>'._("Aucun enregistrement trouvé");
$r.="</div>";
return $r;
}

View file

@ -68,7 +68,7 @@ class gestion_sold extends gestion_table
// $res contains all the line
$res=Database::fetch_all($ret);
if ( sizeof($res)==0) return null;
if ( $res == FALSE || sizeof($res)==0) return null;
$count=0;
foreach ($res as $row)
@ -108,7 +108,7 @@ class gestion_sold extends gestion_table
// $res contains all the line
$res=Database::fetch_all($ret);
if ( empty($res) ) return null;
if ( $res==FALSE || empty($res) ) return null;
foreach ($res[0] as $idx=>$value)
$this->$idx=$value;
}

View file

@ -104,18 +104,20 @@ class Periode
{
/* if jrn_Def_id == 0 then we check the global otherwise we check
a ledger */
if ($this->jrn_def_id!=0)
if ($this->jrn_def_id!=0){
$sql="select status from jrn_periode ".
" where jrn_def_id=".$this->jrn_def_id.
" and p_id =".$this->p_id;
else
" where jrn_def_id=$1 ".
" and p_id = $2";
$status=$this->cn->get_value($sql,[$this->jrn_def_id,$this->p_id]);
}
else {
$sql="select p_closed as status from parm_periode ".
" where ".
" p_id =".$this->p_id;
$res=$this->cn->exec_sql($sql);
$status=Database::fetch_result($res, 0, 0);
if ($status=='OP'||$status=='f')
return 1;
" p_id = $1 ";
$status=$this->cn->get_value($sql,[$this->p_id]);
}
if ($status=='OP'||$status=='f') return 1;
return 0;
}

View file

@ -118,14 +118,14 @@ class Pre_op_fin extends Pre_operation_detail
return $array;
}
/*!\brief load the data from the database and return an array
* \return an array
* \return an array or FALSE is nothing found
*/
function load()
{
$sql="select opd_id,opd_poste,opd_amount,opd_comment,opd_debit".
" from op_predef_detail where od_id=".$this->operation->od_id.
" from op_predef_detail where od_id=$1 ".
" order by opd_id";
$res=$this->db->exec_sql($sql);
$res=$this->db->exec_sql($sql,[$this->operation->od_id]);
$array=Database::fetch_all($res);
return $array;
}

View file

@ -128,9 +128,9 @@ class Pre_operation
function load()
{
$sql="select od_id,jrn_def_id,od_name,od_item,od_jrn_type,od_description".
" from op_predef where od_id=".$this->od_id.
" from op_predef where od_id=$1 ".
" order by od_name";
$res=$this->db->exec_sql($sql);
$res=$this->db->exec_sql($sql,[$this->od_id]);
$array=Database::fetch_all($res);
foreach (array('jrn_def_id','od_name','od_item','od_jrn_type','od_description') as $field) {
$this->$field=$array[0][$field];

View file

@ -0,0 +1,355 @@
<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@noalyss.eu
/**
* @file
* @brief Compute , display and export the tax summary
*
*/
class Tax_Summary
{
private $date_start;
private $date_end;
private $db;
function __construct(Database $db,$p_start, $p_end)
{
$this->db=$db;
$this->set_date_start($p_start);
$this->set_date_end($p_end);
}
/**
* @return Database
*/
public function get_db()
{
return $this->db;
return $this;
}
/**
* @param Database $db
*/
public function set_db($db)
{
$this->db = $db;
return $this;
}
/**
* @return mixed
*/
public function get_date_start()
{
return $this->date_start;
return $this;
}
/**
* @param mixed $date_start
*/
public function set_date_start($date_start)
{
if (isDate($date_start) == NULL) throw Exception(_("Format date invalide") . $date_start);
$this->date_start = $date_start;
return $this;
}
/**
* @return mixed
*/
public function get_date_end()
{
return $this->date_end;
return $this;
}
/**
* @param mixed $date_end
*/
public function set_date_end($date_end)
{
if (isDate($date_end) == NULL) throw Exception(_("Format date invalide") . $date_end);
$this->date_end = $date_end;
return $this;
}
/**
* @brief depends of quant_* table, so we must check first that everything
* is in these tables
*/
function check()
{
/*-------------SALE ---------------------------------*/
$sql="select count(*)
from
jrnx
join quant_sold on (quant_sold.j_id = jrnx.j_id)
where
jrnx.j_jrn_def in (select jrn_def_id from jrn_def where jrn_def_type = 'VEN')
and j_date >= to_date($1,'DD.MM.YYYY')
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(_("Aucune Donnée"));
}
/*-------------Purchase ---------------------------------*/
$sql="select count(*)
from
jrnx
join quant_purchase as qp on (jrnx.j_id = qp.j_id)
where
jrnx.j_jrn_def in (select jrn_def_id from jrn_def where jrn_def_type = 'ACH')
and j_date >= to_date($1,'DD.MM.YYYY')
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(_("Aucune Donnée"));
}
}
/**
* Total for each sales ledger
* @return array
*/
function get_row_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,
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;
}
/**
* Total for each purchase ledger
* @return array
*/
function get_row_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,
j_jrn_def
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 j_jrn_def,qp_vat_code)
select jrn_def_name,
tva_label ,
tva_rate,
tva_both_side,
qp_vat_code,
amount_vat,
amount_wovat,
amount_sided,
amount_noded_amount,
amount_noded_tax,
amount_noded_return,
amount_private
from
detail_tva
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]);
return $array;
}
/**
* Summary for all sales ledger
*/
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,
tva_both_side,
amount_vat,
amount_wovat,
amount_sided
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]);
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)
select
tva_label ,
tva_rate,
tva_both_side,
qp_vat_code,
amount_vat,
amount_wovat,
amount_sided,
amount_noded_amount,
amount_noded_tax,
amount_noded_return,
amount_private
from
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]);
return $array;
}
/**
* @brief display the summary of VAT in the range of date
*/
function display()
{
require_once NOALYSS_INCLUDE."/template/tax_summary_display.php";
}
/**
* @brief display a form to export in CSV
* @see export_printtva_csv.php
*/
function form_export_csv()
{
echo '<form method="GET" action="export.php">';
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::submit("CSV:printtva",_("Export CSV"));
echo '</form>';
}
/**
* @brief display a form to export in PDF
* @see export_printtva_pdf.php
*/
function form_export_pdf()
{
echo '<form method="GET" action="export.php">';
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 '</form>';
}
}

View file

@ -54,7 +54,7 @@ if (isset($_POST['view_invoice']))
$Ledger = new Acc_Ledger_Purchase($cn, $post_jrn);
try
{
$Ledger->verify($_POST);
$Ledger->verify_operation($_POST);
}
catch (Exception $e)
{
@ -68,10 +68,8 @@ if (isset($_POST['view_invoice']))
echo '<div class="content">';
echo '<div id="confirm_div_id" style="width: 47%; float: left;">';
echo h1(_("Confirmation"));
echo '</div>';
echo '<div id="warning_ven_id" class="notice" style="width: 50%; margin-left: 0px; float: right;">';
echo h2(_("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer"),' class="notice"');
echo h1(_("Confirmation"));
echo span(_("Vous devez encore confirmer"),' class="notice"');
echo '</div>';
echo '<div id="confirm_div_id" style="width: 100%; float: left;">';
@ -136,7 +134,7 @@ if (isset($_POST['record']))
$Ledger = new Acc_Ledger_Purchase($cn, $post_jrn);
try
{
$Ledger->verify($_POST);
$Ledger->verify_operation($_POST);
}
catch (Exception $e)
{
@ -252,7 +250,7 @@ echo '</div>';
echo '<div class="content">';
echo '<p class="notice">'.$p_msg.'</p>';
echo '<span class="warning">'.$p_msg.'</span>';
try
{
$payment=$http->request("e_mp", "string",0);

View file

@ -69,7 +69,7 @@ if ( isset($_POST['save']))
{
try
{
$Ledger->verify($_POST);
$Ledger->verify_operation($_POST);
}
catch (Exception $e)
{
@ -101,7 +101,7 @@ if ( isset($_POST['confirm']))
{
try
{
$Ledger->verify($_POST);
$Ledger->verify_operation($_POST);
}
catch (Exception $e)
{
@ -137,7 +137,7 @@ if ( isset($_POST['correct']))
//----------------------------------------
// Blank form
//----------------------------------------
echo '<p class="notice">'.$p_msg.'</p>';
echo '<span class="warning">'.$p_msg.'</span>';
echo '<form class="print" name="form_detail" enctype="multipart/form-data" class="print" METHOD="POST">';
echo HtmlInput::hidden('ledger_type','fin');

View file

@ -72,17 +72,17 @@ if (!isset($_POST['summary']) && !isset($_POST['save']))
}
elseif (isset($_POST['summary']))
{
try {
$ledger->verify($_POST);
require_once NOALYSS_INCLUDE.'/operation_ods_confirm.inc.php';
} catch (Exception $e)
{
echo alert($e->getMessage());
$p_msg=$e->getMessage();
require_once NOALYSS_INCLUDE.'/operation_ods_new.inc.php';
try {
$ledger->verify_operation($_POST);
require_once NOALYSS_INCLUDE.'/operation_ods_confirm.inc.php';
} catch (Exception $e)
{
echo alert($e->getMessage());
$p_msg=$e->getMessage();
require_once NOALYSS_INCLUDE.'/operation_ods_new.inc.php';
}
return;
}
return;
}
elseif (isset($_POST['save']))
{
@ -120,16 +120,16 @@ elseif (isset($_POST['save']))
}
catch (Exception $e)
{
echo '<p class="notice">'._('Opération non extournée').
echo '<span class="warning">'._('Opération non extournée').
$e->getMessage().
'</p>';
'</span>';
}
}
else
{
// warning because date is invalid
echo '<p class="notice">'._('Date invalide, opération non extournée').'</p>';
echo '<span class="warning">'._('Date invalide, opération non extournée').'</span>';
}
}
echo '<ul class="aligned-block">';

View file

@ -37,7 +37,7 @@ $str_dossier=dossier::get();
global $g_parameter;
$http=new HttpInput();
$strac=$http->request('ac');
$ac="ac=".$_REQUEST['ac'];
$ac="ac=".$strac;
$p_msg="";
//----------------------------------------------------------------------
// Encode a new invoice
@ -48,7 +48,7 @@ $p_msg="";
// Check privilege
if ( isset($_REQUEST['p_jrn']) &&
$g_user->check_jrn($_REQUEST['p_jrn']) != 'W' )
$g_user->check_jrn($http->post("p_jrn","number")) != 'W' )
{
NoAccess();
@ -58,10 +58,11 @@ $p_msg="";
/* if a new invoice is encoded, we display a form for confirmation */
if ( isset ($_POST['view_invoice'] ) )
{
$Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
$p_jrn=$http->post("p_jrn","number");
$Ledger=new Acc_Ledger_Sold($cn,$p_jrn);
try
{
$Ledger->verify($_POST);
$Ledger->verify_operation($_POST);
}
catch (Exception $e)
{
@ -76,10 +77,7 @@ $p_msg="";
echo '<div id="confirm_div_id" style="width: 47%; float: left;">';
echo h1(_("Confirmation"));
echo '</div>';
echo '<div id="warning_ven_id" class="notice" style="width: 50%; margin-left: 0px; float: right;">';
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 '</div>';
echo '<div id="confirm_div_id" style="width: 100%; float: left;">';
@ -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 '</div>';
*/
echo '<div class="content">';
echo '<p class="notice">'.$p_msg.'</p>';
echo '<span class="warning">'.$p_msg.'</span>';
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);

View file

@ -108,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
if ( ! defined ("SYSINFO_DISPLAY")) {
define ("SYSINFO_DISPLAY",TRUE);
}
define ("DBVERSION",136);
define ("DBVERSION",137);
define ("MONO_DATABASE",25);
define ("DBVERSIONREPO",18);
define ('NOTFOUND','--not found--');

View file

@ -1,4 +1,6 @@
<?php
Timing is on.
Autocommit is OFF
$menu[]=_('Achat'); $desc[]=_('Nouvel achat ou dépense');$desc_long[]=_('Vous permet d\'encoder des achats, dépenses, des notes de frais ou des notes de crédits, vous pouvez spécifier un bénéficiaire ou un autre moyen de paiement');
$menu[]=_('Historique'); $desc[]=_('Historique des imputations analytiques');$desc_long[]=_('Historique des imputations analytiques');
$menu[]=_('Balance simple'); $desc[]=_('Balance simple des imputations analytiques');$desc_long[]=_('Balance simple des imputations analytiques');
@ -46,7 +48,6 @@ $menu[]=_('Export définition d\'un raport');
$menu[]=_('Export Action Gestion');
$menu[]=_('Export Historique mouvement stock');
$menu[]=_('Export Résumé list stock');
$menu[]=_('Extension'); $desc[]=_('Extensions (plugins)');$desc_long[]=_('Menu regroupant les plugins');
$menu[]=_('Plan Compt. analytique'); $desc[]=_('Plan analytique');$desc_long[]=_('Axe analytique');
$menu[]=_('Groupe'); $desc[]=_('Groupe analytique');$desc_long[]=_('Regroupement de compte analytique');
$menu[]=_('Contact'); $desc[]=_('Liste des contacts');$desc_long[]=_('Liste de tous vos contacts');
@ -58,6 +59,7 @@ $menu[]=_('Paramètre'); $desc[]=_('Module paramètre');$desc_long[]=_('Module
$menu[]=_('Catégorie de documents'); $desc[]=_('Config. catégorie de documents');$desc_long[]=_('Vous permet d\'ajouter de nouveaux type de documents (bordereau de livraison, devis..)');
$menu[]=_('Lettrage par Fiche'); $desc[]=_('Lettrage par fiche');$desc_long[]=_('Lettrage par fiche');
$menu[]=_('Historique achat'); $desc[]=_('Historique achat');$desc_long[]=_('Historique de toutes vos opérations dans les journaux d\'achats un menu de recherche, vous permettra de retrouver rapidement l\'opération qui vous intéresse');
$menu[]=_('Extension'); $desc[]=_('Extensions (plugins)');$desc_long[]=_('Menu regroupant les plugins');
$menu[]=_('Historique opérations diverses'); $desc[]=_('Historique opérations diverses');$desc_long[]=_('Historique de toutes vos opérations dans les journaux d\'opérations diverses un menu de recherche, vous permettra de retrouver rapidement l\'opération qui vous intéresse');
$menu[]=_('Poste'); $desc[]=_('Impression du détail d\'un poste comptable');$desc_long[]=_('Impression du détail d\'un poste comptable');
$menu[]=_('Rapport'); $desc[]=_('Impression de rapport');$desc_long[]=_('Impression de rapport personnalisé, il est aussi possible d\'exporter en CSV afin de faire des graphiques');
@ -96,10 +98,10 @@ $menu[]=_('Recherche'); $desc[]=_('Recherche');$desc_long[]=_('Historique de to
$menu[]=_('Historique'); $desc[]=_('Historique');$desc_long[]=_('Historique de toutes vos opérations un menu de recherche, vous permettra de retrouver rapidement l\'opération qui vous intéresse');
$menu[]=_('Rapprochement'); $desc[]=_('Rapprochement bancaire');$desc_long[]=_('Permet de faire correspondre vos extraits bancaires avec les opérations de vente ou d\'achat, le lettrage se fait automatiquement');
$menu[]=_('Soldes'); $desc[]=_('Solde des comptes en banques, caisse...');$desc_long[]=_('Solde des journaux de trésorerie cela concerne les comptes en banques, caisse , les chèques... ');
$menu[]=_('Sortie &#9094'); $desc[]=_('Sortie');$desc_long[]=_('Déconnexion ');
$menu[]=_('Lettrage par Poste'); $desc[]=_('lettrage par poste comptable');$desc_long[]=_('lettrage par poste comptable');
$menu[]=_('Balance'); $desc[]=_('Balance par catégorie de fiche');$desc_long[]=_('Balance par catégorie de fiche ou pour toutes les fiches ayant un poste comptable');
$menu[]=_('Plan Comptable'); $desc[]=_('Config. du plan comptable');$desc_long[]=_('Modification de votre plan comptable, parfois il est plus rapide d\'utiliser le plugin "Poste Comptable"');
$menu[]=_('Sortie &#9094'); $desc[]=_('Sortie');$desc_long[]=_('Déconnexion ');
$menu[]=_('Historique vente'); $desc[]=_('Historique des ventes');$desc_long[]=_('Historique de toutes vos opérations dans les journaux de vente un menu de recherche, vous permettra de retrouver rapidement l\'opération qui vous intéresse');
$menu[]=_('Historique financier'); $desc[]=_('Historique financier');$desc_long[]=_('Historique de toutes vos opérations dans les journaux de trésorerie un menu de recherche, vous permettra de retrouver rapidement l\'opération qui vous intéresse');
$menu[]=_('Rapprochement'); $desc[]=_('Impression des rapprochements');$desc_long[]=_('Impression des rapprochements : opérations non rapprochées ou avec des montants différents');
@ -134,8 +136,16 @@ $menu[]=_('Export Balance agée'); $desc[]=_('Balance agée');$desc_long[]=_('B
$menu[]=_('Exporte la pièce');
$menu[]=_('Export le document');
$menu[]=_('Exporte le modèle de document');
$menu[]=_('Devises'); $desc[]=_('Configuration des devises');$desc_long[]=_('Permet de configurer les devises');
$menu[]=_('Export ANC');
$menu[]=_('Résumé TVA'); $desc[]=_('totaux par TVA et par journal');$desc_long[]=_('Calcul des totaux par TVA et par journal');
$menu[]=_('Export Résumé TVA');
$menu[]=_('Export Résumé TVA');
Time: 1,027 ms
?>
<?php
Timing is on.
Autocommit is OFF
$attr_def[]=_('Durée Amortissement');
$attr_def[]=_('Montant initial');
$attr_def[]=_('TVA non déductible');
@ -143,8 +153,6 @@ $attr_def[]=_('TVA non déductible récupérable par l\'impôt');
$attr_def[]=_('Partie fiscalement non déductible');
$attr_def[]=_('Dépense charge du grant (partie privé) ');
$attr_def[]=_('Compte bancaire');
$attr_def[]=_('Prix vente');
$attr_def[]=_('Prix achat');
$attr_def[]=_('Date début');
$attr_def[]=_('Nom');
$attr_def[]=_('Taux TVA');
@ -170,9 +178,14 @@ $attr_def[]=_('Contrepartie pour dépense fiscal. non déd.');
$attr_def[]=_('Poste Comptable');
$attr_def[]=_('Date Fin');
$attr_def[]=_('Gestion stock');
$attr_def[]=_('Prix vente');
$attr_def[]=_('Prix achat');
$attr_def[]=_('Société');
Time: 1,164 ms
?>
<?php
Timing is on.
Autocommit is OFF
$document_type[]=_('Document Interne');
$document_type[]=_('Bons de commande client');
$document_type[]=_('Bon de commande Fournisseur');
@ -186,8 +199,11 @@ $document_type[]=_('Note de frais');
$document_type[]=_('Réception commande Fournisseur');
$document_type[]=_('Réception commande Client');
$document_type[]=_('Réception magazine');
Time: 1,120 ms
?>
<?php
Timing is on.
Autocommit is OFF
$action[]=_('Ajout de fiche');
$action[]=_('Création, modification et effacement de fiche');
$action[]=_('création, modification et effacement de catégorie de fiche');
@ -199,26 +215,52 @@ $action[]=_('Effacer une opération ');
$action[]=_('Partager une note');
$action[]=_('Créer une note publique');
$action[]=_('Effacer une note publique');
Time: 0,661 ms
?>
<?php
Timing is on.
Autocommit is OFF
$mdp[]=_('Caisse');
$mdp[]=_('Paiement électronique');
$mdp[]=_('Caisse');
$mdp[]=_('Par gérant ou administrateur');
Time: 1,068 ms
?>
<?php
$jrn_def_name[]=_('Achat');
$jrn_def_name[]=_('Financier');
Timing is on.
Autocommit is OFF
$jrn_def_name[]=_('Opération Diverses');
$jrn_def_name[]=_('Financier');
$jrn_def_name[]=_('Vente');
$jrn_def_name[]=_('Achat');
$jrn_def_name[]=_('Note de crédit');
Time: 1,213 ms
?>
<?php
$jrn_def_description[]=_('Concerne tous les achats, factures reçues, notes de crédit reçues et notes de frais');
$jrn_def_description[]=_('Concerne tous les mouvements financiers (comptes en banque, caisses, visa...)');
Timing is on.
Autocommit is OFF
$jrn_def_description[]=_('Concerne toutes les opérations comme les amortissements, les comptes TVA, ...');
$jrn_def_description[]=_('Concerne tous les mouvements financiers (comptes en banque, caisses, visa...)');
$jrn_def_description[]=_('Concerne toutes les ventes, notes de crédit envoyées');
$jrn_def_description[]=_('Concerne tous les achats, factures reçues, notes de crédit reçues et notes de frais');
Time: 0,806 ms
?>
<?php
Timing is on.
Autocommit is OFF
$jrn_type[]=_('Financier');
$jrn_type[]=_('Vente');
$jrn_type[]=_('Achat');
$jrn_type[]=_('Opérations Diverses');
Time: 0,523 ms
?>
Timing is on.
Autocommit is OFF
\jrn_def_negative_warning[]=_('Attention, ce journal doit utiliser des montants négatifs');
\jrn_def_negative_warning[]=_('Attention, ce journal doit utiliser des montants négatifs');
\jrn_def_negative_warning[]=_('WARNING ! WARNING !');
\jrn_def_negative_warning[]=_('Attention, ce journal doit utiliser des montants négatifs');
\jrn_def_negative_warning[]=_('Attention, ce journal doit utiliser des montants négatifs');
Time: 1,223 ms
?>

View file

@ -20,7 +20,7 @@
// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
require_once NOALYSS_INCLUDE.'/lib/database.class.php';
require_once NOALYSS_INCLUDE.'/class/database.class.php';
/**
* class_currency_history_sql.php

View file

@ -20,7 +20,7 @@
// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
require_once NOALYSS_INCLUDE.'/lib/database.class.php';
require_once NOALYSS_INCLUDE.'/class/database.class.php';
/**
* class_currency_sql.php

View file

@ -1,5 +1,7 @@
<?php
/*
/**
* Autogenerated file
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
@ -16,411 +18,77 @@
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@aevalys.eu
/**
* @file
* @brief Manage the table public.jrn_def
*
*
Example
@code
@endcode
*/
require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
require_once NOALYSS_INCLUDE.'/class/database.class.php';
require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
/**
* @brief Manage the table public.jrn_def
*/
class Jrn_Def_sql
* class_jrn_def_sql.php
*
* @file
* @brief abstract of the table public.jrn_def */
class Jrn_def_SQL extends Noalyss_SQL
{
/* example private $variable=array("easy_name"=>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"
, "jrn_enable"=>"jrn_enable"
, "currency_id"=>"currency_id"
);
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;
$this->default=array(
"jrn_def_id"=>"auto");
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->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
,currency_id
) values ($1
,$2
,$3
,$4
,$5
,$6
,$7
,$8
,$9
,$10
,$11
,$12
,$13
,$14
,$15
,$16
) 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)
, $this->currency_id
)
);
}
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
,$17
) returning jrn_def_id";
$this->jrn_def_id = $this->db->get_value(
$sql, array(
$this->jrn_def_name // 1
, $this->jrn_def_class_deb // 2
, $this->jrn_def_class_cred // 3
, $this->jrn_def_fiche_deb // 4
, $this->jrn_def_fiche_cred // 5
, $this->jrn_deb_max_line // 6
, $this->jrn_cred_max_line // 7
, $this->jrn_def_ech // 8
, $this->jrn_def_ech_lib // 9
, $this->jrn_def_type // 10
, $this->jrn_def_code // 11
, $this->jrn_def_pj_pref // 12
, $this->jrn_def_bank // 13
, $this->jrn_def_num_op // 14
, $this->jrn_def_id // 15
, strip_tags($this->jrn_def_description)) // 16
, $this->currency_id // 17
);
}
}
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
, currency_id = $18
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
, $this->currency_id
)
);
}
/**
* @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
,currency_id
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();
?>

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
require_once NOALYSS_INCLUDE.'/lib/database.class.php';
require_once NOALYSS_INCLUDE.'/class/database.class.php';
/**
* class_operation_currency_sql.php

View file

@ -20,7 +20,7 @@
// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
require_once NOALYSS_INCLUDE.'/lib/database.class.php';
require_once NOALYSS_INCLUDE.'/class/database.class.php';
/**
* class_currency_history_sql.php

View file

@ -0,0 +1,83 @@
<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@noalyss.eu
/**
* @file
* @brief
*
*/
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
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"));
$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();
}

View file

@ -0,0 +1,353 @@
<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@noalyss.eu
/**
* @file
* @brief export PDF
*
*/
if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
require_once NOALYSS_INCLUDE . "/class/tax_summary.class.php";
require_once NOALYSS_INCLUDE . '/class/user.class.php';
require_once NOALYSS_INCLUDE . '/class/pdf_land.class.php';
require_once NOALYSS_INCLUDE . '/lib/http_input.class.php';
bcscale(4);
$http = new HttpInput();
$from_periode = $http->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');

View file

@ -728,7 +728,7 @@ class DatabaseCore
/**\brief wrapper for the function pg_fetch_all
* \param $ret is the result of pg_exec (exec_sql)
* \return double array (row x col )
* \return double array (row x col ) or false
*/
static function fetch_all($ret)

View file

@ -1098,9 +1098,9 @@ class HtmlInput
*/
static function button_action_remove_operation($p_operation)
{
$rmOperation=sprintf("javascript:confirm_box(null,'"._('Voulez-vous effacer cette relation ')."',function () {remove_operation('%s','%s');});",
$rmOperation=sprintf("confirm_box(null,'"._('Voulez-vous effacer cette relation ')."',function () {remove_operation('%s','%s');});",
dossier::id(), $p_operation);
$js='<a class="tinybutton" id="acop'.$p_operation.'" href="javascript:void(0)" onclick="'.$rmOperation.'">'.SMALLX.'</a>';
$js=Icon_Action::trash("acop".$p_operation, $rmOperation);
return $js;
}

View file

@ -88,7 +88,21 @@ class Icon_Action
return $r;
}
/**
* Display a info in a bubble, text is given as parameter
* @param string $p_comment
*
* @return html string
*/
static function tips($p_comment)
{
$p_comment=htmlentities($p_comment);
$r='<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="displayBulle(\''.$p_comment.'\')" onclick="displayBulle(\''.$p_comment.'\')" onmouseout="hideBulle(0)">';
$r.="&#xf086;";
$r.='</span>';
return $r;
}
/**
* Display a icon ON
* @param string $p_div id of element
@ -283,5 +297,14 @@ class Icon_Action
*/
static function unlock($p_id,$p_javascript)
{
$lock_cur="&#xe832;";
$r=sprintf( '<span id="%s" is_locked="0" onclick="toggle_lock(\'%s\');%s" class="icon smallicon">%s</span>',
$p_id,
$p_id,
$p_javascript,
$lock_cur);
return $r;
}
}

View file

@ -0,0 +1,81 @@
<?php
/*
* * Copyright (C) 2019 Dany De Bontridder <dany@alchimerys.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Aut
*
*/
// Copyright Author Dany De Bontridder danydb@noalyss.eu
/**
* @file
* @brief show a switch, when you click on it an hidden field is changed, the value is 1 or 0
*/
require_once NOALYSS_INCLUDE.'/lib/html_input.class.php';
class InputSwitch extends HtmlInput
{
var $icon;
var $value_container;
var $value;
function __construct($name='', $value='', $p_id="")
{
$this->value_container=$name;
$this->value=$value;
$this->icon=$p_id;
$this->javascript="";
}
function input($p_name=NULL, $p_value=NULL)
{
if ($p_name!=NULL)
$this->value_container=$p_name;
if ($p_value!==NULL)
$this->value=$p_value;
if ( $this->icon=="") $this->icon=uniqid ("inputSwitch");
if ( trim($this->value_container) ==="" || trim($this->value) === "") {
throw new Exception(_("Valeur invalide"),1);
}
if ($this->readOnly == TRUE) {
$this->display();
return;
}
echo HtmlInput::hidden($this->value_container, $this->value);
$this->javascript=sprintf('toggle_onoff(\'%s\',\'%s\');%s;',$this->icon,$this->value_container,$this->javascript);
if ($this->value=='1') {
echo Icon_Action::iconon($this->icon, $this->javascript);
} else {
echo Icon_Action::iconoff($this->icon, $this->javascript);
}
}
function display()
{
if ($this->value=='1') {
echo Icon_Action::iconon($this->icon, "");
} else {
echo Icon_Action::iconoff($this->icon, "");
}
}
}

View file

@ -838,7 +838,6 @@ function check()
{
echo td("--");
}
}
} elseif ($this->get_col_type($v)=="custom") {
// For custom col
echo td($this->display_row_custom($v,$p_row[$v]));

View file

@ -103,5 +103,5 @@ content[69]="<?php echo escape_xml(_("Aucune donnée"))?>";
content[70]="<?php echo escape_xml(_("Votre demande est en cours de traitement"))?>";
content[71]="<?php echo _('Limite le type de fiche si vous choisissez la fiche à la saisie, uniquement avec journaux OD');?>";
content[72]="<?php echo _("Pour les journaux FIN, ce sera la fiche du journal");?>";
content[73]="<?php echo _("Mettre à oui pour un journal dédié uniquement aux notes de crédit ou de débit, il affichera un avertissement si le montant n'est pas en négatif");?>";
</script>

View file

@ -111,7 +111,8 @@ if (isset($_POST["FMOD_NAME"]))
if (Database::num_row($Res) != 0)
{
$a_lob = Database::fetch_all($Res);
for ($i = 0; $i < count($a_lob); $i++)
$nb_log=($a_lob == FALSE)?0:count($a_lob);
for ($i = 0; $i < $nb_lob; $i++)
$cn_mod->lo_unlink($a_lob[$i]['jr_pj']);
}
$Res = $cn_mod->exec_sql("truncate table centralized");

View file

@ -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();
}
}

View file

@ -8,16 +8,16 @@ select me_code,'PRINT',1,250,'E',0,6 from menu_ref where me_code='PRINTTVA'
union
select me_code,'PRINT',1,250,'E',0,35 from menu_ref where me_code='PRINTTVA'
union
select me_code,'PRINT',2,250,'E',0,719 from menu_ref where me_code='PRINTTVA'
select me_code,'PRINT',2,250,'E',0,719 from menu_ref where me_code='PRINTTVA' and exists (select 1 from profile where p_id=2)
union
select me_code,'PRINT',2,250,'E',0,716 from menu_ref where me_code='PRINTTVA'
select me_code,'PRINT',2,250,'E',0,716 from menu_ref where me_code='PRINTTVA' and exists (select 1 from profile where p_id=2)
;
insert into menu_ref (me_code,me_menu,me_file,me_type)
values ('CSV:printtva','Export Résumé TVA','export_printtva_csv.php','PR'),
('PDF:printtva','Export Résumé TVA','export_printtva_pdf.php','PR')
;
insert into profile_menu(me_code,p_id,p_type_display) values ('CSV:printtva',1,'P'),('PDF:printtva',1,'P'),('CSV:printtva',2,'P'),('PDF:printtva',2,'P');
insert into profile_menu(me_code,p_id,p_type_display) select 'CSV:printtva',p_id,'P' from profile where p_id in (1,2) union all select 'PDF:printtva',p_id,'P' from profile where p_id in (1,2);
insert into version (val,v_description) values (136,'new feature PRINTTVA');
commit ;

View file

@ -0,0 +1,15 @@
begin;
alter table jrn_def add column jrn_def_negative_amount char(1) default '0';
update jrn_def set jrn_def_negative_amount = '0';
alter table jrn_def add constraint negative_amount_ck check (jrn_def_negative_amount in ('1','0'));
alter table jrn_def alter jrn_def_negative_amount set not null;
comment on column jrn_def.jrn_def_negative_amount is '1 echo a warning if you are not using an negative amount, default 0 for no warning';
alter table jrn_def add column jrn_def_negative_warning text;
update jrn_def set jrn_def_negative_warning = 'Attention, ce journal doit utiliser des montants négatifs';
comment on column jrn_def.jrn_def_negative_warning is 'Yell a warning if the amount if not negative , in the case of jrn_def_negative_amount is Y';
insert into version (val,v_description) values (137,'Ledger warning');
commit ;

View file

@ -0,0 +1,72 @@
<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@noalyss.eu
/**
* @file
* @brief display summary of tax (VAT) possible parameter is time range
*
*/
require_once NOALYSS_INCLUDE.'/class/tax_summary.class.php';
$http = new HttpInput();
$limit = $g_user->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 '<FORM METHOD="GET">';
echo HtmlInput::array_to_hidden(['gDossier','ac'],$_GET);
echo HtmlInput::hidden("do","display");
printf(_("Période du %s au %s"),
$start_periode->input(),
$end_periode->input());
echo HtmlInput::submit("show_tax_summary",_("Afficher"));
echo '</FORM>';
echo '<hr>';
if ( $http->get("do","string","no") == "display")
{
$tax_summary=new Tax_Summary($cn,$start_periode->value,$end_periode->value);
try {
$tax_summary->check();
echo '<ul class="aligned-block">';
echo '<li>';
echo $tax_summary->form_export_csv();
echo '</li>';
echo '<li>';
echo $tax_summary->form_export_pdf();
echo '</li>';
echo '</ul>';
$tax_summary->display();
echo '<ul class="aligned-block">';
echo '<li>';
echo $tax_summary->form_export_csv();
echo '</li>';
echo '<li>';
echo $tax_summary->form_export_pdf();
echo '</li>';
echo '</ul>';
} catch (Exception $e) {
echo $e->getMessage();
}
}

View file

@ -138,7 +138,7 @@ $a_detail=Database::fetch_all($det);
<th class="num"><?=_("TVAC")?></th>
</tr>
<?php
$nb_detail=count($a_detail);
$nb_detail=($a_detail == FALSE)?0 : count($a_detail);
for ($j=0;$j<$nb_detail;$j++):
?>
<tr >

View file

@ -189,11 +189,8 @@ if ($aRap != null ) {
// If write access , allow to drop Reconciles operations
if ( $access=='W') {
$rmReconciliation=new IButton('rmr');
$rmReconciliation->label=SMALLX;
$rmReconciliation->class="tinybutton";
$rmReconciliation->javascript="return confirm_box(null,'"._("vous confirmez?")."',";
$rmReconciliation->javascript.=sprintf('function () { dropLink(\'%s\',\'%s\',\'%s\',\'%s\');deleteRowRec(\'%s\',$(\'row%d\'));})',
$js="return confirm_box(null,'"._("vous confirmez?")."',";
$js.=sprintf('function () { dropLink(\'%s\',\'%s\',\'%s\',\'%s\');deleteRowRec(\'%s\',$(\'row%d\'));})',
$gDossier,
$div,
$jr_id,
@ -201,8 +198,8 @@ if ($aRap != null ) {
$tableid,
$e
);
$remove=$rmReconciliation->input();
$remove=Icon_Action::trash(uniqid(), $js);
// $remove=$rmReconciliation->input();
}
else
$remove='';

View file

@ -7,13 +7,6 @@
<TD>
<?php echo $type;?>
</TD>
</TR>
<TR>
<TD><?php echo _('Type de journal')?> </TD>
<TD>
<?php echo $type;?>
</TD>
</TR>
<TR>
@ -23,10 +16,13 @@
<td></td>
</TR>
<?php
//---------------------------------------------------------------------------------------------------------------
//ODS
//---------------------------------------------------------------------------------------------------------------
if ( $new || $type=='ODS' ):
?>
<TR id="type_ods">
<td><?php echo _('Postes utilisables journal (débit/crédit) ')?>
<td style="white-space: nowrap"><?php echo _('Postes utilisables journal (débit/crédit) ')?>
</TD>
<td>
<?php echo $search;?>
@ -40,46 +36,87 @@ if ( $new || $type=='ODS' ):
endif;
?>
<?php
if ( $new|| $type=='FIN') {
//---------------------------------------------------------------------------------------------------------------
//FIN
//---------------------------------------------------------------------------------------------------------------
if ( $new|| $type=='FIN') :
?>
<tr id="type_fin">
<td>
<?php echo _('Numérotation de chaque opération')?>
</td>
<td>
<?php echo $num_op->input();?>
</td>
</tr>
<tr id="type_fin2">
<TD>
<?php echo _('Compte en banque')?>
</td>
<TD>
<?php
$card=new ICard();
$card->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);
<tr id="type_fin">
<td style="white-space: nowrap">
<?php echo _('Numérotation de chaque opération')?>
</td>
<td>
<?php echo $num_op->input();?>
</td>
</tr>
<tr id="type_fin2">
<TD style="white-space: nowrap">
<?php echo _('Compte en banque')?>
</td>
<TD>
<?php
$card=new ICard();
$card->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;
?>
</td>
<td class="notice" style="white-space: nowrap">
<?php echo _("Obligatoire pour les journaux FIN : donner ici la fiche du compte en banque utilisée")?>
</td>
</tr>
<?php
endif;
?>
</td>
<td class="notice">
<?php echo _("Obligatoire pour les journaux FIN : donner ici la fiche du compte en banque utilisée")?>
</td>
<?php
}
//---------------------------------------------------------------------------------------------------------------
//ACH / VEN
//---------------------------------------------------------------------------------------------------------------
if ( $type == 'ACH' || $type == 'VEN'||$new):
// Display the warning : always used negative amounts
?>
<tr id="neg_amount">
<td style="white-space: nowrap">
<?php
echo _("Uniquement note de débit ou crédit");
echo Icon_Action::warnbulle(73);
?>
</td>
<td>
<?php
$negative->javascript="toggle_row_warning_enable('negative_amount','row_warning')";
$negative->input();
?>
</td>
</tr>
<tr id="row_warning">
<td style="white-space: nowrap">
<?php echo _("Avertissement montant positif"); ?>
</td>
<td>
<?php echo $negative_warning->input();?>
</td>
</tr>
<?php
endif;
?>
</TR>
<tr>
<td><?php echo _("Minimum de lignes à afficher")?></td>
<td style="white-space: nowrap"><?php echo _("Minimum de lignes à afficher")?></td>
<td><?php echo $min_row->input()?></td>
</tr>
<tr>
@ -110,32 +147,33 @@ echo $str_add_button;
</TR>
<?php if ( $new == 0 ) : ?>
<TR>
<TD>
<?php echo _('Dernière pièce numérotée')?>
<?php echo Icon_Action::infobulle(40);?>
</TD>
<TD>
<?php echo $last_seq?>
</TD>
</TR>
<TR>
<TD>
<?php echo _('Dernière pièce numérotée')?>
<?php echo Icon_Action::infobulle(40);?>
</TD>
<TD>
<?php echo $last_seq?>
</TD>
</TR>
<tr>
<TD><?php echo _('N° pièce justificative')?>
<?php echo Icon_Action::infobulle(38);?>
</TD>
<TD>
<?php echo $pj_seq; ?>
</TD>
</tr>
<tr>
<td>
<?=_("Journal actif")?>
</td>
<td>
<?=$actif->input()?>
</td>
<tr>
<TD><?php echo _('N° pièce justificative')?>
<?php echo Icon_Action::infobulle(38);?>
</TD>
<TD>
<?php echo $pj_seq; ?>
</TD>
</tr>
<tr>
<td>
<?=_("Journal actif")?>
</td>
<td>
<?=$actif->input()?>
</td>
</TR>
<?php endif; ?>
<?php
@ -388,6 +426,8 @@ endif;
$('type_fin').style.display='none';
$('type_fin2').style.display='none';
$('type_fin3').style.display='none';
$('neg_amount').style.display='none';
$('row_warning').style.display='none';
}
function show_ledger_div()
{
@ -405,6 +445,19 @@ endif;
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();
}
@ -420,3 +473,10 @@ endif;
?>
</script>
<?php endif; ?>
<?php if ( $type=="ACH" || $type=="VEN") :?>
<script>
toggle_row_warning_enable('negative_amount','row_warning');
</script>
<?php
endif;
?>

View file

@ -0,0 +1,375 @@
<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@noalyss.eu
/**
* @file
* @brief display the tax summary result
* @see Tax_Summary
*
*/?>
<h2><?php echo _("Vente")?></h2>
<?php
bcscale(4);
$array=$this->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 '<tr class="highlight">';
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 '</tr>';
echo '</table>';
endif;
$ledger=$array[$i]['jrn_def_name'];
//reinitialize sum
$tot_vat=0;$tot_wovat=0;$tot_sided=0;
printf("<h3>%s</h3>",$ledger);
echo '<table class="result">';
echo '<tr>';
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 '</tr>';
$r=0;
endif;
$color=($r%2==0)?"even":"odd";
?>
<tr class="<?php echo $color;?>">
<td>
<?=$array[$i]['tva_label']?>
</td>
<td>
<?=$array[$i]['tva_rate']*100?>%
</td>
<td class="num">
<?=nbm($array[$i]['amount_wovat'])?>
</td>
<td class="num">
<?=nbm($array[$i]['amount_vat'])?>
</td>
<td class="num">
<?=nbm($array[$i]['amount_sided'])?>
</td>
</tr>
<?php
$tot_vat=bcadd($tot_vat,$array[$i]['amount_vat']);
$tot_wovat=bcadd($tot_wovat,$array[$i]['amount_wovat']);
$tot_sided=bcadd($tot_sided,$array[$i]['amount_sided']);
?>
<?php endfor;?>
<?php
if ( $nb_array > 0):
// last row with total
echo '<tr class="highlight">';
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 '</tr>';
else:
echo _("Aucune donnée");
endif;
echo '</table>';
?>
<h3><?=_("Résumé tous les journaux de vente")?></h3>
<?php
$a_sum=$this->get_summary_sale();
?>
<table class="result">
<tr>
<th>
<?=_("Code TVA")?>
</th>
<th>
<?=_("Taux")?>
</th>
<th class="num">
<?=_("Montant HT")?>
</th>
<th class="num">
<?=_("Montant TVA")?>
</th>
<th class="num">
<?=_("Montant Autoliquidation")?>
</th>
</tr>
<?php
$nb_sum=count($a_sum);
$tot_vat=0;$tot_wovat=0;$tot_sided=0;
for ($e=0;$e < $nb_sum ; $e++):
$tot_vat=bcadd($tot_vat,$a_sum[$e]['amount_vat']);
$tot_wovat=bcadd($tot_wovat,$a_sum[$e]['amount_wovat']);
$tot_sided=bcadd($tot_sided,$a_sum[$e]['amount_sided']);
?>
<tr>
<td>
<?=$a_sum[$e]['tva_label']?>
</td>
<td class="num">
<?=$a_sum[$e]['tva_rate']*100?>%
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_wovat'])?>
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_vat'])?>
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_sided'])?>
</td>
</tr>
<?php
endfor;
echo '<tr class="highlight">';
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 '</tr>';
?>
</table>
<?php
$array = $this->get_summary_sale();
?>
<h2><?php echo _("Achat")?></h2>
<?php
$array=$this->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 '<tr class="highlight">';
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 '</tr>';
echo '</table>';
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("<h3>%s</h3>",$ledger);
echo '<table class="result">';
echo '<tr>';
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 '</tr>';
$r=0;
endif;
$color=($r%2==0)?"even":"odd";
?>
<tr class="<?php echo $color;?>">
<td>
<?=$array[$i]['tva_label']?>
</td>
<td>
<?=$array[$i]['tva_rate']*100?>%
</td>
<td class="num">
<?=nbm($array[$i]['amount_wovat'])?>
</td>
<td class="num">
<?=nbm($array[$i]['amount_private'])?>
</td>
<td class="num">
<?=nbm($array[$i]['amount_vat'])?>
</td>
<td class="num">
<?=nbm($array[$i]['amount_sided'])?>
</td>
<td class="num">
<?=nbm($array[$i]['amount_noded_amount'])?>
</td>
<td class="num">
<?=nbm($array[$i]['amount_noded_tax'])?>
</td>
<td class="num">
<?=nbm($array[$i]['amount_noded_return'])?>
</td>
</tr>
<?php
$tot_vat=bcadd($tot_vat,$array[$i]['amount_vat']);
$tot_wovat=bcadd($tot_wovat,$array[$i]['amount_wovat']);
$tot_sided=bcadd($tot_sided,$array[$i]['amount_sided']);
$tot_noded_amount=bcadd($tot_noded_amount,$array[$i]['amount_noded_amount']);
$tot_noded_tax=bcadd($tot_noded_tax,$array[$i]['amount_noded_tax']);
$tot_noded_return=bcadd($tot_noded_return,$array[$i]['amount_noded_return']);
$tot_private=bcadd($tot_private,$array[$i]['amount_private']);
?>
<?php endfor;?>
<?php
// last row with total
if ( $nb_array > 0):
echo '<tr class="highlight">';
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 '</tr>';
else:
echo _("Aucune donnée");
endif;
echo '</table>';
?>
<h3><?=_("Résumé tous les journaux d'achat")?></h3>
<?php
$a_sum=$this->get_summary_purchase();
?>
<table class="result">
<tr>
<th>
<?=_("Code TVA")?>
</th>
<th>
<?=_("Taux")?>
</th>
<th class="num">
<?=_("Montant HT")?>
</th>
<th class="num">
<?=_("Privée")?>
</th>
<th class="num">
<?=_("Montant TVA")?>
</th>
<th class="num">
<?=_("Montant Autoliquidation")?>
</th>
<th class="num">
<?=_("Montant Non Déd")?>
</th>
<th class="num">
<?=_("TVA Non Déd")?>
</th>
<th class="num">
<?=_("TVA Non Déd & récup")?>
</th>
</tr>
<?php
$nb_sum=count($a_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;
for ($e=0;$e < $nb_sum ; $e++):
?>
<tr>
<td>
<?=$a_sum[$e]['tva_label']?>
</td>
<td class="num">
<?=$a_sum[$e]['tva_rate']*100?>%
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_wovat'])?>
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_private'])?>
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_vat'])?>
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_sided'])?>
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_noded_amount'])?>
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_noded_tax'])?>
</td>
<td class="num">
<?=nbm($a_sum[$e]['amount_noded_return'])?>
</td>
</tr>
<?php
$tot_vat=bcadd($tot_vat,$a_sum[$e]['amount_vat']);
$tot_wovat=bcadd($tot_wovat,$a_sum[$e]['amount_wovat']);
$tot_sided=bcadd($tot_sided,$a_sum[$e]['amount_sided']);
$tot_noded_amount=bcadd($tot_noded_amount,$a_sum[$e]['amount_noded_amount']);
$tot_noded_tax=bcadd($tot_noded_tax,$a_sum[$e]['amount_noded_tax']);
$tot_noded_return=bcadd($tot_noded_return,$a_sum[$e]['amount_noded_return']);
$tot_private=bcadd($tot_private,$a_sum[$e]['amount_private']);
endfor;
echo '<tr class="highlight">';
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 '</tr>';
?>
</table>

View file

@ -66,7 +66,7 @@ order by jrn_def_name
$res=$cn->exec_sql($sql);
$jrn=Database::fetch_all($res);
$nb_jrn= count($jrn);
$nb_jrn= ($jrn == FALSE) ?0 :count($jrn);
if ( $jrn ===false ) {
echo $g_succeed." "._("Aucune anomalie dans les montants des journaux");
}
@ -158,7 +158,8 @@ having count(*) > 1
$poste=$cn->execute('get_poste',array($a_fiche_id[$i]['f_id']));
$tmp_qcode=$cn->execute('get_qcode',array($a_fiche_id[$i]['f_id']));
$qcode=Database::fetch_all($tmp_qcode);
if ( $qcode[0]['qcode']=="") {
if ( $qcode == FALSE || $qcode[0]['qcode']=="") {
continue;
}
?>
@ -171,7 +172,8 @@ having count(*) > 1
</li>
<ul>
<?php $all_dep=Database::fetch_all($poste);
for ($e=0;$e<count($all_dep);$e++):
$nb_dep = ($all_dep == FALSE ) ? 0 :count($all_dep);
for ($e=0;$e<count($nb_dep);$e++):
?>
<li>
<?php echo HtmlInput::history_account($all_dep[$e]['j_poste'],$all_dep[$e]['j_poste'],' display:inline ')?>
@ -229,7 +231,7 @@ $nb_account_used=count ($a_account_used);
<?php
$ret_operation=$cn->execute('get_operation',array($a_account_used[$i]['f_id']));
$a_operation=Database::fetch_all($ret_operation);
$nb_operation=count($a_operation);
$nb_operation=($a_operation == FALSE) ? 0 : count($a_operation);
?>
<table class="result">
<?php for ($x=0;$x<$nb_operation;$x++):?>

View file

@ -0,0 +1,91 @@
<?php
//@description: Test the HtmlInput object it means the Inum, IText , ...
/*
* * Copyright (C) 2019 Dany De Bontridder <dany@alchimerys.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/**
* @file
* @brief Test the HtmlInput object it means the Inum, IText , ...
*/
require_once NOALYSS_INCLUDE.'/lib/html_input.class.php';
require_once NOALYSS_INCLUDE.'/lib/iaction.class.php';
require_once NOALYSS_INCLUDE.'/lib/ibutton.class.php';
require_once NOALYSS_INCLUDE.'/lib/icard.class.php';
require_once NOALYSS_INCLUDE.'/lib/icheckbox.class.php';
require_once NOALYSS_INCLUDE.'/lib/iconcerned.class.php';
require_once NOALYSS_INCLUDE.'/lib/idate.class.php';
require_once NOALYSS_INCLUDE.'/lib/ifile.class.php';
require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php';
require_once NOALYSS_INCLUDE.'/lib/inum.class.php';
require_once NOALYSS_INCLUDE.'/lib/iperiod.class.php';
require_once NOALYSS_INCLUDE.'/lib/iposte.class.php';
require_once NOALYSS_INCLUDE.'/lib/iradio.class.php';
require_once NOALYSS_INCLUDE.'/lib/irelated_action.class.php';
require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
require_once NOALYSS_INCLUDE.'/lib/ispan.class.php';
require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
require_once NOALYSS_INCLUDE.'/lib/itextarea.class.php';
require_once NOALYSS_INCLUDE.'/lib/itva_popup.class.php';
require_once NOALYSS_INCLUDE.'/lib/input_switch.class.php';
$http=new HttpInput();
?>
<pre>
<?php var_dump($_GET);?>
</pre>
<form method="GET">
<?php echo Dossier::hidden();?>
<?php echo HtmlInput::hidden("script",basename(__FILE__));?>
<h1>Input_switch.class.php</h1>
<h2>Normal</h2>
<pre>
$input_switch=new InputSwitch('input_switch_value',<?php echo $http->get("input_switch_value","string","0")?>);
$input_switch->input();
</pre>
input_switch
<?php
$input_switch=new InputSwitch('input_switch_value',$http->get("input_switch_value","string","0"));
$input_switch->input();
?>
<h2>ReadOnly</h2>
<pre>
$input_switch=new InputSwitch('input_switch_readonly',0);
$input_switch->readOnly=TRUE;
$input_switch->input();
</pre>
input_switch
<?php
$input_switch=new InputSwitch('input_switch_readonly',0);
$input_switch->readOnly=TRUE;
$input_switch->input();
?>
<h1>Submit</h1>
<pre>
echo HtmlInput::submit("submit", _("Envoi"));
</pre>
<p>
<?php echo HtmlInput::submit("submit", _("Envoi"));?>
</p>
</form>

View file

@ -68,12 +68,13 @@ include_once NOALYSS_INCLUDE."/lib/icon_action.class.php";
<p>
more <?php echo Icon_Action::more(uniqid(), "alert('test')");?>
</p>
<p>
menu <?php echo Icon_Action::menu(uniqid(), "alert('test')");?>
</p>
<p>
Lock <?php echo Icon_Action::lock(uniqid(), "alert('test')");?>
</p>
<p>
Unlock <?php echo Icon_Action::unlock(uniqid(), "alert('test')");?>
</p>
<p>
Tips <?php echo Icon_Action::tips("Allo ?")?>
</p>

View file

@ -51,6 +51,7 @@ class Acc_AccountTest extends TestCase
public function testSet_parameter()
{
$this->object->set_parameter("pcm_direct_use", "N");
$this->assertEquals($this->object->get_parameter("pcm_direct_use"),"N");
}
/**
@ -66,7 +67,8 @@ class Acc_AccountTest extends TestCase
*/
public function testLoad()
{
$this->object->load();
$r=$this->object->load();
$this->assertNotEquals($r,-1);
}
/**
@ -83,7 +85,61 @@ class Acc_AccountTest extends TestCase
*/
public function testVerify()
{
$this->object->verify();
global $g_connection;
// duplicate
$duplicate=new Acc_Account($g_connection);
$duplicate->set_parameter('pcm_val', "400");
$duplicate->set_parameter("pcm_lib", "duplicate");
$duplicate->set_parameter("pcm_val_parent", "40");
$duplicate->set_parameter("pcm_direct_use", "N");
try {
$duplicate->insert();
} catch (Exception $ex) {
$this->assertEquals($ex->getCode(),EXC_DUPLICATE);
}
$duplicate->set_parameter('pcm_val','999TEST');
try {
$duplicate->set_parameter("pcm_lib", "");
$duplicate->insert();
} catch (Exception $ex) {
$this->assertEquals($ex->getCode(),EXC_PARAM_VALUE);
}
$duplicate->set_parameter("pcm_lib", "duplicate");
try {
$duplicate->set_parameter("pcm_val_parent", "999TEST");
$duplicate->insert();
} catch (Exception $ex) {
$this->assertEquals($ex->getCode(),EXC_PARAM_VALUE);
}
try {
$duplicate->set_parameter("pcm_val_parent", "xxx");
$duplicate->insert();
} catch (Exception $ex) {
$this->assertEquals($ex->getCode(),EXC_PARAM_VALUE);
}
$duplicate->set_parameter("pcm_val_parent", "9");
try {
$duplicate->set_parameter("pcm_direct_use", "?");
$duplicate->insert();
} catch (Exception $ex) {
$this->assertEquals($ex->getCode(),EXC_PARAM_VALUE);
}
$duplicate->set_parameter("pcm_direct_use", "Y");
try {
$duplicate->set_parameter('pcm_val','');
$duplicate->insert();
} catch (Exception $ex) {
$this->assertEquals($ex->getCode(),EXC_PARAM_VALUE);
}
$duplicate->set_parameter('pcm_val','999TEST');
$duplicate->insert();
$duplicate->delete();
}
/**
@ -91,7 +147,17 @@ class Acc_AccountTest extends TestCase
*/
public function testUpdate()
{
global $g_connection;
$new_string="000001112222";
$old_label=$this->object->get_lib();
$this->object->set_parameter("pcm_lib", $new_string);
$this->object->update();
$check=new Acc_Account($g_connection,$this->object->get_parameter("pcm_val"));
$this->assertEquals($check->get_parameter("pcm_lib"),$new_string);
$check->set_parameter("pcm_lib", $old_label);
$check->update();
$this->object->load();
$this->assertEquals($this->object->get_lib(),$old_label);
}
/**
@ -133,7 +199,6 @@ class Acc_AccountTest extends TestCase
}
catch (Exception $e)
{
echo $e->getTraceAsString();
$this->assertEquals($e->getCode(), EXC_PARAM_VALUE);
}
}
@ -143,7 +208,21 @@ class Acc_AccountTest extends TestCase
*/
public function testSave()
{
$this->object->save();
global $g_connection;
$check=new Acc_Account($g_connection,'999TEST');
$check->set_parameter("pcm_lib", "TESTING");
$check->set_parameter('pcm_val_parent','9');
$check->set_parameter('pcm_direct_use','N');
// insert
$check->save();
$check_new=new Acc_Account($g_connection,'999TEST');
$this->assertEquals($check_new->get_lib(),$check->get_lib());
$check->set_parameter("pcm_lib","NEW VALUE");
// update
$check->save();
$check_new->load();
$this->assertNotEquals($check_new->get_lib(),"TESTING");
$check->delete();
}
}

View file

@ -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);
}
/**

View file

@ -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('<p class="notice"> warning<ol class="notice"><li>First Line</li><li>Second Line</li></ol></p>',$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('<div id="payment">',$r);
$this->assertStringEndsWith('</div>',$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',
'negative_amount'=>0,
'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,26 @@ 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',
'negative_amount'=>0,
'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,"");
}
/**
@ -771,10 +894,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 +911,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 +920,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 +929,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 +938,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()));
}
/**

View file

@ -1,6 +1,5 @@
<?php
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestCase;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-02-11 at 15:39:21.
*/