Ignore:
Timestamp:
2013/03/09 15:27:28 (11 years ago)
Author:
AMUAMU
Message:

税金設定、税計算用ヘルパーの作成中のもの

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/camp/camp-2_13-tax/data/class/helper/SC_Helper_TaxRule.php

    r22619 r22620  
    3333 
    3434    /** 
    35      * 税金情報に基づいて税金額を返す 
     35     * 設定情報に基づいて税金付与した金額を返す 
    3636     * 
    3737     * @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_Utils_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 端数処理 
    3856     * @return integer 税金額 
    3957     */ 
    40     function sfTax($price, $product_id = 0, $product_class_id = 0, $pref_id =0, $country_id = 0) 
     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) 
    4190    { 
    4291        // 条件に基づいて税情報を取得 
     
    52101        $objQuery->setOrder($order); 
    53102        $arrData = $objQuery->select('*', $table, $where, $arrVal); 
    54         return $arrData[0]; // 
     103        // 日付や条件でこねて選択は、作り中。取りあえずスタブ的にデフォルトを返却 
     104        return $arrData[0]; 
     105    } 
     106 
     107 
     108    function getTaxRuleList($has_disable = false) 
     109    { 
    55110 
    56111    } 
    57112 
     113    function getTaxRuleData($tax_rule_id) 
     114    { 
     115 
     116    } 
     117 
     118 
     119    function registerTaxRuleData() { 
     120    } 
    58121} 
Note: See TracChangeset for help on using the changeset viewer.