def test_staff_matter_report2(snapshot, request): """ Test matter report query with billable status 2 must return empty data, there are no matter with this status""" manager = UserFactory(is_staff=True, is_active=True) MatterFactory.create_batch(size=3, manager=manager, billable_status=1) request.user = manager client = Client(schema, context=request) executed = client.execute(""" query staffMatterReportMatter( $after: String $staffName: String $billableStatus: String $billableStatusExclude: Float ) { matters( first: 15 after: $after staffName: $staffName billableStatus: $billableStatus billableStatusExclude: $billableStatusExclude ) { edges { cursor node { id name totalTimeValue totalTimeInvoiced wip billableStatusDisplay daysOpen matterStatusDisplay client { id name } } } pageInfo { endCursor hasNextPage } } } """, variable_values={ 'staffName': manager.full_name, 'billableStatus': 2, 'billableStatusExclude': 3, }) snapshot.assert_match(executed)
def test_staff_principal_matter_report3(snapshot, request): """ Test principal matter report query with 2 billable statuse""" manager = UserFactory(is_staff=True, is_active=True) MatterFactory.create_batch(size=3, principal=manager, billable_status=2) MatterFactory.create_batch(size=3, principal=manager, billable_status=1) request.user = manager client = Client(schema, context=request) executed = client.execute(""" query staffMatterReportMatter( $after: String $principalName: String $billableStatus: String ) { matters( first: 15 after: $after principalName: $principalName billableStatus: $billableStatus ) { edges { cursor node { id name totalTimeValue totalTimeInvoiced wip billableStatusDisplay daysOpen matterStatusDisplay client { id name } } } pageInfo { endCursor hasNextPage } } } """, variable_values={ 'principalName': manager.full_name, 'billableStatus': 2, }) snapshot.assert_match(executed)
def test_open_matters_reports(snapshot, request): """ Test success open matters reports """ MatterFactory.create_batch(size=3, billable_status=3, created_date=date(2018, 8, 17)) client = Client(schema) executed = client.execute(""" query openMattersReports { openMattersReports { id date count } } """) snapshot.assert_match(executed)
def test_total_of_matters_by_staff_reports(snapshot, request): """ Test success total of matters by staff reports """ staff_members = UserFactory.create_batch(size=3, ) MatterFactory.create_batch(size=3, created_date='2015-04-20') MatterFactory.create_batch( size=3, created_date='2018-08-21', ) client = Client(schema) executed = client.execute( """ query totalOfMattersByStaffReports( $staffMembers: [ID], $matterStatus: Int ) { totalOfMattersByStaffReports( staffMembers: $staffMembers, matterStatus: $matterStatus, ) { id date staffMembers{ id } } } """, variable_values={ 'staffMembers': [ to_global_id('UserType', staff_member.id) for staff_member in staff_members ], 'matterStatus': 1, }, ) snapshot.assert_match(executed)
def test_invoices_query(snapshot, request): """ Test invoices query""" client_instance = ClientFactory() matter_instance = MatterFactory(client=client_instance, ) InvoiceFactory(id=1231, matter=matter_instance) InvoiceFactory(id=4322, matter=matter_instance) InvoiceFactory(id=3233, matter=matter_instance) staff_member = UserFactory(id=1) request.user = staff_member client = Client(schema, context=request) query = client.execute(""" query getInvoices { invoices(first: 3) { edges { node { statusDisplay valueExGst valueInclGst receivedPayments netOutstanding history totalBilledValue isPaid dueDate number friendlyReminder firstReminder secondReminder timeEntries{ edges{ node{ description } } } billingMethod timeEntryValue fixedPriceValue canSendXero isInXero } } } } """) snapshot.assert_match(query)
def test_invoices_number_or_client_name_filter_with_str(snapshot, request): """ Test invoices number or client name filter with string value""" client_instance = ClientFactory(organisation=None, contact=ContactFactory(first_name='first', last_name='last'), second_contact=None) matter_instance = MatterFactory(client=client_instance, ) InvoiceFactory(id=6735, matter=matter_instance) InvoiceFactory(id=7845, matter=matter_instance) InvoiceFactory(id=9965, matter=matter_instance) staff_member = UserFactory(id=1) request.user = staff_member client = Client(schema, context=request) query = client.execute(""" query getInvoices($numberOrClientName: String) { invoices(first: 3, numberOrClientName: $numberOrClientName) { edges { node { id matter{ id name client { id name } } } } } } """, variable_values={ 'numberOrClientName': client_instance.name, }) snapshot.assert_match(query)