# Update a quote

`PATCH /businesses/{bid}/quotes/{id}`

Requires the `documents` scope.

Editable while it is a draft or sent, because an offer gets haggled over, and re-sending re-freezes it under the SAME link. A quote the customer already answered is refused: rewriting it would make the record of his answer a lie. Reopen it, or make a new one.

## Path parameters

| Name | Type | | Description |
|---|---|---|---|
| `bid` | string | **required** | Business id, from `POST /businesses`. |
| `id` | string | **required** | Quote id. |

## Body

| Field | Type | | Description |
|---|---|---|---|
| `party` | object |  | `{partyId}` to reference a saved party, or an inline `{name, taxId?, phone?, email?, address?}`. |
| `party.partyId` | string |  |  |
| `party.name` | string |  |  |
| `party.taxId` | string |  |  |
| `party.phone` | string |  |  |
| `party.email` | string |  |  |
| `party.address` | string |  |  |
| `lines` | array of DocumentLine |  |  |
| `title` | string |  | Printed under the heading, for example "טיפול שנתי במשרדים". |
| `quoteDate` | string |  | Default: today, Israel time. |
| `validUntil` | string |  | Default: 14 days out. Send `null` for a standing offer with no expiry. |
| `terms` | string |  | The offer's terms. Printed at the end and shown to the customer above the accept button. |
| `note` | string |  |  |
| `discountAmount` | integer |  |  Integer agorot (₪1 = 100). |
| `priceMode` | string |  |  One of: `net`, `gross`. Default `net`. |
| `currency` | string |  |  One of: `ILS`, `USD`, `EUR`, `GBP`, `CHF`, `AUD`, `CAD`. Default `ILS`. |
| `fxRate` | number |  | Your own rate. Omit for the Bank of Israel rate of the quote date. Unlike a document, a quote that cannot get one still renders. |
| `lang` | string |  |  One of: `he`, `en`. Default `he`. |
| `brandingThemeId` | string |  | The branding theme it prints in (GET /businesses/{bid}/branding-themes). Omit or `null` for the customer's default, else the main design; `"main"` for the main design whatever the customer's default. Frozen at issue: the issued row names the theme it used, `null` for the main design. |
| `zeroVat` | boolean |  | מע״מ בשיעור אפס on the quoted lines. |

## Response

`200`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `quote` | Quote | **required** | הצעת מחיר: an OFFER, and deliberately not a document: it carries no statutory number, it is freely editable and deletable, and it appears in no export, no VAT return and no income report. What it becomes when the customer accepts is an ordinary draft document (`POST .../convert`). |

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

```bash
curl -X PATCH "$BASE/businesses/$BID/quotes/$DOC_ID" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "party": {
      "name": "דנה לוי",
      "taxId": "514667426",
      "phone": "0521111111",
      "email": "dana@example.com",
      "address": "הרצל 12, תל אביב"
    },
    "lines": [
      {
        "description": "איפור כלה",
        "quantity": 1,
        "unitPriceExVat": 120000
      }
    ],
    "priceMode": "gross"
  }'
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/quotes/${DOC_ID}`, {
  method: 'PATCH',
  headers: {
    'X-Api-Key': KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "party": {
      "name": "דנה לוי",
      "taxId": "514667426",
      "phone": "0521111111",
      "email": "dana@example.com",
      "address": "הרצל 12, תל אביב"
    },
    "lines": [
      {
        "description": "איפור כלה",
        "quantity": 1,
        "unitPriceExVat": 120000
      }
    ],
    "priceMode": "gross"
  }),
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.patch(
    f"{BASE}/businesses/{BID}/quotes/{DOC_ID}",
    headers={"X-Api-Key": KEY},
    json={
      "party": {
        "name": "דנה לוי",
        "taxId": "514667426",
        "phone": "0521111111",
        "email": "dana@example.com",
        "address": "הרצל 12, תל אביב"
      },
      "lines": [
        {
          "description": "איפור כלה",
          "quantity": 1,
          "unitPriceExVat": 120000
        }
      ],
      "priceMode": "gross"
    },
)
data = res.json()
```