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