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