'name' => "<i class='crm-i fa-pencil'></i>",
'url' => 'civicrm/payment/edit',
'class' => 'medium-popup',
- 'qs' => "reset=1&id=%%id%%&contri_id=%%contri_id%%",
+ 'qs' => "reset=1&id=%%id%%&contribution_id=%%contribution_id%%",
'title' => ts('Edit Payment'),
),
);
CRM_Core_Action::mask(array(CRM_Core_Permission::EDIT)),
array(
'id' => $resultDAO->id,
- 'contri_id' => $contributionId,
+ 'contribution_id' => $contributionId,
)
);
}
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
- * @param string $trxnEntityTable
- * Entity_table.
+ * @param array $ids
+ * The array that holds all the DB ids.
*
* @return CRM_Core_BAO_FinancialTrxn
*/
- public static function create(&$params, $trxnEntityTable = NULL) {
+ public static function create(&$params, $ids = array()) {
$trxn = new CRM_Financial_DAO_FinancialTrxn();
$trxn->copyValues($params);
$trxn->currency = CRM_Core_Config::singleton()->defaultCurrency;
}
- $trxn->save();
+ //per http://wiki.civicrm.org/confluence/display/CRM/Database+layer we are moving away from $ids array
+ $financialTrxnID = CRM_Utils_Array::value('FinancialTrxn', $ids, CRM_Utils_Array::value('id', $params));
+ $trxn->id = $financialTrxnID;
- // save to entity_financial_trxn table
- $entityFinancialTrxnParams
- = array(
- 'entity_table' => "civicrm_contribution",
- 'financial_trxn_id' => $trxn->id,
- 'amount' => $params['total_amount'],
- );
+ $trxn->save();
- if (!empty($trxnEntityTable)) {
- $entityFinancialTrxnParams['entity_table'] = $trxnEntityTable['entity_table'];
- $entityFinancialTrxnParams['entity_id'] = $trxnEntityTable['entity_id'];
- }
- elseif (!empty($params['entity_id']) && !empty($params['entity_table'])) {
- $entityFinancialTrxnParams['entity_table'] = $params['entity_table'];
- $entityFinancialTrxnParams['entity_id'] = $params['entity_id'];
- }
- else {
- $entityFinancialTrxnParams['entity_id'] = $params['contribution_id'];
+ // we shoudn't proceed further to record related entity financial trxns if it's update
+ if ($financialTrxnID) {
+ return $trxn;
}
+ // save to entity_financial_trxn table
+ $entityFinancialTrxnParams = array(
+ 'entity_table' => CRM_Utils_Array::value('entity_table', $params, 'civicrm_contribution'),
+ 'entity_id' => CRM_Utils_Array::value('entity_id', $params, CRM_Utils_Array::value('contribution_id', $params)),
+ 'financial_trxn_id' => $trxn->id,
+ 'amount' => $params['total_amount'],
+ );
+
$entityTrxn = new CRM_Financial_DAO_EntityFinancialTrxn();
$entityTrxn->copyValues($entityFinancialTrxnParams);
$entityTrxn->save();
'total_amount' => CRM_Utils_Array::value('cost', $params) ? $params['cost'] : 0,
'currency' => CRM_Utils_Array::value('currency', $params),
'status_id' => array_search('Completed', $contributionStatuses),
+ 'entity_id' => $params['contributionId'],
);
- $trxnEntityTable['entity_table'] = 'civicrm_contribution';
- $trxnEntityTable['entity_id'] = $params['contributionId'];
- CRM_Core_BAO_FinancialTrxn::create($financialtrxn, $trxnEntityTable);
+ CRM_Core_BAO_FinancialTrxn::create($financialtrxn);
}
if (!empty($params['oldPremium'])) {
parent::preProcess();
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->assign('id', $this->_id);
- $this->_contributionID = CRM_Utils_Request::retrieve('contri_id', 'Positive', $this);
+ $this->_contributionID = CRM_Utils_Request::retrieve('contribution_id', 'Positive', $this);
$this->_values = civicrm_api3('FinancialTrxn', 'getsingle', array('id' => $this->_id));
if (!empty($this->_values['payment_processor_id'])) {
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath()));
}
-
/**
* Wrapper function to process form submission
*
if (!empty($updateFinancialItemInfoValues['financialTrxn']) && ($contributionCompletedStatusID ==
CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'contribution_status_id'))
) {
- $trxnTable = array(
+ $updateFinancialItemInfoValues = array_merge($updateFinancialItemInfoValues['financialTrxn'], array(
'entity_id' => $newFinancialItem->id,
'entity_table' => 'civicrm_financial_item',
- );
- $reverseTrxn = CRM_Core_BAO_FinancialTrxn::create($updateFinancialItemInfoValues['financialTrxn'], $trxnTable);
+ ));
+ $reverseTrxn = CRM_Core_BAO_FinancialTrxn::create($updateFinancialItemInfoValues['financialTrxn']);
// record reverse entity financial trxn linked to membership's related contribution
civicrm_api3('EntityFinancialTrxn', 'create', array(
'entity_table' => "civicrm_contribution",