Merge pull request #19525 from eileenmcnaughton/member_soft
[civicrm-core.git] / CRM / Price / DAO / LineItem.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Price/LineItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:8455f09e75cc04248153812b7fdd6741)
10 */
11
12 /**
13 * Database access object for the LineItem entity.
14 */
15 class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.7';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_line_item';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = TRUE;
33
34 /**
35 * Line Item
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * table which has the transaction
43 *
44 * @var string
45 */
46 public $entity_table;
47
48 /**
49 * entry in table
50 *
51 * @var int
52 */
53 public $entity_id;
54
55 /**
56 * FK to civicrm_contribution
57 *
58 * @var int
59 */
60 public $contribution_id;
61
62 /**
63 * FK to civicrm_price_field
64 *
65 * @var int
66 */
67 public $price_field_id;
68
69 /**
70 * descriptive label for item - from price_field_value.label
71 *
72 * @var string
73 */
74 public $label;
75
76 /**
77 * How many items ordered
78 *
79 * @var float
80 */
81 public $qty;
82
83 /**
84 * price of each item
85 *
86 * @var float
87 */
88 public $unit_price;
89
90 /**
91 * qty * unit_price
92 *
93 * @var float
94 */
95 public $line_total;
96
97 /**
98 * Participant count for field
99 *
100 * @var int
101 */
102 public $participant_count;
103
104 /**
105 * FK to civicrm_price_field_value
106 *
107 * @var int
108 */
109 public $price_field_value_id;
110
111 /**
112 * FK to Financial Type.
113 *
114 * @var int
115 */
116 public $financial_type_id;
117
118 /**
119 * Portion of total amount which is NOT tax deductible.
120 *
121 * @var float
122 */
123 public $non_deductible_amount;
124
125 /**
126 * tax of each item
127 *
128 * @var float
129 */
130 public $tax_amount;
131
132 /**
133 * Class constructor.
134 */
135 public function __construct() {
136 $this->__table = 'civicrm_line_item';
137 parent::__construct();
138 }
139
140 /**
141 * Returns localized title of this entity.
142 *
143 * @param bool $plural
144 * Whether to return the plural version of the title.
145 */
146 public static function getEntityTitle($plural = FALSE) {
147 return $plural ? ts('Line Items') : ts('Line Item');
148 }
149
150 /**
151 * Returns foreign keys and entity references.
152 *
153 * @return array
154 * [CRM_Core_Reference_Interface]
155 */
156 public static function getReferenceColumns() {
157 if (!isset(Civi::$statics[__CLASS__]['links'])) {
158 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
159 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
160 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_id', 'civicrm_price_field', 'id');
161 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_value_id', 'civicrm_price_field_value', 'id');
162 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
163 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
164 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
165 }
166 return Civi::$statics[__CLASS__]['links'];
167 }
168
169 /**
170 * Returns all the column names of this table
171 *
172 * @return array
173 */
174 public static function &fields() {
175 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
176 Civi::$statics[__CLASS__]['fields'] = [
177 'id' => [
178 'name' => 'id',
179 'type' => CRM_Utils_Type::T_INT,
180 'title' => ts('Line Item ID'),
181 'description' => ts('Line Item'),
182 'required' => TRUE,
183 'where' => 'civicrm_line_item.id',
184 'table_name' => 'civicrm_line_item',
185 'entity' => 'LineItem',
186 'bao' => 'CRM_Price_BAO_LineItem',
187 'localizable' => 0,
188 'html' => [
189 'type' => 'Number',
190 ],
191 'add' => '1.7',
192 ],
193 'entity_table' => [
194 'name' => 'entity_table',
195 'type' => CRM_Utils_Type::T_STRING,
196 'title' => ts('Line Item Entity Type'),
197 'description' => ts('table which has the transaction'),
198 'required' => TRUE,
199 'maxlength' => 64,
200 'size' => CRM_Utils_Type::BIG,
201 'where' => 'civicrm_line_item.entity_table',
202 'table_name' => 'civicrm_line_item',
203 'entity' => 'LineItem',
204 'bao' => 'CRM_Price_BAO_LineItem',
205 'localizable' => 0,
206 'add' => '1.7',
207 ],
208 'entity_id' => [
209 'name' => 'entity_id',
210 'type' => CRM_Utils_Type::T_INT,
211 'title' => ts('Line Item Entity'),
212 'description' => ts('entry in table'),
213 'required' => TRUE,
214 'where' => 'civicrm_line_item.entity_id',
215 'table_name' => 'civicrm_line_item',
216 'entity' => 'LineItem',
217 'bao' => 'CRM_Price_BAO_LineItem',
218 'localizable' => 0,
219 'add' => '1.7',
220 ],
221 'contribution_id' => [
222 'name' => 'contribution_id',
223 'type' => CRM_Utils_Type::T_INT,
224 'title' => ts('Contribution ID'),
225 'description' => ts('FK to civicrm_contribution'),
226 'where' => 'civicrm_line_item.contribution_id',
227 'table_name' => 'civicrm_line_item',
228 'entity' => 'LineItem',
229 'bao' => 'CRM_Price_BAO_LineItem',
230 'localizable' => 0,
231 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
232 'html' => [
233 'label' => ts("Contribution"),
234 ],
235 'add' => '4.5',
236 ],
237 'price_field_id' => [
238 'name' => 'price_field_id',
239 'type' => CRM_Utils_Type::T_INT,
240 'title' => ts('Price Field ID'),
241 'description' => ts('FK to civicrm_price_field'),
242 'where' => 'civicrm_line_item.price_field_id',
243 'table_name' => 'civicrm_line_item',
244 'entity' => 'LineItem',
245 'bao' => 'CRM_Price_BAO_LineItem',
246 'localizable' => 0,
247 'FKClassName' => 'CRM_Price_DAO_PriceField',
248 'html' => [
249 'label' => ts("Price Field"),
250 ],
251 'pseudoconstant' => [
252 'table' => 'civicrm_price_field',
253 'keyColumn' => 'id',
254 'labelColumn' => 'label',
255 'nameColumn' => 'name',
256 ],
257 'add' => '1.7',
258 ],
259 'label' => [
260 'name' => 'label',
261 'type' => CRM_Utils_Type::T_STRING,
262 'title' => ts('Line Item Label'),
263 'description' => ts('descriptive label for item - from price_field_value.label'),
264 'maxlength' => 255,
265 'size' => CRM_Utils_Type::HUGE,
266 'where' => 'civicrm_line_item.label',
267 'default' => 'NULL',
268 'table_name' => 'civicrm_line_item',
269 'entity' => 'LineItem',
270 'bao' => 'CRM_Price_BAO_LineItem',
271 'localizable' => 0,
272 'html' => [
273 'type' => 'Text',
274 ],
275 'add' => '1.7',
276 ],
277 'qty' => [
278 'name' => 'qty',
279 'type' => CRM_Utils_Type::T_MONEY,
280 'title' => ts('Line Item Quantity'),
281 'description' => ts('How many items ordered'),
282 'required' => TRUE,
283 'precision' => [
284 20,
285 2,
286 ],
287 'where' => 'civicrm_line_item.qty',
288 'table_name' => 'civicrm_line_item',
289 'entity' => 'LineItem',
290 'bao' => 'CRM_Price_BAO_LineItem',
291 'localizable' => 0,
292 'html' => [
293 'type' => 'Text',
294 ],
295 'add' => '1.7',
296 ],
297 'unit_price' => [
298 'name' => 'unit_price',
299 'type' => CRM_Utils_Type::T_MONEY,
300 'title' => ts('Unit Price'),
301 'description' => ts('price of each item'),
302 'required' => TRUE,
303 'precision' => [
304 20,
305 2,
306 ],
307 'where' => 'civicrm_line_item.unit_price',
308 'table_name' => 'civicrm_line_item',
309 'entity' => 'LineItem',
310 'bao' => 'CRM_Price_BAO_LineItem',
311 'localizable' => 0,
312 'html' => [
313 'type' => 'Text',
314 ],
315 'add' => '1.7',
316 ],
317 'line_total' => [
318 'name' => 'line_total',
319 'type' => CRM_Utils_Type::T_MONEY,
320 'title' => ts('Line Item Total'),
321 'description' => ts('qty * unit_price'),
322 'required' => TRUE,
323 'precision' => [
324 20,
325 2,
326 ],
327 'where' => 'civicrm_line_item.line_total',
328 'table_name' => 'civicrm_line_item',
329 'entity' => 'LineItem',
330 'bao' => 'CRM_Price_BAO_LineItem',
331 'localizable' => 0,
332 'add' => '1.7',
333 ],
334 'participant_count' => [
335 'name' => 'participant_count',
336 'type' => CRM_Utils_Type::T_INT,
337 'title' => ts('Line Item Participant Count'),
338 'description' => ts('Participant count for field'),
339 'where' => 'civicrm_line_item.participant_count',
340 'default' => 'NULL',
341 'table_name' => 'civicrm_line_item',
342 'entity' => 'LineItem',
343 'bao' => 'CRM_Price_BAO_LineItem',
344 'localizable' => 0,
345 'html' => [
346 'type' => 'Text',
347 ],
348 'add' => '3.2',
349 ],
350 'price_field_value_id' => [
351 'name' => 'price_field_value_id',
352 'type' => CRM_Utils_Type::T_INT,
353 'title' => ts('Option ID'),
354 'description' => ts('FK to civicrm_price_field_value'),
355 'where' => 'civicrm_line_item.price_field_value_id',
356 'default' => 'NULL',
357 'table_name' => 'civicrm_line_item',
358 'entity' => 'LineItem',
359 'bao' => 'CRM_Price_BAO_LineItem',
360 'localizable' => 0,
361 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
362 'html' => [
363 'label' => ts("Option"),
364 ],
365 'pseudoconstant' => [
366 'table' => 'civicrm_price_field_value',
367 'keyColumn' => 'id',
368 'labelColumn' => 'label',
369 'nameColumn' => 'name',
370 ],
371 'add' => '3.3',
372 ],
373 'financial_type_id' => [
374 'name' => 'financial_type_id',
375 'type' => CRM_Utils_Type::T_INT,
376 'title' => ts('Financial Type ID'),
377 'description' => ts('FK to Financial Type.'),
378 'where' => 'civicrm_line_item.financial_type_id',
379 'default' => 'NULL',
380 'table_name' => 'civicrm_line_item',
381 'entity' => 'LineItem',
382 'bao' => 'CRM_Price_BAO_LineItem',
383 'localizable' => 0,
384 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
385 'html' => [
386 'type' => 'Select',
387 'label' => ts("Financial Type"),
388 ],
389 'pseudoconstant' => [
390 'table' => 'civicrm_financial_type',
391 'keyColumn' => 'id',
392 'labelColumn' => 'name',
393 ],
394 'add' => '4.3',
395 ],
396 'non_deductible_amount' => [
397 'name' => 'non_deductible_amount',
398 'type' => CRM_Utils_Type::T_MONEY,
399 'title' => ts('Non-deductible Amount'),
400 'description' => ts('Portion of total amount which is NOT tax deductible.'),
401 'required' => TRUE,
402 'precision' => [
403 20,
404 2,
405 ],
406 'where' => 'civicrm_line_item.non_deductible_amount',
407 'headerPattern' => '/non?.?deduct/i',
408 'dataPattern' => '/^\d+(\.\d{2})?$/',
409 'default' => '0.0',
410 'table_name' => 'civicrm_line_item',
411 'entity' => 'LineItem',
412 'bao' => 'CRM_Price_BAO_LineItem',
413 'localizable' => 0,
414 'html' => [
415 'type' => 'Text',
416 ],
417 'add' => '4.7',
418 ],
419 'tax_amount' => [
420 'name' => 'tax_amount',
421 'type' => CRM_Utils_Type::T_MONEY,
422 'title' => ts('Tax Amount'),
423 'description' => ts('tax of each item'),
424 'precision' => [
425 20,
426 2,
427 ],
428 'import' => TRUE,
429 'where' => 'civicrm_line_item.tax_amount',
430 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
431 'dataPattern' => '/^\d+(\.\d{2})?$/',
432 'export' => TRUE,
433 'table_name' => 'civicrm_line_item',
434 'entity' => 'LineItem',
435 'bao' => 'CRM_Price_BAO_LineItem',
436 'localizable' => 0,
437 'html' => [
438 'type' => 'Text',
439 ],
440 'add' => '4.6',
441 ],
442 ];
443 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
444 }
445 return Civi::$statics[__CLASS__]['fields'];
446 }
447
448 /**
449 * Return a mapping from field-name to the corresponding key (as used in fields()).
450 *
451 * @return array
452 * Array(string $name => string $uniqueName).
453 */
454 public static function &fieldKeys() {
455 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
456 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
457 }
458 return Civi::$statics[__CLASS__]['fieldKeys'];
459 }
460
461 /**
462 * Returns the names of this table
463 *
464 * @return string
465 */
466 public static function getTableName() {
467 return self::$_tableName;
468 }
469
470 /**
471 * Returns if this table needs to be logged
472 *
473 * @return bool
474 */
475 public function getLog() {
476 return self::$_log;
477 }
478
479 /**
480 * Returns the list of fields that can be imported
481 *
482 * @param bool $prefix
483 *
484 * @return array
485 */
486 public static function &import($prefix = FALSE) {
487 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'line_item', $prefix, []);
488 return $r;
489 }
490
491 /**
492 * Returns the list of fields that can be exported
493 *
494 * @param bool $prefix
495 *
496 * @return array
497 */
498 public static function &export($prefix = FALSE) {
499 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'line_item', $prefix, []);
500 return $r;
501 }
502
503 /**
504 * Returns the list of indices
505 *
506 * @param bool $localize
507 *
508 * @return array
509 */
510 public static function indices($localize = TRUE) {
511 $indices = [
512 'index_entity' => [
513 'name' => 'index_entity',
514 'field' => [
515 0 => 'entity_table',
516 1 => 'entity_id',
517 ],
518 'localizable' => FALSE,
519 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
520 ],
521 'UI_line_item_value' => [
522 'name' => 'UI_line_item_value',
523 'field' => [
524 0 => 'entity_table',
525 1 => 'entity_id',
526 2 => 'contribution_id',
527 3 => 'price_field_value_id',
528 4 => 'price_field_id',
529 ],
530 'localizable' => FALSE,
531 'unique' => TRUE,
532 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
533 ],
534 ];
535 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
536 }
537
538 }