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.');
+ }
$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'])) {
// total amount
$this->type("total_amount", "100");
+ // revenue recognition date (CRM-16189)
+ if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+ $this->webtestFillDate('revenue_recognition_date', 'now+4');
+ }
// select payment instrument type = Check and enter chk number
$this->select("payment_instrument_id", "value=4");
$this->assertElementContainsText("xpath=//table[@id='info']/tbody/tr[2]/td[1]", "£ 100.00");
}
+ public function testRevenueRecognitionDateAdd() {
+ $this->webtestLogin();
+ $this->openCiviPage("admin/setting/preferences/contribute", "reset=1");
+ $this->waitForElementPresent("_qf_Contribute_next");
+ $this->click('deferred_revenue_enabled');
+ $this->click('_qf_Contribute_next');
+ $this->waitForPageToLoad($this->getTimeoutMsec());
+
+ // Create a contact to be used as soft creditor
+ $softCreditFname = substr(sha1(rand()), 0, 7);
+ $softCreditLname = substr(sha1(rand()), 0, 7);
+ $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
+
+ //financial account for check
+ $this->openCiviPage("admin/options/payment_instrument", "reset=1");
+ $financialAccount = $this->getText("xpath=//div[@id='payment_instrument']/table/tbody//tr/td[1]/div[text()='Check']/../../td[3]");
+
+ // Add new Financial Account
+ $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
+ $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
+ $financialAccountDescription = "{$financialAccountTitle} Description";
+ $accountingCode = 1033;
+ $financialAccountType = 'Asset';
+ $taxDeductible = FALSE;
+ $isActive = FALSE;
+ $isTax = TRUE;
+ $taxRate = 9;
+ $isDefault = FALSE;
+
+ //Add new organisation
+ if ($orgName) {
+ $this->webtestAddOrganization($orgName);
+ }
+
+ $this->_testAddFinancialAccount($financialAccountTitle,
+ $financialAccountDescription,
+ $accountingCode,
+ $orgName,
+ $financialAccountType,
+ $taxDeductible,
+ $isActive,
+ $isTax,
+ $taxRate,
+ $isDefault
+ );
+
+ $firstName = 'John' . substr(sha1(rand()), 0, 7);
+ $lastName = 'Dsouza' . substr(sha1(rand()), 0, 7);
+ $this->webtestAddContact($firstName, $lastName);
+
+ $this->waitForElementPresent("css=li#tab_contribute a");
+ $this->click("css=li#tab_contribute a");
+ $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
+ $this->clickLink("link=Record Contribution (Check, Cash, EFT ...)", "_qf_Contribution_cancel-bottom", FALSE);
+
+ // select financial type
+ $this->select("financial_type_id", "value=1");
+
+ // fill in Received Date
+ $this->webtestFillDate('receive_date');
+
+ // source
+ $this->type("source", "Mailer 1");
+
+ // total amount
+ $this->type("total_amount", "100");
+
+ // revenue recognition date (CRM-16189)
+ $this->webtestFillDate('revenue_recognition_date', 'now');
+
+ // select payment instrument type = Check and enter chk number
+ $this->select("payment_instrument_id", "value=4");
+ $this->waitForElementPresent("check_number");
+ $this->type("check_number", "check #1041");
+
+ $this->type("trxn_id", "P20901X1" . rand(100, 10000));
+
+ //Additional Detail section
+ $this->click("AdditionalDetail");
+ $this->waitForElementPresent("thankyou_date");
+
+ $this->type("note", "This is a test note.");
+ $this->type("non_deductible_amount", "10.00");
+ $this->type("fee_amount", "0");
+ $this->type("net_amount", "0");
+ $this->type("invoice_id", time());
+ $this->webtestFillDate('thankyou_date');
+
+ // Clicking save.
+ $this->click("_qf_Contribution_upload");
+
+ // verify if Contribution is created
+ $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='Edit']");
+
+ //click through to the Contribution edit screen
+ $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='Edit']");
+ $this->waitForElementPresent("_qf_Contribution_cancel");
+ $val = $this->getValue("xpath=//input[@id='revenue_recognition_date']");
+ $this->assertEquals(date('m/d/Y'), $val);
+ }
+
}