module Workstation
  class AccountingStatementsPage < Workstation::BasePage
    page_url "/accounting/statementshistory"

    table(:statement_table, class: ["table", "table-striped"])
    div(:loading_bar, class: "progress")
    buttons(:request_report, class: "btn-primary")

    def wait_for_loading_bar_to_disappear
      loading_bar_element.element.wait_while(timeout: 60, &:present?)
    end

    def payment_from_row(row)
      statement_table_element[row]["TOTAL PAYMENTS"].text.gsub(/[^\d\.]/, "").to_f
    end
  end
end
