Respect '0' as a default when generating DAOs
[civicrm-core.git] / CRM / Financial / DAO / FinancialAccount.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
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 15class 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?',
45a83e42 282 'default' => '0',
522a26c9 283 'table_name' => 'civicrm_financial_account',
284 'entity' => 'FinancialAccount',
285 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 286 'localizable' => 0,
c3fc2621
CW
287 ],
288 'is_deductible' => [
e501603b
TO
289 'name' => 'is_deductible',
290 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 291 'title' => ts('Deductible Financial Account?'),
e501603b
TO
292 'description' => 'Is this account tax-deductible?',
293 'default' => '1',
522a26c9 294 'table_name' => 'civicrm_financial_account',
295 'entity' => 'FinancialAccount',
296 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 297 'localizable' => 0,
c3fc2621
CW
298 ],
299 'is_tax' => [
e501603b
TO
300 'name' => 'is_tax',
301 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 302 'title' => ts('Tax Financial Account?'),
e501603b 303 'description' => 'Is this account for taxes?',
45a83e42 304 'default' => '0',
522a26c9 305 'table_name' => 'civicrm_financial_account',
306 'entity' => 'FinancialAccount',
307 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 308 'localizable' => 0,
c3fc2621
CW
309 ],
310 'tax_rate' => [
e501603b
TO
311 'name' => 'tax_rate',
312 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 313 'title' => ts('Financial Account Tax Rate'),
e501603b 314 'description' => 'The percentage of the total_amount that is due for this tax.',
c3fc2621 315 'precision' => [
e501603b
TO
316 10,
317 8
c3fc2621 318 ],
522a26c9 319 'table_name' => 'civicrm_financial_account',
320 'entity' => 'FinancialAccount',
321 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 322 'localizable' => 0,
c3fc2621
CW
323 ],
324 'is_reserved' => [
e501603b
TO
325 'name' => 'is_reserved',
326 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 327 'title' => ts('Reserved Financial Account?'),
e501603b 328 'description' => 'Is this a predefined system object?',
522a26c9 329 'table_name' => 'civicrm_financial_account',
330 'entity' => 'FinancialAccount',
331 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 332 'localizable' => 0,
c3fc2621
CW
333 ],
334 'is_active' => [
e501603b
TO
335 'name' => 'is_active',
336 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 337 'title' => ts('Financial Account is Active'),
e501603b 338 'description' => 'Is this property active?',
522a26c9 339 'table_name' => 'civicrm_financial_account',
340 'entity' => 'FinancialAccount',
341 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 342 'localizable' => 0,
c3fc2621
CW
343 ],
344 'is_default' => [
e501603b
TO
345 'name' => 'is_default',
346 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 347 'title' => ts('Default Financial Account'),
e501603b 348 'description' => 'Is this account the default one (or default tax one) for its financial_account_type?',
522a26c9 349 'table_name' => 'civicrm_financial_account',
350 'entity' => 'FinancialAccount',
351 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 352 'localizable' => 0,
c3fc2621
CW
353 ],
354 ];
346aaaba 355 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 356 }
346aaaba 357 return Civi::$statics[__CLASS__]['fields'];
e501603b 358 }
c3fc2621 359
e501603b 360 /**
bd8e0b14 361 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
362 *
363 * @return array
bd8e0b14 364 * Array(string $name => string $uniqueName).
e501603b 365 */
c3fc2621 366 public static function &fieldKeys() {
bd8e0b14
TO
367 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
368 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 369 }
bd8e0b14 370 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 371 }
c3fc2621 372
e501603b
TO
373 /**
374 * Returns the names of this table
375 *
376 * @return string
377 */
c3fc2621 378 public static function getTableName() {
e501603b
TO
379 return self::$_tableName;
380 }
c3fc2621 381
e501603b
TO
382 /**
383 * Returns if this table needs to be logged
384 *
c3fc2621 385 * @return bool
e501603b 386 */
c3fc2621 387 public function getLog() {
e501603b
TO
388 return self::$_log;
389 }
c3fc2621 390
e501603b
TO
391 /**
392 * Returns the list of fields that can be imported
393 *
394 * @param bool $prefix
395 *
396 * @return array
397 */
c3fc2621
CW
398 public static function &import($prefix = FALSE) {
399 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_account', $prefix, []);
60808919 400 return $r;
e501603b 401 }
c3fc2621 402
e501603b
TO
403 /**
404 * Returns the list of fields that can be exported
405 *
406 * @param bool $prefix
407 *
408 * @return array
409 */
c3fc2621
CW
410 public static function &export($prefix = FALSE) {
411 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_account', $prefix, []);
60808919 412 return $r;
e501603b 413 }
c3fc2621 414
e7a6b91a
AS
415 /**
416 * Returns the list of indices
c3fc2621
CW
417 *
418 * @param bool $localize
419 *
420 * @return array
e7a6b91a
AS
421 */
422 public static function indices($localize = TRUE) {
c3fc2621
CW
423 $indices = [
424 'UI_name' => [
e7a6b91a 425 'name' => 'UI_name',
c3fc2621 426 'field' => [
e7a6b91a 427 0 => 'name',
c3fc2621
CW
428 ],
429 'localizable' => FALSE,
430 'unique' => TRUE,
e7a6b91a 431 'sig' => 'civicrm_financial_account::1::name',
c3fc2621
CW
432 ],
433 ];
e7a6b91a
AS
434 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
435 }
c3fc2621 436
e501603b 437}