Details
-
Type: Bug
-
Status: Open
-
Priority: Trivial
-
Resolution: Unresolved
-
Affects Version/s: 4.7.28, 4.7.31
-
Fix Version/s: None
-
Component/s: CiviContribute, CiviCRM API
-
Labels:None
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Needs Funding
-
Verified?:No
Description
Calling Order API with a taxable financial_type_id on the contribution and the line_items create 2 line_items.
To reproduce :
- have financial_type_id 1 (donation) without tax
- add tax on financial_type_id 4 (event registration)
- call the following API - this works because financial_type_id = 1 (but the total_amount doesn't have any taxes)
$li1 = array( 'entity_table' => 'civicrm_participant', 'entity_id' => 23, 'price_field_id' => 5, 'label' => 'aaa', 'qty' => '1.00', 'unit_price' => '20.00', 'line_total' => '20.00', 'participant_count' => 1, 'price_field_value_id' => 5, 'financial_type_id' => 4, 'contribution_type_id' => 4, ); $params = array( 'contact_id' => '3', 'currency' => 'CAD', 'receive_date' => '2017-11-20 14:45:00', 'financial_type_id' => 1, 'contribution_source' => 'TEST', 'is_test' => '0', 'is_pay_later' => '1', 'contribution_status_id' => '2', 'payment_instrument_id' => '4', 'instrument_id' => '4', 'total_amount' => $total_amount, 'line_items' => array( array( 'line_item' => $line_items, ) ), }
returns :
mysql> select * from civicrm_line_item where contribution_id = 31; +----+---------------------+-----------+-----------------+----------------+-------+------+------------+------------+-------------------+----------------------+-------------------+-----------------------+------------+ | id | entity_table | entity_id | contribution_id | price_field_id | label | qty | unit_price | line_total | participant_count | price_field_value_id | financial_type_id | non_deductible_amount | tax_amount | +----+---------------------+-----------+-----------------+----------------+-------+------+------------+------------+-------------------+----------------------+-------------------+-----------------------+------------+ | 34 | civicrm_participant | 23 | 31 | 5 | aaa | 1.00 | 20.00 | 20.00 | 1 | 5 | 4 | 0.00 | NULL | +----+---------------------+-----------+-----------------+----------------+-------+------+------------+------------+-------------------+----------------------+-------------------+-----------------------+------------+ mysql> select total_amount, tax_amount from civicrm_contribution where id = 31; +--------------+------------+ | total_amount | tax_amount | +--------------+------------+ | 20.00 | NULL | +--------------+------------+ 1 row in set (0.00 sec)
- call the same api with financial_type_id = 4 (taxable) - it will add an extra line_item for the contribution that is the same amount as the line_item (sort of duplicate)
$params = array( 'contact_id' => '3', 'currency' => 'CAD', 'receive_date' => '2017-11-20 14:45:00', 'financial_type_id' => 4, 'contribution_source' => 'TEST', 'is_test' => '0', 'is_pay_later' => '1', 'contribution_status_id' => '2', 'payment_instrument_id' => '4', 'instrument_id' => '4', 'total_amount' => $total_amount, 'line_items' => array( array( 'line_item' => $line_items, ) ), }
returns :
mysql> select * from civicrm_line_item where contribution_id = 30; +----+----------------------+-----------+-----------------+----------------+---------------------+------+------------+------------+-------------------+----------------------+-------------------+-----------------------+------------+ | id | entity_table | entity_id | contribution_id | price_field_id | label | qty | unit_price | line_total | participant_count | price_field_value_id | financial_type_id | non_deductible_amount | tax_amount | +----+----------------------+-----------+-----------------+----------------+---------------------+------+------------+------------+-------------------+----------------------+-------------------+-----------------------+------------+ | 32 | civicrm_participant | 23 | 30 | 5 | aaa | 1.00 | 20.00 | 20.00 | 1 | 5 | 4 | 0.00 | 3.00 | | 33 | civicrm_contribution | 30 | 30 | 1 | Contribution Amount | 1.00 | 20.00 | 20.00 | NULL | 1 | 4 | 0.00 | 3.00 | +----+----------------------+-----------+-----------------+----------------+---------------------+------+------------+------------+-------------------+----------------------+-------------------+-----------------------+------------+ 2 rows in set (0.01 sec) mysql> select total_amount, tax_amount from civicrm_contribution where id = 30; +--------------+------------+ | total_amount | tax_amount | +--------------+------------+ | 26.00 | 6.00 | +--------------+------------+ 1 row in set (0.00 sec)