Skip to content

Commit

Permalink
Merge pull request #1 from Edzelopez/apiv4
Browse files Browse the repository at this point in the history
MISC-32 Added support for contribution_id to lineitem table
  • Loading branch information
Edzelopez committed Feb 6, 2014
2 parents 760a98f + 26bcaa5 commit 75d230a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CRM/Price/BAO/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL
$selectClause = "
SELECT li.id,
li.label,
li.contribution_id,
li.qty,
li.unit_price,
li.line_total,
Expand Down Expand Up @@ -169,6 +170,7 @@ static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL
'html_type' => $dao->html_type,
'description' => $dao->description,
'entity_id' => $entityId,
'contribution_id' => $dao->contribution_id,
'financial_type_id' => $dao->financial_type_id,
'membership_type_id' => $dao->membership_type_id,
'membership_num_terms' => $dao->membership_num_terms,
Expand Down Expand Up @@ -296,6 +298,12 @@ static function processPriceSet($entityId, $lineItem, $contributionDetails = NUL
foreach ($values as $line) {
$line['entity_table'] = $entityTable;
$line['entity_id'] = $entityId;
if ($entityTable == 'civicrm_contribution') {
$line['contribution_id'] = $entityId;
}
else {
$line['contribution_id'] = $contributionDetails->id;
}
// if financial type is not set and if price field value is NOT NULL
// get financial type id of price field value
if (!empty($line['price_field_value_id']) && empty($line['financial_type_id'])) {
Expand Down
8 changes: 8 additions & 0 deletions CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,11 @@ VALUES
-- CRM-13970
UPDATE civicrm_navigation set url = 'civicrm/admin/options/from_email_address&reset=1' WHERE url LIKE 'civicrm/admin/options/from_email%';
UPDATE civicrm_navigation set url = CONCAT(SUBSTRING_INDEX(url, '&', 1), '&reset=1') WHERE url LIKE 'civicrm/admin/options/%';

-- Add contribution_id to civicrm_line_item

ALTER TABLE civicrm_line_item ADD contribution_id INT(10) NULL AFTER entity_id;

ALTER TABLE civicrm_line_item
ADD CONSTRAINT `FK_civicrm_contribution_id` FOREIGN KEY (`contribution_id`) REFERENCES civicrm_contribution (`id`) ON DELETE SET NULL;

12 changes: 12 additions & 0 deletions xml/schema/Price/LineItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
<typeColumn>entity_table</typeColumn>
<add>1.7</add>
</dynamicForeignKey>
<field>
<name>contribution_id</name>
<type>int unsigned</type>
<comment>FK to civicrm_contribution</comment>
<add>4.5</add>
</field>
<foreignKey>
<name>contribution_id</name>
<table>civicrm_contribution</table>
<key>id</key>
<onDelete>SET NULL</onDelete>
</foreignKey>
<field>
<name>price_field_id</name>
<type>int unsigned</type>
Expand Down

0 comments on commit 75d230a

Please sign in to comment.