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