Merge pull request #20251 from larssandergreen/change-registration-button-text
[civicrm-core.git] / CRM / Contribute / DAO / Contribution.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contribute/Contribution.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:204947e70942c2db4fb9b84398818aa1)
10 */
11
12 /**
13 * Database access object for the Contribution entity.
14 */
15 class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.3';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_contribution';
26
27 /**
28 * Icon associated with this entity.
29 *
30 * @var string
31 */
32 public static $_icon = 'fa-credit-card';
33
34 /**
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 *
37 * @var bool
38 */
39 public static $_log = TRUE;
40
41 /**
42 * Paths for accessing this entity in the UI.
43 *
44 * @var string[]
45 */
46 protected static $_paths = [
47 'add' => 'civicrm/contribute/add?reset=1&action=add&context=standalone',
48 'view' => 'civicrm/contact/view/contribution?reset=1&action=view&id=[id]',
49 'update' => 'civicrm/contact/view/contribution?reset=1&action=update&id=[id]',
50 'delete' => 'civicrm/contact/view/contribution?reset=1&action=delete&id=[id]',
51 ];
52
53 /**
54 * Contribution ID
55 *
56 * @var int|string|null
57 * (SQL type: int unsigned)
58 * Note that values will be retrieved from the database as a string.
59 */
60 public $id;
61
62 /**
63 * FK to Contact ID
64 *
65 * @var int|string
66 * (SQL type: int unsigned)
67 * Note that values will be retrieved from the database as a string.
68 */
69 public $contact_id;
70
71 /**
72 * FK to Financial Type for (total_amount - non_deductible_amount).
73 *
74 * @var int|string|null
75 * (SQL type: int unsigned)
76 * Note that values will be retrieved from the database as a string.
77 */
78 public $financial_type_id;
79
80 /**
81 * The Contribution Page which triggered this contribution
82 *
83 * @var int|string|null
84 * (SQL type: int unsigned)
85 * Note that values will be retrieved from the database as a string.
86 */
87 public $contribution_page_id;
88
89 /**
90 * FK to Payment Instrument
91 *
92 * @var int|string|null
93 * (SQL type: int unsigned)
94 * Note that values will be retrieved from the database as a string.
95 */
96 public $payment_instrument_id;
97
98 /**
99 * Date contribution was received - not necessarily the creation date of the record
100 *
101 * @var string|null
102 * (SQL type: datetime)
103 * Note that values will be retrieved from the database as a string.
104 */
105 public $receive_date;
106
107 /**
108 * Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.
109 *
110 * @var float|string|null
111 * (SQL type: decimal(20,2))
112 * Note that values will be retrieved from the database as a string.
113 */
114 public $non_deductible_amount;
115
116 /**
117 * Total amount of this contribution. Use market value for non-monetary gifts.
118 *
119 * @var float|string
120 * (SQL type: decimal(20,2))
121 * Note that values will be retrieved from the database as a string.
122 */
123 public $total_amount;
124
125 /**
126 * actual processor fee if known - may be 0.
127 *
128 * @var float|string|null
129 * (SQL type: decimal(20,2))
130 * Note that values will be retrieved from the database as a string.
131 */
132 public $fee_amount;
133
134 /**
135 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
136 *
137 * @var float|string|null
138 * (SQL type: decimal(20,2))
139 * Note that values will be retrieved from the database as a string.
140 */
141 public $net_amount;
142
143 /**
144 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
145 *
146 * @var string|null
147 * (SQL type: varchar(255))
148 * Note that values will be retrieved from the database as a string.
149 */
150 public $trxn_id;
151
152 /**
153 * unique invoice id, system generated or passed in
154 *
155 * @var string|null
156 * (SQL type: varchar(255))
157 * Note that values will be retrieved from the database as a string.
158 */
159 public $invoice_id;
160
161 /**
162 * Human readable invoice number
163 *
164 * @var string|null
165 * (SQL type: varchar(255))
166 * Note that values will be retrieved from the database as a string.
167 */
168 public $invoice_number;
169
170 /**
171 * 3 character string, value from config setting or input via user.
172 *
173 * @var string|null
174 * (SQL type: varchar(3))
175 * Note that values will be retrieved from the database as a string.
176 */
177 public $currency;
178
179 /**
180 * when was gift cancelled
181 *
182 * @var string|null
183 * (SQL type: datetime)
184 * Note that values will be retrieved from the database as a string.
185 */
186 public $cancel_date;
187
188 /**
189 * @var string|null
190 * (SQL type: text)
191 * Note that values will be retrieved from the database as a string.
192 */
193 public $cancel_reason;
194
195 /**
196 * when (if) receipt was sent. populated automatically for online donations w/ automatic receipting
197 *
198 * @var string|null
199 * (SQL type: datetime)
200 * Note that values will be retrieved from the database as a string.
201 */
202 public $receipt_date;
203
204 /**
205 * when (if) was donor thanked
206 *
207 * @var string|null
208 * (SQL type: datetime)
209 * Note that values will be retrieved from the database as a string.
210 */
211 public $thankyou_date;
212
213 /**
214 * Origin of this Contribution.
215 *
216 * @var string|null
217 * (SQL type: varchar(255))
218 * Note that values will be retrieved from the database as a string.
219 */
220 public $source;
221
222 /**
223 * @var string|null
224 * (SQL type: text)
225 * Note that values will be retrieved from the database as a string.
226 */
227 public $amount_level;
228
229 /**
230 * Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.
231 *
232 * @var int|string|null
233 * (SQL type: int unsigned)
234 * Note that values will be retrieved from the database as a string.
235 */
236 public $contribution_recur_id;
237
238 /**
239 * @var bool|string|null
240 * (SQL type: tinyint)
241 * Note that values will be retrieved from the database as a string.
242 */
243 public $is_test;
244
245 /**
246 * @var bool|string|null
247 * (SQL type: tinyint)
248 * Note that values will be retrieved from the database as a string.
249 */
250 public $is_pay_later;
251
252 /**
253 * @var int|string|null
254 * (SQL type: int unsigned)
255 * Note that values will be retrieved from the database as a string.
256 */
257 public $contribution_status_id;
258
259 /**
260 * Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.
261 *
262 * @var int|string|null
263 * (SQL type: int unsigned)
264 * Note that values will be retrieved from the database as a string.
265 */
266 public $address_id;
267
268 /**
269 * @var string|null
270 * (SQL type: varchar(255))
271 * Note that values will be retrieved from the database as a string.
272 */
273 public $check_number;
274
275 /**
276 * The campaign for which this contribution has been triggered.
277 *
278 * @var int|string|null
279 * (SQL type: int unsigned)
280 * Note that values will be retrieved from the database as a string.
281 */
282 public $campaign_id;
283
284 /**
285 * unique credit note id, system generated or passed in
286 *
287 * @var string|null
288 * (SQL type: varchar(255))
289 * Note that values will be retrieved from the database as a string.
290 */
291 public $creditnote_id;
292
293 /**
294 * Total tax amount of this contribution.
295 *
296 * @var float|string|null
297 * (SQL type: decimal(20,2))
298 * Note that values will be retrieved from the database as a string.
299 */
300 public $tax_amount;
301
302 /**
303 * Stores the date when revenue should be recognized.
304 *
305 * @var string|null
306 * (SQL type: datetime)
307 * Note that values will be retrieved from the database as a string.
308 */
309 public $revenue_recognition_date;
310
311 /**
312 * Shows this is a template for recurring contributions.
313 *
314 * @var bool|string|null
315 * (SQL type: tinyint)
316 * Note that values will be retrieved from the database as a string.
317 */
318 public $is_template;
319
320 /**
321 * Class constructor.
322 */
323 public function __construct() {
324 $this->__table = 'civicrm_contribution';
325 parent::__construct();
326 }
327
328 /**
329 * Returns localized title of this entity.
330 *
331 * @param bool $plural
332 * Whether to return the plural version of the title.
333 */
334 public static function getEntityTitle($plural = FALSE) {
335 return $plural ? ts('Contributions') : ts('Contribution');
336 }
337
338 /**
339 * Returns user-friendly description of this entity.
340 *
341 * @return string
342 */
343 public static function getEntityDescription() {
344 return ts('Financial records consisting of transactions, line-items, etc.');
345 }
346
347 /**
348 * Returns foreign keys and entity references.
349 *
350 * @return array
351 * [CRM_Core_Reference_Interface]
352 */
353 public static function getReferenceColumns() {
354 if (!isset(Civi::$statics[__CLASS__]['links'])) {
355 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
356 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
357 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
358 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
359 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
360 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'address_id', 'civicrm_address', 'id');
361 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
362 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
363 }
364 return Civi::$statics[__CLASS__]['links'];
365 }
366
367 /**
368 * Returns all the column names of this table
369 *
370 * @return array
371 */
372 public static function &fields() {
373 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
374 Civi::$statics[__CLASS__]['fields'] = [
375 'contribution_id' => [
376 'name' => 'id',
377 'type' => CRM_Utils_Type::T_INT,
378 'title' => ts('Contribution ID'),
379 'description' => ts('Contribution ID'),
380 'required' => TRUE,
381 'import' => TRUE,
382 'where' => 'civicrm_contribution.id',
383 'export' => TRUE,
384 'table_name' => 'civicrm_contribution',
385 'entity' => 'Contribution',
386 'bao' => 'CRM_Contribute_BAO_Contribution',
387 'localizable' => 0,
388 'html' => [
389 'type' => 'Number',
390 ],
391 'readonly' => TRUE,
392 'add' => '1.3',
393 ],
394 'contribution_contact_id' => [
395 'name' => 'contact_id',
396 'type' => CRM_Utils_Type::T_INT,
397 'title' => ts('Contact ID'),
398 'description' => ts('FK to Contact ID'),
399 'required' => TRUE,
400 'import' => TRUE,
401 'where' => 'civicrm_contribution.contact_id',
402 'headerPattern' => '/contact(.?id)?/i',
403 'dataPattern' => '/^\d+$/',
404 'export' => TRUE,
405 'table_name' => 'civicrm_contribution',
406 'entity' => 'Contribution',
407 'bao' => 'CRM_Contribute_BAO_Contribution',
408 'localizable' => 0,
409 'FKClassName' => 'CRM_Contact_DAO_Contact',
410 'html' => [
411 'type' => 'EntityRef',
412 'label' => ts("Contact"),
413 ],
414 'add' => '1.3',
415 ],
416 'financial_type_id' => [
417 'name' => 'financial_type_id',
418 'type' => CRM_Utils_Type::T_INT,
419 'title' => ts('Financial Type ID'),
420 'description' => ts('FK to Financial Type for (total_amount - non_deductible_amount).'),
421 'where' => 'civicrm_contribution.financial_type_id',
422 'export' => TRUE,
423 'table_name' => 'civicrm_contribution',
424 'entity' => 'Contribution',
425 'bao' => 'CRM_Contribute_BAO_Contribution',
426 'localizable' => 0,
427 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
428 'html' => [
429 'type' => 'Select',
430 'label' => ts("Financial Type"),
431 ],
432 'pseudoconstant' => [
433 'table' => 'civicrm_financial_type',
434 'keyColumn' => 'id',
435 'labelColumn' => 'name',
436 ],
437 'add' => '4.3',
438 ],
439 'contribution_page_id' => [
440 'name' => 'contribution_page_id',
441 'type' => CRM_Utils_Type::T_INT,
442 'title' => ts('Contribution Page ID'),
443 'description' => ts('The Contribution Page which triggered this contribution'),
444 'import' => TRUE,
445 'where' => 'civicrm_contribution.contribution_page_id',
446 'export' => TRUE,
447 'table_name' => 'civicrm_contribution',
448 'entity' => 'Contribution',
449 'bao' => 'CRM_Contribute_BAO_Contribution',
450 'localizable' => 0,
451 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
452 'html' => [
453 'type' => 'Select',
454 'label' => ts("Contribution Page"),
455 ],
456 'pseudoconstant' => [
457 'table' => 'civicrm_contribution_page',
458 'keyColumn' => 'id',
459 'labelColumn' => 'title',
460 ],
461 'add' => '1.5',
462 ],
463 'payment_instrument_id' => [
464 'name' => 'payment_instrument_id',
465 'type' => CRM_Utils_Type::T_INT,
466 'title' => ts('Payment Method ID'),
467 'description' => ts('FK to Payment Instrument'),
468 'where' => 'civicrm_contribution.payment_instrument_id',
469 'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i',
470 'export' => TRUE,
471 'table_name' => 'civicrm_contribution',
472 'entity' => 'Contribution',
473 'bao' => 'CRM_Contribute_BAO_Contribution',
474 'localizable' => 0,
475 'html' => [
476 'type' => 'Select',
477 'label' => ts("Payment Method"),
478 ],
479 'pseudoconstant' => [
480 'optionGroupName' => 'payment_instrument',
481 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
482 ],
483 'add' => '1.3',
484 ],
485 'receive_date' => [
486 'name' => 'receive_date',
487 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
488 'title' => ts('Date Received'),
489 'description' => ts('Date contribution was received - not necessarily the creation date of the record'),
490 'import' => TRUE,
491 'where' => 'civicrm_contribution.receive_date',
492 'headerPattern' => '/receive(.?date)?/i',
493 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
494 'export' => TRUE,
495 'table_name' => 'civicrm_contribution',
496 'entity' => 'Contribution',
497 'bao' => 'CRM_Contribute_BAO_Contribution',
498 'localizable' => 0,
499 'html' => [
500 'type' => 'Select Date',
501 'formatType' => 'activityDateTime',
502 ],
503 'add' => '1.3',
504 ],
505 'non_deductible_amount' => [
506 'name' => 'non_deductible_amount',
507 'type' => CRM_Utils_Type::T_MONEY,
508 'title' => ts('Non-deductible Amount'),
509 'description' => ts('Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.'),
510 'precision' => [
511 20,
512 2,
513 ],
514 'import' => TRUE,
515 'where' => 'civicrm_contribution.non_deductible_amount',
516 'headerPattern' => '/non?.?deduct/i',
517 'dataPattern' => '/^\d+(\.\d{2})?$/',
518 'export' => TRUE,
519 'default' => '0',
520 'table_name' => 'civicrm_contribution',
521 'entity' => 'Contribution',
522 'bao' => 'CRM_Contribute_BAO_Contribution',
523 'localizable' => 0,
524 'html' => [
525 'type' => 'Text',
526 ],
527 'add' => '1.3',
528 ],
529 'total_amount' => [
530 'name' => 'total_amount',
531 'type' => CRM_Utils_Type::T_MONEY,
532 'title' => ts('Total Amount'),
533 'description' => ts('Total amount of this contribution. Use market value for non-monetary gifts.'),
534 'required' => TRUE,
535 'precision' => [
536 20,
537 2,
538 ],
539 'import' => TRUE,
540 'where' => 'civicrm_contribution.total_amount',
541 'headerPattern' => '/^total|(.?^am(ou)?nt)/i',
542 'dataPattern' => '/^\d+(\.\d{2})?$/',
543 'export' => TRUE,
544 'table_name' => 'civicrm_contribution',
545 'entity' => 'Contribution',
546 'bao' => 'CRM_Contribute_BAO_Contribution',
547 'localizable' => 0,
548 'html' => [
549 'type' => 'Text',
550 'label' => ts("Total Amount"),
551 ],
552 'add' => '1.3',
553 ],
554 'fee_amount' => [
555 'name' => 'fee_amount',
556 'type' => CRM_Utils_Type::T_MONEY,
557 'title' => ts('Fee Amount'),
558 'description' => ts('actual processor fee if known - may be 0.'),
559 'precision' => [
560 20,
561 2,
562 ],
563 'import' => TRUE,
564 'where' => 'civicrm_contribution.fee_amount',
565 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
566 'dataPattern' => '/^\d+(\.\d{2})?$/',
567 'export' => TRUE,
568 'table_name' => 'civicrm_contribution',
569 'entity' => 'Contribution',
570 'bao' => 'CRM_Contribute_BAO_Contribution',
571 'localizable' => 0,
572 'html' => [
573 'type' => 'Text',
574 'label' => ts("Fee Amount"),
575 ],
576 'add' => '1.3',
577 ],
578 'net_amount' => [
579 'name' => 'net_amount',
580 'type' => CRM_Utils_Type::T_MONEY,
581 'title' => ts('Net Amount'),
582 'description' => ts('actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.'),
583 'precision' => [
584 20,
585 2,
586 ],
587 'import' => TRUE,
588 'where' => 'civicrm_contribution.net_amount',
589 'headerPattern' => '/net(.?am(ou)?nt)?/i',
590 'dataPattern' => '/^\d+(\.\d{2})?$/',
591 'export' => TRUE,
592 'table_name' => 'civicrm_contribution',
593 'entity' => 'Contribution',
594 'bao' => 'CRM_Contribute_BAO_Contribution',
595 'localizable' => 0,
596 'html' => [
597 'type' => 'Text',
598 'label' => ts("Net Amount"),
599 ],
600 'add' => '1.3',
601 ],
602 'trxn_id' => [
603 'name' => 'trxn_id',
604 'type' => CRM_Utils_Type::T_STRING,
605 'title' => ts('Transaction ID'),
606 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
607 'maxlength' => 255,
608 'size' => CRM_Utils_Type::HUGE,
609 'import' => TRUE,
610 'where' => 'civicrm_contribution.trxn_id',
611 'headerPattern' => '/tr(ansactio|x)n(.?id)?/i',
612 'export' => TRUE,
613 'table_name' => 'civicrm_contribution',
614 'entity' => 'Contribution',
615 'bao' => 'CRM_Contribute_BAO_Contribution',
616 'localizable' => 0,
617 'html' => [
618 'type' => 'Text',
619 ],
620 'readonly' => TRUE,
621 'add' => '1.3',
622 ],
623 'invoice_id' => [
624 'name' => 'invoice_id',
625 'type' => CRM_Utils_Type::T_STRING,
626 'title' => ts('Invoice Reference'),
627 'description' => ts('unique invoice id, system generated or passed in'),
628 'maxlength' => 255,
629 'size' => CRM_Utils_Type::HUGE,
630 'import' => TRUE,
631 'where' => 'civicrm_contribution.invoice_id',
632 'headerPattern' => '/invoice(.?id)?/i',
633 'export' => TRUE,
634 'table_name' => 'civicrm_contribution',
635 'entity' => 'Contribution',
636 'bao' => 'CRM_Contribute_BAO_Contribution',
637 'localizable' => 0,
638 'html' => [
639 'type' => 'Text',
640 ],
641 'readonly' => TRUE,
642 'add' => '1.3',
643 ],
644 'invoice_number' => [
645 'name' => 'invoice_number',
646 'type' => CRM_Utils_Type::T_STRING,
647 'title' => ts('Invoice Number'),
648 'description' => ts('Human readable invoice number'),
649 'maxlength' => 255,
650 'size' => CRM_Utils_Type::HUGE,
651 'import' => TRUE,
652 'where' => 'civicrm_contribution.invoice_number',
653 'headerPattern' => '/invoice(.?number)?/i',
654 'export' => TRUE,
655 'table_name' => 'civicrm_contribution',
656 'entity' => 'Contribution',
657 'bao' => 'CRM_Contribute_BAO_Contribution',
658 'localizable' => 0,
659 'html' => [
660 'type' => 'Text',
661 ],
662 'add' => '4.7',
663 ],
664 'currency' => [
665 'name' => 'currency',
666 'type' => CRM_Utils_Type::T_STRING,
667 'title' => ts('Currency'),
668 'description' => ts('3 character string, value from config setting or input via user.'),
669 'maxlength' => 3,
670 'size' => CRM_Utils_Type::FOUR,
671 'import' => TRUE,
672 'where' => 'civicrm_contribution.currency',
673 'headerPattern' => '/cur(rency)?/i',
674 'dataPattern' => '/^[A-Z]{3}$/i',
675 'export' => TRUE,
676 'default' => NULL,
677 'table_name' => 'civicrm_contribution',
678 'entity' => 'Contribution',
679 'bao' => 'CRM_Contribute_BAO_Contribution',
680 'localizable' => 0,
681 'html' => [
682 'type' => 'Select',
683 'label' => ts("Currency"),
684 ],
685 'pseudoconstant' => [
686 'table' => 'civicrm_currency',
687 'keyColumn' => 'name',
688 'labelColumn' => 'full_name',
689 'nameColumn' => 'name',
690 'abbrColumn' => 'symbol',
691 ],
692 'add' => '1.3',
693 ],
694 'contribution_cancel_date' => [
695 'name' => 'cancel_date',
696 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
697 'title' => ts('Cancelled / Refunded Date'),
698 'description' => ts('when was gift cancelled'),
699 'import' => TRUE,
700 'where' => 'civicrm_contribution.cancel_date',
701 'headerPattern' => '/cancel(.?date)?/i',
702 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
703 'export' => TRUE,
704 'table_name' => 'civicrm_contribution',
705 'entity' => 'Contribution',
706 'bao' => 'CRM_Contribute_BAO_Contribution',
707 'localizable' => 0,
708 'html' => [
709 'type' => 'Select Date',
710 'formatType' => 'activityDateTime',
711 ],
712 'add' => '1.3',
713 ],
714 'cancel_reason' => [
715 'name' => 'cancel_reason',
716 'type' => CRM_Utils_Type::T_TEXT,
717 'title' => ts('Cancellation / Refund Reason'),
718 'import' => TRUE,
719 'where' => 'civicrm_contribution.cancel_reason',
720 'headerPattern' => '/(cancel.?)?reason/i',
721 'export' => TRUE,
722 'table_name' => 'civicrm_contribution',
723 'entity' => 'Contribution',
724 'bao' => 'CRM_Contribute_BAO_Contribution',
725 'localizable' => 0,
726 'html' => [
727 'type' => 'Text',
728 ],
729 'add' => '1.3',
730 ],
731 'receipt_date' => [
732 'name' => 'receipt_date',
733 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
734 'title' => ts('Receipt Date'),
735 'description' => ts('when (if) receipt was sent. populated automatically for online donations w/ automatic receipting'),
736 'import' => TRUE,
737 'where' => 'civicrm_contribution.receipt_date',
738 'headerPattern' => '/receipt(.?date)?/i',
739 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
740 'export' => TRUE,
741 'table_name' => 'civicrm_contribution',
742 'entity' => 'Contribution',
743 'bao' => 'CRM_Contribute_BAO_Contribution',
744 'localizable' => 0,
745 'html' => [
746 'type' => 'Select Date',
747 'formatType' => 'activityDateTime',
748 'label' => ts("Receipt Date"),
749 ],
750 'add' => '1.3',
751 ],
752 'thankyou_date' => [
753 'name' => 'thankyou_date',
754 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
755 'title' => ts('Thank-you Date'),
756 'description' => ts('when (if) was donor thanked'),
757 'import' => TRUE,
758 'where' => 'civicrm_contribution.thankyou_date',
759 'headerPattern' => '/thank(s|(.?you))?(.?date)?/i',
760 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
761 'export' => TRUE,
762 'table_name' => 'civicrm_contribution',
763 'entity' => 'Contribution',
764 'bao' => 'CRM_Contribute_BAO_Contribution',
765 'localizable' => 0,
766 'html' => [
767 'type' => 'Select Date',
768 'formatType' => 'activityDateTime',
769 ],
770 'add' => '1.3',
771 ],
772 'contribution_source' => [
773 'name' => 'source',
774 'type' => CRM_Utils_Type::T_STRING,
775 'title' => ts('Contribution Source'),
776 'description' => ts('Origin of this Contribution.'),
777 'maxlength' => 255,
778 'size' => CRM_Utils_Type::HUGE,
779 'import' => TRUE,
780 'where' => 'civicrm_contribution.source',
781 'headerPattern' => '/source/i',
782 'export' => TRUE,
783 'table_name' => 'civicrm_contribution',
784 'entity' => 'Contribution',
785 'bao' => 'CRM_Contribute_BAO_Contribution',
786 'localizable' => 0,
787 'html' => [
788 'type' => 'Text',
789 ],
790 'add' => '1.3',
791 ],
792 'amount_level' => [
793 'name' => 'amount_level',
794 'type' => CRM_Utils_Type::T_TEXT,
795 'title' => ts('Amount Label'),
796 'import' => TRUE,
797 'where' => 'civicrm_contribution.amount_level',
798 'export' => TRUE,
799 'table_name' => 'civicrm_contribution',
800 'entity' => 'Contribution',
801 'bao' => 'CRM_Contribute_BAO_Contribution',
802 'localizable' => 0,
803 'html' => [
804 'type' => 'Text',
805 ],
806 'add' => '1.7',
807 ],
808 'contribution_recur_id' => [
809 'name' => 'contribution_recur_id',
810 'type' => CRM_Utils_Type::T_INT,
811 'title' => ts('Recurring Contribution ID'),
812 'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'),
813 'where' => 'civicrm_contribution.contribution_recur_id',
814 'export' => TRUE,
815 'table_name' => 'civicrm_contribution',
816 'entity' => 'Contribution',
817 'bao' => 'CRM_Contribute_BAO_Contribution',
818 'localizable' => 0,
819 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
820 'html' => [
821 'label' => ts("Recurring Contribution"),
822 ],
823 'readonly' => TRUE,
824 'add' => '1.4',
825 ],
826 'is_test' => [
827 'name' => 'is_test',
828 'type' => CRM_Utils_Type::T_BOOLEAN,
829 'title' => ts('Test'),
830 'import' => TRUE,
831 'where' => 'civicrm_contribution.is_test',
832 'export' => TRUE,
833 'default' => '0',
834 'table_name' => 'civicrm_contribution',
835 'entity' => 'Contribution',
836 'bao' => 'CRM_Contribute_BAO_Contribution',
837 'localizable' => 0,
838 'html' => [
839 'type' => 'CheckBox',
840 ],
841 'add' => NULL,
842 ],
843 'is_pay_later' => [
844 'name' => 'is_pay_later',
845 'type' => CRM_Utils_Type::T_BOOLEAN,
846 'title' => ts('Is Pay Later'),
847 'import' => TRUE,
848 'where' => 'civicrm_contribution.is_pay_later',
849 'export' => TRUE,
850 'default' => '0',
851 'table_name' => 'civicrm_contribution',
852 'entity' => 'Contribution',
853 'bao' => 'CRM_Contribute_BAO_Contribution',
854 'localizable' => 0,
855 'html' => [
856 'type' => 'CheckBox',
857 ],
858 'add' => '2.1',
859 ],
860 'contribution_status_id' => [
861 'name' => 'contribution_status_id',
862 'type' => CRM_Utils_Type::T_INT,
863 'title' => ts('Contribution Status ID'),
864 'import' => TRUE,
865 'where' => 'civicrm_contribution.contribution_status_id',
866 'headerPattern' => '/status/i',
867 'export' => TRUE,
868 'default' => '1',
869 'table_name' => 'civicrm_contribution',
870 'entity' => 'Contribution',
871 'bao' => 'CRM_Contribute_BAO_Contribution',
872 'localizable' => 0,
873 'html' => [
874 'type' => 'Select',
875 'label' => ts("Contribution Status"),
876 ],
877 'pseudoconstant' => [
878 'optionGroupName' => 'contribution_status',
879 'optionEditPath' => 'civicrm/admin/options/contribution_status',
880 ],
881 'add' => '1.6',
882 ],
883 'contribution_address_id' => [
884 'name' => 'address_id',
885 'type' => CRM_Utils_Type::T_INT,
886 'title' => ts('Address ID'),
887 'description' => ts('Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.'),
888 'where' => 'civicrm_contribution.address_id',
889 'export' => TRUE,
890 'table_name' => 'civicrm_contribution',
891 'entity' => 'Contribution',
892 'bao' => 'CRM_Contribute_BAO_Contribution',
893 'localizable' => 0,
894 'FKClassName' => 'CRM_Core_DAO_Address',
895 'html' => [
896 'label' => ts("Address"),
897 ],
898 'add' => '2.2',
899 ],
900 'contribution_check_number' => [
901 'name' => 'check_number',
902 'type' => CRM_Utils_Type::T_STRING,
903 'title' => ts('Check Number'),
904 'maxlength' => 255,
905 'size' => 6,
906 'import' => TRUE,
907 'where' => 'civicrm_contribution.check_number',
908 'headerPattern' => '/check(.?number)?/i',
909 'export' => TRUE,
910 'table_name' => 'civicrm_contribution',
911 'entity' => 'Contribution',
912 'bao' => 'CRM_Contribute_BAO_Contribution',
913 'localizable' => 0,
914 'html' => [
915 'type' => 'Text',
916 ],
917 'add' => '2.2',
918 ],
919 'contribution_campaign_id' => [
920 'name' => 'campaign_id',
921 'type' => CRM_Utils_Type::T_INT,
922 'title' => ts('Campaign ID'),
923 'description' => ts('The campaign for which this contribution has been triggered.'),
924 'import' => TRUE,
925 'where' => 'civicrm_contribution.campaign_id',
926 'export' => TRUE,
927 'table_name' => 'civicrm_contribution',
928 'entity' => 'Contribution',
929 'bao' => 'CRM_Contribute_BAO_Contribution',
930 'localizable' => 0,
931 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
932 'component' => 'CiviCampaign',
933 'html' => [
934 'type' => 'EntityRef',
935 'label' => ts("Campaign"),
936 ],
937 'pseudoconstant' => [
938 'table' => 'civicrm_campaign',
939 'keyColumn' => 'id',
940 'labelColumn' => 'title',
941 'prefetch' => 'FALSE',
942 ],
943 'add' => '3.4',
944 ],
945 'creditnote_id' => [
946 'name' => 'creditnote_id',
947 'type' => CRM_Utils_Type::T_STRING,
948 'title' => ts('Credit Note ID'),
949 'description' => ts('unique credit note id, system generated or passed in'),
950 'maxlength' => 255,
951 'size' => CRM_Utils_Type::HUGE,
952 'import' => TRUE,
953 'where' => 'civicrm_contribution.creditnote_id',
954 'headerPattern' => '/creditnote(.?id)?/i',
955 'export' => TRUE,
956 'table_name' => 'civicrm_contribution',
957 'entity' => 'Contribution',
958 'bao' => 'CRM_Contribute_BAO_Contribution',
959 'localizable' => 0,
960 'html' => [
961 'type' => 'Text',
962 ],
963 'add' => '4.6',
964 ],
965 'tax_amount' => [
966 'name' => 'tax_amount',
967 'type' => CRM_Utils_Type::T_MONEY,
968 'title' => ts('Tax Amount'),
969 'description' => ts('Total tax amount of this contribution.'),
970 'precision' => [
971 20,
972 2,
973 ],
974 'import' => TRUE,
975 'where' => 'civicrm_contribution.tax_amount',
976 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
977 'dataPattern' => '/^\d+(\.\d{2})?$/',
978 'export' => TRUE,
979 'table_name' => 'civicrm_contribution',
980 'entity' => 'Contribution',
981 'bao' => 'CRM_Contribute_BAO_Contribution',
982 'localizable' => 0,
983 'html' => [
984 'type' => 'Text',
985 ],
986 'add' => '4.6',
987 ],
988 'revenue_recognition_date' => [
989 'name' => 'revenue_recognition_date',
990 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
991 'title' => ts('Revenue Recognition Date'),
992 'description' => ts('Stores the date when revenue should be recognized.'),
993 'import' => TRUE,
994 'where' => 'civicrm_contribution.revenue_recognition_date',
995 'headerPattern' => '/revenue(.?date)?/i',
996 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
997 'export' => TRUE,
998 'table_name' => 'civicrm_contribution',
999 'entity' => 'Contribution',
1000 'bao' => 'CRM_Contribute_BAO_Contribution',
1001 'localizable' => 0,
1002 'html' => [
1003 'type' => 'Select Date',
1004 'formatType' => 'activityDateTime',
1005 'label' => ts("Revenue Recognition Date"),
1006 ],
1007 'add' => '4.7',
1008 ],
1009 'is_template' => [
1010 'name' => 'is_template',
1011 'type' => CRM_Utils_Type::T_BOOLEAN,
1012 'title' => ts('Is a Template Contribution'),
1013 'description' => ts('Shows this is a template for recurring contributions.'),
1014 'import' => TRUE,
1015 'where' => 'civicrm_contribution.is_template',
1016 'export' => TRUE,
1017 'default' => '0',
1018 'table_name' => 'civicrm_contribution',
1019 'entity' => 'Contribution',
1020 'bao' => 'CRM_Contribute_BAO_Contribution',
1021 'localizable' => 0,
1022 'html' => [
1023 'type' => 'CheckBox',
1024 ],
1025 'readonly' => TRUE,
1026 'add' => '5.20',
1027 ],
1028 ];
1029 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
1030 }
1031 return Civi::$statics[__CLASS__]['fields'];
1032 }
1033
1034 /**
1035 * Return a mapping from field-name to the corresponding key (as used in fields()).
1036 *
1037 * @return array
1038 * Array(string $name => string $uniqueName).
1039 */
1040 public static function &fieldKeys() {
1041 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
1042 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
1043 }
1044 return Civi::$statics[__CLASS__]['fieldKeys'];
1045 }
1046
1047 /**
1048 * Returns the names of this table
1049 *
1050 * @return string
1051 */
1052 public static function getTableName() {
1053 return self::$_tableName;
1054 }
1055
1056 /**
1057 * Returns if this table needs to be logged
1058 *
1059 * @return bool
1060 */
1061 public function getLog() {
1062 return self::$_log;
1063 }
1064
1065 /**
1066 * Returns the list of fields that can be imported
1067 *
1068 * @param bool $prefix
1069 *
1070 * @return array
1071 */
1072 public static function &import($prefix = FALSE) {
1073 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution', $prefix, []);
1074 return $r;
1075 }
1076
1077 /**
1078 * Returns the list of fields that can be exported
1079 *
1080 * @param bool $prefix
1081 *
1082 * @return array
1083 */
1084 public static function &export($prefix = FALSE) {
1085 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution', $prefix, []);
1086 return $r;
1087 }
1088
1089 /**
1090 * Returns the list of indices
1091 *
1092 * @param bool $localize
1093 *
1094 * @return array
1095 */
1096 public static function indices($localize = TRUE) {
1097 $indices = [
1098 'UI_contrib_payment_instrument_id' => [
1099 'name' => 'UI_contrib_payment_instrument_id',
1100 'field' => [
1101 0 => 'payment_instrument_id',
1102 ],
1103 'localizable' => FALSE,
1104 'sig' => 'civicrm_contribution::0::payment_instrument_id',
1105 ],
1106 'index_total_amount_receive_date' => [
1107 'name' => 'index_total_amount_receive_date',
1108 'field' => [
1109 0 => 'total_amount',
1110 1 => 'receive_date',
1111 ],
1112 'localizable' => FALSE,
1113 'sig' => 'civicrm_contribution::0::total_amount::receive_date',
1114 ],
1115 'index_source' => [
1116 'name' => 'index_source',
1117 'field' => [
1118 0 => 'source',
1119 ],
1120 'localizable' => FALSE,
1121 'sig' => 'civicrm_contribution::0::source',
1122 ],
1123 'UI_contrib_trxn_id' => [
1124 'name' => 'UI_contrib_trxn_id',
1125 'field' => [
1126 0 => 'trxn_id',
1127 ],
1128 'localizable' => FALSE,
1129 'unique' => TRUE,
1130 'sig' => 'civicrm_contribution::1::trxn_id',
1131 ],
1132 'UI_contrib_invoice_id' => [
1133 'name' => 'UI_contrib_invoice_id',
1134 'field' => [
1135 0 => 'invoice_id',
1136 ],
1137 'localizable' => FALSE,
1138 'unique' => TRUE,
1139 'sig' => 'civicrm_contribution::1::invoice_id',
1140 ],
1141 'index_contribution_status' => [
1142 'name' => 'index_contribution_status',
1143 'field' => [
1144 0 => 'contribution_status_id',
1145 ],
1146 'localizable' => FALSE,
1147 'sig' => 'civicrm_contribution::0::contribution_status_id',
1148 ],
1149 'received_date' => [
1150 'name' => 'received_date',
1151 'field' => [
1152 0 => 'receive_date',
1153 ],
1154 'localizable' => FALSE,
1155 'sig' => 'civicrm_contribution::0::receive_date',
1156 ],
1157 'check_number' => [
1158 'name' => 'check_number',
1159 'field' => [
1160 0 => 'check_number',
1161 ],
1162 'localizable' => FALSE,
1163 'sig' => 'civicrm_contribution::0::check_number',
1164 ],
1165 'index_creditnote_id' => [
1166 'name' => 'index_creditnote_id',
1167 'field' => [
1168 0 => 'creditnote_id',
1169 ],
1170 'localizable' => FALSE,
1171 'sig' => 'civicrm_contribution::0::creditnote_id',
1172 ],
1173 ];
1174 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1175 }
1176
1177 }