Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
0f03f337 | 5 | * @copyright CiviCRM LLC (c) 2004-2017 |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Financial/FinancialAccount.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
e7a6b91a | 9 | * (GenCodeChecksum:4b1497d1607b10f8eec89c101665cd1d) |
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 | */ | |
22 | 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 | */ |
c3fc2621 CW |
29 | static $_log = TRUE; |
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 TO |
151 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
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'), |
e501603b | 172 | 'description' => 'ID', |
c3fc2621 | 173 | 'required' => TRUE, |
522a26c9 | 174 | 'table_name' => 'civicrm_financial_account', |
175 | 'entity' => 'FinancialAccount', | |
176 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 177 | 'localizable' => 0, |
c3fc2621 CW |
178 | ], |
179 | 'name' => [ | |
e501603b TO |
180 | 'name' => 'name', |
181 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 182 | 'title' => ts('Financial Account Name'), |
e501603b | 183 | 'description' => 'Financial Account Name.', |
c3fc2621 | 184 | 'required' => TRUE, |
e501603b TO |
185 | 'maxlength' => 255, |
186 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 187 | 'table_name' => 'civicrm_financial_account', |
188 | 'entity' => 'FinancialAccount', | |
189 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 190 | 'localizable' => 0, |
c3fc2621 CW |
191 | ], |
192 | 'financial_account_contact_id' => [ | |
e501603b TO |
193 | 'name' => 'contact_id', |
194 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 195 | 'title' => ts('Contact ID'), |
e501603b | 196 | 'description' => 'FK to Contact ID that is responsible for the funds in this account', |
522a26c9 | 197 | 'table_name' => 'civicrm_financial_account', |
198 | 'entity' => 'FinancialAccount', | |
199 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 200 | 'localizable' => 0, |
e501603b | 201 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
c3fc2621 CW |
202 | ], |
203 | 'financial_account_type_id' => [ | |
e501603b TO |
204 | 'name' => 'financial_account_type_id', |
205 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 206 | 'title' => ts('Financial Account Type'), |
e501603b | 207 | 'description' => 'pseudo FK into civicrm_option_value.', |
c3fc2621 | 208 | 'required' => TRUE, |
e501603b | 209 | 'default' => '3', |
522a26c9 | 210 | 'table_name' => 'civicrm_financial_account', |
211 | 'entity' => 'FinancialAccount', | |
212 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 213 | 'localizable' => 0, |
c3fc2621 | 214 | 'html' => [ |
e501603b | 215 | 'type' => 'Select', |
c3fc2621 CW |
216 | ], |
217 | 'pseudoconstant' => [ | |
e501603b TO |
218 | 'optionGroupName' => 'financial_account_type', |
219 | 'optionEditPath' => 'civicrm/admin/options/financial_account_type', | |
c3fc2621 CW |
220 | ] |
221 | ], | |
222 | 'accounting_code' => [ | |
e501603b TO |
223 | 'name' => 'accounting_code', |
224 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 225 | 'title' => ts('Accounting Code'), |
e501603b TO |
226 | 'description' => 'Optional value for mapping monies owed and received to accounting system codes.', |
227 | 'maxlength' => 64, | |
228 | 'size' => CRM_Utils_Type::BIG, | |
c3fc2621 | 229 | 'export' => TRUE, |
e501603b TO |
230 | 'where' => 'civicrm_financial_account.accounting_code', |
231 | 'headerPattern' => '', | |
232 | 'dataPattern' => '', | |
522a26c9 | 233 | 'table_name' => 'civicrm_financial_account', |
234 | 'entity' => 'FinancialAccount', | |
235 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 236 | 'localizable' => 0, |
c3fc2621 CW |
237 | ], |
238 | 'account_type_code' => [ | |
e501603b TO |
239 | 'name' => 'account_type_code', |
240 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 241 | 'title' => ts('Account Type Code'), |
e501603b TO |
242 | 'description' => 'Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).', |
243 | 'maxlength' => 64, | |
244 | 'size' => CRM_Utils_Type::BIG, | |
c3fc2621 | 245 | 'export' => TRUE, |
e501603b TO |
246 | 'where' => 'civicrm_financial_account.account_type_code', |
247 | 'headerPattern' => '', | |
248 | 'dataPattern' => '', | |
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'), |
e501603b TO |
258 | 'description' => 'Financial Type Description.', |
259 | 'maxlength' => 255, | |
260 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 261 | 'table_name' => 'civicrm_financial_account', |
262 | 'entity' => 'FinancialAccount', | |
263 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 264 | 'localizable' => 0, |
c3fc2621 CW |
265 | ], |
266 | 'parent_id' => [ | |
e501603b TO |
267 | 'name' => 'parent_id', |
268 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 269 | 'title' => ts('Financial Account Parent'), |
e501603b | 270 | 'description' => 'Parent ID in account hierarchy', |
522a26c9 | 271 | 'table_name' => 'civicrm_financial_account', |
272 | 'entity' => 'FinancialAccount', | |
273 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 274 | 'localizable' => 0, |
e501603b | 275 | 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount', |
c3fc2621 CW |
276 | ], |
277 | 'is_header_account' => [ | |
e501603b TO |
278 | 'name' => 'is_header_account', |
279 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 280 | 'title' => ts('Header Financial Account?'), |
e501603b | 281 | 'description' => 'Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?', |
522a26c9 | 282 | 'table_name' => 'civicrm_financial_account', |
283 | 'entity' => 'FinancialAccount', | |
284 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 285 | 'localizable' => 0, |
c3fc2621 CW |
286 | ], |
287 | 'is_deductible' => [ | |
e501603b TO |
288 | 'name' => 'is_deductible', |
289 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 290 | 'title' => ts('Deductible Financial Account?'), |
e501603b TO |
291 | 'description' => 'Is this account tax-deductible?', |
292 | 'default' => '1', | |
522a26c9 | 293 | 'table_name' => 'civicrm_financial_account', |
294 | 'entity' => 'FinancialAccount', | |
295 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 296 | 'localizable' => 0, |
c3fc2621 CW |
297 | ], |
298 | 'is_tax' => [ | |
e501603b TO |
299 | 'name' => 'is_tax', |
300 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 301 | 'title' => ts('Tax Financial Account?'), |
e501603b | 302 | 'description' => 'Is this account for taxes?', |
522a26c9 | 303 | 'table_name' => 'civicrm_financial_account', |
304 | 'entity' => 'FinancialAccount', | |
305 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 306 | 'localizable' => 0, |
c3fc2621 CW |
307 | ], |
308 | 'tax_rate' => [ | |
e501603b TO |
309 | 'name' => 'tax_rate', |
310 | 'type' => CRM_Utils_Type::T_MONEY, | |
c3fc2621 | 311 | 'title' => ts('Financial Account Tax Rate'), |
e501603b | 312 | 'description' => 'The percentage of the total_amount that is due for this tax.', |
c3fc2621 | 313 | 'precision' => [ |
e501603b TO |
314 | 10, |
315 | 8 | |
c3fc2621 | 316 | ], |
522a26c9 | 317 | 'table_name' => 'civicrm_financial_account', |
318 | 'entity' => 'FinancialAccount', | |
319 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 320 | 'localizable' => 0, |
c3fc2621 CW |
321 | ], |
322 | 'is_reserved' => [ | |
e501603b TO |
323 | 'name' => 'is_reserved', |
324 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 325 | 'title' => ts('Reserved Financial Account?'), |
e501603b | 326 | 'description' => 'Is this a predefined system object?', |
522a26c9 | 327 | 'table_name' => 'civicrm_financial_account', |
328 | 'entity' => 'FinancialAccount', | |
329 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 330 | 'localizable' => 0, |
c3fc2621 CW |
331 | ], |
332 | 'is_active' => [ | |
e501603b TO |
333 | 'name' => 'is_active', |
334 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 335 | 'title' => ts('Financial Account is Active'), |
e501603b | 336 | 'description' => 'Is this property active?', |
522a26c9 | 337 | 'table_name' => 'civicrm_financial_account', |
338 | 'entity' => 'FinancialAccount', | |
339 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 340 | 'localizable' => 0, |
c3fc2621 CW |
341 | ], |
342 | 'is_default' => [ | |
e501603b TO |
343 | 'name' => 'is_default', |
344 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 345 | 'title' => ts('Default Financial Account'), |
e501603b | 346 | 'description' => 'Is this account the default one (or default tax one) for its financial_account_type?', |
522a26c9 | 347 | 'table_name' => 'civicrm_financial_account', |
348 | 'entity' => 'FinancialAccount', | |
349 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 350 | 'localizable' => 0, |
c3fc2621 CW |
351 | ], |
352 | ]; | |
346aaaba | 353 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 354 | } |
346aaaba | 355 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 356 | } |
c3fc2621 | 357 | |
e501603b | 358 | /** |
bd8e0b14 | 359 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
360 | * |
361 | * @return array | |
bd8e0b14 | 362 | * Array(string $name => string $uniqueName). |
e501603b | 363 | */ |
c3fc2621 | 364 | public static function &fieldKeys() { |
bd8e0b14 TO |
365 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
366 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 367 | } |
bd8e0b14 | 368 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 369 | } |
c3fc2621 | 370 | |
e501603b TO |
371 | /** |
372 | * Returns the names of this table | |
373 | * | |
374 | * @return string | |
375 | */ | |
c3fc2621 | 376 | public static function getTableName() { |
e501603b TO |
377 | return self::$_tableName; |
378 | } | |
c3fc2621 | 379 | |
e501603b TO |
380 | /** |
381 | * Returns if this table needs to be logged | |
382 | * | |
c3fc2621 | 383 | * @return bool |
e501603b | 384 | */ |
c3fc2621 | 385 | public function getLog() { |
e501603b TO |
386 | return self::$_log; |
387 | } | |
c3fc2621 | 388 | |
e501603b TO |
389 | /** |
390 | * Returns the list of fields that can be imported | |
391 | * | |
392 | * @param bool $prefix | |
393 | * | |
394 | * @return array | |
395 | */ | |
c3fc2621 CW |
396 | public static function &import($prefix = FALSE) { |
397 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_account', $prefix, []); | |
60808919 | 398 | return $r; |
e501603b | 399 | } |
c3fc2621 | 400 | |
e501603b TO |
401 | /** |
402 | * Returns the list of fields that can be exported | |
403 | * | |
404 | * @param bool $prefix | |
405 | * | |
406 | * @return array | |
407 | */ | |
c3fc2621 CW |
408 | public static function &export($prefix = FALSE) { |
409 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_account', $prefix, []); | |
60808919 | 410 | return $r; |
e501603b | 411 | } |
c3fc2621 | 412 | |
e7a6b91a AS |
413 | /** |
414 | * Returns the list of indices | |
c3fc2621 CW |
415 | * |
416 | * @param bool $localize | |
417 | * | |
418 | * @return array | |
e7a6b91a AS |
419 | */ |
420 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
421 | $indices = [ |
422 | 'UI_name' => [ | |
e7a6b91a | 423 | 'name' => 'UI_name', |
c3fc2621 | 424 | 'field' => [ |
e7a6b91a | 425 | 0 => 'name', |
c3fc2621 CW |
426 | ], |
427 | 'localizable' => FALSE, | |
428 | 'unique' => TRUE, | |
e7a6b91a | 429 | 'sig' => 'civicrm_financial_account::1::name', |
c3fc2621 CW |
430 | ], |
431 | ]; | |
e7a6b91a AS |
432 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
433 | } | |
c3fc2621 | 434 | |
e501603b | 435 | } |