# Cancellations and returns

> Correcting a recorded receipt: cancellation, returned goods, invoice payment refund and invoice credit note.

Source: https://ekasa.ninedigit.sk/en/docs/receipt-registration/corrections

A recorded receipt cannot be changed or deleted. You correct a mistake or a return of goods with **a new receipt**
that refers to the original one.

A receipt correction can have different causes, so recording it in the eKasa system differs too. This article
describes the situations that can arise when correcting receipts and the procedure for each of them.

## Which procedure to use

| Situation | Procedure | New receipt | Item type |
|---|---|---|---|
| the cash register operator made a mistake | [Receipt cancellation](#receipt-cancellation) | `cash_register` | `correction` |
| the customer returns purchased goods | [Returned goods](#returned-goods) | `cash_register` | `returned` |
| the customer paid an invoice in cash and the payment needs to be refunded | [Invoice payment refund](#invoice-payment-refund) | `cash_register` | `correction` |
| crediting an invoice paid other than in cash (for example by bank transfer) | [Invoice credit note](#invoice-credit-note) | `invoice` with a negative amount | no items |

For a cancellation, returned goods and an invoice payment refund, every correcting item refers to the original
receipt in the `referenceReceiptId` field: it contains the unique identifier (or `OKP`) of the original receipt.
Where to find it is described in [Registration result](https://ekasa.ninedigit.sk/en/docs/receipt-registration/result).

## Receipt cancellation

If a receipt that has already been issued needs to be corrected (receipt cancellation, returned goods and so on),
register a new receipt. It contains the receipt items to be corrected, with these differences:

| Item field | Value in the new receipt |
|---|---|
| `type` | `correction` instead of the original type |
| `unitPrice`, `price` | the original prices multiplied by `-1` to get the opposite turnover |
| `referenceReceiptId` | the unique identifier (or `OKP`) of the original receipt |

### Example

The original receipt: two Coca Colas at €1.99 with a €1 loyalty discount, €2.98 in total paid in cash. The
cancellation receipt contains both items as `correction` with opposite prices and refers to the identifier of the
original receipt (`UID` at its bottom).

**Original receipt**

[Image: Original receipt: Coca Cola 2 pcs at €1.99, loyalty discount −€1.00, total €2.98 in cash]

**Cancellation receipt**

[Image: Cancellation receipt: Coca Cola −€3.98 and loyalty discount €1.00 with the original receipt identifier, total −€2.98]

Original receipt:

```http
POST {server_address}/api/v1/requests/receipts/cash_register

{
  "print": {
    "printerName": "pdf"
  },
  "request": {
    "data": {
      "cashRegisterCode": "88812345678900001",
      "items": [
        {
          "type": "positive",
          "name": "Coca Cola",
          "quantity": {
            "amount": 2.00,
            "unit": "ks"
          },
          "unitPrice": 1.99,
          "price": 3.98,
          "vatRate": 23.00
        },
        {
          "type": "discount",
          "name": "Vernostná zľava",
          "quantity": {
            "amount": 1.00
          },
          "unitPrice": -1.00,
          "price": -1.00,
          "vatRate": 23.00
        }
      ],
      "payments": [
        {
          "name": "Hotovosť",
          "amount": 2.98
        }
      ]
    }
  }
}
```

Cancellation receipt:

**HTTP API:**

```http
POST {server_address}/api/v1/requests/receipts/cash_register

{
  "print": {
    "printerName": "pdf"
  },
  "request": {
    "data": {
      "cashRegisterCode": "88812345678900001",
      "items": [
        {
          "type": "correction",
          "referenceReceiptId": "O-40198CCAA6D54C46998CCAA6D56-TEST",
          "name": "Coca Cola",
          "quantity": {
            "amount": 2.00,
            "unit": "ks"
          },
          "unitPrice": -1.99,
          "price": -3.98,
          "vatRate": 23.00
        },
        {
          "type": "correction",
          "referenceReceiptId": "O-40198CCAA6D54C46998CCAA6D56-TEST",
          "name": "Vernostná zľava",
          "quantity": {
            "amount": 1.00
          },
          "unitPrice": 1.00,
          "price": 1.00,
          "vatRate": 23.00
        }
      ],
      "payments": [
        {
          "name": "Hotovosť",
          "amount": -2.98
        }
      ]
    }
  }
}
```

**.NET library:**

```csharp
var original = "O-40198CCAA6D54C46998CCAA6D56-TEST";

var items = new ReceiptItems
{
    new ReceiptItem(ReceiptItemType.Correction, "Coca Cola", -1.99m, new Quantity(2, "ks"), 23m,
        referenceReceiptId: original),
    new ReceiptItem(ReceiptItemType.Correction, "Vernostná zľava", 1.00m, 1, 23m,
        referenceReceiptId: original)
};

var receipt = new CashRegisterReceipt("88812345678900001", items)
{
    Payments = new ReceiptPayments { new ReceiptPayment("Hotovosť", -2.98m) }
};

RegisterReceiptResult result = await client.RegisterReceiptAsync(
    new RegisterCashRegisterReceiptRequest(receipt),
    RegisterReceiptPrintContext.CreatePos(),
    cancellationToken);
```

## Returned goods

If the customer returns purchased goods, register a new receipt containing the receipt items that are returned:

| Item field | Value in the new receipt |
|---|---|
| `type` | `returned` instead of the original type |
| `quantity.amount` | the number of returned units, a positive number |
| `unitPrice`, `price` | negative, as in the examples below |
| `referenceReceiptId` | the unique identifier (or `OKP`) of the original receipt |

If a discount applies to the item, you have two options:

| Option | How | Example |
|---|---|---|
| merge the item with its discount | return the original positive item and its discount as one `returned` item whose total equals the price of the positive item plus the related discount | [Example 1](#example-1) |
| return the discount separately | register the discount item as a positive item (`positive`) | [Example 2](#example-2) |

In both examples the customer returns goods from the same original receipt as in the [cancellation](#example):
two Coca Colas at €1.99 with a €1 loyalty discount, €2.98 in total paid in cash.

### Example 1

Coca Cola and the discount in one returned item: 2 pcs at −€1.49, −€2.98 in total (−€3.98 + €1.00).

**Original receipt**

[Image: Original receipt: Coca Cola 2 pcs at €1.99, loyalty discount −€1.00, total €2.98 in cash]

**Receipt with returned goods**

[Image: Receipt with returned goods: Coca Cola −2 pcs at €1.49, total −€2.98, with the original receipt identifier]

**HTTP API:**

```http
POST {server_address}/api/v1/requests/receipts/cash_register

{
  "print": {
    "printerName": "pdf"
  },
  "request": {
    "data": {
      "cashRegisterCode": "88812345678900001",
      "items": [
        {
          "type": "returned",
          "referenceReceiptId": "O-40198CCAA6D54C46998CCAA6D56-TEST",
          "name": "Coca Cola",
          "quantity": {
            "amount": 2.00,
            "unit": "ks"
          },
          "unitPrice": -1.49,
          "price": -2.98,
          "vatRate": 23.00
        }
      ],
      "payments": [
        {
          "name": "Hotovosť",
          "amount": -2.98
        }
      ]
    }
  }
}
```

**.NET library:**

```csharp
var items = new ReceiptItems
{
    new ReceiptItem(ReceiptItemType.Returned, "Coca Cola", -1.49m, new Quantity(2, "ks"), 23m,
        referenceReceiptId: "O-40198CCAA6D54C46998CCAA6D56-TEST")
};
```

Register the receipt as in the [cancellation](#example), with the payment `new ReceiptPayment("Hotovosť", -2.98m)`.

### Example 2

Coca Cola as a returned item at the original price and the loyalty discount returned as a positive item
“Vrátenie zľavy” (discount refund). VAT rates for a discount refund are described in
[Receipt items](https://ekasa.ninedigit.sk/en/docs/receipt-registration/items).

**Original receipt**

[Image: Original receipt: Coca Cola 2 pcs at €1.99, loyalty discount −€1.00, total €2.98 in cash]

**Receipt with returned goods**

[Image: Receipt with returned goods: Coca Cola −€3.98 with the original receipt identifier and a discount refund of €1.00, total −€2.98]

**HTTP API:**

```http
POST {server_address}/api/v1/requests/receipts/cash_register

{
  "print": {
    "printerName": "pdf"
  },
  "request": {
    "data": {
      "cashRegisterCode": "88812345678900001",
      "items": [
        {
          "type": "returned",
          "referenceReceiptId": "O-40198CCAA6D54C46998CCAA6D56-TEST",
          "name": "Coca Cola",
          "quantity": {
            "amount": 2.00,
            "unit": "ks"
          },
          "unitPrice": -1.99,
          "price": -3.98,
          "vatRate": 23.00
        },
        {
          "type": "positive",
          "name": "Vrátenie zľavy",
          "quantity": {
            "amount": 1.00
          },
          "unitPrice": 1.00,
          "price": 1.00,
          "vatRate": 23.00
        }
      ],
      "payments": [
        {
          "name": "Hotovosť",
          "amount": -2.98
        }
      ]
    }
  }
}
```

**.NET library:**

```csharp
var items = new ReceiptItems
{
    new ReceiptItem(ReceiptItemType.Returned, "Coca Cola", -1.99m, new Quantity(2, "ks"), 23m,
        referenceReceiptId: "O-40198CCAA6D54C46998CCAA6D56-TEST"),
    new ReceiptItem(ReceiptItemType.Positive, "Vrátenie zľavy", 1.00m, 1, 23m)
};
```

Register the receipt as in the [cancellation](#example), with the payment `new ReceiptPayment("Hotovosť", -2.98m)`.

## Invoice payment refund

A cash payment of an invoice registered in the eKasa system with an `invoice` receipt is refunded similarly to
returned goods: create a cash register receipt (a `cash_register` receipt) with the following item:

| Item field | Value |
|---|---|
| `type` | `correction` |
| `unitPrice`, `price` | the negative amount of the original cash payment of the invoice |
| `referenceReceiptId` | the identifier of the original receipt, the invoice payment |
| `name` | for example “Vrátenie úhrady faktúry číslo …” (refund of invoice payment number …) |

**Cash payment of an invoice**

[Image: Invoice payment receipt for FA-0001, €189.90]

**Invoice payment refund**

[Image: Receipt with the item Vrátenie úhrady faktúry číslo FA-0001, −€189.90, with the invoice payment identifier]

Cash payment of an invoice:

```http
POST {server_address}/api/v1/requests/receipts/invoice

{
  "print": {
    "printerName": "pdf"
  },
  "request": {
    "data": {
      "cashRegisterCode": "88812345678900001",
      "invoiceNumber": "FA-0001",
      "amount": 189.90
    }
  }
}
```

Refund of the cash payment of the invoice:

**HTTP API:**

```http
POST {server_address}/api/v1/requests/receipts/cash_register

{
  "print": {
    "printerName": "pdf"
  },
  "request": {
    "data": {
      "cashRegisterCode": "88812345678900001",
      "items": [
        {
          "type": "correction",
          "referenceReceiptId": "O-69EAABF5BE2B465BAAABF5BE2BC-TEST",
          "name": "Vrátenie úhrady faktúry číslo FA-0001",
          "quantity": {
            "amount": 1.00,
            "unit": "ks"
          },
          "unitPrice": -189.90,
          "price": -189.90,
          "vatRate": 0.00
        }
      ],
      "payments": [
        {
          "name": "Hotovosť",
          "amount": -189.90
        }
      ]
    }
  }
}
```

**.NET library:**

```csharp
var items = new ReceiptItems
{
    new ReceiptItem(ReceiptItemType.Correction, "Vrátenie úhrady faktúry číslo FA-0001",
        -189.90m, new Quantity(1, "ks"), 0m,
        referenceReceiptId: "O-69EAABF5BE2B465BAAABF5BE2BC-TEST")
};

var receipt = new CashRegisterReceipt("88812345678900001", items)
{
    Payments = new ReceiptPayments { new ReceiptPayment("Hotovosť", -189.90m) }
};
```

## Invoice credit note

An invoice that was not paid through the eKasa system, so there is no invoice payment receipt with a unique
identifier for it, is credited as a cash payment of the invoice (an `invoice` receipt) with a negative sign.

[Image: Invoice payment receipt for FA-0001 with the amount −€189.90]

**HTTP API:**

```http
POST {server_address}/api/v1/requests/receipts/invoice

{
  "print": {
    "printerName": "pdf"
  },
  "request": {
    "data": {
      "cashRegisterCode": "88812345678900001",
      "invoiceNumber": "FA-0001",
      "amount": -189.90
    }
  }
}
```

**.NET library:**

```csharp
var creditNote = new InvoiceReceipt("88812345678900001", "FA-0001", -189.90m);

RegisterReceiptResult result = await client.RegisterReceiptAsync(
    new RegisterInvoiceReceiptRequest(creditNote),
    RegisterReceiptPrintContext.CreatePos(),
    cancellationToken);
```

## Where next

- [Receipt items](https://ekasa.ninedigit.sk/en/docs/receipt-registration/items): Item types and the reference to the original receipt.
- [Discounts](https://ekasa.ninedigit.sk/en/docs/receipt-registration/discounts): Item discount and whole-receipt discount.
- [Registration result](https://ekasa.ninedigit.sk/en/docs/receipt-registration/result): The receipt identifier a correction refers to.
