From 9c3900d27ece24c6651ce587fb4fbbc76071c33f Mon Sep 17 00:00:00 2001 From: Devadathan M B <84301852+devadathanmb@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:28:02 +0530 Subject: [PATCH] feat: Add group-by-state support to stats APIs for expenses, advance_requests, and reports (#587) --- reference/admin.yaml | 364 ++++++++++++++++---- reference/approver.yaml | 270 +++++++++++---- reference/spender.yaml | 364 ++++++++++++++++---- src/components/schemas/advance_request.yaml | 96 +++++- src/components/schemas/expense.yaml | 92 ++++- src/components/schemas/report.yaml | 183 +++++++--- 6 files changed, 1086 insertions(+), 283 deletions(-) diff --git a/reference/admin.yaml b/reference/admin.yaml index 04009776e..8617255cb 100644 --- a/reference/admin.yaml +++ b/reference/admin.yaml @@ -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: | @@ -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 @@ -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 diff --git a/reference/approver.yaml b/reference/approver.yaml index d3e19aed9..16a965aa9 100644 --- a/reference/approver.yaml +++ b/reference/approver.yaml @@ -2688,51 +2688,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_comments_in: type: object additionalProperties: false @@ -3565,23 +3662,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 expense_filters_out: type: object additionalProperties: false diff --git a/reference/spender.yaml b/reference/spender.yaml index 95cc4bb33..0e720866c 100644 --- a/reference/spender.yaml +++ b/reference/spender.yaml @@ -3251,51 +3251,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_purpose_in: type: object additionalProperties: false @@ -3887,26 +3984,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 @@ -7790,23 +7947,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 expense_filters_out: type: object additionalProperties: false diff --git a/src/components/schemas/advance_request.yaml b/src/components/schemas/advance_request.yaml index 017a0eaf5..32b210963 100644 --- a/src/components/schemas/advance_request.yaml +++ b/src/components/schemas/advance_request.yaml @@ -151,27 +151,89 @@ advance_request_action_in: 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: './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 + 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." + # NOTE: This is a hack to maintain backward compatibility with the existing response structure + # TODO: @Dev to update the response once the hack is removed from platform-api + - 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.0 + - 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 diff --git a/src/components/schemas/expense.yaml b/src/components/schemas/expense.yaml index 78dfe4671..2660fcd0d 100644 --- a/src/components/schemas/expense.yaml +++ b/src/components/schemas/expense.yaml @@ -1653,24 +1653,84 @@ expenses_stats_in: 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: './fields.yaml#/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 + # NOTE: This is a hack to maintain backward compatibility with the existing response structure + # TODO: @Dev to update the response once the hack is removed from platform-api + - 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.0 + - 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 + accounting_export_summary_in: type: object diff --git a/src/components/schemas/report.yaml b/src/components/schemas/report.yaml index c7403f7aa..ae62ac585 100644 --- a/src/components/schemas/report.yaml +++ b/src/components/schemas/report.yaml @@ -956,52 +956,151 @@ process_summary_out: 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') + Query param string similar to reports GET call. Use group_by_state=eq.true to get state-wise grouping of stats. + nullable: false + example: id=in.('rp123','rep1234')&group_by_state=eq.true reports_stats_out: - type: object - properties: - count: - type: integer - nullable: False - description: | - This field indicates the count of reports. - example: 1 - total_amount: - allOf: - - $ref: './fields.yaml#/amount' - description: | - This field indicates the sum of amount of reports. - example: 100 - processing_amount: - allOf: - - $ref: './fields.yaml#/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: './fields.yaml#/amount' - - $ref: './fields.yaml#/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 + 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.0 + 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.0 + 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.0 + 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.0 + # NOTE: This is a hack to maintain backward compatibility with the existing response structure + # TODO: @Dev to update the response once the hack is removed from platform-api + - 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.0 + total_amount: 350.0 + - state: "APPROVER_PENDING" + count: 5 + failed_amount: null + failed_count: null + processing_amount: null + processing_count: null + reimbursable_amount: 500.0 + total_amount: 2200.0 + - state: "PAYMENT_PROCESSING" + count: 5 + failed_amount: 200.0 + failed_count: 1 + processing_amount: 1500.0 + processing_count: 3 + reimbursable_amount: 500.0 + total_amount: 2200.0 + - state: "PAID" + count: 0 + failed_amount: null + failed_count: null + processing_amount: null + processing_count: null + reimbursable_amount: 0.0 + total_amount: 0.0 report_create_and_submit_expenses: type: object