openapi: "3.0.0"
info:
  version: 1.0.0
  title: Artix VPos
  description: Виртуальная касса
servers:
  - url: http://localhost:8090
paths:
  /calculatediscount:
    post:
      summary: Расчёт скидок
      operationId: calculatediscount
      requestBody:
        description: Чек
        required: true
        content:
          application/json:
            schema:
              description: Чек
              type: object
              required:
              - identifier
              - positions
              properties:
                cashCode:
                  description: Код кассы
                  type: string
                shopCode:
                  description: Код магазина
                  type: string
                shopLabels:
                  description: Объект "Коды меток магазина"
                  type: array
                  items:
                    type: object
                    description: Код метки магазина                    
                    properties:
                      id:
                        description: Идентификатор метки
                        type: string
                identifier:
                  description: Идентификатор
                  type: string
                positions:
                  description: Объект "Позиции"
                  type: array
                  items:
                    type: object
                    description: Позиция чека
                    required:
                    - posnum
                    - barcode
                    - quant
                    properties:
                      posnum:
                        description: Номер позиции в чеке
                        type: integer
                        format: int32
                      barcode:
                        description: Штрих-код товара
                        type: string
                      minprice:
                        description: Минимальная цена товара
                        type: number
                        format: double
                      name:
                        description: Название позиции
                        type: string
                      price:
                        description: Цена товара
                        type: number
                        format: double
                      quant:
                        description: Количество товара
                        type: number
                        format: double
                      tmc:
                        $ref: '#/components/schemas/tmc'
                cards:
                  description: Объект "Карты"
                  type: array
                  items:
                    type: object
                    description: Карта
                    required:
                    - number
                    properties:
                      number:
                        description: Номер карты
                        type: string
                coupons:
                  description: Объект "Купоны"
                  type: array
                  items:
                    type: object
                    description: Купон
                    required:
                    - number
                    properties:
                      number:
                        description: Номер купона
                        type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/calculatedCheck'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
  /spendbonus:
    post:
      summary: Списание бонусов
      operationId: spendBonus
      requestBody:
        description: Чек с рассчитанными скидками
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - check
              - bonusSum
              properties:
                check:
                  $ref: '#/components/schemas/calculatedCheck'
                bonusSum:
                  type: number
                  format: double
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/calculatedCheck'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
  /total:
    post:
      summary: Удаленное закрытие чека на ФР Онлайн
      operationId: total
      requestBody:
        description: Чек с рассчитанными скидками
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - check
              - payments
              properties:
                check:
                  $ref: '#/components/schemas/calculatedCheck'
                payments:
                  description: Объект "Оплаты"
                  type: array
                  items:
                    type: object
                    description: Оплата
                    required:
                    - type
                    - amount
                    properties:
                      type:
                        description: Код типа оплаты в кассе
                        type: integer
                        format: int32
                      amount:
                        description: Сумма оплаты
                        type: number
                        format: double
                customerAddress:
                  description: Номер телефона/email клиента
                  type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/documentIdentifiers'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
  /getdocumentsinfo:
    post:
      summary: Получение информации о документе
      operationId: getdocumentsinfo
      requestBody:
        description: Идентификаторы документов
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/documentIdentifiers'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                description: Информация о в формате JSON
                type: string
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
components:
  schemas:
    error:
      description: Ошибка
      type: object
      properties:
        errorCode:
          description: Код ошибки
          type: integer
          format: int32
        url:
          description: Путь
          type: string
        message:
          description: Описание
          type: string
        errorClassName:
          description: Класс исключения
          type: string
    discount:
      description: Скидка
      type: object
      required:
      - posnum
      - campaigncode
      - campaignname
      - discountcode
      - discountname
      - discountmode
      - discountsum
      - ispositiondiscount
      - minpriceignored
      - discountrate
      - discounttype
      properties:
        campaigncode:
          description: Код акции
          type: integer
          format: int32
        campaignname:
          description: Название акции
          type: string
        cardnumber:
          description: Номер карты
          type: string
        discountcode:
          description: Код правила начисления акции
          type: integer
          format: int32
        discountmode:
          description: Тип правила начисления акции
          type: integer
          format: int32
        discountname:
          description: Наименование правила начисления акции
          type: string
        discountrate:
          description: Процент скидки
          type: number
          format: double
        discountsum:
          description: Сумма скидки
          type: number
          format: double
        discounttype:
          description: "Тип скидки: 1 - процентная; 2 - суммовая; 3 - индекс цены."
          type: integer
          format: int32
        ispositiondiscount:
          description: "Флаг на что применялась скидка: 0 - на чек; 1 - на позицию."
          type: integer
          format: int32
        minpriceignored:
          description: Флаг игнорирования минимальной цены при применении скидки
          type: boolean
        posnum:
          description: Номер позиции в чеке
          type: integer
          format: int32
        sessionid:
          type: string
    tmc:
      description: Товар
      type: object
      properties:
        minprice:
          description: Минимальная цена
          type: number
          format: double
        price:
          description: Цена
          type: number
          format: double
    calculatedCheck:
      description: Рассчитанный чек
      type: object
      required:
      - identifier
      - positions
      properties:
        cards:
          description: Объект "Карты"
          type: array
          items:
            description: Карта
            type: object
            required:
            - number
            properties:
              bonusbalance:
                description: Баланс бонусных баллов
                type: number
                format: double
              cardmode:
                description: Тип карты
                type: integer
                format: int32
              idcardgroup:
                description: Идентификационный номер группы, к которой относится карта
                type: integer
                format: int32
              namecardgroup:
                description: Имя группы, к которой относится карта
                type: string
              number:
                description: Номер карты
                type: string
        coupons:
          description: Объект "Купоны"
          type: array
          items:
            description: Купон
            type: object
            required:
            - number
            properties:
              number:
                description: Номер купона
                type: string
              type:
                description: Тип купона
                type: integer
                format: int32
        identifier:
          description: Для внутреннего использования
          type: string
        pointsForEarn:
          description: Сумма баллов для начисления
          type: number
          format: double
        pointsForSpend:
          description: Сумма баллов для списания
          type: number
          format: double
        signature:
          description: Для внутреннего использования
          type: string
        sum:
          description: Сумма документа
          type: number
          format: double
        positions:
          description: Объект "Позиции"
          type: array
          items:
            description: Позиция
            type: object
            required:
            - posnum
            - barcode
            - code
            - dept
            - measure
            - measurename
            - name
            - paymentobject
            - price
            - minprice
            - quant
            - taramode
            - vatrate
            - vatcode
            - vatsum
            properties:
              barcode:
                description: Штрих-код товара
                type: string
              code:
                description: Код товара
                type: string
              dept:
                description: Отдел
                type: integer
                format: int32
              isallowbonusspend:
                description: Можно ли списать бонусы
                type: boolean
              measure:
                description: Код единицы измерения
                type: integer
                format: int32
              measurename:
                description: Наименование единицы измерения
                type: string
              minprice:
                description: Минимальная цена товара
                type: number
                format: double
              name:
                description: Название позиции
                type: string
              paymentmethod:
                description: Признак способа расчета
                type: integer
                format: int32
              paymentobject:
                description: Признак предмета расчета
                type: integer
                format: int32
              posnum:
                description: Номер позиции в чеке
                type: integer
                format: int32
              price:
                description: Цена товара
                type: number
                format: double
              quant:
                description: Количество товара
                type: number
                format: double
              sum:
                description: Сумма со скидкой
                type: number
                format: double
              sumWithoutDiscounts:
                description: Сумма без скидки
                type: number
                format: double
              taramode:
                description: Для внутреннего использования
                type: integer
                format: int32
              vatcode:
                description: Код налога
                type: integer
                format: int32
              vatrate:
                description: Ставка налога
                type: number
                format: double
              vatsum:
                description: Сумма налога
                type: number
                format: double
              discounts:
                description: Объект "Скидки"
                type: array
                items:
                  $ref: '#/components/schemas/discount'
              earnedbonuses:
                description: Объект "Начисленные бонусы"
                type: array
                items:
                  description: Начисленные бонусы
                  type: object
                  properties:
                    amount:
                      description: Сумма начисления бонусов
                      type: number
                      format: double
                    assettimebeg:
                      description: Дата активации бонусов
                      type: string
                      format: date-time
                    assettimeend:
                      description: Дата сгорания бонусов
                      type: string
                      format: date-time
                    campaigncode:
                      description: Код акции
                      type: integer
                      format: int32
                    campaignname:
                      description: Наименование акции
                      type: string
                    cardnumber:
                      description: Номер карты
                      type: string
                    ispositionbonus:
                      description: Признак начисления на позицию
                      type: integer
                      format: int32
                    weight:
                      type: integer
                      format: int32
              spentbonuses:
                description: Объект "Списанные бонусы"
                type: array
                items:
                  $ref: '#/components/schemas/discount'
              tmc:
                $ref: '#/components/schemas/tmc'
    documentIdentifiers:
      type: object
      properties:
        identifiers:
          description: Объект "Идентификаторы документов"
          type: array
          items:
            description: Идентификатор документа
            type: string