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