当前位置: 首页>>代码示例>>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;未经允许,请勿转载。