Task 0002128: Clôture comptabilité française
This commit is contained in:
parent
948a509e1f
commit
e723c5c5b1
14 changed files with 2027 additions and 833 deletions
|
|
@ -327,7 +327,18 @@ $path = array(
|
|||
//visibility quantity
|
||||
"update_visibility_quantity"=>"ajax_update_visibility_quantity",
|
||||
// detail customer , supplier operation
|
||||
"event_display_detail"=>"ajax_event_display_detail"
|
||||
"event_display_detail"=>"ajax_event_display_detail",
|
||||
// update periode in opening operation
|
||||
"operation_exercice+update_periode"=>"ajax_operation_exercice",
|
||||
// modify row in exercice (opening/closing) operation
|
||||
"operation_exercice+modify_row"=>"ajax_operation_exercice",
|
||||
// save row in exercice (opening/closing) operation
|
||||
"operation_exercice+save_row"=>"ajax_operation_exercice",
|
||||
// compute the balance after saving row in exercice (opening/closing) operation
|
||||
"operation_exercice+display_total"=>"ajax_operation_exercice",
|
||||
// delete row in exercice (opening/closing) operation
|
||||
"operation_exercice+delete_row"=>"ajax_operation_exercice",
|
||||
|
||||
) ;
|
||||
|
||||
if (array_key_exists($op, $path)) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
153
include/ajax/ajax_operation_exercice.php
Normal file
153
include/ajax/ajax_operation_exercice.php
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<?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@aevalys.eu 6/01/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief display the possible value of exercice
|
||||
*/
|
||||
global $http, $g_user;
|
||||
if ($g_user->check_module("OPCL") == 0) throw new \Exception(EXC_FORBIDDEN);
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Update the periode of the selected folder
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if ($op == "operation_exercice+update_periode") {
|
||||
|
||||
try {
|
||||
$folder_id = $http->get("folder", "number");
|
||||
if ($g_user->check_dossier($folder_id, true) == 'X') throw new \Exception(EXC_FORBIDDEN);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$conx = new Database($folder_id);
|
||||
$periode = $conx->make_array("select distinct p_exercice,p_exercice from parm_periode order by p_exercice desc");
|
||||
$sExercice = new ISelect("exercice");
|
||||
$sExercice->id = "select_exercice_id";
|
||||
$sExercice->value = $periode;
|
||||
echo $sExercice->input();
|
||||
return;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Display a detail operation_exercice to modify or add id
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if ($op == "operation_exercice+modify_row") {
|
||||
try {
|
||||
$row_id = $http->post("row_id", "number", -1);
|
||||
$oe_id=$http->post("oe_id","number");
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
return;
|
||||
}
|
||||
$operation_detail_sql = new Operation_Exercice_Detail_SQL($cn, $row_id);
|
||||
$operation_detail_sql->oe_id=$oe_id;
|
||||
if ( $row_id == -1) $operation_detail_sql->oed_debit='f';
|
||||
Operation_Exercice::input_row($operation_detail_sql);
|
||||
|
||||
return;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// save a row
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if ($op == "operation_exercice+save_row") {
|
||||
try {
|
||||
$row_id = $http->post("row_id", "number");
|
||||
$oe_id = $http->post("oe_id", "number");
|
||||
$oe_poste = $http->post("oe_poste", "text");
|
||||
$qcode = $http->post("qcode", "text");
|
||||
$label = $http->post("label", "text");
|
||||
$amount = $http->post("amount", "number");
|
||||
$debit = $http->post("debit", "text", 'f');
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
return;
|
||||
}
|
||||
$operation_detail_sql = new Operation_Exercice_Detail_SQL($cn, $row_id);
|
||||
|
||||
$operation_detail_sql->setp("oed_poste", $oe_poste)
|
||||
->setp("oed_qcode", $qcode)
|
||||
->setp("oed_label", $label)
|
||||
->setp("oed_amount", $amount)
|
||||
->setp("oe_id",$oe_id)
|
||||
->setp("oed_debit", $debit);
|
||||
try {
|
||||
$operation_detail_sql->save();
|
||||
$data = $operation_detail_sql->to_array();
|
||||
|
||||
ob_start();
|
||||
$operation_exercice = new Operation_Exercice();
|
||||
if ($row_id == -1 ) {
|
||||
$operation_exercice->display_row($data, true);
|
||||
} else {
|
||||
|
||||
$operation_exercice->display_row($data, false);
|
||||
}
|
||||
$str = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$answer = [];
|
||||
$answer["status"] = "OK";
|
||||
$answer['row_id'] = $operation_detail_sql->oed_id;
|
||||
$answer['oe_id'] = $operation_detail_sql->oe_id;
|
||||
$answer['content'] = $str;
|
||||
echo json_response($answer);
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Compute the balance, we receive only the OED_ID , then we must find out what was the complete
|
||||
// OPERATION_EXERCICE
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if ($op == "operation_exercice+display_total") {
|
||||
try {
|
||||
$row_id = $http->get("row_id", "number");
|
||||
$operation_detail_sql = new Operation_Exercice_Detail_SQL($cn, $row_id);
|
||||
if ($operation_detail_sql->getp("oe_id") == "") {
|
||||
throw new Exception("AOE-113:not existing line");
|
||||
}
|
||||
$operation_exercice = new Operation_Exercice($operation_detail_sql->oe_id);
|
||||
$operation_exercice->display_total(false);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
//delete a row OPERATION_EXERCICE
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if ($op == "operation_exercice+delete_row") {
|
||||
try {
|
||||
$row_id = $http->get("row_id", "number");
|
||||
$operation_detail_sql = new Operation_Exercice_Detail_SQL($cn, $row_id);
|
||||
$oe_id=$operation_detail_sql->oe_id;
|
||||
$other_row=$cn->get_value("select oed_id from operation_exercice_detail where oe_id=$1 limit 1 ",
|
||||
[$oe_id]);
|
||||
|
||||
$operation_detail_sql->delete();
|
||||
echo json_response(array("status"=>"OK","row_id"=>$other_row));
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1759,34 +1759,6 @@ class Acc_Ledger extends jrn_def_sql
|
|||
return $card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get the saldo of an exercice, used for the opening of a folder
|
||||
* @param$p_exercice is the exercice we want
|
||||
* \return an array
|
||||
* index =
|
||||
* - solde (debit > 0 ; credit < 0)
|
||||
* - j_poste
|
||||
* - j_qcode
|
||||
*/
|
||||
function get_saldo_exercice($p_exercice)
|
||||
{
|
||||
$sql="select sum(a.montant) as solde, j_poste, j_qcode
|
||||
from
|
||||
(select j_id, case when j_debit='t' then j_montant
|
||||
else j_montant * (-1) end as montant
|
||||
from jrnx) as a
|
||||
join jrnx using (j_id)
|
||||
join parm_periode on (j_tech_per = p_id )
|
||||
where
|
||||
p_exercice=$1
|
||||
and j_poste::text not like '7%'
|
||||
and j_poste::text not like '6%'
|
||||
group by j_poste,j_qcode
|
||||
having (sum(a.montant) != 0 ) order by 1 desc";
|
||||
$res=$this->db->get_array($sql, array($p_exercice));
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if a Dossier is using the strict mode or not
|
||||
* \return true if we are using the strict_mode
|
||||
|
|
|
|||
43
include/class/operation_closing.class.php
Normal file
43
include/class/operation_closing.class.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?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@aevalys.eu 6/01/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief
|
||||
*/
|
||||
class Operation_Closing extends Operation_Exercice
|
||||
{
|
||||
private $signature ;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->signature='closing';
|
||||
|
||||
}
|
||||
public function get_signature(): string
|
||||
{
|
||||
return $this->signature;
|
||||
}
|
||||
|
||||
function from_request()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
156
include/class/operation_exercice.class.php
Normal file
156
include/class/operation_exercice.class.php
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
<?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@aevalys.eu 6/01/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief
|
||||
*/
|
||||
|
||||
class Operation_Exercice
|
||||
{
|
||||
protected $operation_exercice_sql;
|
||||
|
||||
public function __construct($p_id = -1)
|
||||
{
|
||||
$this->operation_exercice_sql = new Operation_Exercice_SQL(Dossier::connect(), $p_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief input the source of the data : folder, exercice, closing or opening operation
|
||||
* @return void
|
||||
*/
|
||||
public static function input_source()
|
||||
{
|
||||
require NOALYSS_TEMPLATE . "/operation_exercice-input_source.php";
|
||||
}
|
||||
|
||||
function display_result()
|
||||
{
|
||||
$cn = Dossier::connect();
|
||||
// get data
|
||||
$a_data = $cn->get_array("
|
||||
SELECT oed_id
|
||||
, oe_id
|
||||
, oed_poste
|
||||
, oed_qcode
|
||||
, oed_label
|
||||
, oed_amount
|
||||
, oed_debit
|
||||
FROM public.operation_exercice_detail
|
||||
where
|
||||
oe_id=$1
|
||||
order by oed_debit desc,oed_poste,oed_qcode
|
||||
|
||||
", [$this->operation_exercice_sql->oe_id]);
|
||||
$aheader = array(_("Poste"), _("Fiche"), _("Libellé"), _("Montant"), _("Débit/Crédit"));
|
||||
echo \HtmlInput::filter_table("operation_exercice_tb", '0,1,2,3,4', 1);
|
||||
echo \HtmlInput::button_action(_("Ajouter une ligne"), sprintf("operation_exercice.modify_row('-1','%s')", $this->operation_exercice_sql->oe_id));
|
||||
echo '<table class="result" id="operation_exercice_tb">';
|
||||
foreach ($aheader as $header) echo th($header, 'style="text-align:center"');
|
||||
echo th("");
|
||||
|
||||
foreach ($a_data as $data) {
|
||||
$this->display_row($data);
|
||||
}
|
||||
echo '</table>';
|
||||
echo \HtmlInput::button_action(_("Ajouter une ligne"), sprintf("operation_exercice.modify_row('-1','%s')", $this->operation_exercice_sql->oe_id));
|
||||
$this->display_total();
|
||||
echo Dossier::hidden();
|
||||
$js = <<<EOF
|
||||
(function() {
|
||||
$$(".op-exercice").forEach(item=>item.addEventListener("click",function(event) {operation_exercice.click_modify_row(item)}));
|
||||
})();
|
||||
EOF;
|
||||
echo create_script($js);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief display the balance (total) of the operation
|
||||
* @param bool $with_span if yes add the span wrapper , otherwise doesn't add it
|
||||
*/
|
||||
public function display_total($with_span = true)
|
||||
{
|
||||
$cn = Dossier::connect();
|
||||
$sql_total = "
|
||||
with saldo_deb_cred as
|
||||
(
|
||||
select
|
||||
case when oed_debit is true then oed_amount else 0-oed_amount end signed_amount ,
|
||||
case when oed_debit is true then oed_amount end debit,
|
||||
case when oed_debit is false then oed_amount end credit
|
||||
from public.operation_exercice_detail
|
||||
where oe_id=$1
|
||||
)
|
||||
select sum(signed_amount) delta,sum(debit) debit,sum(credit) credit from saldo_deb_cred
|
||||
";
|
||||
$total = $cn->get_row($sql_total, [$this->operation_exercice_sql->oe_id]);
|
||||
if ($with_span) {
|
||||
echo '<span id="tot_ope_exe" style="margin-left:20%">';
|
||||
}
|
||||
$style = 'style="display:inline-block;padding:1rem;margin:1rem;border:1px solid navy;width:20%;text-align:center;font-size:140%"';
|
||||
|
||||
echo span(sprintf(_("Débit %s"), nbm($total['debit'])), $style);
|
||||
echo span(sprintf(_("Crédit %s"), nbm($total['credit'])), $style);
|
||||
$s="";
|
||||
if ($total['delta'] > 0) {
|
||||
$s = " Solde débiteur ";
|
||||
}
|
||||
if ($total['delta'] < 0) {
|
||||
$s = " Solde créditeur ";
|
||||
}
|
||||
echo span($s . " " . nbm($total['delta']), $style);
|
||||
if ($with_span) {
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief let display one row
|
||||
* @param $data array row of operation_exercice_detail [oed_id, oe_id, oed_poste, oed_qcode oed_label
|
||||
* oed_amount oed_debit]
|
||||
* @return void
|
||||
* @see Operation_Exercice_Detail_SQL
|
||||
*/
|
||||
function display_row($data, $row_tr = true)
|
||||
{
|
||||
if ($row_tr) printf('<tr class="op-exercice even" id="oe_%s" oed_id="%s" oe_id="%s">', $data['oed_id'], $data['oed_id'], $data['oe_id']);
|
||||
echo td($data['oed_poste']);
|
||||
echo td($data['oed_qcode']);
|
||||
echo td(h($data['oed_label']));
|
||||
echo td(nbm($data['oed_amount']), 'class="num"');
|
||||
echo td(($data['oed_debit'] == 'f' ? _("Crédit") : _("Débit")), 'style="text-align:center"');
|
||||
echo td(\Icon_Action::modify(uniqid(), sprintf("operation_exercice.modify_row('%s','%s')", $data['oed_id'], $data['oe_id'])));
|
||||
|
||||
|
||||
if ($row_tr) print ('</tr >');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief input one row of operation_exercice
|
||||
* @param $data array row of operation_exercice_detail [oed_id, oe_id, oed_poste, oed_qcode oed_label
|
||||
* oed_amount oed_debit]
|
||||
* @return void
|
||||
* @see Operation_Exercice_Detail_SQL
|
||||
*/
|
||||
public static function input_row(Operation_Exercice_Detail_SQL $operation_detail_sql)
|
||||
{
|
||||
require_once NOALYSS_TEMPLATE . "/operation_exercice-input_row.php";
|
||||
}
|
||||
|
||||
}
|
||||
146
include/class/operation_opening.class.php
Normal file
146
include/class/operation_opening.class.php
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
<?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@aevalys.eu 6/01/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief
|
||||
*/
|
||||
|
||||
class Operation_Opening extends Operation_Exercice
|
||||
{
|
||||
private $signature;
|
||||
private $from_folder;
|
||||
private $exercice;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->signature = 'opening';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_from_folder()
|
||||
{
|
||||
return $this->from_folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $from_folder
|
||||
*/
|
||||
public function set_from_folder($from_folder): void
|
||||
{
|
||||
$this->from_folder = $from_folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_exercice()
|
||||
{
|
||||
return $this->exercice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $exercice
|
||||
*/
|
||||
public function set_exercice($exercice): void
|
||||
{
|
||||
$this->exercice = $exercice;
|
||||
}
|
||||
|
||||
public function get_signature(): string
|
||||
{
|
||||
return $this->signature;
|
||||
}
|
||||
|
||||
function from_request()
|
||||
{
|
||||
$http = new HttpInput();
|
||||
$this->exercice = $http->request("exercice", "number");
|
||||
$this->from_folder = $http->request("dos_id", "number");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert data into data operation_exercice and operation_exercice_detail
|
||||
* @return void
|
||||
*/
|
||||
function insert()
|
||||
{
|
||||
$cn = Dossier::connect();
|
||||
$other_dossier = new Database($this->from_folder);
|
||||
|
||||
$sql = "
|
||||
with total_account as (
|
||||
select sum(a.montant) as tot_amount, j_poste, f_id
|
||||
from
|
||||
(select j_id, case when j_debit='t' then j_montant
|
||||
else j_montant * (-1) end as montant
|
||||
from jrnx) as a
|
||||
join jrnx using (j_id)
|
||||
join parm_periode on (j_tech_per = p_id )
|
||||
where
|
||||
p_exercice=$1
|
||||
and j_poste::text not like '7%'
|
||||
and j_poste::text not like '6%'
|
||||
group by j_poste,f_id
|
||||
having (sum(a.montant) != 0 )
|
||||
)
|
||||
select t1.tot_amount
|
||||
,t1.j_poste
|
||||
,(select pcm_lib from tmp_pcmn where pcm_val=t1.j_poste) as lib_accounting
|
||||
,t1.f_id
|
||||
,(select ad_value fd2 from fiche_detail fd2 where fd2.f_id=t1.f_id and fd2.ad_id=23) qcode
|
||||
,(select fd3.ad_value from fiche_detail fd3 where fd3.f_id=t1.f_id and fd3.ad_id=1) f_name
|
||||
,abs(t1.tot_amount) atot_amount
|
||||
,case when tot_amount <0 then 'f' else 't' end debit
|
||||
from total_account t1
|
||||
";
|
||||
$exercice_report=$this->exercice+1;
|
||||
$this->operation_exercice_sql->setp("oe_type", $this->signature)
|
||||
->setp("oe_dossier_id", $this->from_folder)
|
||||
->set("oe_text",_("Ecriture ouverture $exercice_report"))
|
||||
->setp("oe_exercice", $this->exercice);
|
||||
try {
|
||||
$cn->start();
|
||||
$this->operation_exercice_sql->insert();
|
||||
$array = $other_dossier->get_array($sql, array($this->exercice));
|
||||
if (empty($array)) return;
|
||||
foreach ($array as $item) {
|
||||
$row = new Operation_Exercice_Detail_SQL($cn);
|
||||
$row->oe_id = $this->operation_exercice_sql->oe_id;
|
||||
$row->oed_poste = (empty($item['qcode']))?$item["j_poste"]:null;
|
||||
$row->oed_qcode = $item["qcode"];
|
||||
$row->oed_amount = $item['atot_amount'];
|
||||
$row->oed_label=(empty($item['qcode']))?$item['lib_accounting']:$item['f_name'];
|
||||
$row->oed_debit = $item["debit"];
|
||||
$row->save();
|
||||
}
|
||||
$cn->commit();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$cn->rollback();
|
||||
echo $e->getMessage();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -341,6 +341,7 @@ define('EXC_PARAM_VALUE', 1005);
|
|||
define('EXC_PARAM_TYPE', 1006);
|
||||
define('EXC_DUPLICATE', 1200);
|
||||
define('EXC_INVALID', 1400);
|
||||
define('EXC_FORBIDDEN', 1500);
|
||||
define("UNPINDG", "");
|
||||
define("PINDG", "");
|
||||
|
||||
|
|
|
|||
79
include/database/operation_exercice_detail_sql.class.php
Normal file
79
include/database/operation_exercice_detail_sql.class.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?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 Dany WM De Bontridder($(YEAR))
|
||||
*
|
||||
* $(DATE)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief abstract of the table
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @brief abstract of the table
|
||||
*/
|
||||
class Operation_Exercice_Detail_SQL extends Table_Data_SQL
|
||||
{
|
||||
|
||||
function __construct(DatabaseCore $p_cn, $p_id = -1)
|
||||
{
|
||||
$this->table = "operation_exercice_detail";
|
||||
$this->primary_key = "oed_id";
|
||||
/*
|
||||
* List of columns
|
||||
*/
|
||||
$this->name = array(
|
||||
'oed_id' => 'oed_id'
|
||||
, 'oe_id' => 'oe_id'
|
||||
, 'oed_poste' => 'oed_poste'
|
||||
, 'oed_qcode' => 'oed_qcode'
|
||||
, 'oed_label' => 'oed_label'
|
||||
, 'oed_amount' => 'oed_amount'
|
||||
, 'oed_debit' => 'oed_debit'
|
||||
|
||||
|
||||
);
|
||||
/*
|
||||
* Type of columns
|
||||
*/
|
||||
$this->type = array(
|
||||
'oed_id' => 'number'
|
||||
, 'oe_id' => 'number'
|
||||
, 'oed_poste' => 'text'
|
||||
, 'oed_qcode' => 'text'
|
||||
, 'oed_label' => 'text'
|
||||
, 'oed_amount' => 'number'
|
||||
, 'oed_debit' => 'text'
|
||||
|
||||
);
|
||||
|
||||
$this->default = array(
|
||||
"oed_id" => "oed_id"
|
||||
);
|
||||
|
||||
|
||||
|
||||
$this->date_format = "DD.MM.YYYY";
|
||||
parent::__construct($p_cn, $p_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
81
include/database/operation_exercice_sql.class.php
Normal file
81
include/database/operation_exercice_sql.class.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?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 Dany WM De Bontridder($(YEAR))
|
||||
*
|
||||
* $(DATE)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief abstract of the table public.operation_exercice
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @brief abstract of the table public.operation_exercice
|
||||
*/
|
||||
class Operation_Exercice_SQL extends Table_Data_SQL
|
||||
{
|
||||
|
||||
function __construct(DatabaseCore $p_cn, $p_id = -1)
|
||||
{
|
||||
$this->table = "public.operation_exercice";
|
||||
$this->primary_key = "oe_id";
|
||||
/*
|
||||
* List of columns
|
||||
*/
|
||||
$this->name = array(
|
||||
"oe_id" => "oe_id",
|
||||
"oe_date" => "oe_date",
|
||||
"oe_text" => "oe_text",
|
||||
"oe_type" => "oe_type",
|
||||
"tech_user" => "tech_user",
|
||||
"tech_date" => "tech_date",
|
||||
"oe_dossier_id" => "oe_dossier_id",
|
||||
"oe_exercice" => "oe_exercice",
|
||||
|
||||
);
|
||||
/*
|
||||
* Type of columns
|
||||
*/
|
||||
$this->type = array(
|
||||
"oe_id" => "number",
|
||||
"oe_date" => "date",
|
||||
"oe_text" => "text",
|
||||
"oe_type" => "text",
|
||||
"tech_user" => "text",
|
||||
"tech_date" => "date",
|
||||
"oe_dossier_id" => "number",
|
||||
"oe_exercice" => "number",
|
||||
|
||||
);
|
||||
|
||||
|
||||
$this->default = array(
|
||||
"oe_id" => "oe_id",
|
||||
"tech_user" => "tech_user",
|
||||
"tech_date" => "tech_date",
|
||||
);
|
||||
|
||||
$this->date_format = "DD.MM.YYYY";
|
||||
parent::__construct($p_cn, $p_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
49
include/operation_exercice.inc.php
Normal file
49
include/operation_exercice.inc.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?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@aevalys.eu 6/01/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief For opening or closing exercice , operation needed
|
||||
*/
|
||||
|
||||
$http=new HttpInput();
|
||||
if ( $http->request("sa","string","") == "" )
|
||||
{
|
||||
Operation_Exercice::input_source();
|
||||
return;
|
||||
}
|
||||
if ( $http->request("sa") == "opening")
|
||||
{
|
||||
|
||||
$operation_exercice_id= $http->get("operation_exercice_id","number",-1);
|
||||
$operation_opening=new Operation_Opening($operation_exercice_id);
|
||||
try {
|
||||
// take data from request
|
||||
$operation_opening->from_request();
|
||||
if ( $operation_exercice_id == -1 ) {
|
||||
$operation_opening->insert();
|
||||
}
|
||||
// Display result
|
||||
$operation_opening->display_result();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
return;
|
||||
}
|
||||
114
include/template/operation_exercice-input_row.php
Normal file
114
include/template/operation_exercice-input_row.php
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?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@aevalys.eu 7/01/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief input data for one row of OPERATION_EXERCICE_DETAIL, inherited data $operation_detail_sql
|
||||
*
|
||||
* \see Operation_Exercice::input_row
|
||||
*/
|
||||
Noalyss\Dbg::echo_file(__FILE__);
|
||||
|
||||
$data = $operation_detail_sql->to_array();
|
||||
|
||||
if (DEBUGNOALYSS > 1) echo \Noalyss\Dbg::hidden_info("data", $data);
|
||||
|
||||
$poste = new \IPoste("oe_poste");
|
||||
$poste->value = $data['oed_poste'];
|
||||
$poste->id = 'oe_poste';
|
||||
$poste->set_attribute('gDossier', Dossier::id());
|
||||
$poste->set_attribute('jrn', 0);
|
||||
$poste->set_attribute('account', 'oe_poste');
|
||||
$label_id= uniqid('label');
|
||||
$poste->set_attribute('label',$label_id);
|
||||
|
||||
$poste->dbl_click_history();
|
||||
|
||||
|
||||
$card = new \ICard("qcode");
|
||||
$card->value = $data['oed_qcode'];
|
||||
$card->set_dblclick("fill_ipopcard(this);");
|
||||
$card->set_attribute('label', "label");
|
||||
$card->set_function('fill_data');
|
||||
$card->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ', $card->name);
|
||||
|
||||
$label = new IText("label", $data['oed_label']);
|
||||
$label->id=$label_id;
|
||||
$label->size = 80;
|
||||
|
||||
$amount = new INum("amount", $data['oed_amount']);
|
||||
|
||||
$checkbox = new ICheckBox("debit");
|
||||
|
||||
$checkbox->value = 't';
|
||||
$checkbox->selected =($data['oed_debit'] == 't')?true:false;
|
||||
|
||||
$checkbox->javascript='onclick="display_dcside(this)"';
|
||||
|
||||
echo \HtmlInput::title_box("", "operation_exercice_bx");
|
||||
?>
|
||||
<div>
|
||||
<form onsubmit="operation_exercice.save_row();return false;" id="operation_exercice_input_row_frm" method="POST">
|
||||
<?php
|
||||
echo Dossier::hidden();
|
||||
echo HtmlInput::hidden("ac", "OPCL");
|
||||
echo HtmlInput::hidden("row_id", $operation_detail_sql->oed_id);
|
||||
echo HtmlInput::hidden("op", 'operation_exercice+save_row');
|
||||
echo HtmlInput::hidden("oe_id", $operation_detail_sql->oe_id);
|
||||
?>
|
||||
<div class="form-group">
|
||||
<label for="oe_poste"><?= _("Poste") ?></label>
|
||||
<?= $poste->input() ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="qcode"><?= _("Fiche") ?></label>
|
||||
<?= $card->input() ?>
|
||||
<?= $card->search() ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="oed_label"><?= _("Libellé") ?></label>
|
||||
<?= $label->input() ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="amount"><?= _("Montant") ?></label>
|
||||
<?= $amount->input() ?>
|
||||
|
||||
<?= $checkbox->input() ?>
|
||||
<label for="debit">
|
||||
<span id="txtdebit">
|
||||
<?=($data['oed_debit']=="f")?_("Crédit"):_("Débit")?>
|
||||
</span>
|
||||
|
||||
</label>
|
||||
</div>
|
||||
<ul class="aligned-block">
|
||||
<li>
|
||||
<?= \HtmlInput::submit("save", _("Sauve")) ?>
|
||||
</li>
|
||||
<li>
|
||||
<?= \HtmlInput::button_close("operation_exercice_bx") ?>
|
||||
</li>
|
||||
<li>
|
||||
<?=\HtmlInput::button_action(_("Effacer"), sprintf("operation_exercice.delete_row('%s')", $data['oed_id']))?>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
129
include/template/operation_exercice-input_source.php
Normal file
129
include/template/operation_exercice-input_source.php
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?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@aevalys.eu 6/01/24
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \brief input the source of the opening / closing operation
|
||||
*/
|
||||
|
||||
\Noalyss\Dbg::echo_file(__FILE__);
|
||||
|
||||
global $cn;
|
||||
global $g_user;
|
||||
global $g_parameter;
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// if DEBUG then show both , otherwise if MY_REPORT=Y shows opening otherwise , shows only closing
|
||||
// Show opening if report == Y or NOALYSS > 1
|
||||
//-------------------------------------------------------------------------------------------
|
||||
if ( $g_parameter->MY_REPORT=="Y" || DEBUGNOALYSS > 1) :
|
||||
?>
|
||||
<div class="content">
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<FORM method="POST">
|
||||
|
||||
<div class="" id="opening_div">
|
||||
<h2><?= _("Ouverture") ?></h2>
|
||||
<div class="text-muted">
|
||||
<?= _("Ouverture des comptes pour l'exercice qui débute pour les comptes 0 à 5.") ?>
|
||||
<?= ("Choisissez l'exercice clôturé (exercice N-1) du dossier à reporter pour les a-nouveaux (exercice N)") ?>
|
||||
</div>
|
||||
<?php
|
||||
/**************************************************************************
|
||||
* Needed information :
|
||||
* - Date of the first day of exercice
|
||||
* - Folder
|
||||
* - Exercice N-1
|
||||
*************************************************************************/
|
||||
$date = new IDate("date_opening");
|
||||
$avail = $g_user->get_available_folder();
|
||||
|
||||
|
||||
$array = array();
|
||||
$i = 0;
|
||||
foreach ($avail as $r) {
|
||||
$array[$i]['value'] = $r['dos_id'];
|
||||
$array[$i]['label'] = sprintf("%s %s (%s)",$r['dos_id'],$r['dos_name'],substr($r['dos_description']??"",0,50));
|
||||
$i++;
|
||||
}
|
||||
$sAvail = new ISelect('dos_id');
|
||||
$sAvail->id = "dos_id";
|
||||
$sAvail->selected = Dossier::id();
|
||||
$sAvail->value = $array;
|
||||
$sAvail->javascript = sprintf('onchange="operation_exercice.update_periode(%d)"',Dossier::id());
|
||||
|
||||
$exercice = $cn->make_array("select distinct p_exercice,p_exercice_label from parm_periode order by p_exercice desc");
|
||||
$sExercice = new ISelect("exercice");
|
||||
$sExercice->id = "select_exercice_id";
|
||||
$sExercice->value = $exercice;
|
||||
|
||||
echo HtmlInput::array_to_hidden(["gDossier","ac"],$_REQUEST);
|
||||
echo HtmlInput::hidden("sa","opening");
|
||||
?>
|
||||
<div class="form-group">
|
||||
<label for="dos_id"><?= _("Depuis le dossier") ?></label>
|
||||
<?= $sAvail->input() ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dos_id"><?= _("Exercice N-1") ?></label>
|
||||
<?= $sExercice->input() ?>
|
||||
</div>
|
||||
<?= \HtmlInput::submit("ope_submit", _("Valider")) ?>
|
||||
</div>
|
||||
</FORM>
|
||||
<?php
|
||||
endif;
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Show closing if report == N or NOALYSS > 1
|
||||
//-------------------------------------------------------------------------------------------
|
||||
|
||||
if ( $g_parameter->MY_REPORT=="N" || DEBUGNOALYSS > 1) :
|
||||
?>
|
||||
</div>
|
||||
<div class="col">
|
||||
|
||||
<FORM method="POST">
|
||||
<div class="" id="closing_div" style="display:grid">
|
||||
<h2>Clôture</h2>
|
||||
<div class="text-muted">Clôture de l'exercice pour les comptes 6 à 7</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
echo HtmlInput::array_to_hidden(["gDossier","ac"],$_REQUEST);
|
||||
echo HtmlInput::hidden("sa","closing");
|
||||
$cl_exercice = $cn->make_array("select distinct p_exercice,p_exercice_label from parm_periode order by p_exercice desc");
|
||||
$sclExercice = new ISelect("exercice_cl");
|
||||
$sclExercice->id = "select_exercice_cl_id";
|
||||
$sclExercice->value = $cl_exercice;
|
||||
?>
|
||||
<div class="form-group">
|
||||
<label for="exercice_cl"><?= _("Exercice à clôturer") ?></label>
|
||||
<?php echo $sclExercice->input(); ?>
|
||||
</div>
|
||||
<?= \HtmlInput::submit("ope_submit", _("Valider")) ?>
|
||||
</FORM>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
|
@ -22,8 +22,7 @@ begin
|
|||
end if;
|
||||
return NEW;
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
$function$;
|
||||
|
||||
drop trigger if exists fiche_detail_check_qcode_trg on public.fiche_detail ;
|
||||
drop function comptaproc.fiche_detail_qcode_upd();
|
||||
|
|
@ -40,3 +39,56 @@ insert into parameter values ('MY_REPORT','N') ON CONFLICT DO NOTHING;
|
|||
|
||||
update menu_ref set me_file='payment_method.inc.php' where me_code='CFGPAY';
|
||||
|
||||
update menu_ref set me_menu='Principal' where me_code='COMPANY';
|
||||
update menu_ref set me_menu='Financier' where me_code='MENUFIN';
|
||||
|
||||
CREATE OR REPLACE FUNCTION comptaproc.set_tech_user()
|
||||
RETURNS trigger
|
||||
AS $function$
|
||||
declare
|
||||
/* variable */
|
||||
noalyss_user text;
|
||||
begin
|
||||
new.tech_user := current_setting('noalyss.user_login');
|
||||
new.tech_date := now();
|
||||
return NEW;
|
||||
|
||||
exception when others then
|
||||
new.tech_date := now();
|
||||
new.tech_user := current_user;
|
||||
return NEW;
|
||||
end ;
|
||||
$function$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
drop table if exists operation_exercice_detail;
|
||||
drop table if exists operation_exercice;
|
||||
|
||||
create table operation_exercice
|
||||
(
|
||||
oe_id bigint generated by default as identity primary key,
|
||||
oe_date date null,
|
||||
oe_type text not null check (oe_type = 'opening' or oe_type = 'closing'),
|
||||
oe_text text ,
|
||||
oe_dossier_id int not null,
|
||||
oe_exercice int not null,
|
||||
tech_user text,
|
||||
tech_date timestamp default now()
|
||||
);
|
||||
|
||||
create table operation_exercice_detail
|
||||
(
|
||||
oed_id bigint generated by default as identity primary key,
|
||||
oe_id bigint references operation_exercice (oe_id) on update cascade on delete cascade not null,
|
||||
oed_poste account_type ,
|
||||
oed_qcode text ,
|
||||
oed_label text,
|
||||
oed_amount numeric (20,4),
|
||||
oed_debit bool
|
||||
);
|
||||
|
||||
create trigger trg_set_tech_user before insert or update on operation_exercice for each row execute function comptaproc.set_tech_user();
|
||||
|
||||
update menu_ref set me_code='OPCL' , me_menu='Ouvert./Fermeture',me_file='operation_exercice.inc.php',me_description='Opération de cloture ou d''ouverture d''exercice'
|
||||
,me_description_etendue ='Ecriture d''ouverture ou de fermeture , , reporte les soldes des comptes de l''année passé du poste comptable 0xxx à 5xxxx sur l''année courante ou ferme les comptes de 6 à 7 de l''année '
|
||||
where me_code='OPEN';
|
||||
Loading…
Add table
Add a link
Reference in a new issue