From ac90350f71582d1f631a7a7d9143b3eb81ea80ce Mon Sep 17 00:00:00 2001
From: Tim Otten <totten@civicrm.org>
Date: Tue, 28 Apr 2020 15:33:33 -0700
Subject: [PATCH] dev/core#1724 - Fix defaults for invoice-related settings

The default values were previously stored in 'contribution_invoice_settings', but
the updates are stored in individual settings, which makes it difficult to reconcile
the default values and explicit values.

With this revision, 'contribution_invoice_settings' is strictly virtual, and
all the other settings (like 'invoice_due_date') are canonical.
---
 settings/Contribute.setting.php | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/settings/Contribute.setting.php b/settings/Contribute.setting.php
index b9bd3699f0a..9e6e73f37f1 100644
--- a/settings/Contribute.setting.php
+++ b/settings/Contribute.setting.php
@@ -41,17 +41,8 @@ return [
     'group' => 'contribute',
     'name' => 'contribution_invoice_settings',
     'type' => 'Array',
-    'default' => [
-      'invoice_prefix' => 'INV_',
-      'credit_notes_prefix' => 'CN_',
-      'due_date' => '10',
-      'due_date_period' => 'days',
-      'notes' => '',
-      'tax_term' => 'Sales Tax',
-      'tax_display_settings' => 'Inclusive',
-    ],
     'add' => '4.7',
-    'title' => ts('Deprecated setting'),
+    'title' => ts('Deprecated, virtualized setting'),
     'is_domain' => 1,
     'is_contact' => 0,
     'help_text' => NULL,
@@ -74,6 +65,7 @@ return [
     'settings_pages' => ['contribute' => ['weight' => 90]],
   ],
   'invoice_prefix' => [
+    'default' => 'INV_',
     'html_type' => 'text',
     'name' => 'invoice_prefix',
     'add' => '5.23',
@@ -84,6 +76,7 @@ return [
     'is_contact' => 0,
   ],
   'invoice_due_date' => [
+    'default' => '10',
     'name' => 'invoice_due_date',
     'html_type' => 'text',
     'title' => ts('Due Date'),
@@ -93,6 +86,7 @@ return [
     'is_contact' => 0,
   ],
   'invoice_due_date_period' => [
+    'default' => 'days',
     'html_type' => 'select',
     'name' => 'invoice_due_date_period',
     'title' => ts('For transmission'),
@@ -110,6 +104,7 @@ return [
     ],
   ],
   'invoice_notes' => [
+    'default' => '',
     'name' => 'invoice_notes',
     'html_type' => 'wysiwyg',
     'title' => ts('Notes or Standard Terms'),
@@ -131,6 +126,7 @@ return [
     'description' => ts('Should a pdf invoice be emailed automatically?'),
   ],
   'tax_term' => [
+    'default' => 'Sales Tax',
     'name' => 'tax_term',
     'html_type' => 'text',
     'add' => '5.23',
@@ -140,6 +136,7 @@ return [
     'is_contact' => 0,
   ],
   'tax_display_settings' => [
+    'default' => 'Inclusive',
     'html_type' => 'select',
     'name' => 'tax_display_settings',
     'type' => CRM_Utils_Type::T_STRING,
-- 
GitLab