def METHOD_NAME(
    patron_martigny, librarian_martigny, librarian2_martigny,
    system_librarian_martigny, document, org_martigny,
    acq_invoice_fiction_sion, acq_invoice_fiction_saxon,
    acq_invoice_fiction_martigny
):
    """Test invoices permissions class."""
    # Anonymous user & Patron :: None action allowed
    identity_changed.send(
        current_app._get_current_object(), identity=AnonymousIdentity()
    )
    check_permission(AcqInvoicePermissionPolicy, {
        'search': False,
        'read': False,
        'create': False,
        'update': False,
        'delete': False
    }, {})
    login_user(patron_martigny.user)
    check_permission(AcqInvoicePermissionPolicy, {
        'search': False,
        'read': False,
        'create': False,
        'update': False,
        'delete': False
    }, acq_invoice_fiction_martigny)
    # As staff member without any specific access :
    #   - None action allowed
    #   - except read record of its own library (pro_read_only)
    login_user(librarian2_martigny.user)
    check_permission(AcqInvoicePermissionPolicy, {
        'search': True,
        'read': True,
        'create': False,
        'update': False,
        'delete': False
    }, acq_invoice_fiction_martigny)
    check_permission(AcqInvoicePermissionPolicy, {
        'search': True,
        'read': False,
        'create': False,
        'update': False,
        'delete': False
    }, acq_invoice_fiction_sion)
    # As staff member with "library-administration" role :
    #   - Search :: everything
    #   - Read :: record of its own library
    #   - Create/Update/Delete :: record of its own library
    login_user(librarian_martigny.user)
    check_permission(AcqInvoicePermissionPolicy, {
        'search': True,
        'read': True,
        'create': True,
        'update': True,
        'delete': True
    }, acq_invoice_fiction_martigny)
    check_permission(AcqInvoicePermissionPolicy, {
        'search': True,
        'read': False,
        'create': False,
        'update': False,
        'delete': False
    }, acq_invoice_fiction_saxon)
    # As staff member with "full_permissions" role :
    #   - Search :: everything
    #   - Read :: record of its own organisation
    #   - Create/Update/Delete :: record of its own organisation
    login_user(system_librarian_martigny.user)
    check_permission(AcqInvoicePermissionPolicy, {
        'search': True,
        'read': True,
        'create': True,
        'update': True,
        'delete': True
    }, acq_invoice_fiction_saxon)
    check_permission(AcqInvoicePermissionPolicy, {
        'search': True,
        'read': False,
        'create': False,
        'update': False,
        'delete': False
    }, acq_invoice_fiction_sion)
    # Special case !!! An acquisition invoice linked to a closed budget
    # should be considerate as roll-overed and can't be updated.
    with mock.patch(
        'rero_ils.modules.acquisition.acq_invoices.api.AcquisitionInvoice.'
        'is_active',
        False
    ):
        check_permission(AcqInvoicePermissionPolicy, {
            'search': True,
            'read': True,
            'create': False,
            'update': False,
            'delete': False
        }, acq_invoice_fiction_martigny)