
components:

    schemas:

        HsOfficeCoopAssetsTransactionType:
            type: string
            enum:
                - REVERSAL
                - DEPOSIT
                - DISBURSAL
                - TRANSFER
                - ADOPTION
                - CLEARING
                - LOSS
                - LIMITATION

        HsOfficeCoopAssetsTransaction:
            type: object
            properties:
                uuid:
                    type: string
                    format: uuid
                membership.uuid:
                    type: string
                    format: uuid
                    nullable: false
                membership.memberNumber:
                    type: string
                    pattern: 'M-[0-9]{7}'
                transactionType:
                    $ref: '#/components/schemas/HsOfficeCoopAssetsTransactionType'
                assetValue:
                    type: number
                    format: currency
                valueDate:
                   type: string
                   format: date
                reference:
                    type: string
                comment:
                    type: string
                adoptionAssetTx:
                    # a TRANSFER tx must refer to the related ADOPTION tx
                    $ref: '#/components/schemas/HsOfficeRelatedCoopAssetsTransaction'
                transferAssetTx:
                    # an ADOPTION tx must refer to the related TRANSFER tx
                    $ref: '#/components/schemas/HsOfficeRelatedCoopAssetsTransaction'
                revertedAssetTx:
                    # a REVERSAL tx must refer to the related tx, which can be of any type but REVERSAL
                    $ref: '#/components/schemas/HsOfficeRelatedCoopAssetsTransaction'
                reversalAssetTx:
                    # a reverted tx, which can be any but REVERSAL, must refer to the related REVERSAL tx
                    $ref: '#/components/schemas/HsOfficeRelatedCoopAssetsTransaction'

        HsOfficeRelatedCoopAssetsTransaction:
            description:
                Similar to `HsOfficeCoopAssetsTransaction` but just the UUID of the related property, to avoid recursive JSON.
            type: object
            properties:
                uuid:
                    type: string
                    format: uuid
                membership.uuid:
                    type: string
                    format: uuid
                    nullable: false
                membership.memberNumber:
                    type: string
                    pattern: 'M-[0-9]{7}'
                transactionType:
                    $ref: '#/components/schemas/HsOfficeCoopAssetsTransactionType'
                assetValue:
                    type: number
                    format: currency
                valueDate:
                    type: string
                    format: date
                reference:
                    type: string
                comment:
                    type: string
                adoptionAssetTx.uuid:
                    description: a TRANSFER tx must refer to the related ADOPTION tx
                    type: string
                    format: uuid
                transferAssetTx.uuid:
                    description: an ADOPTION tx must refer to the related TRANSFER tx
                    type: string
                    format: uuid
                revertedAssetTx.uuid:
                    description: a REVERSAL tx must refer to the related tx, which can be of any type but REVERSAL
                    type: string
                    format: uuid
                reversalAssetTx.uuid:
                    description: a reverted tx, which can be any but REVERSAL, must refer to the related REVERSAL tx
                    type: string
                    format: uuid

        HsOfficeCoopAssetsTransactionInsert:
            type: object
            properties:
                membership.uuid:
                    type: string
                    format: uuid
                    nullable: false
                transactionType:
                    $ref: '#/components/schemas/HsOfficeCoopAssetsTransactionType'
                assetValue:
                    type: number
                    format: currency
                valueDate:
                    type: string
                    format: date
                reference:
                    type: string
                    minLength: 6
                    maxLength: 48
                comment:
                    type: string
                revertedAssetTx.uuid:
                    type: string
                    format: uuid
                adoptingMembership.uuid:
                    type: string
                    format: uuid
                adoptingMembership.memberNumber:
                    type: string
                    pattern: 'M-[0-9]{7}'
            required:
                - membership.uuid
                - transactionType
                - assetValue
                - valueDate
                - reference
            additionalProperties: false
