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