Feature: Accounting Reports Generation

  # ACC-594, ACC-592, ACC-625
  @ows_accounting
  @frontend_accounting
  Scenario: User is able to cancel the report
    Given I am on the Accounting::StatementsPage
    When I click 'Request Report' button for last period with positive revenue
    Then I should see report form with all required elements
    When I cancel the report request
    Then I should be redirected to the statements page

  # ACC-621
  @ows_accounting
  @frontend_accounting
  Scenario: User is able to download report which has been requested before
    Given I am on the Accounting::StatementsPage
    When I click 'Request Report' button for last period with positive revenue
    And I attempt to generate full report
    Then I should see download duplicate report link
    When I try to download file
    Then I should have downloaded file in the system with corresponding name

  # ACC-621
  @ows_accounting
  @frontend_accounting
  Scenario: User sees and downloads requested reports for different periods
    Given I am on the Accounting::StatementsPage
    When I click 'View Requested' link for last period with positive revenue
    Then I should be redirected to the view requested page
    And the ViewRequestedReports page title should be displayed correctly
    And I should see all available reports that currently queued or ready for download
    When I try to download report file
    Then I should have downloaded file in the system with corresponding name

  # ACC-598, ACC-627, ACC-604, ACC-601
  @ows_accounting
  @frontend_accounting
  Scenario Outline: User is able to download just generated report
    Given I am on the Accounting::StatementsPage
    When I click 'Request Report' button for last period with positive revenue
    And I select <file_type> file type
    And I select <number_format> number format
    And I clean up previous downloads history for <report_type> report
    And I attempt to generate <report_type> report
    Then I should be redirected to the view requested page
    And the last report should be displayed correctly on the requested reports history page
    And I wait until the report has Download link
    And I try to download file from the last generated report
    Then I should have downloaded file in the system with corresponding name
    And the report file should have required fields

    Examples:
      | report_type | file_type | number_format |
      | full        | xls       | EU            |
      | custom      | xls       | US            |
      | physical    | txt       | US            |
