source: branches/camp/camp-2_13-tax/data/class/helper/SC_Helper_TaxRule.php @ 22621

Revision 22621, 3.7 KB checked in by AMUAMU, 11 years ago (diff)

少し修正

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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 * 会員規約を管理するヘルパークラス.
26 *
27 * @package Helper
28 * @author AMUAMU
29 * @version $Id:$
30 */
31class SC_Helper_TaxRule
32{
33
34    /**
35     * 設定情報に基づいて税金付与した金額を返す
36     *
37     * @param integer $price 計算対象の金額
38     * @return integer 税金付与した金額
39     */
40    function sfCalcIncTax($price, $product_id = 0, $product_class_id = 0, $pref_id =0, $country_id = 0)
41    {
42        $arrTaxRule = SC_Helper_TaxRule_Ex:;getTaxRule($product_id, $product_class_id, $pref_id, $country_id);
43
44        return SC_Helper_TaxRule_Ex::sfTax($price, $arrTaxRule['tax_rate'], $arrTaxRule['tax_rule'], $arrTaxRule['tax_adjust']);
45    }
46
47    /**
48     * 税金額を返す
49     *
50     * ・店舗基本情報に基づいた計算は SC_Helper_DB::sfTax() を使用する
51     *
52     * @param integer $price 計算対象の金額
53     * @param integer $tax 税率(%単位)
54     *     XXX integer のみか不明
55     * @param integer $tax_rule 端数処理
56     * @return integer 税金額
57     */
58    function sfTax($price, $tax, $calc_rule, $tax_adjust = 0)
59    {
60        $real_tax = $tax / 100;
61        $ret = $price * $real_tax;
62        switch ($calc_rule) {
63            // 四捨五入
64            case 1:
65                $ret = round($ret);
66                break;
67            // 切り捨て
68            case 2:
69                $ret = floor($ret);
70                break;
71            // 切り上げ
72            case 3:
73                $ret = ceil($ret);
74                break;
75            // デフォルト:切り上げ
76            default:
77                $ret = ceil($ret);
78                break;
79        }
80        return $ret + $tax_adjust;
81    }
82
83    /**
84     * 税金設定情報に基づいて税金額を返す
85     *
86     * @param integer $price 計算対象の金額
87     * @return array 税設定情報
88     */
89    function getTaxRule($product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0)
90    {
91        // 条件に基づいて税情報を取得
92        $objQuery =& SC_Query_Ex::getSingletonInstance();
93        $table = 'dtb_tax_rule';
94        $where = '(product_id = 0 OR product_id = ?)'
95                    . ' AND (product_class_id = 0 OR product_class_id = ?)'
96                    . ' AND (pref_id = 0 OR pref_id = ?)'
97                    . ' AND (country_id = 0 OR country_id = ?)';
98
99        $arrVal = array($product_id, $product_class_id, $pref_id, $country_id);
100        $order = 'apply_date DESC';
101        $objQuery->setOrder($order);
102        $arrData = $objQuery->select('*', $table, $where, $arrVal);
103        // 日付や条件でこねて選択は、作り中。取りあえずスタブ的にデフォルトを返却
104        return $arrData[0];
105    }
106
107
108    function getTaxRuleList($has_disable = false)
109    {
110
111    }
112
113    function getTaxRuleData($tax_rule_id)
114    {
115
116    }
117
118
119    function registerTaxRuleData() {
120    }
121}
Note: See TracBrowser for help on using the repository browser.