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


PHP Helper::formatAmount方法代碼示例

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


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

示例1: save

 /**
  * @param Ticket $expenseTicket
  * @throws NotFoundException
  */
 public function save(Ticket $expenseTicket)
 {
     if (!$this->getServiceLocator() instanceof ServiceLocatorInterface) {
         throw new NotFoundException('Service locator not defined for expense item.');
     }
     $itemDao = $this->getItemDao();
     $costDao = $this->getCostDao();
     // Normalize values
     $this->prepare();
     $data = $this->getData();
     $itemAmount = null;
     $costCenters = [];
     $itemData = [];
     if ($this->getMode() == self::MODE_ADD) {
         $costCenters = $data['costCenters'];
         $itemAmount = $data['amount'];
         $itemData = ['transaction_id' => $data['transactionId'], 'account_id' => $data['accountId'], 'account_reference' => $data['accountReference'], 'sub_category_id' => $data['subCategoryId'], 'currency_id' => $data['currencyId'], 'amount' => Helper::formatAmount($itemAmount), 'is_startup' => $data['isStartup'], 'is_deposit' => $data['isDeposit'], 'is_refund' => $data['isRefund'], 'comment' => $data['accountComment'], 'type' => $data['type'], 'status' => $data['status']];
         if ($data['period']['from']) {
             $itemData['period_from'] = $data['period']['from'];
             $itemData['period_to'] = $data['period']['to'];
         }
     }
     switch ($this->getMode()) {
         case self::MODE_ADD:
             $itemData['expense_id'] = $expenseTicket->getExpenseId();
             $itemData['creator_id'] = $expenseTicket->getCreatorId();
             $itemData['date_created'] = date('Y-m-d H:i:s');
             if (!$data['period']['from']) {
                 $itemData['period_from'] = $itemData['period_to'] = date('Y-m-d');
             }
             $expenseItemId = $itemDao->save($itemData);
             $this->setId($expenseItemId);
             if (count($costCenters)) {
                 $costCenterAmount = $itemAmount / count($costCenters);
                 foreach ($costCenters as $costCenter) {
                     $costDao->save(['expense_item_id' => $expenseItemId, 'cost_center_id' => $costCenter['id'], 'cost_center_type' => $this->translateCCT($costCenter['type']), 'amount' => $this->calculateCostAmount($costCenterAmount, $data['currencyId'], $costCenter['currencyId'], $data['isRefund'])]);
                 }
             }
             break;
         case self::MODE_DELETE:
             $costDao->delete(['expense_item_id' => $this->getId()]);
             $itemDao->delete(['id' => $this->getId()]);
             break;
     }
 }
開發者ID:arbi,項目名稱:MyCode,代碼行數:49,代碼來源:Item.php


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