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