# Edit Visit

Update the attendance status, bill comment, Services, Product Items, and
payments of a visit.
> **This is a replace operation for the whole visit.** `services` and
`goods_transactions` replace every Service line and every Product Item of
the visit, not only those of `record_id`. A list that is omitted
defaults to `[]` and deletes all its lines. There is no append. Read the
visit first and echo every line exactly.

### How to work with this operation
- `comment` is required and overwrites the visit's bill (document)
comment, not the Appointment comment. Echo the current bill comment.
- `attendance` is required. When the Business User has the right to sell
Products in Appointments, a status other than arrived (`1`) or confirmed
(`2`) deletes every Product Item of the visit and cancels all its
payments.
- `services` must list every Service line of every Appointment of the
visit, each with its `record_id`; a line without `record_id` returns
`422`. An Appointment whose lines are missing loses them, and a changed
set of Services sends the Booking User a "record changed" message.
- `goods_transactions` must list every Product Item of the visit. A line
with `id` updates that line, a line without `id` is created, and an
existing line that is not sent is deleted together with any gift card or
membership it issued.
- Without the right to sell Products in Appointments,
`goods_transactions` is ignored and the request still returns `200`.
Read the visit back to confirm the change. This operation does not
check the finer Product rights (create, edit, price, discount, and their
day limits) that
[Save Visit Appointments](/en/b2b-v2/openapi#tag/Appointments/operation/save_attendance_appointments)
enforces.
- A printed sale bill refuses Product Item changes (`400`), and refuses
`deleted_transaction_ids` (`422`).
- When the Location forbids negative stock, a line that would take an
Inventory below zero returns `406`. Otherwise stock may go negative.
- A gift card line needs `good_special_number` unless its type allows an
empty code. A membership whose type expires on a specific date needs
`good_planned_activation_date`. Echo both for existing gift card and
membership lines; otherwise the save fails or re-issues them.
- Product Item changes re-apply the Booking User's loyalty discount
programs to the visit. Send `cost` from the read's `manual_cost`, never
from the read's `cost`, which already includes loyalty discounts and
would be discounted twice. Read the lines back after the save.
- Every save sends the partner webhook "record update" for the
Appointments of the visit.

Endpoint: PUT /visits/{visit_id}/{record_id}
Version: 1.0.0
Security: BearerPartnerUser

## Description:

  - `How to work with this operation` ()
    - `comment` is required and overwrites the visit's bill (document)
comment, not the Appointment comment. Echo the current bill comment.
- `attendance` is required. When the Business User has the right to sell
Products in Appointments, a status other than arrived (`1`) or confirmed
(`2`) deletes every Product Item of the visit and cancels all its
payments.
- `services` must list every Service line of every Appointment of the
visit, each with its `record_id`; a line without `record_id` returns
`422`. An Appointment whose lines are missing loses them, and a changed
set of Services sends the Booking User a "record changed" message.
- `goods_transactions` must list every Product Item of the visit. A line
with `id` updates that line, a line without `id` is created, and an
existing line that is not sent is deleted together with any gift card or
membership it issued.
- Without the right to sell Products in Appointments,
`goods_transactions` is ignored and the request still returns `200`.
Read the visit back to confirm the change. This operation does not
check the finer Product rights (create, edit, price, discount, and their
day limits) that
[Save Visit Appointments](/en/b2b-v2/openapi#tag/Appointments/operation/save_attendance_appointments)
enforces.
- A printed sale bill refuses Product Item changes (`400`), and refuses
`deleted_transaction_ids` (`422`).
- When the Location forbids negative stock, a line that would take an
Inventory below zero returns `406`. Otherwise stock may go negative.
- A gift card line needs `good_special_number` unless its type allows an
empty code. A membership whose type expires on a specific date needs
`good_planned_activation_date`. Echo both for existing gift card and
membership lines; otherwise the save fails or re-issues them.
- Product Item changes re-apply the Booking User's loyalty discount
programs to the visit. Send `cost` from the read's `manual_cost`, never
from the read's `cost`, which already includes loyalty discounts and
would be discounted twice. Read the lines back after the save.
- Every save sends the partner webhook "record update" for the
Appointments of the visit.

## Security:

  - `BearerPartnerUser` (unknown)
    http bearer Bearer {PartnerToken}, User {UserToken}

## Path parameters:

  - `visit_id` (number, required)

  - `record_id` (number, required)

## Header parameters:

  - `Accept` (string, required)
    e.g. application/vnd.api.v2+json

  - `Content-Type` (string, required)
    application/json

  - `Authorization` (string, required)
    Bearer partner_token, User user_token

## Request fields (*/*):

  - `attendance` (number, required)
    Visit status (2 - The user confirmed the appointment, 1 - The user came, the services were provided, 0 - the user is waiting, -1 - the user did not show)

  - `comment` (string, required)
    A comment

  - `new_transactions` (array)
    Array of objects of new commodity transactions

  - `new_transactions.id` (number)
    Financial transaction ID

  - `new_transactions.amount` (number)
    Sum

  - `new_transactions.account_id` (number)
    Checkout ID

  - `deleted_transaction_ids` (array)
    IDs of visit payments (financial transactions) to delete. Applied only
with the Appointment finances right and without `fast_payment`.

  - `goods_transactions` (array)
    Every Product Item of the visit. The list replaces the visit's Product
Items: send each existing line with its `id`, add a line without `id`
to create it, and leave a line out to delete it.

  - `goods_transactions.id` (integer)
    Product Item (inventory transaction) ID. Required to keep an existing line; omit it to create a line.

  - `goods_transactions.title` (string)
    Ignored

  - `goods_transactions.barcode` (string)
    Ignored

  - `goods_transactions.article` (string)
    Ignored

  - `goods_transactions.amount` (number)
    Quantity in sale units, as a positive number. The read returns it as a negative number; send its absolute value.

  - `goods_transactions.cost_per_unit` (number)
    Ignored; send the unit price in `price`

  - `goods_transactions.price` (number)
    Unit price before discount. Echo the read's `cost_per_unit`; for a new line, use the Product's sale price.

  - `goods_transactions.cost` (number)
    Line total after `discount` and before loyalty programs: `round(price × amount × (100 − discount) / 100, 2)`. Echo the read's `manual_cost`.

  - `goods_transactions.discount` (number)
    Discount in percent

  - `goods_transactions.operation_unit_type` (integer)
    1 - sold to the Booking User (sale unit), 2 - written off as a Service consumable (consumption unit)
    Enum: "1", "2"

  - `goods_transactions.master_id` (integer)
    Team Member ID credited with the sale

  - `goods_transactions.storage_id` (integer)
    Inventory ID the Product is written off from

  - `goods_transactions.good_id` (integer)
    Product ID

  - `goods_transactions.good_special_number` (string)
    Gift card or membership number. Echo it for existing gift card and membership lines.

  - `goods_transactions.good_planned_activation_date` (string)
    Planned membership activation date (`YYYY-MM-DD`). Required when the membership type expires on a specific date; echo it for existing membership lines.

  - `goods_transactions.goods_marks` (array)
    Goods marking codes of the line. Echo them for marked Products.

  - `services` (array)
    Every Service line of every Appointment of the visit. The list replaces
the visit's Service lines; an Appointment whose lines are missing loses
them.

  - `services.id` (number, required)
    Service ID

  - `services.title` (string)
    Ignored

  - `services.cost` (number)
    Line total after discount. Echo the read's `manual_cost`.

  - `services.cost_per_unit` (number)
    Ignored; send the unit price in `first_cost`

  - `services.discount` (number)
    Discount in percent

  - `services.first_cost` (number)
    Unit price before discount. Echo the read's `cost_per_unit`.

  - `services.amount` (integer)
    Number of Service units

  - `services.record_id` (number, required)
    Appointment ID the line belongs to

  - `fast_payment` (number)
    Quick payment 1 - cash, 2 - cashless, 129 - cash and print, 130 - cashless and print

## Response 200:

  - `200` (unknown)
    OK

## Response 401:

  - `401` (unknown)
    Unauthorized

## Response 401 fields (application/json):

  - `success` (boolean)
    Response status.
    Example: false

  - `data` (object | null)
    Response data.
    Example: null

  - `meta` (object)
    Additional response data.

  - `meta.message` (string)
    Error message.
    Example: Authentication needed.

## Response 403:

  - `403` (unknown)
    Forbidden

## Response 403 fields (application/json):

  - `success` (boolean)
    Response status.
    Example: false

  - `data` (object | null)
    Response data.
    Example: null

  - `meta` (object)
    Additional response data.

  - `meta.message` (string)
    Error message.
    Example: Access denied.

## Response 404:

  - `404` (unknown)
    Not Found

## Response 404 fields (application/json):

  - `success` (boolean)
    Response status.
    Example: false

  - `data` (object | null)
    Response data.
    Example: null

  - `meta` (object | array)
    Additional response data (empty object or empty array)
    Example: {}

