<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem {
/**
- * class constructor
+ * Class constructor
*/
function __construct( ) {
parent::__construct( );
}
/**
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. Typically the valid params are only
- * contact_id. We'll tweak this function to be more full featured over a period
- * of time. This is the inverse function of create. It also stores all the retrieved
- * values in the default array
+ * Fetch object based on array of properties
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $defaults (reference ) an assoc array to hold the flattened values
*
- * @return object CRM_Contribute_BAO_FinancialItem object
+ * @return CRM_Contribute_BAO_FinancialItem object
* @access public
* @static
*/
}
/**
- * function to add the financial items and financial trxn
+ * Add the financial items and financial trxn
*
* @param object $lineItem line item object
* @param object $contribution contribution object
);
if ($taxTrxnID) {
+ $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
+ $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$params['amount'] = $lineItem->tax_amount;
- $params['description'] = 'VAT';
+ $params['description'] = $taxTerm;
$accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
}
else {
}
/**
- * function to create the financial Items and financial enity trxn
+ * Create the financial Items and financial enity trxn
*
* @param array $params associated array to create financial items
* @param array $ids financial item ids
*/
static function create(&$params, $ids = NULL, $trxnIds = NULL) {
$financialItem = new CRM_Financial_DAO_FinancialItem();
+
+ if (!empty($ids['id'])) {
+ CRM_Utils_Hook::pre('edit', 'FinancialItem', $ids['id'], $params);
+ }
+ else {
+ CRM_Utils_Hook::pre('create', 'FinancialItem', NULL, $params);
+ }
+
$financialItem->copyValues($params);
if (!empty($ids['id'])) {
$financialItem->id = $ids['id'];
}
$entity_trxn->save();
}
+ if (!empty($ids['id'])) {
+ CRM_Utils_Hook::post('edit', 'FinancialItem', $financialItem->id, $financialItem);
+ }
+ else {
+ CRM_Utils_Hook::post('create', 'FinancialItem', $financialItem->id, $financialItem);
+ }
return $financialItem;
}
/**
- * takes an associative array and creates a entity financial transaction object
+ * Takes an associative array and creates a entity financial transaction object
*
* @param array $params (reference ) an assoc array of name/value pairs
*
- * @return object CRM_Core_BAO_FinancialTrxn object
+ * @return CRM_Core_BAO_FinancialTrxn object
* @access public
* @static
*/
}
/**
- * retrive entity financial trxn details
+ * Retrive entity financial trxn details
*
* @param array $params (reference ) an assoc array of name/value pairs
- *
- * @param bool $maxId
- *
- * @internal param bool $maxID to retrive max id
+ * @param bool $maxId to retrive max id
*
* @return array
* @access public
}
/**
- * check if contact is present in financial_item table
+ * Check if contact is present in financial_item table
*
* CRM-12929
*