diff --git a/docs/api/routes-all.md b/docs/api/routes-all.md index e0ce103..d60eb12 100644 --- a/docs/api/routes-all.md +++ b/docs/api/routes-all.md @@ -10,50 +10,53 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body). ### Reusable types - `T1` = `{ article: T2 }` -- `T2` = `{ id: int, sku: str, name: str, slug: str, desc: str|null, seo: str|null, track_stock: bool, unitamount: num|null, weight: num|null, unit: T31, brand: T28|null, categoryIds: int[], photos: T26[], eans: str[], prices: T37[], suppliers: T12[] }` -- `T3` = `{ delivery: T4 }` -- `T4` = `{ id: int, number: str, type: str, supplierId: int|null, date: str, lines: T21[], files: T9[], externalNumber?: str|null, createdAt?: str, ledger?: T41 }` -- `T5` = `{ labeltemplate: T6 }` -- `T6` = `{ id: int, name: str, width: num, height: num, dpi: int, type: str, content: T17, thumb?: str|null }` -- `T7` = `{ order: T11 }` -- `T8` = `{ quote: T11 }` -- `T9` = `{ id: int, manifestId: int, fileId: int, sort: int, hash: str, mimetype: str, name: str, size: int, created?: str, modified?: str, thumbavif?: str|null, thumbx?: int|null, thumby?: int|null, meta?: { [k]: str }|null }` -- `T10` = `{ id: int, name: str, pairingpin?: str|null, token?: str|null, pairedAt?: str|null, clientserial?: str|null, rootCategoryId?: int|null, syncRootArticles?: bool, lastseenAt?: str|null, updatedAt?: str|null, categoryIds?: int[] }` -- `T11` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T21[], createdAt?: str }` -- `T12` = `{ id: int, articleId: int, entityId: int, pu: num, sort: int, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T43|null }` -- `T13` = `{ id: int, entityId: int, addressType: str, firstName?: str|null, name?: str|null, street?: str|null, streetNumber?: str|null, zip?: str|null, city?: str|null, county?: str|null }` -- `T14` = `{ ledger: T15[] }` -- `T15` = `{ id: int, manifestarticle_id: int, transaction_type: str, amount: num, transaction_text: str, hash_version: int, prev_hash?: str, sku?: str|null, created_at?: str }` -- `T16` = `{ id: int, name: str, sort: int, exclusive: bool, values: T32[], articleCount?: int }` -- `T17` = `{ objects: T22[] }` +- `T2` = `{ id: int, sku: str, name: str, slug: str, desc: str|null, seo: str|null, track_stock: bool, unitamount: num|null, weight: num|null, unit: T32, brand: T29|null, categoryIds: int[], photos: T27[], eans: str[], prices: T40[], suppliers: T13[] }` +- `T3` = `{ order: T4 }` +- `T4` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T22[], createdAt?: str, shipping?: T39|null, shippings?: T39[], payment?: T35|null, payments?: T35[], paid?: bool, delivered?: bool }` +- `T5` = `{ delivery: T6 }` +- `T6` = `{ id: int, number: str, type: str, supplierId: int|null, date: str, lines: T22[], files: T10[], externalNumber?: str|null, createdAt?: str, ledger?: T44 }` +- `T7` = `{ labeltemplate: T8 }` +- `T8` = `{ id: int, name: str, width: num, height: num, dpi: int, type: str, content: T18, thumb?: str|null }` +- `T9` = `{ quote: T12 }` +- `T10` = `{ id: int, manifestId: int, fileId: int, sort: int, hash: str, mimetype: str, name: str, size: int, created?: str, modified?: str, thumbavif?: str|null, thumbx?: int|null, thumby?: int|null, meta?: { [k]: str }|null }` +- `T11` = `{ id: int, name: str, pairingpin?: str|null, token?: str|null, pairedAt?: str|null, clientserial?: str|null, rootCategoryId?: int|null, syncRootArticles?: bool, lastseenAt?: str|null, updatedAt?: str|null, categoryIds?: int[] }` +- `T12` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T22[], createdAt?: str }` +- `T13` = `{ id: int, articleId: int, entityId: int, pu: num, sort: int, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T46|null }` +- `T14` = `{ id: int, entityId: int, addressType: str, firstName?: str|null, name?: str|null, street?: str|null, streetNumber?: str|null, zip?: str|null, city?: str|null, county?: str|null }` +- `T15` = `{ ledger: T16[] }` +- `T16` = `{ id: int, manifestarticle_id: int, transaction_type: str, amount: num, transaction_text: str, hash_version: int, prev_hash?: str, sku?: str|null, created_at?: str }` +- `T17` = `{ id: int, name: str, sort: int, exclusive: bool, values: T33[], articleCount?: int }` - `T18` = `{ objects: T23[] }` -- `T19` = `{ printer: T24 }` -- `T20` = `{ entity: T27 }` -- `T21` = `{ id: int, sku: str|null, name: str|null, pu: num, amount: num, net: num, rebate: num, taxrate: num, comment: str|null }` -- `T22` = `{ id: str, type: str, x: num, y: num, w?: num, h?: num, text?: str, font?: str, fontSize?: num, barcodeFormat?: str }` +- `T19` = `{ objects: T24[] }` +- `T20` = `{ printer: T25 }` +- `T21` = `{ entity: T28 }` +- `T22` = `{ id: int, sku: str|null, name: str|null, pu: num, amount: num, net: num, rebate: num, taxrate: num, comment: str|null }` - `T23` = `{ id: str, type: str, x: num, y: num, w?: num, h?: num, text?: str, font?: str, fontSize?: num, barcodeFormat?: str }` -- `T24` = `{ id: int, company_id: int, address: str, type: str, sort: int, model?: str|null, serial?: str|null, desc?: str|null }` -- `T25` = `{ amount: num, net: num, taxrate: num, sku?: str|null, name?: str|null, pu?: num, rebate?: num, comment?: str|null }` -- `T26` = `{ sort: int, fullHash: str, fullW: int, fullH: int, fullSize: int, thumbW: int, thumbH: int, thumbHash: str }` -- `T27` = `{ id: int, customergroupId: int, firstName: str|null, name: str, number: str|null, createdAt: str, updatedAt: str }` -- `T28` = `{ name: str, id?: int|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null }` -- `T29` = `{ id: int, companyuser_id: int, provider: str, model: str, created_at: str, updated_at: str, state: str }` -- `T30` = `{ article: T35 }` -- `T31` = `{ si: str, basesi: str, basesifactor: num, symbol?: str|null, name?: str|null }` -- `T32` = `{ id: int, attributeId: int, value: str, sort: int, articleCount?: int }` -- `T33` = `{ id: int, name: str, sort: int, exclusive: bool, articleCount?: int }` -- `T34` = `{ id: int, iso639: str, name: str, taxrate: num, reducedtaxrate: num }` -- `T35` = `{ id: int, categoryId: int, name: str, sku: str, track_stock: bool }` -- `T36` = `{ id: int, email: str, selectedCompanyId: int|null, picture?: str }` -- `T37` = `{ minmultiplier: num, net: num, taxRate: num, customergroupId: int }` -- `T38` = `{ fullHash: str, thumbW: int, thumbH: int, thumbHash: str }` -- `T39` = `{ id: int, entityId: int, contactType: str, contact: str }` -- `T40` = `{ id: int, name: str, createdAt: str, updatedAt: str }` -- `T41` = `{ totalPositions: int, completelyOnLedgerPositions: int }` -- `T42` = `{ warehouse: T44 }` -- `T43` = `{ net: num, taxId: int, taxRate?: num|null }` -- `T44` = `{ id: int, name: str, sort: int }` -- `T45` = `{ id: int, categoryIds: int[] }` +- `T24` = `{ id: str, type: str, x: num, y: num, w?: num, h?: num, text?: str, font?: str, fontSize?: num, barcodeFormat?: str }` +- `T25` = `{ id: int, company_id: int, address: str, type: str, sort: int, model?: str|null, serial?: str|null, desc?: str|null }` +- `T26` = `{ amount: num, net: num, taxrate: num, sku?: str|null, name?: str|null, pu?: num, rebate?: num, comment?: str|null }` +- `T27` = `{ sort: int, fullHash: str, fullW: int, fullH: int, fullSize: int, thumbW: int, thumbH: int, thumbHash: str }` +- `T28` = `{ id: int, customergroupId: int, firstName: str|null, name: str, number: str|null, createdAt: str, updatedAt: str }` +- `T29` = `{ name: str, id?: int|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null }` +- `T30` = `{ id: int, companyuser_id: int, provider: str, model: str, created_at: str, updated_at: str, state: str }` +- `T31` = `{ article: T37 }` +- `T32` = `{ si: str, basesi: str, basesifactor: num, symbol?: str|null, name?: str|null }` +- `T33` = `{ id: int, attributeId: int, value: str, sort: int, articleCount?: int }` +- `T34` = `{ id: int, name: str, sort: int, exclusive: bool, articleCount?: int }` +- `T35` = `{ id: int, accountId: int, manifestId: int, type: str, amount: num }` +- `T36` = `{ id: int, iso639: str, name: str, taxrate: num, reducedtaxrate: num }` +- `T37` = `{ id: int, categoryId: int, name: str, sku: str, track_stock: bool }` +- `T38` = `{ id: int, email: str, selectedCompanyId: int|null, picture?: str }` +- `T39` = `{ id: int, manifestId: int, number: str, type: str, state: str }` +- `T40` = `{ minmultiplier: num, net: num, taxRate: num, customergroupId: int }` +- `T41` = `{ fullHash: str, thumbW: int, thumbH: int, thumbHash: str }` +- `T42` = `{ id: int, entityId: int, contactType: str, contact: str }` +- `T43` = `{ id: int, name: str, createdAt: str, updatedAt: str }` +- `T44` = `{ totalPositions: int, completelyOnLedgerPositions: int }` +- `T45` = `{ warehouse: T47 }` +- `T46` = `{ net: num, taxId: int, taxRate?: num|null }` +- `T47` = `{ id: int, name: str, sort: int }` +- `T48` = `{ id: int, categoryIds: int[] }` ### Routes @@ -74,7 +77,7 @@ _none_ #### Create article in category — `POST /article` - Params: `body: { categoryId: int, name: str, desc?: str, seo?: str, track_stock?: bool }` -- Returns: `201 T30` +- Returns: `201 T31` #### Export articles as ZIP — `GET /article/export.zip` - Params: `query: categoryId?: int` - Returns: `200 zip` @@ -110,10 +113,10 @@ _none_ - Returns: `200 { children: { id: int, sku: str, name: str, parentsort: int, attributeValueId: int, attributeValue: str }[] }` #### Create and attach a new child article to a parent article — `POST /article/{sku}/children` - Params: `sku: str, body: { attributeValueId?: int, value?: str, name?: str }` -- Returns: `201 T30` +- Returns: `201 T31` #### Attach an existing article as a child to a parent article — `PUT /article/{sku}/children` - Params: `sku: str, body: { sku: str, attributeValueId?: int, value?: str, reparent?: bool }` -- Returns: `200 { article: T35, children: { id: int, sku: str, name: str, parentsort: int, attributeValueId: int, attributeValue: str }[] }` +- Returns: `200 { article: T37, children: { id: int, sku: str, name: str, parentsort: int, attributeValueId: int, attributeValue: str }[] }` #### Remove a child article from a parent article — `DELETE /article/{sku}/children/{childSku}` - Params: `sku: str, childSku: str, query: deleteArticle?: bool` - Returns: `200 { success: bool, deleted: bool }` @@ -140,7 +143,7 @@ _none_ - Returns: `200 { options: { id: int, articleId: int, sku: str, name: str, count: int, sort: int, mandated: bool }[] }` #### Toggle parent mode for an article — `POST /article/{sku}/parent` - Params: `sku: str, body: { isParent: bool, attributeNameId?: int }` -- Returns: `200 T30` +- Returns: `200 T31` #### Replace POS prices by SKU (net > gross; price=net, tax=taxRate %) — `PUT /article/{sku}/prices` - Params: `sku: str, body: { prices: { net?: num, gross?: num, price?: num, taxRate?: num, tax?: num, minmultiplier?: num }[] }` - Returns: `200 T1` @@ -158,10 +161,10 @@ _none_ - Returns: `200 { ok: bool }` #### List article suppliers — `GET /article/{sku}/supplier` - Params: `sku: str` -- Returns: `200 { suppliers: T12[] }` +- Returns: `200 { suppliers: T13[] }` #### Assign supplier to article — `POST /article/{sku}/supplier` - Params: `sku: str, body: { entityId: int, sku?: str|null, pu?: num, stock?: num|null, sort?: int|null, netPrice?: num|null, taxId?: int|null, taxRate?: num|null }` -- Returns: `201 { supplier: T12 }` +- Returns: `201 { supplier: T13 }` #### Reorder article suppliers — `PUT /article/{sku}/supplier/order` - Params: `sku: str, body: { ids: int[] }` - Returns: `200 { ids: int[] }` @@ -170,7 +173,7 @@ _none_ - Returns: `204 void` #### Update article supplier assignment — `PATCH /article/{sku}/supplier/{id}` - Params: `sku: str, id: int, body: { sku?: str|null, pu?: num, stock?: num|null, sort?: int, netPrice?: num|null, taxId?: int|null, taxRate?: num|null }` -- Returns: `200 { supplier: T12 }` +- Returns: `200 { supplier: T13 }` #### Set article track_stock flag by SKU — `PUT /article/{sku}/track_stock` - Params: `sku: str, body: { track_stock: bool }` - Returns: `200 T1` @@ -182,19 +185,19 @@ _none_ #### List attribute names — `GET /attributename` _none_ -- Returns: `200 { attributenames: T16[] }` +- Returns: `200 { attributenames: T17[] }` #### Create attribute name — `POST /attributename` - Params: `body: { name: str, sort?: int, exclusive?: bool }` -- Returns: `201 { attributename: T16 }` +- Returns: `201 { attributename: T17 }` #### Reorder attribute names — `PUT /attributename/order` - Params: `body: { attributenameIds: int[] }` - Returns: `200 { ok: bool }` #### List values for an attribute — `GET /attributename/{attributeId}/value` - Params: `attributeId: int` -- Returns: `200 { values: T32[] }` +- Returns: `200 { values: T33[] }` #### Create value for an attribute — `POST /attributename/{attributeId}/value` - Params: `attributeId: int, body: { value: str, sort?: int }` -- Returns: `201 { attributevalue: T32 }` +- Returns: `201 { attributevalue: T33 }` #### Reorder values of an attribute — `PUT /attributename/{attributeId}/value/order` - Params: `attributeId: int, body: { attributevalueIds: int[] }` - Returns: `200 { ok: bool }` @@ -203,7 +206,7 @@ _none_ - Returns: `200 { ok: bool }` #### Update attribute name — `PATCH /attributename/{id}` - Params: `id: int, body: { name?: str, sort?: int, exclusive?: bool }` -- Returns: `200 { attributename: T16 }` +- Returns: `200 { attributename: T17 }` ### Section: /attributevalue @@ -212,28 +215,28 @@ _none_ - Returns: `200 { ok: bool }` #### Update attribute value — `PATCH /attributevalue/{id}` - Params: `id: int, body: { value?: str, sort?: int }` -- Returns: `200 { attributevalue: T32 }` +- Returns: `200 { attributevalue: T33 }` #### Delete attribute value image — `DELETE /attributevalue/{id}/image` - Params: `id: int` -- Returns: `200 { attributevalue: { id: int, thumbW: int|null, thumbH: int|null, thumbHash: str|null, pics: T38[] } }` +- Returns: `200 { attributevalue: { id: int, thumbW: int|null, thumbH: int|null, thumbHash: str|null, pics: T41[] } }` #### Add or replace attribute value image — `POST /attributevalue/{id}/image` - Params: `id: int, image/avif` -- Returns: `201 { attributevalue: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T38[] } }` +- Returns: `201 { attributevalue: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T41[] } }` ### Section: /auth #### Login with Google ID token — `POST /auth/login` - Params: `body: { idToken: str }` -- Returns: `200 { message: str, user: T36 }` +- Returns: `200 { message: str, user: T38 }` #### Logout — `POST /auth/logout` _none_ - Returns: `200 { message: str }` #### Current user — `GET /auth/me` _none_ -- Returns: `200 { user: T36, googleClientId: str }` +- Returns: `200 { user: T38, googleClientId: str }` #### Set selected company — `PUT /auth/selected-company` - Params: `body: { companyId: int }` -- Returns: `200 { user: T36 }` +- Returns: `200 { user: T38 }` ### Section: /brand @@ -242,7 +245,7 @@ _none_ - Returns: `200 { brands: { id: int, name: str, articleCount: int, pics: { fullHash: str, thumbW: int, thumbH: int, thumbHash: str, smallThumbW?: int|null, smallThumbH?: int|null, smallThumbBinary?: str|null }[], gsprpinfo?: str|null }[], total: int, offset: int, limit: int }` #### Create brand — `POST /brand` - Params: `body: { name: str, gsprpinfo?: str }` -- Returns: `201 { brand: { id: int, name: str, pics: T38[], gsprpinfo?: str|null } }` +- Returns: `201 { brand: { id: int, name: str, pics: T41[], gsprpinfo?: str|null } }` #### Delete brand — `DELETE /brand/{id}` - Params: `id: int` - Returns: `204 void` @@ -251,10 +254,10 @@ _none_ - Returns: `200 { brand: { id: int, name: str, touchedArticleCount: int, gsprpinfo?: str|null } }` #### Delete brand image — `DELETE /brand/{id}/image` - Params: `id: int` -- Returns: `200 { brand: { id: int, thumbW: int|null, thumbH: int|null, thumbHash: str|null, pics: T38[] } }` +- Returns: `200 { brand: { id: int, thumbW: int|null, thumbH: int|null, thumbHash: str|null, pics: T41[] } }` #### Add or replace brand image — `POST /brand/{id}/image` - Params: `id: int, image/avif` -- Returns: `201 { brand: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T38[] } }` +- Returns: `201 { brand: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T41[] } }` ### Section: /category @@ -269,7 +272,7 @@ _none_ - Returns: `200 { categoryIds: int[] }` #### Category tree — `GET /category/tree` _none_ -- Returns: `200 { languageId: int, tree: { id: int, sort: int, posterminalIds: int[], parentId?: int|null, name?: str|null, slug?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null }[], articles: { id: int, sku: str, name: str, slug: str, track_stock: bool, optionsCount: int, articleListCount: int, childCount: int, net?: num|null, taxRate?: num|null, parentArticleId?: int|null, parentSku?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null, brand?: T28|null }[] }` +- Returns: `200 { languageId: int, tree: { id: int, sort: int, posterminalIds: int[], parentId?: int|null, name?: str|null, slug?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null }[], articles: { id: int, sku: str, name: str, slug: str, track_stock: bool, optionsCount: int, articleListCount: int, childCount: int, net?: num|null, taxRate?: num|null, parentArticleId?: int|null, parentSku?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null, brand?: T29|null }[] }` #### Delete category — `DELETE /category/{id}` - Params: `id: int, query: recursive?: bool` - Returns: `204 void` @@ -278,7 +281,7 @@ _none_ - Returns: `200 { category: { id: int, name: str, slug: str, parentId: int, sort: int } }` #### Articles in category — `GET /category/{id}/articles` - Params: `id: int` -- Returns: `200 { articles: { id: int, sku: str, name: str, slug: str, track_stock: bool, optionsCount: int, articleListCount: int, childCount: int, net?: num|null, taxRate?: num|null, parentArticleId?: int|null, parentSku?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null, brand?: T28|null }[] }` +- Returns: `200 { articles: { id: int, sku: str, name: str, slug: str, track_stock: bool, optionsCount: int, articleListCount: int, childCount: int, net?: num|null, taxRate?: num|null, parentArticleId?: int|null, parentSku?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null, brand?: T29|null }[] }` #### List category attribute values — `GET /category/{id}/attributevalue` - Params: `id: int` - Returns: `200 { attributevalues: { id: int, attributeId: int, attributeName: str, attributeValueId: int, value: str, sort: int, categoryId?: int, exclusive?: bool }[] }` @@ -305,10 +308,10 @@ _none_ #### List companies — `GET /company` _none_ -- Returns: `200 { companies: T34[] }` +- Returns: `200 { companies: T36[] }` #### Create company — `POST /company` - Params: `body: { iso639: str, name: str, taxrate: num, reducedtaxrate: num }` -- Returns: `201 { company: T34, user: T36 }` +- Returns: `201 { company: T36, user: T38 }` #### Get company history — `GET /company/history` - Params: `query: limit?: int` - Returns: `200 { history: { id: int, date: str, text: str, companyuserId?: int|null }[], truncated: bool }` @@ -332,7 +335,7 @@ _none_ - Returns: `204 void` #### Update company — `PUT /company/{id}` - Params: `id: int, body: { iso639: str, name: str, taxrate: num, reducedtaxrate: num }` -- Returns: `200 { company: T34 }` +- Returns: `200 { company: T36 }` ### Section: /customergroup @@ -341,7 +344,7 @@ _none_ - Returns: `200 { customergroups: { id: int, name: str, sort: int, editable: bool }[] }` #### Create customer group — `POST /customergroup` - Params: `body: { name: str }` -- Returns: `201 { customergroup: T44 }` +- Returns: `201 { customergroup: T47 }` #### Reorder customer groups — `PUT /customergroup/order` - Params: `body: { customergroupIds: int[] }` - Returns: `200 { customergroupIds: int[] }` @@ -350,16 +353,16 @@ _none_ - Returns: `204 void` #### Update customer group — `PATCH /customergroup/{id}` - Params: `id: int, body: { name: str }` -- Returns: `200 { customergroup: T44 }` +- Returns: `200 { customergroup: T47 }` ### Section: /delivery #### List deliveries — `GET /delivery` _none_ -- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int|null, date: str, externalNumber?: str|null, createdAt?: str, ledger?: T41 }[] }` +- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int|null, date: str, externalNumber?: str|null, createdAt?: str, ledger?: T44 }[] }` #### Create delivery — `POST /delivery` -- Params: `body: { externalNumber: str, date: str, lines: T25[], supplierId?: int|null, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` -- Returns: `201 T3` +- Params: `body: { externalNumber: str, date: str, lines: T26[], supplierId?: int|null, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` +- Returns: `201 T5` #### Parse document (SSE) — `POST /delivery/parse` - Params: `form: { file: str }` - Returns: `200 SSE` @@ -377,10 +380,10 @@ _none_ - Returns: `204 void` #### Get delivery — `GET /delivery/{id}` - Params: `id: int` -- Returns: `200 T3` +- Returns: `200 T5` #### Update delivery — `PATCH /delivery/{id}` -- Params: `id: int, body: { externalNumber?: str|null, date?: str, supplierId?: int|null, lines?: T25[], files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` -- Returns: `200 T3` +- Params: `id: int, body: { externalNumber?: str|null, date?: str, supplierId?: int|null, lines?: T26[], files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` +- Returns: `200 T5` #### Get delivery attachment file content — `GET /delivery/{id}/file/{fileId}` - Params: `id: int, fileId: int, query: download?: bool` - Returns: `200 str` @@ -389,46 +392,46 @@ _none_ #### List entities — `GET /entity` - Params: `query: customergroupId?: int, role?: str` -- Returns: `200 { entities: T27[] }` +- Returns: `200 { entities: T28[] }` #### Create entity — `POST /entity` - Params: `body: { customergroupId: int, name: str, firstName?: str|null, number?: str }` -- Returns: `201 T20` +- Returns: `201 T21` #### Peek next customer number — `GET /entity/next-number` _none_ - Returns: `200 { number: str }` #### List entity addresses — `GET /entity/{entityId}/address` - Params: `entityId: int` -- Returns: `200 { addresses: T13[] }` +- Returns: `200 { addresses: T14[] }` #### Create entity address — `POST /entity/{entityId}/address` - Params: `entityId: int, body: { addressType: str, firstName?: str|null, name?: str|null, street?: str|null, streetNumber?: str|null, zip?: str|null, city?: str|null, county?: str|null }` -- Returns: `201 { address: T13 }` +- Returns: `201 { address: T14 }` #### Delete entity address — `DELETE /entity/{entityId}/address/{id}` - Params: `entityId: int, id: int` - Returns: `204 void` #### Update entity address — `PATCH /entity/{entityId}/address/{id}` - Params: `entityId: int, id: int, body: { addressType?: str, firstName?: str|null, name?: str|null, street?: str|null, streetNumber?: str|null, zip?: str|null, city?: str|null, county?: str|null }` -- Returns: `200 { address: T13 }` +- Returns: `200 { address: T14 }` #### List entity contacts — `GET /entity/{entityId}/contact` - Params: `entityId: int` -- Returns: `200 { contacts: T39[] }` +- Returns: `200 { contacts: T42[] }` #### Create entity contact — `POST /entity/{entityId}/contact` - Params: `entityId: int, body: { contactType: str, contact: str }` -- Returns: `201 { contact: T39 }` +- Returns: `201 { contact: T42 }` #### Delete entity contact — `DELETE /entity/{entityId}/contact/{id}` - Params: `entityId: int, id: int` - Returns: `204 void` #### Update entity contact — `PATCH /entity/{entityId}/contact/{id}` - Params: `entityId: int, id: int, body: { contactType?: str, contact?: str }` -- Returns: `200 { contact: T39 }` +- Returns: `200 { contact: T42 }` #### Delete entity — `DELETE /entity/{id}` - Params: `id: int` - Returns: `204 void` #### Get entity — `GET /entity/{id}` - Params: `id: int` -- Returns: `200 T20` +- Returns: `200 T21` #### Update entity — `PATCH /entity/{id}` - Params: `id: int, body: { name?: str, firstName?: str|null, number?: str|null }` -- Returns: `200 T20` +- Returns: `200 T21` ### Section: /events @@ -470,50 +473,50 @@ _none_ _none_ - Returns: `200 { labeltemplates: { id: int, name: str, width: num, height: num, dpi: int, type: str, thumb?: str|null }[] }` #### Create label template — `POST /labeltemplate` -- Params: `body: { name: str, width: num, height: num, dpi: int, type: str, content: T18 }` -- Returns: `201 T5` +- Params: `body: { name: str, width: num, height: num, dpi: int, type: str, content: T19 }` +- Returns: `201 T7` #### Delete label template — `DELETE /labeltemplate/{id}` - Params: `id: int` - Returns: `204 void` #### Get label template by ID — `GET /labeltemplate/{id}` - Params: `id: int` -- Returns: `200 T5` +- Returns: `200 T7` #### Update label template (partial) — `PATCH /labeltemplate/{id}` -- Params: `id: int, body: { name?: str, width?: num, height?: num, dpi?: int, type?: str, content?: T18 }` -- Returns: `200 T5` +- Params: `id: int, body: { name?: str, width?: num, height?: num, dpi?: int, type?: str, content?: T19 }` +- Returns: `200 T7` #### Update label template — `PUT /labeltemplate/{id}` -- Params: `id: int, body: { name?: str, width?: num, height?: num, dpi?: int, type?: str, content?: T18 }` -- Returns: `200 T5` +- Params: `id: int, body: { name?: str, width?: num, height?: num, dpi?: int, type?: str, content?: T19 }` +- Returns: `200 T7` ### Section: /ledger #### Query ledger by manifest article ID or SKU — `GET /ledger` - Params: `query: manifestarticle_id?: int, sku?: str, transaction_type?: str` -- Returns: `200 T14` +- Returns: `200 T15` #### Add ledger entry — `POST /ledger` - Params: `body: { manifestarticle_id: int, transaction_type: str, amount: num, transaction_text: str }` -- Returns: `201 { ledger: T15 }` +- Returns: `201 { ledger: T16 }` #### Query ledger by manifest article ID — `GET /ledger/manifestarticle/{manifestarticleId}` - Params: `manifestarticleId: int, query: transaction_type?: str` -- Returns: `200 T14` +- Returns: `200 T15` #### Query ledger by article SKU — `GET /ledger/sku/{sku}` - Params: `sku: str, query: transaction_type?: str` -- Returns: `200 T14` +- Returns: `200 T15` ### Section: /modelconversation #### List conversations — `GET /modelconversation` _none_ -- Returns: `200 { conversations: T29[] }` +- Returns: `200 { conversations: T30[] }` #### Create conversation — `POST /modelconversation` - Params: `body: { provider: str, model: str }` -- Returns: `201 { conversation: T29 }` +- Returns: `201 { conversation: T30 }` #### Delete conversation — `DELETE /modelconversation/{id}` - Params: `id: int` - Returns: `204 void` #### Get conversation — `GET /modelconversation/{id}` - Params: `id: int` -- Returns: `200 { conversation: T29 }` +- Returns: `200 { conversation: T30 }` #### List conversation messages — `GET /modelconversation/{id}/message` - Params: `id: int` - Returns: `200 { messages: { id: int, conversation_id: int, created_at: str, role: str, message: str }[] }` @@ -537,31 +540,31 @@ _none_ #### List orders — `GET /order` - Params: `query: offset?: int, limit?: int` -- Returns: `200 { orders: T11[], total: int, offset: int, limit: int }` +- Returns: `200 { orders: T4[], total: int, offset: int, limit: int }` #### Create order — `POST /order` -- Params: `body: { number: str, date: str, lines: T25[], entityId?: int|null }` -- Returns: `201 T7` +- Params: `body: { number: str, date: str, lines: T26[], entityId?: int|null }` +- Returns: `201 T3` #### Delete order — `DELETE /order/{id}` - Params: `id: int` - Returns: `204 void` #### Get order — `GET /order/{id}` - Params: `id: int` -- Returns: `200 T7` +- Returns: `200 T3` #### Update order — `PATCH /order/{id}` -- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T25[] }` -- Returns: `200 T7` +- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T26[] }` +- Returns: `200 T3` #### List payments of an order — `GET /order/{id}/payment` - Params: `id: int` -- Returns: `200 { payments: { id: int, accountId: int, manifestId: int, type: str, amount: num }[] }` +- Returns: `200 { payments: T35[] }` #### Add payment to an order — `POST /order/{id}/payment` - Params: `id: int, body: { accountId: int, type: str, amount: num }` -- Returns: `201 { payment: { id: int, accountId: int, manifestId: int, type: str, amount: num } }` +- Returns: `201 { payment: T35 }` #### List shippings of an order — `GET /order/{id}/shipping` - Params: `id: int` -- Returns: `200 { shippings: { id: int, manifestId: int, number: str, type: str, state: str }[] }` +- Returns: `200 { shippings: T39[] }` #### Create shipping for an order — `POST /order/{id}/shipping` - Params: `id: int, body: { type: str, state: str }` -- Returns: `201 { shipping: { id: int, manifestId: int, number: str, type: str, state: str } }` +- Returns: `201 { shipping: T39 }` ### Section: /package @@ -579,37 +582,37 @@ _none_ #### List POS terminals — `GET /posterminal` _none_ -- Returns: `200 { posterminals: T10[] }` +- Returns: `200 { posterminals: T11[] }` #### Create POS terminal — `PUT /posterminal` - Params: `body: { name: str, rootCategoryId?: int|null, syncRootArticles?: bool }` -- Returns: `200 { posterminal: T10 }` +- Returns: `200 { posterminal: T11 }` #### Delete POS terminal — `DELETE /posterminal/{id}` - Params: `id: int` - Returns: `204 void` #### Update POS terminal — `PATCH /posterminal/{id}` - Params: `id: int, body: { name?: str, rootCategoryId?: int|null, syncRootArticles?: bool, pairingpin?: str|null }` -- Returns: `200 { posterminal: T10 }` +- Returns: `200 { posterminal: T11 }` #### Disable all categories on terminal — `DELETE /posterminal/{id}/all` - Params: `id: int` -- Returns: `200 T45` +- Returns: `200 T48` #### Enable all categories on terminal — `PUT /posterminal/{id}/all` - Params: `id: int` -- Returns: `200 T45` +- Returns: `200 T48` #### Disable category on terminal — `DELETE /posterminal/{id}/category/{categoryId}` - Params: `id: int, categoryId: int` -- Returns: `200 T45` +- Returns: `200 T48` #### Enable category on terminal — `PUT /posterminal/{id}/category/{categoryId}` - Params: `id: int, categoryId: int` -- Returns: `200 T45` +- Returns: `200 T48` ### Section: /printer #### List printers — `GET /printer` _none_ -- Returns: `200 { printers: T24[] }` +- Returns: `200 { printers: T25[] }` #### Create printer — `POST /printer` - Params: `body: { address: str, type: str, model?: str|null, serial?: str|null, sort?: int, desc?: str|null }` -- Returns: `201 T19` +- Returns: `201 T20` #### Reorder printers — `PUT /printer/order` - Params: `body: { printerIds: int[] }` - Returns: `200 { printerIds: int[] }` @@ -618,22 +621,22 @@ _none_ - Returns: `204 void` #### Get printer by ID — `GET /printer/{id}` - Params: `id: int` -- Returns: `200 T19` +- Returns: `200 T20` #### Update printer (partial) — `PATCH /printer/{id}` - Params: `id: int, body: { address?: str, type?: str, model?: str|null, serial?: str|null, sort?: int, desc?: str|null }` -- Returns: `200 T19` +- Returns: `200 T20` #### Update printer — `PUT /printer/{id}` - Params: `id: int, body: { address?: str, type?: str, model?: str|null, serial?: str|null, sort?: int, desc?: str|null }` -- Returns: `200 T19` +- Returns: `200 T20` ### Section: /propertyname #### List property names — `GET /propertyname` _none_ -- Returns: `200 { propertynames: T33[] }` +- Returns: `200 { propertynames: T34[] }` #### Create property name — `POST /propertyname` - Params: `body: { name: str, sort?: int, exclusive?: bool }` -- Returns: `201 { propertyname: T33 }` +- Returns: `201 { propertyname: T34 }` #### Reorder property names — `PUT /propertyname/order` - Params: `body: { propertynameIds: int[] }` - Returns: `200 { ok: bool }` @@ -642,7 +645,7 @@ _none_ - Returns: `200 { ok: bool }` #### Update property name — `PATCH /propertyname/{id}` - Params: `id: int, body: { name?: str, sort?: int, exclusive?: bool }` -- Returns: `200 { propertyname: T33 }` +- Returns: `200 { propertyname: T34 }` ### Section: /public @@ -665,17 +668,17 @@ _none_ _none_ - Returns: `200 { quotes: { id: int, number: str, type: str, entityId: int|null, date: str, createdAt?: str }[] }` #### Create quote — `POST /quote` -- Params: `body: { number: str, date: str, lines: T25[], entityId?: int|null }` -- Returns: `201 T8` +- Params: `body: { number: str, date: str, lines: T26[], entityId?: int|null }` +- Returns: `201 T9` #### Delete quote — `DELETE /quote/{id}` - Params: `id: int` - Returns: `204 void` #### Get quote — `GET /quote/{id}` - Params: `id: int` -- Returns: `200 T8` +- Returns: `200 T9` #### Update quote — `PATCH /quote/{id}` -- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T25[] }` -- Returns: `200 T8` +- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T26[] }` +- Returns: `200 T9` ### Section: /serper @@ -714,28 +717,28 @@ _none_ #### Adjust stock manually — `POST /stock/adjust` - Params: `body: { sku?: str, warehouseId?: int, amount?: num, text?: str|null, lines?: { sku: str, amount: num, warehouseId?: int, text?: str }[] }` -- Returns: `201 { manifest: { id: int, number: str, type: str, date: str, createdAt: str }, lines: { manifestarticle_id: int, sku: str, name: str, warehouse_id: int, amount: num, text: str }[], ledger: T15[] }` +- Returns: `201 { manifest: { id: int, number: str, type: str, date: str, createdAt: str }, lines: { manifestarticle_id: int, sku: str, name: str, warehouse_id: int, amount: num, text: str }[], ledger: T16[] }` ### Section: /supplier #### List suppliers — `GET /supplier` _none_ -- Returns: `200 { suppliers: T40[] }` +- Returns: `200 { suppliers: T43[] }` #### Create supplier — `POST /supplier` - Params: `body: { name: str }` -- Returns: `201 { supplier: T40 }` +- Returns: `201 { supplier: T43 }` #### Delete supplier — `DELETE /supplier/{id}` - Params: `id: int` - Returns: `204 void` #### Update supplier — `PATCH /supplier/{id}` - Params: `id: int, body: { name: str }` -- Returns: `200 { supplier: T40 }` +- Returns: `200 { supplier: T43 }` #### List supplier articles by SKUs — `GET /supplier/{id}/articles` - Params: `id: int, query: skus?: string` -- Returns: `200 { articles: { id: int, articleId: int, entityId: int, pu: num, sort: int, article: { id: int, sku: str, name?: str|null, slug?: str|null, photos?: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans?: str[] }, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T43|null }[] }` +- Returns: `200 { articles: { id: int, articleId: int, entityId: int, pu: num, sort: int, article: { id: int, sku: str, name?: str|null, slug?: str|null, photos?: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans?: str[] }, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T46|null }[] }` #### Query supplier articles by SKUs (bulk) — `POST /supplier/{id}/articles` - Params: `id: int, body?: { skus?: str[] }` -- Returns: `200 { articles: { id: int, articleId: int, entityId: int, pu: num, sort: int, article: { id: int, sku: str, name?: str|null, slug?: str|null, photos?: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans?: str[] }, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T43|null }[] }` +- Returns: `200 { articles: { id: int, articleId: int, entityId: int, pu: num, sort: int, article: { id: int, sku: str, name?: str|null, slug?: str|null, photos?: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans?: str[] }, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T46|null }[] }` ### Section: /thumb @@ -750,10 +753,10 @@ _none_ - Returns: `204 void` #### List units — `GET /unit` _none_ -- Returns: `200 { units: T31[] }` +- Returns: `200 { units: T32[] }` #### Upsert unit — `PUT /unit` - Params: `body: { si: str, basesi: str, basesifactor: num, symbol: str, name: str }` -- Returns: `200 { unit: T31 }` +- Returns: `200 { unit: T32 }` ### Section: /v1 @@ -804,10 +807,10 @@ _none_ #### List warehouses — `GET /warehouse` _none_ -- Returns: `200 { warehouses: T44[] }` +- Returns: `200 { warehouses: T47[] }` #### Create warehouse — `POST /warehouse` - Params: `body: { name: str, sort?: int }` -- Returns: `201 T42` +- Returns: `201 T45` #### Reorder warehouses — `PUT /warehouse/order` - Params: `body: { warehouseIds: int[] }` - Returns: `200 { warehouseIds: int[] }` @@ -816,10 +819,10 @@ _none_ - Returns: `204 void` #### Get warehouse by ID — `GET /warehouse/{id}` - Params: `id: int` -- Returns: `200 T42` +- Returns: `200 T45` #### Update warehouse (partial) — `PATCH /warehouse/{id}` - Params: `id: int, body: { name?: str, sort?: int }` -- Returns: `200 T42` +- Returns: `200 T45` #### Update warehouse — `PUT /warehouse/{id}` - Params: `id: int, body: { name?: str, sort?: int }` -- Returns: `200 T42` +- Returns: `200 T45` diff --git a/docs/api/routes.md b/docs/api/routes.md index 6a9e423..6eb784d 100644 --- a/docs/api/routes.md +++ b/docs/api/routes.md @@ -10,45 +10,48 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body). ### Reusable types - `T1` = `{ article: T2 }` -- `T2` = `{ id: int, sku: str, name: str, slug: str, desc: str|null, seo: str|null, track_stock: bool, unitamount: num|null, weight: num|null, unit: T29, brand: T27|null, categoryIds: int[], photos: T25[], eans: str[], prices: T33[], suppliers: T11[] }` -- `T3` = `{ delivery: T4 }` -- `T4` = `{ id: int, number: str, type: str, supplierId: int|null, date: str, lines: T20[], files: T9[], externalNumber?: str|null, createdAt?: str, ledger?: T37 }` -- `T5` = `{ labeltemplate: T6 }` -- `T6` = `{ id: int, name: str, width: num, height: num, dpi: int, type: str, content: T16, thumb?: str|null }` -- `T7` = `{ order: T10 }` -- `T8` = `{ quote: T10 }` -- `T9` = `{ id: int, manifestId: int, fileId: int, sort: int, hash: str, mimetype: str, name: str, size: int, created?: str, modified?: str, thumbavif?: str|null, thumbx?: int|null, thumby?: int|null, meta?: { [k]: str }|null }` -- `T10` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T20[], createdAt?: str }` -- `T11` = `{ id: int, articleId: int, entityId: int, pu: num, sort: int, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T39|null }` -- `T12` = `{ id: int, entityId: int, addressType: str, firstName?: str|null, name?: str|null, street?: str|null, streetNumber?: str|null, zip?: str|null, city?: str|null, county?: str|null }` -- `T13` = `{ ledger: T14[] }` -- `T14` = `{ id: int, manifestarticle_id: int, transaction_type: str, amount: num, transaction_text: str, hash_version: int, prev_hash?: str, sku?: str|null, created_at?: str }` -- `T15` = `{ id: int, name: str, sort: int, exclusive: bool, values: T30[], articleCount?: int }` -- `T16` = `{ objects: T21[] }` +- `T2` = `{ id: int, sku: str, name: str, slug: str, desc: str|null, seo: str|null, track_stock: bool, unitamount: num|null, weight: num|null, unit: T30, brand: T28|null, categoryIds: int[], photos: T26[], eans: str[], prices: T36[], suppliers: T12[] }` +- `T3` = `{ order: T4 }` +- `T4` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T21[], createdAt?: str, shipping?: T35|null, shippings?: T35[], payment?: T33|null, payments?: T33[], paid?: bool, delivered?: bool }` +- `T5` = `{ delivery: T6 }` +- `T6` = `{ id: int, number: str, type: str, supplierId: int|null, date: str, lines: T21[], files: T10[], externalNumber?: str|null, createdAt?: str, ledger?: T40 }` +- `T7` = `{ labeltemplate: T8 }` +- `T8` = `{ id: int, name: str, width: num, height: num, dpi: int, type: str, content: T17, thumb?: str|null }` +- `T9` = `{ quote: T11 }` +- `T10` = `{ id: int, manifestId: int, fileId: int, sort: int, hash: str, mimetype: str, name: str, size: int, created?: str, modified?: str, thumbavif?: str|null, thumbx?: int|null, thumby?: int|null, meta?: { [k]: str }|null }` +- `T11` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T21[], createdAt?: str }` +- `T12` = `{ id: int, articleId: int, entityId: int, pu: num, sort: int, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T42|null }` +- `T13` = `{ id: int, entityId: int, addressType: str, firstName?: str|null, name?: str|null, street?: str|null, streetNumber?: str|null, zip?: str|null, city?: str|null, county?: str|null }` +- `T14` = `{ ledger: T15[] }` +- `T15` = `{ id: int, manifestarticle_id: int, transaction_type: str, amount: num, transaction_text: str, hash_version: int, prev_hash?: str, sku?: str|null, created_at?: str }` +- `T16` = `{ id: int, name: str, sort: int, exclusive: bool, values: T31[], articleCount?: int }` - `T17` = `{ objects: T22[] }` -- `T18` = `{ printer: T23 }` -- `T19` = `{ entity: T26 }` -- `T20` = `{ id: int, sku: str|null, name: str|null, pu: num, amount: num, net: num, rebate: num, taxrate: num, comment: str|null }` -- `T21` = `{ id: str, type: str, x: num, y: num, w?: num, h?: num, text?: str, font?: str, fontSize?: num, barcodeFormat?: str }` +- `T18` = `{ objects: T23[] }` +- `T19` = `{ printer: T24 }` +- `T20` = `{ entity: T27 }` +- `T21` = `{ id: int, sku: str|null, name: str|null, pu: num, amount: num, net: num, rebate: num, taxrate: num, comment: str|null }` - `T22` = `{ id: str, type: str, x: num, y: num, w?: num, h?: num, text?: str, font?: str, fontSize?: num, barcodeFormat?: str }` -- `T23` = `{ id: int, company_id: int, address: str, type: str, sort: int, model?: str|null, serial?: str|null, desc?: str|null }` -- `T24` = `{ amount: num, net: num, taxrate: num, sku?: str|null, name?: str|null, pu?: num, rebate?: num, comment?: str|null }` -- `T25` = `{ sort: int, fullHash: str, fullW: int, fullH: int, fullSize: int, thumbW: int, thumbH: int, thumbHash: str }` -- `T26` = `{ id: int, customergroupId: int, firstName: str|null, name: str, number: str|null, createdAt: str, updatedAt: str }` -- `T27` = `{ name: str, id?: int|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null }` -- `T28` = `{ article: T32 }` -- `T29` = `{ si: str, basesi: str, basesifactor: num, symbol?: str|null, name?: str|null }` -- `T30` = `{ id: int, attributeId: int, value: str, sort: int, articleCount?: int }` -- `T31` = `{ id: int, name: str, sort: int, exclusive: bool, articleCount?: int }` -- `T32` = `{ id: int, categoryId: int, name: str, sku: str, track_stock: bool }` -- `T33` = `{ minmultiplier: num, net: num, taxRate: num, customergroupId: int }` -- `T34` = `{ fullHash: str, thumbW: int, thumbH: int, thumbHash: str }` -- `T35` = `{ id: int, entityId: int, contactType: str, contact: str }` -- `T36` = `{ id: int, name: str, createdAt: str, updatedAt: str }` -- `T37` = `{ totalPositions: int, completelyOnLedgerPositions: int }` -- `T38` = `{ warehouse: T40 }` -- `T39` = `{ net: num, taxId: int, taxRate?: num|null }` -- `T40` = `{ id: int, name: str, sort: int }` +- `T23` = `{ id: str, type: str, x: num, y: num, w?: num, h?: num, text?: str, font?: str, fontSize?: num, barcodeFormat?: str }` +- `T24` = `{ id: int, company_id: int, address: str, type: str, sort: int, model?: str|null, serial?: str|null, desc?: str|null }` +- `T25` = `{ amount: num, net: num, taxrate: num, sku?: str|null, name?: str|null, pu?: num, rebate?: num, comment?: str|null }` +- `T26` = `{ sort: int, fullHash: str, fullW: int, fullH: int, fullSize: int, thumbW: int, thumbH: int, thumbHash: str }` +- `T27` = `{ id: int, customergroupId: int, firstName: str|null, name: str, number: str|null, createdAt: str, updatedAt: str }` +- `T28` = `{ name: str, id?: int|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null }` +- `T29` = `{ article: T34 }` +- `T30` = `{ si: str, basesi: str, basesifactor: num, symbol?: str|null, name?: str|null }` +- `T31` = `{ id: int, attributeId: int, value: str, sort: int, articleCount?: int }` +- `T32` = `{ id: int, name: str, sort: int, exclusive: bool, articleCount?: int }` +- `T33` = `{ id: int, accountId: int, manifestId: int, type: str, amount: num }` +- `T34` = `{ id: int, categoryId: int, name: str, sku: str, track_stock: bool }` +- `T35` = `{ id: int, manifestId: int, number: str, type: str, state: str }` +- `T36` = `{ minmultiplier: num, net: num, taxRate: num, customergroupId: int }` +- `T37` = `{ fullHash: str, thumbW: int, thumbH: int, thumbHash: str }` +- `T38` = `{ id: int, entityId: int, contactType: str, contact: str }` +- `T39` = `{ id: int, name: str, createdAt: str, updatedAt: str }` +- `T40` = `{ totalPositions: int, completelyOnLedgerPositions: int }` +- `T41` = `{ warehouse: T43 }` +- `T42` = `{ net: num, taxId: int, taxRate?: num|null }` +- `T43` = `{ id: int, name: str, sort: int }` ### Routes @@ -69,7 +72,7 @@ _none_ #### Create article in category — `POST /article` - Params: `body: { categoryId: int, name: str, desc?: str, seo?: str, track_stock?: bool }` -- Returns: `201 T28` +- Returns: `201 T29` #### Delete article by SKU — `DELETE /article/{sku}` - Params: `sku: str, query: cascade?: bool` - Returns: `204 void` @@ -102,10 +105,10 @@ _none_ - Returns: `200 { children: { id: int, sku: str, name: str, parentsort: int, attributeValueId: int, attributeValue: str }[] }` #### Create and attach a new child article to a parent article — `POST /article/{sku}/children` - Params: `sku: str, body: { attributeValueId?: int, value?: str, name?: str }` -- Returns: `201 T28` +- Returns: `201 T29` #### Attach an existing article as a child to a parent article — `PUT /article/{sku}/children` - Params: `sku: str, body: { sku: str, attributeValueId?: int, value?: str, reparent?: bool }` -- Returns: `200 { article: T32, children: { id: int, sku: str, name: str, parentsort: int, attributeValueId: int, attributeValue: str }[] }` +- Returns: `200 { article: T34, children: { id: int, sku: str, name: str, parentsort: int, attributeValueId: int, attributeValue: str }[] }` #### Remove a child article from a parent article — `DELETE /article/{sku}/children/{childSku}` - Params: `sku: str, childSku: str, query: deleteArticle?: bool` - Returns: `200 { success: bool, deleted: bool }` @@ -129,7 +132,7 @@ _none_ - Returns: `200 { options: { id: int, articleId: int, sku: str, name: str, count: int, sort: int, mandated: bool }[] }` #### Toggle parent mode for an article — `POST /article/{sku}/parent` - Params: `sku: str, body: { isParent: bool, attributeNameId?: int }` -- Returns: `200 T28` +- Returns: `200 T29` #### Replace POS prices by SKU (net > gross; price=net, tax=taxRate %) — `PUT /article/{sku}/prices` - Params: `sku: str, body: { prices: { net?: num, gross?: num, price?: num, taxRate?: num, tax?: num, minmultiplier?: num }[] }` - Returns: `200 T1` @@ -147,10 +150,10 @@ _none_ - Returns: `200 { ok: bool }` #### List article suppliers — `GET /article/{sku}/supplier` - Params: `sku: str` -- Returns: `200 { suppliers: T11[] }` +- Returns: `200 { suppliers: T12[] }` #### Assign supplier to article — `POST /article/{sku}/supplier` - Params: `sku: str, body: { entityId: int, sku?: str|null, pu?: num, stock?: num|null, sort?: int|null, netPrice?: num|null, taxId?: int|null, taxRate?: num|null }` -- Returns: `201 { supplier: T11 }` +- Returns: `201 { supplier: T12 }` #### Reorder article suppliers — `PUT /article/{sku}/supplier/order` - Params: `sku: str, body: { ids: int[] }` - Returns: `200 { ids: int[] }` @@ -159,7 +162,7 @@ _none_ - Returns: `204 void` #### Update article supplier assignment — `PATCH /article/{sku}/supplier/{id}` - Params: `sku: str, id: int, body: { sku?: str|null, pu?: num, stock?: num|null, sort?: int, netPrice?: num|null, taxId?: int|null, taxRate?: num|null }` -- Returns: `200 { supplier: T11 }` +- Returns: `200 { supplier: T12 }` #### Set article track_stock flag by SKU — `PUT /article/{sku}/track_stock` - Params: `sku: str, body: { track_stock: bool }` - Returns: `200 T1` @@ -171,19 +174,19 @@ _none_ #### List attribute names — `GET /attributename` _none_ -- Returns: `200 { attributenames: T15[] }` +- Returns: `200 { attributenames: T16[] }` #### Create attribute name — `POST /attributename` - Params: `body: { name: str, sort?: int, exclusive?: bool }` -- Returns: `201 { attributename: T15 }` +- Returns: `201 { attributename: T16 }` #### Reorder attribute names — `PUT /attributename/order` - Params: `body: { attributenameIds: int[] }` - Returns: `200 { ok: bool }` #### List values for an attribute — `GET /attributename/{attributeId}/value` - Params: `attributeId: int` -- Returns: `200 { values: T30[] }` +- Returns: `200 { values: T31[] }` #### Create value for an attribute — `POST /attributename/{attributeId}/value` - Params: `attributeId: int, body: { value: str, sort?: int }` -- Returns: `201 { attributevalue: T30 }` +- Returns: `201 { attributevalue: T31 }` #### Reorder values of an attribute — `PUT /attributename/{attributeId}/value/order` - Params: `attributeId: int, body: { attributevalueIds: int[] }` - Returns: `200 { ok: bool }` @@ -192,7 +195,7 @@ _none_ - Returns: `200 { ok: bool }` #### Update attribute name — `PATCH /attributename/{id}` - Params: `id: int, body: { name?: str, sort?: int, exclusive?: bool }` -- Returns: `200 { attributename: T15 }` +- Returns: `200 { attributename: T16 }` ### Section: /attributevalue @@ -201,13 +204,13 @@ _none_ - Returns: `200 { ok: bool }` #### Update attribute value — `PATCH /attributevalue/{id}` - Params: `id: int, body: { value?: str, sort?: int }` -- Returns: `200 { attributevalue: T30 }` +- Returns: `200 { attributevalue: T31 }` #### Delete attribute value image — `DELETE /attributevalue/{id}/image` - Params: `id: int` -- Returns: `200 { attributevalue: { id: int, thumbW: int|null, thumbH: int|null, thumbHash: str|null, pics: T34[] } }` +- Returns: `200 { attributevalue: { id: int, thumbW: int|null, thumbH: int|null, thumbHash: str|null, pics: T37[] } }` #### Add or replace attribute value image — `POST /attributevalue/{id}/image` - Params: `id: int, image/avif` -- Returns: `201 { attributevalue: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T34[] } }` +- Returns: `201 { attributevalue: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T37[] } }` ### Section: /auth @@ -225,7 +228,7 @@ _none_ - Returns: `200 { brands: { id: int, name: str, articleCount: int, pics: { fullHash: str, thumbW: int, thumbH: int, thumbHash: str, smallThumbW?: int|null, smallThumbH?: int|null, smallThumbBinary?: str|null }[], gsprpinfo?: str|null }[], total: int, offset: int, limit: int }` #### Create brand — `POST /brand` - Params: `body: { name: str, gsprpinfo?: str }` -- Returns: `201 { brand: { id: int, name: str, pics: T34[], gsprpinfo?: str|null } }` +- Returns: `201 { brand: { id: int, name: str, pics: T37[], gsprpinfo?: str|null } }` #### Delete brand — `DELETE /brand/{id}` - Params: `id: int` - Returns: `204 void` @@ -234,10 +237,10 @@ _none_ - Returns: `200 { brand: { id: int, name: str, touchedArticleCount: int, gsprpinfo?: str|null } }` #### Delete brand image — `DELETE /brand/{id}/image` - Params: `id: int` -- Returns: `200 { brand: { id: int, thumbW: int|null, thumbH: int|null, thumbHash: str|null, pics: T34[] } }` +- Returns: `200 { brand: { id: int, thumbW: int|null, thumbH: int|null, thumbHash: str|null, pics: T37[] } }` #### Add or replace brand image — `POST /brand/{id}/image` - Params: `id: int, image/avif` -- Returns: `201 { brand: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T34[] } }` +- Returns: `201 { brand: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T37[] } }` ### Section: /category @@ -249,7 +252,7 @@ _none_ - Returns: `200 { categoryIds: int[] }` #### Category tree — `GET /category/tree` _none_ -- Returns: `200 { languageId: int, tree: { id: int, sort: int, posterminalIds: int[], parentId?: int|null, name?: str|null, slug?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null }[], articles: { id: int, sku: str, name: str, slug: str, track_stock: bool, optionsCount: int, articleListCount: int, childCount: int, net?: num|null, taxRate?: num|null, parentArticleId?: int|null, parentSku?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null, brand?: T27|null }[] }` +- Returns: `200 { languageId: int, tree: { id: int, sort: int, posterminalIds: int[], parentId?: int|null, name?: str|null, slug?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null }[], articles: { id: int, sku: str, name: str, slug: str, track_stock: bool, optionsCount: int, articleListCount: int, childCount: int, net?: num|null, taxRate?: num|null, parentArticleId?: int|null, parentSku?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null, brand?: T28|null }[] }` #### Delete category — `DELETE /category/{id}` - Params: `id: int, query: recursive?: bool` - Returns: `204 void` @@ -258,7 +261,7 @@ _none_ - Returns: `200 { category: { id: int, name: str, slug: str, parentId: int, sort: int } }` #### Articles in category — `GET /category/{id}/articles` - Params: `id: int` -- Returns: `200 { articles: { id: int, sku: str, name: str, slug: str, track_stock: bool, optionsCount: int, articleListCount: int, childCount: int, net?: num|null, taxRate?: num|null, parentArticleId?: int|null, parentSku?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null, brand?: T27|null }[] }` +- Returns: `200 { articles: { id: int, sku: str, name: str, slug: str, track_stock: bool, optionsCount: int, articleListCount: int, childCount: int, net?: num|null, taxRate?: num|null, parentArticleId?: int|null, parentSku?: str|null, fullHash?: str|null, thumbW?: int|null, thumbH?: int|null, thumbHash?: str|null, brand?: T28|null }[] }` #### List category attribute values — `GET /category/{id}/attributevalue` - Params: `id: int` - Returns: `200 { attributevalues: { id: int, attributeId: int, attributeName: str, attributeValueId: int, value: str, sort: int, categoryId?: int, exclusive?: bool }[] }` @@ -312,7 +315,7 @@ _none_ - Returns: `200 { customergroups: { id: int, name: str, sort: int, editable: bool }[] }` #### Create customer group — `POST /customergroup` - Params: `body: { name: str }` -- Returns: `201 { customergroup: T40 }` +- Returns: `201 { customergroup: T43 }` #### Reorder customer groups — `PUT /customergroup/order` - Params: `body: { customergroupIds: int[] }` - Returns: `200 { customergroupIds: int[] }` @@ -321,25 +324,25 @@ _none_ - Returns: `204 void` #### Update customer group — `PATCH /customergroup/{id}` - Params: `id: int, body: { name: str }` -- Returns: `200 { customergroup: T40 }` +- Returns: `200 { customergroup: T43 }` ### Section: /delivery #### List deliveries — `GET /delivery` _none_ -- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int|null, date: str, externalNumber?: str|null, createdAt?: str, ledger?: T37 }[] }` +- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int|null, date: str, externalNumber?: str|null, createdAt?: str, ledger?: T40 }[] }` #### Create delivery — `POST /delivery` -- Params: `body: { externalNumber: str, date: str, lines: T24[], supplierId?: int|null, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` -- Returns: `201 T3` +- Params: `body: { externalNumber: str, date: str, lines: T25[], supplierId?: int|null, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` +- Returns: `201 T5` #### Delete delivery — `DELETE /delivery/{id}` - Params: `id: int` - Returns: `204 void` #### Get delivery — `GET /delivery/{id}` - Params: `id: int` -- Returns: `200 T3` +- Returns: `200 T5` #### Update delivery — `PATCH /delivery/{id}` -- Params: `id: int, body: { externalNumber?: str|null, date?: str, supplierId?: int|null, lines?: T24[], files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` -- Returns: `200 T3` +- Params: `id: int, body: { externalNumber?: str|null, date?: str, supplierId?: int|null, lines?: T25[], files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }` +- Returns: `200 T5` #### Get delivery attachment file content — `GET /delivery/{id}/file/{fileId}` - Params: `id: int, fileId: int, query: download?: bool` - Returns: `200 str` @@ -348,46 +351,46 @@ _none_ #### List entities — `GET /entity` - Params: `query: customergroupId?: int, role?: str` -- Returns: `200 { entities: T26[] }` +- Returns: `200 { entities: T27[] }` #### Create entity — `POST /entity` - Params: `body: { customergroupId: int, name: str, firstName?: str|null, number?: str }` -- Returns: `201 T19` +- Returns: `201 T20` #### Peek next customer number — `GET /entity/next-number` _none_ - Returns: `200 { number: str }` #### List entity addresses — `GET /entity/{entityId}/address` - Params: `entityId: int` -- Returns: `200 { addresses: T12[] }` +- Returns: `200 { addresses: T13[] }` #### Create entity address — `POST /entity/{entityId}/address` - Params: `entityId: int, body: { addressType: str, firstName?: str|null, name?: str|null, street?: str|null, streetNumber?: str|null, zip?: str|null, city?: str|null, county?: str|null }` -- Returns: `201 { address: T12 }` +- Returns: `201 { address: T13 }` #### Delete entity address — `DELETE /entity/{entityId}/address/{id}` - Params: `entityId: int, id: int` - Returns: `204 void` #### Update entity address — `PATCH /entity/{entityId}/address/{id}` - Params: `entityId: int, id: int, body: { addressType?: str, firstName?: str|null, name?: str|null, street?: str|null, streetNumber?: str|null, zip?: str|null, city?: str|null, county?: str|null }` -- Returns: `200 { address: T12 }` +- Returns: `200 { address: T13 }` #### List entity contacts — `GET /entity/{entityId}/contact` - Params: `entityId: int` -- Returns: `200 { contacts: T35[] }` +- Returns: `200 { contacts: T38[] }` #### Create entity contact — `POST /entity/{entityId}/contact` - Params: `entityId: int, body: { contactType: str, contact: str }` -- Returns: `201 { contact: T35 }` +- Returns: `201 { contact: T38 }` #### Delete entity contact — `DELETE /entity/{entityId}/contact/{id}` - Params: `entityId: int, id: int` - Returns: `204 void` #### Update entity contact — `PATCH /entity/{entityId}/contact/{id}` - Params: `entityId: int, id: int, body: { contactType?: str, contact?: str }` -- Returns: `200 { contact: T35 }` +- Returns: `200 { contact: T38 }` #### Delete entity — `DELETE /entity/{id}` - Params: `id: int` - Returns: `204 void` #### Get entity — `GET /entity/{id}` - Params: `id: int` -- Returns: `200 T19` +- Returns: `200 T20` #### Update entity — `PATCH /entity/{id}` - Params: `id: int, body: { name?: str, firstName?: str|null, number?: str|null }` -- Returns: `200 T19` +- Returns: `200 T20` ### Section: /labeltemplate @@ -395,35 +398,35 @@ _none_ _none_ - Returns: `200 { labeltemplates: { id: int, name: str, width: num, height: num, dpi: int, type: str, thumb?: str|null }[] }` #### Create label template — `POST /labeltemplate` -- Params: `body: { name: str, width: num, height: num, dpi: int, type: str, content: T17 }` -- Returns: `201 T5` +- Params: `body: { name: str, width: num, height: num, dpi: int, type: str, content: T18 }` +- Returns: `201 T7` #### Delete label template — `DELETE /labeltemplate/{id}` - Params: `id: int` - Returns: `204 void` #### Get label template by ID — `GET /labeltemplate/{id}` - Params: `id: int` -- Returns: `200 T5` +- Returns: `200 T7` #### Update label template (partial) — `PATCH /labeltemplate/{id}` -- Params: `id: int, body: { name?: str, width?: num, height?: num, dpi?: int, type?: str, content?: T17 }` -- Returns: `200 T5` +- Params: `id: int, body: { name?: str, width?: num, height?: num, dpi?: int, type?: str, content?: T18 }` +- Returns: `200 T7` #### Update label template — `PUT /labeltemplate/{id}` -- Params: `id: int, body: { name?: str, width?: num, height?: num, dpi?: int, type?: str, content?: T17 }` -- Returns: `200 T5` +- Params: `id: int, body: { name?: str, width?: num, height?: num, dpi?: int, type?: str, content?: T18 }` +- Returns: `200 T7` ### Section: /ledger #### Query ledger by manifest article ID or SKU — `GET /ledger` - Params: `query: manifestarticle_id?: int, sku?: str, transaction_type?: str` -- Returns: `200 T13` +- Returns: `200 T14` #### Add ledger entry — `POST /ledger` - Params: `body: { manifestarticle_id: int, transaction_type: str, amount: num, transaction_text: str }` -- Returns: `201 { ledger: T14 }` +- Returns: `201 { ledger: T15 }` #### Query ledger by manifest article ID — `GET /ledger/manifestarticle/{manifestarticleId}` - Params: `manifestarticleId: int, query: transaction_type?: str` -- Returns: `200 T13` +- Returns: `200 T14` #### Query ledger by article SKU — `GET /ledger/sku/{sku}` - Params: `sku: str, query: transaction_type?: str` -- Returns: `200 T13` +- Returns: `200 T14` ### Section: /number @@ -438,31 +441,31 @@ _none_ #### List orders — `GET /order` - Params: `query: offset?: int, limit?: int` -- Returns: `200 { orders: T10[], total: int, offset: int, limit: int }` +- Returns: `200 { orders: T4[], total: int, offset: int, limit: int }` #### Create order — `POST /order` -- Params: `body: { number: str, date: str, lines: T24[], entityId?: int|null }` -- Returns: `201 T7` +- Params: `body: { number: str, date: str, lines: T25[], entityId?: int|null }` +- Returns: `201 T3` #### Delete order — `DELETE /order/{id}` - Params: `id: int` - Returns: `204 void` #### Get order — `GET /order/{id}` - Params: `id: int` -- Returns: `200 T7` +- Returns: `200 T3` #### Update order — `PATCH /order/{id}` -- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T24[] }` -- Returns: `200 T7` +- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T25[] }` +- Returns: `200 T3` #### List payments of an order — `GET /order/{id}/payment` - Params: `id: int` -- Returns: `200 { payments: { id: int, accountId: int, manifestId: int, type: str, amount: num }[] }` +- Returns: `200 { payments: T33[] }` #### Add payment to an order — `POST /order/{id}/payment` - Params: `id: int, body: { accountId: int, type: str, amount: num }` -- Returns: `201 { payment: { id: int, accountId: int, manifestId: int, type: str, amount: num } }` +- Returns: `201 { payment: T33 }` #### List shippings of an order — `GET /order/{id}/shipping` - Params: `id: int` -- Returns: `200 { shippings: { id: int, manifestId: int, number: str, type: str, state: str }[] }` +- Returns: `200 { shippings: T35[] }` #### Create shipping for an order — `POST /order/{id}/shipping` - Params: `id: int, body: { type: str, state: str }` -- Returns: `201 { shipping: { id: int, manifestId: int, number: str, type: str, state: str } }` +- Returns: `201 { shipping: T35 }` ### Section: /package @@ -480,10 +483,10 @@ _none_ #### List printers — `GET /printer` _none_ -- Returns: `200 { printers: T23[] }` +- Returns: `200 { printers: T24[] }` #### Create printer — `POST /printer` - Params: `body: { address: str, type: str, model?: str|null, serial?: str|null, sort?: int, desc?: str|null }` -- Returns: `201 T18` +- Returns: `201 T19` #### Reorder printers — `PUT /printer/order` - Params: `body: { printerIds: int[] }` - Returns: `200 { printerIds: int[] }` @@ -492,22 +495,22 @@ _none_ - Returns: `204 void` #### Get printer by ID — `GET /printer/{id}` - Params: `id: int` -- Returns: `200 T18` +- Returns: `200 T19` #### Update printer (partial) — `PATCH /printer/{id}` - Params: `id: int, body: { address?: str, type?: str, model?: str|null, serial?: str|null, sort?: int, desc?: str|null }` -- Returns: `200 T18` +- Returns: `200 T19` #### Update printer — `PUT /printer/{id}` - Params: `id: int, body: { address?: str, type?: str, model?: str|null, serial?: str|null, sort?: int, desc?: str|null }` -- Returns: `200 T18` +- Returns: `200 T19` ### Section: /propertyname #### List property names — `GET /propertyname` _none_ -- Returns: `200 { propertynames: T31[] }` +- Returns: `200 { propertynames: T32[] }` #### Create property name — `POST /propertyname` - Params: `body: { name: str, sort?: int, exclusive?: bool }` -- Returns: `201 { propertyname: T31 }` +- Returns: `201 { propertyname: T32 }` #### Reorder property names — `PUT /propertyname/order` - Params: `body: { propertynameIds: int[] }` - Returns: `200 { ok: bool }` @@ -516,7 +519,7 @@ _none_ - Returns: `200 { ok: bool }` #### Update property name — `PATCH /propertyname/{id}` - Params: `id: int, body: { name?: str, sort?: int, exclusive?: bool }` -- Returns: `200 { propertyname: T31 }` +- Returns: `200 { propertyname: T32 }` ### Section: /quote @@ -524,17 +527,17 @@ _none_ _none_ - Returns: `200 { quotes: { id: int, number: str, type: str, entityId: int|null, date: str, createdAt?: str }[] }` #### Create quote — `POST /quote` -- Params: `body: { number: str, date: str, lines: T24[], entityId?: int|null }` -- Returns: `201 T8` +- Params: `body: { number: str, date: str, lines: T25[], entityId?: int|null }` +- Returns: `201 T9` #### Delete quote — `DELETE /quote/{id}` - Params: `id: int` - Returns: `204 void` #### Get quote — `GET /quote/{id}` - Params: `id: int` -- Returns: `200 T8` +- Returns: `200 T9` #### Update quote — `PATCH /quote/{id}` -- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T24[] }` -- Returns: `200 T8` +- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T25[] }` +- Returns: `200 T9` ### Section: /shipping @@ -558,28 +561,28 @@ _none_ #### Adjust stock manually — `POST /stock/adjust` - Params: `body: { sku?: str, warehouseId?: int, amount?: num, text?: str|null, lines?: { sku: str, amount: num, warehouseId?: int, text?: str }[] }` -- Returns: `201 { manifest: { id: int, number: str, type: str, date: str, createdAt: str }, lines: { manifestarticle_id: int, sku: str, name: str, warehouse_id: int, amount: num, text: str }[], ledger: T14[] }` +- Returns: `201 { manifest: { id: int, number: str, type: str, date: str, createdAt: str }, lines: { manifestarticle_id: int, sku: str, name: str, warehouse_id: int, amount: num, text: str }[], ledger: T15[] }` ### Section: /supplier #### List suppliers — `GET /supplier` _none_ -- Returns: `200 { suppliers: T36[] }` +- Returns: `200 { suppliers: T39[] }` #### Create supplier — `POST /supplier` - Params: `body: { name: str }` -- Returns: `201 { supplier: T36 }` +- Returns: `201 { supplier: T39 }` #### Delete supplier — `DELETE /supplier/{id}` - Params: `id: int` - Returns: `204 void` #### Update supplier — `PATCH /supplier/{id}` - Params: `id: int, body: { name: str }` -- Returns: `200 { supplier: T36 }` +- Returns: `200 { supplier: T39 }` #### List supplier articles by SKUs — `GET /supplier/{id}/articles` - Params: `id: int, query: skus?: string` -- Returns: `200 { articles: { id: int, articleId: int, entityId: int, pu: num, sort: int, article: { id: int, sku: str, name?: str|null, slug?: str|null, photos?: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans?: str[] }, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T39|null }[] }` +- Returns: `200 { articles: { id: int, articleId: int, entityId: int, pu: num, sort: int, article: { id: int, sku: str, name?: str|null, slug?: str|null, photos?: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans?: str[] }, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T42|null }[] }` #### Query supplier articles by SKUs (bulk) — `POST /supplier/{id}/articles` - Params: `id: int, body?: { skus?: str[] }` -- Returns: `200 { articles: { id: int, articleId: int, entityId: int, pu: num, sort: int, article: { id: int, sku: str, name?: str|null, slug?: str|null, photos?: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans?: str[] }, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T39|null }[] }` +- Returns: `200 { articles: { id: int, articleId: int, entityId: int, pu: num, sort: int, article: { id: int, sku: str, name?: str|null, slug?: str|null, photos?: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans?: str[] }, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T42|null }[] }` ### Section: /unit @@ -588,19 +591,19 @@ _none_ - Returns: `204 void` #### List units — `GET /unit` _none_ -- Returns: `200 { units: T29[] }` +- Returns: `200 { units: T30[] }` #### Upsert unit — `PUT /unit` - Params: `body: { si: str, basesi: str, basesifactor: num, symbol: str, name: str }` -- Returns: `200 { unit: T29 }` +- Returns: `200 { unit: T30 }` ### Section: /warehouse #### List warehouses — `GET /warehouse` _none_ -- Returns: `200 { warehouses: T40[] }` +- Returns: `200 { warehouses: T43[] }` #### Create warehouse — `POST /warehouse` - Params: `body: { name: str, sort?: int }` -- Returns: `201 T38` +- Returns: `201 T41` #### Reorder warehouses — `PUT /warehouse/order` - Params: `body: { warehouseIds: int[] }` - Returns: `200 { warehouseIds: int[] }` @@ -609,13 +612,13 @@ _none_ - Returns: `204 void` #### Get warehouse by ID — `GET /warehouse/{id}` - Params: `id: int` -- Returns: `200 T38` +- Returns: `200 T41` #### Update warehouse (partial) — `PATCH /warehouse/{id}` - Params: `id: int, body: { name?: str, sort?: int }` -- Returns: `200 T38` +- Returns: `200 T41` #### Update warehouse — `PUT /warehouse/{id}` - Params: `id: int, body: { name?: str, sort?: int }` -- Returns: `200 T38` +- Returns: `200 T41` ### Binary & streaming routes (reachable only via `fetch()` in javascript_execute) These routes are NOT in the table above because their responses are binary or long-lived streams, which the `dashback_request` tool cannot return usefully. They ARE reachable from inside `javascript_execute` with `fetch("/route")`, where you can decode the bytes, write them to the VFS and embed them in your reply: diff --git a/docs/api/routes/order/create.md b/docs/api/routes/order/create.md index ee6d7c7..3711f76 100644 --- a/docs/api/routes/order/create.md +++ b/docs/api/routes/order/create.md @@ -62,7 +62,41 @@ Created order "taxrate": 1, "comment": "…" } - ] + ], + "shipping": { + "id": 1, + "manifestId": 1, + "number": "…", + "type": "…", + "state": "…" + }, + "shippings": [ + { + "id": 1, + "manifestId": 1, + "number": "…", + "type": "…", + "state": "…" + } + ], + "payment": { + "id": 1, + "accountId": 1, + "manifestId": 1, + "type": "…", + "amount": 1 + }, + "payments": [ + { + "id": 1, + "accountId": 1, + "manifestId": 1, + "type": "…", + "amount": 1 + } + ], + "paid": true, + "delivered": true } } ``` diff --git a/docs/api/routes/order/get.md b/docs/api/routes/order/get.md index 88214e4..2365c0d 100644 --- a/docs/api/routes/order/get.md +++ b/docs/api/routes/order/get.md @@ -37,7 +37,41 @@ Order "taxrate": 1, "comment": "…" } - ] + ], + "shipping": { + "id": 1, + "manifestId": 1, + "number": "…", + "type": "…", + "state": "…" + }, + "shippings": [ + { + "id": 1, + "manifestId": 1, + "number": "…", + "type": "…", + "state": "…" + } + ], + "payment": { + "id": 1, + "accountId": 1, + "manifestId": 1, + "type": "…", + "amount": 1 + }, + "payments": [ + { + "id": 1, + "accountId": 1, + "manifestId": 1, + "type": "…", + "amount": 1 + } + ], + "paid": true, + "delivered": true } } ``` diff --git a/docs/api/routes/order/list.md b/docs/api/routes/order/list.md index 2da5859..9a2fb9d 100644 --- a/docs/api/routes/order/list.md +++ b/docs/api/routes/order/list.md @@ -6,7 +6,7 @@ List orders Lists sales orders (`manifest` rows with `type = 'order'`) for the authenticated user's selected company. -Results are paged, include line items, and provide total unpaged count. +Results are paged, include line items, shipping, payment, and provide total unpaged count. ## Query parameters @@ -42,7 +42,41 @@ Order list "taxrate": 1, "comment": "…" } - ] + ], + "shipping": { + "id": 1, + "manifestId": 1, + "number": "…", + "type": "…", + "state": "…" + }, + "shippings": [ + { + "id": 1, + "manifestId": 1, + "number": "…", + "type": "…", + "state": "…" + } + ], + "payment": { + "id": 1, + "accountId": 1, + "manifestId": 1, + "type": "…", + "amount": 1 + }, + "payments": [ + { + "id": 1, + "accountId": 1, + "manifestId": 1, + "type": "…", + "amount": 1 + } + ], + "paid": true, + "delivered": true } ], "total": 1, diff --git a/docs/api/routes/order/update.md b/docs/api/routes/order/update.md index e3126c2..b52f4fd 100644 --- a/docs/api/routes/order/update.md +++ b/docs/api/routes/order/update.md @@ -56,7 +56,41 @@ Updated order "taxrate": 1, "comment": "…" } - ] + ], + "shipping": { + "id": 1, + "manifestId": 1, + "number": "…", + "type": "…", + "state": "…" + }, + "shippings": [ + { + "id": 1, + "manifestId": 1, + "number": "…", + "type": "…", + "state": "…" + } + ], + "payment": { + "id": 1, + "accountId": 1, + "manifestId": 1, + "type": "…", + "amount": 1 + }, + "payments": [ + { + "id": 1, + "accountId": 1, + "manifestId": 1, + "type": "…", + "amount": 1 + } + ], + "paid": true, + "delivered": true } } ``` diff --git a/src/api/openapi.js b/src/api/openapi.js index 85fd49d..6cea055 100644 --- a/src/api/openapi.js +++ b/src/api/openapi.js @@ -995,6 +995,24 @@ * type: array * items: * $ref: '#/components/schemas/ManifestLine' + * shipping: + * $ref: '#/components/schemas/Shipping' + * nullable: true + * shippings: + * type: array + * items: + * $ref: '#/components/schemas/Shipping' + * payment: + * $ref: '#/components/schemas/Payment' + * nullable: true + * payments: + * type: array + * items: + * $ref: '#/components/schemas/Payment' + * paid: + * type: boolean + * delivered: + * type: boolean * ArticleImage: * type: object * required: [picId, sort, full, thumb, hash, thumbHash] diff --git a/src/api/routes/order.js b/src/api/routes/order.js index ddc2eae..90814df 100644 --- a/src/api/routes/order.js +++ b/src/api/routes/order.js @@ -43,7 +43,7 @@ export function register(app, basePath = '') { * description: | * Lists sales orders (`manifest` rows with `type = 'order'`) * for the authenticated user's selected company. - * Results are paged, include line items, and provide total unpaged count. + * Results are paged, include line items, shipping, payment, and provide total unpaged count. * security: * - cookieAuth: [] * parameters: diff --git a/src/db/order.js b/src/db/order.js index f9fc379..345126d 100644 --- a/src/db/order.js +++ b/src/db/order.js @@ -1,26 +1,69 @@ import { getStore } from './store.js'; +async function enrichSingleOrder(store, googleAuthId, order) { + if (!order) return order; + const [shippings, payments] = await Promise.all([ + store.shipping.listByManifestId(googleAuthId, order.id).catch(() => []), + store.payment.listByManifestId(googleAuthId, order.id).catch(() => []), + ]); + + const isPaid = Array.isArray(payments) && payments.length > 0; + const isDelivered = Array.isArray(shippings) && shippings.some((s) => s.state === 'shipped' || s.state === 'delivered'); + + return { + ...order, + shipping: shippings[0] ?? null, + shippings: shippings ?? [], + payment: payments[0] ?? null, + payments: payments ?? [], + paid: isPaid, + delivered: isDelivered, + }; +} + +async function enrichOrderResult(store, googleAuthId, result) { + if (!result) return result; + if (Array.isArray(result)) { + return Promise.all(result.map((o) => enrichSingleOrder(store, googleAuthId, o))); + } + if (Array.isArray(result.orders)) { + const enrichedOrders = await Promise.all( + result.orders.map((o) => enrichSingleOrder(store, googleAuthId, o)) + ); + return { + ...result, + orders: enrichedOrders, + }; + } + return result; +} + export async function list(googleAuthId, opts) { const store = await getStore(); - return store.order.list(googleAuthId, opts); + const result = await store.order.list(googleAuthId, opts); + return enrichOrderResult(store, googleAuthId, result); } export async function getById(googleAuthId, id) { const store = await getStore(); - return store.order.getById(googleAuthId, id); + const order = await store.order.getById(googleAuthId, id); + return enrichSingleOrder(store, googleAuthId, order); } export async function create(googleAuthId, data) { const store = await getStore(); - return store.order.create(googleAuthId, data); + const order = await store.order.create(googleAuthId, data); + return enrichSingleOrder(store, googleAuthId, order); } export async function update(googleAuthId, id, data) { const store = await getStore(); - return store.order.update(googleAuthId, id, data); + const order = await store.order.update(googleAuthId, id, data); + return enrichSingleOrder(store, googleAuthId, order); } export async function remove(googleAuthId, id) { const store = await getStore(); return store.order.delete(googleAuthId, id); } + diff --git a/src/services/companyImport.js b/src/services/companyImport.js index b19c5c4..6511a30 100644 --- a/src/services/companyImport.js +++ b/src/services/companyImport.js @@ -179,11 +179,19 @@ export async function executeCompanyImport({ // MARK: - Phase 7: Orders / Receipts // #region Phase 7: Orders / Receipts + const allArtIdToSku = new Map(); + for (const a of artRecords) { + const kArt = cleanValue(a.id ?? a.kArtikel); + const sku = cleanValue(a.sku ?? a.cArtNr); + if (kArt && sku) allArtIdToSku.set(kArt, sku); + } + const ordersResult = await importOrders({ store, googleAuthId, manRecords, itemRecords, + jtlArtIdToSku: allArtIdToSku, progressTracker, }); // #endregion @@ -213,6 +221,8 @@ export async function executeCompanyImport({ ordersTotal: totalReceiptsCount, ordersImported: ordersResult.ordersImported, ordersSkipped: ordersResult.ordersSkipped, + paymentsImported: ordersResult.paymentsImported, + shippingsImported: ordersResult.shippingsImported, }, }; } diff --git a/src/services/companyImport/articleImporter.js b/src/services/companyImport/articleImporter.js index 67bd627..1bde335 100644 --- a/src/services/companyImport/articleImporter.js +++ b/src/services/companyImport/articleImporter.js @@ -36,8 +36,8 @@ export async function importArticles({ let articlesUpdated = 0; for (const a of includedArticles) { - const jtlArtId = String(a.kArtikel); - const sku = cleanValue(a.cArtNr); + const jtlArtId = String(a.id ?? a.kArtikel); + const sku = cleanValue(a.sku ?? a.cArtNr); if (!sku) { progressTracker.counts.articlesdone++; continue; @@ -45,15 +45,15 @@ export async function importArticles({ jtlArtIdToSku.set(jtlArtId, sku); - let name = cleanValue(a.cName); - let desc = cleanValue(a.descriptions); + let name = cleanValue(a.name ?? a.cName); + let desc = cleanValue(a.desc ?? a.descriptions); if (!name && desc) { try { const parsed = JSON.parse(desc); const item = Array.isArray(parsed) ? parsed[0] : parsed; - if (item?.cName) name = String(item.cName).trim(); - if (item?.cBeschreibung) desc = String(item.cBeschreibung).trim(); + if (item?.cName || item?.name) name = String(item.cName || item.name).trim(); + if (item?.cBeschreibung || item?.desc) desc = String(item.cBeschreibung || item.desc).trim(); } catch {} } if (!name) name = `Artikel ${sku}`; @@ -66,7 +66,7 @@ export async function importArticles({ if (rawCatStr.startsWith('[') || rawCatStr.startsWith('{')) { try { const raw = JSON.parse(rawCatStr); - parsedIds = (Array.isArray(raw) ? raw : [raw]).map((it) => String(it.kKategorie || it)); + parsedIds = (Array.isArray(raw) ? raw : [raw]).map((it) => String(it.id ?? it.kKategorie ?? it)); } catch { parsedIds = rawCatStr.split(/[\r\n,;]+/).map((s) => s.trim()).filter(Boolean); } @@ -81,12 +81,13 @@ export async function importArticles({ } const primaryCatId = assignedDashCatIds[0] || hauptDashId; - const trackStock = a.cLagerAktiv === 'Y' ? 1 : 0; - const netPrice = parseGermanFloat(a.fVKNetto, 0); - const taxRate = a.kSteuerklasse === '3' ? 7 : 19; - const barcode = cleanValue(a.cBarcode); + const rawTrack = cleanValue(a.track_strock ?? a.track_stock ?? a.cLagerAktiv); + const trackStock = (rawTrack === 'Y' || rawTrack === '1' || rawTrack === 'true') ? 1 : 0; + const netPrice = parseGermanFloat(a.net ?? a.fVKNetto, 0); + const taxRate = a.taxrate != null && String(a.taxrate).trim() !== '' ? parseGermanFloat(a.taxrate, 19) : (a.kSteuerklasse === '3' ? 7 : 19); + const barcode = cleanValue(a.ean ?? a.cBarcode); - const hersteller = cleanValue(a.Hersteller); + const hersteller = cleanValue(a.brand ?? a.Hersteller); const brandId = hersteller ? (brandNameToId.get(hersteller.toLowerCase()) || null) : null; let existingArticle = null; diff --git a/src/services/companyImport/catalogPreprocessor.js b/src/services/companyImport/catalogPreprocessor.js index b32762e..73cbf6b 100644 --- a/src/services/companyImport/catalogPreprocessor.js +++ b/src/services/companyImport/catalogPreprocessor.js @@ -20,15 +20,15 @@ export function filterCatalogRecords(catRecords, artRecords) { const excludedJtlIds = new Set(['72']); for (const c of catRecords) { - let name = (c.cName || '').trim(); + let name = (c.name || c.cName || '').trim(); if (!name) { try { const tr = JSON.parse(c.translations || '[]'); - name = tr[0]?.cName || ''; + name = tr[0]?.cName || tr[0]?.name || ''; } catch {} } if (name.toLowerCase().includes('papierkorb') || name.toLowerCase().includes('trash')) { - excludedJtlIds.add(String(c.kKategorie)); + excludedJtlIds.add(String(c.id ?? c.kKategorie)); } } @@ -36,8 +36,8 @@ export function filterCatalogRecords(catRecords, artRecords) { while (addedExcluded) { addedExcluded = false; for (const c of catRecords) { - const id = String(c.kKategorie); - const parent = String(c.kOberKategorie); + const id = String(c.id ?? c.kKategorie); + const parent = String(c.parentid ?? c.kOberKategorie); if (!excludedJtlIds.has(id) && excludedJtlIds.has(parent)) { excludedJtlIds.add(id); addedExcluded = true; @@ -45,16 +45,21 @@ export function filterCatalogRecords(catRecords, artRecords) { } } - const includedCategories = catRecords.filter((c) => !excludedJtlIds.has(String(c.kKategorie))); + const includedCategories = catRecords.filter((c) => !excludedJtlIds.has(String(c.id ?? c.kKategorie))); const includedArticles = artRecords.filter((a) => { + const rawActive = cleanValue(a.active ?? a.cAktiv); + if (rawActive === '0' || rawActive === 'N' || rawActive === 'false') { + return false; + } + const catStr = String(a.categories || '').trim(); if (!catStr) return true; let catIds = []; if (catStr.startsWith('[') || catStr.startsWith('{')) { try { const raw = JSON.parse(catStr); - catIds = (Array.isArray(raw) ? raw : [raw]).map((it) => String(it.kKategorie || it)); + catIds = (Array.isArray(raw) ? raw : [raw]).map((it) => String(it.id ?? it.kKategorie ?? it)); } catch { catIds = catStr.split(/[\r\n,;]+/).map((s) => s.trim()).filter(Boolean); } @@ -94,7 +99,7 @@ export function prepareImportTasks({ importDir, includedCategories, includedArti for (const rel of picRel.split(/[\r\n,;]+/).map((s) => s.trim()).filter(Boolean)) { const full = path.resolve(importDir, rel); if (fs.existsSync(full)) { - categoryImageTasks.push({ catJtlId: String(c.kKategorie), relPath: rel, fullPath: full }); + categoryImageTasks.push({ catJtlId: String(c.id ?? c.kKategorie), relPath: rel, fullPath: full }); } } } @@ -103,11 +108,11 @@ export function prepareImportTasks({ importDir, includedCategories, includedArti // Brand images (unique manufacturers, 1 primary logo) const brandMap = new Map(); // brandName -> array of { relPath, fullPath } for (const a of includedArticles) { - const brand = cleanValue(a.Hersteller); + const brand = cleanValue(a.brand ?? a.Hersteller); if (!brand) continue; if (!brandMap.has(brand)) { brandMap.set(brand, []); - const rawPics = String(a.manufacturerPictureFiles || '').trim(); + const rawPics = String(a.brandPictureFiles ?? a.manufacturerPictureFiles ?? '').trim(); if (rawPics) { for (const rel of rawPics.split(/[\r\n,;]+/).map((s) => s.trim()).filter(Boolean)) { const full = path.resolve(importDir, rel); @@ -129,7 +134,7 @@ export function prepareImportTasks({ importDir, includedCategories, includedArti // Article images const articleImageTasks = []; for (const a of includedArticles) { - const sku = cleanValue(a.cArtNr); + const sku = cleanValue(a.sku ?? a.cArtNr); if (!sku) continue; const rawPics = String(a.pictureFiles || '').trim(); if (rawPics) { diff --git a/src/services/companyImport/categoryImporter.js b/src/services/companyImport/categoryImporter.js index 8323f0e..cc6e1ae 100644 --- a/src/services/companyImport/categoryImporter.js +++ b/src/services/companyImport/categoryImporter.js @@ -64,14 +64,14 @@ export async function importCategories({ safety++; const remaining = []; for (const c of pendingCats) { - const jtlId = String(c.kKategorie); - const jtlParent = String(c.kOberKategorie || '0'); + const jtlId = String(c.id ?? c.kKategorie); + const jtlParent = String(c.parentid ?? c.kOberKategorie ?? '0'); - let name = cleanValue(c.cName); + let name = cleanValue(c.name ?? c.cName); if (!name) { try { const tr = JSON.parse(c.translations || '[]'); - name = tr[0]?.cName || ''; + name = tr[0]?.name || tr[0]?.cName || ''; } catch {} } if (!name) name = `Kategorie ${jtlId}`; diff --git a/src/services/companyImport/orderImporter.js b/src/services/companyImport/orderImporter.js index c01ce29..99193be 100644 --- a/src/services/companyImport/orderImporter.js +++ b/src/services/companyImport/orderImporter.js @@ -10,33 +10,37 @@ const log = createLogger('import'); // #region Order / Manifest Importer /** - * Imports order manifests and line items, resolving customer entities. + * Imports order manifests and line items, resolving customer entities, payments, and shippings. * * @param {object} params * @param {object} params.store - Store singleton * @param {number} params.googleAuthId * @param {Array>} params.manRecords * @param {Array>} params.itemRecords + * @param {Map} [params.jtlArtIdToSku] * @param {object} params.progressTracker - * @returns {Promise<{ ordersImported: number, ordersSkipped: number }>} + * @returns {Promise<{ ordersImported: number, ordersSkipped: number, paymentsImported: number, shippingsImported: number }>} */ export async function importOrders({ store, googleAuthId, manRecords, itemRecords, + jtlArtIdToSku = new Map(), progressTracker, }) { let ordersImported = 0; let ordersSkipped = 0; + let paymentsImported = 0; + let shippingsImported = 0; if (manRecords.length === 0 || itemRecords.length === 0) { - return { ordersImported, ordersSkipped }; + return { ordersImported, ordersSkipped, paymentsImported, shippingsImported }; } const itemsByAuftrag = new Map(); for (const it of itemRecords) { - const kAuftrag = String(it.kAuftrag || '').trim(); + const kAuftrag = String(it.manifestid ?? it.kAuftrag ?? '').trim(); if (!kAuftrag) continue; if (!itemsByAuftrag.has(kAuftrag)) { itemsByAuftrag.set(kAuftrag, []); @@ -88,8 +92,38 @@ export async function importOrders({ } }; + const accountMap = new Map(); + try { + const accounts = await store.account.list(googleAuthId); + for (const acc of accounts) { + if (acc.name) { + accountMap.set(acc.name.trim().toLowerCase(), acc.id); + } + } + } catch (err) { + log.warn('Could not list accounts:', err.message); + } + + const resolveAccountId = async (accountName) => { + const cleanAccName = (accountName || 'Bar').trim(); + const key = cleanAccName.toLowerCase(); + if (accountMap.has(key)) return accountMap.get(key); + + try { + const created = await store.account.create(googleAuthId, { + type: cleanAccName, + name: cleanAccName, + }); + accountMap.set(key, created.id); + return created.id; + } catch (err) { + log.warn(`Could not create account "${cleanAccName}":`, err.message); + return accountMap.values().next().value || null; + } + }; + for (const m of manRecords) { - const orderNumber = cleanValue(m.cAuftragsNr); + const orderNumber = cleanValue(m.nr ?? m.cAuftragsNr); if (!orderNumber || existingOrderNumbers.has(orderNumber)) { ordersSkipped++; progressTracker.counts.receiptsdone++; @@ -97,7 +131,8 @@ export async function importOrders({ continue; } - const rawItems = itemsByAuftrag.get(String(m.kAuftrag || '').trim()) || []; + const manifestKey = String(m.id ?? m.kAuftrag ?? '').trim(); + const rawItems = itemsByAuftrag.get(manifestKey) || []; if (rawItems.length === 0) { ordersSkipped++; progressTracker.counts.receiptsdone++; @@ -105,15 +140,18 @@ export async function importOrders({ continue; } + rawItems.sort((a, b) => (Number(a.sort ?? a.nSort) || 0) - (Number(b.sort ?? b.nSort) || 0)); + const lines = rawItems.map((it) => { - const sku = cleanValue(it.cArtNr) || null; - const rawName = cleanValue(it.cName || it.cNameStandard); + const articleId = cleanValue(it.articleid ?? it.kArtikel); + const sku = cleanValue(it.sku ?? it.cArtNr) || (articleId && jtlArtIdToSku?.get?.(articleId)) || null; + const rawName = cleanValue(it.name ?? it.cName ?? it.cNameStandard); const name = rawName || (sku ? `Artikel ${sku}` : 'Artikel'); - const amount = parseGermanFloat(it.fAnzahl, 1); - const net = parseGermanFloat(it.fVKNetto, 0); - const taxrate = parseGermanFloat(it.fMwSt, 19); - const rebate = parseGermanFloat(it.fRabatt, 0); - const comment = cleanValue(it.cHinweis) || null; + const amount = parseGermanFloat(it.amount ?? it.fAnzahl, 1); + const net = parseGermanFloat(it.net ?? it.fVKNetto, 0); + const taxrate = parseGermanFloat(it.taxrate ?? it.fMwSt, 19); + const rebate = parseGermanFloat(it.rebate ?? it.fRabatt, 0); + const comment = cleanValue(it.comment ?? it.cHinweis) || null; return { sku, @@ -126,18 +164,19 @@ export async function importOrders({ }; }); - const custName = cleanValue(m.cName) || 'Laufkunde'; - const custFirstName = cleanValue(m.cVorname); + const custName = cleanValue(m.name ?? m.cName) || 'Laufkunde'; + const custFirstName = cleanValue(m.firstName ?? m.cVorname); const entityId = await resolveEntityId(custName, custFirstName); - const dateStr = cleanValue(m.dErstellt); + const dateStr = cleanValue(m.created_at ?? m.dErstellt); const parsedDate = dateStr ? new Date(dateStr) : new Date(); const validDate = !Number.isNaN(parsedDate.getTime()) ? parsedDate.toISOString() : new Date().toISOString(); + let createdOrder = null; try { - await store.order.create(googleAuthId, { + createdOrder = await store.order.create(googleAuthId, { number: orderNumber, - externalNumber: cleanValue(m.cExterneAuftragsnummer) || null, + externalNumber: cleanValue(m.extnr ?? m.cExterneAuftragsnummer) || null, date: validDate, createdAt: validDate, entityId: entityId || undefined, @@ -149,16 +188,67 @@ export async function importOrders({ log.warn(`Failed to create order ${orderNumber}:`, err.message); } + if (createdOrder) { + // Handle Payment + const isPayed = String(m.payed ?? '').trim() === '1'; + const paymentType = cleanValue(m.paymentType); + if (isPayed && paymentType) { + const orderTotal = Math.round( + lines.reduce( + (sum, l) => sum + (l.amount * l.net * (1 - (l.rebate || 0) / 100) * (1 + (l.taxrate || 0) / 100)), + 0 + ) * 100 + ) / 100; + + if (orderTotal > 0) { + try { + const accountId = await resolveAccountId(paymentType); + if (accountId) { + await store.payment.create(googleAuthId, { + accountId, + manifestId: createdOrder.id, + type: paymentType, + amount: orderTotal, + }); + paymentsImported++; + } + } catch (err) { + log.warn(`Failed to create payment for order ${orderNumber}:`, err.message); + } + } + } + + // Handle Delivery / Shipping + const shippingType = cleanValue(m.shippingType); + if (shippingType) { + const isShipped = String(m.shipped ?? '').trim() === '1'; + const shippingState = isShipped ? 'shipped' : 'open'; + + try { + await store.shipping.create(googleAuthId, { + manifestId: createdOrder.id, + type: shippingType, + state: shippingState, + }); + shippingsImported++; + } catch (err) { + log.warn(`Failed to create shipping for order ${orderNumber}:`, err.message); + } + } + } + progressTracker.counts.receiptsdone++; progressTracker.emitProgress(); } progressTracker.emitProgress(true); - log.info(`Orders complete: ${ordersImported} created, ${ordersSkipped} skipped`); + log.info(`Orders complete: ${ordersImported} created, ${ordersSkipped} skipped, ${paymentsImported} payments, ${shippingsImported} shippings`); return { ordersImported, ordersSkipped, + paymentsImported, + shippingsImported, }; } diff --git a/src/services/companyImport/pfandImporter.js b/src/services/companyImport/pfandImporter.js index c003c34..44ed566 100644 --- a/src/services/companyImport/pfandImporter.js +++ b/src/services/companyImport/pfandImporter.js @@ -72,12 +72,12 @@ export async function importPfand({ // 1. Identify parent articles and map their Pfand values so child variants can inherit const parentPfandMap = new Map(); for (const a of includedArticles) { - const sku = cleanValue(a.cArtNr); - const isParent = a.nIstVater === '1' || (sku && parentSkus.has(sku)); + const sku = cleanValue(a.sku ?? a.cArtNr); + const isParent = a.is_parent === '1' || a.nIstVater === '1' || (sku && parentSkus.has(sku)); if (isParent) { const val = extractPfandValue(a.attributes); if (val != null) { - parentPfandMap.set(String(a.kArtikel), val); + parentPfandMap.set(String(a.id ?? a.kArtikel), val); } } } @@ -85,19 +85,20 @@ export async function importPfand({ // 2. Discover target articles (purchasable standalone or variant items) and their Pfand values const articleTargets = []; for (const a of includedArticles) { - const sku = cleanValue(a.cArtNr); + const sku = cleanValue(a.sku ?? a.cArtNr); if (!sku) continue; - const isParent = a.nIstVater === '1' || parentSkus.has(sku); + const isParent = a.is_parent === '1' || a.nIstVater === '1' || parentSkus.has(sku); if (isParent) { // Parent articles cannot have options in Dash continue; } let pfandVal = extractPfandValue(a.attributes); - if (pfandVal == null && a.kVaterArtikel && a.kVaterArtikel !== '0') { - if (parentPfandMap.has(String(a.kVaterArtikel))) { - pfandVal = parentPfandMap.get(String(a.kVaterArtikel)); + const parentId = cleanValue(a.parentid ?? a.kVaterArtikel); + if (pfandVal == null && parentId && parentId !== '0') { + if (parentPfandMap.has(parentId)) { + pfandVal = parentPfandMap.get(parentId); } } diff --git a/src/services/companyImport/variantImporter.js b/src/services/companyImport/variantImporter.js index cbd6fbc..8851aed 100644 --- a/src/services/companyImport/variantImporter.js +++ b/src/services/companyImport/variantImporter.js @@ -60,15 +60,15 @@ export async function importVariants({ // Group children by parent SKU const parentChildrenMap = new Map(); for (const child of includedArticles) { - const parentJtlId = String(child.kVaterArtikel || '').trim(); + const parentJtlId = String(child.parentid ?? child.kVaterArtikel ?? '').trim(); if (!parentJtlId || parentJtlId === '0') continue; const parentSku = jtlArtIdToSku.get(parentJtlId); - const childSku = cleanValue(child.cArtNr); + const childSku = cleanValue(child.sku ?? child.cArtNr); if (!parentSku || !childSku || parentSku === childSku) continue; if (!parentChildrenMap.has(parentSku)) { - const parentRow = includedArticles.find((a) => String(a.kArtikel) === parentJtlId) || null; + const parentRow = includedArticles.find((a) => String(a.id ?? a.kArtikel) === parentJtlId) || null; parentChildrenMap.set(parentSku, { parentRow, children: [] }); } parentChildrenMap.get(parentSku).children.push(child); @@ -76,7 +76,7 @@ export async function importVariants({ let variantsLinked = 0; for (const [parentSku, { parentRow, children }] of parentChildrenMap.entries()) { - const rawAttrName = parentRow ? cleanValue(parentRow.kEigenschaftKombi) : ''; + const rawAttrName = parentRow ? cleanValue(parentRow.variation ?? parentRow.kEigenschaftKombi) : ''; const targetAttrId = await resolveAttributeId(rawAttrName || 'Variante'); if (targetAttrId) { @@ -92,8 +92,8 @@ export async function importVariants({ const usedValues = new Set(); for (const child of children) { - const childSku = cleanValue(child.cArtNr); - let val = cleanValue(child.kEigenschaftKombi) || 'Standard'; + const childSku = cleanValue(child.sku ?? child.cArtNr); + let val = cleanValue(child.variation ?? child.kEigenschaftKombi) || 'Standard'; if (usedValues.has(val.toLowerCase())) { val = `${val} (${childSku})`; diff --git a/todo.md b/todo.md index a2c3f3e..6e37a8a 100644 --- a/todo.md +++ b/todo.md @@ -29,3 +29,5 @@ We use a KassenSichV **`SonstigerVorgang`** transaction as the absolute cryptogr ```text [TSE Signed Genesis] -> [Tx 2 (prev_hash = Genesis Signature)] -> [Tx 3] -> ... ``` + +webhook into public applet. \ No newline at end of file