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