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