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