#  Please read this document for further details:
#  https://docs.google.com/document/d/1OM0MCR1Ajmmt5cIay08FyN-Hv23uC9VIFMnRNi8i3Iw/

@accounting-run
Feature: Accounting Run

  #  Before running clean environment with make abacus_accounting_run_setup
  @id_56ef68fd5c06d009d4664b8f9c26270e15a918c3a2fc2ccbb784e0c89fc76104
  Scenario: Accounting Run Calculations Are Correct
    Given I login to abacus with a test user
    And I prepare the QA environment Accounting Run data
    When I define entities names for the Accounting Run
    And I navigate to accounting periods page
    Then I create a new accounting period
    And I open newly created accounting period
    And I get eligible sales
    And I mark all sales as Delivered
    And I approve the sales file
    And I prepare mechanical deductions
    And I initiate the Accounting Run
    Then The Accounting Run results match the expected values
      | contractId | contractTermId | termType |
      | 549169     | 85362          | label    |
      | 549497     | 85508          | label    |
      | 549497     | 85509          | product  |
      | 549202     | 85714          | track    |
    And The mechanical deductions are correct for the contracts
      | contractId | payShare |
      | 549853     | customer |
      | 549852     | both     |
      | 549203     | business |
    And I approve the Accounting Run
    And I skip the run for remaining runcontrollers
    And I mark runs as complete
    Then I close the accounting period
    And I assert the mechanical deductions values in the publishing escrow table
