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