public static function recordPartialPayment($contribution, $params) {
$balanceTrxnParams['to_financial_account_id'] = self::getToFinancialAccount($contribution, $params);
- $fromFinancialAccountId = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($contribution['financial_type_id'], 'Accounts Receivable Account is');
- $balanceTrxnParams['from_financial_account_id'] = $fromFinancialAccountId;
+ $balanceTrxnParams['from_financial_account_id'] = CRM_Financial_BAO_FinancialAccount::getFinancialAccountForFinancialTypeByRelationship($contribution['financial_type_id'], 'Accounts Receivable Account is');
$balanceTrxnParams['total_amount'] = $params['total_amount'];
$balanceTrxnParams['contribution_id'] = $params['contribution_id'];
$balanceTrxnParams['trxn_date'] = CRM_Utils_Array::value('trxn_date', $params, CRM_Utils_Array::value('contribution_receive_date', $params, date('YmdHis')));
$balanceTrxnParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'status_id', 'Completed');
$balanceTrxnParams['payment_instrument_id'] = CRM_Utils_Array::value('payment_instrument_id', $params, $contribution['payment_instrument_id']);
$balanceTrxnParams['check_number'] = CRM_Utils_Array::value('check_number', $params);
-
- // @todo the logic of this section seems very wrong. This code is ONLY reached from the Payment.create
- // routine so is_payment should ALWAYS be true
- $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
- $statusId = array_search('Completed', $contributionStatuses);
- if ($fromFinancialAccountId != NULL &&
- ($statusId == array_search('Completed', $contributionStatuses) || $statusId == array_search('Partially paid', $contributionStatuses))
- ) {
- $balanceTrxnParams['is_payment'] = 1;
- }
+ $balanceTrxnParams['is_payment'] = 1;
if (!empty($params['payment_processor'])) {
+ // I can't find evidence this is passed in - I was gonna just remove it but decided to deprecate as I see self::getToFinancialAccount
+ // also anticipates it.
+ CRM_Core_Error::deprecatedFunctionWarning('passing payment_processor is deprecated - use payment_processor_id');
$balanceTrxnParams['payment_processor_id'] = $params['payment_processor'];
}
return CRM_Core_BAO_FinancialTrxn::create($balanceTrxnParams);
public static function recordPayment($contributionId, $trxnData, $participantId) {
list($contributionDAO, $params) = self::getContributionAndParamsInFormatForRecordFinancialTransaction($contributionId);
- if (!$participantId) {
- $participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $contributionId, 'participant_id', 'contribution_id');
- }
-
$trxnData['trxn_date'] = !empty($trxnData['trxn_date']) ? $trxnData['trxn_date'] : date('YmdHis');
$params['payment_instrument_id'] = CRM_Utils_Array::value('payment_instrument_id', $trxnData, CRM_Utils_Array::value('payment_instrument_id', $params));
// which in 'Partial Paid' => 'Completed' is not useful, instead specific financial record updates
// are coded below i.e. just updating financial_item status to 'Paid'
+ if (!$participantId) {
+ $participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $contributionId, 'participant_id', 'contribution_id');
+ }
if ($participantId) {
// update participant status
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();