From 104c17df645a41ebde0ef07a0a30bd6d29555372 Mon Sep 17 00:00:00 2001 From: Ana Nelson Date: Mon, 17 May 2021 16:46:11 -0700 Subject: [PATCH] Add setting to choose invoice prefix (defaults to Civi-) --- CRM/Civiquickbooks/Invoice.php | 7 ++++++- settings/civiquickbooks.setting.php | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CRM/Civiquickbooks/Invoice.php b/CRM/Civiquickbooks/Invoice.php index 09e50dc..e0a4ef0 100644 --- a/CRM/Civiquickbooks/Invoice.php +++ b/CRM/Civiquickbooks/Invoice.php @@ -650,6 +650,11 @@ protected function mapToAccounts($db_contribution, $accountsID, $SyncToken, $qb_ 'group_name' => 'Contribute Preferences', ]); + $invoice_prefix = civicrm_api3('Setting', 'getvalue', array( + 'name' => "quickbooks_invoice_prefix", + 'group' => 'QuickBooks Online Settings', + )); + if (!empty($invoice_settings['due_date']) && !empty($invoice_settings['due_date_period'])) { $time_adjust_str = '+' . $invoice_settings['due_date'] . ' ' . $invoice_settings['due_date_period']; } @@ -700,7 +705,7 @@ protected function mapToAccounts($db_contribution, $accountsID, $SyncToken, $qb_ } if ($whereToGetInvoiceNumber == 'civi') { - $new_invoice['DocNumber'] = 'Civi-' . $db_contribution['id']; + $new_invoice['DocNumber'] = $invoice_prefix . sprintf("%07d", $db_contribution['id']); } elseif ($whereToGetInvoiceNumber == 'qb') { $new_invoice['AutoDocNumber'] = 1; diff --git a/settings/civiquickbooks.setting.php b/settings/civiquickbooks.setting.php index fdebfa8..1d87e5b 100644 --- a/settings/civiquickbooks.setting.php +++ b/settings/civiquickbooks.setting.php @@ -158,6 +158,23 @@ ], 'quick_form_type' => 'Element', ], + 'quickbooks_invoice_prefix' => [ + 'group_name' => E::ts('QuickBooks Online Settings'), + 'group' => 'civiquickbooks', + 'name' => 'quickbooks_invoice_prefix', + 'type' => 'String', + 'default' => 'Civi-', + 'title' => E::ts('Invoice Prefix'), + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => E::ts('Will be prefixed to Transaction ID when creating an invoices in QBO.'), + 'help_text' => E::ts('Will be prefixed to Transaction ID when creating an invoice in QBO.'), + 'html_type' => 'Text', + 'html_attributes' => [ + 'size' => 10, + ], + 'quick_form_type' => 'Element', + ], 'quickbooks_log_dir' => [ 'group_name' => E::ts('QuickBooks Online Settings'), 'group' => 'civiquickbooks',