
components:

    schemas:

        HsOfficeCoopSharesTransactionType:
            type: string
            enum:
                - REVERSAL
                - SUBSCRIPTION
                - CANCELLATION

        HsOfficeCoopSharesTransaction:
            type: object
            properties:
                uuid:
                    type: string
                    format: uuid
                membership.uuid:
                    type: string
                    format: uuid
                    nullable: false
                transactionType:
                    $ref: '#/components/schemas/HsOfficeCoopSharesTransactionType'
                shareCount:
                    type: integer
                valueDate:
                   type: string
                   format: date
                reference:
                    type: string
                comment:
                    type: string
                revertedShareTx:
                    $ref: '#/components/schemas/HsOfficeReferencedCoopSharesTransaction'
                reversalShareTx:
                    $ref: '#/components/schemas/HsOfficeReferencedCoopSharesTransaction'

        HsOfficeReferencedCoopSharesTransaction:
            description:
                Similar to `HsOfficeCoopSharesTransaction` but without the self-referencing properties
                (`revertedShareTx` and `reversalShareTx`), to avoid recursive JSON.
            type: object
            properties:
                uuid:
                    type: string
                    format: uuid
                membership.uuid:
                    type: string
                    format: uuid
                    nullable: false
                transactionType:
                    $ref: '#/components/schemas/HsOfficeCoopSharesTransactionType'
                shareCount:
                    type: integer
                valueDate:
                    type: string
                    format: date
                reference:
                    type: string
                comment:
                    type: string

        HsOfficeCoopSharesTransactionInsert:
            type: object
            properties:
                membership.uuid:
                    type: string
                    format: uuid
                    nullable: false
                transactionType:
                    $ref: '#/components/schemas/HsOfficeCoopSharesTransactionType'
                shareCount:
                    type: integer
                valueDate:
                    type: string
                    format: date
                reference:
                    type: string
                    minLength: 6
                    maxLength: 48
                comment:
                    type: string
                revertedShareTx.uuid:
                    type: string
                    format: uuid
            required:
                - membership.uuid
                - transactionType
                - shareCount
                - valueDate
                - reference
            additionalProperties: false
