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