<?xml version="1.0" encoding="iso-8859-1" ?>

<table>
  <base>CRM/Contribute</base>
  <class>Contribution</class>
  <name>civicrm_contribution</name>
  <description>Financial records consisting of transactions, line-items, etc.</description>
  <add>1.3</add>
  <log>true</log>
  <icon>fa-credit-card</icon>
  <component>CiviContribute</component>
  <paths>
    <add>civicrm/contribute/add?reset=1&amp;action=add&amp;context=standalone</add>
    <view>civicrm/contact/view/contribution?reset=1&amp;action=view&amp;id=[id]</view>
    <update>civicrm/contact/view/contribution?reset=1&amp;action=update&amp;id=[id]</update>
    <delete>civicrm/contact/view/contribution?reset=1&amp;action=delete&amp;id=[id]</delete>
  </paths>
  <field>
    <name>id</name>
    <uniqueName>contribution_id</uniqueName>
    <type>int unsigned</type>
    <required>true</required>
    <import>true</import>
    <title>Contribution ID</title>
    <comment>Contribution ID</comment>
    <html>
      <type>Number</type>
    </html>
    <add>1.3</add>
  </field>
  <primaryKey>
    <name>id</name>
    <autoincrement>true</autoincrement>
  </primaryKey>
  <field>
    <name>contact_id</name>
    <uniqueName>contribution_contact_id</uniqueName>
    <title>Contact ID</title>
    <type>int unsigned</type>
    <required>true</required>
    <import>true</import>
    <headerPattern>/contact(.?id)?/i</headerPattern>
    <dataPattern>/^\d+$/</dataPattern>
    <comment>FK to Contact ID</comment>
    <html>
      <type>EntityRef</type>
      <label>Contact</label>
    </html>
    <add>1.3</add>
  </field>
  <foreignKey>
    <name>contact_id</name>
    <table>civicrm_contact</table>
    <key>id</key>
    <add>1.3</add>
    <onDelete>CASCADE</onDelete>
  </foreignKey>
  <field>
    <name>financial_type_id</name>
    <title>Financial Type ID</title>
    <type>int unsigned</type>
    <comment>FK to Financial Type for (total_amount - non_deductible_amount).</comment>
    <pseudoconstant>
      <table>civicrm_financial_type</table>
      <keyColumn>id</keyColumn>
      <labelColumn>name</labelColumn>
    </pseudoconstant>
    <export>true</export>
    <import>true</import>
    <html>
      <type>Select</type>
      <label>Financial Type</label>
    </html>
    <add>4.3</add>
  </field>
  <foreignKey>
    <name>financial_type_id</name>
    <table>civicrm_financial_type</table>
    <key>id</key>
    <add>4.3</add>
  </foreignKey>
  <field>
    <name>contribution_page_id</name>
    <title>Contribution Page ID</title>
    <type>int unsigned</type>
    <import>true</import>
    <comment>The Contribution Page which triggered this contribution</comment>
    <pseudoconstant>
      <table>civicrm_contribution_page</table>
      <keyColumn>id</keyColumn>
      <nameColumn>name</nameColumn>
      <labelColumn>title</labelColumn>
    </pseudoconstant>
    <html>
      <type>Select</type>
      <label>Contribution Page</label>
    </html>
    <add>1.5</add>
  </field>
  <foreignKey>
    <name>contribution_page_id</name>
    <table>civicrm_contribution_page</table>
    <key>id</key>
    <onDelete>SET NULL</onDelete>
  </foreignKey>
  <field>
    <name>payment_instrument_id</name>
    <uniqueName>payment_instrument_id</uniqueName>
    <title>Payment Method ID</title>
    <type>int unsigned</type>
    <comment>FK to Payment Instrument</comment>
    <export>true</export>
    <import>true</import>
    <headerPattern>/^payment|(p(ayment\s)?instrument)$/i</headerPattern>
    <pseudoconstant>
      <optionGroupName>payment_instrument</optionGroupName>
    </pseudoconstant>
    <html>
      <type>Select</type>
      <label>Payment Method</label>
    </html>
    <add>1.3</add>
  </field>
  <index>
    <name>UI_contrib_payment_instrument_id</name>
    <fieldName>payment_instrument_id</fieldName>
    <add>1.6</add>
  </index>
  <field>
    <name>receive_date</name>
    <title>Contribution Date</title>
    <type>datetime</type>
    <import>true</import>
    <headerPattern>/receive(.?date)?/i</headerPattern>
    <dataPattern>/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/</dataPattern>
    <add>1.3</add>
    <html>
     <type>Select Date</type>
     <formatType>activityDateTime</formatType>
   </html>
  </field>
  <field>
    <name>non_deductible_amount</name>
    <title>Non-deductible Amount</title>
    <type>decimal</type>
    <default>0</default>
    <import>true</import>
    <headerPattern>/non?.?deduct/i</headerPattern>
    <dataPattern>/^\d+(\.\d{2})?$/</dataPattern>
    <comment>Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.</comment>
    <add>1.3</add>
    <html>
     <type>Text</type>
   </html>
  </field>
  <field>
    <name>total_amount</name>
    <type>decimal</type>
    <required>true</required>
    <import>true</import>
    <headerPattern>/^total|(.?^am(ou)?nt)/i</headerPattern>
    <dataPattern>/^\d+(\.\d{2})?$/</dataPattern>
    <comment>Total amount of this contribution. Use market value for non-monetary gifts.</comment>
    <add>1.3</add>
    <html>
      <type>Text</type>
      <label>Total Amount</label>
    </html>
  </field>
  <index>
    <name>index_total_amount_receive_date</name>
    <fieldName>total_amount</fieldName>
    <fieldName>receive_date</fieldName>
    <add>4.7</add>
  </index>
  <field>
    <name>fee_amount</name>
    <type>decimal</type>
    <import>true</import>
    <headerPattern>/fee(.?am(ou)?nt)?/i</headerPattern>
    <dataPattern>/^\d+(\.\d{2})?$/</dataPattern>
    <comment>actual processor fee if known - may be 0.</comment>
    <add>1.3</add>
    <html>
      <type>Text</type>
      <label>Fee Amount</label>
    </html>
  </field>
  <field>
    <name>net_amount</name>
    <type>decimal</type>
    <import>true</import>
    <headerPattern>/net(.?am(ou)?nt)?/i</headerPattern>
    <dataPattern>/^\d+(\.\d{2})?$/</dataPattern>
    <comment>actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.</comment>
    <add>1.3</add>
    <html>
      <type>Text</type>
      <label>Net Amount</label>
    </html>
  </field>
  <field>
    <name>trxn_id</name>
    <title>Transaction ID</title>
    <type>varchar</type>
    <length>255</length>
    <import>true</import>
    <headerPattern>/tr(ansactio|x)n(.?id)?/i</headerPattern>
    <comment>unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method</comment>
    <readonly>true</readonly>
    <html>
     <type>Text</type>
   </html>
    <add>1.3</add>
  </field>
  <field>
    <name>invoice_id</name>
    <title>Invoice Reference</title>
    <type>varchar</type>
    <length>255</length>
    <import>true</import>
    <headerPattern>/invoice(.?id)?/i</headerPattern>
    <comment>unique invoice id, system generated or passed in</comment>
    <readonly>true</readonly>
    <html>
      <type>Text</type>
    </html>
    <add>1.3</add>
  </field>
  <field>
    <name>invoice_number</name>
    <title>Invoice Number</title>
    <type>varchar</type>
    <length>255</length>
    <import>true</import>
    <headerPattern>/invoice(.?number)?/i</headerPattern>
    <comment>Human readable invoice number</comment>
    <html>
      <type>Text</type>
    </html>
    <add>4.7</add>
  </field>
  <field>
    <name>currency</name>
    <type>varchar</type>
    <length>3</length>
    <default>NULL</default>
    <import>true</import>
    <headerPattern>/cur(rency)?/i</headerPattern>
    <dataPattern>/^[A-Z]{3}$/i</dataPattern>
    <comment>3 character string, value from config setting or input via user.</comment>
    <add>1.3</add>
    <pseudoconstant>
      <table>civicrm_currency</table>
      <keyColumn>name</keyColumn>
      <labelColumn>full_name</labelColumn>
      <nameColumn>name</nameColumn>
      <abbrColumn>symbol</abbrColumn>
    </pseudoconstant>
    <html>
      <type>Select</type>
      <label>Currency</label>
    </html>
  </field>
  <field>
    <name>cancel_date</name>
    <title>Cancelled / Refunded Date</title>
    <type>datetime</type>
    <import>true</import>
    <headerPattern>/cancel(.?date)?/i</headerPattern>
    <dataPattern>/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/</dataPattern>
    <comment>when was gift cancelled</comment>
    <add>1.3</add>
    <html>
      <type>Select Date</type>
      <formatType>activityDateTime</formatType>
    </html>
    <uniqueName>contribution_cancel_date</uniqueName>
  </field>
  <field>
    <name>cancel_reason</name>
    <type>text</type>
    <title>Cancellation / Refund Reason</title>
    <import>true</import>
    <export>true</export>
    <headerPattern>/(cancel.?)?reason/i</headerPattern>
    <html>
      <type>Text</type>
      <size>40</size>
    </html>
    <add>1.3</add>
  </field>
  <field>
    <name>receipt_date</name>
    <type>datetime</type>
    <import>true</import>
    <headerPattern>/receipt(.?date)?/i</headerPattern>
    <dataPattern>/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/</dataPattern>
    <comment>when (if) receipt was sent. populated automatically for online donations w/ automatic receipting</comment>
    <html>
      <type>Select Date</type>
      <formatType>activityDateTime</formatType>
      <label>Receipt Date</label>
    </html>
    <add>1.3</add>
  </field>
  <field>
    <name>thankyou_date</name>
    <title>Thank-you Date</title>
    <type>datetime</type>
    <import>true</import>
    <headerPattern>/thank(s|(.?you))?(.?date)?/i</headerPattern>
    <dataPattern>/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/</dataPattern>
    <comment>when (if) was donor thanked</comment>
    <add>1.3</add>
    <html>
      <type>Select Date</type>
      <formatType>activityDateTime</formatType>
    </html>
  </field>
  <field>
    <name>source</name>
    <uniqueName>contribution_source</uniqueName>
    <title>Contribution Source</title>
    <type>varchar</type>
    <length>255</length>
    <import>true</import>
    <headerPattern>/source/i</headerPattern>
    <comment>Origin of this Contribution.</comment>
    <add>1.3</add>
    <html>
      <type>Text</type>
    </html>
  </field>
  <index>
    <name>index_source</name>
    <fieldName>source</fieldName>
    <add>4.7</add>
  </index>
  <field>
    <name>amount_level</name>
    <title>Amount Label</title>
    <type>text</type>
    <import>true</import>
    <add>1.7</add>
    <html>
      <type>Text</type>
    </html>
  </field>
  <index>
    <name>UI_contrib_trxn_id</name>
    <fieldName>trxn_id</fieldName>
    <unique>true</unique>
    <add>2.1</add>
  </index>
  <index>
    <name>UI_contrib_invoice_id</name>
    <fieldName>invoice_id</fieldName>
    <unique>true</unique>
    <add>2.1</add>
  </index>
  <field>
    <name>contribution_recur_id</name>
    <title>Recurring Contribution ID</title>
    <type>int unsigned</type>
    <comment>Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.</comment>
    <export>true</export>
    <readonly>true</readonly>
    <html>
      <label>Recurring Contribution</label>
      <type>EntityRef</type>
    </html>
    <add>1.4</add>
  </field>
  <foreignKey>
    <name>contribution_recur_id</name>
    <table>civicrm_contribution_recur</table>
    <key>id</key>
    <add>1.4</add>
    <onDelete>SET NULL</onDelete>
  </foreignKey>
  <field>
    <name>is_test</name>
    <title>Test</title>
    <type>boolean</type>
    <default>0</default>
    <required>true</required>
    <import>true</import>
    <html>
      <type>CheckBox</type>
    </html>
  </field>
  <field>
    <name>is_pay_later</name>
    <title>Is Pay Later</title>
    <type>boolean</type>
    <default>0</default>
    <required>true</required>
    <import>true</import>
    <add>2.1</add>
    <html>
      <type>CheckBox</type>
    </html>
  </field>
  <field>
    <name>contribution_status_id</name>
    <title>Contribution Status ID</title>
    <type>int unsigned</type>
    <default>1</default>
    <import>true</import>
    <export>true</export>
    <headerPattern>/status/i</headerPattern>
    <pseudoconstant>
      <optionGroupName>contribution_status</optionGroupName>
    </pseudoconstant>
    <html>
      <type>Select</type>
      <label>Contribution Status</label>
    </html>
    <add>1.6</add>
  </field>
  <index>
    <name>index_contribution_status</name>
    <fieldName>contribution_status_id</fieldName>
    <add>1.6</add>
  </index>
  <index>
    <name>received_date</name>
    <fieldName>receive_date</fieldName>
    <add>1.6</add>
  </index>
  <field>
    <name>address_id</name>
    <uniqueName>contribution_address_id</uniqueName>
    <title>Address ID</title>
    <type>int unsigned</type>
    <comment>Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.</comment>
    <html>
      <label>Address</label>
    </html>
    <add>2.2</add>
    <export>true</export>
  </field>
  <foreignKey>
    <name>address_id</name>
    <table>civicrm_address</table>
    <key>id</key>
    <add>2.2</add>
    <onDelete>SET NULL</onDelete>
  </foreignKey>
  <field>
    <name>check_number</name>
    <title>Check Number</title>
    <uniqueName>contribution_check_number</uniqueName>
    <headerPattern>/check(.?number)?/i</headerPattern>
    <type>varchar</type>
    <length>255</length>
    <html>
      <type>Text</type>
      <size>6</size>
    </html>
    <import>true</import>
    <add>2.2</add>
  </field>
  <index>
    <name>check_number</name>
    <fieldName>check_number</fieldName>
    <add>2.2</add>
  </index>
  <field>
    <name>campaign_id</name>
    <component>CiviCampaign</component>
    <uniqueName>contribution_campaign_id</uniqueName>
    <type>int unsigned</type>
    <title>Campaign ID</title>
    <import>true</import>
    <comment>The campaign for which this contribution has been triggered.</comment>
    <add>3.4</add>
    <pseudoconstant>
      <table>civicrm_campaign</table>
      <keyColumn>id</keyColumn>
      <labelColumn>title</labelColumn>
      <prefetch>disabled</prefetch>
    </pseudoconstant>
    <html>
      <type>EntityRef</type>
      <label>Campaign</label>
    </html>
  </field>
  <field>
    <name>creditnote_id</name>
    <title>Credit Note ID</title>
    <type>varchar</type>
    <length>255</length>
    <import>true</import>
    <headerPattern>/creditnote(.?id)?/i</headerPattern>
    <comment>unique credit note id, system generated or passed in</comment>
    <add>4.6</add>
    <html>
      <type>Text</type>
    </html>
  </field>
  <index>
    <name>index_creditnote_id</name>
    <fieldName>creditnote_id</fieldName>
    <add>4.7</add>
  </index>
  <field>
    <name>tax_amount</name>
    <title>Tax Amount</title>
    <type>decimal</type>
    <import>true</import>
    <headerPattern>/tax(.?am(ou)?nt)?/i</headerPattern>
    <dataPattern>/^\d+(\.\d{2})?$/</dataPattern>
    <comment>Total tax amount of this contribution.</comment>
    <default>0</default>
    <required>true</required>
    <add>4.6</add>
    <html>
      <type>Text</type>
    </html>
  </field>
  <foreignKey>
    <name>campaign_id</name>
    <table>civicrm_campaign</table>
    <key>id</key>
    <onDelete>SET NULL</onDelete>
  </foreignKey>
  <field>
    <name>revenue_recognition_date</name>
    <type>datetime</type>
    <import>true</import>
    <headerPattern>/revenue(.?date)?/i</headerPattern>
    <dataPattern>/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/</dataPattern>
    <comment>Stores the date when revenue should be recognized.</comment>
    <html>
      <type>Select Date</type>
      <formatType>activityDateTime</formatType>
      <label>Revenue Recognition Date</label>
    </html>
    <add>4.7</add>
  </field>
  <field>
    <name>is_template</name>
    <title>Is a Template Contribution</title>
    <type>boolean</type>
    <default>0</default>
    <required>true</required>
    <import>true</import>
    <comment>Shows this is a template for recurring contributions.</comment>
    <readonly>true</readonly>
    <html>
      <type>CheckBox</type>
    </html>
    <add>5.20</add>
  </field>
</table>
