This commit is contained in:
seb
2026-08-22 05:40:06 +02:00
parent 390d66890b
commit ccf7854e6c
3 changed files with 13 additions and 2 deletions

View File

@@ -26,6 +26,8 @@ LANGUAGE_ID=1
# Product sync (tSteuerzone.cName used to look up tax rates per tSteuerklasse)
TAX_ZONE_NAME=Zone-EU
# Warehouse ID for inventory stock (vLagerbestandProLager)
WARENLAGER_ID=1
# Shop filter: active shop is queried from tShopSubshop at startup

4
API.md
View File

@@ -247,10 +247,12 @@ Notable fields:
| `prices` | One entry per customer group |
| `isCompositeProduct` | `"1"` if the article is a Stückliste parent |
| `imghash` | Pass to `/v1/pimage?path=...` |
| `use_stock` | `"1"` if `cLagerAktiv = 'Y'`, otherwise `"0"` |
| `quantity` | Stock quantity from `dbo.vLagerbestandProLager` for configured `WARENLAGER_ID` |
| Deposit fields | Present when JTL-POS Pfand attributes are set |
| `attributes` | Article attributes from `tArtikelAttribut` (incl. Pfand) |
Many other product fields are filled with static defaults (`sort`, `use_stock`, `unit`, etc.) for JTL-POS compatibility.
Many other product fields are filled with static defaults (`sort`, `unit`, `PLU`, etc.) for JTL-POS compatibility.
**Node only:** `prices[]` applies percustomer-group net overrides from `tPreis` / `tPreisDetail`. C++ currently fills every group with the base gross price.

View File

@@ -8,6 +8,7 @@ import { getActiveShopId } from '../shop.js';
const LANGUAGE_ID = Number(process.env.LANGUAGE_ID) || 1;
const TAX_ZONE_NAME = process.env.TAX_ZONE_NAME || 'Zone-EU';
const WARENLAGER_ID = Number(process.env.WARENLAGER_ID) || Number(process.env.JTL_KWARENLAGER) || 1;
const PRODUCT_LIST_SQL = `
WITH TaxRates AS (
@@ -53,11 +54,14 @@ SELECT TOP (@limit)
FROM Pos.vProductVariant pv
WHERE pv.kProduct = a.kArtikel
) AS variantName,
a.cBarcode AS barcode
a.cBarcode AS barcode,
a.cLagerAktiv,
ISNULL(v.fBestand, 0) AS fBestand
FROM dbo.tArtikel a
INNER JOIN dbo.tArtikelBeschreibung ab ON ab.kArtikel = a.kArtikel AND ab.kSprache = @languageId
LEFT JOIN TaxRates tr ON tr.kSteuerklasse = a.kSteuerklasse
LEFT JOIN ImageRV ir ON ir.kArtikel = a.kArtikel
LEFT JOIN dbo.vLagerbestandProLager v ON v.kArtikel = a.kArtikel AND v.kWarenlager = @warenlagerId
WHERE a.cAktiv = 'Y'
AND (@kShop = 0 OR EXISTS (
SELECT 1 FROM dbo.tKategorieArtikel ka
@@ -129,6 +133,7 @@ export async function getProductList({ cursor = 0, limit = 20 } = {}) {
.input('languageId', sql.Int, LANGUAGE_ID)
.input('taxZoneName', sql.NVarChar, TAX_ZONE_NAME)
.input('kShop', sql.Int, getActiveShopId())
.input('warenlagerId', sql.Int, WARENLAGER_ID)
.query(PRODUCT_LIST_SQL),
getCustomerGroupIds(),
]);
@@ -209,6 +214,8 @@ export async function getProductList({ cursor = 0, limit = 20 } = {}) {
variants: product.variantName ?? '',
isCompositeProduct: product.isCompositeProduct,
attributes: articleAttributes?.attributes ?? [],
use_stock: product.cLagerAktiv === 'Y' || product.cLagerAktiv === '1' ? '1' : '0',
quantity: String(product.fBestand ?? 0),
...(articleAttributes?.deposit ?? {}),
};
});