<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
*
* @param object $lineItem line item object
* @param object $contribution contribution object
+ * @param boolean $taxTrxnID
*
* @access public
* @static
* @return void
*/
- static function add($lineItem, $contribution) {
+ static function add($lineItem, $contribution, $taxTrxnID = FALSE) {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
$itemStatus = NULL;
'status_id' => $itemStatus,
);
+ 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'] = $taxTerm;
+ $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
+ }
+ else {
+ $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
+ }
if ($lineItem->financial_type_id) {
$searchParams = array(
'entity_table' => 'civicrm_financial_type',
'entity_id' => $lineItem->financial_type_id,
- 'account_relationship' => 1,
+ 'account_relationship' => $accountRel,
);
$result = array();
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'];
+
return self::create($params, NULL, $trxnId);
}
/**
* retrive entity financial trxn details
*
- * @param array $params (reference ) an assoc array of name/value pairs
+ * @param array $params (reference ) an assoc array of name/value pairs
+ *
+ * @param bool $maxId
*
- * @param boolean $maxID to retrive max id
+ * @internal param bool $maxID to retrive max id
*
* @return array
* @access public