noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
operation_closing.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19// Copyright Author Dany De Bontridder danydb@aevalys.eu 6/01/24
20/*!
21 * \file
22 * \brief Closing operation
23 */
24/*!
25 * \class Operation_Closing
26 * \brief closing operation , end of exercice for French accountancy
27 */
29{
30 private $signature ;
31 private $exercice;
32
34 {
35 parent::__construct($p_id);
36 $this->signature='closing';
37
38 }
39 public function get_exercice()
40 {
41 return $this->exercice;
42 }
43
44 /**
45 * @param mixed $exercice
46 */
47 public function set_exercice($exercice): void
48 {
49 $this->exercice = $exercice;
50 }
51 public function get_signature(): string
52 {
53 return $this->signature;
54 }
55
56 function from_request()
57 {
58 $http = new HttpInput();
59 $this->exercice = $http->request("exercice_cl", "number");
60 }
61 /**
62 * @brief insert data into data operation_exercice and operation_exercice_detail
63 * @return void
64 */
65 function insert()
66 {
67 $cn = Dossier::connect();
68
69 $sql = "
70with total_account as (
71 select sum(a.montant) as tot_amount, j_poste, f_id
72 from
73 (select j_id, case when j_debit='t' then j_montant
74 else j_montant * (-1) end as montant
75 from jrnx) as a
76 join jrnx using (j_id)
77 join parm_periode on (j_tech_per = p_id )
78 where
79 p_exercice=$1
80 and( j_poste::text like '7%'
81 or j_poste::text like '6%')
82 group by j_poste,f_id
83 having (sum(a.montant) != 0 )
84 )
85select t1.tot_amount
86 ,t1.j_poste
87 ,(select pcm_lib from tmp_pcmn where pcm_val=t1.j_poste) as lib_accounting
88 ,t1.f_id
89 ,(select ad_value fd2 from fiche_detail fd2 where fd2.f_id=t1.f_id and fd2.ad_id=23) qcode
90,(select fd3.ad_value from fiche_detail fd3 where fd3.f_id=t1.f_id and fd3.ad_id=1) f_name
91,abs(t1.tot_amount) atot_amount
92,case when tot_amount <0 then 't' else 'f' end debit
93from total_account t1
94";
95 $exercice_report=$this->exercice;
96 $this->operation_exercice_sql->setp("oe_type", $this->signature)
97 ->setp("oe_dossier_id", Dossier::id())
98 ->set("oe_text",_("Ecriture cloture $exercice_report"))
99 ->setp("oe_exercice", $this->exercice);
100 try {
101 $cn->start();
102 $this->operation_exercice_sql->insert();
103 $array = $cn->get_array($sql, array($this->exercice));
104 if (empty($array)) return;
105 foreach ($array as $item) {
107 $row->oe_id = $this->operation_exercice_sql->oe_id;
108 $row->oed_poste = (empty($item['qcode']))?$item["j_poste"]:null;
109 $row->oed_qcode = $item["qcode"];
110 $row->oed_amount = $item['atot_amount'];
111 $row->oed_label=(empty($item['qcode']))?$item['lib_accounting']:$item['f_name'];
112 $row->oed_debit = $item["debit"];
113 $row->save();
114 }
115 $cn->commit();
116
117 } catch (\Exception $e) {
118 $cn->rollback();
119 echo $e->getMessage();
120 throw $e;
121 }
122
123 }
124 public function display_result()
125 {
126 echo h2("ClĂ´ture compte");
127
128 parent::display_result(); // TODO: Change the autogenerated stub
129 }
130}
h2($p_string, $p_class="", $raw="")
Definition ac_common.php:68
_("actif, passif,charge,...")
manage the http input (get , post, request) and extract from an array
closing operation , end of exercice for French accountancy
insert()
insert data into data operation_exercice and operation_exercice_detail
abstract of the table operation_exercice_detail
Special operations end or start of exercice.