@ows_payment_closing_balances
Feature: Abacus Payments 2

  Background: Clear browser
    Given I have a clear browser

  @frontend_royalties_closing_balances
  @ows_royalties_closing_balances
  @ows_abacus_event_closing_balances
  @ows_abacus_state_closing_balances
  @lambda_documents_closing_balances
  @lambda_documents_payout_closing_balances
  @id_6c1dd6626e098c9a13c7aece7d383e4a67265894627fda2a62d2e1ee0cd7beab
  Scenario: Payment group payment accounts and info pop up
    Given an orchard employee label_7123_admin_3 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-TEST               |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 123                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new account via API
    And I update payment description
    And I have a Distribution runcontroller created
    And I have a new Distribution contract lifecycle created with accounts created for AWAL Recordings Licensing Ltd
    And I complete the account to create payment in entity equal 100 and update tax_eligibility to complete
    And I have a new payment group created
    Then I should be able to add account to a payment group payment
    And payment details should be shown at payment info popup
    And I should be able to see the account on a group payment page
    And I should be able to see an entry on payment overview section
    And I should be able to see an entry on payments page

  @ows_royalties_closing_balances
  @ows_abacus_event_closing_balances
  @ows_abacus_state_closing_balances
  @lambda_documents_closing_balances
  @lambda_documents_payout_closing_balances
  @id_66b4c1750a83afcba754ca2d26ed721d7c87a46cbc24d446e45d3473671d2309
  Scenario: Approve/send payment for PAYCHEX paymnent method
    Given an orchard employee label_7123_admin_3 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                     |
      | companyBrandName | awal                      |
      | paidBy           | AWAL-TEST                 |
      | agreementType    | AWAL Core                 |
      | currency         | USD                       |
      | owner            | awal                      |
      | paymentMinimum   | 333                       |
      | paymentSchedule  | 60 days after quarter end |
    And I create 1 new active account via API
    And I have a Distribution runcontroller created
    And I have a new Distribution contract lifecycle created with accounts created for AWAL Recordings Licensing Ltd
    And I update account_payee and account_tax_info tables
    And I complete the account to create payment in entity equal 100 and update tax_eligibility to complete
    And I update payoneer id in DB to 100246640
    And I have a new payment group created
    And I update payment groupd criteria to PAYCHEX
    And I add closing balance to the account
    And I add taxable revenue to the account
    And I update payment method in DB to PAYCHEX
    Then I should be able to create a payment for payment group created
    And I should be able to see generated Payment
    And I should be able to see account name on a group payment page
    And I should be able to approve the payment
    And I update payment method in DB to PAYONEER

  @ows_royalties_closing_balances
  @ows_abacus_event_closing_balances
  @ows_abacus_state_closing_balances
  @lambda_documents_closing_balances
  @frontend_royalties_closing_balances
  @lambda_documents_payout_closing_balances
  @id_73a956bb5e3ebbd3ee58ef95111b8994f64eeacc30c75fc4e170e33067258c3e
  @deleteWorksheetAccountContractClosingBalance
  Scenario: Approve/send payment and pending payment
    Given an orchard employee label_7123_admin_3 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-TEST               |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 333                     |
      | paymentSchedule  | 45 days after month end |
    And I create 2 new active accounts via API
    And I have a Distribution runcontroller created
    And I have a new Distribution contract lifecycle created with accounts created for AWAL Recordings Licensing Ltd
    And I update account_payee and account_tax_info tables
    And I complete the account to create payment in entity equal 100 and update tax_eligibility to complete
    And I update payoneer id in DB to 100246640
    And I add closing balance to the account
    And I add taxable revenue to the account
    And I should be able to add a payment for a specific accounts
    And I should be able to see generated Payment
    And I should be able to see account name on a group payment page
    And I should be able to add a note for the payment
    And I should be able to approve the payment
    And I should be able to add a payment for a specific accounts
    Then payment group should contain a pending payment

  @ows_royalties_closing_balances
  @ows_abacus_event_closing_balances
  @ows_abacus_state_closing_balances
  @lambda_documents_closing_balances
  @frontend_royalties_closing_balances
  @lambda_documents_payout_closing_balances
  @id_f52d379544a1cc9169e3d92dbd9e265f9a70ac37f31703489624f747ea1bbb3b
  Scenario: Payment does not go to ledger after payment has failed to verify from Payoneer
    Given an orchard employee label_7123_admin_3 for Abacus
    And I log in to Abacus silently
    And I am successfully logged in to Abacus
    And I prepare an abacus account data:
      | Key              | Value                   |
      | companyBrandName | awal                    |
      | paidBy           | AWAL-TEST               |
      | agreementType    | AWAL Core               |
      | currency         | USD                     |
      | owner            | awal                    |
      | paymentMinimum   | 333                     |
      | paymentSchedule  | 45 days after month end |
    And I create 1 new active account via API
    And I have a Distribution runcontroller created
    And I have a new Distribution contract lifecycle created with accounts created for AWAL Recordings Licensing Ltd
    And I update account_payee and account_tax_info tables
    And I add closing balance to the account
    And I add taxable revenue to the account
    And I complete the account to create payment in entity equal 100 and update tax_eligibility to complete
    And I update payoneer id in DB to 0
    And I should be able to add a payment for a specific accounts
    And I should be able to see generated Payment
    And I should be able to add a note for the payment
    And I should be able to approve the payment
    And I should be able to send the payment
    And I should see that Payment batch failed
