---
title: "Parts and supplies"
weight: 40
description: "Management of parts, consumables and equipment installed or removed during a SmartInterventions intervention, on the Dolibarr back office side."
source_hash: "7886b471"
---

# Parts and supplies

This page describes the management of parts, consumables and equipment installed
or removed during a SmartInterventions intervention, as it
appears on the Dolibarr back office side (fixed administrator, workshop
manager or invoicing clerk workstation).

On an intervention card, a "Parts" tab lists all the
lines attached to this intervention. The "Add a part" button at
the top right allows creating a new line. Each line has a
status: Draft, Validated, or Cancelled.

## Creating and validating a line

![Parts tab of an intervention in the back office: list of attached lines with their role, quantity, price and status (Draft, Validated, Cancelled)](screenshots/pieces-backoffice-ligne.webp)

A part line carries several information blocks:

- **Identity**: catalog product (optional), label, role (consumable,
  new installed equipment, replacement part, removal only) and,
  for the "replacement" or "removal only" roles, the concerned
  parent equipment and the fate of the removed part
  (destroyed, brought back to the warehouse, returned to the supplier under
  warranty, recycled, left on site).
- **Quantity and stock**: planned / installed quantity, unit, serial
  or batch number, possible expiry date, source warehouse,
  purchase supplier and warranty in months.
- **Price**: ex-tax unit selling price and VAT rate. The ex-tax
  purchase price is reserved for administrators.
- **Notes**: public note printed on the intervention PDF, and
  private internal note never published.
- **Status**: "Draft", "Validated" or "Cancelled" badge and
  contextual action buttons.

Moving to the "Validated" status triggers the price snapshot (the
catalog rate is frozen on the line), the check of the accepted values
(see below), the strong traceability constraint check (serial or batch
number, certified operator, expiry date) if the product is marked
"to track", and depending on the configuration an automatic stock-out.

A draft line can be deleted. A validated line can only be
cancelled by an administrator, which regenerates an inverse stock movement
if necessary.

Deleting an intervention deletes its part lines too. As long as it
carries validated lines, which took the parts out of stock, are invoiced
or recorded in the regulatory register, the deletion is refused, from
the intervention card as from the intervention list:

> This intervention cannot be deleted: it carries 2 validated part line(s), with their stock exit, their invoicing and their entry in the regulatory register. First cancel these lines in the Parts and supplies tab (right "Administer partlines (post-validation edits, price recompute, access cost columns)"), which puts the parts back in stock, then delete the intervention.

Once these lines are cancelled, the intervention is deleted as usual,
with its draft and cancelled lines.

The source warehouse of a line is the one the stock leaves at
validation. A technician can only set their own warehouse (the one of
their user card), the **Default warehouse (fallback for stock
movements)** or the **Target warehouse for supplier warranty returns**
of the module setup. Administrators and users allowed to create stock
movements can pick any warehouse of their entity. A refused warehouse is
ignored: the warehouse is then chosen automatically at validation.

## Accepted values on a line

The quantity, unit price and VAT rate of a line are copied as they are
onto the quote and the invoice of the customer. Without the
**Administer partlines** right, a line must stay within these bounds,
on creation as on edition, in the app as on the back-office card:

- **Quantity**: greater than 0.
- **Unit price**: 0 or more.
- **VAT rate**: an active rate of the VAT rates dictionary
  (**Home > Setup > Dictionaries > VAT Rates**) for the country of the
  intervention customer, or for the country of your company when the
  customer has no country.
- **Price of an installed catalog part**: the selling price of the
  product in the catalog, whatever price is sent. An off-catalog part
  keeps the typed price, and a part "To offer in the quote" the price
  negotiated by the holder of the quote right.

A value outside these bounds is refused, and the app explains it on the
line concerned, for example:

> The quantity must be greater than 0. Only a parts administrator (right "Administer partlines (post-validation edits, price recompute, access cost columns)") can enter a negative quantity (credit, part take-back).

The holder of the **Administer partlines** right keeps negative values
and other rates: this is how a credit or a part take-back is entered.
These lines are copied as negative lines onto the quote and the invoice.
A value already stored is not checked again: a technician can edit the
note of a credit line without touching its amounts.

Validation is the exception. It copies the line onto the invoice and into
the stock: the quantity, the price and the VAT rate are therefore checked
again, as they will be invoiced. A credit line, or a draft saved before
these bounds existed, is validated by the holder of the **Administer
partlines** right only. For a technician, the validation is refused and
the line stays a draft:

> This part cannot be validated. The quantity must be greater than 0. Only a parts administrator (right "Administer partlines (post-validation edits, price recompute, access cost columns)") can enter a negative quantity (credit, part take-back).

The references carried by the line are checked the same way, for every
user:

- **Operator** (refrigerant and biocide register): a user of the entity.
  Without the **Administer partlines** right, it must be yourself or an
  internal contact of the intervention (intervening technician or
  follow-up manager), still active: the register credits the handling to
  them. The refusal reads:

  > The operator of a part must be yourself or a contact of this intervention, because the regulatory register credits the handling to them. Only a parts administrator (right "Administer partlines (post-validation edits, price recompute, access cost columns)") can name another user.

- **Supplier**: a third party marked as supplier, in business, of the
  entity. The supplier orders of the parts go to it.
- **Units** (quantity, dose, treated area) and **fate of the removed
  part**: an active entry of their dictionary.

As for the amounts, a reference already stored is not checked again as
long as it is not changed.

## Permissions

Four permissions drive access to parts:

- `read`: see the tab and the lines (a typical technician).
- `write`: create and edit draft lines, and validate.
- `delete`: delete a draft line (deleting a validated line
  is never possible, only cancellation is).
- `admin`: edit a validated line (with logging), cancel a
  validated line, see the ex-tax purchase price, access the
  price recalculation screen, enter or validate values outside the bounds above
  (negative quantity or price, another VAT rate, another price than the
  catalog one) and name as operator a user who is not a contact of the
  intervention.

A module option `SMARTINTERVENTIONS_HIDE_PRICES_FROM_TECH` allows
to hide the ex-tax unit price and the ex-tax total from users who do not have the
admin permission, for example for a workshop where technicians must not
announce prices to the customer. By default this option is
disabled and the technician sees the ex-tax unit price (but never the ex-tax purchase price).

## Price recalculation before invoicing

The `partline_repricing.php` screen (accessible to administrators
only) compares line by line the price frozen at
validation time with the current catalog rate. The variance is
displayed as a percentage and lines above half a percent of drift are
pre-checked.

Typical use case: a technician intervened three weeks ago,
the catalog has been updated since (promotion, supplier price increase), and
the invoicing clerk wants to send an invoice consistent with the current rate
rather than with the rate of three weeks ago.

Each recalculation generates an audit line in the Dolibarr log:

```
REPRICED partline=42 subprice=12.00->15.00 cost=8.00->9.50 user=7
```

This format is deliberately extractable with a simple `grep REPRICED`
on the logs.

## Mobile app (PWA)

Since v2 a dedicated "Parts and supplies" block is displayed in the
technician's mobile report, just under the time spent and before
the closing / signatures block.

This block is distinct from the historical "Consumed Products/Services"
section (mobile catalog linked to `lines_products`). Both can
coexist during the migration: the new section persists to the
`llx_smartinter_partline` table and directly feeds the
detailed invoicing, batch/serial stock management and the PDFs.

### Three add entries

The "Add a part" button opens a modal with three tiles:

- **Scan**: camera reading of an EAN-13, CODE-128, QR
  or Data Matrix barcode. The code is resolved in cascade: product by
  `barcode`, then by the `supplier_barcodes` extrafield (supplier
  codes), then on the server catalog via
  `GET /partline/resolve-barcode`, and finally on the "off
  catalog" option. When there is no camera (permission denied, old
  browser), a file selector `<input capture>` allows
  taking a photo of the code and decoding it via @zxing/browser.
- **Search**: text search (ref or label) on the offline
  catalog stored in IndexedDB. The catalog is synchronized
  automatically on first use and capped at 2000 products (LRU +
  30-day expiry, favorites spared).
- **Off catalog**: entry of a free label when the
  part is not (yet) referenced in Dolibarr. The line carries a
  `fk_product = NULL`; the invoicing clerk decides later whether the part must
  be referenced or invoiced as is.

> **Entering the price on an off-catalog line.** The "Unit ex-tax
> price" field only appears in the modal for users who
> hold the "quote" permission (on-site quote) AND when the line's
> destination is "To offer in the quote". A free line marked "Installed
> part", or entered by a technician without the "quote" permission, therefore
> offers no price field: this is deliberate. In this case, the rate is
> set in the back office by the invoicing clerk at validation or
> invoicing time (cf. the "Permissions" section above and the
> "On-site quote" page). To allow a technician to announce a price
> directly on site, grant them the "quote" permission and choose the
> destination "To offer in the quote".

### Burst scan mode

For serialized products installed in quantity (ex: 5 light fixtures), a
"Rush scan" button accumulates the N serial numbers in the same
modal, then creates N distinct lines on tap "Validate". Duplicates
are flagged but not inserted. Cancelling the modal writes nothing.

Two entry points lead to this modal: the "Open the rush scan" link of a
part form (serialized product, quantity above 1), which keeps the product
already chosen, and the "Rush scan" button at the top of the Parts
block, which first asks to choose the product from the catalog. Only a
product tracked by serial number can be chosen there: for another
product, the modal explains why and points to "Add a part".

For a regulated product (refrigerant, biocide), the modal shows the same
"Certified operator" block as the part form: you are selected by
default, and the chosen operator (with the dose, treated surface and
target of a biocide) is carried by each of the N lines. The lines are no
longer refused at validation for lack of an operator.

### SN / batch selector

When the chosen product is serialized (`tobatch = 2`), a selector
lists the available SNs in the warehouse in FIFO (increasing entry
date). When it is batch-tracked (`tobatch = 1`), the selector
lists batches in FEFO (increasing expiry) with a FIFO toggle for
non-perishable consumables. Free entry is forbidden on
SNs and tolerated on batches only if the option
`STOCK_ALLOW_NEGATIVE_TRANSFER` is enabled on the Dolibarr side.

### Offline operation

Each entered line is immediately persisted in IndexedDB with an
identifier `client_uuid` generated by the PWA (UUID v4 RFC 4122). As
long as the connection is not restored, the line carries a "Waiting
for synchronization" badge and remains editable / deletable.

When the network returns, or via the "Synchronize" button in the
block header, the PWA sends each line to `POST /partline` with the header
`X-Offline-Sync: 1`. On the server side, this flag triggers an authoritative recalculation
of the `subprice` from the current catalog: the price entered
offline (`subprice_offline_hint`) is persisted as is for
audit, but it is the server price that is authoritative on the final line.

Idempotence is guaranteed by the UNIQUE
`(entity, client_uuid)` constraint: a line sent twice (unstable
network, manual retry, second terminal) always produces the same
line in the database, never a duplicate.

A network cut or a transient server error is retried automatically. A
refusal of the server is not: a value outside the bounds, an operator who
is not allowed, a missing Dolibarr right would meet the same refusal on
every sending. The line then stays in the block with the "Refused by the
server" badge followed by the sentence that explains the refusal, for
example:

> Refused by the server - The unit price cannot be negative. Only a parts administrator (right "Administer partlines (post-validation edits, price recompute, access cost columns)") can enter a negative price (credit, part take-back).

It is no longer sent again on its own, and the "Synchronize" button does
not show for it. Tap "Edit", correct the value and save: the line leaves
right away. When the refusal comes from a missing right, have your
administrator add it, then tap "Retry" on the line.

A quote requested on the same intervention waits until the refused part
is corrected or deleted, so that it does not leave without it. A quote
itself refused by the server (missing right, refused value, missing
signature...) is sent only once: it shows under the block with the label
"Quote refused by the server", the sentence of the server and a "Retry"
button, to tap once the cause is gone.

### Strong traceability products (must_tracking)

If the product carries the `must_tracking = 1` extrafield (refrigerant, biocide, veterinary medicine, etc.), the modal
displays a warning when the batch number, serial number or
certified operator is missing. The line remains creatable locally (the
technician can complete it later before the final synchronization)
but the server will refuse the commit with a clear error if one
of these fields remains empty.

### Catalog indicator

The block header permanently displays a "Catalog: X/Y" counter
(products stored over cap), a "Catalog truncated" badge when the
server returned more products than the PWA can store, and the
date of the last synchronization. A button refreshes the catalog on
demand.

## Complete end-to-end cycle

Here is the typical journey of a part installed in the field up to its
invoicing:

1. **Field entry (PWA)** -- The technician opens the
   intervention card on their smartphone, opens the "Parts and
   supplies" block, scans or searches the product, completes quantity,
   batch or serial number, takes a photo if necessary. A
   draft line is immediately saved locally with a
   `client_uuid` identifier that guarantees idempotence.
2. **Synchronization** -- When the network returns (or via the
   "Synchronize" button), the line is pushed to the server via
   `POST /partline` with the `X-Offline-Sync: 1` header. The server
   recalculates the selling price (`subprice`) from the
   current catalog and the purchase price (`subprice_cost`) from the WAP, then
   keeps the price entered offline in `subprice_offline_hint`
   for audit.
3. **Validation** -- At the time of the customer signature or via the
   "Validate" action of the back office, the line moves from "Draft" to
   "Validated". This transition triggers:
   - the final price snapshot,
   - the strong traceability checks (batch/serial, operator
     certified, expiry date) for products marked
     `must_tracking`,
   - the automatic stock-out (source warehouse by default),
   - the equipment side effects (creation / uninstallation /
     replacement) according to the line's role,
   - the regulatory checks for refrigerants and biocides.
4. **Invoicing** -- At the `fichinter -> invoice` conversion,
   each validated and `billable=1` line generates a corresponding
   `facturedet`, carrying the line discount. A line already invoiced
   (`fk_facturedet` set) is never invoiced again: a second invoice
   created from the same intervention only takes the parts not invoiced
   yet, and deleting by hand the line of a part on a draft invoice does
   not make it billable again. The `element_element` link is created
   between the intervention card and the invoice. If the invoice is then
   deleted, the `BILL_DELETE` trigger resets
   `partline.fk_facturedet = NULL` and purges the links.
5. **Retroactive cancellation** -- If a validated line must be
   cancelled (customer refusal, error), an administrator clicks
   "Cancel": the line moves to "Cancelled", an inverse stock movement
   is generated, and the equipment side effects are
   propagated (an installed emergency lighting unit that is cancelled sees its
   equipment deactivated and an `uninstalled` event recorded).

## Regulated products and operator register

For fluorinated gases (label `is_fluorinated_gas`) and
biocides (label `is_biocide`), additional
rules apply: a certified operator must be designated via
`fk_user_operator` (yourself or an internal contact of the intervention,
see "Accepted values on a line"), the minimum certification category is
checked (by default in warning mode, in strict mode via the
constant `SMARTINTERVENTIONS_OPERATOR_CERT_ENFORCE=1`), and the
entry of dosage / treated surface / target is required for
biocides.

In the app, a regulated product shows a "Certified operator" block in the
part form. The picker offers the operators the server accepts: yourself,
selected by default, then the active internal contacts of the
intervention (intervening technicians, follow-up manager). The holder of
the **Administer partlines** right also finds every active user of the
entity there. The certification category of each one is shown in
brackets, and a warning shows when it is below the minimum category of
the product. The list travels with the intervention: it stays available
offline.

The block also shows when you edit a regulated part already saved,
whether it was already sent to the server or is still waiting for
synchronization: the chosen operator is kept and can be changed, and the
part keeps its catalog product.

All lines entered by a certified operator are
viewable and exportable via the operator register. See the dedicated
[Operator register](/smartinterventions/registre-operateur) page.
