# onSaleDeleted

### Purpose

Triggered when a sale is deleted. Use this hook to log sale removals for auditing purposes.

### When It Triggers

* Owner or authorized employee deletes a sale
* Sale is removed from the database

### Parameters

| Parameter              | Type   | Description                             |
| ---------------------- | ------ | --------------------------------------- |
| `data.source`          | number | Server ID of actor                      |
| `data.shopId`          | string | Unique shop identifier                  |
| `data.shopName`        | string | Display name of the shop                |
| `data.actorIdentifier` | string | Identifier of person who deleted        |
| `data.actorName`       | string | Name of person who deleted              |
| `data.saleId`          | string | Unique sale identifier                  |
| `data.saleName`        | string | Sale display name                       |
| `data.discount`        | number | Discount percentage of the deleted sale |
| `data.timestamp`       | number | Server timestamp                        |

### Example

```lua
exports['sd-shops']:registerServerHook('onSaleDeleted', function(data)
    -- Log sale deletion
    print(('[SALE] %s deleted "%s" at %s'):format(
        data.actorName, data.saleName, data.shopName
    ))

    -- Send Discord notification
    exports['your-logging']:Log('sale-deleted', {
        shop = data.shopName,
        saleName = data.saleName,
        saleId = data.saleId,
        discount = data.discount,
        deletedBy = data.actorName
    })
end)
```
