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

Revision 22626, 4.0 KB checked in by AMUAMU, 11 years ago (diff)

商品詳細の表示のみはdtb_tax_ruleに従うように。

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     * @param integer $price 計算対象の金額
37     * @return integer 税金付与した金額
38     */
39    function sfCalcIncTax($price, $product_id = 0, $product_class_id = 0, $pref_id =0, $country_id = 0)
40    {
41        return $price + SC_Helper_TaxRule_Ex::sfTax($price, $product_id, $product_class_id, $pref_id, $country_id);
42    }
43
44    /**
45     * 設定情報に基づいて税金の金額を返す
46     *
47     * @param integer $price 計算対象の金額
48     * @return integer 税金した金額
49     */
50    function sfTax($price, $product_id = 0, $product_class_id = 0, $pref_id =0, $country_id = 0)
51    {
52        $arrTaxRule = SC_Helper_TaxRule_Ex::getTaxRule($product_id, $product_class_id, $pref_id, $country_id);
53        return SC_Helper_TaxRule_Ex::calcTax($price, $arrTaxRule['tax_rate'], $arrTaxRule['tax_rule'], $arrTaxRule['tax_adjust']);
54    }
55
56    /**
57     * 税金額を計算する
58     *
59     * @param integer $price 計算対象の金額
60     * @param integer $tax 税率(%単位)
61     *     XXX integer のみか不明
62     * @param integer $tax_rule 端数処理
63     * @return integer 税金額
64     */
65    function calcTax ($price, $tax, $calc_rule, $tax_adjust = 0)
66    {
67        $real_tax = $tax / 100;
68        $ret = $price * $real_tax;
69        switch ($calc_rule) {
70            // 四捨五入
71            case 1:
72                $ret = round($ret);
73                break;
74            // 切り捨て
75            case 2:
76                $ret = floor($ret);
77                break;
78            // 切り上げ
79            case 3:
80                $ret = ceil($ret);
81                break;
82            // デフォルト:切り上げ
83            default:
84                $ret = ceil($ret);
85                break;
86        }
87        return $ret + $tax_adjust;
88    }
89
90    /**
91     * 現在有効な税金設定情報を返す
92     *
93     * @param integer $price 計算対象の金額
94     * @return array 税設定情報
95     */
96    function getTaxRule($product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0)
97    {
98        // 条件に基づいて税情報を取得
99        $objQuery =& SC_Query_Ex::getSingletonInstance();
100        $table = 'dtb_tax_rule';
101        $where = '(product_id = 0 OR product_id = ?)'
102                    . ' AND (product_class_id = 0 OR product_class_id = ?)'
103                    . ' AND (pref_id = 0 OR pref_id = ?)'
104                    . ' AND (country_id = 0 OR country_id = ?)';
105
106        $arrVal = array($product_id, $product_class_id, $pref_id, $country_id);
107        $order = 'apply_date DESC';
108        $objQuery->setOrder($order);
109        $arrData = $objQuery->select('*', $table, $where, $arrVal);
110        // 日付や条件でこねて選択は、作り中。取りあえずスタブ的にデフォルトを返却
111        return $arrData[0];
112    }
113
114
115    function getTaxRuleList($has_disable = false)
116    {
117
118    }
119
120    function getTaxRuleData($tax_rule_id)
121    {
122
123    }
124
125
126    function registerTaxRuleData() {
127    }
128}
Note: See TracBrowser for help on using the repository browser.