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