# Stock synchronization

> One stock pool across source site, Trendyol and Temu: deducts open orders, prevents overselling, zeroes out-of-stock items and logs every push.

Your Trendyol and Temu stores are fed from the same stock pool. Sellable quantity is computed per barcode and only changed items are pushed.

## Sync flow

How a stock push looks in the panel (sample data).

## One stock pool

### Sellable stock formula

- What it does: One formula decides the quantity sent to marketplaces for each barcode.
- How it works: Source stock (variant stock when a variant barcode matches) − open order quantity across all your stores − store safety stock; never below 0.
- Problem solved: Marketplaces holding unrelated stock numbers.
- Technical detail: Variant barcode matches take precedence over product-level barcodes, so one size's stock is never mistaken for the product total.

### Overselling prevention

- What it does: When an order lands on one store, the same barcode's stock on your other stores drops immediately.
- How it works: If order sync finds a new open order it triggers a stock push for all of the user's active stores.
- Problem solved: The last units selling on two marketplaces at once.
- Technical detail: Open order: Trendyol Created/Picking/Invoiced; Temu pending and processing orders.

### Deactivating sold-out items

- What it does: Products that sold out, were blocked or became passive at the source are set to 0 stock on the marketplace.
- How it works: If a product is not active, its pool stock is treated as 0 and the listing is marked 'Stock 0'.
- Problem solved: Orders for items the supplier no longer has.
- Technical detail: States: Matched, Stock 0, Unmatched, Error.

## Sync frequency and conflict resolution

| Topic | Behaviour |
| --- | --- |
| Frequency | Per store 5–1,440 minutes; default 15. Listing matching refreshes every 6 hours. |
| Manual trigger | 'Push stock', 'Pull orders', 'Match products' buttons in the panel |
| Source of truth | The Giyimport pool. Stock edited manually on the marketplace is reset on the next sync. |
| Change detection | Only barcodes whose computed quantity differs from the last pushed or marketplace value are sent. |
| Errors | Failed items are marked 'Error', the message is stored and they are retried on the next sync. |
| Safety stock | A fixed quantity (0–100) deducted from every barcode. |

## Log screen

### Sync log

- What it does: Every matching, stock push and order pull is recorded with start/end, trigger and result.
- How it works: Records are listed in the sync log on the 'Marketplaces' screen and kept for 90 days.
- Problem solved: Not being able to trace why a product shows wrong stock on a marketplace.
- Technical detail: Summary fields: checked, changed, pushed, failed, zeroed / fetched, newOpenOrders.
