public function tearDown() {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(array('civicrm_uf_match'));
+ $financialAccounts = $this->callAPISuccess('FinancialAccount', 'get', array());
+ foreach ($financialAccounts['values'] as $financialAccount) {
+ if ($financialAccount['name'] == 'Test Tax financial account ' || $financialAccount['name'] == 'Test taxable financial Type') {
+ $entityFinancialTypes = $this->callAPISuccess('EntityFinancialAccount', 'get', array(
+ 'financial_account_id' => $financialAccount['id'],
+ ));
+ foreach ($entityFinancialTypes['values'] as $entityFinancialType) {
+ $this->callAPISuccess('EntityFinancialAccount', 'delete', array('id' => $entityFinancialType['id']));
+ }
+ $this->callAPISuccess('FinancialAccount', 'delete', array('id' => $financialAccount['id']));
+ }
+ }
}
/**
}
/**
- * CRM-19126 Add test to verify when complete transaction is called tax amount is not changed
+ * CRM-19126 Add test to verify when complete transaction is called tax amount is not changed.
+ *
+ * @param string $thousandSeparator
+ * punctuation used to refer to thousands.
+ *
+ * @dataProvider getThousandSeparators
*/
- public function testCheckTaxAmount() {
+ public function testCheckTaxAmount($thousandSeparator) {
+ $this->setCurrencySeparators($thousandSeparator);
$contact = $this->createLoggedInUser();
$financialType = $this->callAPISuccess('financial_type', 'create', array(
'name' => 'Test taxable financial Type',
));
}
+ /**
+ * CRM-20685 Repeattransaction produces incorrect Financial Type ID (in specific circumstance) - if number of lineItems = 1.
+ *
+ * This case happens when the line item & contribution do not have the same type in his initiating transaction.
+ */
+ public function testRepeatTransactionUpdatedFinancialTypeAndNotEquals() {
+ $originalContribution = $this->setUpRecurringContribution(array(), array('financial_type_id' => 2));
+ // This will made the trick to get the not equals behaviour.
+ $this->callAPISuccess('line_item', 'create', array('id' => 1, 'financial_type_id' => 4));
+ $this->callAPISuccess('contribution', 'repeattransaction', array(
+ 'contribution_recur_id' => $originalContribution['id'],
+ 'contribution_status_id' => 'Completed',
+ 'trxn_id' => uniqid(),
+ ));
+ $lineItemParams = array(
+ 'entity_id' => $originalContribution['id'],
+ 'sequential' => 1,
+ 'return' => array(
+ 'entity_table',
+ 'qty',
+ 'unit_price',
+ 'line_total',
+ 'label',
+ 'financial_type_id',
+ 'deductible_amount',
+ 'price_field_value_id',
+ 'price_field_id',
+ ),
+ );
+ $this->callAPISuccessGetSingle('contribution', array(
+ 'total_amount' => 100,
+ 'financial_type_id' => 2,
+ ));
+ $lineItem1 = $this->callAPISuccess('line_item', 'get', array_merge($lineItemParams, array(
+ 'entity_id' => $originalContribution['id'],
+ )));
+ $expectedLineItem = array_merge(
+ $lineItem1['values'][0], array(
+ 'line_total' => '100.00',
+ 'unit_price' => '100.00',
+ 'financial_type_id' => 4,
+ 'contribution_type_id' => 4,
+ )
+ );
+
+ $lineItem2 = $this->callAPISuccess('line_item', 'get', array_merge($lineItemParams, array(
+ 'entity_id' => $originalContribution['id'] + 1,
+ )));
+ $this->callAPISuccess('line_item', 'create', array('id' => 1, 'financial_type_id' => 1));
+ unset($expectedLineItem['id'], $expectedLineItem['entity_id']);
+ unset($lineItem2['values'][0]['id'], $lineItem2['values'][0]['entity_id']);
+ $this->assertEquals($expectedLineItem, $lineItem2['values'][0]);
+ }
+
+
/**
* Test completing a transaction does not 'mess' with net amount (CRM-15960).
*/
'net_amount' => 20,
'fee_amount' => 0,
'financial_type_id' => 1,
- 'receive_date' => '04/21/2015',
- 'receive_date_time' => '11:27PM',
'contact_id' => $this->_individualId,
'contribution_status_id' => 1,
'billing_middle_name' => '',