當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item::setDiscount方法代碼示例

本文整理匯總了PHP中Item::setDiscount方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::setDiscount方法的具體用法?PHP Item::setDiscount怎麽用?PHP Item::setDiscount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Item的用法示例。


在下文中一共展示了Item::setDiscount方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: gerateBilling

 public function gerateBilling()
 {
     $order = null;
     $customers = $this->getUserID();
     $structJsonArray = array();
     foreach ($customers as $customer) {
         $structJson = new Json();
         $structJson->setCustomerId($customer['zoho_books_contact_id']);
         $structJson->setDate(date('d-m-Y'));
         $invoices_per_costumer = $this->getUserInvoice($customer['zoho_books_contact_id']);
         //var_dump($invoices_per_costumer);
         foreach ($invoices_per_costumer as $invoice_each) {
             $item = new Item();
             $order++;
             $item->setItemId("460000000027017");
             $item->setProjectId("");
             $item->setExpenseId("");
             $item->setName("Print Services");
             $item->setDescription($invoice_each['description']);
             $item->setItemOrder($order);
             $item->setRate($invoice_each['rate']);
             $item->setUnit("Nos");
             $item->setQuantity(1.0);
             $item->setDiscount(0.0);
             $item->setTaxId("460000000027005");
             $structJson->setLineItems($item);
             $item = null;
         }
         $structJson->setNotes("Thanks for your business.");
         $order = null;
         $structJsonArray[] = $structJson;
         $structJson = null;
     }
     return $structJsonArray;
 }
開發者ID:denisolvr,項目名稱:Billing-Code-Test,代碼行數:35,代碼來源:Bill.php

示例2: test_accessors

 public function test_accessors()
 {
     /** === Test Data === */
     $DISCOUNT = 'discount';
     $SALE_ITEM_ID = 'sale item id';
     $SUBTOTAL = 'subtotal';
     $TOTAL = 'total';
     /** === Call and asserts  === */
     $this->obj->setDiscount($DISCOUNT);
     $this->obj->setSaleItemId($SALE_ITEM_ID);
     $this->obj->setSubtotal($SUBTOTAL);
     $this->obj->setTotal($TOTAL);
     $this->assertEquals($DISCOUNT, $this->obj->getDiscount());
     $this->assertEquals($SALE_ITEM_ID, $this->obj->getSaleItemId());
     $this->assertEquals($SUBTOTAL, $this->obj->getSubtotal());
     $this->assertEquals($TOTAL, $this->obj->getTotal());
 }
開發者ID:praxigento,項目名稱:mobi_mod_mage2_pv,代碼行數:17,代碼來源:Item_Test.php

示例3: executeCalculate

 /**
  * Receives the Invoice form data and calculates each row total amount and
  * full invoice totals. Returns a json
  *
  * @param 'invoice' from Request
  * @return JSON through Response
  */
 public function executeCalculate(sfWebRequest $request)
 {
     $currency = PropertyTable::get('currency');
     $format = new sfNumberFormat($this->culture);
     $data = $request->getParameter('invoice');
     $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     $invoice = new Invoice();
     $items = array();
     $totals = array();
     if (isset($data['Items'])) {
         foreach ((array) $data['Items'] as $itemId => $itemData) {
             if ($itemData['remove']) {
                 continue;
             }
             $item = new Item();
             $item->setUnitaryCost($itemData['unitary_cost']);
             $item->setQuantity($itemData['quantity']);
             $item->setDiscount($itemData['discount']);
             if (isset($itemData['taxes_list'])) {
                 $taxes = Doctrine::getTable('Tax')->createQuery()->whereIn('id', $itemData['taxes_list'])->execute();
                 $item->Taxes = $taxes;
             }
             $items[$itemId] = $format->format($item->getGrossAmount(), 'c', $currency);
             $invoice->Items[] = $item;
         }
         $totals['base'] = $format->format($invoice->calculate('base_amount', true), 'c', $currency);
         $totals['discount'] = $format->format($invoice->calculate('discount_amount', true), 'c', $currency);
         $totals['net'] = $format->format($invoice->calculate('net_amount', true), 'c', $currency);
         $totals['taxes'] = $format->format($invoice->calculate('tax_amount', true), 'c', $currency);
         $totals['gross'] = $format->format($invoice->calculate('gross_amount', true), 'c', $currency);
     } else {
         $zero = $format->format(0, 'c', $currency);
         $totals['base'] = $zero;
         $totals['discount'] = $zero;
         $totals['net'] = $zero;
         $totals['taxes'] = $zero;
         $totals['gross'] = $zero;
     }
     return $this->renderText(json_encode(array('items' => $items, 'totals' => $totals)));
 }
開發者ID:solutema,項目名稱:siwapp-sf1,代碼行數:47,代碼來源:actions.class.php

示例4: initializeWithRawData

 /**
  * Initialize the object with raw data
  *
  * @param $data
  * @return Item
  */
 public static function initializeWithRawData($data)
 {
     $item = new Item();
     if (isset($data['description'])) {
         $item->setDescription($data['description']);
     }
     if (isset($data['amount'])) {
         $item->setAmount($data['amount']);
     }
     if (isset($data['price'])) {
         $item->setPrice($data['price']);
     }
     if (isset($data['vat'])) {
         $item->setVat($data['vat']);
     }
     if (isset($data['reference_id'])) {
         $item->setReferenceId($data['reference_id']);
     }
     if (isset($data['total_without_vat'])) {
         $item->setTotalWithoutVat($data['total_without_vat']);
     }
     if (isset($data['total_vat'])) {
         $item->setTotalVat($data['total_vat']);
     }
     if (isset($data['total_with_vat'])) {
         $item->setTotalWithVat($data['total_with_vat']);
     }
     if (isset($data['discount'])) {
         $item->setDiscount($data['discount']);
     }
     if (isset($data['percentage'])) {
         $item->setDiscountIsPercentage($data['percentage']);
     }
     if (isset($data['discount_description'])) {
         $item->setDiscountDescription($data['discount_description']);
     }
     return $item;
 }
開發者ID:sumocoders,項目名稱:factr,代碼行數:44,代碼來源:Item.php

示例5: generateInvoiceItems

 protected function generateInvoiceItems()
 {
     for ($j = 0; $j < mt_rand(1, 10); $j++) {
         $item = new Item();
         $item->setDescription($this->items[array_rand($this->items)]);
         $item->setUnitaryCost(mt_rand(100, 100000) / 100);
         $item->setQuantity(mt_rand(1, 10));
         if (mt_rand(1, 15) == 1) {
             $item->setDiscount(mt_rand(1, 70));
         }
         $max_tax = mt_rand(1, 10) == 1 ? mt_rand(1, 3) : 1;
         for ($kk = 0; $kk < $max_tax; $kk++) {
             $item->Taxes[] = $this->getRandomTax();
         }
         $this->inv->Items[] = $item;
     }
 }
開發者ID:solutema,項目名稱:siwapp-sf1,代碼行數:17,代碼來源:RandomDataLoadTask.class.php

示例6: dirname

<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(6, new lime_output_color());
$t->diag('Item class tests');
$item = new Item();
$item->setUnitaryCost(1234.214);
$item->setQuantity(3);
$item->setDiscount(13);
$tax1 = new Tax();
$tax2 = new Tax();
$tax1->setValue(16);
$tax2->setValue(4);
$item->Taxes[] = $tax1;
$item->Taxes[] = $tax2;
$base = 1234.214 * 3;
$discount = $base * 13 / 100;
$taxAmount = ($base - $discount) * ($tax1->value + $tax2->value) / 100;
$t->is($item->getBaseAmount(), $base, 'getBaseAmount()');
$t->is($item->getNetAmount(), $base - $discount, 'getNetAmount()');
$t->is($item->getDiscountAmount(), $discount, 'getDiscountAmount()');
$t->is($item->getTaxAmount(), $taxAmount, 'getTaxAmount()');
$t->is($item->getGrossAmount(), $base - $discount + $taxAmount, 'getGrossAmount()');
$t->is($item->getTaxesPercent(), $tax1->value + $tax2->value, 'getTaxesPercent()');
開發者ID:solutema,項目名稱:siwapp-sf1,代碼行數:24,代碼來源:ItemTest.php


注:本文中的Item::setDiscount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。