当前位置: 首页>>代码示例>>PHP>>正文


PHP moneyRound函数代码示例

本文整理汇总了PHP中moneyRound函数的典型用法代码示例。如果您正苦于以下问题:PHP moneyRound函数的具体用法?PHP moneyRound怎么用?PHP moneyRound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了moneyRound函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: exchange

 function exchange($val)
 {
     $date = sqlDate('now');
     $kes = $this->getDi()->currencyExchangeTable->getRate('KES', $date);
     $usd = $this->getDi()->currencyExchangeTable->getRate('USD', $date);
     return moneyRound($val * $kes / $usd);
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:7,代码来源:jambopay.php

示例2: calculate

 public function calculate(Invoice $invoiceBill)
 {
     $this->coupon = $invoiceBill->getCoupon();
     $this->user = $invoiceBill->getUser();
     $isFirstPayment = $invoiceBill->isFirstPayment();
     foreach ($invoiceBill->getItems() as $item) {
         $item->first_discount = $item->second_discount = 0;
         $item->_calculateTotal();
     }
     if (!$this->coupon) {
         return;
     }
     if ($this->coupon->getBatch()->discount_type == Coupon::DISCOUNT_PERCENT) {
         foreach ($invoiceBill->getItems() as $item) {
             if ($this->coupon->isApplicable($item->item_type, $item->item_id, $isFirstPayment)) {
                 $item->first_discount = moneyRound($item->first_total * $this->coupon->getBatch()->discount / 100);
             }
             if ($this->coupon->isApplicable($item->item_type, $item->item_id, false)) {
                 $item->second_discount = moneyRound($item->second_total * $this->coupon->getBatch()->discount / 100);
             }
         }
     } else {
         // absolute discount
         $discountFirst = $this->coupon->getBatch()->discount;
         $discountSecond = $this->coupon->getBatch()->discount;
         $first_discountable = $second_discountable = array();
         $first_total = $second_total = 0;
         $second_total = array_reduce($second_discountable, create_function('$s,$item', 'return $s+=$item->second_total;'), 0);
         foreach ($invoiceBill->getItems() as $item) {
             if ($this->coupon->isApplicable($item->item_type, $item->item_id, $isFirstPayment)) {
                 $first_total += $item->first_total;
                 $first_discountable[] = $item;
             }
             if ($this->coupon->isApplicable($item->item_type, $item->item_id, false)) {
                 $second_total += $item->second_total;
                 $second_discountable[] = $item;
             }
         }
         if ($first_total) {
             $k = max(0, min($discountFirst / $first_total, 1));
             // between 0 and 1!
             foreach ($first_discountable as $item) {
                 $item->first_discount = moneyRound($item->first_total * $k);
             }
         }
         if ($second_total) {
             $k = max(0, min($discountSecond / $second_total, 1));
             // between 0 and 1!
             foreach ($second_discountable as $item) {
                 $item->second_discount = moneyRound($item->second_total * $k);
             }
         }
     }
     foreach ($invoiceBill->getItems() as $item) {
         $item->_calculateTotal();
     }
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:57,代码来源:Coupon.php

示例3: calculatePiece

 public function calculatePiece(stdClass $fields)
 {
     if (!$fields->no_tax) {
         $fields->tax = moneyRound($fields->total * $this->tax_rate / 100);
     } else {
         $fields->tax = 0.0;
     }
     $fields->total += $fields->tax;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:9,代码来源:Tax.php

示例4: assertAmount

 public function assertAmount($expected, $got, $whereMsg = "amount")
 {
     if ($e = moneyRound($expected) != ($g = moneyRound($got))) {
         throw new Am_Exception_Paysystem_TransactionInvalid("Transaction {$whereMsg} [{$g}] does not match expected [{$e}]");
     }
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:6,代码来源:Incoming.php

示例5: getAmount

 public function getAmount()
 {
     return moneyRound($this->request->get('price'));
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:4,代码来源:hotmart.php

示例6: calculate

 /**
  * Refresh totals according to currently selected
  *   items, _coupon, user and so ons
  * Should be called on a fresh invoice only, because
  * it may break reporting later if called on a paid
  * invoice
  * @return Invoice provides fluent interface
  */
 function calculate()
 {
     foreach ($this->getCalculators() as $calc) {
         $calc->calculate($this);
     }
     // now summarize all items to invoice totals
     $priceFields = array('first_subtotal' => null, 'first_discount' => 'first_discount', 'first_tax' => 'first_tax', 'first_shipping' => 'first_shipping', 'first_total' => 'first_total', 'second_subtotal' => null, 'second_discount' => 'second_discount', 'second_tax' => 'second_tax', 'second_shipping' => 'second_shipping', 'second_total' => 'second_total');
     foreach ($priceFields as $k => $kk) {
         $this->{$k} = 0.0;
     }
     foreach ($this->getItems() as $item) {
         $this->first_subtotal += moneyRound($item->first_price * $item->qty);
         $this->second_subtotal += moneyRound($item->second_price * $item->qty);
         foreach ($priceFields as $k => $kk) {
             $this->{$k} += $kk ? $item->{$kk} : 0;
         }
     }
     foreach ($priceFields as $k => $kk) {
         $this->{$k} = moneyRound($this->{$k});
     }
     /// set periods, it has been checked for compatibility in @see add()
     foreach ($this->getItems() as $item) {
         $this->currency = $item->currency;
         if (!@$this->first_period) {
             $this->first_period = $item->first_period;
         }
         if (!@$this->second_period) {
             $this->second_period = $item->second_period;
         }
         $this->rebill_times = max(@$this->rebill_times, $item->rebill_times);
     }
     if ($this->currency == Am_Currency::getDefault()) {
         $this->base_currency_multi = 1.0;
     } else {
         $this->base_currency_multi = $this->getDi()->currencyExchangeTable->getRate($this->currency, sqlDate(!empty($this->tm_added) ? $this->tm_added : $this->getDi()->sqlDateTime));
         if (!$this->base_currency_multi) {
             $this->base_currency_multi = 1;
         }
     }
     $this->getDi()->hook->call(Am_Event::INVOICE_CALCULATE, array('invoice' => $this));
     return $this;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:50,代码来源:Invoice.php

示例7: calculatePiece

 public function calculatePiece(stdClass $fields)
 {
     $orig_price = $this->item->data()->get('orig_' . $this->currentPrefix . 'price');
     $fields->price = $orig_price ? $orig_price : $fields->price;
     $fields->tax = $fields->discount = $fields->shipping = 0.0;
     $fields->total = moneyRound($fields->price * $fields->qty);
 }
开发者ID:grlf,项目名称:eyedock,代码行数:7,代码来源:Calc.php

示例8: _setExpressAmounts

 function _setExpressAmounts(Invoice $invoice)
 {
     $this->addPostParameter('PAYMENTREQUEST_0_AMT', $invoice->first_total);
     $this->addPostParameter('PAYMENTREQUEST_0_CURRENCYCODE', $invoice->currency);
     // @todo
     $this->addPostParameter('PAYMENTREQUEST_0_ITEMAMT', $invoice->first_total - $invoice->first_tax);
     //        $this->addPostParameter('PAYMENTREQUEST_0_SHIPPINGAMT', $invoice->first_shipping);
     $this->addPostParameter('PAYMENTREQUEST_0_TAXAMT', $invoice->first_tax);
     $this->addPostParameter('PAYMENTREQUEST_0_INVNUM', $invoice->getSecureId('paypal'));
     $this->addPostParameter('PAYMENTREQUEST_0_NOTIFYURL', $this->plugin->getPluginUrl('ipn'));
     $this->addPostParameter('PAYMENTREQUEST_0_PAYMENTACTION', 'Sale');
     $i = 0;
     foreach ($invoice->getItems() as $item) {
         /* @var $item InvoiceItem */
         $this->addPostParameter('L_PAYMENTREQUEST_0_NAME' . $i, $item->item_title);
         $this->addPostParameter('L_PAYMENTREQUEST_0_AMT' . $i, moneyRound(($item->first_total - $item->first_tax) / $item->qty));
         //            $this->addPostParameter('L_PAYMENTREQUEST_0_ITEMAMT'.$i, $item->getFirstSubtotal());
         //            $this->addPostParameter('L_PAYMENTREQUEST_0_NUMBER'.$i, $item->item_id);
         $this->addPostParameter('L_PAYMENTREQUEST_0_QTY' . $i, $item->qty);
         //            $this->addPostParameter('L_PAYMENTREQUEST_0_TAXAMT'.$i, $item->first_tax);
         /// The unique non-changing identifier for the seller at the marketplace site. This ID is not displayed.
         //$this->addPostParameter('L_PAYMENTREQUEST_0_SELLERID'.$i, );
         // PAYMENTREQUEST_n_SELLERPAYPALACCOUNTID
         $i++;
     }
     if ($invoice->rebill_times) {
         $this->addPostParameter('L_BILLINGTYPE0', 'RecurringPayments');
         $this->addPostParameter('L_BILLINGAGREEMENTDESCRIPTION0', $invoice->getTerms());
     }
 }
开发者ID:grlf,项目名称:eyedock,代码行数:30,代码来源:PaypalApiRequest.php

示例9: calculatePiece

 public function calculatePiece(stdClass $fields)
 {
     $fields->tax = $fields->discount = $fields->shipping = 0.0;
     $fields->total = moneyRound($fields->price * $fields->qty);
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:5,代码来源:Zero.php

示例10: getAmount

 public function getAmount()
 {
     return moneyRound($this->vars['Amount']);
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:4,代码来源:sagepay-form.php

示例11: setAmount

 function setAmount($amount)
 {
     $this->amount = moneyRound($amount);
     return $this;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:5,代码来源:Manual.php

示例12: getPlannedRebills

 function getPlannedRebills($start, $stop)
 {
     $row = $this->getDi()->db->selectRow("\n            SELECT \n                COUNT(*) AS cnt, \n                SUM(second_total) AS total \n            FROM ?_invoice\n            WHERE rebill_date BETWEEN DATE(?) AND DATE(?)\n            ", sqlTime(strtotime($start)), sqlTime(strtotime($stop)));
     return array((int) $row['cnt'], moneyRound($row['total']));
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:5,代码来源:AdminController.php

示例13: getUnusedAmount

 /**
  * Return unused amount for $item subscription
  * null will be returned if:
  *   - subscription is lifetime
  *   - subscription is for free product
  *   - subscription is expired
  * @param Invoice $invoice
  * @param InvoiceItem $item
  * @return float|null
  */
 function getUnusedAmount(Invoice $invoice, InvoiceItem $item)
 {
     $row = $this->getDi()->db->selectRow("\n            SELECT begin_date, expire_date \n            FROM ?_access\n            WHERE invoice_id=?d AND product_id=?\n            ORDER by expire_date desc LIMIT 1 \n            ", $invoice->pk(), $item->item_id);
     if (!$row) {
         return;
     }
     $maxExpire = $row['expire_date'];
     $maxBegin = $row['begin_date'];
     if ($maxExpire < $this->getDi()->sqlDate) {
         return null;
     }
     if ($maxExpire == Am_Period::MAX_SQL_DATE) {
         return null;
     }
     $daysTotal = $this->diffDays($maxBegin, $maxExpire);
     $daysUnused = $this->diffDays($this->getDi()->sqlDate, $maxExpire) - 1;
     // -1 as today date can be fully used
     $pc = $invoice->getPaymentsCount();
     $field = $pc == 1 && (double) $invoice->first_total || $pc == 0 ? 'first_total' : 'second_total';
     $paid = $item->get($field);
     return moneyRound($daysUnused * $paid / $daysTotal);
 }
开发者ID:grlf,项目名称:eyedock,代码行数:32,代码来源:ProductUpgrade.php

示例14: getSaleCode

    function getSaleCode(Invoice $invoice, InvoicePayment $payment)
    {
        if ($this->getDi()->config->get('analytics_version', 'google') == 'universal') {
            $out = <<<CUT
<script type="text/javascript">
    ga('create', '{$this->id}', 'auto');
    ga('send', 'pageview');
</script>
CUT;
        } else {
            $out = <<<CUT

<script type="text/javascript">
if (typeof(_gaq)=='object') { // sometimes google-analytics can be blocked and we will avoid error
    _gaq.push(['_setAccount', '{$this->id}']);
    _gaq.push(['_trackPageview']);
}
</script>
CUT;
        }
        if (empty($payment->amount) && !$this->getDi()->config->get('google_analytics_track_free_signups')) {
            return $out;
        } elseif (empty($payment->amount)) {
            $a = array($invoice->public_id, $this->getDi()->config->get('site_title'), 0, 0, 0, $invoice->getCity(), $invoice->getState(), $invoice->getCountry());
        } else {
            $a = array($payment->transaction_id, $this->getDi()->config->get('site_title'), $payment->amount - $payment->tax - $payment->shipping, (double) $payment->tax, (double) $payment->shipping, $invoice->getCity(), $invoice->getState(), $invoice->getCountry());
        }
        $a = implode(",\n", array_map('json_encode', $a));
        $items = "";
        foreach ($invoice->getItems() as $item) {
            if ($this->getDi()->config->get('analytics_version', 'google') == 'universal') {
                $it = json_encode(array('id' => $payment->transaction_id, 'name' => $item->item_title, 'sku' => $item->item_id, 'price' => moneyRound($item->first_total / $item->qty), 'quantity' => $item->qty));
                $items .= "ga('ecommerce:addItem', {$it});\n";
            } else {
                $items .= "['_addItem', '{$payment->transaction_id}', '{$item->item_id}', '{$item->item_title}','', {$item->first_total}, {$item->qty}],";
            }
        }
        if ($this->getDi()->config->get('analytics_version', 'google') == 'universal') {
            $tr = json_encode(array('id' => $payment->transaction_id, 'affiliation' => $this->getDi()->config->get("site_title"), 'revenue' => empty($payment->amount) ? 0 : $payment->amount - $payment->tax - $payment->shipping, 'shipping' => empty($payment->amount) ? 0 : $payment->shipping, 'tax' => empty($payment->amount) ? 0 : $payment->tax));
            return $out . <<<CUT
<script type="text/javascript">
    ga('require', 'ecommerce');
    ga('ecommerce:addTransaction', {$tr});
    {$items}
    ga('ecommerce:send');
</script>
<!-- end of GA code -->
CUT;
        }
        return $out . <<<CUT
<script type="text/javascript">
if (typeof(_gaq)=='object') { // sometimes google-analytics can be blocked and we will avoid error
    _gaq.push(
        ['_addTrans', {$a}],
        {$items}
        ['_trackTrans']
    );
}
</script>
<!-- end of GA code -->
CUT;
    }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:62,代码来源:google-analytics.php

示例15: calculate

 public function calculate(Invoice $invoice, InvoiceItem $item, User $aff, $paymentNumber = 0, $tier = 0, $paymentAmount = 0.0, $paymentDate = 'now', &$matchedRules = array())
 {
     // take aff.commission_days in account for 1-tier only
     if ($tier == 0 && ($commissionDays = $this->getDi()->config->get('aff.commission_days'))) {
         $signupDays = $this->getDi()->time - strtotime($invoice->getUser()->aff_added ? $invoice->getUser()->aff_added : $invoice->getUser()->added);
         $signupDays = intval($signupDays / (3600 * 24));
         // to days
         if ($commissionDays < $signupDays) {
             return;
         }
         // no commission for this case, affiliate<->user relation is expired
     }
     $multi = 1.0;
     $isFirst = $paymentNumber <= 1;
     $prefix = $isFirst && (double) $item->first_total ? 'first' : 'second';
     if ($tier == 0) {
         if ($invoice->get("{$prefix}_total") == 0) {
             $paidForItem = 0;
         } else {
             $paidForItem = $paymentAmount * $item->get("{$prefix}_total") / $invoice->get("{$prefix}_total");
         }
     } else {
         // for higher tier just take amount paid to previous tier
         $paidForItem = $paymentAmount;
     }
     $paidForItem = $tier ? $paidForItem : $paidForItem / $invoice->base_currency_multi;
     foreach ($this->findRules($invoice, $item, $aff, $paymentNumber, $tier, $paymentDate) as $rule) {
         array_push($matchedRules, $rule);
         // Second tier commission have to be calculated as percent from First tier commission.
         if ($tier > 0) {
             return moneyRound($rule->first_payment_c * $paidForItem / 100);
         }
         if ($rule->type == AffCommissionRule::TYPE_MULTI) {
             $multi *= $rule->multi;
         } else {
             if ($paidForItem == 0) {
                 // free signup?
                 if ($paymentNumber == 0 && $rule->free_signup_c) {
                     return moneyRound($multi * $rule->free_signup_c);
                 }
             } elseif ($isFirst) {
                 // first payment
                 if ($rule->first_payment_t == '%') {
                     return moneyRound($multi * $rule->first_payment_c * $paidForItem / 100);
                 } else {
                     return moneyRound($multi * $rule->first_payment_c);
                 }
             } else {
                 // recurring payment
                 if ($rule->recurring_t == '%') {
                     return moneyRound($multi * $rule->recurring_c * $paidForItem / 100);
                 } else {
                     return moneyRound($multi * $rule->recurring_c);
                 }
             }
         }
     }
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:58,代码来源:AffCommissionRule.php


注:本文中的moneyRound函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。