FALSE
);
+ // CRM-16189, add Revenue Recognition Date
+ if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+ $this->add('date', 'revenue_recognition_date', ts('Revenue Recognition Date'), CRM_Core_SelectValues::date(NULL, 'M Y', NULL, 5));
+ }
+
// add various dates
$this->addDateTime('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
$errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', array(1 => $fields['trxn_id']));
}
}
-
+ if (!empty($fields['revenue_recognition_date'])
+ && count(array_filter($fields['revenue_recognition_date'])) == 1
+ ) {
+ $errors['revenue_recognition_date'] = ts('Month and Year are required field for Revenue Recognition.');
+ }
+ // CRM-16189
+ $errorMessage = CRM_Financial_BAO_FinancialAccount::checkFinancialTypeHasDeferred($fields, $self->_id, $self);
+ if ($errorMessage) {
+ $errors['financial_type_id'] = ' ';
+ $errors['_qf_default'] = $errorMessage;
+ }
$errors = array_merge($errors, $softErrors);
return $errors;
}
if ($priceSetId) {
$params['skipCleanMoney'] = 1;
}
-
+ $params['revenue_recognition_date'] = NULL;
+ if (!empty($formValues['revenue_recognition_date'])
+ && count(array_filter($formValues['revenue_recognition_date'])) == 2
+ ) {
+ $params['revenue_recognition_date'] = CRM_Utils_Date::processDate(
+ '01-' . implode('-', $formValues['revenue_recognition_date'])
+ );
+ }
$dates = array(
'receive_date',
'receipt_date',
);
foreach ($dates as $d) {
- $params[$d] = CRM_Utils_Date::processDate($formValues[$d], $formValues[$d . '_time'], TRUE);
+ if (isset($formValues[$d])) {
+ $params[$d] = CRM_Utils_Date::processDate($formValues[$d], CRM_Utils_Array::value($d . '_time', $formValues), TRUE);
+ }
}
if (!empty($formValues['is_email_receipt'])) {