Feature: Contract clause matching
  In order to ensure that payees get the right cut from a transaction
  As an accountant
  I want to match the right contract clause to each transaction

  Scenario: Matching clauses within a contract to transactions

    Given transactions with the following features:
      | Country | Store   | Type      | Track id |
      | USA     | Spotify | Streaming | 1        |
      | USA     | Itunes  | Streaming | 2        |
      | Canada  | Itunes  | Download  | 2        |
      | India   | Tidal   | Streaming | 5        |
      | India   | Itunes  | Download  | 13       |
      | India   | Itunes  | Download  | 17       |

    And a contract that applies to each of these transactions with the following clauses:
      | Country | Store   | Type      | Track id | Split |
      | All     | All     | All       | 17       | 0.35  |
      | USA     | All     | Streaming | All      | 0.25  |
      | USA     | Spotify | All       | All      | 0.30  |
      | All     | Itunes  | Download  | All      | 0.15  |
      | All     | All     | All       | All      | 0.10  |

    When I match clauses to each of the transactions

    Then I get the following matched splits:
      | Country | Store   | Type      | Track id | Split |
      | USA     | Spotify | Streaming | 1        | 0.25  |
      | USA     | Itunes  | Streaming | 2        | 0.25  |
      | Canada  | Itunes  | Download  | 2        | 0.15  |
      | India   | Tidal   | Streaming | 5        | 0.1   |
      | India   | Itunes  | Download  | 13       | 0.15  |
      | India   | Itunes  | Download  | 17       | 0.35  |
