CRM_Contribute_BAO_Contribution
class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution
Constants
NOT_NULL |
|
IS_NULL |
|
DB_DAO_NOTNULL |
|
VALUE_SEPARATOR |
|
BULK_INSERT_COUNT |
|
BULK_INSERT_HIGH_COUNT |
|
QUERY_FORMAT_WILDCARD |
|
QUERY_FORMAT_NO_QUOTES |
|
Properties
static null | $_nullObject | from CRM_Core_DAO | |
static array | $_nullArray | from CRM_Core_DAO | |
static | $_dbColumnValueCache | from CRM_Core_DAO | |
static array | $_testEntitiesToSkip | Define entities that shouldn't be created or deleted when creating/ deleting test objects - this prevents world regions, countries etc from being added / deleted | from CRM_Core_DAO |
static object | $_factory | The factory class for this application. | from CRM_Core_DAO |
static | $_checkedSqlFunctionsExist | from CRM_Core_DAO | |
protected | $_options | https://issues.civicrm.org/jira/browse/CRM-17748 internal variable for DAO to hold per-query settings | from CRM_Core_DAO |
static string | $_tableName | Static instance to hold the table name. | from CRM_Contribute_DAO_Contribution |
static boolean | $_log | Should CiviCRM log any modifications to this table in the civicrm_log table. | from CRM_Contribute_DAO_Contribution |
int | $id | Contribution ID | from CRM_Contribute_DAO_Contribution |
int | $contact_id | FK to Contact ID | from CRM_Contribute_DAO_Contribution |
int | $financial_type_id | FK to Financial Type for (total_amount - non_deductible_amount). | from CRM_Contribute_DAO_Contribution |
int | $contribution_page_id | The Contribution Page which triggered this contribution | from CRM_Contribute_DAO_Contribution |
int | $payment_instrument_id | FK to Payment Instrument | from CRM_Contribute_DAO_Contribution |
datetime | $receive_date | Date contribution was received - not necessarily the creation date of the record | from CRM_Contribute_DAO_Contribution |
float | $non_deductible_amount | Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types. | from CRM_Contribute_DAO_Contribution |
float | $total_amount | Total amount of this contribution. Use market value for non-monetary gifts. | from CRM_Contribute_DAO_Contribution |
float | $fee_amount | actual processor fee if known - may be 0. | from CRM_Contribute_DAO_Contribution |
float | $net_amount | actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount. | from CRM_Contribute_DAO_Contribution |
string | $trxn_id | unique transaction id. may be processor id, bank id + trans id, or account number + check number. | from CRM_Contribute_DAO_Contribution |
string | $invoice_id | unique invoice id, system generated or passed in | from CRM_Contribute_DAO_Contribution |
string | $currency | 3 character string, value from config setting or input via user. | from CRM_Contribute_DAO_Contribution |
datetime | $cancel_date | when was gift cancelled | from CRM_Contribute_DAO_Contribution |
text | $cancel_reason | from CRM_Contribute_DAO_Contribution | |
datetime | $receipt_date | when (if) receipt was sent. populated automatically for online donations w/ automatic receipting | from CRM_Contribute_DAO_Contribution |
datetime | $thankyou_date | when (if) was donor thanked | from CRM_Contribute_DAO_Contribution |
string | $source | Origin of this Contribution. | from CRM_Contribute_DAO_Contribution |
text | $amount_level | from CRM_Contribute_DAO_Contribution | |
int | $contribution_recur_id | Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events. | from CRM_Contribute_DAO_Contribution |
boolean | $is_test | from CRM_Contribute_DAO_Contribution | |
boolean | $is_pay_later | from CRM_Contribute_DAO_Contribution | |
int | $contribution_status_id | from CRM_Contribute_DAO_Contribution | |
int | $address_id | Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data. | from CRM_Contribute_DAO_Contribution |
string | $check_number | from CRM_Contribute_DAO_Contribution | |
int | $campaign_id | The campaign for which this contribution has been triggered. | from CRM_Contribute_DAO_Contribution |
string | $creditnote_id | unique credit note id, system generated or passed in | from CRM_Contribute_DAO_Contribution |
float | $tax_amount | Total tax amount of this contribution. | from CRM_Contribute_DAO_Contribution |
datetime | $revenue_recognition_date | Stores the date when revenue should be recognized. | from CRM_Contribute_DAO_Contribution |
static array | $_importableFields | Static field for all the contribution information that we can potentially import | |
static array | $_exportableFields | Static field for all the contribution information that we can potentially export | |
static array | $_trxnIDs | Static field to hold financial trxn id's. | |
array | $_relatedObjects | Field for all the objects related to this contribution | |
string | $_component | Field for the component - either 'event' (participant) or 'contribute' (any item related to a contribution page e.g. membership, pledge, contribution) This is used for composing messages because they have dependency on the contribution_page or event page - although over time we may eliminate that | |
string | $trxn_result_code | Possibly obsolete variable. |
Methods
Class constructor.
Assign Test Value.
Execute a query by the current DAO, localizing it along the way (if needed).
Static function to set the factory instance for this class.
Factory method to instantiate a new object from a table name.
Initialization for all DAO objects. Since we access DB_DO programatically we need to set the links manually.
Returns foreign keys and entity references.
Returns all the column names of this table
Deletes items from table which match current objects variables.
Given an associative array of name/value pairs, extract all the values that belong to this object and initialize the object with said values
Store all the values from this object in an associative array this is a destructive store, calling function is responsible for keeping sanity of id's.
Create an attribute for this specific field. We only do this for strings and text
Get the size and maxLength attributes for this text field.
Check if there is a record with the same name in the db.
Check if there is a given column in a specific table.
Scans all the tables using a slow query and table name.
Checks if a constraint exists for a specified table.
Checks if CONSTRAINT keyword exists for a specified table.
Checks if the FK constraint name is in the format 'FK_tableName_columnName' for a specified column of a table.
Check whether a specific column in a specific table has always the same value.
Check whether a specific column in a specific table is always NULL.
Check if there is a given table in the database.
Get all the result records as mapping between columns.
Given a DAO name, a column name and a column value, find the record and GET the value of another column in that record
Given a DAO name, a column name and a column value, find the record and SET the value of another column in that record
Get sort string.
Fetch object based on array of properties.
Delete the object records that are associated with this contact.
Execute an unbuffered query.
Execute a query.
Execute a query and get the single result.
Compose the query by merging the parameters into it.
make a shallow copy of an object.
Cascade update through related entities.
Given the component id, compute the contact id since its used for things like send email
Fetch object based on array of properties.
Escape a list of strings for use with "WHERE X IN (.
Creates a test object, including any required objects it needs via recursion createOnly: only create in database, do not store or return the objects (useful for perf testing) ONLY USE FOR TESTING
Deletes the this object plus any dependent objects that are associated with it.
Set defaults when creating new entity.
No description
No description
Build a list of triggers via hook and add them to (err, reconcile them with) the database.
Because sql functions are sometimes lost, esp during db migration, we check here to avoid numerous support requests
Given a list of fields, create a list of references.
List all tables which have hard foreign keys to this table.
Lookup the value of a MySQL global configuration variable.
Update the fields array to also hold keys for pseudoconstant fields that relate to contained fields.
Get options for a given contribution field.
Provides documentation and validation for the buildOptions $context param
Get SQL where clause for SQL filter syntax input parameters.
SQL has a limit of 64 characters on various names: table name, trigger name, column name .
https://issues.civicrm.org/jira/browse/CRM-17748 Sets the internal options to be used on a query
https://issues.civicrm.org/jira/browse/CRM-17748 wrapper to pass internal DAO options down to DB_mysql/DB_Common level
Generates acl clauses suitable for adding to WHERE or ON when doing an api.get for this entity
This returns the final permissioned query string for this entity
ensure database name is 'safe', i.e. only contains word characters (includes underscores) and dashes, and contains at least one [a-z] case insenstive.
Return a mapping from field-name to the corresponding key (as used in fields()).
Returns the list of fields that can be imported
Returns the list of fields that can be exported
Takes an associative array and creates a contribution object.
Is this contribution updating an existing recurring contribution.
Get defaults for new entity.
Fetch the object and store the values in the values array.
Get the values and resolve the most common mappings.
Calculate net_amount & fee_amount if they are not set.
No description
Get address params ready to be passed to the payment processor.
Get the number of terms for this contribution for a given membership type based on querying the line item table and relevant price field values Note that any one contribution should only be able to have one line item relating to a particular membership type
Takes an associative array and creates a contribution object.
Get the values for pseudoconstants for name->value and reverse.
Convert associative array names to values and vice-versa.
Retrieve DB object based on input parameters.
Combine all the importable fields from the lower levels object.
Get exportable fields with pseudoconstants rendered as an extra field.
Combine all the exportable fields from the lower level objects.
No description
Delete the indirect records associated with this contribution first.
React to a financial transaction (payment) failure.
Check if there is a contribution with the same trxn_id or invoice_id.
Takes an associative array and creates a contribution_product object.
Get list of contribution fields for profile.
Add extra fields specific to contribution.
No description
Get list of contributions which credit the passed in contact ID.
Get the sort name of a contact for a particular contribution.
No description
Check if there is a contribution with the params passed in.
Get the contribution details for component export.
Create address associated with contribution record.
Delete billing address record related contribution.
This function check online pending contribution associated w/ Online Event Registration or Online Membership signup.
Update contribution as well as related objects.
Returns all contribution related object ids.
No description
Repeat a transaction as part of a recurring series.
Get individual id for onbehalf contribution.
No description
Load objects relations to contribution object.
Create array of message information - ie. return html version, txt version, to field
Gather values for contribution mail - this function has been created as part of CRM-9996 refactoring as a step towards simplifying the composeMessage function Values related to the contribution in question are gathered
Assign message variables to template but try to break the habit.
Check whether payment processor supports cancellation of contribution subscription
Check whether subscription is already cancelled.
Create all financial accounts entry.
Update all financial accounts entry.
Is this contribution status a reversal.
Check status validation on update of a contribution.
Delete contribution of contact.
Validate financial type.
Function to record additional payment for partial and refund contributions.
No description
Get list of payments displayed by Contribute_Page_PaymentInfo.
Get financial account id has 'Sales Tax Account is' account relationship with financial type.
Get the tax amount (misnamed function).
Check financial type validation on update of a contribution.
Update related pledge payment payments.
Compute the stats values
Is there only one line item attached to the contribution.
Complete an order.
Send receipt from contribution.
Generate From email and from name in an array values
Generate credit note id with next avaible number
Load related memberships.
This function is used to record partial payments for contribution
Get the description (source field) for the recurring contribution.
Function to add payments for contribution for Partially Paid status
Function use to store line item proportionaly in in entity financial trxn table
Function to check line items.
Get the financial account for the item associated with the new transaction.
ContributionPage values were being imposed onto values.
Get values of CiviContribute Settings and check if its enabled or not.
This function process contribution related objects.
Get the amount for the financial item row.
Get the multiplier for adjusting rows.
Check if contribution has participant/membership payment.
Create Accounts Receivable financial trxn entry for Completed Contribution.
Calculate financial item amount when contribution is updated.
Retrieve Sales Tax Financial Accounts.
Create tax entry in civicrm_entity_financial_trxn table.
Create array of last financial item id's.
Create proportional entries in civicrm_entity_financial_trxn.
Load entities related to the contribution into $this->_relatedObjects.
Should an email receipt be sent for this contribution when complete.
Function to replace contribution tokens.
Details
at line 84
CRM_Core_DAO
__construct()
Class constructor.
in CRM_Contribute_DAO_Contribution at line 857
static
getTableName()
Returns the names of this table
in CRM_Core_DAO at line 112
static
init(string $dsn)
Initialize the DAO object.
in CRM_Core_DAO at line 131
static DB_common
getConnection()
in CRM_Core_DAO at line 142
protected
assignTestFK(string $fieldName, $fieldDef, array $params)
at line 5375
protected
assignTestValue(string $fieldName, array $fieldDef, int $counter)
Assign Test Value.
in CRM_Core_DAO at line 303
reset()
Reset the DAO object.
DAO is kinda crappy in that there is an unwritten rule of one query per DAO.
We attempt to get around this crappy restriction by resetting some of DAO's internal fields. Use this with caution
in CRM_Core_DAO at line 323
static string
getLocaleTableName(string $tableName)
in CRM_Core_DAO at line 345
object
query(string $query, bool $i18nRewrite = TRUE)
Execute a query by the current DAO, localizing it along the way (if needed).
in CRM_Core_DAO at line 374
static
setFactory(object $factory)
Static function to set the factory instance for this class.
in CRM_Core_DAO at line 383
factory(string $table = '')
Factory method to instantiate a new object from a table name.
in CRM_Core_DAO at line 395
initialize()
Initialization for all DAO objects. Since we access DB_DO programatically we need to set the links manually.
in CRM_Core_DAO at line 411
array
keys()
Defines the default key as 'id'.
in CRM_Core_DAO at line 426
array
sequenceKey()
Tells DB_DataObject which keys use autoincrement.
'id' is autoincrementing by default.
in CRM_Contribute_DAO_Contribution at line 234
static array
getReferenceColumns()
Returns foreign keys and entity references.
in CRM_Contribute_DAO_Contribution at line 252
static array
fields()
Returns all the column names of this table
in CRM_Core_DAO at line 462
array
table()
Get/set an associative array of table columns
in CRM_Core_DAO at line 485
CRM_Core_DAO
save(bool $hook = TRUE)
Save DAO object.
in CRM_Core_DAO at line 536
delete(bool $useWhere = FALSE)
Deletes items from table which match current objects variables.
Returns the true on success
for example
Designed to be extended
$object = new mytable(); $object->ID=123; echo $object->delete(); // builds a conditon
$object = new mytable(); $object->whereAdd('age > 12'); $object->limit(1); $object->orderBy('age DESC'); $object->delete(true); // dont use object vars, use the conditions, limit and order.
in CRM_Core_DAO at line 552
log(bool $created = FALSE)
in CRM_Core_DAO at line 587
bool
copyValues(array $params)
Given an associative array of name/value pairs, extract all the values that belong to this object and initialize the object with said values
in CRM_Core_DAO at line 628
static
storeValues(object $object, array $values)
Store all the values from this object in an associative array this is a destructive store, calling function is responsible for keeping sanity of id's.
in CRM_Core_DAO at line 650
static array|null
makeAttribute(array $field)
Create an attribute for this specific field. We only do this for strings and text
in CRM_Core_DAO at line 703
static array
getAttribute(string $class, string $fieldName = NULL)
Get the size and maxLength attributes for this text field.
(or for all text fields) in the DAO object.
in CRM_Core_DAO at line 731
static
transaction($type)
in CRM_Core_DAO at line 754
static bool
objectExists(string $value, string $daoName, string $daoID, string $fieldName = 'name', string $domainID = NULL)
Check if there is a record with the same name in the db.
in CRM_Core_DAO at line 780
static bool
checkFieldExists(string $tableName, string $columnName, bool $i18nRewrite = TRUE)
Check if there is a given column in a specific table.
in CRM_Core_DAO at line 798
static array
getTableNames()
Scans all the tables using a slow query and table name.
in CRM_Core_DAO at line 820
static bool
isDBMyISAM(int $maxTablesToCheck = 10)
in CRM_Core_DAO at line 837
static string
getDatabaseName()
Get the name of the CiviCRM database.
in CRM_Core_DAO at line 851
static bool
checkConstraintExists(string $tableName, string $constraint)
Checks if a constraint exists for a specified table.
in CRM_Core_DAO at line 879
static bool
schemaRequiresRebuilding(array $tables = array("civicrm_contact"))
Checks if CONSTRAINT keyword exists for a specified table.
in CRM_Core_DAO at line 915
static bool
checkFKConstraintInFormat(string $tableName, string $columnName)
Checks if the FK constraint name is in the format 'FK_tableName_columnName' for a specified column of a table.
in CRM_Core_DAO at line 944
static bool
checkFieldHasAlwaysValue(string $tableName, string $columnName, string $columnValue)
Check whether a specific column in a specific table has always the same value.
in CRM_Core_DAO at line 961
static bool
checkFieldIsAlwaysNull(string $tableName, string $columnName)
Check whether a specific column in a specific table is always NULL.
in CRM_Core_DAO at line 977
static bool
checkTableExists(string $tableName)
Check if there is a given table in the database.
in CRM_Core_DAO at line 995
bool
checkVersion($version)
in CRM_Core_DAO at line 1013
static object
findById(int $id)
Find a DAO object for the given ID and return it.
in CRM_Core_DAO at line 1027
array
fetchAll()
Returns all results as array-encoded records.
in CRM_Core_DAO at line 1045
array
fetchMap(string $keyColumn, string $valueColumn)
Get all the result records as mapping between columns.
in CRM_Core_DAO at line 1070
static string|null
getFieldValue(string $daoName, int $searchValue, string $returnColumn = 'name', string $searchColumn = 'id', bool $force = FALSE)
Given a DAO name, a column name and a column value, find the record and GET the value of another column in that record
in CRM_Core_DAO at line 1120
static bool
setFieldValue(string $daoName, int $searchValue, string $setColumn, string $setValue, string $searchColumn = 'id')
Given a DAO name, a column name and a column value, find the record and SET the value of another column in that record
in CRM_Core_DAO at line 1146
static string
getSortString(array|object $sort, string $default = NULL)
Get sort string.
in CRM_Core_DAO at line 1177
static object
commonRetrieve(string $daoName, array $params, array $defaults, array $returnProperities = NULL)
Fetch object based on array of properties.
in CRM_Core_DAO at line 1202
static
deleteEntityContact(string $daoName, int $contactId)
Delete the object records that are associated with this contact.
in CRM_Core_DAO at line 1227
static CRM_Core_DAO
executeUnbufferedQuery(string $query, array $params = array(), bool $abort = TRUE, null $daoName = NULL, bool $freeDAO = FALSE, bool $i18nRewrite = TRUE, bool $trapException = FALSE)
Execute an unbuffered query.
This is a wrapper around new functionality exposed with CRM-17748.
in CRM_Core_DAO at line 1293
static CRM_Core_DAO|object
executeQuery(string $query, array $params = array(), bool $abort = TRUE, null $daoName = NULL, bool $freeDAO = FALSE, bool $i18nRewrite = TRUE, bool $trapException = FALSE)
Execute a query.
in CRM_Core_DAO at line 1343
static string|null
singleValueQuery(string $query, array $params = array(), bool $abort = TRUE, bool $i18nRewrite = TRUE)
Execute a query and get the single result.
in CRM_Core_DAO at line 1381
static string
composeQuery(string $query, array $params, bool $abort = TRUE)
Compose the query by merging the parameters into it.
in CRM_Core_DAO at line 1428
static
freeResult(null $ids = NULL)
in CRM_Core_DAO at line 1474
static CRM_Core_DAO
copyGeneric(string $daoName, array $criteria, array $newData = NULL, string $fieldsFix = NULL, string $blockCopyOfDependencies = NULL)
make a shallow copy of an object.
and all the fields in the object
in CRM_Core_DAO at line 1557
static CRM_Core_DAO|null
cascadeUpdate(string $daoName, $fromId, $toId, array $newData = array())
Cascade update through related entities.
in CRM_Core_DAO at line 1601
static array
getContactIDsFromComponent($componentIDs, string $tableName)
Given the component id, compute the contact id since its used for things like send email
in CRM_Core_DAO at line 1636
static object
commonRetrieveAll(string $daoName, string $fieldIdName = 'id', int $fieldId, $details, array $returnProperities = NULL)
Fetch object based on array of properties.
in CRM_Core_DAO at line 1658
static
dropAllTables()
in CRM_Core_DAO at line 1680
static string
escapeString($string)
in CRM_Core_DAO at line 1709
static string
escapeStrings(array $strings, string $default = NULL)
Escape a list of strings for use with "WHERE X IN (.
..)" queries.
in CRM_Core_DAO at line 1728
static string
escapeWildCardString($string)
in CRM_Core_DAO at line 1756
static object|array|NULL
createTestObject(string $daoName, array $params = array(), int $numObjects = 1, bool $createOnly = FALSE)
Creates a test object, including any required objects it needs via recursion createOnly: only create in database, do not store or return the objects (useful for perf testing) ONLY USE FOR TESTING
in CRM_Core_DAO at line 1839
static
deleteTestObjects(string $daoName, array $params = array())
Deletes the this object plus any dependent objects that are associated with it.
ONLY USE FOR TESTING
in CRM_Core_DAO at line 1885
static
setCreateDefaults(array $params, $defaults)
Set defaults when creating new entity.
(don't call this set defaults as already in use with different signature in some places)
in CRM_Core_DAO at line 1903
static string
createTempTableName(string $prefix = 'civicrm', bool $addRandomString = TRUE, null $string = NULL)
in CRM_Core_DAO at line 1923
static bool
checkTriggerViewPermission(bool $view = TRUE, bool $trigger = TRUE)
in CRM_Core_DAO at line 1971
static
debugPrint(null $message = NULL, bool $printDAO = TRUE)
in CRM_Core_DAO at line 1995
static
triggerRebuild(string $tableName = NULL, bool $force = FALSE)
deprecated
deprecated
Build a list of triggers via hook and add them to (err, reconcile them with) the database.
in CRM_Core_DAO at line 2006
static
checkSqlFunctionsExist()
Because sql functions are sometimes lost, esp during db migration, we check here to avoid numerous support requests
in CRM_Core_DAO at line 2023
static
dropTriggers(string $tableName = NULL)
deprecated
deprecated
Wrapper function to drop triggers.
in CRM_Core_DAO at line 2034
static
createTriggers(array $info, string $onlyTableName = NULL)
deprecated
deprecated
in CRM_Core_DAO at line 2045
static array
createReferenceColumns(string $className)
Given a list of fields, create a list of references.
in CRM_Core_DAO at line 2068
array
findReferences()
Find all records which refer to this entity.
in CRM_Core_DAO at line 2097
array
getReferenceCounts()
in CRM_Core_DAO at line 2134
static array
getReferencesToTable(string $tableName)
List all tables which have hard foreign keys to this table.
For now, this returns a description of every entity_id/entity_table reference. TODO: filter dynamic entity references on the $tableName, based on schema metadata in dynamicForeignKey which enumerates a restricted set of possible entity_table's.
in CRM_Core_DAO at line 2158
static mixed
getGlobalSetting(string $name, mixed $default = NULL)
Lookup the value of a MySQL global configuration variable.
in CRM_Core_DAO at line 2183
static protected
appendPseudoConstantsToFields(array $fields)
Update the fields array to also hold keys for pseudoconstant fields that relate to contained fields.
This is relevant where we want to offer both the ID field and the label field as an option, e.g. search builder.
It is currently limited for optionGroupName for purposes keeping the scope of the change small, but is appropriate for other sorts of pseudoconstants.
at line 3771
static array|bool
buildOptions(string $fieldName, string $context = NULL, array $props = array())
Get options for a given contribution field.
in CRM_Core_DAO at line 2220
getOptionLabels()
Populate option labels for this object's fields.
in CRM_Core_DAO at line 2246
static array
buildOptionsContext(string $context = NULL)
Provides documentation and validation for the buildOptions $context param
in CRM_Core_DAO at line 2266
bool|array
getFieldSpec(string $fieldName)
in CRM_Core_DAO at line 2309
static NULL|string|array
createSQLFilter(string $fieldName, array $filter, string $type = NULL, string $alias = NULL, bool $returnSanitisedArray = FALSE)
Get SQL where clause for SQL filter syntax input parameters.
SQL version of api function to assign filters to the DAO based on the syntax $field => array('IN' => array(4,6,9)) OR $field => array('LIKE' => array('%me%)) etc
in CRM_Core_DAO at line 2372
static array
acceptedSQLOperators()
in CRM_Core_DAO at line 2409
static string
shortenSQLName(string $string, int $length = 60, bool $makeRandom = FALSE)
SQL has a limit of 64 characters on various names: table name, trigger name, column name .
..
For custom groups and fields we generated names from user entered input which can be longer than this length, this function helps with creating strings that meet various criteria.
in CRM_Core_DAO at line 2435
setOptions(array $options)
https://issues.civicrm.org/jira/browse/CRM-17748 Sets the internal options to be used on a query
in CRM_Core_DAO at line 2448
protected
_setDBOptions(array $options)
https://issues.civicrm.org/jira/browse/CRM-17748 wrapper to pass internal DAO options down to DB_mysql/DB_Common level
in CRM_Core_DAO at line 2463
setApiFilter(array $params)
deprecated
deprecated
in CRM_Core_DAO at line 2480
array
addSelectWhereClause()
Generates acl clauses suitable for adding to WHERE or ON when doing an api.get for this entity
Return format is in the form of fieldname => clauses starting with an operator. e.g.:
in CRM_Core_DAO at line 2521
static array
getSelectWhereClause(string $tableAlias = NULL)
This returns the final permissioned query string for this entity
With acls from related entities + additional clauses from hook_civicrm_selectWhereClause
in CRM_Core_DAO at line 2544
static bool
requireSafeDBName($database)
ensure database name is 'safe', i.e. only contains word characters (includes underscores) and dashes, and contains at least one [a-z] case insenstive.
in CRM_Contribute_DAO_Contribution at line 846
static array
fieldKeys()
Return a mapping from field-name to the corresponding key (as used in fields()).
in CRM_Contribute_DAO_Contribution at line 865
boolean
getLog()
Returns if this table needs to be logged
in CRM_Contribute_DAO_Contribution at line 875
static array
import(bool $prefix = false)
Returns the list of fields that can be imported
in CRM_Contribute_DAO_Contribution at line 886
static array
export(bool $prefix = false)
Returns the list of fields that can be exported
in CRM_Contribute_DAO_Contribution at line 893
static
indices($localize = TRUE)
Returns the list of indices
at line 102
static CRM_Contribute_BAO_Contribution|void
add(array $params, array $ids = array())
Takes an associative array and creates a contribution object.
the function extract all the params it needs to initialize the create a contribution object. the params array could contain additional unused name/value pairs
at line 266
static bool
isUpdateToRecurringContribution(array $params)
Is this contribution updating an existing recurring contribution.
We need to upd the status of the linked recurring contribution if we have a new payment against it, or the initial pending payment is being confirmed (or failing).
at line 287
static array
getDefaults()
Get defaults for new entity.
at line 309
static CRM_Contribute_BAO_Contribution|null
getValues(array $params, array $values, array $ids)
Fetch the object and store the values in the values array.
at line 344
static array
getValuesWithMappings(array $params)
Get the values and resolve the most common mappings.
Since contribution status is resolved in almost every function that calls getValues it makes sense to have an extra function to resolve it rather than repeat the code.
Think carefully before adding more mappings to be resolved as there could be performance implications if this function starts to be called from more iterative functions.
at line 367
static
calculateMissingAmountParams(array $params, int|null $contributionID)
Calculate net_amount & fee_amount if they are not set.
Net amount should be total - fee. This should only be called for new contributions.
at line 402
static protected array
getBillingAddressParams($params, $billingLocationTypeID)
at line 442
static array
getPaymentProcessorReadyAddressParams(array $params, int $billingLocationTypeID)
Get address params ready to be passed to the payment processor.
We need address params in a couple of formats. For the payment processor we wan state_province_id-5. To create an address we need state_province_id.
at line 464
int
getNumTermsByContributionAndMembershipType(int $membershipTypeID, int $contributionID)
Get the number of terms for this contribution for a given membership type based on querying the line item table and relevant price field values Note that any one contribution should only be able to have one line item relating to a particular membership type
at line 485
static CRM_Contribute_BAO_Contribution
create(array $params, array $ids = array())
Takes an associative array and creates a contribution object.
at line 645
static
resolveDefaults(array $defaults, bool $reverse = FALSE)
Get the values for pseudoconstants for name->value and reverse.
at line 666
static bool
lookupValue(array $defaults, string $property, array $lookup, bool $reverse)
Convert associative array names to values and vice-versa.
This function is used by both the web form layer and the api. Note that the api needs the name => value conversion, also the view layer typically requires value => name conversion
at line 702
static CRM_Contribute_BAO_Contribution
retrieve(array $params, array $defaults, array $ids)
Retrieve DB object based on input parameters.
It also stores all the retrieved values in the default array.
at line 720
static array
importableFields(string $contactType = 'Individual', bool $status = TRUE)
Combine all the importable fields from the lower levels object.
The ordering is important, since currently we do not have a weight scheme. Adding weight is super important and should be done in the next week or so, before this can be called complete.
at line 786
static
getExportableFieldsWithPseudoConstants()
Get exportable fields with pseudoconstants rendered as an extra field.
at line 800
static array
exportableFields(bool $checkPermission = TRUE)
Combine all the exportable fields from the lower level objects.
at line 905
static array|null
getTotalAmountAndCount(null $status = NULL, null $startDate = NULL, null $endDate = NULL)
at line 971
static mixed|null
deleteContribution(int $id)
Delete the indirect records associated with this contribution first.
at line 1047
static
failPayment(int $contributionID, int $contactID, string $message)
React to a financial transaction (payment) failure.
Prior to CRM-16417 these were simply removed from the database but it has been agreed that seeing attempted payments is important for forensic and outreach reasons.
at line 1076
static bool
checkDuplicate(array $input, array $duplicates, int $id = NULL)
Check if there is a contribution with the same trxn_id or invoice_id.
at line 1128
static CRM_Contribute_DAO_ContributionProduct
addPremium(array $params)
Takes an associative array and creates a contribution_product object.
the function extract all the params it needs to initialize the create a contribution_product object. the params array could contain additional unused name/value pairs
at line 1145
static array
getContributionFields(bool $addExtraFields = TRUE)
Get list of contribution fields for profile.
For now we only allow custom contribution fields to be in profile
at line 1174
static
getSpecialContributionFields()
Add extra fields specific to contribution.
at line 1216
static array
getCurrentandGoalAmount(int $pageID)
at line 1253
static array
getHonorContacts(int $honorId)
Get list of contributions which credit the passed in contact ID.
The returned array provides details about the original contribution & donor.
at line 1290
static null|string
sortName(int $id)
Get the sort name of a contact for a particular contribution.
at line 1307
static array
annual(int $contactID)
at line 1401
static array
checkDuplicateIds(array $params)
Check if there is a contribution with the params passed in.
Used for trxn_id,invoice_id and contribution_id
at line 1433
static array
getContributionDetails(int $exportMode, string $componentIds)
Get the contribution details for component export.
at line 1500
static int
createAddress(array $params, int $billingLocationTypeID)
Create address associated with contribution record.
As long as there is one or more billing field in the parameters we will create the address.
(historically the decision to create or not was based on the payment 'type' but these lines are greyer than once thought).
at line 1516
static
deleteAddress(int $contributionId = NULL, int $contactId = NULL)
Delete billing address record related contribution.
at line 1562
static int
checkOnlinePendingContribution(int $componentId, string $componentName)
This function check online pending contribution associated w/ Online Event Registration or Online Membership signup.
at line 1629
static array
transitionComponents(array $params, bool $processContributionObject = FALSE)
deprecated
deprecated
Update contribution as well as related objects.
This function by-passes hooks - to address this - don't use this function.
at line 2066
static array
getComponentDetails($contributionId)
Returns all contribution related object ids.
at line 2129
static null|string
contributionCount(int $contactId, bool $includeSoftCredit = TRUE)
at line 2183
static protected array
repeatTransaction(CRM_Contribute_BAO_Contribution $contribution, array $input, array $contributionParams, int $paymentProcessorID)
Repeat a transaction as part of a recurring series.
Only call this via the api as it is being refactored. The intention is that the repeatTransaction function (possibly living on the ContributionRecur BAO) would be called first to create a pending contribution with a subsequent call to the contribution.completetransaction api.
The completeTransaction functionality has historically been overloaded to both complete and repeat payments.
at line 2249
static array
getOnbehalfIds(int $contributionId, int $contributorId = NULL)
Get individual id for onbehalf contribution.
at line 2316
static array
getContributionDates()
at line 2364
bool
loadRelatedObjects(array $input, array $ids, bool $loadAll = FALSE)
Load objects relations to contribution object.
Objects are stored in the $_relatedObjects property In the first instance we are just moving functionality from BASEIpn -
at line 2495
array
composeMessageArray(array $input, array $ids, array $values, bool $returnMessageText = TRUE)
Create array of message information - ie. return html version, txt version, to field
at line 2662
array
_gatherMessageValues(array $input, array $values, array $ids = array())
Gather values for contribution mail - this function has been created as part of CRM-9996 refactoring as a step towards simplifying the composeMessage function Values related to the contribution in question are gathered
at line 2871
mixed
_assignMessageVariablesToTemplate($values, $input, bool $returnMessageText = TRUE)
Assign message variables to template but try to break the habit.
In order to get away from leaky variables it is better to ensure variables are set in values and assign them from the send function. Otherwise smarty variables can leak if this is called more than once - e.g. processing multiple recurring payments for processors like IATS that use tokens.
Apply variables for message to smarty template - this function is part of analysing what is in the huge function & breaking it down into manageable chunks. Eventually it will be refactored into something else Note we send directly from this function in some cases because it is only partly refactored.
Don't call this function directly as the signature will change.
at line 3072
static bool
isCancelSubscriptionSupported(int $contributionId, bool $isNotCancelled = TRUE)
Check whether payment processor supports cancellation of contribution subscription
at line 3103
static string
isSubscriptionCancelled(int $contributionId)
Check whether subscription is already cancelled.
at line 3129
static null|object
recordFinancialAccounts(array $params, array $financialTrxnValues = NULL)
Create all financial accounts entry.
at line 3501
static
updateFinancialAccounts(array $params, string $context = NULL)
Update all financial accounts entry.
at line 3697
static bool
isContributionStatusNegative(int $status_id)
Is this contribution status a reversal.
If so we would expect to record a negative value in the financial_trxn table.
at line 3716
static bool
checkStatusValidation(array $values, array $fields, array $errors)
Check status validation on update of a contribution.
at line 3752
static
deleteContactContribution(int $contactId)
Delete contribution of contact.
CRM-12155
at line 3814
static array|bool
validateFinancialType(int $financialTypeId, string $relationName = 'Expense Account is')
Validate financial type.
CRM-13231
at line 3838
static null|object
recordAdditionalPayment(int $contributionId, array $trxnsData, string $paymentType = 'owed', int $participantId = NULL, bool $updateStatus = TRUE)
Function to record additional payment for partial and refund contributions.
at line 4013
static
addActivityForPayment($entityObj, $trxnObj, $activityType, $component, int $contributionId)
at line 4059
static mixed
getPaymentInfo(int $id, $component, bool $getTrxnInfo = FALSE, bool $usingLineTotal = FALSE)
Get list of payments displayed by Contribute_Page_PaymentInfo.
at line 4175
static int
getFinancialAccountId(int $financialTypeId)
Get financial account id has 'Sales Tax Account is' account relationship with financial type.
at line 4196
static array
checkTaxAmount(array $params, bool $isLineItem = FALSE)
Get the tax amount (misnamed function).
at line 4300
static bool
checkFinancialTypeChange(Integer $financialTypeId, Integer $contributionId, array $errors)
Check financial type validation on update of a contribution.
at line 4332
static
updateRelatedPledge(string $action, int $pledgePaymentID, int $contributionID, bool $adjustTotalAmount, float $total_amount, float $original_total_amount, int $contribution_status_id, int $original_contribution_status_id)
Update related pledge payment payments.
This function has been refactored out of the back office contribution form and may still overlap with other functions.
at line 4399
static array|null
computeStats(string $stat, string $sql, string $alias = NULL)
Compute the stats values
at line 4463
static bool
isSingleLineItem(int $id)
Is there only one line item attached to the contribution.
at line 4486
static array
completeOrder(array $input, array $ids, array $objects, CRM_Core_Transaction $transaction, int $recur, CRM_Contribute_BAO_Contribution $contribution)
Complete an order.
Do not call this directly - use the contribution.completetransaction api as this function is being refactored.
Currently overloaded to complete a transaction & repeat a transaction - fix!
Moving it out of the BaseIPN class is just the first step.
at line 4771
static array
sendMail(array $input, array $ids, int $contributionID, array $values, bool $returnMessageText = FALSE)
Send receipt from contribution.
Do not call this directly - it is being refactored. use contribution.sendmessage api call.
Note that the compose message part has been moved to contribution In general LoadObjects is called first to get the objects but the composeMessageArray function now calls it.
at line 4795
static
generateFromEmailAndName($input, $contribution)
Generate From email and from name in an array values
at line 4819
static string
createCreditNoteId()
Generate credit note id with next avaible number
at line 4852
loadRelatedMembershipObjects(array $ids)
Load related memberships.
Note that in theory it should be possible to retrieve these from the line_item table with the membership_payment table being deprecated. Attempting to do this here causes tests to fail as it seems the api is not correctly linking the line items when the contribution is created in the flow where the contribution is created in the API, followed by the membership (using the api) followed by the membership payment. The membership payment BAO does have code to address this but it doesn't appear to be working.
I don't know if it never worked or broke as a result of https://issues.civicrm.org/jira/browse/CRM-14918.
at line 4894
static object
recordPartialPayment(array $contribution, array $params)
This function is used to record partial payments for contribution
at line 4947
static protected array
getRecurringContributionDescription(CRM_Contribute_BAO_Contribution $contribution, CRM_Event_DAO_Event|null $event)
Get the description (source field) for the recurring contribution.
at line 4975
static
addPayments(array $contributions, array $contributionStatusId = NULL)
Function to add payments for contribution for Partially Paid status
at line 5013
static
assignProportionalLineItems(array $trxnParams, Integer $trxnId, float $contributionTotalAmount)
Function use to store line item proportionaly in in entity financial trxn table
at line 5035
static
checkLineItems(array $params)
Function to check line items.
at line 5062
static int
getFinancialAccountForStatusChangeTrxn(array $params, int $default)
Get the financial account for the item associated with the new transaction.
at line 5097
protected array
addContributionPageValuesToValuesHeavyHandedly(array $values)
ContributionPage values were being imposed onto values.
I have made this explicit and removed the couple (is_recur, is_pay_later) we REALLY didn't want superimposed. The rest are left there in their overkill out of cautiousness.
The rationale for making this explicit is that it was a case of carefully set values being seemingly randonly overwritten without much care. In general I think array randomly setting variables en mass is risky.
at line 5177
static string
checkContributeSettings(string $name = NULL)
Get values of CiviContribute Settings and check if its enabled or not.
Note: The CiviContribute settings are stored as single entry in civicrm_setting in serialized form. Usually this should be stored as flat settings for each form fields as per CiviCRM standards. Since this would take more effort to change the current behaviour of CiviContribute settings we will live with an inconsistency because it's too hard to change for now. https://github.com/civicrm/civicrm-core/pull/8562#issuecomment-227874245
at line 5197
static null|string
transitionComponentWithReturnMessage(int $contributionId, int $statusId, int|null $previousStatusId = NULL, string $receiveDate = NULL)
This function process contribution related objects.
at line 5321
static protected float
getFinancialItemAmountFromParams(array $params, string $context, array $lineItemDetails, bool $isARefund)
Get the amount for the financial item row.
Helper function to start to break down recordFinancialTransactions for readability.
The logic is more historical than .. logical. Paths other than the deprecated one are tested.
Codewise, several somewhat disimmilar things have been squished into recordFinancialAccounts for historical reasons. Going forwards we can hope to add tests & improve readibility of that function
at line 5361
static protected int
getMultiplier(int $contribution_status_id, string $context)
Get the multiplier for adjusting rows.
If we are dealing with a refund or cancellation then it will be a negative amount to reflect the negative transaction.
If we are changing Financial Type it will be a negative amount to adjust down the old type.
at line 5401
static bool
allowUpdateRevenueRecognitionDate(int $contributionId)
Check if contribution has participant/membership payment.
at line 5431
static string
recordAlwaysAccountsReceivable(array $trxnParams, string $contributionParams)
Create Accounts Receivable financial trxn entry for Completed Contribution.
at line 5470
static float
calculateFinancialItemAmount(array $params, array $amountParams, string $context)
Calculate financial item amount when contribution is updated.
at line 5497
static array
getSalesTaxFinancialAccounts()
Retrieve Sales Tax Financial Accounts.
at line 5519
static
createProportionalEntry(array $entityParams, array $eftParams)
Create tax entry in civicrm_entity_financial_trxn table.
at line 5533
static array
getLastFinancialItemIds(int $contributionId)
Create array of last financial item id's.
at line 5568
static
createProportionalFinancialEntries(array $entityParams, array $lineItems, array $ftIds, array $taxItems)
Create proportional entries in civicrm_entity_financial_trxn.
at line 5595
protected
loadRelatedEntitiesByID(array $ids)
Load entities related to the contribution into $this->_relatedObjects.
at line 5621
protected mixed
isEmailReceipt(array $input)
Should an email receipt be sent for this contribution when complete.
at line 5650
static array
replaceContributionTokens(array $contributionIds, string $subject, array $subjectToken, string $text, string $html, array $messageToken, bool $escapeSmarty)
Function to replace contribution tokens.