本文整理汇总了PHP中CRM_Contribute_BAO_Contribution::getFinancialAccountId方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution::getFinancialAccountId方法的具体用法?PHP CRM_Contribute_BAO_Contribution::getFinancialAccountId怎么用?PHP CRM_Contribute_BAO_Contribution::getFinancialAccountId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution::getFinancialAccountId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeFeeSelections
/**
* @param array $params
* @param int $participantId
* @param int $contributionId
* @param $feeBlock
* @param array $lineItems
* @param $paidAmount
* @param int $priceSetId
*/
public static function changeFeeSelections($params, $participantId, $contributionId, $feeBlock, $lineItems, $paidAmount, $priceSetId)
{
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
$pendingRefundStatusId = array_search('Pending refund', $contributionStatuses);
$previousLineItems = CRM_Price_BAO_LineItem::getLineItems($participantId, 'participant');
CRM_Price_BAO_PriceSet::processAmount($feeBlock, $params, $lineItems);
// get the submitted
foreach ($feeBlock as $id => $values) {
CRM_Price_BAO_LineItem::format($id, $params, $values, $submittedLineItems);
$submittedFieldId[] = CRM_Utils_Array::retrieveValueRecursive($submittedLineItems, 'price_field_id');
}
if (!empty($submittedLineItems)) {
$insertLines = $submittedLineItems;
$submittedFieldValueIds = array_keys($submittedLineItems);
$updateLines = array();
foreach ($previousLineItems as $id => $previousLineItem) {
// check through the submitted items if the previousItem exists,
// if found in submitted items, do not use it for new item creations
if (in_array($previousLineItem['price_field_value_id'], $submittedFieldValueIds)) {
// if submitted line items are existing don't fire INSERT query
unset($insertLines[$previousLineItem['price_field_value_id']]);
// for updating the line items i.e. use-case - once deselect-option selecting again
if ($previousLineItem['line_total'] != $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'] || $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'] == 0 && $submittedLineItems[$previousLineItem['price_field_value_id']]['qty'] == 1 || $previousLineItem['qty'] != $submittedLineItems[$previousLineItem['price_field_value_id']]['qty']) {
$updateLines[$previousLineItem['price_field_value_id']] = $submittedLineItems[$previousLineItem['price_field_value_id']];
$updateLines[$previousLineItem['price_field_value_id']]['id'] = $id;
}
}
}
$submittedFields = implode(', ', $submittedFieldId);
$submittedFieldValues = implode(', ', $submittedFieldValueIds);
}
if (!empty($submittedFields) && !empty($submittedFieldValues)) {
$updateLineItem = "UPDATE civicrm_line_item li\nINNER JOIN civicrm_financial_item fi\n ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')\nSET li.qty = 0,\n li.line_total = 0.00,\n li.tax_amount = NULL\nWHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId}) AND\n (price_field_value_id NOT IN ({$submittedFieldValues}))\n";
CRM_Core_DAO::executeQuery($updateLineItem);
// gathering necessary info to record negative (deselected) financial_item
$updateFinancialItem = "\n SELECT fi.*, SUM(fi.amount) as differenceAmt, price_field_value_id, financial_type_id, tax_amount\n FROM civicrm_financial_item fi LEFT JOIN civicrm_line_item li ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')\nWHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId})\nGROUP BY li.entity_table, li.entity_id, price_field_value_id, fi.id\n";
$updateFinancialItemInfoDAO = CRM_Core_DAO::executeQuery($updateFinancialItem);
$trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId, 'DESC', TRUE);
$trxnId['id'] = $trxn['financialTrxnId'];
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$updateFinancialItemInfoValues = array();
$financialItemsArray = array();
while ($updateFinancialItemInfoDAO->fetch()) {
$updateFinancialItemInfoValues = (array) $updateFinancialItemInfoDAO;
$updateFinancialItemInfoValues['transaction_date'] = date('YmdHis');
// the below params are not needed
unset($updateFinancialItemInfoValues['id']);
unset($updateFinancialItemInfoValues['created_date']);
// if not submitted and difference is not 0 make it negative
if (!in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] != 0) {
// INSERT negative financial_items
$updateFinancialItemInfoValues['amount'] = -$updateFinancialItemInfoValues['amount'];
if ($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']) {
$updateFinancialItemInfoValues['tax']['amount'] = -$previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount'];
$updateFinancialItemInfoValues['tax']['description'] = $taxTerm;
if ($updateFinancialItemInfoValues['financial_type_id']) {
$updateFinancialItemInfoValues['tax']['financial_account_id'] = CRM_Contribute_BAO_Contribution::getFinancialAccountId($updateFinancialItemInfoValues['financial_type_id']);
}
}
// INSERT negative financial_items for tax amount
$financialItemsArray[] = $updateFinancialItemInfoValues;
} elseif (in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] == 0) {
$updateFinancialItemInfoValues['amount'] = $updateFinancialItemInfoValues['amount'];
// INSERT financial_items for tax amount
if ($updateFinancialItemInfoValues['entity_id'] == $updateLines[$updateFinancialItemInfoValues['price_field_value_id']]['id'] && isset($updateLines[$updateFinancialItemInfoValues['price_field_value_id']]['tax_amount'])) {
$updateFinancialItemInfoValues['tax']['amount'] = $updateLines[$updateFinancialItemInfoValues['price_field_value_id']]['tax_amount'];
$updateFinancialItemInfoValues['tax']['description'] = $taxTerm;
if ($updateLines[$updateFinancialItemInfoValues['price_field_value_id']]['financial_type_id']) {
$updateFinancialItemInfoValues['tax']['financial_account_id'] = CRM_Contribute_BAO_Contribution::getFinancialAccountId($updateLines[$updateFinancialItemInfoValues['price_field_value_id']]['financial_type_id']);
}
}
$financialItemsArray[] = $updateFinancialItemInfoValues;
}
}
} elseif (empty($submittedFields) && empty($submittedFieldValues)) {
$updateLineItem = "UPDATE civicrm_line_item li\n INNER JOIN civicrm_financial_item fi\n ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')\n SET li.qty = 0,\n li.line_total = 0.00,\n li.tax_amount = NULL\n WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId})";
CRM_Core_DAO::executeQuery($updateLineItem);
}
$amountLevel = array();
$totalParticipant = $participantCount = 0;
if (!empty($updateLines)) {
foreach ($updateLines as $valueId => $vals) {
$taxAmount = "NULL";
if (isset($vals['tax_amount'])) {
$taxAmount = $vals['tax_amount'];
}
$amountLevel[] = $vals['label'] . ' - ' . (double) $vals['qty'];
if (isset($vals['participant_count'])) {
$participantCount = $vals['participant_count'];
//.........这里部分代码省略.........