/** * 税金付与した金額を返す * * ・店舗基本情報に基づいた計算は SC_Helper_DB::sfTax() を使用する * * @param integer $price 計算対象の金額 * @param integer $tax 税率(%単位) * XXX integer のみか不明 * @param integer $tax_rule 端数処理 * @return integer 税金付与した金額 */ function sfCalcIncTax($price, $tax, $tax_rule) { return $price + SC_Utils_Ex::sfTax($price, $tax, $tax_rule); }
/** * 店舗基本情報に基づいて税金額を返す * * @param integer $price 計算対象の金額 * @return double 税金額 */ public function sfTax($price) { // 店舗基本情報を取得 $CONF = SC_Helper_DB_Ex::sfGetBasisData(); return SC_Utils_Ex::sfTax($price, $CONF['tax'], $CONF['tax_rule']); }
/** * 入力内容のチェックを行う. * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @return array エラーメッセージの配列 */ public function lfCheckError(&$objFormParam) { $objProduct = new SC_Product_Ex(); $arrValues = $objFormParam->getHashArray(); $arrErr = array(); $arrErrTemp = $objFormParam->checkError(); $arrErrDate = array(); foreach ($arrValues['shipping_date_year'] as $key_index => $year) { $month = $arrValues['shipping_date_month'][$key_index]; $day = $arrValues['shipping_date_day'][$key_index]; $objError = new SC_CheckError_Ex(array('shipping_date_year' => $year, 'shipping_date_month' => $month, 'shipping_date_day' => $day)); $objError->doFunc(array('お届け日', 'shipping_date_year', 'shipping_date_month', 'shipping_date_day'), array('CHECK_DATE')); $arrErrDate['shipping_date_year'][$key_index] = $objError->arrErr['shipping_date_year']; } $arrErrTemp = array_merge($arrErrTemp, $arrErrDate); // 複数項目チェック $year = $arrValues['order_birth_year']; $month = $arrValues['order_birth_month']; $day = $arrValues['order_birth_day']; $objError = new SC_CheckError_Ex(array('order_birth_year' => $year, 'order_birth_month' => $month, 'order_birth_day' => $day)); $objError->doFunc(array('生年月日', 'order_birth_year', 'order_birth_month', 'order_birth_day'), array('CHECK_BIRTHDAY')); $arrErrTemp['order_birth_year'] = $objError->arrErr['order_birth_year']; // 商品の種類数 $max = count($arrValues['quantity']); $subtotal = 0; $totalpoint = 0; $totaltax = 0; for ($i = 0; $i < $max; $i++) { // 小計の計算 $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i]; // 小計の計算 $totaltax += SC_Utils_Ex::sfTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i]; // 加算ポイントの計算 $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; // 在庫数のチェック $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]); // 編集前の値と比較するため受注詳細を取得 $objPurchase = new SC_Helper_Purchase_Ex(); $arrOrderDetail = SC_Utils_Ex::sfSwapArray($objPurchase->getOrderDetail($objFormParam->getValue('order_id'), false)); if ($arrProduct['stock_unlimited'] != '1' && $arrProduct['stock'] < $arrValues['quantity'][$i] - $arrOrderDetail['quantity'][$i]) { $class_name1 = $arrValues['classcategory_name1'][$i]; $class_name1 = SC_Utils_Ex::isBlank($class_name1) ? 'なし' : $class_name1; $class_name2 = $arrValues['classcategory_name2'][$i]; $class_name2 = SC_Utils_Ex::isBlank($class_name2) ? 'なし' : $class_name2; $arrErr['quantity'][$i] .= $arrValues['product_name'][$i] . '/(' . $class_name1 . ')/(' . $class_name2 . ') の在庫が不足しています。 設定できる数量は「' . ($arrOrderDetail['quantity'][$i] + $arrProduct['stock']) . '」までです。<br />'; } } // 消費税 $arrValues['tax'] = $totaltax; // 小計 $arrValues['subtotal'] = $subtotal; // 合計 $arrValues['total'] = $subtotal - $arrValues['discount'] + $arrValues['deliv_fee'] + $arrValues['charge']; // お支払い合計 $arrValues['payment_total'] = $arrValues['total'] - $arrValues['use_point'] * POINT_VALUE; // 加算ポイント $arrValues['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']) + $arrValues['birth_point']; // 最終保持ポイント $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point']; if ($arrValues['total'] < 0) { $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />'; } if ($arrValues['payment_total'] < 0) { $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />'; } if ($arrValues['total_point'] < 0) { $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />'; } $objFormParam->setParam($arrValues); $arrErr = array_merge($arrErr, $arrErrTemp); return $arrErr; }
function lfCheek($arrInfo, $mode = "") { $objDb = new SC_Helper_DB_Ex(); $arrVal = $this->objFormParam->getHashArray(); $arrErr = array(); // 商品の種類数 $max = count($arrVal['quantity']); $subtotal = 0; $totalpoint = 0; $totaltax = 0; for ($i = 0; $i < $max; $i++) { // 小計の計算 $subtotal += SC_Utils_Ex::sfPreTax($arrVal['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']) * $arrVal['quantity'][$i]; // 小計の計算 $totaltax += SC_Utils_Ex::sfTax($arrVal['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']) * $arrVal['quantity'][$i]; // 加算ポイントの計算 $totalpoint += SC_Utils_Ex::sfPrePoint($arrVal['price'][$i], $arrVal['point_rate'][$i]) * $arrVal['quantity'][$i]; } // 消費税 $arrVal['tax'] = $totaltax; // 小計 $arrVal['subtotal'] = $subtotal; // 合計 $arrVal['total'] = $subtotal - $arrVal['discount'] + $arrVal['deliv_fee'] + $arrVal['charge']; // お支払い合計 $arrVal['payment_total'] = $arrVal['total'] - $arrVal['use_point'] * POINT_VALUE; // 加算ポイント $arrVal['add_point'] = SC_Utils_Ex::sfGetAddPoint($totalpoint, $arrVal['use_point'], $arrInfo); if (strlen($_POST['customer_id']) > 0) { list($arrVal['point'], $arrVal['total_point']) = $objDb->sfGetCustomerPointFromCid($_POST['customer_id'], $arrVal['use_point'], $arrVal['add_point']); } else { list($arrVal['point'], $arrVal['total_point']) = $objDb->sfGetCustomerPoint($_POST['order_id'], $arrVal['use_point'], $arrVal['add_point']); } if ($arrVal['total'] < 0) { $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />'; } if ($arrVal['payment_total'] < 0) { $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />'; } //新規追加受注のみ if ($mode == "add") { if ($arrVal['total_point'] < 0) { $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />'; } } $this->objFormParam->setParam($arrVal); return $arrErr; }
function sfPreTax($price, $tax = null, $tax_rule = null) { return $price + SC_Utils_Ex::sfTax($price, $tax, $tax_rule); }
function getAllProductsTax($arrInfo) { // 税合計 $total = 0; $max = $this->getMax(); for ($i = 0; $i <= $max; $i++) { $price = $_SESSION[$this->key][$i]['price']; $quantity = $_SESSION[$this->key][$i]['quantity']; $tax = SC_Utils_Ex::sfTax($price, $arrInfo['tax'], $arrInfo['tax_rule']); $total += $tax * $quantity; } return $total; }