*
* @return string
* Credit Note Id.
+ *
+ * @throws \CiviCRM_API3_Exception
*/
public static function createCreditNoteId() {
- $prefixValue = Civi::settings()->get('contribution_invoice_settings');
$creditNoteNum = CRM_Core_DAO::singleValueQuery("SELECT count(creditnote_id) as creditnote_number FROM civicrm_contribution WHERE creditnote_id IS NOT NULL");
$creditNoteId = NULL;
do {
$creditNoteNum++;
- $creditNoteId = CRM_Utils_Array::value('credit_notes_prefix', $prefixValue) . "" . $creditNoteNum;
+ $creditNoteId = Civi::settings()->get('credit_notes_prefix') . '' . $creditNoteNum;
$result = civicrm_api3('Contribution', 'getcount', [
'sequential' => 1,
'creditnote_id' => $creditNoteId,
'type' => 'Array',
'default' => [
'invoice_prefix' => 'INV_',
- 'credit_notes_prefix' => 'CN_',
'due_date' => '10',
'due_date_period' => 'days',
'notes' => '',
/**
* Function tests that financial records are added when Pending Contribution is Canceled.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCreateUpdateContributionCancelPending() {
- // Enable & disable invoicing just to standardise the credit note id setting.
- // Longer term we want to separate that setting from 'taxAndInvoicing'.
- // and / or remove from core.
- $this->enableTaxAndInvoicing();
+ Civi::settings()->set('credit_notes_prefix', 'CN_');
$contribParams = [
'contact_id' => $this->_individualId,
'receive_date' => '2012-01-01',
$this->_checkFinancialTrxn($contribution, 'cancelPending', NULL, $checkTrxnDate);
$this->_checkFinancialItem($contribution['id'], 'cancelPending');
$this->assertEquals('CN_1', $contribution['values'][$contribution['id']]['creditnote_id']);
- $this->disableTaxAndInvoicing();
}
/**