Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-12983

Contributions created via the API are unbalanced

    Details

    • Documentation Required?:
      None

      Description

      After using the Contribution Create API ( with skipLineItem = 1 ) and the LineItem create API to create a new contribution, I end up with an unbalanced transaction listed in the Bookkeeping Transaction report. (Financial Account Debit is listed as "Payment Processor Account" but Financial Account Credit is empty.)

      I also noticed that there is no records for this contribution in the table "civicrm_financial_item"

      The PHP code that I used to call the API is below:
      $source_tmp = 'test of API payment';
      $skipLineItem_parm = "1";
      $new_contrib_params = array( 'version' => 3,
      'sequential' => 1,
      'financial_type_id' => 10,
      'contact_id' => 12724,
      'skipLineItem' => $skipLineItem_parm,
      'payment_instrument_id' => 1,
      'total_amount' => 53.00 ,
      'trxn_id' => '' ,
      'contribution_recur_id' => '' ,
      'currency' => 'USD' ,
      'contribution_campaign_id' => '1',
      'source' => $source_tmp ,
      'contribution_status_id' => 1,
      'receive_date' => '20130616' ) ;

      //$new_contrib_params['total_amount'] = $gateway_amount;
      $new_contrib_result = civicrm_api('Contribution', 'create', $new_contrib_params ) ;
      if($new_contrib_result['is_error'] <> 0 )

      { print "<br>Error calling Contribution Create API: <br>"; print_r( $new_contrib_result); }

      else{
      print "<br>Created test contribution via API<br>";
      print_r($new_contrib_result);

      $new_contrib_id = $new_contrib_result['id'];

      // create line items:
      $params = array(
      'version' => 3,
      'sequential' => 1,
      'entity_table' => 'civicrm_contribution',
      'entity_id' => $new_contrib_id ,
      //'price_field_id' => $original_line_item['price_field_id'],
      //'label' => $original_line_item['label'],
      'qty' => "53",
      'unit_price' => "1",
      'line_total' => "53",
      'financial_type_id' => '10',

      );

      //print "<br><br>New line item:<br> ";
      //print_r( $params ) ;
      $li_result = civicrm_api('LineItem', 'create', $params);
      if($li_result['is_error'] <> 0 )

      { print "<br>Error calling Line Item API: <br>"; print_r( $li_result); }

      else

      { print "<br>Called line item API: <br>"; // print_r( $li_result); }

      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                sgladstone Sarah Gladstone
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: