Add __toString function for debugging purpose
Improve DBG tools: print out or return a string
This commit is contained in:
parent
5152ceeab7
commit
0fbc7bfdfa
5 changed files with 162 additions and 24 deletions
|
|
@ -42,6 +42,11 @@ class Acc_Currency
|
||||||
$this->currency=new V_Currency_Last_Value_SQL($p_cn, $p_id);
|
$this->currency=new V_Currency_Last_Value_SQL($p_cn, $p_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
return "Acc_Currency [".$this->currency->__toString()."]";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a V_Currency_Last_Value_SQL thanks its iso_code
|
* Retrieve a V_Currency_Last_Value_SQL thanks its iso_code
|
||||||
* @param string $p_iso
|
* @param string $p_iso
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,28 @@ class Acc_Operation
|
||||||
$this->currency_rate_ref=1;
|
$this->currency_rate_ref=1;
|
||||||
$this->currency_id=NULL;
|
$this->currency_id=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __toString(): string
|
||||||
|
{
|
||||||
|
$r=<<<EOF
|
||||||
|
Acc_Operation Object
|
||||||
|
[
|
||||||
|
db {$this->db}
|
||||||
|
qcode {$this->qcode}
|
||||||
|
user {$this->user}
|
||||||
|
periode {$this->periode}
|
||||||
|
jr_id {$this->jr_id}
|
||||||
|
jr_optype {$this->jr_optype}
|
||||||
|
amount {$this->amount}
|
||||||
|
currency_rate {$this->amount}
|
||||||
|
currency_rate_ref {$this->amount}
|
||||||
|
currency_id {$this->amount}
|
||||||
|
]
|
||||||
|
EOF;
|
||||||
|
return $r;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@brief retrieve the grpt_id from jrn for a jr_id
|
*@brief retrieve the grpt_id from jrn for a jr_id
|
||||||
*@return jrn.jr_grpt_id or an empty string if not found
|
*@return jrn.jr_grpt_id or an empty string if not found
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,29 @@ class Anc_Operation
|
||||||
return $this->currency_rate;
|
return $this->currency_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
$r=<<<EOF
|
||||||
|
Object Anc_Operation [
|
||||||
|
\$row=>$this->row,
|
||||||
|
\$list=> $this->list,
|
||||||
|
\$id => $this->id,
|
||||||
|
\$po_id => $this->po_id,
|
||||||
|
\$oa_amount $this->oa_amount,
|
||||||
|
\$oa_description => $this->oa_description,
|
||||||
|
\$oa_debit => $this->oa_debit,
|
||||||
|
\$j_id => $this->j_id,
|
||||||
|
\$oa_group => $this->oa_group,
|
||||||
|
\$oa_date => $this->oa_date,
|
||||||
|
\$pa_id => $this->pa_id,
|
||||||
|
\$card => $this->card ,
|
||||||
|
private \$currency_rate => $this->currency_rate,
|
||||||
|
]
|
||||||
|
EOF;
|
||||||
|
return $r;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function set_currency_rate($currency_rate)
|
public function set_currency_rate($currency_rate)
|
||||||
{
|
{
|
||||||
$this->currency_rate=$currency_rate;
|
$this->currency_rate=$currency_rate;
|
||||||
|
|
@ -778,20 +801,87 @@ class Anc_Operation
|
||||||
* \param $p_item if the item nb for each item (purchase or selling
|
* \param $p_item if the item nb for each item (purchase or selling
|
||||||
* merchandise)
|
* merchandise)
|
||||||
* \param $p_array structure
|
* \param $p_array structure
|
||||||
* \verbatim
|
|
||||||
nb_tA A is the number of the item it contains the number of
|
nb_tx x is the number of the item it contains the number of
|
||||||
rows of CA for this card
|
rows of CA for this card
|
||||||
valAlR amount for the CA (item A row R)
|
<h1>val double array : amount for the CA row ACC => sub row ANC </h1>
|
||||||
|
here Operation 0 has 2 row for a total of 10.31 and 1
|
||||||
|
here Operation 1 has 1 row for a total of 430
|
||||||
|
\verbatim
|
||||||
|
[val] => Array
|
||||||
|
(
|
||||||
|
[0] => Array
|
||||||
|
(
|
||||||
|
[0] => 10.31
|
||||||
|
[1] => 1
|
||||||
|
)
|
||||||
|
|
||||||
|
[1] => Array
|
||||||
|
(
|
||||||
|
[0] => 430
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
\endverbatim
|
||||||
|
<h1>amount_tx the amount for each row</h1>
|
||||||
|
It is the amount to split per accounting, it is possible that it is different from the sum of the given amount (<i>
|
||||||
|
see val</i>) per row
|
||||||
|
\verbatim
|
||||||
|
[amount_t0] => 11.31
|
||||||
|
[amount_t1] => 430
|
||||||
|
\endverbatim
|
||||||
ta_AoCrow_R contains the value of the pa_id and po_id for this
|
ta_AoCrow_R contains the value of the pa_id and po_id for this
|
||||||
row with the form pa_id_po_id %d_%d
|
row with the form pa_id_po_id %d_%d
|
||||||
|
<h1> hplan = Double array operation</h1>
|
||||||
|
<p> Double array operation => all the amount but in linear form</p>
|
||||||
|
|
||||||
|
<p>Example if the amount of the operation 0 is splitted in 2 rows and 2 cols (because 2 analytic plan, means 2 cols)
|
||||||
|
we have an array of 4 values for operation 0, it gives the poste_analytique.po_id (from DB).</p>
|
||||||
|
<p> Here is the operation 0
|
||||||
|
(one row of the accounting) is splitted in po_id = 1 (pa_id see in tables or array pa_id) and po_id=5 (second pa_id)
|
||||||
|
for 10.31 (<i>see array val</i>) and for 1 is set for po_id 1 and 4, p
|
||||||
|
</p>
|
||||||
|
\verbatim
|
||||||
|
[hplan] => Array
|
||||||
|
(
|
||||||
|
[0] => Array
|
||||||
|
(
|
||||||
|
[0] => 1
|
||||||
|
[1] => 5
|
||||||
|
[2] => 1
|
||||||
|
[3] => 4
|
||||||
|
)
|
||||||
|
|
||||||
|
[1] => Array
|
||||||
|
(
|
||||||
|
[0] => 1
|
||||||
|
[1] => 6
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
<h1> pa_id </h1>
|
||||||
|
pa_id array of plan_analytic.pa_id (1 per column), always ordered by pa_id
|
||||||
|
|
||||||
|
\verbatim
|
||||||
|
[pa_id] => Array
|
||||||
|
(
|
||||||
|
[0] => 1
|
||||||
|
[1] => 2
|
||||||
|
)
|
||||||
|
|
||||||
*\endverbatim
|
*\endverbatim
|
||||||
|
*
|
||||||
* \attention The idea is one j_id matches several oa_id,
|
* \attention The idea is one j_id matches several oa_id,
|
||||||
* serveral data are set before the call :
|
* serveral data <b>must be </b>set before the call :
|
||||||
* -j_id
|
*
|
||||||
* -oa_debit
|
* <ul><li> j_id</li>
|
||||||
* -oa_group
|
* <li>oa_debit</li>
|
||||||
* -oa_date
|
* <li>oa_group</li>
|
||||||
* -oa_description
|
* <li>oa_date</li>
|
||||||
|
* <li>oa_description</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function save_form_plan($p_array,$p_item,$p_j_id)
|
function save_form_plan($p_array,$p_item,$p_j_id)
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,21 @@ class Periode
|
||||||
$this->jrn_def_id=0;
|
$this->jrn_def_id=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
$r=<<<EOF
|
||||||
|
Object Periode [
|
||||||
|
\$jrn_def_id=>$jrn_def_id,
|
||||||
|
\$p_id=>$p_id,
|
||||||
|
\$status => $status,
|
||||||
|
\$p_start => $p_start,
|
||||||
|
\$p_end => $p_end,
|
||||||
|
]
|
||||||
|
EOF;
|
||||||
|
return $r;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function set_ledger($p_jrn)
|
function set_ledger($p_jrn)
|
||||||
{
|
{
|
||||||
$this->jrn_def_id=$p_jrn;
|
$this->jrn_def_id=$p_jrn;
|
||||||
|
|
|
||||||
|
|
@ -5,39 +5,45 @@ require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
|
||||||
|
|
||||||
class Dbg
|
class Dbg
|
||||||
{
|
{
|
||||||
public static function echo_var($n_level, $msg)
|
public static function echo_var($n_level, $msg,$print=true)
|
||||||
{
|
{
|
||||||
if (DEBUGNOALYSS > $n_level) {
|
if (DEBUGNOALYSS > $n_level) {
|
||||||
echo '<span style="font-size:12px;color:orangered;background-color:lightyellow;">';
|
$r= '<span style="font-size:12px;color:orangered;background-color:lightyellow;">';
|
||||||
$type = gettype($msg);
|
$type = gettype($msg);
|
||||||
if (in_array($type, ["string", "integer", "double"])) {
|
if (in_array($type, ["string", "integer", "double"])) {
|
||||||
echo $msg;
|
$r.= $msg;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
echo "<pre>DBG";
|
$r.= "<pre>DBG";
|
||||||
var_export($msg);
|
$r.=print_r($msg,true);
|
||||||
echo '</pre>';
|
$r.='</pre>';
|
||||||
}
|
}
|
||||||
echo '</span>';
|
$r.='</span>';
|
||||||
|
if ($print) { echo $r;}
|
||||||
|
return $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function echo_function($msg)
|
public static function echo_function($msg,$print=true)
|
||||||
{
|
{
|
||||||
if (DEBUGNOALYSS > 1) {
|
if (DEBUGNOALYSS > 1) {
|
||||||
echo '<span style="font-size:12px;color:lightgreen;background-color:lightyellow;">';
|
$r = '<span style="font-size:12px;color:lightgreen;background-color:lightyellow;">';
|
||||||
echo "[FILE: $msg]";
|
$r.="[FILE: $msg]";
|
||||||
|
|
||||||
echo '</span>';
|
$r.= '</span>';
|
||||||
|
if ($print) { echo $r;}
|
||||||
|
return $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static function echo_file($msg)
|
public static function echo_file($msg,$print=true)
|
||||||
{
|
{
|
||||||
if (DEBUGNOALYSS > 1) {
|
if (DEBUGNOALYSS > 1) {
|
||||||
echo '<span style="font-size:12px;color:brown;background-color:lightyellow;">';
|
$r = '<span style="font-size:12px;color:brown;background-color:lightyellow;">';
|
||||||
echo "[FILE: $msg]";
|
$r.="[FILE: $msg]";
|
||||||
|
|
||||||
echo '</span>';
|
$r.= '</span>';
|
||||||
|
if ($print) { echo $r;}
|
||||||
|
return $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue