DB Error:: Already exists during renewing membership automatically
I have a cron job that runs smart debit sync every day for recurring contribution and its failing with DB Error: already exists
After looking it carefully in details found that it fails when the original contribution of recurring has tax_amount set.
Mar 18 10:53:06 [info] $Fatal Error Details = Array ( [callback] => Array ( [0] => CRM_Core_Error [1] => exceptionHandler )
[code] => -5
[message] => DB Error: already exists
[mode] => 16
[debug_info] => INSERT INTO civicrm_line_item (entity_table , entity_id , contribution_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id , tax_amount ) VALUES ('civicrm_contribution' , 20069 , 20069 , 1 , 'Contribution Amount' , 1 , 30.00 , 30.00 , 1 , 33 , 6 ) [nativecode=1062 ** Duplicate entry 'civicrm_contribution-20069-20069-1-1' for key 'UI_line_item_value']
[type] => DB_Error
[user_info] => INSERT INTO civicrm_line_item (entity_table , entity_id , contribution_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id , tax_amount ) VALUES ('civicrm_contribution' , 20069 , 20069 , 1 , 'Contribution Amount' , 1 , 30.00 , 30.00 , 1 , 33 , 6 ) [nativecode=1062 ** Duplicate entry 'civicrm_contribution-20069-20069-1-1' for key 'UI_line_item_value']
[to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="INSERT INTO civicrm_line_item (entity_table , entity_id , contribution_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id , tax_amount ) VALUES ('civicrm_contribution' , 20069 , 20069 , 1 , 'Contribution Amount' , 1 , 30.00 , 30.00 , 1 , 33 , 6 ) [nativecode=1062 ** Duplicate entry 'civicrm_contribution-20069-20069-1-1' for key 'UI_line_item_value']"]
)