Skip to content

Commit

Permalink
Use function to determinie if invoicing is enabled which accounts for…
Browse files Browse the repository at this point in the history
… historical weirdness
  • Loading branch information
eileenmcnaughton committed Nov 21, 2018
1 parent 8d33433 commit 4a88526
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions CRM/Admin/Form/Preferences/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public function buildQuickForm() {

//changes for freezing the invoices/credit notes checkbox if invoicing is uncheck
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$this->assign('invoicing', $invoicing);
$this->assign('invoicing', CRM_Invoicing_Utils::isInvoicingEnabled());

$this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor'));

Expand Down
3 changes: 1 addition & 2 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ public function buildQuickForm() {

// build price set form.
$buildPriceSet = FALSE;
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$invoicing = CRM_Invoicing_Utils::isInvoicingEnabled();
$this->assign('invoicing', $invoicing);

$buildRecurBlock = FALSE;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ContributionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function preProcess() {
// assign values to the template
$this->assign($values);
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$invoicing = CRM_Invoicing_Utils::isInvoicingEnabled();
$this->assign('invoicing', $invoicing);
$this->assign('isDeferred', CRM_Utils_Array::value('deferred_revenue_enabled', $invoiceSettings));
if ($invoicing && isset($values['tax_amount'])) {
Expand Down
3 changes: 1 addition & 2 deletions CRM/Contribute/Page/UserDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ public function listContribution() {
*/
public function run() {
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$defaultInvoicePage = CRM_Utils_Array::value('default_invoice_page', $invoiceSettings);
$this->assign('invoicing', $invoicing);
$this->assign('invoicing', CRM_Invoicing_Utils::isInvoicingEnabled());
$this->assign('defaultInvoicePage', $defaultInvoicePage);
parent::preProcess();
$this->listContribution();
Expand Down
3 changes: 1 addition & 2 deletions CRM/Invoicing/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2018
*/

class CRM_Invoicing_Utils {

/**
Expand All @@ -47,7 +46,7 @@ public static function onToggle($oldValue, $newValue, $metadata) {
return;
}
$existingUserViewOptions = civicrm_api3('Setting', 'get', ['return' => 'user_dashboard_options'])['values'][CRM_Core_Config::domainID()]['user_dashboard_options'];
$optionValues= civicrm_api3('Setting', 'getoptions', ['field' => 'user_dashboard_options'])['values'];
$optionValues = civicrm_api3('Setting', 'getoptions', ['field' => 'user_dashboard_options'])['values'];
$invoiceKey = array_search('Invoices / Credit Notes', $optionValues);
$existingIndex = in_array($invoiceKey, $existingUserViewOptions);

Expand Down
4 changes: 1 addition & 3 deletions tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public function testDashboardContentContributions() {
*/
public function testDashboardContentContributionsWithInvoicingEnabled() {
$this->contributionCreate(['contact_id' => $this->contactID]);
$this->callAPISuccess('Setting', 'create', ['invoicing' => 1, 'contribution_invoice_settings' => [
'invoicing' => 1,
]]);
$this->callAPISuccess('Setting', 'create', ['invoicing' => 1]);
$this->runUserDashboard();
$expectedStrings = [
'Your Contribution(s)',
Expand Down

0 comments on commit 4a88526

Please sign in to comment.