Commit | Line | Data |
---|---|---|
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 | |
449c4e6b | 9 | * (GenCodeChecksum:50acc3ed98cf98d333d2fa80d7089577) |
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 | * | |
e6ca0a57 | 34 | * @var int |
e501603b TO |
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 | * | |
e6ca0a57 | 48 | * @var int |
e501603b TO |
49 | */ |
50 | public $contact_id; | |
c3fc2621 | 51 | |
e501603b TO |
52 | /** |
53 | * pseudo FK into civicrm_option_value. | |
54 | * | |
e6ca0a57 | 55 | * @var int |
e501603b TO |
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 | * | |
e6ca0a57 | 83 | * @var int |
e501603b TO |
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 | * | |
e6ca0a57 | 90 | * @var bool |
e501603b TO |
91 | */ |
92 | public $is_header_account; | |
c3fc2621 | 93 | |
e501603b TO |
94 | /** |
95 | * Is this account tax-deductible? | |
96 | * | |
e6ca0a57 | 97 | * @var bool |
e501603b TO |
98 | */ |
99 | public $is_deductible; | |
c3fc2621 | 100 | |
e501603b TO |
101 | /** |
102 | * Is this account for taxes? | |
103 | * | |
e6ca0a57 | 104 | * @var bool |
e501603b TO |
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 | * | |
e6ca0a57 | 118 | * @var bool |
e501603b TO |
119 | */ |
120 | public $is_reserved; | |
c3fc2621 | 121 | |
e501603b TO |
122 | /** |
123 | * Is this property active? | |
124 | * | |
e6ca0a57 | 125 | * @var bool |
e501603b TO |
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 | * | |
e6ca0a57 | 132 | * @var bool |
e501603b TO |
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 | |
449c4e6b CW |
144 | /** |
145 | * Returns localized title of this entity. | |
146 | */ | |
147 | public static function getEntityTitle() { | |
148 | return ts('Financial Accounts'); | |
149 | } | |
150 | ||
e501603b | 151 | /** |
f41f0342 | 152 | * Returns foreign keys and entity references. |
e501603b TO |
153 | * |
154 | * @return array | |
155 | * [CRM_Core_Reference_Interface] | |
156 | */ | |
c3fc2621 | 157 | public static function getReferenceColumns() { |
346aaaba | 158 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
fa45b5b9 | 159 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); |
c3fc2621 CW |
160 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); |
161 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_financial_account', 'id'); | |
346aaaba | 162 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
e501603b | 163 | } |
346aaaba | 164 | return Civi::$statics[__CLASS__]['links']; |
e501603b | 165 | } |
c3fc2621 | 166 | |
e501603b TO |
167 | /** |
168 | * Returns all the column names of this table | |
169 | * | |
170 | * @return array | |
171 | */ | |
c3fc2621 | 172 | public static function &fields() { |
346aaaba | 173 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
174 | Civi::$statics[__CLASS__]['fields'] = [ |
175 | 'id' => [ | |
e501603b TO |
176 | 'name' => 'id', |
177 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 178 | 'title' => ts('Financial Account ID'), |
215b423e | 179 | 'description' => ts('ID'), |
c3fc2621 | 180 | 'required' => TRUE, |
a36434b9 | 181 | 'where' => 'civicrm_financial_account.id', |
522a26c9 | 182 | 'table_name' => 'civicrm_financial_account', |
183 | 'entity' => 'FinancialAccount', | |
184 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 185 | 'localizable' => 0, |
c3fc2621 CW |
186 | ], |
187 | 'name' => [ | |
e501603b TO |
188 | 'name' => 'name', |
189 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 190 | 'title' => ts('Financial Account Name'), |
215b423e | 191 | 'description' => ts('Financial Account Name.'), |
c3fc2621 | 192 | 'required' => TRUE, |
e501603b TO |
193 | 'maxlength' => 255, |
194 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 195 | 'where' => 'civicrm_financial_account.name', |
522a26c9 | 196 | 'table_name' => 'civicrm_financial_account', |
197 | 'entity' => 'FinancialAccount', | |
198 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 199 | 'localizable' => 0, |
c3fc2621 CW |
200 | ], |
201 | 'financial_account_contact_id' => [ | |
e501603b TO |
202 | 'name' => 'contact_id', |
203 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 204 | 'title' => ts('Contact ID'), |
215b423e | 205 | 'description' => ts('FK to Contact ID that is responsible for the funds in this account'), |
a36434b9 | 206 | 'where' => 'civicrm_financial_account.contact_id', |
522a26c9 | 207 | 'table_name' => 'civicrm_financial_account', |
208 | 'entity' => 'FinancialAccount', | |
209 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 210 | 'localizable' => 0, |
e501603b | 211 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
c3fc2621 CW |
212 | ], |
213 | 'financial_account_type_id' => [ | |
e501603b TO |
214 | 'name' => 'financial_account_type_id', |
215 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 216 | 'title' => ts('Financial Account Type'), |
215b423e | 217 | 'description' => ts('pseudo FK into civicrm_option_value.'), |
c3fc2621 | 218 | 'required' => TRUE, |
a36434b9 | 219 | 'where' => 'civicrm_financial_account.financial_account_type_id', |
e501603b | 220 | 'default' => '3', |
522a26c9 | 221 | 'table_name' => 'civicrm_financial_account', |
222 | 'entity' => 'FinancialAccount', | |
223 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 224 | 'localizable' => 0, |
c3fc2621 | 225 | 'html' => [ |
e501603b | 226 | 'type' => 'Select', |
c3fc2621 CW |
227 | ], |
228 | 'pseudoconstant' => [ | |
e501603b TO |
229 | 'optionGroupName' => 'financial_account_type', |
230 | 'optionEditPath' => 'civicrm/admin/options/financial_account_type', | |
e6ca0a57 | 231 | ], |
c3fc2621 CW |
232 | ], |
233 | 'accounting_code' => [ | |
e501603b TO |
234 | 'name' => 'accounting_code', |
235 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 236 | 'title' => ts('Accounting Code'), |
215b423e | 237 | 'description' => ts('Optional value for mapping monies owed and received to accounting system codes.'), |
e501603b TO |
238 | 'maxlength' => 64, |
239 | 'size' => CRM_Utils_Type::BIG, | |
e501603b | 240 | 'where' => 'civicrm_financial_account.accounting_code', |
a36434b9 | 241 | 'export' => TRUE, |
522a26c9 | 242 | 'table_name' => 'civicrm_financial_account', |
243 | 'entity' => 'FinancialAccount', | |
244 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 245 | 'localizable' => 0, |
c3fc2621 CW |
246 | ], |
247 | 'account_type_code' => [ | |
e501603b TO |
248 | 'name' => 'account_type_code', |
249 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 250 | 'title' => ts('Account Type Code'), |
215b423e | 251 | 'description' => ts('Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).'), |
e501603b TO |
252 | 'maxlength' => 64, |
253 | 'size' => CRM_Utils_Type::BIG, | |
e501603b | 254 | 'where' => 'civicrm_financial_account.account_type_code', |
a36434b9 | 255 | 'export' => TRUE, |
522a26c9 | 256 | 'table_name' => 'civicrm_financial_account', |
257 | 'entity' => 'FinancialAccount', | |
258 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 259 | 'localizable' => 0, |
c3fc2621 CW |
260 | ], |
261 | 'description' => [ | |
e501603b TO |
262 | 'name' => 'description', |
263 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 264 | 'title' => ts('Financial Account Description'), |
215b423e | 265 | 'description' => ts('Financial Type Description.'), |
e501603b TO |
266 | 'maxlength' => 255, |
267 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 268 | 'where' => 'civicrm_financial_account.description', |
522a26c9 | 269 | 'table_name' => 'civicrm_financial_account', |
270 | 'entity' => 'FinancialAccount', | |
271 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 272 | 'localizable' => 0, |
c3fc2621 CW |
273 | ], |
274 | 'parent_id' => [ | |
e501603b TO |
275 | 'name' => 'parent_id', |
276 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 277 | 'title' => ts('Financial Account Parent'), |
215b423e | 278 | 'description' => ts('Parent ID in account hierarchy'), |
a36434b9 | 279 | 'where' => 'civicrm_financial_account.parent_id', |
522a26c9 | 280 | 'table_name' => 'civicrm_financial_account', |
281 | 'entity' => 'FinancialAccount', | |
282 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 283 | 'localizable' => 0, |
e501603b | 284 | 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount', |
c3fc2621 CW |
285 | ], |
286 | 'is_header_account' => [ | |
e501603b TO |
287 | 'name' => 'is_header_account', |
288 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 289 | 'title' => ts('Header Financial Account?'), |
215b423e | 290 | '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 | 291 | 'where' => 'civicrm_financial_account.is_header_account', |
45a83e42 | 292 | 'default' => '0', |
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_deductible' => [ | |
e501603b TO |
299 | 'name' => 'is_deductible', |
300 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 301 | 'title' => ts('Deductible Financial Account?'), |
215b423e | 302 | 'description' => ts('Is this account tax-deductible?'), |
a36434b9 | 303 | 'where' => 'civicrm_financial_account.is_deductible', |
e501603b | 304 | 'default' => '1', |
522a26c9 | 305 | 'table_name' => 'civicrm_financial_account', |
306 | 'entity' => 'FinancialAccount', | |
307 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 308 | 'localizable' => 0, |
c3fc2621 CW |
309 | ], |
310 | 'is_tax' => [ | |
e501603b TO |
311 | 'name' => 'is_tax', |
312 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 313 | 'title' => ts('Tax Financial Account?'), |
215b423e | 314 | 'description' => ts('Is this account for taxes?'), |
a36434b9 | 315 | 'where' => 'civicrm_financial_account.is_tax', |
45a83e42 | 316 | 'default' => '0', |
522a26c9 | 317 | 'table_name' => 'civicrm_financial_account', |
318 | 'entity' => 'FinancialAccount', | |
319 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 320 | 'localizable' => 0, |
c3fc2621 CW |
321 | ], |
322 | 'tax_rate' => [ | |
e501603b TO |
323 | 'name' => 'tax_rate', |
324 | 'type' => CRM_Utils_Type::T_MONEY, | |
c3fc2621 | 325 | 'title' => ts('Financial Account Tax Rate'), |
215b423e | 326 | 'description' => ts('The percentage of the total_amount that is due for this tax.'), |
c3fc2621 | 327 | 'precision' => [ |
e501603b | 328 | 10, |
fb607354 | 329 | 8, |
c3fc2621 | 330 | ], |
a36434b9 | 331 | 'where' => 'civicrm_financial_account.tax_rate', |
522a26c9 | 332 | 'table_name' => 'civicrm_financial_account', |
333 | 'entity' => 'FinancialAccount', | |
334 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 335 | 'localizable' => 0, |
c3fc2621 CW |
336 | ], |
337 | 'is_reserved' => [ | |
e501603b TO |
338 | 'name' => 'is_reserved', |
339 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 340 | 'title' => ts('Reserved Financial Account?'), |
215b423e | 341 | 'description' => ts('Is this a predefined system object?'), |
a36434b9 | 342 | 'where' => 'civicrm_financial_account.is_reserved', |
522a26c9 | 343 | 'table_name' => 'civicrm_financial_account', |
344 | 'entity' => 'FinancialAccount', | |
345 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 346 | 'localizable' => 0, |
c3fc2621 CW |
347 | ], |
348 | 'is_active' => [ | |
e501603b TO |
349 | 'name' => 'is_active', |
350 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 351 | 'title' => ts('Financial Account is Active'), |
215b423e | 352 | 'description' => ts('Is this property active?'), |
a36434b9 | 353 | 'where' => 'civicrm_financial_account.is_active', |
522a26c9 | 354 | 'table_name' => 'civicrm_financial_account', |
355 | 'entity' => 'FinancialAccount', | |
356 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 357 | 'localizable' => 0, |
c3fc2621 CW |
358 | ], |
359 | 'is_default' => [ | |
e501603b TO |
360 | 'name' => 'is_default', |
361 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 362 | 'title' => ts('Default Financial Account'), |
215b423e | 363 | 'description' => ts('Is this account the default one (or default tax one) for its financial_account_type?'), |
a36434b9 | 364 | 'where' => 'civicrm_financial_account.is_default', |
522a26c9 | 365 | 'table_name' => 'civicrm_financial_account', |
366 | 'entity' => 'FinancialAccount', | |
367 | 'bao' => 'CRM_Financial_BAO_FinancialAccount', | |
6a7e5e5d | 368 | 'localizable' => 0, |
c3fc2621 CW |
369 | ], |
370 | ]; | |
346aaaba | 371 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 372 | } |
346aaaba | 373 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 374 | } |
c3fc2621 | 375 | |
e501603b | 376 | /** |
bd8e0b14 | 377 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
378 | * |
379 | * @return array | |
bd8e0b14 | 380 | * Array(string $name => string $uniqueName). |
e501603b | 381 | */ |
c3fc2621 | 382 | public static function &fieldKeys() { |
bd8e0b14 TO |
383 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
384 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 385 | } |
bd8e0b14 | 386 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 387 | } |
c3fc2621 | 388 | |
e501603b TO |
389 | /** |
390 | * Returns the names of this table | |
391 | * | |
392 | * @return string | |
393 | */ | |
c3fc2621 | 394 | public static function getTableName() { |
e501603b TO |
395 | return self::$_tableName; |
396 | } | |
c3fc2621 | 397 | |
e501603b TO |
398 | /** |
399 | * Returns if this table needs to be logged | |
400 | * | |
c3fc2621 | 401 | * @return bool |
e501603b | 402 | */ |
c3fc2621 | 403 | public function getLog() { |
e501603b TO |
404 | return self::$_log; |
405 | } | |
c3fc2621 | 406 | |
e501603b TO |
407 | /** |
408 | * Returns the list of fields that can be imported | |
409 | * | |
410 | * @param bool $prefix | |
411 | * | |
412 | * @return array | |
413 | */ | |
c3fc2621 CW |
414 | public static function &import($prefix = FALSE) { |
415 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_account', $prefix, []); | |
60808919 | 416 | return $r; |
e501603b | 417 | } |
c3fc2621 | 418 | |
e501603b TO |
419 | /** |
420 | * Returns the list of fields that can be exported | |
421 | * | |
422 | * @param bool $prefix | |
423 | * | |
424 | * @return array | |
425 | */ | |
c3fc2621 CW |
426 | public static function &export($prefix = FALSE) { |
427 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_account', $prefix, []); | |
60808919 | 428 | return $r; |
e501603b | 429 | } |
c3fc2621 | 430 | |
e7a6b91a AS |
431 | /** |
432 | * Returns the list of indices | |
c3fc2621 CW |
433 | * |
434 | * @param bool $localize | |
435 | * | |
436 | * @return array | |
e7a6b91a AS |
437 | */ |
438 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
439 | $indices = [ |
440 | 'UI_name' => [ | |
e7a6b91a | 441 | 'name' => 'UI_name', |
c3fc2621 | 442 | 'field' => [ |
e7a6b91a | 443 | 0 => 'name', |
c3fc2621 CW |
444 | ], |
445 | 'localizable' => FALSE, | |
446 | 'unique' => TRUE, | |
e7a6b91a | 447 | 'sig' => 'civicrm_financial_account::1::name', |
c3fc2621 CW |
448 | ], |
449 | ]; | |
e7a6b91a AS |
450 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
451 | } | |
c3fc2621 | 452 | |
e501603b | 453 | } |