@abacus_delete_knr_adjustment_files
@frontend_royalties
@abacus_adjustments
@ows_abacus_worksheet
Feature: Abacus Adjustments 1

  Background: Clear browser
    Given I have a clear browser

  @id_0c2fc0af5101cf451a316c5d84e53a8b22488f94ccd16fc344140a629885cf3d
  Scenario: Download adjustments file template
    Given an orchard employee label_7123_admin_1 for Abacus
    When I log in to Abacus silently
    Then I am successfully logged in to Abacus
    Then I should be able to download adjustments file template

  @ACC-8180
  @id_078bf9a5e9dce06d404f1350286dab01453563744157ad0e596f3d9c90427b4b
  Scenario: File over 70,000 rows should throw an error
    Given an orchard employee label_7123_admin_1 for Abacus
    And I log in to Abacus silently
    Then I am successfully logged in to Abacus
    And I should be able to upload very_big_file_test.xlsx adjustments file

  @id_d6c3eea7536cca395cc2867a59d622e541e4d7bd4da2065d6a4cc8fdf6fa8099
  Scenario: Adjustments File with amount 0 should throw an error
    Given an orchard employee label_7123_admin_1 for Abacus
    And I log in to Abacus silently
    Then I am successfully logged in to Abacus
    And I should be able to upload cypress_invalid_adjustments_file_amount_zero.xlsx adjustments file
    Then error report should contain the error: Amount cannot be zero

  @update_adjustment_file_fixtures
  @id_66ae0ee9a0381bc086b3d86946931ab42d806de9e8df63b885512eb66f128c93
  Scenario Outline: Upload different adjustments files
    Given an orchard employee label_7123_admin_1 for Abacus
    When I log in to Abacus silently
    Then I am successfully logged in to Abacus
    And I reopen closed balance for current statement period for payment entity: KNR_UK
    And I reopen closed balance for current statement period for payment entity: KNR_NL
    Then I should be able to upload <file> adjustments file

    Examples:
      | file                                     |
      | cypress_valid_adjustments_file.xlsx      |
      | cypress_invalid_adj_invalid_headers.xlsx |
      | cypress_invalid_adj_content_error.xlsx   |

  @update_adjustment_file_fixtures
  @id_d31f1f4a106302a0e02c960dbb0af6d671e59a0feb3cd0a5c81341f34bc6742f
  Scenario: Search for adjustments by status/batch_id/filename/statement_period/added_by
    Given an orchard employee label_7123_admin_1 for Abacus
    When I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I reopen closed balance for current statement period for payment entity: KNR_UK
    And I reopen closed balance for current statement period for payment entity: KNR_NL
    When I have multiple adjustment files uploaded
    Then I should be able to search for an adjustment by batch id
    Then I should be able to search for an adjustment by status
    Then I should be able to search for an adjustment by filename
    Then I should be able to search for an adjustment by statementPeriod
    Then I should be able to search for an adjustment by addedBy

  @update_adjustment_file_fixtures
  @id_e3cf3c03095921520a5ee01b26aff4cafab40fa67df0708d1fcb43cd4499c12d
  Scenario: Approve and apply adjustments
    Given an orchard employee label_7123_admin_1 for Abacus
    When I log in to Abacus silently
    Then I am successfully logged in to Abacus
    And I reopen closed balance for current statement period for payment entity: KNR_UK
    And I reopen closed balance for current statement period for payment entity: KNR_NL
    Then I should be able to upload cypress_valid_adjustments_file.xlsx adjustments file
    And I should be able to import the adjustments
    And I should be able to approve the adjustments
    And I should be able to apply the adjustments

  @update_adjustment_file_fixtures
  @id_08ab6edc317c8908a9ab47ef5528af03768782abda9545044445d29bcf1504ca
  Scenario: Filter particular adjustments batch by account or contract
    Given an orchard employee label_7123_admin_1 for Abacus
    When I log in to Abacus silently
    Then I am successfully logged in to Abacus
    And I reopen closed balance for current statement period for payment entity: KNR_UK
    And I reopen closed balance for current statement period for payment entity: KNR_NL
    Then I should be able to upload cypress_valid_adjustments_file.xlsx adjustments file
    And I should be able to import the adjustments
    Then I filter adjustments by account or contract
