@frontend_royalties
@ows_abacus_contract
Feature: abacus contract lifecycle - miscellaneous

  Background: Clear browser
    Given I have a clear browser

  @id_94b71118e88fd3e1cb4fab90549cae190ff1c4568eafe647253fcba7eb6b34ad
  Scenario: CRUD contract notes
    Given an orchard employee label_7123_admin_4 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-US                 |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 123                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new active account via API
    And I have a Distribution runcontroller created
    And I prepare an abacus contract data:
      | Key           | Value                         |
      | contractType  | Distribution                  |
      | signingEntity | AWAL Recordings America, Inc. |
      | renewalRule   | Continuously Active           |
    And I should be able to create Active contract with this data via new flow
    Then I should be able to add/update/delete contract notes

  @id_227467180c0e188a37b79d7723bba0468eacca42f5212f6c5a1ac045f21c94b2
  Scenario: Edit general contract details
    Given an orchard employee label_7123_admin_4 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-US                 |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 123                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new active account via API
    And I have a Distribution runcontroller created
    And I prepare an abacus contract data:
      | Key           | Value                         |
      | contractType  | Distribution                  |
      | signingEntity | AWAL Recordings America, Inc. |
      | renewalRule   | Continuously Active           |
    And I should be able to create Active contract with this data via new flow
    Then I should be able to edit contract's general details

  @id_6c5fa385a3b06d83825cfa9ccf01049e03e56b81c3b865a83c7b4952779406ab
  Scenario: contract with KNR account
    Given an orchard employee label_7123_admin_4 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | knr                     |
      | paidBy           | KNR-UK                  |
      | currency         | USD                     |
      | owner            | knr                     |
      | paymentMinimum   | 123                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new active account via API
    And I have a Performer Neighbouring Rights runcontroller created
    And I prepare an abacus contract data:
      | Key           | Value                                  |
      | contractType  | Performer Neighbouring Rights          |
      | signingEntity | Kollective Neighbouring Rights Limited |
      | renewalRule   | Renew Periodically                     |
    And I should be able to create Active contract with this data via new flow

  @id_4c841a79fdba15122b1d8dacb152209a699efc3f6fb33a568754552dd3feb5c1
  Scenario: Edit renewal rule and period start date
    Given an orchard employee label_7123_admin_4 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-US                 |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 123                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new active account via API
    And I have a Distribution runcontroller created
    And I prepare an abacus contract data:
      | Key           | Value                         |
      | contractType  | Distribution                  |
      | signingEntity | AWAL Recordings America, Inc. |
      | renewalRule   | Continuously Active           |
    And I should be able to create Active contract with this data via new flow
    Then I should be able to edit contract's renewal rule
    Then I should be able to edit contract's current period start date

  @id_f640ebcf6dc16593eb805fd8adf6576cf3864b5b3b3df079fdb9b1410c49d2bb
  Scenario: Exclude/Include contract from the Accounting Run
    Given an orchard employee label_7123_admin_4 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-US                 |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 123                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new active account via API
    And I have a Distribution runcontroller created
    And I prepare an abacus contract data:
      | Key           | Value                         |
      | contractType  | Distribution                  |
      | signingEntity | AWAL Recordings America, Inc. |
      | renewalRule   | Continuously Active           |
    And I should be able to create Active contract with this data via new flow
    Then I should be able to exclude contract from accounting run
    Then I should be able to include contract in accounting run

  @id_f23dae1b060d0b82574a0275e7c50e488caae1792139bee5bf590654b8c303e8
  Scenario: Enable/Disable flowthrough for the contract
    Given an orchard employee label_7123_admin_4 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-US                 |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 123                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new active account via API
    And I have a Distribution runcontroller created
    And I prepare an abacus contract data:
      | Key           | Value                         |
      | contractType  | Distribution                  |
      | signingEntity | AWAL Recordings America, Inc. |
      | renewalRule   | Continuously Active           |
    And I should be able to create Active contract with this data via new flow
    Then I should be able to set contract as flowthrough
    Then I should be able to unset contract as flowthrough

  @id_e92b64cf123640daf7ff5b9dac30572bfc957732196f86711ea4b72c328b93a3
  Scenario: add contract to a collection period
    Given an orchard employee label_7123_admin_4 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-US                 |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 123                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new active account via API
    And I have a Performer Neighbouring Rights runcontroller created
    And I prepare an abacus contract data:
      | Key              | Value                         |
      | contractType     | Performer Neighbouring Rights |
      | collectionPeriod | true                          |
      | signingEntity    | AWAL Recordings America, Inc. |
      | renewalRule      | Continuously Active           |
    And I should be able to create Active contract with this data via new flow
    Then I should be able to add contract termination date
    Then contract's status should be Collection Period
