Skip to content

Commit

Permalink
feat: Add group_by_state support to advance request stats API
Browse files Browse the repository at this point in the history
  • Loading branch information
devadathanmb committed Dec 5, 2024
1 parent 733597b commit 776d383
Showing 1 changed file with 68 additions and 17 deletions.
85 changes: 68 additions & 17 deletions src/components/schemas/advance_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,80 @@ advance_request_action_in:
example: 'rpa21A2rdj2'

advance_requests_stats_in:
type: object
required:
- data
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: './fields.yaml#/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
type: array
description: |
Array containing stats objects. When group_by_state is true, contains objects for ALL possible states
(with count and total_amount as 0 for states with no matching advance requests). When false or not provided,
contains single object with aggregated stats and null state.
items:
type: object
required:
- count
- total_amount
- state
properties:
count:
type: integer
nullable: false
description: |
Number of advance requests that match the specified criteria.
example: 10
total_amount:
type: number
nullable: false
description: |
Sum of amounts for matching advance requests.
example: 44545.4
state:
type: string
nullable: true
description: |
Advance request state for grouping. null when group_by_state is false or not provided.
When group_by_state is true, response includes all possible states, with count=0
and total_amount=0 for states with no matching advance requests.
example: DRAFT
enum:
- DRAFT
- APPROVAL_PENDING
- APPROVED
- SENT_BACK
- PULLED_BACK
- REJECTED
- PAID
- null
example:
- state: "DRAFT"
count: 10
total_amount: 44545.4
- state: "APPROVAL_PENDING"
count: 0
total_amount: 0
- state: "APPROVED"
count: 343
total_amount: 1337.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
Expand Down

0 comments on commit 776d383

Please sign in to comment.