@frontend_royalties
@ows_royalties
Feature: Royalties
  Scenario: Base page should be valid
    Given I am logged in to abacus application
    When I am on the Royalties::HomePage
    Then I should see correct title and main links
    And I should be able to navigate via sidebar

  Scenario: Payee details sub-tabs
    Given I am logged in to abacus application
    And I have a payee with a contract
    Then I should be able to view payee details sub-tabs

  @ows_payee
  Scenario Outline: Add Payee
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then I should be able to add <payee_type> payee
    And I should be able to navigate back to PayeesPage

  Examples:
    | payee_type     |
    | Artist         |
    | Distributor    |
    | Label          |

  @ows_payee
  Scenario: Add payee with payment_schedule and payment_minimum
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee with payment_schedule and payment_minimum
    And I should be able to edit Artist payee with payment_schedule and payment_minimum

  @ows_payee
  Scenario Outline: Add Payee with different payment agreement types
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then I should be able to add payee with <types> payment agreement
    And I should be able to navigate back to PayeesPage

  Examples:
    | types          |
    | Finetunes      |
    | Phonofile      |
    | SME Canada     |
    | The Orchard    |

  Scenario: Add Runcontroller
    Given I am logged in to abacus application
    When I am on the Royalties::RunControllersPage
    Then I should be able to add runcontroller

  @ows_payee
  Scenario: View payee details page
    Given I am logged in to abacus application
    And I have a new Artist payee created
    When I am on the Royalties::PayeesPage
    Then I should be able to view payee details

  @ows_payee
  Scenario: Edit payee details
    Given I am logged in to abacus application
    When I have a new Artist payee created
    Then I should be able to edit payee details

  @ows_payee
  Scenario: Add Contract
    Given I am logged in to abacus application
    And I have a runcontroller created
    And I have a new Distributor payee created
    When I am on the Royalties::AddContractPage
    Then I should be able to create new contract

  @ows_payee
  Scenario: View contract details page
    Given I am logged in to abacus application
    When I have a new contract
    Then I should be able to view contract details

  @ows_payee
  Scenario: Payee details page should contain list of contracts payee is used in
    Given I am logged in to abacus application
    And I have a new Artist payee created
    And I have a new contract created with this payee
    Then I should be able to see list of contracts of the payee

  @ows_payee
  Scenario: Add adjustments
    Given I am logged in to abacus application
    And I have a new contract
    Then I should be able to add contract adjustments

  Scenario: View accounting periods page
    Given I am logged in to abacus application
    When I am on the Royalties::AccountingPeriodsPage
    Then I should be able to view list of accounting periods

  Scenario: View accounting period details page
    Given I am logged in to abacus application
    And I have an open accounting period
    And I open details page for the open period
    Then accounting period details page should be valid

  # not working atm due to payee & contract sync action is not ready
  @wip
  @sales_file
  Scenario: invalidate the Accounting Run
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    And I have sales file added and processed
    When I open details page for the open period
    And I should be able to upload exchange rates file
    Then I should be able to start the accounting run
    And I should be able to invalidate the accounting run

  # not working atm due to payee & contract sync action is not ready
  @wip
  @sales_file
  Scenario: Mechanical Deductions
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have sales file added and processed
    When I open details page for the open period
    And I should be able to upload exchange rates file
    Then I should be able to run mechanical deductions

  # not working atm due to payee & contract sync action is not ready
  @wip
  @sales_file
  Scenario: Commit the Accounting Run
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    And I have sales file added and processed
    When I open details page for the open period
    And I should be able to upload exchange rates file
    Then I should be able to start the accounting run
    And I should be able to commit the accounting run

  @royalties_qa_smoke
  Scenario: QA smoke scenario
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then Payees page should be valid
    And Contracts page should be valid
    And Accounting Periods page should be valid
    And Admin page should be valid

  @wip
  @royalties_qa_smoke
  Scenario: Accounting Run Summary file can be downloaded on QA
    Given I am logged in to abacus application
    When I open details page for the open period
    And I open run summary details if present
    Then I should be able to download run summary details tsv
    And file content should be valid

  # not working atm due to payee & contract sync action is not ready
  @wip
  @sales_file
  Scenario: deliver sales
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have sales file added and processed
    When I open details page for the open period
    And I should be able to upload exchange rates file
    Then I should be able to set period to "All Sales Delivered"

  # there's currently no way to create a run summary item in a DB as a fixture
  @wip
  Scenario: Accounting Run Summary page
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    When I have an accounting run
    Then I should be able to view Accounting Run Summary page

  @sales_file
  Scenario: Upload exchange rates file
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    And I have sales file added and processed
    When I open details page for the open period
    Then I should be able to upload exchange rates file

  # not working atm due to payee & contract sync action is not ready
  @wip
  @sales_file
  Scenario: Skip the Accounting Run
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    And I have sales file added and processed
    When I open details page for the open period
    And I should be able to upload exchange rates file
    Then I should be able to skip the accounting run
    And I should be able to undo the skip

  @ows_payee
  Scenario: Add Payee Check Payment Details
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    Then I should be able to fill check payment details info

  @ows_payee
  Scenario: Add Payee Wire Transfer Payment Details
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    Then I should be able to fill wire transfer payment details info

  @ows_payee
  Scenario Outline: Add Payee Western Union Payment Details
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    Then I should be able to fill western union payment details info: <western_union_status>

  Examples:
    | western_union_status               |
    | Enrollment Not Currently Available |
    | Enrollment Available               |
    | Enrollment in Progress             |
    | Incomplete Enrollment              |
    | Enrolled                           |

  @ows_payee
  Scenario: Add/Edit Payee Payment Contact Details
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    And I should be able to edit payment contact details

  Scenario: View Payment Method Minimums
    Given I am logged in to abacus application
    When I am on the Royalties::PaymentMethodMinimumsPage
    Then I should be able to view payment method minimums

  Scenario: Edit Payment Method Minimums
    Given I am logged in to abacus application
    When I am on the Royalties::PaymentMethodMinimumsPage
    Then I should be able to edit payment method minimums
    And I should be able to see the minimums on the payee's page popup and navigate to admin page from it

  Scenario: Put payee's Payment Eligibility on hold/active
    Given I am logged in to abacus application
    When I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    And I should be able to add check payment details
    And I should be able to put payee's Payment Eligibility on hold
    And I should be able to put payee's Payment Eligibility active
    Then I should be able to view payee's payment hold history

  @ows_ledger
  Scenario: Payee's accounting details section
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    Then I should be able to add payee's accounting details
    Then I should be able to view payee's accounting details section

  @delete_dag
  @ows_payee
  Scenario Outline: Search for payee
    Given I am logged in to abacus application
    And I have an open accounting period
    And I am on the Royalties::PayeesPage
    And I have a new contract
    Then I should be able to add payee's accounting details
    Then I should be able to search for a payee by <search_criteria>

  Examples:
    | search_criteria |
    | name            |
    | currency        |
    | agreement       |
    | status          |
    | balance         |

  @ows_payment
  @ows_abacus_event
  Scenario: Payment groups
    Given I am logged in to abacus application
    And I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    When I am on the Royalties::PaymentsPage
    Then I should be able to add payment groups

  @ows_payment
  @ows_abacus_event
  Scenario: Payment group payment payees
    Given I am logged in to abacus application
    And I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    When I am on the Royalties::PaymentsPage
    Then I should be able to add payee to a payment group payment
    And I should be able to see the payee on a group payment page
    And I should be able to see an entry on payment overview section
    And I should be able to see an entry on payments page

  @ows_payment
  @ows_abacus_event
  Scenario: Delete payment group payment payees
    Given I am logged in to abacus application
    And I have 2 payees associated with payment group payment
    Then I should be able to delete a payee from the payment

  @ows_payment
  @ows_abacus_event
  Scenario: Delete payment
    Given I am logged in to abacus application
    And I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    When I am on the Royalties::PaymentsPage
    Then I should be able to add payee to a payment group payment
    And I should be able to delete the payment

  @ows_payment
  @ows_abacus_event
  Scenario: Add a note for a payee
    Given I am logged in to abacus application
    And I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    When I am on the Royalties::PaymentsPage
    Then I should be able to add payee to a payment group payment
    And I should be able to add a note for a payee

  @delete_dag
  @ows_payment
  @ows_abacus_event
  Scenario: Approve/post payment
    Given I am logged in to abacus application
    And I am on the Royalties::PayeesPage
    Then I should be able to add Artist payee
    When I am on the Royalties::PaymentsPage
    Then I should be able to add payee to a payment group payment
    And I should be able to approve the payment
    And I should be able to post the payment

  @ows_abacus_contract
  Scenario: add contract base terms rate
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    Then I should be able to fill contract term details

  @ows_abacus_contract
  Scenario: add contract product exceptions
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    And I should be able to fill contract term details
    Then I should be able to add a contract product exception

  @ows_abacus_contract
  Scenario: add contract track exceptions
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    And I should be able to fill contract term details
    Then I should be able to add a contract track exception

  @ows_abacus_contract
  Scenario: add contract mechanical deductions
    Given I am logged in to abacus application
    And I have an open accounting period
    And I have a new contract
    And I should be able to fill contract term details
    Then I should be able to add a contract mechanical deductions

  Scenario: Statutory Rates page
    Given I am logged in to abacus application
    When I am on the Royalties::AdminPage
    Then I should be able to see valid admin links
    When I am on the Royalties::StatutoryRatesPage
    Then StatutoryRatesPage should be valid

  Scenario: add accounting period id
    Given I am logged in to abacus application
    And I have an open accounting period
    When I assign a period_id to the accounting period
    Then I should be able to see it on accounting period details list
