This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * This file is part of EC-CUBE |
||
4 | * |
||
5 | * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
||
6 | * |
||
7 | * http://www.lockon.co.jp/ |
||
8 | * |
||
9 | * This program is free software; you can redistribute it and/or |
||
10 | * modify it under the terms of the GNU General Public License |
||
11 | * as published by the Free Software Foundation; either version 2 |
||
12 | * of the License, or (at your option) any later version. |
||
13 | * |
||
14 | * This program is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU General Public License |
||
20 | * along with this program; if not, write to the Free Software |
||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
22 | */ |
||
23 | |||
24 | |||
25 | namespace Eccube\Service; |
||
26 | |||
27 | class TaxRuleService |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
28 | { |
||
29 | /** |
||
30 | * @var \Eccube\Repository\TaxRuleRepository |
||
31 | */ |
||
32 | private $taxRuleRepository; |
||
33 | |||
34 | /** |
||
35 | * __construct |
||
36 | * |
||
37 | * @param \Eccube\Repository\TaxRuleRepository $taxRuleRepository |
||
38 | */ |
||
39 | 615 | public function __construct(\Eccube\Repository\TaxRuleRepository $taxRuleRepository) |
|
40 | { |
||
41 | 615 | $this->taxRuleRepository = $taxRuleRepository; |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * 設定情報に基づいて税金の金額を返す |
||
46 | * |
||
47 | * @param int $price 計算対象の金額 |
||
48 | * @param int|null|\Eccube\Entity\Product $product 商品 |
||
49 | * @param int|null|\Eccube\Entity\ProductClass $productClass 商品規格 |
||
50 | * @param int|null|\Eccube\Entity\Master\Pref $pref 都道府県 |
||
51 | * @param int|null|\Eccube\Entity\Master\Country $country 国 |
||
52 | * @return double 税金付与した金額 |
||
53 | */ |
||
54 | public function getTax($price, $product = null, $productClass = null, $pref = null, $country = null) |
||
55 | { |
||
56 | /* @var $TaxRule \Eccube\Entity\TaxRule */ |
||
57 | $TaxRule = $this->taxRuleRepository->getByRule($product, $productClass, $pref, $country); |
||
58 | |||
59 | return $this->calcTax($price, $TaxRule->getTaxRate(), $TaxRule->getCalcRule()->getId(), $TaxRule->getTaxAdjust()); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * calcIncTax |
||
64 | * |
||
65 | * @param int $price 計算対象の金額 |
||
66 | * @param int|null|\Eccube\Entity\Product $product 商品 |
||
67 | * @param int|null|\Eccube\Entity\ProductClass $productClass 商品規格 |
||
68 | * @param int|null|\Eccube\Entity\Master\Pref $pref 都道府県 |
||
69 | * @param int|null|\Eccube\Entity\Master\Country $country 国 |
||
70 | * @return int |
||
71 | */ |
||
72 | public function getPriceIncTax($price, $product = null, $productClass = null, $pref = null, $country = null) |
||
73 | { |
||
74 | return $price + $this->getTax($price, $product, $productClass, $pref, $country); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * 税金額を計算する |
||
79 | * |
||
80 | * @param int $price 計算対象の金額 |
||
0 ignored issues
–
show
|
|||
81 | * @param int $taxRate 税率(%単位) |
||
0 ignored issues
–
show
|
|||
82 | * @param int $calcRule 端数処理 |
||
0 ignored issues
–
show
|
|||
83 | * @param int $taxAdjust 調整額 |
||
0 ignored issues
–
show
|
|||
84 | * @return double 税金額 |
||
85 | */ |
||
86 | 4 | public function calcTax($price, $taxRate, $calcRule, $taxAdjust = 0) |
|
87 | { |
||
88 | 4 | $tax = $price * $taxRate / 100; |
|
89 | $roundTax = $this->roundByCalcRule($tax, $calcRule); |
||
90 | |||
91 | 4 | return $roundTax + $taxAdjust; |
|
92 | 1 | } |
|
93 | |||
94 | /** |
||
95 | * 課税規則に応じて端数処理を行う |
||
96 | * |
||
97 | * @param float|integer $value 端数処理を行う数値 |
||
98 | * @param integer $calcRule 課税規則 |
||
99 | * @return double 端数処理後の数値 |
||
100 | */ |
||
101 | 4 | public function roundByCalcRule($value, $calcRule) |
|
102 | { |
||
103 | switch ($calcRule) { |
||
104 | // 四捨五入 |
||
105 | 4 | case \Eccube\Entity\Master\Taxrule::ROUND: |
|
106 | $ret = round($value); |
||
107 | 4 | break; |
|
108 | // 切り捨て |
||
109 | case \Eccube\Entity\Master\Taxrule::FLOOR: |
||
110 | $ret = floor($value); |
||
111 | break; |
||
112 | // 切り上げ |
||
113 | case \Eccube\Entity\Master\Taxrule::CEIL: |
||
114 | $ret = ceil($value); |
||
115 | break; |
||
116 | // デフォルト:切り上げ |
||
117 | default: |
||
118 | $ret = ceil($value); |
||
119 | break; |
||
120 | } |
||
121 | |||
122 | 4 | return $ret; |
|
123 | } |
||
124 | } |
||
125 |