Merge pull request #23201 from civicrm/5.49
[civicrm-core.git] / CRM / Financial / DAO / FinancialAccount.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Financial/FinancialAccount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:bbb54fc9abdb9f5187f84b0b4eadb53e)
10 */
11
12 /**
13 * Database access object for the FinancialAccount entity.
14 */
15 class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.2';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_financial_account';
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 * ID
36 *
37 * @var int|string|null
38 * (SQL type: int unsigned)
39 * Note that values will be retrieved from the database as a string.
40 */
41 public $id;
42
43 /**
44 * Financial Account Name.
45 *
46 * @var string
47 * (SQL type: varchar(255))
48 * Note that values will be retrieved from the database as a string.
49 */
50 public $name;
51
52 /**
53 * FK to Contact ID that is responsible for the funds in this account
54 *
55 * @var int|string|null
56 * (SQL type: int unsigned)
57 * Note that values will be retrieved from the database as a string.
58 */
59 public $contact_id;
60
61 /**
62 * pseudo FK into civicrm_option_value.
63 *
64 * @var int|string
65 * (SQL type: int unsigned)
66 * Note that values will be retrieved from the database as a string.
67 */
68 public $financial_account_type_id;
69
70 /**
71 * Optional value for mapping monies owed and received to accounting system codes.
72 *
73 * @var string|null
74 * (SQL type: varchar(64))
75 * Note that values will be retrieved from the database as a string.
76 */
77 public $accounting_code;
78
79 /**
80 * Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).
81 *
82 * @var string|null
83 * (SQL type: varchar(64))
84 * Note that values will be retrieved from the database as a string.
85 */
86 public $account_type_code;
87
88 /**
89 * Financial Type Description.
90 *
91 * @var string|null
92 * (SQL type: varchar(255))
93 * Note that values will be retrieved from the database as a string.
94 */
95 public $description;
96
97 /**
98 * Parent ID in account hierarchy
99 *
100 * @var int|string|null
101 * (SQL type: int unsigned)
102 * Note that values will be retrieved from the database as a string.
103 */
104 public $parent_id;
105
106 /**
107 * Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?
108 *
109 * @var bool|string
110 * (SQL type: tinyint)
111 * Note that values will be retrieved from the database as a string.
112 */
113 public $is_header_account;
114
115 /**
116 * Is this account tax-deductible?
117 *
118 * @var bool|string
119 * (SQL type: tinyint)
120 * Note that values will be retrieved from the database as a string.
121 */
122 public $is_deductible;
123
124 /**
125 * Is this account for taxes?
126 *
127 * @var bool|string
128 * (SQL type: tinyint)
129 * Note that values will be retrieved from the database as a string.
130 */
131 public $is_tax;
132
133 /**
134 * The percentage of the total_amount that is due for this tax.
135 *
136 * @var float|string|null
137 * (SQL type: decimal(10,8))
138 * Note that values will be retrieved from the database as a string.
139 */
140 public $tax_rate;
141
142 /**
143 * Is this a predefined system object?
144 *
145 * @var bool|string
146 * (SQL type: tinyint)
147 * Note that values will be retrieved from the database as a string.
148 */
149 public $is_reserved;
150
151 /**
152 * Is this property active?
153 *
154 * @var bool|string
155 * (SQL type: tinyint)
156 * Note that values will be retrieved from the database as a string.
157 */
158 public $is_active;
159
160 /**
161 * Is this account the default one (or default tax one) for its financial_account_type?
162 *
163 * @var bool|string
164 * (SQL type: tinyint)
165 * Note that values will be retrieved from the database as a string.
166 */
167 public $is_default;
168
169 /**
170 * Class constructor.
171 */
172 public function __construct() {
173 $this->__table = 'civicrm_financial_account';
174 parent::__construct();
175 }
176
177 /**
178 * Returns localized title of this entity.
179 *
180 * @param bool $plural
181 * Whether to return the plural version of the title.
182 */
183 public static function getEntityTitle($plural = FALSE) {
184 return $plural ? ts('Financial Accounts') : ts('Financial Account');
185 }
186
187 /**
188 * Returns foreign keys and entity references.
189 *
190 * @return array
191 * [CRM_Core_Reference_Interface]
192 */
193 public static function getReferenceColumns() {
194 if (!isset(Civi::$statics[__CLASS__]['links'])) {
195 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
196 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
197 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_financial_account', 'id');
198 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
199 }
200 return Civi::$statics[__CLASS__]['links'];
201 }
202
203 /**
204 * Returns all the column names of this table
205 *
206 * @return array
207 */
208 public static function &fields() {
209 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
210 Civi::$statics[__CLASS__]['fields'] = [
211 'id' => [
212 'name' => 'id',
213 'type' => CRM_Utils_Type::T_INT,
214 'title' => ts('Financial Account ID'),
215 'description' => ts('ID'),
216 'required' => TRUE,
217 'where' => 'civicrm_financial_account.id',
218 'table_name' => 'civicrm_financial_account',
219 'entity' => 'FinancialAccount',
220 'bao' => 'CRM_Financial_BAO_FinancialAccount',
221 'localizable' => 0,
222 'html' => [
223 'type' => 'Number',
224 ],
225 'readonly' => TRUE,
226 'add' => '3.2',
227 ],
228 'name' => [
229 'name' => 'name',
230 'type' => CRM_Utils_Type::T_STRING,
231 'title' => ts('Financial Account Name'),
232 'description' => ts('Financial Account Name.'),
233 'required' => TRUE,
234 'maxlength' => 255,
235 'size' => CRM_Utils_Type::HUGE,
236 'where' => 'civicrm_financial_account.name',
237 'table_name' => 'civicrm_financial_account',
238 'entity' => 'FinancialAccount',
239 'bao' => 'CRM_Financial_BAO_FinancialAccount',
240 'localizable' => 0,
241 'add' => '3.2',
242 ],
243 'financial_account_contact_id' => [
244 'name' => 'contact_id',
245 'type' => CRM_Utils_Type::T_INT,
246 'title' => ts('Contact ID'),
247 'description' => ts('FK to Contact ID that is responsible for the funds in this account'),
248 'where' => 'civicrm_financial_account.contact_id',
249 'table_name' => 'civicrm_financial_account',
250 'entity' => 'FinancialAccount',
251 'bao' => 'CRM_Financial_BAO_FinancialAccount',
252 'localizable' => 0,
253 'FKClassName' => 'CRM_Contact_DAO_Contact',
254 'html' => [
255 'label' => ts("Contact"),
256 ],
257 'add' => '4.3',
258 ],
259 'financial_account_type_id' => [
260 'name' => 'financial_account_type_id',
261 'type' => CRM_Utils_Type::T_INT,
262 'title' => ts('Financial Account Type'),
263 'description' => ts('pseudo FK into civicrm_option_value.'),
264 'required' => TRUE,
265 'where' => 'civicrm_financial_account.financial_account_type_id',
266 'default' => '3',
267 'table_name' => 'civicrm_financial_account',
268 'entity' => 'FinancialAccount',
269 'bao' => 'CRM_Financial_BAO_FinancialAccount',
270 'localizable' => 0,
271 'html' => [
272 'type' => 'Select',
273 ],
274 'pseudoconstant' => [
275 'optionGroupName' => 'financial_account_type',
276 'optionEditPath' => 'civicrm/admin/options/financial_account_type',
277 ],
278 'add' => '4.3',
279 ],
280 'accounting_code' => [
281 'name' => 'accounting_code',
282 'type' => CRM_Utils_Type::T_STRING,
283 'title' => ts('Accounting Code'),
284 'description' => ts('Optional value for mapping monies owed and received to accounting system codes.'),
285 'maxlength' => 64,
286 'size' => CRM_Utils_Type::BIG,
287 'where' => 'civicrm_financial_account.accounting_code',
288 'export' => TRUE,
289 'table_name' => 'civicrm_financial_account',
290 'entity' => 'FinancialAccount',
291 'bao' => 'CRM_Financial_BAO_FinancialAccount',
292 'localizable' => 0,
293 'add' => '4.3',
294 ],
295 'account_type_code' => [
296 'name' => 'account_type_code',
297 'type' => CRM_Utils_Type::T_STRING,
298 'title' => ts('Account Type Code'),
299 'description' => ts('Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).'),
300 'maxlength' => 64,
301 'size' => CRM_Utils_Type::BIG,
302 'where' => 'civicrm_financial_account.account_type_code',
303 'export' => TRUE,
304 'table_name' => 'civicrm_financial_account',
305 'entity' => 'FinancialAccount',
306 'bao' => 'CRM_Financial_BAO_FinancialAccount',
307 'localizable' => 0,
308 'add' => '4.3',
309 ],
310 'description' => [
311 'name' => 'description',
312 'type' => CRM_Utils_Type::T_STRING,
313 'title' => ts('Financial Account Description'),
314 'description' => ts('Financial Type Description.'),
315 'maxlength' => 255,
316 'size' => CRM_Utils_Type::HUGE,
317 'where' => 'civicrm_financial_account.description',
318 'table_name' => 'civicrm_financial_account',
319 'entity' => 'FinancialAccount',
320 'bao' => 'CRM_Financial_BAO_FinancialAccount',
321 'localizable' => 0,
322 'add' => '4.3',
323 ],
324 'parent_id' => [
325 'name' => 'parent_id',
326 'type' => CRM_Utils_Type::T_INT,
327 'title' => ts('Parent ID'),
328 'description' => ts('Parent ID in account hierarchy'),
329 'where' => 'civicrm_financial_account.parent_id',
330 'table_name' => 'civicrm_financial_account',
331 'entity' => 'FinancialAccount',
332 'bao' => 'CRM_Financial_BAO_FinancialAccount',
333 'localizable' => 0,
334 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
335 'html' => [
336 'label' => ts("Parent"),
337 ],
338 'add' => '4.3',
339 ],
340 'is_header_account' => [
341 'name' => 'is_header_account',
342 'type' => CRM_Utils_Type::T_BOOLEAN,
343 'title' => ts('Header Financial Account?'),
344 'description' => ts('Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?'),
345 'required' => TRUE,
346 'where' => 'civicrm_financial_account.is_header_account',
347 'default' => '0',
348 'table_name' => 'civicrm_financial_account',
349 'entity' => 'FinancialAccount',
350 'bao' => 'CRM_Financial_BAO_FinancialAccount',
351 'localizable' => 0,
352 'add' => '4.3',
353 ],
354 'is_deductible' => [
355 'name' => 'is_deductible',
356 'type' => CRM_Utils_Type::T_BOOLEAN,
357 'title' => ts('Deductible Financial Account?'),
358 'description' => ts('Is this account tax-deductible?'),
359 'required' => TRUE,
360 'where' => 'civicrm_financial_account.is_deductible',
361 'default' => '0',
362 'table_name' => 'civicrm_financial_account',
363 'entity' => 'FinancialAccount',
364 'bao' => 'CRM_Financial_BAO_FinancialAccount',
365 'localizable' => 0,
366 'add' => '4.3',
367 ],
368 'is_tax' => [
369 'name' => 'is_tax',
370 'type' => CRM_Utils_Type::T_BOOLEAN,
371 'title' => ts('Tax Financial Account?'),
372 'description' => ts('Is this account for taxes?'),
373 'required' => TRUE,
374 'where' => 'civicrm_financial_account.is_tax',
375 'default' => '0',
376 'table_name' => 'civicrm_financial_account',
377 'entity' => 'FinancialAccount',
378 'bao' => 'CRM_Financial_BAO_FinancialAccount',
379 'localizable' => 0,
380 'add' => '4.3',
381 ],
382 'tax_rate' => [
383 'name' => 'tax_rate',
384 'type' => CRM_Utils_Type::T_MONEY,
385 'title' => ts('Financial Account Tax Rate'),
386 'description' => ts('The percentage of the total_amount that is due for this tax.'),
387 'precision' => [
388 10,
389 8,
390 ],
391 'where' => 'civicrm_financial_account.tax_rate',
392 'table_name' => 'civicrm_financial_account',
393 'entity' => 'FinancialAccount',
394 'bao' => 'CRM_Financial_BAO_FinancialAccount',
395 'localizable' => 0,
396 'add' => '4.3',
397 ],
398 'is_reserved' => [
399 'name' => 'is_reserved',
400 'type' => CRM_Utils_Type::T_BOOLEAN,
401 'title' => ts('Reserved Financial Account?'),
402 'description' => ts('Is this a predefined system object?'),
403 'required' => TRUE,
404 'where' => 'civicrm_financial_account.is_reserved',
405 'default' => '0',
406 'table_name' => 'civicrm_financial_account',
407 'entity' => 'FinancialAccount',
408 'bao' => 'CRM_Financial_BAO_FinancialAccount',
409 'localizable' => 0,
410 'add' => '4.3',
411 ],
412 'is_active' => [
413 'name' => 'is_active',
414 'type' => CRM_Utils_Type::T_BOOLEAN,
415 'title' => ts('Financial Account is Active'),
416 'description' => ts('Is this property active?'),
417 'required' => TRUE,
418 'where' => 'civicrm_financial_account.is_active',
419 'default' => '1',
420 'table_name' => 'civicrm_financial_account',
421 'entity' => 'FinancialAccount',
422 'bao' => 'CRM_Financial_BAO_FinancialAccount',
423 'localizable' => 0,
424 'add' => '4.3',
425 ],
426 'is_default' => [
427 'name' => 'is_default',
428 'type' => CRM_Utils_Type::T_BOOLEAN,
429 'title' => ts('Default Financial Account'),
430 'description' => ts('Is this account the default one (or default tax one) for its financial_account_type?'),
431 'required' => TRUE,
432 'where' => 'civicrm_financial_account.is_default',
433 'default' => '0',
434 'table_name' => 'civicrm_financial_account',
435 'entity' => 'FinancialAccount',
436 'bao' => 'CRM_Financial_BAO_FinancialAccount',
437 'localizable' => 0,
438 'add' => '4.3',
439 ],
440 ];
441 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
442 }
443 return Civi::$statics[__CLASS__]['fields'];
444 }
445
446 /**
447 * Return a mapping from field-name to the corresponding key (as used in fields()).
448 *
449 * @return array
450 * Array(string $name => string $uniqueName).
451 */
452 public static function &fieldKeys() {
453 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
454 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
455 }
456 return Civi::$statics[__CLASS__]['fieldKeys'];
457 }
458
459 /**
460 * Returns the names of this table
461 *
462 * @return string
463 */
464 public static function getTableName() {
465 return self::$_tableName;
466 }
467
468 /**
469 * Returns if this table needs to be logged
470 *
471 * @return bool
472 */
473 public function getLog() {
474 return self::$_log;
475 }
476
477 /**
478 * Returns the list of fields that can be imported
479 *
480 * @param bool $prefix
481 *
482 * @return array
483 */
484 public static function &import($prefix = FALSE) {
485 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_account', $prefix, []);
486 return $r;
487 }
488
489 /**
490 * Returns the list of fields that can be exported
491 *
492 * @param bool $prefix
493 *
494 * @return array
495 */
496 public static function &export($prefix = FALSE) {
497 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_account', $prefix, []);
498 return $r;
499 }
500
501 /**
502 * Returns the list of indices
503 *
504 * @param bool $localize
505 *
506 * @return array
507 */
508 public static function indices($localize = TRUE) {
509 $indices = [
510 'UI_name' => [
511 'name' => 'UI_name',
512 'field' => [
513 0 => 'name',
514 ],
515 'localizable' => FALSE,
516 'unique' => TRUE,
517 'sig' => 'civicrm_financial_account::1::name',
518 ],
519 ];
520 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
521 }
522
523 }