# Supplier imports

**Catalog → Importuri furnizori** (supplier imports; *Import products from suppliers*) reads your suppliers' product
feeds. From each feed it keeps:

- the supplier's cost and stock for the products you already sell;
- optionally, a retail price worked out from that cost;
- new products, created as **drafts** for you to review.

The supplier's categories, brands and attribute values become yours through a **dictionary** you fill in once.

## Setting up a feed

The supplier must exist first (Stock → Suppliers), with the currency its prices are in.

- **Sursa** (source): the supplier, a name, how often it runs (by hand, daily, hourly), and where the feed comes from.
  - An **address**: `https://` on a public server only. A key in the address is stored encrypted.
  - An **uploaded file**: CSV, XML or JSON, up to 200 MB.

  Then the format:
  - for CSV, the separator (or found automatically; Windows-1250 files are converted);
  - for XML, the element that holds one product (e.g. `product`);
  - for JSON, the path to the product list (e.g. `data.products`).
- **Câmpuri** (fields): for each field, the feed's column, element or key. Nested elements are written `parent/child`, an
  XML attribute `@name`. **Citește un eșantion** (read a sample) shows the columns and the first rows, and suggests them
  as you type. Only the product code (SKU) is required. The other fields: name, barcode, brand, category, purchase price
  (net, in the supplier's currency), recommended retail price, supplier stock, VAT rate, weight in grams, description and
  images.
- **Reguli** (rules):
  - **Creează produsele noi** (create new products): rows that match no product of yours become drafts.
  - **Actualizează costul** (update the cost): the purchase price, in lei at the BNR rate, becomes the product's manual
    cost, used for margins until the first goods receipt.
  - **Calculează prețul de vânzare** (work out the retail price): price = cost × (1 + markup) × (1 + VAT), rounded to
    ,90, ,99, the whole leu or not at all.
  - The **VAT rate** for new products when the feed has none.
- **Atribute** (attributes): which feed columns become which of your attributes on new products.

## How a run matches products

Each row is matched to your product in this order:

1. by the supplier's code, once linked by an earlier run;
2. by your SKU;
3. by the barcode.

A matched product gets the supplier's cost and stock and, if the rules say so, its cost and price. **Its name,
description and images are never changed.**

A row with no match becomes a new **draft** only when creating is on, it has a name, and its category is mapped in the
dictionary. The draft gets:

- the name and description (HTML removed);
- up to five images (`https://` addresses);
- the barcode, weight and the mapped specifications.

You check it and publish it.

## The dictionary

**Dicționar** lists every category, brand and attribute value the feed has used, with the number of rows that carried
it. For each one, choose what it is in your shop, or ignore it.

Words that plainly match are mapped by themselves:

- a category whose last part has the same name, when only one does;
- a brand with the same name;
- a value with the same text.

Case and diacritics don't matter in these matches. New words appear after each run, marked **nou** (new), and the feed
list shows how many are waiting.

- An unmapped **category** holds back its new products until you map it; ignoring it means they are never created.
- An unmapped **brand** leaves the product without one.
- An unmapped **value** does not become a specification. Add missing brands and values in the catalog, then map them here.

## Runs and products

**Rulări** (runs) shows each run's result:

- the rows read, products created, updated and unchanged;
- rows skipped, with the reasons and some example codes;
- products that were **missing from the feed** (no longer sent by the supplier; nothing is switched off for you).

**Produse** (products) lists the supplier's codes with your product and the supplier's stock. **Rulează acum** (run now)
starts a run straight away.

Not built yet: Excel (XLSX) feeds, which wait for the choice of a spreadsheet library.
