Skip to content

Commit

Permalink
feat: Add group-by-state support to stats APIs for expenses, advance_…
Browse files Browse the repository at this point in the history
…requests, and reports (#587)
  • Loading branch information
devadathanmb authored Dec 10, 2024
1 parent 921e7a1 commit 9c3900d
Show file tree
Hide file tree
Showing 6 changed files with 1,086 additions and 283 deletions.
364 changes: 289 additions & 75 deletions reference/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4464,23 +4464,80 @@ components:
nullable: false
type: string
description: |
This field contains the query param string similar to the query params passed in expenses GET call for displaying expenses in the list view.
example: id=in.('tx1263', 'tx1569')
Query param string similar to expenses GET call. Use group_by_state=eq.true to get state-wise grouping of stats.
example: id=in.('tx1263', 'tx1569')&group_by_state=eq.true
expenses_stats_out:
type: object
properties:
count:
type: integer
nullable: false
description: |
This field represents the total number of expenses that match the criteria specified in the query_params within the body of the request.
example: 1
total_amount:
allOf:
- $ref: '#/components/schemas/amount'
description: |
This field indicates the sum of amount of expenses that match the criteria specified in the query_params within the body of the request.
example: 100
oneOf:
- type: array
title: State-wise grouped stats
description: Stats grouped by expense state
items:
type: object
required:
- count
- total_amount
- state
properties:
count:
type: integer
nullable: false
description: Number of matching expenses in this state
example: 10
total_amount:
type: number
nullable: false
description: Sum of amounts for matching expenses in this state
example: 44545.4
state:
type: string
enum:
- COMPLETE
- DRAFT
- APPROVER_PENDING
- APPROVED
- PAYMENT_PENDING
- PAYMENT_PROCESSING
- PAID
description: Expense state
- type: object
title: Overall stats
description: Overall stats without state grouping
required:
- count
- total_amount
properties:
count:
type: integer
nullable: false
description: Total number of matching expenses
example: 353
total_amount:
type: number
nullable: false
description: Sum of amounts for all matching expenses
example: 45882.4
example:
- state: COMPLETE
count: 343
total_amount: 1337
- state: DRAFT
count: 10
total_amount: 44545.4
- state: PAID
count: 0
total_amount: 0
- state: PAYMENT_PROCESSING
count: 0
total_amount: 0
- state: APPROVER_PENDING
count: 0
total_amount: 0
- state: PAYMENT_PENDING
count: 0
total_amount: 0
- state: APPROVED
count: 0
total_amount: 0
query_params:
type: string
description: |
Expand Down Expand Up @@ -4851,26 +4908,86 @@ components:
advance_requests_stats_in:
properties:
query_params:
type: string
description: |
This field contains the query param string similar to the query params passed in advance_requests GET call for displaying advance_requests in the list view.
Query param string similar to advance_requests GET call. Use group_by_state=eq.true to get state-wise grouping of stats.
nullable: false
example: id=in.('adr1263', 'adr1569')
example: id=in.('adr1263','adr1569')&group_by_state=eq.true
advance_requests_stats_out:
type: object
properties:
count:
type: integer
description: |
This field represents the total number of advance_requests that match the criteria specified in the query_params within the body of the request.
nullable: false
example: 1
total_amount:
allOf:
- $ref: '#/components/schemas/amount'
description: |
This field indicates the sum of amount of advance_requests that match the criteria specified in the query_params within the body of the request.
example: 100
oneOf:
- type: array
title: State-wise grouped stats
description: Stats grouped by advance request state
items:
type: object
required:
- count
- total_amount
- state
properties:
count:
type: integer
nullable: false
description: Number of matching advance requests in this state.
example: 10
total_amount:
type: number
nullable: false
description: Sum of amounts for matching advance requests in this state.
example: 44545.4
state:
type: string
enum:
- DRAFT
- APPROVAL_PENDING
- APPROVED
- CANCELLED
- REJECTED
- PAID
- PULLED_BACK
- SENT_BACK
description: Advance request state.
- type: object
title: Overall stats
description: Overall stats without state grouping.
required:
- count
- total_amount
properties:
count:
type: integer
nullable: false
description: Total number of matching advance requests.
example: 353
total_amount:
type: number
nullable: false
description: Sum of amounts for all matching advance requests.
example: 45882.4
example:
- state: DRAFT
count: 10
total_amount: 44545.4
- state: APPROVAL_PENDING
count: 0
total_amount: 0
- state: APPROVED
count: 343
total_amount: 1337
- state: CANCELLED
count: 0
total_amount: 0
- state: SENT_BACK
count: 0
total_amount: 0
- state: PULLED_BACK
count: 0
total_amount: 0
- state: REJECTED
count: 0
total_amount: 0
- state: PAID
count: 0
total_amount: 0
advance_request_out_embed:
type: object
nullable: true
Expand Down Expand Up @@ -6192,51 +6309,148 @@ components:
reports_stats_in:
properties:
query_params:
nullable: false
type: string
description: |
This field contains the query param string similar to the query params passed in reports GET call for displaying reports in the list view.
example: state=eq.PAYMENT_PROCESSING&report_id=in.('rp123', 'rep1234')
reports_stats_out:
type: object
properties:
count:
type: integer
Query param string similar to reports GET call. Use group_by_state=eq.true to get state-wise grouping of stats.
nullable: false
description: |
This field indicates the count of reports.
example: 1
total_amount:
allOf:
- $ref: '#/components/schemas/amount'
description: |
This field indicates the sum of amount of reports.
example: 100
processing_amount:
allOf:
- $ref: '#/components/schemas/amount'
description: |
This field indicates the sum of reimbursable amount of reports in Processing state.
example: 101
processing_count:
type: integer
description: |
This field indicates the count of reports in Processing state.
example: 2
failed_amount:
nullable: true
anyOf:
- $ref: '#/components/schemas/amount'
- $ref: '#/components/schemas/null_field'
description: |
This field indicates the sum of reimbursable amount of reports in Processing state for which ACH has failed
example: 101
failed_count:
type: integer
nullable: true
description: |
This field indicates the count of reports in processing state for which ACH has failed.
example: 1
example: id=in.('rp123','rep1234')&group_by_state=eq.true
reports_stats_out:
oneOf:
- type: array
title: State-wise grouped stats
description: Stats grouped by report state
items:
type: object
required:
- count
- total_amount
- state
- failed_amount
- failed_count
- processing_amount
- processing_count
- reimbursable_amount
properties:
count:
type: integer
nullable: false
description: Number of matching reports in this state.
example: 5
total_amount:
type: number
nullable: false
description: Sum of amounts for matching reports in this state.
example: 2200
state:
type: string
enum:
- APPROVER_PENDING
- DRAFT
- PAYMENT_PROCESSING
- APPROVER_INQUIRY
- APPROVED
- PAYMENT_PENDING
- PAID
description: Report state.
failed_amount:
type: number
nullable: true
description: Sum of reimbursable amount for ACH-failed reports, applicable only in PAYMENT_PROCESSING state.
example: 200
failed_count:
type: integer
nullable: true
description: Count of ACH-failed reports, applicable only in PAYMENT_PROCESSING state.
example: 1
processing_amount:
type: number
nullable: true
description: Sum of reimbursable amount for processing reports, applicable only in PAYMENT_PROCESSING state.
example: 1500
processing_count:
type: integer
nullable: true
description: Count of processing reports, applicable only in PAYMENT_PROCESSING state.
example: 3
reimbursable_amount:
type: number
nullable: false
description: Sum of reimbursable amounts for matching reports in this state.
example: 500
- type: object
title: Overall stats
description: Overall stats without state grouping (response for older mobile app versions).
required:
- count
- total_amount
- processing_amount
- processing_count
- failed_amount
- failed_count
properties:
count:
type: integer
nullable: false
description: Total number of matching reports.
example: 1
total_amount:
type: number
nullable: false
description: Total sum of amounts for all matching reports.
example: 100
processing_amount:
type: number
nullable: true
description: Sum of reimbursable amounts for reports in processing state.
example: 101
processing_count:
type: integer
nullable: true
description: Count of reports in processing state.
example: 2
failed_amount:
type: number
nullable: true
description: Sum of reimbursable amounts for reports in processing state with ACH failures.
example: 101
failed_count:
type: integer
nullable: true
description: Count of reports in processing state with ACH failures.
example: 1
example:
- state: DRAFT
count: 3
failed_amount: null
failed_count: null
processing_amount: null
processing_count: null
reimbursable_amount: 200
total_amount: 350
- state: APPROVER_PENDING
count: 5
failed_amount: null
failed_count: null
processing_amount: null
processing_count: null
reimbursable_amount: 500
total_amount: 2200
- state: PAYMENT_PROCESSING
count: 5
failed_amount: 200
failed_count: 1
processing_amount: 1500
processing_count: 3
reimbursable_amount: 500
total_amount: 2200
- state: PAID
count: 0
failed_amount: null
failed_count: null
processing_amount: null
processing_count: null
reimbursable_amount: 0
total_amount: 0
report_create_and_submit_expenses:
type: object
additionalProperties: false
Expand Down
Loading

0 comments on commit 9c3900d

Please sign in to comment.