@frontend_royalties_closing_balances
@ows_payment_closing_balances
Feature: Abacus Closing Balances tests

  Background: Clear browser
    Given I have a clear browser

  @abacus_delete_non_applied_adj_files_for_awal_tests
  @abacus_delete_awal_adjustment_files
  @abacus_close_balance
  @ows_abacus_worksheet_closing_balances
  @update_adjustment_file_fixtures
  @abacus_entity_update
  @id_8bb54a882323777fd5775f6d1cd2e2ba65e03e0d8ad9d90d9322d209dc5d707d
  Scenario: User should not be able to upload adjustments once balance is closed
    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
    # reopen balance if it's closed to have scenario in consistent state
    And I reopen closed balance for current statement period for payment entity: AWAL_TEST_CLOSE_BALANCE
    # we have to close balances for payment entity first
    Then I should be able to close the balance for payment entity: AWAL_TEST_CLOSE_BALANCE
    And I should be able to upload adjustments_file_awal_test_closed.xlsx adjustments file
    Then error report should contain the error: Contract's balance is closed

  @abacus_delete_non_applied_adj_files_for_awal_tests
  @abacus_delete_awal_adjustment_files
  @abacus_close_balance
  @ows_abacus_worksheet_closing_balances
  @update_adjustment_file_fixtures
  @abacus_backfill
  @lambda_documents_closing_balances
  @lambda_documents_payout_closing_balances
  @abacus_entity_update
  @id_23ab8e5973e9d084e02e6a765fb49eb2ab51806941dd7889aab589d271384350
  Scenario: Paying off the closed balance
    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 save the account's payable balance for future reference
    And I reopen closed balance for current statement period for payment entity: AWAL_TEST_CLOSE_BALANCE
    And I post a backfill and ledger event
    Then I should be able to close the balance for payment entity: AWAL_TEST_CLOSE_BALANCE
    And account's balance should reflect the adjustment
    Then I should be able to issue a payment for an account
