Changeset 22653


Ignore:
Timestamp:
2013/03/09 22:31:08 (11 years ago)
Author:
maeken
Message:

商品規格登録(編集)にて税情報設定対応

Location:
branches/camp/camp-2_13-tax/data/class
Files:
3 edited

Legend:

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

    r22644 r22653  
    135135        $arrData = $objQuery->select('*', $table, $where, $arrVal); 
    136136        // 日付や条件でこねて選択は、作り中。取りあえずスタブ的にデフォルトを返却 
    137         return $arrData[0]; 
     137        // 一旦配列の最後の項目を返すように変更 
     138        // return $arrData[0]; 
     139        return $arrData[count($arrData)-1]; 
    138140    } 
    139141 
     
    144146     * @return 
    145147     */ 
    146     function setTaxRuleForProduct($tax_rate, $tax_adjust=0, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) 
    147     { 
    148         // デフォルトの設定取得 
    149         $arrRet = SC_Helper_TaxRule_Ex::getTaxRule(); 
     148    function setTaxRuleForProduct($tax_rate, $product_id = 0, $product_class_id = 0, $tax_adjust=0, $pref_id = 0, $country_id = 0) 
     149    { 
    150150        // 税情報を設定 
    151         SC_Helper_TaxRule_Ex::setTaxRule($arrRet['calc_rule'], 
    152                                          $tax_rate, 
    153                                          $arrRet['apply_date'], 
     151        SC_Helper_TaxRule_Ex::setTaxRule($tax_rate, 
    154152                                         $tax_adjust, 
    155153                                         $product_id, 
     
    160158 
    161159    /** 
    162      * 税金設定情報を登録する(仮) 
     160     * 税金設定情報を登録する(仮)リファクタする(memo:規格設定後に商品編集を行うと消費税が0になるのを対応が必要) 
    163161     * 
    164162     * @param 
    165163     * @return 
    166164     */ 
    167     function setTaxRule($calc_rule, $tax_rate, $apply_date, $tax_adjust=0, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) 
     165    function setTaxRule($tax_rate, $tax_adjust=0, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) 
    168166    { 
    169167        // デフォルトの設定とtax_rateの値が同じ場合は登録しない 
     
    172170            return; 
    173171        } 
    174         // 税情報を設定 
    175         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    176         $table = 'dtb_tax_rule'; 
    177         $arrValues = array(); 
    178         // todo idを計算して設定する必要あり 
    179         $arrValues['tax_rule_id'] = 1; 
    180         $arrValues['country_id'] = $country_id; 
    181         $arrValues['pref_id'] = $pref_id; 
    182         $arrValues['product_id'] = $product_id; 
    183         $arrValues['product_class_id'] = $product_class_id; 
    184         $arrValues['calc_rule'] = $calc_rule; 
    185         $arrValues['tax_rate'] = $tax_rate; 
    186         $arrValues['tax_adjust'] = $tax_adjust; 
    187         $arrValues['apply_date'] = $apply_date; 
    188         $arrValues['create_date'] = 'CURRENT_TIMESTAMP'; 
    189         $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; 
     172        // 新規か更新か? 
     173        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     174        $where = 'product_id=? and product_class_id=? and pref_id=? and country_id=?'; 
     175        $arrVal = array($product_id, $product_class_id, $pref_id, $country_id); 
     176        $arrCheck = $objQuery->select('*', 'dtb_tax_rule', $where, $arrVal); 
    190177         
    191         $objQuery->insert($table, $arrValues); 
     178        if(empty($arrCheck)) { 
     179            // 税情報を新規 
     180            $table = 'dtb_tax_rule'; 
     181            $arrValues = array(); 
     182            // todo idを計算して設定する必要あり(nextvalに変更?) 
     183            $arrTaxruleid = $objQuery->select('max(tax_rule_id)', 'dtb_tax_rule'); 
     184            $arrValues['tax_rule_id'] = $arrTaxruleid[0]['max(tax_rule_id)']+1; 
     185            $arrValues['country_id'] = $country_id; 
     186            $arrValues['pref_id'] = $pref_id; 
     187            $arrValues['product_id'] = $product_id; 
     188            $arrValues['product_class_id'] = $product_class_id; 
     189            $arrValues['calc_rule'] = $arrRet['calc_rule']; 
     190            $arrValues['tax_rate'] = $tax_rate; 
     191            $arrValues['tax_adjust'] = $tax_adjust; 
     192            $arrValues['apply_date'] = $arrRet['apply_date']; 
     193            $arrValues['create_date'] = 'CURRENT_TIMESTAMP'; 
     194            $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; 
     195         
     196            $objQuery->insert($table, $arrValues); 
     197        } else { 
     198            // 税情報を更新 
     199            $objQuery->update('dtb_tax_rule', array('tax_rate' => $tax_rate), $where, $arrVal); 
     200        } 
    192201    } 
    193202     
  • branches/camp/camp-2_13-tax/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php

    r22638 r22653  
    11421142         
    11431143        // 税情報設定 
    1144         SC_Helper_TaxRule_Ex::setTaxRuleForProduct($arrList['tax_rate'], 0, $arrList['product_id'], $arrList['product_class_id']); 
     1144        SC_Helper_TaxRule_Ex::setTaxRuleForProduct($arrList['tax_rate'], $arrList['product_id'], $arrList['product_class_id']); 
    11451145 
    11461146        // 関連商品登録 
  • branches/camp/camp-2_13-tax/data/class/pages/admin/products/LC_Page_Admin_Products_ProductClass.php

    r22567 r22653  
    217217        $objFormParam->addParam(NORMAL_PRICE_TITLE, 'price01', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); 
    218218        $objFormParam->addParam(SALE_PRICE_TITLE, 'price02', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); 
     219        $objFormParam->addParam('消費税率', 'tax_rate', PERCENTAGE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); 
    219220        $objFormParam->addParam('商品種別', 'product_type_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); 
    220221        $objFormParam->addParam('削除フラグ', 'del_flg', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); 
     
    294295 
    295296            $objQuery->insert('dtb_products_class', $arrPC); 
     297             
     298            // 税情報登録/更新 
     299            SC_Helper_TaxRule_Ex::setTaxRuleForProduct($arrList['tax_rate'][$i], $arrPC['product_id'], $arrPC['product_class_id']); 
    296300        } 
    297301 
     
    361365                ) { 
    362366                    $arrErr['stock'][$i] = '※ 在庫数が入力されていません。<br />'; 
     367                } 
     368                /* 
     369                 * 消費税率の必須チェック 
     370                 */ 
     371                if (SC_Utils_Ex::isBlank($arrValues['tax_rate'][$i])) 
     372                { 
     373                    $arrErr['tax_rate'][$i] = '※ 消費税率が入力されていません。<br />'; 
    363374                } 
    364375                /* 
     
    482493            'classcategory_name1', 'classcategory_name2', 'stock', 
    483494            'stock_unlimited', 'price01', 'price02', 
    484             'product_type_id', 'down_filename', 'down_realfilename', 'upload_index', 
     495            'product_type_id', 'down_filename', 'down_realfilename', 'upload_index', 'tax_rate' 
    485496        ); 
    486497        $arrFormValues = $objFormParam->getSwapArray($arrKeys); 
     
    506517                    $arrValues['del_flg'] = '0'; 
    507518                } 
     519                // 消費税率を設定 
     520                $arrRet = SC_Helper_TaxRule_Ex::getTaxRule($arrValues['product_id'], $arrValues['product_class_id']); 
     521                $arrValues['tax_rate'] = $arrRet['tax_rate']; 
     522                 
    508523                $arrMergeProductsClass[] = $arrValues; 
    509524            } 
Note: See TracChangeset for help on using the changeset viewer.