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