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:8bb63ebee681c2eb4acbf8650b224dc2)
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 public static function getEntityTitle() {
120 return ts('Financial Items');
124 * Returns foreign keys and entity references.
127 * [CRM_Core_Reference_Interface]
129 public static function getReferenceColumns() {
130 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
131 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
132 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
133 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
134 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
135 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
137 return Civi
::$statics[__CLASS__
]['links'];
141 * Returns all the column names of this table
145 public static function &fields() {
146 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
147 Civi
::$statics[__CLASS__
]['fields'] = [
150 'type' => CRM_Utils_Type
::T_INT
,
151 'title' => ts('Financial Item ID'),
153 'where' => 'civicrm_financial_item.id',
154 'table_name' => 'civicrm_financial_item',
155 'entity' => 'FinancialItem',
156 'bao' => 'CRM_Financial_BAO_FinancialItem',
161 'name' => 'created_date',
162 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
163 'title' => ts('Financial Item Created Date'),
164 'description' => ts('Date and time the item was created'),
166 'where' => 'civicrm_financial_item.created_date',
167 'default' => 'CURRENT_TIMESTAMP',
168 'table_name' => 'civicrm_financial_item',
169 'entity' => 'FinancialItem',
170 'bao' => 'CRM_Financial_BAO_FinancialItem',
174 'transaction_date' => [
175 'name' => 'transaction_date',
176 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
177 'title' => ts('Financial Item Transaction Date'),
178 'description' => ts('Date and time of the source transaction'),
180 'where' => 'civicrm_financial_item.transaction_date',
181 'table_name' => 'civicrm_financial_item',
182 'entity' => 'FinancialItem',
183 'bao' => 'CRM_Financial_BAO_FinancialItem',
188 'name' => 'contact_id',
189 'type' => CRM_Utils_Type
::T_INT
,
190 'title' => ts('Financial Item Contact ID'),
191 'description' => ts('FK to Contact ID of contact the item is from'),
193 'where' => 'civicrm_financial_item.contact_id',
195 'table_name' => 'civicrm_financial_item',
196 'entity' => 'FinancialItem',
197 'bao' => 'CRM_Financial_BAO_FinancialItem',
199 'FKClassName' => 'CRM_Contact_DAO_Contact',
203 'name' => 'description',
204 'type' => CRM_Utils_Type
::T_STRING
,
205 'title' => ts('Financial Item Description'),
206 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
208 'size' => CRM_Utils_Type
::HUGE
,
209 'where' => 'civicrm_financial_item.description',
210 'table_name' => 'civicrm_financial_item',
211 'entity' => 'FinancialItem',
212 'bao' => 'CRM_Financial_BAO_FinancialItem',
218 'type' => CRM_Utils_Type
::T_MONEY
,
219 'title' => ts('Amount'),
220 'description' => ts('Total amount of this item'),
226 'where' => 'civicrm_financial_item.amount',
227 'headerPattern' => '/unit?.?amoun/i',
228 'dataPattern' => '/^\d+(\.\d{2})?$/',
230 'table_name' => 'civicrm_financial_item',
231 'entity' => 'FinancialItem',
232 'bao' => 'CRM_Financial_BAO_FinancialItem',
237 'name' => 'currency',
238 'type' => CRM_Utils_Type
::T_STRING
,
239 'title' => ts('Financial Item Currency'),
240 'description' => ts('Currency for the amount'),
242 'size' => CRM_Utils_Type
::FOUR
,
243 'where' => 'civicrm_financial_item.currency',
245 'table_name' => 'civicrm_financial_item',
246 'entity' => 'FinancialItem',
247 'bao' => 'CRM_Financial_BAO_FinancialItem',
252 'pseudoconstant' => [
253 'table' => 'civicrm_currency',
254 'keyColumn' => 'name',
255 'labelColumn' => 'full_name',
256 'nameColumn' => 'name',
257 'abbrColumn' => 'symbol',
261 'financial_account_id' => [
262 'name' => 'financial_account_id',
263 'type' => CRM_Utils_Type
::T_INT
,
264 'title' => ts('Financial Account ID'),
265 'description' => ts('FK to civicrm_financial_account'),
266 'where' => 'civicrm_financial_item.financial_account_id',
267 'table_name' => 'civicrm_financial_item',
268 'entity' => 'FinancialItem',
269 'bao' => 'CRM_Financial_BAO_FinancialItem',
271 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
275 'pseudoconstant' => [
276 'table' => 'civicrm_financial_account',
278 'labelColumn' => 'name',
283 'name' => 'status_id',
284 'type' => CRM_Utils_Type
::T_INT
,
285 'title' => ts('Financial Item Status ID'),
286 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
287 'where' => 'civicrm_financial_item.status_id',
289 'table_name' => 'civicrm_financial_item',
290 'entity' => 'FinancialItem',
291 'bao' => 'CRM_Financial_BAO_FinancialItem',
296 'pseudoconstant' => [
297 'optionGroupName' => 'financial_item_status',
298 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
303 'name' => 'entity_table',
304 'type' => CRM_Utils_Type
::T_STRING
,
305 'title' => ts('Entity Table'),
306 'description' => ts('The table providing the source of this item such as civicrm_line_item'),
308 'size' => CRM_Utils_Type
::BIG
,
309 'where' => 'civicrm_financial_item.entity_table',
310 'table_name' => 'civicrm_financial_item',
311 'entity' => 'FinancialItem',
312 'bao' => 'CRM_Financial_BAO_FinancialItem',
317 'name' => 'entity_id',
318 'type' => CRM_Utils_Type
::T_INT
,
319 'title' => ts('Entity ID'),
320 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
321 'where' => 'civicrm_financial_item.entity_id',
322 'table_name' => 'civicrm_financial_item',
323 'entity' => 'FinancialItem',
324 'bao' => 'CRM_Financial_BAO_FinancialItem',
329 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
331 return Civi
::$statics[__CLASS__
]['fields'];
335 * Return a mapping from field-name to the corresponding key (as used in fields()).
338 * Array(string $name => string $uniqueName).
340 public static function &fieldKeys() {
341 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
342 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
344 return Civi
::$statics[__CLASS__
]['fieldKeys'];
348 * Returns the names of this table
352 public static function getTableName() {
353 return self
::$_tableName;
357 * Returns if this table needs to be logged
361 public function getLog() {
366 * Returns the list of fields that can be imported
368 * @param bool $prefix
372 public static function &import($prefix = FALSE) {
373 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_item', $prefix, []);
378 * Returns the list of fields that can be exported
380 * @param bool $prefix
384 public static function &export($prefix = FALSE) {
385 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_item', $prefix, []);
390 * Returns the list of indices
392 * @param bool $localize
396 public static function indices($localize = TRUE) {
398 'IX_created_date' => [
399 'name' => 'IX_created_date',
403 'localizable' => FALSE,
404 'sig' => 'civicrm_financial_item::0::created_date',
406 'IX_transaction_date' => [
407 'name' => 'IX_transaction_date',
409 0 => 'transaction_date',
411 'localizable' => FALSE,
412 'sig' => 'civicrm_financial_item::0::transaction_date',
414 'index_entity_id_entity_table' => [
415 'name' => 'index_entity_id_entity_table',
420 'localizable' => FALSE,
421 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
424 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;