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