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