Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Extract & share code to determine revenue recognition date. #16388

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
*/

/**
*
* Back office participant form.
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* This class generates form components for processing a participation
* in an event
* Back office participant form.
*/
class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment {

Expand Down Expand Up @@ -1829,15 +1828,13 @@ public function buildEventFeeForm($form) {
*/
protected function preparePaidEventProcessing($params): array {
$participantStatus = CRM_Event_PseudoConstant::participantStatus();
$contributionParams = ['skipCleanMoney' => TRUE];
$contributionParams = [
'skipCleanMoney' => TRUE,
'revenue_recognition_date' => $this->getRevenueRecognitionDate(),
];
$lineItem = [];
$additionalParticipantDetails = [];
if (Civi::settings()->get('deferred_revenue_enabled')) {
$eventStartDate = $this->getEventValue('start_date');
if (strtotime($eventStartDate) > strtotime(date('Ymt'))) {
$contributionParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
}
}

if ($this->isPaymentOnExistingContribution()) {
$contributionParams['total_amount'] = $this->getParticipantValue('fee_amount');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved up higher


Expand Down Expand Up @@ -2050,19 +2047,8 @@ public function processContribution(
'invoice_id'
);
}
$contribParams['revenue_recognition_date'] = $this->getRevenueRecognitionDate();

if (Civi::settings()->get('deferred_revenue_enabled')) {
$eventStartDate = CRM_Utils_Array::value(
'start_date',
CRM_Utils_Array::value(
'event',
$form->_values
)
);
if (strtotime($eventStartDate) > strtotime(date('Ymt'))) {
$contribParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
}
}
//create an contribution address
// The concept of contributeMode is deprecated. Elsewhere we use the function processBillingAddress() - although
// currently that is only inherited by back-office forms.
Expand Down Expand Up @@ -2228,4 +2214,21 @@ protected function getParticipantID() {
return $this->_id ?? $this->_pId;
}

/**
* Get the value for the revenue recognition date field.
*
* @return string
*
* @throws \CiviCRM_API3_Exception
*/
protected function getRevenueRecognitionDate() {
if (Civi::settings()->get('deferred_revenue_enabled')) {
$eventStartDate = $this->getEventValue('start_date');
if (strtotime($eventStartDate) > strtotime(date('Ymt'))) {
return date('Ymd', strtotime($eventStartDate));
}
}
return '';
}

}