Improve Exception for accountancy ACH, VEN, ODS, FIN
This commit is contained in:
parent
d15e85649d
commit
5f33bc1bd3
11 changed files with 94 additions and 46 deletions
|
|
@ -1644,11 +1644,9 @@ class Acc_Ledger extends jrn_def_sql
|
|||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
record_log($e);
|
||||
record_log($e);
|
||||
$this->db->rollback();
|
||||
echo _('OPERATION ANNULEE ');
|
||||
echo '<hr>';
|
||||
echo __FILE__.__LINE__.$e->getMessage();
|
||||
echo_warning(_('OPERATION ANNULEE voir log'));
|
||||
exit();
|
||||
}
|
||||
$this->db->commit();
|
||||
|
|
|
|||
|
|
@ -979,6 +979,9 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
$acc_operation->pj=$e_pj;
|
||||
|
||||
$jr_id=$acc_operation->insert_jrn();
|
||||
if ( $jr_id == false )
|
||||
throw new Exception (_("Erreur de balance"),EXC_BALANCE);
|
||||
|
||||
// $acc_operation->update_receipt();
|
||||
$this->db->exec_sql('update jrn set jr_pj_number=$1 where jr_id=$2', array($acc_operation->pj, $jr_id));
|
||||
$internal=$this->compute_internal_code($seq);
|
||||
|
|
@ -1096,13 +1099,10 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$r='<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
|
||||
$this->db->rollback();
|
||||
record_log($e);
|
||||
throw new Exception($r);
|
||||
throw $e;
|
||||
}
|
||||
$this->db->commit();
|
||||
if ($acc_currency->get_id()==0)
|
||||
|
|
|
|||
|
|
@ -946,10 +946,6 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
// Total DEB
|
||||
$acc_operation->amount=$this->db->get_value("select sum(j_montant) from jrnx where j_grpt = $1 and j_debit='t'",
|
||||
array($seq));
|
||||
if ( DEBUGNOALYSS > 1 ) {
|
||||
echo __LINE__." amount ".$acc_operation->amount."<br>";
|
||||
|
||||
}
|
||||
$acc_operation->desc=$e_comm;
|
||||
$acc_operation->grpt=$seq;
|
||||
$acc_operation->jrn=$p_jrn;
|
||||
|
|
@ -961,7 +957,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$acc_operation->currency_rate_ref=$currency_rate_ref->get_rate();
|
||||
|
||||
if ( ! $this->jr_id=$acc_operation->insert_jrn() ) {
|
||||
throw new Exception (_("Erreur de balance"));
|
||||
throw new Exception (_("Erreur de balance"),EXC_BALANCE);
|
||||
}
|
||||
$this->pj=$acc_operation->update_receipt();
|
||||
|
||||
|
|
@ -1145,14 +1141,9 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
}//end try
|
||||
catch (Exception $e)
|
||||
{
|
||||
record_log($e);
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage().$e->getMessage();
|
||||
record_log($e->getMessage());
|
||||
record_log($e);
|
||||
$this->db->rollback();
|
||||
throw new Exception($e);
|
||||
throw $e;
|
||||
}
|
||||
$this->db->commit();
|
||||
return $internal;
|
||||
|
|
@ -1272,7 +1263,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
$add_js="";
|
||||
if ( $g_parameter->MY_PJ_SUGGEST !='N')
|
||||
{
|
||||
$add_js="update_pj();";
|
||||
$add_js="update_receipt();";
|
||||
}
|
||||
if ($g_parameter->MY_DATE_SUGGEST == 'Y')
|
||||
{
|
||||
|
|
@ -1565,7 +1556,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
/* if we suggest the pj n# the run the script */
|
||||
if ( $g_parameter->MY_PJ_SUGGEST !='N')
|
||||
{
|
||||
$r.='<script> update_pj();</script>';
|
||||
$r.='<script> update_receipt();</script>';
|
||||
}
|
||||
// set focus on date
|
||||
$r.= create_script("$('".$Date->id."').focus()");
|
||||
|
|
|
|||
|
|
@ -678,7 +678,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$acc_operation->currency_rate_ref=$currency_rate_ref->get_rate();
|
||||
|
||||
if ( ! $this->jr_id=$acc_operation->insert_jrn() ) {
|
||||
throw new Exception (_("Erreur de balance"));
|
||||
throw new Exception (_("Erreur de balance"),EXC_BALANCE);
|
||||
}
|
||||
|
||||
$this->pj = $acc_operation->update_receipt();
|
||||
|
|
@ -856,15 +856,9 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$acc_operation_note->save();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
record_log($e);
|
||||
echo '<span class="error">' .
|
||||
'Erreur dans l\'enregistrement ' .
|
||||
__FILE__ . ':' . __LINE__ . ' ' .
|
||||
$e->getMessage();
|
||||
echo $e->getTraceAsString();
|
||||
|
||||
record_log($e);
|
||||
$this->db->rollback();
|
||||
throw new Exception ($e);
|
||||
throw $e;
|
||||
}
|
||||
$this->db->commit();
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,16 @@ if (isset($_POST['record']))
|
|||
echo '<div class="content">';
|
||||
|
||||
$Ledger = new Acc_Ledger_Purchase($cn, $post_jrn);
|
||||
$internal = $Ledger->insert($_POST);
|
||||
|
||||
try {
|
||||
$internal = $Ledger->insert($_POST);
|
||||
} catch (\Exception $e) {
|
||||
if ( $e->getCode()==EXC_BALANCE)
|
||||
echo_warning(_("enregistrement annulé: balance , voyer le fichier log"));
|
||||
else
|
||||
echo_warning($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Save the predefined operation */
|
||||
|
|
|
|||
|
|
@ -116,7 +116,16 @@ if ( isset($_POST['confirm']))
|
|||
echo '</div>';
|
||||
|
||||
echo '<div class="content">';
|
||||
$a= $Ledger->insert($_POST);
|
||||
try {
|
||||
$a= $Ledger->insert($_POST);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
if ( $e->getCode()==EXC_BALANCE)
|
||||
echo_warning(_("enregistrement annulé: balance , voyer le fichier log"));
|
||||
else
|
||||
echo_warning($e->getMessage());
|
||||
return;
|
||||
}
|
||||
echo '<h1>'._('Enregistrement').' </h1>';
|
||||
echo '<div class="content">';
|
||||
echo $a;
|
||||
|
|
|
|||
|
|
@ -122,7 +122,18 @@ if ( isset($_POST['record']) )
|
|||
echo '<div class="content">';
|
||||
|
||||
$Ledger=new Acc_Ledger_Sale($cn,$_POST['p_jrn']);
|
||||
$internal=$Ledger->insert($_POST);
|
||||
try {
|
||||
$internal=$Ledger->insert($_POST);
|
||||
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
if ( $e->getCode()==EXC_BALANCE)
|
||||
echo_warning(_("enregistrement annulé: balance , voyer le fichier log"));
|
||||
else
|
||||
echo_warning($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Save the predefined operation */
|
||||
if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
|
||||
|
|
|
|||
|
|
@ -113,9 +113,6 @@ if (!defined('LOGINPUT')) {
|
|||
define("LOGINPUT", false);
|
||||
}
|
||||
|
||||
if (!defined('DEBUGNOALYSS')) {
|
||||
define('DEBUGNOALYSS', 0);
|
||||
}
|
||||
$version_noalyss = NOALYSS_VERSION;
|
||||
|
||||
// If you don't want to be notified of the update
|
||||
|
|
@ -158,6 +155,7 @@ if (DEBUGNOALYSS == 0) {
|
|||
ini_set("html_errors", 0);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('log_errors_max_len', 0);
|
||||
if(function_exists('xdebug_disable')) { xdebug_disable(); }
|
||||
} elseif (DEBUGNOALYSS == 1) {
|
||||
/* DEVELOPPEMENT : display all errors warning notice deprecated ...*/
|
||||
error_reporting(2147483647);
|
||||
|
|
@ -347,6 +345,8 @@ define('EXC_PARAM_TYPE', 1006);
|
|||
define('EXC_DUPLICATE', 1200);
|
||||
define('EXC_INVALID', 1400);
|
||||
define('EXC_FORBIDDEN', 1500);
|
||||
// exception when balance is incorrect when saving an operation
|
||||
define('EXC_BALANCE', 1501);
|
||||
define("UNPINDG", "");
|
||||
define("PINDG", "");
|
||||
|
||||
|
|
|
|||
|
|
@ -1335,22 +1335,54 @@ function is_msie()
|
|||
return $is_msie;
|
||||
}
|
||||
/**
|
||||
*@brief Record an error message into the log file of the server.
|
||||
*@brief Record an error message into the log file of the server or in the log folder of NOALYSS
|
||||
* Record also the GET and POST data
|
||||
* @param string $p_message
|
||||
* @param $p_message string message to display
|
||||
*/
|
||||
function record_log($p_message)
|
||||
{
|
||||
if ( gettype ($p_message) == "object" && method_exists($p_message,"getTraceAsString") == 1) {
|
||||
$date=date('d.m.y');
|
||||
// variable: $handle_log resource on log file ,
|
||||
$handle_log=fopen(NOALYSS_BASE."/log/noalyss-{$date}.log","a+");
|
||||
|
||||
error_log("noalyss exception ".$p_message->getMessage(),0);
|
||||
error_log("noalyss exception".$p_message->getTraceAsString(),0);
|
||||
if ($handle_log == false )
|
||||
{
|
||||
|
||||
if ( gettype ($p_message) == "object" && method_exists($p_message,"getTraceAsString") == 1) {
|
||||
|
||||
error_log("noalyss exception ".$p_message->getMessage(),0);
|
||||
error_log("noalyss exception".$p_message->getTraceAsString(),0);
|
||||
} else {
|
||||
error_log("noalyss".var_export($p_message,true),0);
|
||||
|
||||
}
|
||||
error_log("noalyss GET [".json_encode($_GET,0,10)."]");
|
||||
error_log("_POST [".json_encode($_POST,0,10)."]",0);
|
||||
} else {
|
||||
error_log("noalyss".var_export($p_message,true),0);
|
||||
$now=date('y-m-d H:i');
|
||||
fwrite ($handle_log,str_repeat("=", 80)."\n");
|
||||
fwrite ($handle_log,"ERROR: {$now}\n");
|
||||
fwrite($handle_log,"noalyss GET [".var_export($_GET,true)."]");
|
||||
fwrite ($handle_log,"\n");
|
||||
fwrite($handle_log,"_POST [".var_export($_POST,true)."]");
|
||||
fwrite ($handle_log,"\n");
|
||||
if ( gettype ($p_message) == "object" && method_exists($p_message,"getTraceAsString") == 1) {
|
||||
|
||||
fwrite($handle_log,"noalyss exception ".$p_message->getMessage());
|
||||
fwrite ($handle_log,"\n");
|
||||
fwrite($handle_log,"noalyss exception".$p_message->getTraceAsString());
|
||||
fwrite ($handle_log,"\n");
|
||||
} else {
|
||||
fwrite($handle_log,"noalyss".var_export($p_message,true));
|
||||
fwrite ($handle_log,"\n");
|
||||
|
||||
}
|
||||
|
||||
fwrite ($handle_log,str_repeat("=", 80)."\n");
|
||||
|
||||
|
||||
}
|
||||
error_log("noalyss GET [".json_encode($_GET,0,10)."]");
|
||||
error_log("_POST [".json_encode($_POST,0,10)."]",0);
|
||||
|
||||
}
|
||||
if(!function_exists('tracedebug')) {
|
||||
function tracedebug($file,$var, $label = NULL) {
|
||||
|
|
|
|||
3
log/.htaccess
Normal file
3
log/.htaccess
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
order deny,allow
|
||||
deny from all
|
||||
|
||||
1
log/index.html
Normal file
1
log/index.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<h1>LOGFILE</h1>
|
||||
Loading…
Add table
Add a link
Reference in a new issue