本文整理汇总了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;
}
}