Skip to content

Commit

Permalink
Add setting to choose invoice prefix (defaults to Civi-)
Browse files Browse the repository at this point in the history
  • Loading branch information
ananelson authored and agileware-fj committed Oct 17, 2022
1 parent eaf01b0 commit 104c17d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CRM/Civiquickbooks/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions settings/civiquickbooks.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 104c17d

Please sign in to comment.