5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Financial/FinancialItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:a70adfdd0e2248a7583c5c49ad0a5b85)
13 * Database access object for the FinancialItem entity.
15 class CRM_Financial_DAO_FinancialItem
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '4.3';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_financial_item';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
39 * Date and time the item was created
46 * Date and time of the source transaction
50 public $transaction_date;
53 * FK to Contact ID of contact the item is from
60 * Human readable description of this item, to ease display without lookup of source item.
67 * Total amount of this item
74 * Currency for the amount
81 * FK to civicrm_financial_account
85 public $financial_account_id;
88 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
95 * The table providing the source of this item such as civicrm_line_item
102 * The specific source item that is responsible for the creation of this financial_item
111 public function __construct() {
112 $this->__table
= 'civicrm_financial_item';
113 parent
::__construct();
117 * Returns localized title of this entity.
119 * @param bool $plural
120 * Whether to return the plural version of the title.
122 public static function getEntityTitle($plural = FALSE) {
123 return $plural ?
ts('Financial Items') : ts('Financial Item');
127 * Returns foreign keys and entity references.
130 * [CRM_Core_Reference_Interface]
132 public static function getReferenceColumns() {
133 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
134 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
135 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
136 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
137 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
138 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
140 return Civi
::$statics[__CLASS__
]['links'];
144 * Returns all the column names of this table
148 public static function &fields() {
149 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
150 Civi
::$statics[__CLASS__
]['fields'] = [
153 'type' => CRM_Utils_Type
::T_INT
,
154 'title' => ts('Financial Item ID'),
156 'where' => 'civicrm_financial_item.id',
157 'table_name' => 'civicrm_financial_item',
158 'entity' => 'FinancialItem',
159 'bao' => 'CRM_Financial_BAO_FinancialItem',
164 'name' => 'created_date',
165 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
166 'title' => ts('Financial Item Created Date'),
167 'description' => ts('Date and time the item was created'),
169 'where' => 'civicrm_financial_item.created_date',
170 'default' => 'CURRENT_TIMESTAMP',
171 'table_name' => 'civicrm_financial_item',
172 'entity' => 'FinancialItem',
173 'bao' => 'CRM_Financial_BAO_FinancialItem',
177 'transaction_date' => [
178 'name' => 'transaction_date',
179 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
180 'title' => ts('Financial Item Transaction Date'),
181 'description' => ts('Date and time of the source transaction'),
183 'where' => 'civicrm_financial_item.transaction_date',
184 'table_name' => 'civicrm_financial_item',
185 'entity' => 'FinancialItem',
186 'bao' => 'CRM_Financial_BAO_FinancialItem',
191 'name' => 'contact_id',
192 'type' => CRM_Utils_Type
::T_INT
,
193 'title' => ts('Financial Item Contact ID'),
194 'description' => ts('FK to Contact ID of contact the item is from'),
196 'where' => 'civicrm_financial_item.contact_id',
198 'table_name' => 'civicrm_financial_item',
199 'entity' => 'FinancialItem',
200 'bao' => 'CRM_Financial_BAO_FinancialItem',
202 'FKClassName' => 'CRM_Contact_DAO_Contact',
206 'name' => 'description',
207 'type' => CRM_Utils_Type
::T_STRING
,
208 'title' => ts('Financial Item Description'),
209 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
211 'size' => CRM_Utils_Type
::HUGE
,
212 'where' => 'civicrm_financial_item.description',
213 'table_name' => 'civicrm_financial_item',
214 'entity' => 'FinancialItem',
215 'bao' => 'CRM_Financial_BAO_FinancialItem',
221 'type' => CRM_Utils_Type
::T_MONEY
,
222 'title' => ts('Amount'),
223 'description' => ts('Total amount of this item'),
229 'where' => 'civicrm_financial_item.amount',
230 'headerPattern' => '/unit?.?amoun/i',
231 'dataPattern' => '/^\d+(\.\d{2})?$/',
233 'table_name' => 'civicrm_financial_item',
234 'entity' => 'FinancialItem',
235 'bao' => 'CRM_Financial_BAO_FinancialItem',
240 'name' => 'currency',
241 'type' => CRM_Utils_Type
::T_STRING
,
242 'title' => ts('Financial Item Currency'),
243 'description' => ts('Currency for the amount'),
245 'size' => CRM_Utils_Type
::FOUR
,
246 'where' => 'civicrm_financial_item.currency',
248 'table_name' => 'civicrm_financial_item',
249 'entity' => 'FinancialItem',
250 'bao' => 'CRM_Financial_BAO_FinancialItem',
255 'pseudoconstant' => [
256 'table' => 'civicrm_currency',
257 'keyColumn' => 'name',
258 'labelColumn' => 'full_name',
259 'nameColumn' => 'name',
260 'abbrColumn' => 'symbol',
264 'financial_account_id' => [
265 'name' => 'financial_account_id',
266 'type' => CRM_Utils_Type
::T_INT
,
267 'title' => ts('Financial Account ID'),
268 'description' => ts('FK to civicrm_financial_account'),
269 'where' => 'civicrm_financial_item.financial_account_id',
270 'table_name' => 'civicrm_financial_item',
271 'entity' => 'FinancialItem',
272 'bao' => 'CRM_Financial_BAO_FinancialItem',
274 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
278 'pseudoconstant' => [
279 'table' => 'civicrm_financial_account',
281 'labelColumn' => 'name',
286 'name' => 'status_id',
287 'type' => CRM_Utils_Type
::T_INT
,
288 'title' => ts('Financial Item Status ID'),
289 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
290 'where' => 'civicrm_financial_item.status_id',
292 'table_name' => 'civicrm_financial_item',
293 'entity' => 'FinancialItem',
294 'bao' => 'CRM_Financial_BAO_FinancialItem',
299 'pseudoconstant' => [
300 'optionGroupName' => 'financial_item_status',
301 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
306 'name' => 'entity_table',
307 'type' => CRM_Utils_Type
::T_STRING
,
308 'title' => ts('Entity Table'),
309 'description' => ts('The table providing the source of this item such as civicrm_line_item'),
311 'size' => CRM_Utils_Type
::BIG
,
312 'where' => 'civicrm_financial_item.entity_table',
313 'table_name' => 'civicrm_financial_item',
314 'entity' => 'FinancialItem',
315 'bao' => 'CRM_Financial_BAO_FinancialItem',
320 'name' => 'entity_id',
321 'type' => CRM_Utils_Type
::T_INT
,
322 'title' => ts('Entity ID'),
323 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
324 'where' => 'civicrm_financial_item.entity_id',
325 'table_name' => 'civicrm_financial_item',
326 'entity' => 'FinancialItem',
327 'bao' => 'CRM_Financial_BAO_FinancialItem',
332 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
334 return Civi
::$statics[__CLASS__
]['fields'];
338 * Return a mapping from field-name to the corresponding key (as used in fields()).
341 * Array(string $name => string $uniqueName).
343 public static function &fieldKeys() {
344 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
345 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
347 return Civi
::$statics[__CLASS__
]['fieldKeys'];
351 * Returns the names of this table
355 public static function getTableName() {
356 return self
::$_tableName;
360 * Returns if this table needs to be logged
364 public function getLog() {
369 * Returns the list of fields that can be imported
371 * @param bool $prefix
375 public static function &import($prefix = FALSE) {
376 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_item', $prefix, []);
381 * Returns the list of fields that can be exported
383 * @param bool $prefix
387 public static function &export($prefix = FALSE) {
388 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_item', $prefix, []);
393 * Returns the list of indices
395 * @param bool $localize
399 public static function indices($localize = TRUE) {
401 'IX_created_date' => [
402 'name' => 'IX_created_date',
406 'localizable' => FALSE,
407 'sig' => 'civicrm_financial_item::0::created_date',
409 'IX_transaction_date' => [
410 'name' => 'IX_transaction_date',
412 0 => 'transaction_date',
414 'localizable' => FALSE,
415 'sig' => 'civicrm_financial_item::0::transaction_date',
417 'index_entity_id_entity_table' => [
418 'name' => 'index_entity_id_entity_table',
423 'localizable' => FALSE,
424 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
427 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;