# Calculate Reverse Totals

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/managers/reverse-credit-note/totals:
    post:
      summary: Calculate Reverse Totals
      deprecated: false
      description: >+
        Calculates the refund totals for a reverse order before creating the
        actual reverse order.


        **This endpoint is typically used to:**


        - Preview refund amounts for full or partial returns

        - Show customers or operators a breakdown of refund totals `(subtotal,
        discounts, VAT, total)`

        - Validate selected return products and quantities prior to reverse
        order creation



        :::info[]

        ## ⚠️ Important


        - This endpoint does not create a reverse order.

        - No stock changes, refunds, or order status updates occur.

        - It is a read-only calculation based on provided inputs.

        :::

      tags:
        - Default module/Apps/Merchant APIs/Reverse Orders
      parameters:
        - name: Authorization
          in: header
          description: >-
            The Authorization token is a unique key given to the third-party
            application (Partner) by Zid. It is used to authenticate the API
            requests made by the Partner application. The token verifies the
            partner's identity and ensures they have permission to access Zid's
            API but does not provide any specific user or store information. It
            should be included in the header of API requests when the partner
            application needs to access Zid's API.
          required: true
          example: '{{Autherization}}'
          schema:
            type: string
        - name: X-MANAGER-TOKEN
          in: header
          description: >-
            Unique manager token used to authorize requests at a manager level,
            specific to each partner.
          required: true
          example: '{{Access-Token}}'
          schema:
            type: string
        - name: Accept-Language
          in: header
          description: Language preference.
          required: true
          example: en
          schema:
            type: string
        - name: Accept
          in: header
          description: ''
          required: false
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                order_id:
                  type: integer
                  example: 64085792
                is_partial:
                  type: integer
                  enum:
                    - 0
                    - 1
                  x-apidog-enum:
                    - value: 0
                      name: ''
                      description: ''
                    - value: 1
                      name: ''
                      description: ''
                  example: 1
                products[0][order_product_id]:
                  type: integer
                  example: 110166397
                products[0][quantity]:
                  type: integer
                  example: 1
              required:
                - order_id
                - is_partial
            examples: {}
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  invoice:
                    type: array
                    items:
                      type: object
                      x-apidog-refs: {}
                      x-apidog-orders:
                        - code
                        - value
                        - value_string
                        - title
                      properties:
                        code:
                          type: string
                        value:
                          type: number
                        value_string:
                          type: string
                        title:
                          type: string
                      required:
                        - code
                        - value
                        - value_string
                        - title
                      x-apidog-ignore-properties: []
                required:
                  - invoice
                x-apidog-orders:
                  - invoice
                x-apidog-ignore-properties: []
              example:
                invoice:
                  - code: sub_totals
                    value: 173.5304338832
                    value_string: 173.53 SAR
                    title: Sub Total
                  - code: discounts
                    value: 0
                    value_string: 0.00 SAR
                    title: Discount
                  - code: sub_total_after_discounts
                    value: 173.5304338832
                    value_string: 173.53 SAR
                    title: Subtotal After Discounts
                  - code: vat
                    value: 26.02956508248
                    value_string: 26.03 SAR
                    title: VAT (%15)
                  - code: total
                    value: 199.55999896568
                    value_string: 199.56 SAR
                    title: Total
          headers: {}
          x-apidog-name: OK
        '401':
          description: ''
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Response returned when the request cannot be authenticated
                  because the required credentials are missing, invalid, or
                  expired.
                properties:
                  status:
                    type: string
                    description: Indicates the overall status of the API response.
                    examples:
                      - error
                  message:
                    type: object
                    description: >-
                      Contains structured details explaining why the request
                      could not be authenticated.
                    properties:
                      type:
                        type: string
                        description: Indicates the category of the response message.
                        examples:
                          - error
                      code:
                        type: string
                        description: >-
                          A machine-readable code identifying the authentication
                          error. Returns null when no specific code is
                          available.
                        examples:
                          - UNAUTHORIZED
                        nullable: true
                      name:
                        type: string
                        description: >-
                          A short, human-readable title describing the
                          authentication error. Returns null when no title is
                          available.
                        examples:
                          - Unauthorized
                        nullable: true
                      description:
                        type: string
                        description: >-
                          A human-readable explanation of why the request could
                          not be authenticated. Returns null when no detailed
                          explanation is available.
                        examples:
                          - >-
                            Authentication credentials are missing, invalid, or
                            expired.
                        nullable: true
                    required:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-orders:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                examples:
                  - status: error
                    message:
                      type: error
                      code: UNAUTHORIZED
                      name: Unauthorized
                      description: >-
                        Authentication credentials are missing, invalid, or
                        expired.
                x-apidog-ignore-properties: []
              examples:
                '6':
                  summary: Example 1
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_MISSING
                      name: Sorry
                      description: Please login first.
                '7':
                  summary: Example 2
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_INVALID
                      name: Sorry
                      description: Login session expired. Please login again.
                '8':
                  summary: Example 3
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_INVALID
                      name: Sorry
                      description: Invalid authentication
          headers: {}
          x-apidog-name: Unauthorized
        '404':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message: &ref_0
                    $ref: '#/components/schemas/ResponseEnvelopMessage'
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                x-apidog-ignore-properties: []
              example:
                status: error
                message:
                  type: error
                  code: ERROR_POPUP_BACK
                  name: Sorry
                  description: Order not found
          headers: {}
          x-apidog-name: Not found
        '422':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message: *ref_0
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                x-apidog-ignore-properties: []
              example:
                status: validation_error
                message:
                  type: validation_errors
                  code: ERROR_POPUP_OK
                  name: Inputs
                  description: Input errors!
                  validations:
                    - field: order_id
                      errors:
                        - The order id field is required.
          headers: {}
          x-apidog-name: Validation errors
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Status of the error.
                  message: *ref_0
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                x-apidog-ignore-properties: []
              example:
                status: error
                message:
                  type: error
                  code: MSG_HIDDEN
                  name: Error
                  description: Internal Server Error
          headers: {}
          x-apidog-name: Internal Server error
        x-422:Execution Exception:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message: *ref_0
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                x-apidog-ignore-properties: []
              example:
                status: error
                message:
                  type: error
                  code: null
                  name: null
                  description: >-
                    Product reversed quantity (2) is not available in original
                    order
          headers: {}
          x-apidog-name: Execution Exception
        x-500:Server Error:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
                x-apidog-orders:
                  - message
                x-apidog-ignore-properties: []
              example:
                message: Server Error
          headers: {}
          x-apidog-name: Server Error
      security: []
      x-apidog-folder: Default module/Apps/Merchant APIs/Reverse Orders
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/613905/apis/api-27460874-run
components:
  schemas:
    ResponseEnvelopMessage:
      type: object
      properties:
        type:
          type: string
          description: Type of response message returned by the API.
          examples:
            - success
        code:
          type: string
          description: Response code returned by the API, if available.
          examples:
            - MSG_POPUP_OK
          nullable: true
        name:
          type: string
          description: Name or title of the response message, if available.
          examples:
            - Coupons
          nullable: true
        description:
          type: string
          description: Detailed description of the response message, if available.
          examples:
            - Coupons created successfully
          nullable: true
      required:
        - type
        - code
        - name
        - description
      description: Additional response metadata.
      x-apidog-orders:
        - type
        - code
        - name
        - description
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes: {}
servers:
  - url: https://api.zid.sa/
    description: Prod Env
security: []

```
