noalyss Version-9
additional_tax.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
20// Copyright 2022 Author Dany De Bontridder dany@alchimerys.be
21
22
24{
25 private $tax_amount;
27 private $currency_id;
28 private $ac_id;
29 private $ac_label;
30 private $ac_rate;
32
34 {
35 $this->tax_amount = round($tax_amount, 2);
36 $this->currency_amount = round($currency_amount, 4);
37 $this->currency_id = $currency_id;
38 $this->ac_id = $ac_id;
39 $this->ac_label = $ac_label;
40 $this->ac_rate = $ac_rate;
41 $this->ac_accounting = $ac_accounting;
42 }
43
44 /**
45 * @return float
46 */
47 public function getTaxAmount(): float
48 {
49 return $this->tax_amount;
50 }
51
52 /**
53 * @return float
54 */
55 public function getCurrencyAmount(): float
56 {
58 }
59
60 /**
61 * @return mixed
62 */
63 public function getCurrencyId()
64 {
65 return $this->currency_id;
66 }
67
68 /**
69 * @return mixed
70 */
71 public function getAcId()
72 {
73 return $this->ac_id;
74 }
75
76 /**
77 * @return mixed
78 */
79 public function getAcLabel()
80 {
81 return $this->ac_label;
82 }
83
84 /**
85 * @return mixed
86 */
87 public function getAcRate()
88 {
89 return $this->ac_rate;
90 }
91
92 /**
93 * @return mixed
94 */
95 public function getAcAccounting()
96 {
98 }
99
100 /**
101 * @brief create an array of Additional_Tax
102 * @param $p_jrn_id
103 * @param $sum_euro
104 * @param $sum_currency
105 * @return array
106 */
107 static function get_by_operation($p_jrn_id, &$sum_euro, &$sum_currency)
108 {
109 bcscale(4);
110 global $cn;
111 $array = $cn->get_array("select
112 case when j_debit is false and jn.jrn_def_type='ACH' then 0-j_montant
113 when j_debit is true and jn.jrn_def_type='VEN' then 0-j_montant
114 else j_montant end j_montant,
115 jrn.currency_id,
116 oc_amount,
117 jt.ac_id,
118 jrnx.j_debit,
119 aot.ac_label,
120 aot.ac_rate,
121 aot.ac_accounting,
122 jn.jrn_def_type
123 from jrn_tax jt
124 join jrnx using (j_id)
125 join jrn on (jrnx.j_grpt=jrn.jr_grpt_id)
126 join jrn_def jn on (jrn.jr_def_id=jn.jrn_def_id)
127 join acc_other_tax aot on (jt.ac_id=aot.ac_id)
128 left join operation_currency oc ON (oc.j_id=jt.j_id)
129 where
130 jr_id=$1", [$p_jrn_id]);
131 $sum_currency = 0;
132 $sum_euro = 0;
133 if (empty($array)) {
134 return array();
135 }
136 $nb = count($array);
137 $a_additional_tax = array();
138 for ($i = 0; $i < $nb; $i++) {
139 $a_additional_tax[] = new Additional_Tax($array[$i]['j_montant'],
140 $array[$i]['oc_amount'],
141 $array[$i]['currency_id'],
142 $array[$i]['ac_id'],
143 $array[$i]['ac_label'],
144 $array[$i]['ac_rate'],
145 $array[$i]['ac_accounting'],
146 );
147 $sum_euro = bcadd($sum_euro, $array[$i]['j_montant']);
148 $sum_currency = bcadd($sum_currency, $array[$i]['oc_amount']);
149 }
150 $sum_euro = round($sum_euro, 2);
151 return $a_additional_tax;
152 }
153
154 /**
155 * @brief display the additional_tax in the ledger_detail for Sales and Purchase
156 * @param $p_jrn_id
157 * @param $sum_euro
158 * @param $sum_currency
159 * @param int $decalage
160 */
161 static function display_row($p_jrn_id, &$sum_euro, &$sum_currency, $decalage = 0)
162 {
163 global $g_parameter;
164 $a_additional_tax = Additional_Tax::get_by_operation($p_jrn_id, $sum_euro, $sum_currency);
165 $nb = count($a_additional_tax);
166 for ($i = 0; $i < $nb; $i++) {
167 echo '<tr>';
168
169 echo td($a_additional_tax[$i]->ac_accounting);
170 echo td($a_additional_tax[$i]->ac_label . " ( " . $a_additional_tax[$i]->ac_rate . " %)");
171 echo td(nbm($a_additional_tax[$i]->tax_amount), 'class="num"');
172 if ($g_parameter->MY_TVA_USE == 'Y')
173 echo td("") . td("") . td("") . td("");
174 else
175 echo td("") ;
176 for ($e = 0; $e < $decalage; $e++) {
177 echo td("");
178 }
179 echo td(nbm($a_additional_tax[$i]->tax_amount), 'class="num"');
180 if ($a_additional_tax[$i]->currency_id != 0) {
181 echo td(nbm($a_additional_tax[$i]->currency_amount), 'class="num"');
182 }
183 echo '</tr>';
184 }
185 }
186}
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
global $g_parameter
static get_by_operation($p_jrn_id, &$sum_euro, &$sum_currency)
create an array of Additional_Tax
__construct($tax_amount, $currency_amount, $currency_id, $ac_id, $ac_label, $ac_rate, $ac_accounting)
static display_row($p_jrn_id, &$sum_euro, &$sum_currency, $decalage=0)
display the additional_tax in the ledger_detail for Sales and Purchase