Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-8033 CiviAccounts Data Schema
  3. CRM-9083

Fully integrate financial_trxn, entity_financial_trxn tables

    Details

    • Type: Sub-task
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.0
    • Component/s: Accounting Integration
    • Labels:
      None

      Description

      Currently, manually recorded contributions do not result in entries in the civicrm_financial_trxn and civicrm_entity_financial_trxn tables; they are only created for payments made via online contributions. This issue fixes that. Also, it updates the schema for civicrm_financial_trxn table to reflect changes for CiviAccounts.

      Modify xml/schema/Financial/FinancialTrxn.xml as follows:
      Rename from_account_id to from_financial_account_id by following the model of <change> <changedName> used elsewhere, eg to_financial_account_id. Search for any code that refers to this field and modify appropriately to new name.
      Remove trxn_type.
      Add payment_processor_id field.
      Fill in the payment_processor_id based on a lookup using the payment_processor field (ie create upgrade script that translates payment_processor to payment_processor_id using civicrm_financial_trxn.payment_processor=civicrm_payment_processor.name and add it to CRM/Upgrade/Incremental/sql/4.2.alpha1.mysql.tpl)
      Then remove payment_processor field.

      Add an ALTER statement to rename from_account_id to from_financial_account_id.

      When contributions are manually added or edited through the browser, specifically when a civicrm_contribution record is (added or (edited AND there is no civicrm_entity_financial_trxn pointing to the civicrm_contribution record))), change the code so that rows are inserted in civicrm_financial_trxn and civicrm_entity_financial_trxn tables as follows:

      Add a new field to the form(s) (civicrm/contribute/add?reset=1&action=add&context=standalone or civicrm/contact/view/contribution?reset=1&action=add&context=contribution&cid=103) as follows:

      • under Received and above Paid By
      • label: Received Into
      • select box containing all civicrm_financial_account items with financial_account_type_id of Asset
      • store in civicrm_financial_trxn.to_financial_account_id
      • field is required

      civicrm_financial_trxn : take values from the form except:
      payment_processor - null
      trxn_result_code - null

      civicrm_entity_financial_trxn:
      entity_table='civicrm_contribution'
      entity_id=civicrm_contribution.id
      financial_trxn_id=civicrm_financial_trxn.id
      amount=civicrm_financial_trxn.total_amount

      Create tests/phpunit/WebTest/Contribute/OfflineContributionTest.php and tests/phpunit/WebTest/Contribute/StandaloneContributionTest.php..

        Attachments

          Activity

            People

            • Assignee:
              pradeep.nayak Pradeep Nayak
              Reporter:
              joemurray Joe Murray
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: