@cache_warm
@slow
@accounting
@ows_accounting
@frontend_accounting
Feature: Accounting
  In order to ensure the accuracy and reliability of accounting data
  As a Workstation Accounting user
  I want to view current and historical accounting data
  * DRB = Digital Revenue Breakdown, on AccountingBreakdownPage
# TODO: move this to SPA SA once Accounting is under SPA

  @legacy
  @regression
  Scenario: Access accounting breakdown page
    Given a Workstation label_7482 user
    Given I am on the Workstation homepage
    When I navigate to Accounting, Current Period using the top nav
    Then I should be on the accounting breakdown page

  Scenario: Verify historical publishing deductions
    Given a Workstation label_19405 user
    Given I am on the accounting breakdown page for the current period
    When I view the accounting breakdown for "Jan 2014" to "Jan 2014"
    Then I should see a Ringtones publishing deduction of "£-0.06"
    And I should see a Full Tracks publishing deduction of "£-721.27"
    And I should see an Outstanding Balance of "£0.00"

  @wip
  Scenario Outline: Accounting Snapshot links to Accounting breakdown page
    Given the Show Gross Accounting feature control is <feature_control> for label_19405
    And Gross Revenue logic is <feature_control>
    And a Workstation label_19405 user
    When I am on the Workstation homepage
    And I view the accounting breakdown for the current period through the Accounting Snapshot
    Then the start and end period filters should be correct
    And the Revenue should match the value in the snapshot

    Examples:
      | feature_control |
      | enabled         |
      | disabled        |

  Scenario: Previous/Penultimate period summary (NOTE: this used to validate the current period, but that breaks when the accounting run is applied to the QA env)
    Given a Workstation label_19405 user
    Given I am on the accounting breakdown page for the penultimate period
    And I should see the correct Outstanding Balance
    When I get the penultimate period's Opening Balance
    Then the antepenultimate period's Outstanding Balance should match it

  Scenario Outline: Apply views, verify totals match
    Given a Workstation label_19405 user
    Given I am on the accounting breakdown page for the current period
    When I apply a <view> view to the accounting breakdown
    Then the DRB Revenue Total should match the Summary section Revenue
    And the view should show as applied

  Examples:
  | view            |
  | activity period |
  | subaccount      |
  | imprint         |
  | artist          |
  | product         |
  | track           |
  | source          |
  | channel         |
  | country         |

  # possibly an idea for a test?
  @wip
  Scenario: Verify Revenue and Payment in Statements export matches with Summary
    Given a Workstation label_19405 user
    When PENDING: I visit the accounting statements page
    And PENDING: I download the report for the most recent period
    Then PENDING: the values for Revenue and Payment in it should match that of the Summary section

  @wip
  Scenario Outline: New Accounting Statements page links to Accounting Breakdown page
    Given the Show Gross Accounting feature control is <feature_control> for label_19405
    And Gross Revenue logic is <feature_control>
    And a Workstation label_19405 user
    When I am on the Workstation::AccountingStatementsPage
    And I navigate to the breakdown page for the previous period from the statements page
    Then I should see the accounting breakdown page for the selected previous period

    Examples:
      | feature_control |
      | enabled         |
      | disabled        |

  # ACC-953
  @first_statement_period_change
  Scenario: Suppress Workstation Accounting Before date should apply to the filter on View page
    Given a Workstation label_7482 user
    When I update the first statement period to "223"
    And I am on the accounting breakdown page for the current period
    Then I should see the starting form period to be "223" in dropdown filter
    When I view the accounting breakdown for "Q3 2017" to "Q4 2017"
    Then the DRB Revenue Total should match the Summary section Revenue

  # ACC-952
  # November 26, 2018: This scenario doesn't make sense as-is. It's supposed to suppress accounting
  # data before Q4 2017 but the most recent periods are all from 2018 so it would never show anything
  # from 2017 anymore. Is there a way to salvage this or this pretty much irrelevant?
  @wip
  @first_statement_period_change
  Scenario: Suppress Workstation Accounting Before date should apply to Revenue snapshots
    Given a Workstation label_7482 user
    And I am on the Workstation homepage
    When I update the first statement period to "226"
    And I refresh the page
    Then I should see the Recent Revenue starting from "Q4 2017" period

  # ACC-646, ACC-580
  @legacy
  Scenario: User should be able to navigate to Physical Reserves page
    Given a Workstation label_21989 user
    When I am on the Workstation::AccountingBreakdownPage
    Then I should see "Physical Reserves" tab in the subnavigation menu
    When I click on "Physical Reserves" tab
    Then I should be redirected to the statements page Physical Reserves page
    And I should see Expected Reserve Payouts table

  # ACC-576
  Scenario: Physical Reserves tab should not be displayed for subaccounts
    Given a Workstation subaccount_20651 user
    When I am on the Workstation::AccountingBreakdownPage
    Then I should not see "Physical Reserves" tab in the subnavigation menu
