Feature: Calculate revenue due
  In order to ensure that payees get the right amounts each month
  As an accountant
  I want to look up their contracts, compute their cuts and aggregate them.

  Scenario: Accounting run

    Given the following transactions:
      |  Date      | Vendor | Country | Store   | Type      | Track id | Total |
      | 2019-01-12 |  123   | USA     | Spotify | Streaming | 1        | 5     |
      | 2019-01-15 |  123   | USA     | Itunes  | Streaming | 1        | 3     |
      | 2019-02-22 |  123   | Canada  | Itunes  | Download  | 2        | 5     |
      | 2019-01-04 |  456   | India   | Tidal   | Streaming | 3        | 6     |
      | 2019-02-05 |  456   | India   | Itunes  | Download  | 4        | 2     |

    And the following contracts:
      | Contract ID | Vendor | Start Date | End Date   | Payee |
      | 1           | 123    | 2019-01-01 | 2019-01-31 | Troy  |
      | 2           | 123    | 2019-01-01 | 2019-02-28 | Jenna |
      | 3           | 456    | 2019-01-01 | 2019-01-31 | Jay   |
      | 4           | 456    | 2019-02-01 | 2019-02-28 | Troy  |

    And the following contract clauses:
      | Contract ID | Country | Store   | Type      | Track id | Split |
      | 1           | USA     | All     | Streaming | All      | 0.25  |
      | 1           | All     | All     | All       | All      | 0.1   |
      | 2           | USA     | Spotify | All       | All      | 0.30  |
      | 2           | All     | All     | All       | All      | 0.15  |
      | 3           | All     | Itunes  | Download  | All      | 0.5   |
      | 3           | All     | All     | All       | All      | 0.45  |
      | 4           | All     | All     | All       | All      | 0.20  |

    When I compute the revenue due each payee

    Then I get the following results:
      | Payee | Amount |
      | Troy  | 2.4000 |
      | Jenna | 2.7000 |
      | Jay   | 2.7000 |