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


PHP CRM_Price_BAO_LineItem::calculateTaxRate方法代码示例

本文整理汇总了PHP中CRM_Price_BAO_LineItem::calculateTaxRate方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_LineItem::calculateTaxRate方法的具体用法?PHP CRM_Price_BAO_LineItem::calculateTaxRate怎么用?PHP CRM_Price_BAO_LineItem::calculateTaxRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Price_BAO_LineItem的用法示例。


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

示例1: getLineItems

 /**
  * Given a participant id/contribution id,
  * return contribution/fee line items
  *
  * @param int $entityId
  *   participant/contribution id.
  * @param string $entity
  *   participant/contribution.
  *
  * @param null $isQuick
  * @param bool $isQtyZero
  * @param bool $relatedEntity
  *
  * @param string $overrideWhereClause
  *   E.g "WHERE contribution id = 7 " per the getLineItemsByContributionID wrapper.
  *   this function precedes the convenience of the contribution id but since it does quite a bit more than just a db retrieval we need to be able to use it even
  *   when we don't want it's entity-id magix
  *
  * @param bool $invoice
  * @return array
  *   Array of line items
  */
 public static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL, $isQtyZero = TRUE, $relatedEntity = FALSE, $overrideWhereClause = '', $invoice = FALSE)
 {
     $whereClause = $fromClause = NULL;
     $selectClause = "\n      SELECT    li.id,\n      li.label,\n      li.contribution_id,\n      li.qty,\n      li.unit_price,\n      li.line_total,\n      li.entity_table,\n      li.entity_id,\n      pf.label as field_title,\n      pf.html_type,\n      pfv.membership_type_id,\n      pfv.membership_num_terms,\n      li.price_field_id,\n      li.participant_count,\n      li.price_field_value_id,\n      li.financial_type_id,\n      li.tax_amount,\n      pfv.description";
     $condition = "li.entity_id = %2.id AND li.entity_table = 'civicrm_%2'";
     if ($relatedEntity) {
         $condition = "li.contribution_id = %2.id ";
     }
     $fromClause = "\n      FROM      civicrm_%2 as %2\n      LEFT JOIN civicrm_line_item li ON ({$condition})\n      LEFT JOIN civicrm_price_field_value pfv ON ( pfv.id = li.price_field_value_id )\n      LEFT JOIN civicrm_price_field pf ON (pf.id = li.price_field_id )";
     $whereClause = "\n      WHERE     %2.id = %1";
     // CRM-16250 get additional participant's fee selection details only for invoice PDF (if any)
     if ($entity == 'participant' && $invoice) {
         $additionalParticipantIDs = CRM_Event_BAO_Participant::getAdditionalParticipantIds($entityId);
         if (!empty($additionalParticipantIDs)) {
             $whereClause = "WHERE %2.id IN (%1, " . implode(', ', $additionalParticipantIDs) . ")";
         }
     }
     $orderByClause = " ORDER BY pf.weight, pfv.weight";
     if ($isQuick) {
         $fromClause .= " LEFT JOIN civicrm_price_set cps on cps.id = pf.price_set_id ";
         $whereClause .= " and cps.is_quick_config = 0";
     }
     if (!$isQtyZero) {
         $whereClause .= " and li.qty != 0";
     }
     $lineItems = array();
     if (!$entityId || !$entity || !$fromClause) {
         return $lineItems;
     }
     $params = array(1 => array($entityId, 'Integer'), 2 => array($entity, 'Text'));
     $getTaxDetails = FALSE;
     $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     if ($overrideWhereClause) {
         $whereClause = $overrideWhereClause;
     }
     $dao = CRM_Core_DAO::executeQuery("{$selectClause} {$fromClause} {$whereClause} {$orderByClause}", $params);
     while ($dao->fetch()) {
         if (!$dao->id) {
             continue;
         }
         $lineItems[$dao->id] = array('qty' => (double) $dao->qty, 'label' => $dao->label, 'unit_price' => $dao->unit_price, 'line_total' => $dao->line_total, 'price_field_id' => $dao->price_field_id, 'participant_count' => $dao->participant_count, 'price_field_value_id' => $dao->price_field_value_id, 'field_title' => $dao->field_title, 'html_type' => $dao->html_type, 'description' => $dao->description, 'entity_id' => empty($overrideWhereClause) ? $entityId : $dao->entity_id, 'entity_table' => $dao->entity_table, 'contribution_id' => $dao->contribution_id, 'financial_type_id' => $dao->financial_type_id, 'membership_type_id' => $dao->membership_type_id, 'membership_num_terms' => $dao->membership_num_terms, 'tax_amount' => $dao->tax_amount);
         $lineItems[$dao->id]['tax_rate'] = CRM_Price_BAO_LineItem::calculateTaxRate($lineItems[$dao->id]);
         $lineItems[$dao->id]['subTotal'] = $lineItems[$dao->id]['qty'] * $lineItems[$dao->id]['unit_price'];
         if ($lineItems[$dao->id]['tax_amount'] != '') {
             $getTaxDetails = TRUE;
         }
     }
     if ($invoicing) {
         $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
         $smarty = CRM_Core_Smarty::singleton();
         $smarty->assign('taxTerm', $taxTerm);
         $smarty->assign('getTaxDetails', $getTaxDetails);
     }
     return $lineItems;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:78,代码来源:LineItem.php


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