// Update contribution.
if (!empty($params['id'])) {
+
+ $id = $params['id'];
+ $values = $ids = array();
+ $contrbutionParams = array('id' => $id);
+ $prevContributionValue = CRM_Contribute_BAO_Contribution::getValues($contrbutionParams, $values, $ids);
+
// CRM-19126 and CRM-19152, civicrm_line_item.tax_amount incorrectly set when using online payment processor.
// It looks like this method is meant to be called in multiple contexts: new & update
// When creating, would expect total_amount to be set? Prior to 4.7, when creating online membership
// Conceptually, if we're "updating", and total_amount is unknown. We're dealing with an incomplete
// view, why are we nulling out all line item taxes, or messing with any other tax amounts?
if (!isset($params['total_amount'])) {
- return $params;
+ if (!empty($prevContributionValue->tax_amount)) {
+ $params['total_amount'] = $prevContributionValue->total_amount - $prevContributionValue->tax_amount;
+ if (isset($params['fee_amount'])) {
+ $params['net_amount'] = $params['total_amount'] - $params['fee_amount'];
+ }
+ else {
+ $params['net_amount'] = $params['total_amount'] - $prevContributionValue->fee_amount;
+ $params['fee_amount'] = $prevContributionValue->fee_amount;
+ }
+ }
+ else {
+ if (isset($params['fee_amount'])) {
+ $params['net_amount'] = $prevContributionValue->total_amount - $params['fee_amount'];
+ $params['total_amount'] = $prevContributionValue->total_amount;
+ }
+ else {
+ $params['total_amount'] = $prevContributionValue->total_amount;
+ $params['fee_amount'] = $prevContributionValue->fee_amount;
+ }
+ }
}
-
- $id = $params['id'];
- $values = $ids = array();
- $contrbutionParams = array('id' => $id);
- $prevContributionValue = CRM_Contribute_BAO_Contribution::getValues($contrbutionParams, $values, $ids);
-
// To assign pervious finantial type on update of contribution
if (!isset($params['financial_type_id'])) {
$params['financial_type_id'] = $prevContributionValue->financial_type_id;
$this->callAPISuccess('contribution', 'completetransaction', array(
'id' => $contribution['id'],
'trxn_id' => '777788888',
+ 'fee_amount' => '6.00',
));
- $contribution2 = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'return' => 'tax_amount', 'sequential' => 1));
+ $contribution2 = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'return' => array('tax_amount', 'fee_amount', 'net_amount'), 'sequential' => 1));
$this->assertEquals($contribution1['values'][0]['tax_amount'], $contribution2['values'][0]['tax_amount']);
+ $this->assertEquals('6.00', $contribution2['values'][0]['fee_amount']);
+ $this->assertEquals('94.00', $contribution2['values'][0]['net_amount']);
}
/**