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:02ec1490ebc665316bc38da19b07cb60)
13 * Database access object for the FinancialItem entity.
15 class CRM_Financial_DAO_FinancialItem
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_financial_item';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
37 * Date and time the item was created
44 * Date and time of the source transaction
48 public $transaction_date;
51 * FK to Contact ID of contact the item is from
58 * Human readable description of this item, to ease display without lookup of source item.
65 * Total amount of this item
72 * Currency for the amount
79 * FK to civicrm_financial_account
83 public $financial_account_id;
86 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
93 * The table providing the source of this item such as civicrm_line_item
100 * The specific source item that is responsible for the creation of this financial_item
109 public function __construct() {
110 $this->__table
= 'civicrm_financial_item';
111 parent
::__construct();
115 * Returns foreign keys and entity references.
118 * [CRM_Core_Reference_Interface]
120 public static function getReferenceColumns() {
121 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
122 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
123 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
124 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
125 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
126 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
128 return Civi
::$statics[__CLASS__
]['links'];
132 * Returns all the column names of this table
136 public static function &fields() {
137 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
138 Civi
::$statics[__CLASS__
]['fields'] = [
141 'type' => CRM_Utils_Type
::T_INT
,
142 'title' => ts('Financial Item ID'),
144 'where' => 'civicrm_financial_item.id',
145 'table_name' => 'civicrm_financial_item',
146 'entity' => 'FinancialItem',
147 'bao' => 'CRM_Financial_BAO_FinancialItem',
151 'name' => 'created_date',
152 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
153 'title' => ts('Financial Item Created Date'),
154 'description' => ts('Date and time the item was created'),
156 'where' => 'civicrm_financial_item.created_date',
157 'default' => 'CURRENT_TIMESTAMP',
158 'table_name' => 'civicrm_financial_item',
159 'entity' => 'FinancialItem',
160 'bao' => 'CRM_Financial_BAO_FinancialItem',
163 'transaction_date' => [
164 'name' => 'transaction_date',
165 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
166 'title' => ts('Financial Item Transaction Date'),
167 'description' => ts('Date and time of the source transaction'),
169 'where' => 'civicrm_financial_item.transaction_date',
170 'table_name' => 'civicrm_financial_item',
171 'entity' => 'FinancialItem',
172 'bao' => 'CRM_Financial_BAO_FinancialItem',
176 'name' => 'contact_id',
177 'type' => CRM_Utils_Type
::T_INT
,
178 'title' => ts('Financial Item Contact ID'),
179 'description' => ts('FK to Contact ID of contact the item is from'),
181 'where' => 'civicrm_financial_item.contact_id',
183 'table_name' => 'civicrm_financial_item',
184 'entity' => 'FinancialItem',
185 'bao' => 'CRM_Financial_BAO_FinancialItem',
187 'FKClassName' => 'CRM_Contact_DAO_Contact',
190 'name' => 'description',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Financial Item Description'),
193 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
195 'size' => CRM_Utils_Type
::HUGE
,
196 'where' => 'civicrm_financial_item.description',
197 'table_name' => 'civicrm_financial_item',
198 'entity' => 'FinancialItem',
199 'bao' => 'CRM_Financial_BAO_FinancialItem',
204 'type' => CRM_Utils_Type
::T_MONEY
,
205 'title' => ts('Amount'),
206 'description' => ts('Total amount of this item'),
212 'where' => 'civicrm_financial_item.amount',
213 'headerPattern' => '/unit?.?amoun/i',
214 'dataPattern' => '/^\d+(\.\d{2})?$/',
216 'table_name' => 'civicrm_financial_item',
217 'entity' => 'FinancialItem',
218 'bao' => 'CRM_Financial_BAO_FinancialItem',
222 'name' => 'currency',
223 'type' => CRM_Utils_Type
::T_STRING
,
224 'title' => ts('Financial Item Currency'),
225 'description' => ts('Currency for the amount'),
227 'size' => CRM_Utils_Type
::FOUR
,
228 'where' => 'civicrm_financial_item.currency',
230 'table_name' => 'civicrm_financial_item',
231 'entity' => 'FinancialItem',
232 'bao' => 'CRM_Financial_BAO_FinancialItem',
237 'pseudoconstant' => [
238 'table' => 'civicrm_currency',
239 'keyColumn' => 'name',
240 'labelColumn' => 'full_name',
241 'nameColumn' => 'name',
242 'abbrColumn' => 'symbol',
245 'financial_account_id' => [
246 'name' => 'financial_account_id',
247 'type' => CRM_Utils_Type
::T_INT
,
248 'title' => ts('Financial Account ID'),
249 'description' => ts('FK to civicrm_financial_account'),
250 'where' => 'civicrm_financial_item.financial_account_id',
251 'table_name' => 'civicrm_financial_item',
252 'entity' => 'FinancialItem',
253 'bao' => 'CRM_Financial_BAO_FinancialItem',
255 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
259 'pseudoconstant' => [
260 'table' => 'civicrm_financial_account',
262 'labelColumn' => 'name',
266 'name' => 'status_id',
267 'type' => CRM_Utils_Type
::T_INT
,
268 'title' => ts('Financial Item Status ID'),
269 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
270 'where' => 'civicrm_financial_item.status_id',
272 'table_name' => 'civicrm_financial_item',
273 'entity' => 'FinancialItem',
274 'bao' => 'CRM_Financial_BAO_FinancialItem',
279 'pseudoconstant' => [
280 'optionGroupName' => 'financial_item_status',
281 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
285 'name' => 'entity_table',
286 'type' => CRM_Utils_Type
::T_STRING
,
287 'title' => ts('Entity Table'),
288 'description' => ts('The table providing the source of this item such as civicrm_line_item'),
290 'size' => CRM_Utils_Type
::BIG
,
291 'where' => 'civicrm_financial_item.entity_table',
292 'table_name' => 'civicrm_financial_item',
293 'entity' => 'FinancialItem',
294 'bao' => 'CRM_Financial_BAO_FinancialItem',
298 'name' => 'entity_id',
299 'type' => CRM_Utils_Type
::T_INT
,
300 'title' => ts('Entity ID'),
301 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
302 'where' => 'civicrm_financial_item.entity_id',
303 'table_name' => 'civicrm_financial_item',
304 'entity' => 'FinancialItem',
305 'bao' => 'CRM_Financial_BAO_FinancialItem',
309 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
311 return Civi
::$statics[__CLASS__
]['fields'];
315 * Return a mapping from field-name to the corresponding key (as used in fields()).
318 * Array(string $name => string $uniqueName).
320 public static function &fieldKeys() {
321 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
322 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
324 return Civi
::$statics[__CLASS__
]['fieldKeys'];
328 * Returns the names of this table
332 public static function getTableName() {
333 return self
::$_tableName;
337 * Returns if this table needs to be logged
341 public function getLog() {
346 * Returns the list of fields that can be imported
348 * @param bool $prefix
352 public static function &import($prefix = FALSE) {
353 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_item', $prefix, []);
358 * Returns the list of fields that can be exported
360 * @param bool $prefix
364 public static function &export($prefix = FALSE) {
365 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_item', $prefix, []);
370 * Returns the list of indices
372 * @param bool $localize
376 public static function indices($localize = TRUE) {
378 'IX_created_date' => [
379 'name' => 'IX_created_date',
383 'localizable' => FALSE,
384 'sig' => 'civicrm_financial_item::0::created_date',
386 'IX_transaction_date' => [
387 'name' => 'IX_transaction_date',
389 0 => 'transaction_date',
391 'localizable' => FALSE,
392 'sig' => 'civicrm_financial_item::0::transaction_date',
394 'index_entity_id_entity_table' => [
395 'name' => 'index_entity_id_entity_table',
400 'localizable' => FALSE,
401 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
404 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;