xml/templates/dao.tpl - Simplify fieldKeys()
[civicrm-core.git] / CRM / Financial / DAO / FinancialAccount.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
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
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Financial/FinancialAccount.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:f8ca05b54a4b94d2636d0da894b7236f)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_financial_account';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
e501603b
TO
62 /**
63 * static value to see if we should log any modifications to
64 * this table in the civicrm_log table
65 *
66 * @var boolean
67 */
68 static $_log = true;
69 /**
70 * ID
71 *
72 * @var int unsigned
73 */
74 public $id;
75 /**
76 * Financial Account Name.
77 *
78 * @var string
79 */
80 public $name;
81 /**
82 * FK to Contact ID that is responsible for the funds in this account
83 *
84 * @var int unsigned
85 */
86 public $contact_id;
87 /**
88 * pseudo FK into civicrm_option_value.
89 *
90 * @var int unsigned
91 */
92 public $financial_account_type_id;
93 /**
94 * Optional value for mapping monies owed and received to accounting system codes.
95 *
96 * @var string
97 */
98 public $accounting_code;
99 /**
100 * Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).
101 *
102 * @var string
103 */
104 public $account_type_code;
105 /**
106 * Financial Type Description.
107 *
108 * @var string
109 */
110 public $description;
111 /**
112 * Parent ID in account hierarchy
113 *
114 * @var int unsigned
115 */
116 public $parent_id;
117 /**
118 * Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?
119 *
120 * @var boolean
121 */
122 public $is_header_account;
123 /**
124 * Is this account tax-deductible?
125 *
126 * @var boolean
127 */
128 public $is_deductible;
129 /**
130 * Is this account for taxes?
131 *
132 * @var boolean
133 */
134 public $is_tax;
135 /**
136 * The percentage of the total_amount that is due for this tax.
137 *
138 * @var float
139 */
140 public $tax_rate;
141 /**
142 * Is this a predefined system object?
143 *
144 * @var boolean
145 */
146 public $is_reserved;
147 /**
148 * Is this property active?
149 *
150 * @var boolean
151 */
152 public $is_active;
153 /**
154 * Is this account the default one (or default tax one) for its financial_account_type?
155 *
156 * @var boolean
157 */
158 public $is_default;
159 /**
160 * Contains the opening balance for this financial account
161 *
162 * @var float
163 */
164 public $opening_balance;
165 /**
166 * Contains the opening balance for the current period for this financial account
167 *
168 * @var float
169 */
170 public $current_period_opening_balance;
171 /**
172 * class constructor
173 *
174 * @return civicrm_financial_account
175 */
176 function __construct() {
177 $this->__table = 'civicrm_financial_account';
178 parent::__construct();
179 }
180 /**
181 * Returns foreign keys and entity references
182 *
183 * @return array
184 * [CRM_Core_Reference_Interface]
185 */
186 static function getReferenceColumns() {
187 if (!self::$_links) {
188 self::$_links = static ::createReferenceColumns(__CLASS__);
189 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
190 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'parent_id', 'civicrm_financial_account', 'id');
191 }
192 return self::$_links;
193 }
194 /**
195 * Returns all the column names of this table
196 *
197 * @return array
198 */
199 static function &fields() {
200 if (!(self::$_fields)) {
201 self::$_fields = array(
202 'id' => array(
203 'name' => 'id',
204 'type' => CRM_Utils_Type::T_INT,
205 'title' => ts('Financial Account ID') ,
206 'description' => 'ID',
207 'required' => true,
208 ) ,
209 'name' => array(
210 'name' => 'name',
211 'type' => CRM_Utils_Type::T_STRING,
212 'title' => ts('Financial Account Name') ,
213 'description' => 'Financial Account Name.',
214 'required' => true,
215 'maxlength' => 255,
216 'size' => CRM_Utils_Type::HUGE,
217 ) ,
218 'financial_account_contact_id' => array(
219 'name' => 'contact_id',
220 'type' => CRM_Utils_Type::T_INT,
221 'title' => ts('Contact ID') ,
222 'description' => 'FK to Contact ID that is responsible for the funds in this account',
223 'FKClassName' => 'CRM_Contact_DAO_Contact',
224 ) ,
225 'financial_account_type_id' => array(
226 'name' => 'financial_account_type_id',
227 'type' => CRM_Utils_Type::T_INT,
228 'title' => ts('Financial Account Type') ,
229 'description' => 'pseudo FK into civicrm_option_value.',
230 'required' => true,
231 'default' => '3',
232 'html' => array(
233 'type' => 'Select',
234 ) ,
235 'pseudoconstant' => array(
236 'optionGroupName' => 'financial_account_type',
237 'optionEditPath' => 'civicrm/admin/options/financial_account_type',
238 )
239 ) ,
240 'accounting_code' => array(
241 'name' => 'accounting_code',
242 'type' => CRM_Utils_Type::T_STRING,
243 'title' => ts('Accounting Code') ,
244 'description' => 'Optional value for mapping monies owed and received to accounting system codes.',
245 'maxlength' => 64,
246 'size' => CRM_Utils_Type::BIG,
247 'export' => true,
248 'where' => 'civicrm_financial_account.accounting_code',
249 'headerPattern' => '',
250 'dataPattern' => '',
251 ) ,
252 'account_type_code' => array(
253 'name' => 'account_type_code',
254 'type' => CRM_Utils_Type::T_STRING,
255 'title' => ts('Account Type Code') ,
256 'description' => 'Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).',
257 'maxlength' => 64,
258 'size' => CRM_Utils_Type::BIG,
259 'export' => true,
260 'where' => 'civicrm_financial_account.account_type_code',
261 'headerPattern' => '',
262 'dataPattern' => '',
263 ) ,
264 'description' => array(
265 'name' => 'description',
266 'type' => CRM_Utils_Type::T_STRING,
267 'title' => ts('Financial Account Description') ,
268 'description' => 'Financial Type Description.',
269 'maxlength' => 255,
270 'size' => CRM_Utils_Type::HUGE,
271 ) ,
272 'parent_id' => array(
273 'name' => 'parent_id',
274 'type' => CRM_Utils_Type::T_INT,
275 'title' => ts('Financial Account Parent') ,
276 'description' => 'Parent ID in account hierarchy',
277 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
278 ) ,
279 'is_header_account' => array(
280 'name' => 'is_header_account',
281 'type' => CRM_Utils_Type::T_BOOLEAN,
282 'title' => ts('Header Financial Account?') ,
283 'description' => 'Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?',
284 ) ,
285 'is_deductible' => array(
286 'name' => 'is_deductible',
287 'type' => CRM_Utils_Type::T_BOOLEAN,
288 'title' => ts('Deductible Financial Account?') ,
289 'description' => 'Is this account tax-deductible?',
290 'default' => '1',
291 ) ,
292 'is_tax' => array(
293 'name' => 'is_tax',
294 'type' => CRM_Utils_Type::T_BOOLEAN,
295 'title' => ts('Tax Financial Account?') ,
296 'description' => 'Is this account for taxes?',
297 ) ,
298 'tax_rate' => array(
299 'name' => 'tax_rate',
300 'type' => CRM_Utils_Type::T_MONEY,
301 'title' => ts('Financial Account Tax Rate') ,
302 'description' => 'The percentage of the total_amount that is due for this tax.',
303 'precision' => array(
304 10,
305 8
306 ) ,
307 ) ,
308 'is_reserved' => array(
309 'name' => 'is_reserved',
310 'type' => CRM_Utils_Type::T_BOOLEAN,
311 'title' => ts('Reserved Financial Account?') ,
312 'description' => 'Is this a predefined system object?',
313 ) ,
314 'is_active' => array(
315 'name' => 'is_active',
316 'type' => CRM_Utils_Type::T_BOOLEAN,
317 'title' => ts('Financial Account is Active') ,
318 'description' => 'Is this property active?',
319 ) ,
320 'is_default' => array(
321 'name' => 'is_default',
322 'type' => CRM_Utils_Type::T_BOOLEAN,
323 'title' => ts('Default Financial Account') ,
324 'description' => 'Is this account the default one (or default tax one) for its financial_account_type?',
325 ) ,
326 'opening_balance' => array(
327 'name' => 'opening_balance',
328 'type' => CRM_Utils_Type::T_MONEY,
329 'title' => ts('Opening Balance') ,
330 'description' => 'Contains the opening balance for this financial account',
331 'precision' => array(
332 20,
333 2
334 ) ,
335 ) ,
336 'current_period_opening_balance' => array(
337 'name' => 'current_period_opening_balance',
338 'type' => CRM_Utils_Type::T_MONEY,
339 'title' => ts('Current period opening Balance') ,
340 'description' => 'Contains the opening balance for the current period for this financial account',
341 'precision' => array(
342 20,
343 2
344 ) ,
345 ) ,
346 );
347 }
348 return self::$_fields;
349 }
350 /**
351 * Returns an array containing, for each field, the arary key used for that
352 * field in self::$_fields.
353 *
354 * @return array
355 */
356 static function &fieldKeys() {
357 if (!(self::$_fieldKeys)) {
358 self::$_fieldKeys = array(
359 'id' => 'id',
360 'name' => 'name',
361 'contact_id' => 'financial_account_contact_id',
362 'financial_account_type_id' => 'financial_account_type_id',
363 'accounting_code' => 'accounting_code',
364 'account_type_code' => 'account_type_code',
365 'description' => 'description',
366 'parent_id' => 'parent_id',
367 'is_header_account' => 'is_header_account',
368 'is_deductible' => 'is_deductible',
369 'is_tax' => 'is_tax',
370 'tax_rate' => 'tax_rate',
371 'is_reserved' => 'is_reserved',
372 'is_active' => 'is_active',
373 'is_default' => 'is_default',
374 'opening_balance' => 'opening_balance',
375 'current_period_opening_balance' => 'current_period_opening_balance',
376 );
377 }
378 return self::$_fieldKeys;
379 }
380 /**
381 * Returns the names of this table
382 *
383 * @return string
384 */
385 static function getTableName() {
386 return self::$_tableName;
387 }
388 /**
389 * Returns if this table needs to be logged
390 *
391 * @return boolean
392 */
393 function getLog() {
394 return self::$_log;
395 }
396 /**
397 * Returns the list of fields that can be imported
398 *
399 * @param bool $prefix
400 *
401 * @return array
402 */
403 static function &import($prefix = false) {
60808919
TO
404 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_account', $prefix, array());
405 return $r;
e501603b
TO
406 }
407 /**
408 * Returns the list of fields that can be exported
409 *
410 * @param bool $prefix
411 *
412 * @return array
413 */
414 static function &export($prefix = false) {
60808919
TO
415 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_account', $prefix, array());
416 return $r;
e501603b
TO
417 }
418}