if ($line['entity_table'] == 'civicrm_contribution') {
$line['entity_id'] = $contributionDetails->id;
}
+ // CRM-19094: entity_table is set to civicrm_membership then ensure
+ // the entityId is set to membership ID not contribution by default
+ elseif (!empty($line['entity_id']) && $line['entity_id'] == $contributionDetails->id) {
+ $membershipId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', 'contribution_id', $line['entity_id'], 'membership_id');
+ $line['entity_id'] = $membershipId ? $membershipId : $line['entity_id'];
+ }
}
// if financial type is not set and if price field value is NOT NULL