<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2015
*/
class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem {
/**
- * Class constructor
+ * Class constructor.
*/
public function __construct() {
parent::__construct();
}
/**
- * Fetch object based on array of properties
+ * Fetch object based on array of properties.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
}
/**
- * Add the financial items and financial trxn
+ * Add the financial items and financial trxn.
*
* @param object $lineItem
* Line item object.
* Contribution object.
* @param bool $taxTrxnID
*
- * @return void
+ * @param int $trxnId
+ *
+ * @return CRM_Financial_DAO_FinancialItem
*/
- public static function add($lineItem, $contribution, $taxTrxnID = FALSE) {
+ public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId = NULL) {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
$itemStatus = NULL;
CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
$params['financial_account_id'] = CRM_Utils_Array::value('financial_account_id', $result);
}
- $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE);
- $trxnId['id'] = $trxn['financialTrxnId'];
+ if (empty($trxnId)) {
+ $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE);
+ $trxnId['id'] = $trxn['financialTrxnId'];
+ }
return self::create($params, NULL, $trxnId);
}
/**
- * Create the financial Items and financial enity trxn
+ * Create the financial Items and financial entity trxn.
*
* @param array $params
* Associated array to create financial items.
* @param array $trxnIds
* Financial item ids.
*
- * @return object
+ * @return CRM_Financial_DAO_FinancialItem
*/
public static function create(&$params, $ids = NULL, $trxnIds = NULL) {
$financialItem = new CRM_Financial_DAO_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.
}
/**
- * Retrive entity financial trxn details
+ * Retrive entity financial trxn details.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
public static function retrieveEntityFinancialTrxn($params, $maxId = FALSE) {
$financialItem = new CRM_Financial_DAO_EntityFinancialTrxn();
$financialItem->copyValues($params);
- //retrieve last entry from civicrm_entity_financial_trxn
+ // retrieve last entry from civicrm_entity_financial_trxn
if ($maxId) {
$financialItem->orderBy('id DESC');
$financialItem->limit(1);
}
/**
- * Check if contact is present in financial_item table
+ * Check if contact is present in financial_item table.
*
* CRM-12929
*