Skip to main content

Articole și stocuri

Listare articole

cURL
curl -X POST http://localhost:4000/NextUpServices/Services/POST/ \
-H "Content-Type: text/plain" \
-d "{\"AuthenticationToken\":\"$NX_TOKEN\",\"Method\":\"GetAllArticles\",\"Params\":{}}"

Adăugare articol

Node.js
const newArticle = await client._call('AddArticle', {
Code: '0000010',
Name: 'Servicii consultanță avansată',
VATRateId: 1, // 19% TVA
UnitOfMeasure: 'ORA',
IsService: true,
SalePrice: 350.00
});

Căutare după nume sau cod

Python
results = nx_call(token, 'GetArticlesByNameAndCode', {'name': 'laptop'})
# Returnează toate articolele care conțin "laptop" în nume

Stocuri

cURL
# Toate stocurile (toate articolele × toate depozitele)
curl -X POST http://localhost:4000/NextUpServices/Services/POST/ \
-H "Content-Type: text/plain" \
-d "{\"AuthenticationToken\":\"$NX_TOKEN\",\"Method\":\"GetAllStocksForArticles\",\"Params\":{}}"

# Doar pentru un articol
curl -X POST http://localhost:4000/NextUpServices/Services/POST/ \
-H "Content-Type: text/plain" \
-d "{\"AuthenticationToken\":\"$NX_TOKEN\",\"Method\":\"GetStocksForArticleByCode\",\"Params\":{\"code\":\"0000002\"}}"

Verificare disponibilitate înainte de comandă

Node.js — pattern util
async function checkAvailability(client, articleCode, qty, warehouseId) {
const stocks = await client._call('GetStocksForArticleByCode', { code: articleCode });
const inWh = stocks.find(s => s.WarehouseId === warehouseId);
if (!inWh) return { available: 0, ok: false };
const available = inWh.Quantity - inWh.ReservedQuantity;
return { available, ok: available >= qty };
}

const check = await checkAvailability(client, '0000002', 5, 1);
if (!check.ok) {
console.warn(`Doar ${check.available} unități disponibile`);
}