From 00bbd2e764aef70186275f34215ab6e817ff533e Mon Sep 17 00:00:00 2001 From: seb Date: Tue, 15 Sep 2026 09:24:43 +0200 Subject: [PATCH] feat(schema): replace manifestarticle article_id FK with sku, rename articlesupplier sku/stock fields --- README.md | 12 +- generate-schema-graph.js | 9 +- package-lock.json | 272 ++-- package.json | 8 +- schema-graph.dot | 130 +- schema-graph.svg | 2955 +++++++++++++++++----------------- src/schema.js | 43 +- src/sql/articleDelete.js | 16 - src/sql/delivery.js | 35 +- src/sql/manifestDoc.js | 35 +- src/store/article/delete.js | 18 +- src/store/delivery/create.js | 3 +- src/store/delivery/update.js | 3 +- src/store/manifestLines.js | 46 +- src/store/order/create.js | 3 +- src/store/order/update.js | 3 +- src/store/quote/create.js | 3 +- src/store/quote/update.js | 3 +- 18 files changed, 1720 insertions(+), 1877 deletions(-) diff --git a/README.md b/README.md index 56a77ac..eb2ab26 100644 --- a/README.md +++ b/README.md @@ -297,8 +297,8 @@ Maps articles to suppliers (`entity`) with purchase pricing, stock, packaging un | `article_id` | `INT` | FK → `article(id)` (`ON DELETE CASCADE`) | | `entity_id` | `INT` | FK → `entity(id)` (`ON DELETE CASCADE`) | | `price_id` | `INT` | FK → `price(id)` (`ON DELETE NO ACTION`), nullable | -| `supplierSKU` | `NVARCHAR(100)` | Supplier's SKU code, nullable | -| `supplierStock` | `FLOAT` | Stock available at supplier, nullable | +| `sku` | `NVARCHAR(100)` | Supplier's SKU code, nullable | +| `stock` | `FLOAT` | Stock available at supplier, nullable | | `pu` | `FLOAT` | Packaging unit (Verpackungseinheit), default `1` | --- @@ -327,9 +327,7 @@ type DeliverySummary = { type DeliveryLine = { id: number, - articleId: number | null, sku: string | null, - customsku: string | null, customname: string | null, amount: number, net: number, @@ -341,11 +339,11 @@ type DeliveryLine = { type Delivery = DeliverySummary & { lines: DeliveryLine[] } ``` -`create` inserts header + lines in one transaction. The `number` is auto-allocated via `getnextnumberwithprefixandpadding` (`numbers` type `delivery`); supply `externalNumber` for an external (supplier) reference. `supplierId` null or a Lieferanten `entity` of the company (else `Supplier not found`). Each line requires either `sku` (resolved in the company category tree → `Article not found`; `customsku` and `customname` forced `null`) or custom line fields (`customsku` / `customname` with `articleId` set to `null`). If `article_id` is set, `customsku` and `customname` must be null (`CK_manifestarticle_article_or_custom`). `amount`, `net`, `tax` (rate → `tax.ensure`); `rebate` defaults `0`. Empty/invalid `date` → `Invalid delivery`; bad line payload → `Invalid lines`. +`create` inserts header + lines in one transaction. The `number` is auto-allocated via `getnextnumberwithprefixandpadding` (`numbers` type `delivery`); supply `externalNumber` for an external (supplier) reference. `supplierId` null or a Lieferanten `entity` of the company (else `Supplier not found`). Each line requires either `sku` or `customname`. For delivery manifests, `sku` points to `articlesupplier.sku`; for quote and order manifests, `sku` points to `article.sku`. Lines are stored without FKs so manifest articles are preserved even if articles or suppliers are deleted. `amount`, `net`, `tax` (rate → `tax.ensure`); `rebate` defaults `0`. Empty/invalid `date` → `Invalid delivery`; bad line payload → `Invalid lines`. `update` patches header fields that are present. If `lines` is present, replace-all lines; if omitted, leave lines unchanged. Returns full `Delivery`. -`delete` removes the manifest (`manifestarticle` cascades). Errors: `No company selected`, `Company not found`, `Not authorized`, `Delivery not found`, `Supplier not found`, `Article not found`, `Invalid delivery`, `Invalid lines`. +`delete` removes the manifest (`manifestarticle` cascades). Errors: `No company selected`, `Company not found`, `Not authorized`, `Delivery not found`, `Supplier not found`, `Invalid delivery`, `Invalid lines`. --- @@ -655,7 +653,7 @@ Auth via the article's `categoryarticle` category + `resolveCategoryAccess`. Err `orderImages` sets `articlepic.sort` to `0..n-1` in the given order. `fullHashes` must list every image of the article exactly once. Errors: `Article not found`, `Invalid image order`, `Not authorized`. -`delete` removes the article when it has no child articles (`fatherarticle_id` FK is `ON DELETE NO ACTION`). Cascades: `articlehistory`, `articleean`, `categoryarticle`, `price`, `articlesupplier`, `articletext`, `articlelistarticle`, `optionslistarticle`, `articlepic`; deletes linked `pic` rows and owned `articlelist` / `optionslist`. `manifestarticle.article_id` is set to `NULL` and `comment` gets `article deleted` appended. Errors: `Article not found`, `Article has children`, `Not authorized`. +`delete` removes the article when it has no child articles (`fatherarticle_id` FK is `ON DELETE NO ACTION`). Cascades: `articlehistory`, `articleean`, `categoryarticle`, `price`, `articlesupplier`, `articletext`, `articlelistarticle`, `optionslistarticle`, `articlepic`; deletes linked `pic` rows and owned `articlelist` / `optionslist`. Errors: `Article not found`, `Article has children`, `Not authorized`. --- diff --git a/generate-schema-graph.js b/generate-schema-graph.js index 3918e68..0b4d53d 100644 --- a/generate-schema-graph.js +++ b/generate-schema-graph.js @@ -363,10 +363,15 @@ const CLUSTERS = [ label: 'Media', tables: ['pic', 'articlepic', 'categorypic', 'brandpic'], }, + { + id: 'manifests', + label: 'Documents', + tables: ['manifest', 'manifestarticle', 'ledger'], + }, { id: 'commerce', - label: 'Pricing & Documents', - tables: ['tax', 'price', 'manifest', 'manifestarticle', 'ledger'], + label: 'Pricing', + tables: ['tax', 'price'], }, { id: 'units', label: 'Units', tables: ['unit'] }, { id: 'pos', label: 'POS', tables: ['posterminal', 'posterminalcategory'] }, diff --git a/package-lock.json b/package-lock.json index a9ba5d0..d6a9e99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,15 @@ "version": "0.1.0", "license": "ISC", "dependencies": { - "@clack/prompts": "^1.7.0", - "@hpcc-js/wasm-graphviz": "^1.28.0", + "@clack/prompts": "^1.8.1", + "@hpcc-js/wasm-graphviz": "^1.29.1", "chalk": "^6.0.0", "dotenv": "^17.4.2", - "sharp": "^0.35.3", + "sharp": "^0.35.4", "thumbhash": "^0.1.1" }, "devDependencies": { - "mssql": "^12.7.0" + "mssql": "^12.7.2" }, "peerDependencies": { "mssql": "^12.6.0" @@ -282,9 +282,9 @@ } }, "node_modules/@clack/core": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.4.3.tgz", - "integrity": "sha512-/kr3UWNtdJfxZtPgDqUOmG2pvwlmcLGheex5yiZKdwbzZJxhV+HMNR9QNmyY5cGwTNV6LrR7Jtp+KjhUAP1qBQ==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.5.1.tgz", + "integrity": "sha512-iHTrHA8MtVuLl2TfZySmcKv1qO2PoyC9Z7pfSDozEuV5vtY3/wcOPKJXlqJ5Oq2Cx5DDGQGAMVx6HZfRRoVEbQ==", "license": "MIT", "dependencies": { "fast-wrap-ansi": "^0.2.0", @@ -295,12 +295,12 @@ } }, "node_modules/@clack/prompts": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.7.0.tgz", - "integrity": "sha512-y7/yvZ2TPAnR9+jnc00klvNNLkJiXFFrQA/hlLCcxA9a2A4zQIOimyFQ9XfwYKiGD1fb5GY8vbKIIgO8d5Tb2A==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.8.1.tgz", + "integrity": "sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ==", "license": "MIT", "dependencies": { - "@clack/core": "1.4.3", + "@clack/core": "1.5.1", "fast-string-width": "^3.0.2", "fast-wrap-ansi": "^0.2.0", "sisteransi": "^1.0.5" @@ -320,9 +320,9 @@ } }, "node_modules/@hpcc-js/wasm-graphviz": { - "version": "1.28.0", - "resolved": "https://registry.npmjs.org/@hpcc-js/wasm-graphviz/-/wasm-graphviz-1.28.0.tgz", - "integrity": "sha512-KqvPy7ckxPc1xv8Kt7H3bo9cj8U4gfOXxQ8grLZvDZxyQQjnXsKxrweJLLJtEoWWtQqAk4biUB0g2qsjkTiMVA==", + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/@hpcc-js/wasm-graphviz/-/wasm-graphviz-1.29.1.tgz", + "integrity": "sha512-koAQL0wlryEMeBs4/cQC3GB5ziITv66gR9DU/SWYjjup+iQ+Nbjcqxeaef+sffN4F4cBYZ3P31B5z7+cbSABbw==", "license": "Apache-2.0" }, "node_modules/@img/colour": { @@ -335,9 +335,9 @@ } }, "node_modules/@img/sharp-darwin-arm64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.3.tgz", - "integrity": "sha512-RMnFX7YQsMoh7lWfcM4NEHHymBX/rLuKNPVM84XE9ONPcaSCDgE7CHIHpSgPcO2xcRthgBy1HfNO319mwhIAkg==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.4.tgz", + "integrity": "sha512-Uhfl4V4lhP2nbUVF9+hyH1+luj86f1gUFeo8ALYxFoULoU+G87D43BfeMP8XHsk9boxAnCY/bf2EHwhA7MuGsA==", "cpu": [ "arm64" ], @@ -353,13 +353,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.3.2" + "@img/sharp-libvips-darwin-arm64": "1.3.3" } }, "node_modules/@img/sharp-darwin-x64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.3.tgz", - "integrity": "sha512-Xo+5uFBtLN0BKqieTxiFzFPQAUlBbbH5iBKyRX/z1JrbnYsHTfKJnUfL8+p2TPXr1pXqao4eeL4Rl144uDpK9w==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.4.tgz", + "integrity": "sha512-hWniXY3bG5qKpkKrAwPe4y+VTPmf086YQAnkxWh7uA1YrlRouWGa0M0Mxj3ZjnXFkv7/TD1bTy9lGUK26vRvWw==", "cpu": [ "x64" ], @@ -375,20 +375,20 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.3.2" + "@img/sharp-libvips-darwin-x64": "1.3.3" } }, "node_modules/@img/sharp-freebsd-wasm32": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.3.tgz", - "integrity": "sha512-lUxcqWIj2wMQ9BrwNjngcr1gWUr5xgaGThBRqPPalIC2n67Cqj1uPh8NnA/ZhAg8hUbKl+kVHKwgUIwe6ZYPrg==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.4.tgz", + "integrity": "sha512-lIsKw/BU+kjB4eZjxrYrZmwOJYi3Ajrv66iAlBmUPyKc3HpnloevB1g3wxGD9P/5BbQ1brBGl65VRRrCvQDEqA==", "license": "Apache-2.0", "optional": true, "os": [ "freebsd" ], "dependencies": { - "@img/sharp-wasm32": "0.35.3" + "@img/sharp-wasm32": "0.35.4" }, "engines": { "node": ">=20.9.0" @@ -398,9 +398,9 @@ } }, "node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.2.tgz", - "integrity": "sha512-9J6ypZFpQBj4YnePGoq/S38w6nz+vqg5WZLrLGY4YuSemdMq47GMLBPO42MzwdGwpg/agZ7xzZcFHa48xlywfg==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.3.tgz", + "integrity": "sha512-suTBPTDGrI9WodccaDdwZItTSaBYASlBk1NSfElSHrUfzu3szG6lvIF58+WiFvnfzuK8ZBFS5zE00PxqxnRiPg==", "cpu": [ "arm64" ], @@ -414,9 +414,9 @@ } }, "node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.2.tgz", - "integrity": "sha512-m2pW1n6cns9VaubNwsZ+c3CRYjxNQWgJ5gPlnL1nbBcpkBvFm6SCFN5o0psFHI8w9n11NKhFkeEDns98tiqbEw==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.3.tgz", + "integrity": "sha512-FVJZ5mITMobmXIz/hPDTw0EintTW5H3WfrxwLqEqjiIihlu+hVRyGrFQ60xl0Lxn7Bt3zdpevPaQi0HEzqz9fw==", "cpu": [ "x64" ], @@ -430,9 +430,9 @@ } }, "node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.2.tgz", - "integrity": "sha512-1eMLzy92I4J6rmi4mAT8yC3HxOtniyGELlzGbNMLLeqe052ahFQ0h6LFq+lh5DsDIdYViIDst08abvSbcEdLXQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.3.tgz", + "integrity": "sha512-3rbU4vqXXc3hY/OiXdl52xZvT0F1yEngWfvqudtPJg/KkyiaQw2DRsFrNzpmLvfavbwOq3qXn36GP8obHRULQA==", "cpu": [ "arm" ], @@ -449,9 +449,9 @@ } }, "node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.2.tgz", - "integrity": "sha512-dqVSFynCox4C/J8kT16V7SIFAns0IjgLwkvYT7p8LQVmJ5OS5b6tI9IGflxTeuBS//zXeFIUbwt5dwxyZ17cnA==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.3.tgz", + "integrity": "sha512-0DaL0A6Xu6sQSQFwe4iVCrKWU2cCTItnRsYsCdxAMm9NF6twAA9BKnoqy4hqz4+azQ0JHuA26qiUKsf1XJ/v5A==", "cpu": [ "arm64" ], @@ -468,9 +468,9 @@ } }, "node_modules/@img/sharp-libvips-linux-ppc64": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.2.tgz", - "integrity": "sha512-3z0NHDxD6n5I9gc05U1eW1AyRm+Gznzq3naMrthPNqE6oYykcogW0l/jfpJdjYnuNl8R7yI9pNbE1XiUeyq0Aw==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.3.tgz", + "integrity": "sha512-cdn1OvUBwsXhbC0zSzJnNzf5MZ/mTrobawDvNXBTxe8VtqKAm0sRuEY2Evzovb/w9JMk4TvRxqt1mekSuJz64w==", "cpu": [ "ppc64" ], @@ -487,9 +487,9 @@ } }, "node_modules/@img/sharp-libvips-linux-riscv64": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.2.tgz", - "integrity": "sha512-bsb4rI+NldGOsXuej2r8OdSS8+zXDVaCWxyWrcv6kneTOlgAHtZABRzBBCwdsPiD90J4myNJuHpg6kA20ImW/w==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.3.tgz", + "integrity": "sha512-HjPVx7yKz+0lqdhDlTw1tt90wamBoxhiXpvl1XZpJLiHH4RCJ5yDTqH+VlYPv2fwFs89JFw4c1IexYOcQUi4IQ==", "cpu": [ "riscv64" ], @@ -506,9 +506,9 @@ } }, "node_modules/@img/sharp-libvips-linux-s390x": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.2.tgz", - "integrity": "sha512-/ABshyj8gCpyIrNXnHn4LorDJ0HHm1VhXPBlxZ8zAtfVPAaSafXPGn+sUSIRiwaSBy0mmFjSjiXI5mkcwdChKQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.3.tgz", + "integrity": "sha512-neWLh+3yCNThxnfy3c4BbVBeGgt9aftno+XbT56iK28RgeDs3UOFWviLWlUu0bArYVYJaFDK+RRohbicUNCm8Q==", "cpu": [ "s390x" ], @@ -525,9 +525,9 @@ } }, "node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.2.tgz", - "integrity": "sha512-ITPEtgffGJ0S6G9dRyw/366tJQqFRcHWPHhC+Stpg3Z8AEMrDrTr2lhdz4f/Y/HMbRh//7Z5mBzEpVdi62Oc3w==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.3.tgz", + "integrity": "sha512-4vKmvAst9nrowcqquKFAyZJUDolUaIp8uRiN0mWFguJ1IplC9/pitXtlnnlU4aa/eJw3J7i67V+pwUL+wZGdsA==", "cpu": [ "x64" ], @@ -544,9 +544,9 @@ } }, "node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.2.tgz", - "integrity": "sha512-zE9EdiUzUmg5mDT5a1rk5fYJ6GWPloTwWBYDS14naqHsL+EaMpDj1AWnpLgh3u0YCORv2Tt50wrcrpYqkP97Kw==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.3.tgz", + "integrity": "sha512-Y9kQaLMuNoB0bPYOOdcZMaseNrFpPodIWWMrx+CZyydf2xn68j9WYc6sWWRrDwNkzCQjKYfc68L7jKjGlHMibw==", "cpu": [ "arm64" ], @@ -563,9 +563,9 @@ } }, "node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.2.tgz", - "integrity": "sha512-m0lrLiUt+lBYnCFr8qV/65yMR4E/c7/wf78I5eKTdkEakFAlZ9QlzEM3QIhhAwVeUhLAHLcCq7a7Vszq/oFNZQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.3.tgz", + "integrity": "sha512-fj8Mv0HHfD1Rr+4I68+3agJynxDWtBFgicTbSOb9Bke6pIwzGcJ+RX/yHjmiEGFMCavY/dxvem7MyNaJF+wDiw==", "cpu": [ "x64" ], @@ -582,9 +582,9 @@ } }, "node_modules/@img/sharp-linux-arm": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.3.tgz", - "integrity": "sha512-affVWCTLooy8TSxbDx2qkzuDeaWLNVBA+P//FNBirHsXpP2fuBhk5AuboYUnrDnzoXes8GFjpTx0SBFOCRg+FA==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.4.tgz", + "integrity": "sha512-7OAS8gI0EReKGVN2HssHlM6umJgxF5VI3xN0p9FA91p/YO+ou5hiNghLdZ5BEHztwaaK5+bLKRf8x/o2L2nk9A==", "cpu": [ "arm" ], @@ -603,13 +603,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-arm": "1.3.2" + "@img/sharp-libvips-linux-arm": "1.3.3" } }, "node_modules/@img/sharp-linux-arm64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.3.tgz", - "integrity": "sha512-QgKDspHPnrU+GQ55XPhGwyhC8acLVOOSyAvo1oVfFmrIXLkDNmGWzAfDZ4xK8oSA1qBQrALcHX0G5UZni/SuFQ==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.4.tgz", + "integrity": "sha512-De4jpEnAU8Hd5oT0j1G3uL4ZvTuipVMn7YC6vPaJhy6/7EwEae0SVAoBrUMYQbkLGDm85taVWwuPc1a44LTzCQ==", "cpu": [ "arm64" ], @@ -628,13 +628,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-arm64": "1.3.2" + "@img/sharp-libvips-linux-arm64": "1.3.3" } }, "node_modules/@img/sharp-linux-ppc64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.3.tgz", - "integrity": "sha512-sMd8rDxmpLOwv/7N44klFjOD5DUO7FLdjiXDI0hoxYaf7Ar262dQIEkosE98bps+5HPLtp/EvNqeqQtOycP/IA==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.4.tgz", + "integrity": "sha512-2oYZJeIl4kCcMGk4ouZVjnkCtFrpQFlNEtJ6GbxzhHQchwH0NH/qEb9ykmOl29dqwMq+JhFdZn+1ak2FKhI9fQ==", "cpu": [ "ppc64" ], @@ -653,13 +653,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-ppc64": "1.3.2" + "@img/sharp-libvips-linux-ppc64": "1.3.3" } }, "node_modules/@img/sharp-linux-riscv64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.3.tgz", - "integrity": "sha512-0Eob78yjlYPfL5vMNWAW55l3R9Y6BQS/gOfe0ZcP9mEz9ohhKSt4im1hayiknXgf8AWrFqMvJcKIdmLmEe7yeQ==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.4.tgz", + "integrity": "sha512-cPbNChoRURAWdebDIHSenxRpgEdy7JkPydSnUxRm9VvKD7m0/xVaR/8Fzlu81pk5nHEvHH87UZUA7cTtwnbJSA==", "cpu": [ "riscv64" ], @@ -678,13 +678,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-riscv64": "1.3.2" + "@img/sharp-libvips-linux-riscv64": "1.3.3" } }, "node_modules/@img/sharp-linux-s390x": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.3.tgz", - "integrity": "sha512-KgAxQ0DxpNOq1rG2t5cgTgShJFGSuU7XO45cqC+1NVOuZnP6tlgZRuSYOfNupGkHID0o3cJOsw4DVeJpMovcGw==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.4.tgz", + "integrity": "sha512-RY0JFY8Fd6RonCBtHz+DvadaPkXDSI1AUn6yWL9TipqkZ1vY8w8evqdgyDFnkm4/K1ve1TvZiaePP5oSd4+WVQ==", "cpu": [ "s390x" ], @@ -703,13 +703,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-s390x": "1.3.2" + "@img/sharp-libvips-linux-s390x": "1.3.3" } }, "node_modules/@img/sharp-linux-x64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.3.tgz", - "integrity": "sha512-8pqvxubL2PGdhlPy6GLqzDYMUjyRmKAwKHYKixpdJYBUK7PJ0C029XdsnpFIdgRZG68fZiGdHVWcKPvtiPB4cA==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.4.tgz", + "integrity": "sha512-9qvvEAuk8k89TfWUoX2htWjbAMX8p+NxCppjpcg5k6xMsjhBQPTsoIh36h9Qde4WRuGpJeYnOjdosDn/cnv+OA==", "cpu": [ "x64" ], @@ -728,13 +728,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-x64": "1.3.2" + "@img/sharp-libvips-linux-x64": "1.3.3" } }, "node_modules/@img/sharp-linuxmusl-arm64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.3.tgz", - "integrity": "sha512-Vz0iQjzzcSX3HCbfwFfCSG/9SCIqyO0mH2sXyiHaAYfBk0cRsCWXRyQYX0ovCK/PAQBbTzQ0dsPQHh5MAFL59w==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.4.tgz", + "integrity": "sha512-KB5jxpfWQTr0nc3xdHtWChdbifHrBGsd2SM62Eyxrl8afikm+f5qGBU75SJIZBT/S1MC8XyacdlXBMSWq6OURA==", "cpu": [ "arm64" ], @@ -753,13 +753,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-arm64": "1.3.2" + "@img/sharp-libvips-linuxmusl-arm64": "1.3.3" } }, "node_modules/@img/sharp-linuxmusl-x64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.3.tgz", - "integrity": "sha512-6O1NPKcDVj9QEdg7Hx549EX8U0rp6yXQERqru6yRN7fGBn32UvIRJUlWnk+8xDCiG76hXVBbX82NZ/ZKr0euIg==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.4.tgz", + "integrity": "sha512-f+eZJZIQNEEd26RPSW+76chwOf1XtA2Y/O+5ocVyLliHkeih3e+jhLVBdNTd2rS3IbNXK8+ug93Vf5ZXtF5Lxg==", "cpu": [ "x64" ], @@ -778,17 +778,17 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-x64": "1.3.2" + "@img/sharp-libvips-linuxmusl-x64": "1.3.3" } }, "node_modules/@img/sharp-wasm32": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.3.tgz", - "integrity": "sha512-cZ0XkcYGpHZkqW6iCkqTcmUC0CD9DhD5d/qeZlZkfRBn6GnHniZXLUo5+9xw8Iv76YE6LQFN9YNBlKREcCG76w==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.4.tgz", + "integrity": "sha512-zQnl4Kwp7Q6NHsENtU2T/00Zi+w3AQNwz3+UaTyVBy2FpXrzXzGjndpK61onhZjRtRpQXxCTeqw19bVyXOh7jA==", "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", "optional": true, "dependencies": { - "@emnapi/runtime": "^1.11.1" + "@emnapi/runtime": "^1.11.3" }, "engines": { "node": ">=20.9.0" @@ -798,16 +798,16 @@ } }, "node_modules/@img/sharp-webcontainers-wasm32": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.3.tgz", - "integrity": "sha512-2rnq7bX3NzeR2T4YWgz8qiG4h3TSdMe+vN1iQXpJleSJ3SM5zQ8Fy2SyyXAWlbxpEZ2Y+Z4u1BePgJEYbSy80Q==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.4.tgz", + "integrity": "sha512-ESfNkywmCfPNyaZjxooddJQiQ+l/nTpGEOGthxiLnIHXC/CmcBixnfwUleX9mCz9ovrUUvKMap/pm8RYbzfwaA==", "cpu": [ "wasm32" ], "license": "Apache-2.0", "optional": true, "dependencies": { - "@img/sharp-wasm32": "0.35.3" + "@img/sharp-wasm32": "0.35.4" }, "engines": { "node": ">=20.9.0" @@ -817,9 +817,9 @@ } }, "node_modules/@img/sharp-win32-arm64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.3.tgz", - "integrity": "sha512-4bPwFdMbeC4JQ8L8LOyWp6nsHcboP5fxkp6iPOXz2Vg49R42TuMs2whkJ5OAP4/Ul035qOzy0AecOF9VOscn4w==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.4.tgz", + "integrity": "sha512-iNdlBX9gLVvqe2I3uIJSIKTq6wckP/DYxZtcqxm09x5Gi24DnFBmPAWZmr60ZyYMG0xlzo6goG3670ar+RXvRw==", "cpu": [ "arm64" ], @@ -836,9 +836,9 @@ } }, "node_modules/@img/sharp-win32-ia32": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.3.tgz", - "integrity": "sha512-r53mXsBN6lFUDiST764SvgwUdHAqM4rPAiDzAmf4fLoB6X/rkfyTrLCg6+g17wJJiCmB3JYgHuUldCWUIRFSXw==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.4.tgz", + "integrity": "sha512-kqRsbaa5CS6KHlpxnN7WhE6vAAugXyZButpRdvDWetlv6Qv4N9WTcrWzF7tXfB9T7MsoadqdI8hmwLq6UlLvtw==", "cpu": [ "ia32" ], @@ -855,9 +855,9 @@ } }, "node_modules/@img/sharp-win32-x64": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.3.tgz", - "integrity": "sha512-D4y1vNeZrIIJCN+uHaWVtH86B+aCrdMYYjicy9pXHvbGZeGYLLSd3wdVuC37FxVXlU1ARsk84eKWfWMXGYEqvA==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.4.tgz", + "integrity": "sha512-XtmnYhBcrORsJ4XJngyzr/EWP0hRZLAZRFaApdKuviyqF78+ylxh2y06ZmtULAMOnObJ3ucpN0AcwSWnMowTRg==", "cpu": [ "x64" ], @@ -1419,9 +1419,9 @@ "license": "MIT" }, "node_modules/mssql": { - "version": "12.7.0", - "resolved": "https://registry.npmjs.org/mssql/-/mssql-12.7.0.tgz", - "integrity": "sha512-J6SJKXi1jYbhHjjooLNtPnX7+s3cq5IJ701Wgy/UW1SXRpgFlJJsYi3IPve9RVgCUkq0Cqv2aaaSJ4IXtIF3mg==", + "version": "12.7.2", + "resolved": "https://registry.npmjs.org/mssql/-/mssql-12.7.2.tgz", + "integrity": "sha512-zhpPw+WXBWLw7d7J6Y0aWgQy0EV8HKDGNSvmkAjP8bSM4H41X0fweAeKWI+bg9Ri+JHCbsf/QScjmACBFcEo8A==", "dev": true, "license": "MIT", "dependencies": { @@ -1545,9 +1545,9 @@ } }, "node_modules/sharp": { - "version": "0.35.3", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.3.tgz", - "integrity": "sha512-ej0zVHuZGHCiABXcNxeYhpRnPNPAcvbG8RMdBAhDAxLKkCRVSpK3Iyu7qbqw3JMzoj0REeM6f3tJLtVwl0023Q==", + "version": "0.35.4", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.4.tgz", + "integrity": "sha512-n++8XWcj+jCOr2IOl7h8LbKnGBDY4aPbmprMONBNFdn0ImXqpGVv5zliDs0V9HbmbCQLpbuo2ej9rAoOQTvMDA==", "license": "Apache-2.0", "dependencies": { "@img/colour": "^1.1.0", @@ -1561,31 +1561,31 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-darwin-arm64": "0.35.3", - "@img/sharp-darwin-x64": "0.35.3", - "@img/sharp-freebsd-wasm32": "0.35.3", - "@img/sharp-libvips-darwin-arm64": "1.3.2", - "@img/sharp-libvips-darwin-x64": "1.3.2", - "@img/sharp-libvips-linux-arm": "1.3.2", - "@img/sharp-libvips-linux-arm64": "1.3.2", - "@img/sharp-libvips-linux-ppc64": "1.3.2", - "@img/sharp-libvips-linux-riscv64": "1.3.2", - "@img/sharp-libvips-linux-s390x": "1.3.2", - "@img/sharp-libvips-linux-x64": "1.3.2", - "@img/sharp-libvips-linuxmusl-arm64": "1.3.2", - "@img/sharp-libvips-linuxmusl-x64": "1.3.2", - "@img/sharp-linux-arm": "0.35.3", - "@img/sharp-linux-arm64": "0.35.3", - "@img/sharp-linux-ppc64": "0.35.3", - "@img/sharp-linux-riscv64": "0.35.3", - "@img/sharp-linux-s390x": "0.35.3", - "@img/sharp-linux-x64": "0.35.3", - "@img/sharp-linuxmusl-arm64": "0.35.3", - "@img/sharp-linuxmusl-x64": "0.35.3", - "@img/sharp-webcontainers-wasm32": "0.35.3", - "@img/sharp-win32-arm64": "0.35.3", - "@img/sharp-win32-ia32": "0.35.3", - "@img/sharp-win32-x64": "0.35.3" + "@img/sharp-darwin-arm64": "0.35.4", + "@img/sharp-darwin-x64": "0.35.4", + "@img/sharp-freebsd-wasm32": "0.35.4", + "@img/sharp-libvips-darwin-arm64": "1.3.3", + "@img/sharp-libvips-darwin-x64": "1.3.3", + "@img/sharp-libvips-linux-arm": "1.3.3", + "@img/sharp-libvips-linux-arm64": "1.3.3", + "@img/sharp-libvips-linux-ppc64": "1.3.3", + "@img/sharp-libvips-linux-riscv64": "1.3.3", + "@img/sharp-libvips-linux-s390x": "1.3.3", + "@img/sharp-libvips-linux-x64": "1.3.3", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.3", + "@img/sharp-libvips-linuxmusl-x64": "1.3.3", + "@img/sharp-linux-arm": "0.35.4", + "@img/sharp-linux-arm64": "0.35.4", + "@img/sharp-linux-ppc64": "0.35.4", + "@img/sharp-linux-riscv64": "0.35.4", + "@img/sharp-linux-s390x": "0.35.4", + "@img/sharp-linux-x64": "0.35.4", + "@img/sharp-linuxmusl-arm64": "0.35.4", + "@img/sharp-linuxmusl-x64": "0.35.4", + "@img/sharp-webcontainers-wasm32": "0.35.4", + "@img/sharp-win32-arm64": "0.35.4", + "@img/sharp-win32-ia32": "0.35.4", + "@img/sharp-win32-x64": "0.35.4" }, "peerDependenciesMeta": { "@types/node": { diff --git a/package.json b/package.json index 6809ec3..a127bc5 100644 --- a/package.json +++ b/package.json @@ -18,17 +18,17 @@ "test:api": "node scripts/test-api.js" }, "dependencies": { - "@clack/prompts": "^1.7.0", - "@hpcc-js/wasm-graphviz": "^1.28.0", + "@clack/prompts": "^1.8.1", + "@hpcc-js/wasm-graphviz": "^1.29.1", "chalk": "^6.0.0", "dotenv": "^17.4.2", - "sharp": "^0.35.3", + "sharp": "^0.35.4", "thumbhash": "^0.1.1" }, "peerDependencies": { "mssql": "^12.6.0" }, "devDependencies": { - "mssql": "^12.7.0" + "mssql": "^12.7.2" } } diff --git a/schema-graph.dot b/schema-graph.dot index a891f1a..01a6fe2 100644 --- a/schema-graph.dot +++ b/schema-graph.dot @@ -11,7 +11,6 @@ digraph schema { fontcolor="#e2e8f0"; margin=14; meta [label=<
meta
keyNVARCHAR(255)
valueNVARCHAR(MAX)
>]; customergroup [label=<
customergroup
idINT PK
company_id?INT FK
nameNVARCHAR(255)
sortINT
>]; - company [label=<
company
idINT PK
taxrate?INT FK
reducedtaxrate?INT FK
taxfreerate?INT FK
root_category_id?INT FK
default_language_id?INT FK
poscustomergroup_idINT FK
nameNVARCHAR(255)
>]; numbers [label=<
numbers
idINT PK
company_idINT FK
typeNVARCHAR(100)
prefixNVARCHAR(50)
paddingINT
nextINT
>]; entityaddress [label=<
entityaddress
idINT PK
entity_idINT FK
first_name?NVARCHAR(255)
name?NVARCHAR(255)
street?NVARCHAR(255)
streetnumber?NVARCHAR(50)
zip?NVARCHAR(50)
city?NVARCHAR(255)
county?NVARCHAR(255)
addresstypeNVARCHAR(50)
sortINT
>]; entity [label=<
entity
idINT PK
customergroup_idINT FK
first_name?NVARCHAR(255)
nameNVARCHAR(255)
number?NVARCHAR(100)
created_atDATETIME2
updated_atDATETIME2
>]; @@ -19,6 +18,7 @@ digraph schema { entitycontact [label=<
entitycontact
idINT PK
entity_idINT FK
contacttypeNVARCHAR(50)
contactNVARCHAR(255)
sortINT
>]; syncpos [label=<
syncpos
idINT PK
company_idINT FK
paircodeNVARCHAR(50)
token?NVARCHAR(255)
>]; entityhistory [label=<
entityhistory
idINT PK
entity_idINT FK
companyuser_id?INT FK
dateDATETIME2
textNVARCHAR(MAX)
>]; + company [label=<
company
idINT PK
poscustomergroup_idINT FK
root_category_id?INT FK
default_language_id?INT FK
taxrate?INT FK
reducedtaxrate?INT FK
taxfreerate?INT FK
nameNVARCHAR(255)
>]; companysetting [label=<
companysetting
idINT PK
company_idINT FK
keyNVARCHAR(255)
valueNVARCHAR(MAX)
frontendBIT
writeonlyBIT
>]; google_auth [label=<
google_auth
idINT PK
selected_company?INT FK
emailNVARCHAR(320)
picture?NVARCHAR(2048)
picturebinary?VARBINARY(MAX)
sub?NVARCHAR(255)
created_atDATETIME2
>]; } @@ -27,7 +27,7 @@ digraph schema { style="rounded,filled"; fillcolor="#202a3a"; color="#3f4c5f"; fontcolor="#e2e8f0"; margin=14; language [label=<
language
idINT PK
iso639NVARCHAR(10)
>]; - unittext [label=<
unittext
idINT PK
language_idINT FK
unit_idINT FK
symbolNVARCHAR(50)
nameNVARCHAR(255)
>]; + unittext [label=<
unittext
idINT PK
unit_idINT FK
language_idINT FK
symbolNVARCHAR(50)
nameNVARCHAR(255)
>]; categorytext [label=<
categorytext
idINT PK
category_idINT FK
language_idINT FK
nameNVARCHAR(255)
slugNVARCHAR(255)
seo?NVARCHAR(MAX)
desc?NVARCHAR(MAX)
>]; articletext [label=<
articletext
idINT PK
article_idINT FK
language_idINT FK
nameNVARCHAR(255)
slugNVARCHAR(255)
seo?NVARCHAR(MAX)
desc?NVARCHAR(MAX)
>]; } @@ -35,17 +35,17 @@ digraph schema { label="Catalog"; labeljust="l"; fontsize=15; style="rounded,filled"; fillcolor="#202a3a"; color="#3f4c5f"; fontcolor="#e2e8f0"; margin=14; - category [label=<
category
idINT PK
parent_id?INT FK
sortINT
>]; categoryarticle [label=<
categoryarticle
idINT PK
category_idINT FK
article_idINT FK
>]; brand [label=<
brand
idINT PK
company_idINT FK
nameNVARCHAR(255)
gsprpinfo?NVARCHAR(MAX)
>]; - articlehistory [label=<
articlehistory
idINT PK
article_idINT FK
companyuser_id?INT FK
dateDATETIME2
textNVARCHAR(MAX)
>]; - article [label=<
article
idINT PK
brand_id?INT FK
fatherarticle_id?INT FK
articlelist_id?INT FK
optionslist_id?INT FK
unit_idINT FK
sku?NVARCHAR(100)
unitamountFLOAT
weightFLOAT
is_fatherBIT
fathersortINT
created_atDATETIME2
updated_atDATETIME2
>]; + category [label=<
category
idINT PK
parent_id?INT FK
sortINT
>]; + articlehistory [label=<
articlehistory
idINT PK
companyuser_id?INT FK
article_idINT FK
dateDATETIME2
textNVARCHAR(MAX)
>]; + article [label=<
article
idINT PK
brand_id?INT FK
fatherarticle_id?INT FK
articlelist_id?INT FK
optionslist_id?INT FK
unit_idINT FK
sku?NVARCHAR(100)
unitamountFLOAT
weightFLOAT
is_fatherBIT
fathersortINT
created_atDATETIME2
updated_atDATETIME2
>]; articleean [label=<
articleean
idINT PK
article_idINT FK
eanNVARCHAR(50)
>]; articlelist [label=<
articlelist
idINT PK
>]; + articlesupplier [label=<
articlesupplier
idINT PK
entity_idINT FK
article_idINT FK
price_id?INT FK
sku?NVARCHAR(100)
stock?FLOAT
puFLOAT
>]; articlelistarticle [label=<
articlelistarticle
idINT PK
article_idINT FK
articlelist_idINT FK
countINT
sortINT
>]; - articlesupplier [label=<
articlesupplier
idINT PK
price_id?INT FK
article_idINT FK
entity_idINT FK
SupplierSKU?NVARCHAR(100)
supplierStock?FLOAT
puFLOAT
>]; - optionslist [label=<
optionslist
idINT PK
>]; optionslistarticle [label=<
optionslistarticle
idINT PK
article_idINT FK
optionslist_idINT FK
countINT
sortINT
mandatedBIT
>]; + optionslist [label=<
optionslist
idINT PK
>]; } subgraph cluster_media { label="Media"; labeljust="l"; fontsize=15; @@ -53,18 +53,23 @@ digraph schema { fontcolor="#e2e8f0"; margin=14; pic [label=<
pic
idINT PK
wINT
hINT
sizeBIGINT
hashNVARCHAR(64)
thumbwINT
thumbhINT
thumbhashNVARCHAR(64)
sourceNVARCHAR(MAX)
fullbinaryVARBINARY(MAX)
thumbbinaryVARBINARY(MAX)
>]; categorypic [label=<
categorypic
idINT PK
pic_idINT FK
category_idINT FK
sortINT
>]; - articlepic [label=<
articlepic
idINT PK
pic_idINT FK
article_idINT FK
sortINT
>]; brandpic [label=<
brandpic
idINT PK
pic_idINT FK
brand_idINT FK
sortINT
>]; + articlepic [label=<
articlepic
idINT PK
pic_idINT FK
article_idINT FK
sortINT
>]; } - subgraph cluster_commerce { - label="Pricing & Documents"; labeljust="l"; fontsize=15; + subgraph cluster_manifests { + label="Documents"; labeljust="l"; fontsize=15; style="rounded,filled"; fillcolor="#202a3a"; color="#3f4c5f"; fontcolor="#e2e8f0"; margin=14; + manifestarticle [label=<
manifestarticle
idINT PK
manifest_idINT FK
tax_idINT FK
sku?NVARCHAR(100)
customname?NVARCHAR(255)
amountFLOAT
netFLOAT
comment?NVARCHAR(MAX)
rebateFLOAT
>]; + manifest [label=<
manifest
idINT PK
entity_id?INT FK
company_idINT FK
numberNVARCHAR(100)
typeNVARCHAR(100)
external_number?NVARCHAR(100)
dateDATETIME2
>]; ledger [label=<
ledger
idINT PK
manifestarticle_idINT FK
transaction_typeNVARCHAR(100)
amountFLOAT
transaction_textNVARCHAR(MAX)
hash_versionINT
prev_hash?NVARCHAR(128)
>]; - manifestarticle [label=<
manifestarticle
idINT PK
manifest_idINT FK
tax_idINT FK
article_id?INT FK
customsku?NVARCHAR(100)
customname?NVARCHAR(255)
amountFLOAT
netFLOAT
comment?NVARCHAR(MAX)
rebateFLOAT
>]; - manifest [label=<
manifest
idINT PK
company_idINT FK
entity_id?INT FK
numberNVARCHAR(100)
typeNVARCHAR(100)
external_number?NVARCHAR(100)
dateDATETIME2
>]; - price [label=<
price
idINT PK
tax_idINT FK
article_idINT FK
customergroup_idINT FK
minmultiplierDECIMAL(18,4)
netFLOAT
>]; + } + subgraph cluster_commerce { + label="Pricing"; labeljust="l"; fontsize=15; + style="rounded,filled"; fillcolor="#202a3a"; color="#3f4c5f"; + fontcolor="#e2e8f0"; margin=14; tax [label=<
tax
idINT PK
rateDECIMAL(18,4)
>]; + price [label=<
price
idINT PK
customergroup_idINT FK
article_idINT FK
tax_idINT FK
minmultiplierDECIMAL(18,4)
netFLOAT
>]; } subgraph cluster_units { label="Units"; labeljust="l"; fontsize=15; @@ -77,71 +82,70 @@ digraph schema { style="rounded,filled"; fillcolor="#202a3a"; color="#3f4c5f"; fontcolor="#e2e8f0"; margin=14; posterminal [label=<
posterminal
idINT PK
company_idINT FK
nameNVARCHAR(255)
token?NVARCHAR(255)
pairingpinNVARCHAR(50)
>]; - posterminalcategory [label=<
posterminalcategory
idINT PK
category_idINT FK
posterminal_idINT FK
>]; + posterminalcategory [label=<
posterminalcategory
idINT PK
posterminal_idINT FK
category_idINT FK
>]; } __legend [label=<
Legend
PKprimary key
FKforeign key
?nullable column
—FOREIGN KEY constraint
- -naming convention only, no constraint
>]; - google_auth:selected_company:e -> company:in9:n [color="#ff6b6b", fontcolor="#ff6b6b", tooltip="FK_google_auth_selected_company", weight=3]; + google_auth:selected_company:sw -> company:in6:n [color="#ff6b6b", fontcolor="#ff6b6b", tooltip="FK_google_auth_selected_company", weight=3]; category:parent_id:e -> category:id:e [color="#6bdf9a", fontcolor="#6bdf9a", tooltip="FK_category_parent", constraint=false]; - company:root_category_id:w -> category:in5:n [color="#5aa7ff", fontcolor="#5aa7ff", tooltip="FK_company_root_category", constraint=false, weight=1]; - company:default_language_id:sw -> language:in3:n [color="#f5c15c", fontcolor="#f5c15c", tooltip="FK_company_default_language", constraint=false, weight=1]; - company:taxrate:e -> tax:in4:n [color="#c79bff", fontcolor="#c79bff", tooltip="FK_company_taxrate", constraint=false, weight=1]; - company:reducedtaxrate:e -> tax:in2:n [color="#ff9f5a", fontcolor="#ff9f5a", tooltip="FK_company_reducedtaxrate", weight=3]; - company:taxfreerate:e -> tax:in3:n [color="#5cd6d6", fontcolor="#5cd6d6", tooltip="FK_company_taxfreerate", constraint=false, weight=1]; - customergroup:company_id:se -> company:in4:n [color="#ff7fc2", fontcolor="#ff7fc2", tooltip="FK_customergroup_company", weight=3]; - company:poscustomergroup_id:sw -> customergroup:in2:n [color="#8f95ff", fontcolor="#8f95ff", tooltip="FK_company_poscustomergroup", constraint=false, weight=1]; - entity:customergroup_id:nw -> customergroup:in1:n [color="#58d18a", fontcolor="#58d18a", tooltip="FK_entity_customergroup", weight=3]; - entityaddress:entity_id:sw -> entity:in2:n [color="#ff8f66", fontcolor="#ff8f66", tooltip="FK_entityaddress_entity", weight=3]; - entitycontact:entity_id:se -> entity:in3:n [color="#4fc4e8", fontcolor="#4fc4e8", tooltip="FK_entitycontact_entity", weight=3]; - entityhistory:entity_id:sw -> entity:in4:n [color="#a98cff", fontcolor="#a98cff", tooltip="FK_entityhistory_entity", weight=3]; - entityhistory:companyuser_id:se -> companyuser:in1:n [color="#ff6f6f", fontcolor="#ff6f6f", tooltip="FK_entityhistory_companyuser", constraint=false, weight=1]; - unit:company_id:e -> company:in2:n [color="#4ecb8f", fontcolor="#4ecb8f", tooltip="FK_unit_company", weight=3]; + company:root_category_id:e -> category:in0:n [color="#5aa7ff", fontcolor="#5aa7ff", tooltip="FK_company_root_category", constraint=false, weight=1]; + company:default_language_id:e -> language:in0:n [color="#f5c15c", fontcolor="#f5c15c", tooltip="FK_company_default_language", constraint=false, weight=1]; + company:taxrate:e -> tax:in2:n [color="#c79bff", fontcolor="#c79bff", tooltip="FK_company_taxrate", constraint=false, weight=1]; + company:reducedtaxrate:e -> tax:in1:n [color="#ff9f5a", fontcolor="#ff9f5a", tooltip="FK_company_reducedtaxrate", weight=3]; + company:taxfreerate:e -> tax:in0:n [color="#5cd6d6", fontcolor="#5cd6d6", tooltip="FK_company_taxfreerate", constraint=false, weight=1]; + customergroup:company_id:w -> company:in1:n [color="#ff7fc2", fontcolor="#ff7fc2", tooltip="FK_customergroup_company", weight=3]; + company:poscustomergroup_id:w -> customergroup:in0:n [color="#8f95ff", fontcolor="#8f95ff", tooltip="FK_company_poscustomergroup", constraint=false, weight=1]; + entity:customergroup_id:w -> customergroup:in1:n [color="#58d18a", fontcolor="#58d18a", tooltip="FK_entity_customergroup", weight=3]; + entityaddress:entity_id:ne -> entity:in0:n [color="#ff8f66", fontcolor="#ff8f66", tooltip="FK_entityaddress_entity", weight=3]; + entitycontact:entity_id:sw -> entity:in1:n [color="#4fc4e8", fontcolor="#4fc4e8", tooltip="FK_entitycontact_entity", weight=3]; + entityhistory:entity_id:sw -> entity:in2:n [color="#a98cff", fontcolor="#a98cff", tooltip="FK_entityhistory_entity", weight=3]; + entityhistory:companyuser_id:se -> companyuser:in0:n [color="#ff6f6f", fontcolor="#ff6f6f", tooltip="FK_entityhistory_companyuser", constraint=false, weight=1]; + unit:company_id:w -> company:in9:n [color="#4ecb8f", fontcolor="#4ecb8f", tooltip="FK_unit_company", weight=3]; unittext:unit_id:se -> unit:in1:n [color="#5aa7e6", fontcolor="#5aa7e6", tooltip="FK_unittext_unit", weight=3]; - unittext:language_id:nw -> language:in0:n [color="#ff7aa8", fontcolor="#ff7aa8", tooltip="FK_unittext_language", constraint=false, weight=1]; - brand:company_id:e -> company:in1:n [color="#e0b25a", fontcolor="#e0b25a", tooltip="FK_brand_company", weight=3]; + unittext:language_id:nw -> language:in1:n [color="#ff7aa8", fontcolor="#ff7aa8", tooltip="FK_unittext_language", constraint=false, weight=1]; + brand:company_id:w -> company:in8:n [color="#e0b25a", fontcolor="#e0b25a", tooltip="FK_brand_company", weight=3]; article:unit_id:e -> unit:in0:n [color="#56c8c8", fontcolor="#56c8c8", tooltip="FK_article_unit", constraint=false, weight=1]; article:brand_id:sw -> brand:in1:n [color="#ff5f9e", fontcolor="#ff5f9e", tooltip="FK_article_brand", constraint=false, weight=1]; - article:articlelist_id:sw -> articlelist:in0:n [color="#ffb25a", fontcolor="#ffb25a", tooltip="FK_article_articlelist", weight=3]; + article:articlelist_id:sw -> articlelist:in1:n [color="#ffb25a", fontcolor="#ffb25a", tooltip="FK_article_articlelist", weight=3]; article:optionslist_id:e -> optionslist:in0:n [color="#56d68a", fontcolor="#56d68a", tooltip="FK_article_optionslist", constraint=false, weight=1]; article:fatherarticle_id:e -> article:id:e [color="#66b3ff", fontcolor="#66b3ff", tooltip="FK_article_fatherarticle", constraint=false]; - articlehistory:article_id:ne -> article:in4:n [color="#c79bff", fontcolor="#c79bff", tooltip="FK_articlehistory_article", weight=3]; - articlehistory:companyuser_id:e -> companyuser:in0:n [color="#ff6b6b", fontcolor="#ff6b6b", tooltip="FK_articlehistory_companyuser", constraint=false, weight=1]; - articleean:article_id:sw -> article:in6:n [color="#6bdf9a", fontcolor="#6bdf9a", tooltip="FK_articleean_article", weight=3]; - articlepic:article_id:e -> article:in2:n [color="#5aa7ff", fontcolor="#5aa7ff", tooltip="FK_articlepic_article", weight=3]; + articlehistory:article_id:ne -> article:in2:n [color="#c79bff", fontcolor="#c79bff", tooltip="FK_articlehistory_article", weight=3]; + articlehistory:companyuser_id:w -> companyuser:in1:n [color="#ff6b6b", fontcolor="#ff6b6b", tooltip="FK_articlehistory_companyuser", constraint=false, weight=1]; + articleean:article_id:se -> article:in4:n [color="#6bdf9a", fontcolor="#6bdf9a", tooltip="FK_articleean_article", weight=3]; + articlepic:article_id:e -> article:in0:n [color="#5aa7ff", fontcolor="#5aa7ff", tooltip="FK_articlepic_article", weight=3]; articlepic:pic_id:w -> pic:in0:n [color="#f5c15c", fontcolor="#f5c15c", tooltip="FK_articlepic_pic", constraint=false, weight=1]; brandpic:brand_id:se -> brand:in0:n [color="#c79bff", fontcolor="#c79bff", tooltip="FK_brandpic_brand", weight=3]; brandpic:pic_id:nw -> pic:in2:n [color="#ff9f5a", fontcolor="#ff9f5a", tooltip="FK_brandpic_pic", constraint=false, weight=1]; - articlelistarticle:articlelist_id:sw -> articlelist:in1:n [color="#5cd6d6", fontcolor="#5cd6d6", tooltip="FK_articlelistarticle_articlelist", weight=3]; - articlelistarticle:article_id:e -> article:in7:n [color="#ff7fc2", fontcolor="#ff7fc2", tooltip="FK_articlelistarticle_article", constraint=false, weight=1]; + articlelistarticle:articlelist_id:sw -> articlelist:in0:n [color="#5cd6d6", fontcolor="#5cd6d6", tooltip="FK_articlelistarticle_articlelist", weight=3]; + articlelistarticle:article_id:w -> article:in6:n [color="#ff7fc2", fontcolor="#ff7fc2", tooltip="FK_articlelistarticle_article", constraint=false, weight=1]; optionslistarticle:optionslist_id:se -> optionslist:in1:n [color="#8f95ff", fontcolor="#8f95ff", tooltip="FK_optionslistarticle_optionslist", weight=3]; - optionslistarticle:article_id:w -> article:in9:n [color="#58d18a", fontcolor="#58d18a", tooltip="FK_optionslistarticle_article", constraint=false, weight=1]; - categoryarticle:category_id:sw -> category:in2:n [color="#ff8f66", fontcolor="#ff8f66", tooltip="FK_categoryarticle_category", weight=3]; - categoryarticle:article_id:se -> article:in3:n [color="#4fc4e8", fontcolor="#4fc4e8", tooltip="FK_categoryarticle_article", constraint=false, weight=1]; - categorypic:category_id:se -> category:in0:n [color="#a98cff", fontcolor="#a98cff", tooltip="FK_categorypic_category", weight=3]; + optionslistarticle:article_id:sw -> article:in7:n [color="#58d18a", fontcolor="#58d18a", tooltip="FK_optionslistarticle_article", constraint=false, weight=1]; + categoryarticle:category_id:se -> category:in3:n [color="#ff8f66", fontcolor="#ff8f66", tooltip="FK_categoryarticle_category", weight=3]; + categoryarticle:article_id:se -> article:in1:n [color="#4fc4e8", fontcolor="#4fc4e8", tooltip="FK_categoryarticle_article", constraint=false, weight=1]; + categorypic:category_id:e -> category:in2:n [color="#a98cff", fontcolor="#a98cff", tooltip="FK_categorypic_category", weight=3]; categorypic:pic_id:e -> pic:in1:n [color="#ff6f6f", fontcolor="#ff6f6f", tooltip="FK_categorypic_pic", constraint=false, weight=1]; - categorytext:category_id:e -> category:in3:n [color="#4ecb8f", fontcolor="#4ecb8f", tooltip="FK_categorytext_category", weight=3]; + categorytext:category_id:w -> category:in5:n [color="#4ecb8f", fontcolor="#4ecb8f", tooltip="FK_categorytext_category", weight=3]; categorytext:language_id:w -> language:in2:n [color="#5aa7e6", fontcolor="#5aa7e6", tooltip="FK_categorytext_language", constraint=false, weight=1]; - articletext:article_id:e -> article:in10:n [color="#ff7aa8", fontcolor="#ff7aa8", tooltip="FK_articletext_article", weight=3]; - articletext:language_id:w -> language:in1:n [color="#e0b25a", fontcolor="#e0b25a", tooltip="FK_articletext_language", constraint=false, weight=1]; - price:tax_id:sw -> tax:in1:n [color="#56c8c8", fontcolor="#56c8c8", tooltip="FK_price_tax", constraint=false, weight=1]; - price:article_id:e -> article:in1:n [color="#ff5f9e", fontcolor="#ff5f9e", tooltip="FK_price_article", weight=3]; - price:customergroup_id:e -> customergroup:in0:n [color="#ffb25a", fontcolor="#ffb25a", tooltip="FK_price_customergroup", constraint=false, weight=1]; - articlesupplier:article_id:sw -> article:in8:n [color="#56d68a", fontcolor="#56d68a", tooltip="FK_articlesupplier_article", weight=3]; - articlesupplier:entity_id:e -> entity:in1:n [color="#66b3ff", fontcolor="#66b3ff", tooltip="FK_articlesupplier_entity", constraint=false, weight=1]; + articletext:article_id:e -> article:in8:n [color="#ff7aa8", fontcolor="#ff7aa8", tooltip="FK_articletext_article", weight=3]; + articletext:language_id:w -> language:in3:n [color="#e0b25a", fontcolor="#e0b25a", tooltip="FK_articletext_language", constraint=false, weight=1]; + price:tax_id:se -> tax:in4:n [color="#56c8c8", fontcolor="#56c8c8", tooltip="FK_price_tax", constraint=false, weight=1]; + price:article_id:w -> article:in9:n [color="#ff5f9e", fontcolor="#ff5f9e", tooltip="FK_price_article", weight=3]; + price:customergroup_id:w -> customergroup:in2:n [color="#ffb25a", fontcolor="#ffb25a", tooltip="FK_price_customergroup", constraint=false, weight=1]; + articlesupplier:article_id:nw -> article:in5:n [color="#56d68a", fontcolor="#56d68a", tooltip="FK_articlesupplier_article", weight=3]; + articlesupplier:entity_id:w -> entity:in4:n [color="#66b3ff", fontcolor="#66b3ff", tooltip="FK_articlesupplier_entity", constraint=false, weight=1]; articlesupplier:price_id:e -> price:in0:n [color="#c79bff", fontcolor="#c79bff", tooltip="FK_articlesupplier_price", constraint=false, weight=1]; - manifest:company_id:w -> company:in0:n [color="#ff6b6b", fontcolor="#ff6b6b", tooltip="FK_manifest_company", weight=3]; - manifest:entity_id:e -> entity:in0:n [color="#6bdf9a", fontcolor="#6bdf9a", tooltip="FK_manifest_entity", constraint=false, weight=1]; - manifestarticle:manifest_id:nw -> manifest:in0:n [color="#5aa7ff", fontcolor="#5aa7ff", tooltip="FK_manifestarticle_manifest", weight=3]; - manifestarticle:article_id:e -> article:in0:n [color="#f5c15c", fontcolor="#f5c15c", tooltip="FK_manifestarticle_article", constraint=false, weight=1]; - manifestarticle:tax_id:sw -> tax:in0:n [color="#c79bff", fontcolor="#c79bff", tooltip="FK_manifestarticle_tax", constraint=false, weight=1]; - ledger:manifestarticle_id:ne -> manifestarticle:in0:n [color="#ff9f5a", fontcolor="#ff9f5a", tooltip="FK_ledger_manifestarticle", weight=3]; - numbers:company_id:sw -> company:in5:n [color="#5cd6d6", fontcolor="#5cd6d6", tooltip="FK_numbers_company", weight=3]; - companyuser:google_auth_id:e -> google_auth:in0:n [color="#ff7fc2", fontcolor="#ff7fc2", tooltip="FK_companyuser_google_auth", constraint=false, weight=1]; - companyuser:company_id:w -> company:in6:n [color="#8f95ff", fontcolor="#8f95ff", tooltip="FK_companyuser_company", weight=3]; - syncpos:company_id:e -> company:in7:n [color="#58d18a", fontcolor="#58d18a", tooltip="FK_syncpos_company", weight=3]; - companysetting:company_id:w -> company:in8:n [color="#ff8f66", fontcolor="#ff8f66", tooltip="FK_companysetting_company", weight=3]; - posterminal:company_id:se -> company:in3:n [color="#4fc4e8", fontcolor="#4fc4e8", tooltip="FK_posterminal_company", weight=3]; - posterminalcategory:posterminal_id:sw -> posterminal:in0:n [color="#a98cff", fontcolor="#a98cff", tooltip="FK_posterminalcategory_posterminal", weight=3]; - posterminalcategory:category_id:w -> category:in4:n [color="#ff6f6f", fontcolor="#ff6f6f", tooltip="FK_posterminalcategory_category", constraint=false, weight=1]; + manifest:company_id:w -> company:in7:n [color="#ff6b6b", fontcolor="#ff6b6b", tooltip="FK_manifest_company", weight=3]; + manifest:entity_id:w -> entity:in3:n [color="#6bdf9a", fontcolor="#6bdf9a", tooltip="FK_manifest_entity", constraint=false, weight=1]; + manifestarticle:manifest_id:sw -> manifest:in0:n [color="#5aa7ff", fontcolor="#5aa7ff", tooltip="FK_manifestarticle_manifest", weight=3]; + manifestarticle:tax_id:e -> tax:in3:n [color="#f5c15c", fontcolor="#f5c15c", tooltip="FK_manifestarticle_tax", constraint=false, weight=1]; + ledger:manifestarticle_id:sw -> manifestarticle:in0:n [color="#c79bff", fontcolor="#c79bff", tooltip="FK_ledger_manifestarticle", weight=3]; + numbers:company_id:e -> company:in2:n [color="#ff9f5a", fontcolor="#ff9f5a", tooltip="FK_numbers_company", weight=3]; + companyuser:google_auth_id:e -> google_auth:in0:n [color="#5cd6d6", fontcolor="#5cd6d6", tooltip="FK_companyuser_google_auth", constraint=false, weight=1]; + companyuser:company_id:w -> company:in3:n [color="#ff7fc2", fontcolor="#ff7fc2", tooltip="FK_companyuser_company", weight=3]; + syncpos:company_id:ne -> company:in4:n [color="#8f95ff", fontcolor="#8f95ff", tooltip="FK_syncpos_company", weight=3]; + companysetting:company_id:sw -> company:in5:n [color="#58d18a", fontcolor="#58d18a", tooltip="FK_companysetting_company", weight=3]; + posterminal:company_id:e -> company:in0:n [color="#ff8f66", fontcolor="#ff8f66", tooltip="FK_posterminal_company", weight=3]; + posterminalcategory:posterminal_id:sw -> posterminal:in0:n [color="#4fc4e8", fontcolor="#4fc4e8", tooltip="FK_posterminalcategory_posterminal", weight=3]; + posterminalcategory:category_id:e -> category:in1:n [color="#a98cff", fontcolor="#a98cff", tooltip="FK_posterminalcategory_category", constraint=false, weight=1]; } \ No newline at end of file diff --git a/schema-graph.svg b/schema-graph.svg index c2d43e1..c5a5538 100644 --- a/schema-graph.svg +++ b/schema-graph.svg @@ -4,628 +4,510 @@ - - + + schema - + cluster_identity - -Identity & Company + +Identity & Company cluster_i18n - -Localization + +Localization cluster_catalog - -Catalog + +Catalog cluster_media - -Media + +Media -cluster_commerce - -Pricing & Documents +cluster_manifests + +Documents -cluster_units - -Units +cluster_commerce + +Pricing +cluster_units + +Units + + cluster_pos - -POS + +POS meta - - -meta - - -key -NVARCHAR(255) - - -value -NVARCHAR(MAX) + + +meta + + +key +NVARCHAR(255) + + +value +NVARCHAR(MAX) customergroup - - - - - -customergroup - - -id -INT -PK - - -company_id -? -INT -FK - - -name -NVARCHAR(255) - - -sort -INT + + + + + +customergroup + + +id +INT +PK + + +company_id +? +INT +FK + + +name +NVARCHAR(255) + + +sort +INT - + company - - - - - - - - - - - - -company - - -id -INT -PK - - -taxrate -? -INT -FK - - -reducedtaxrate -? -INT -FK - - -taxfreerate -? -INT -FK - - -root_category_id -? -INT -FK - - -default_language_id -? -INT -FK - - -poscustomergroup_id -INT -FK - - -name -NVARCHAR(255) + + + + + + + + + + + + +company + + +id +INT +PK + + +poscustomergroup_id +INT +FK + + +root_category_id +? +INT +FK + + +default_language_id +? +INT +FK + + +taxrate +? +INT +FK + + +reducedtaxrate +? +INT +FK + + +taxfreerate +? +INT +FK + + +name +NVARCHAR(255) -customergroup:se->company:n +customergroup:w->company:n - - - - - - - -company:sw->customergroup:n - - - - - - - - -language - - - - - - -language - - -id -INT -PK - - -iso639 -NVARCHAR(10) - - - -company:sw->language:n - - - - - - - - -category - - - - - - - - -category - - -id -INT -PK - - -parent_id -? -INT -FK - - -sort -INT - - - -company:w->category:n - - - - - - - - -tax - - - - - - - -tax - - -id -INT -PK - - -rate -DECIMAL(18,4) - - - -company:e->tax:n - - - - - - - - -company:e->tax:n - - - - - - - - -company:e->tax:n - - - + + - + numbers - - -numbers - - -id -INT -PK - - -company_id -INT -FK - - -type -NVARCHAR(100) - - -prefix -NVARCHAR(50) - - -padding -INT - - -next -INT + + +numbers + + +id +INT +PK + + +company_id +INT +FK + + +type +NVARCHAR(100) + + +prefix +NVARCHAR(50) + + +padding +INT + + +next +INT - -numbers:sw->company:n - - - + +numbers:e->company:n + + + - + entityaddress - - -entityaddress - - -id -INT -PK - - -entity_id -INT -FK - - -first_name? -NVARCHAR(255) - - -name? -NVARCHAR(255) - - -street? -NVARCHAR(255) - - -streetnumber? -NVARCHAR(50) - - -zip? -NVARCHAR(50) - - -city? -NVARCHAR(255) - - -county? -NVARCHAR(255) - - -addresstype -NVARCHAR(50) - - -sort -INT + + +entityaddress + + +id +INT +PK + + +entity_id +INT +FK + + +first_name? +NVARCHAR(255) + + +name? +NVARCHAR(255) + + +street? +NVARCHAR(255) + + +streetnumber? +NVARCHAR(50) + + +zip? +NVARCHAR(50) + + +city? +NVARCHAR(255) + + +county? +NVARCHAR(255) + + +addresstype +NVARCHAR(50) + + +sort +INT - + entity - - - - - - - -entity - - -id -INT -PK - - -customergroup_id -INT -FK - - -first_name? -NVARCHAR(255) - - -name -NVARCHAR(255) - - -number? -NVARCHAR(100) - - -created_at -DATETIME2 - - -updated_at -DATETIME2 + + + + + + + +entity + + +id +INT +PK + + +customergroup_id +INT +FK + + +first_name? +NVARCHAR(255) + + +name +NVARCHAR(255) + + +number? +NVARCHAR(100) + + +created_at +DATETIME2 + + +updated_at +DATETIME2 -entityaddress:sw->entity:n +entityaddress:ne->entity:n - - + + -entity:nw->customergroup:n +entity:w->customergroup:n - - + + - + companyuser - - - - -companyuser - - -id -INT -PK - - -company_id -INT -FK - - -google_auth_id -INT -FK + + + + +companyuser + + +id +INT +PK + + +company_id +INT +FK + + +google_auth_id +INT +FK - + companyuser:w->company:n - - - + + + google_auth - - - -google_auth - - -id -INT -PK - - -selected_company -? -INT -FK - - -email -NVARCHAR(320) - - -picture? -NVARCHAR(2048) - - -picturebinary? -VARBINARY(MAX) - - -sub? -NVARCHAR(255) - - -created_at -DATETIME2 + + + +google_auth + + +id +INT +PK + + +selected_company +? +INT +FK + + +email +NVARCHAR(320) + + +picture? +NVARCHAR(2048) + + +picturebinary? +VARBINARY(MAX) + + +sub? +NVARCHAR(255) + + +created_at +DATETIME2 - + companyuser:e->google_auth:n - - - + + + - + entitycontact - - -entitycontact - - -id -INT -PK - - -entity_id -INT -FK - - -contacttype -NVARCHAR(50) - - -contact -NVARCHAR(255) - - -sort -INT + + +entitycontact + + +id +INT +PK + + +entity_id +INT +FK + + +contacttype +NVARCHAR(50) + + +contact +NVARCHAR(255) + + +sort +INT -entitycontact:se->entity:n +entitycontact:sw->entity:n - - + + - + syncpos - - -syncpos - - -id -INT -PK - - -company_id -INT -FK - - -paircode -NVARCHAR(50) - - -token? -NVARCHAR(255) + + +syncpos + + +id +INT +PK + + +company_id +INT +FK + + +paircode +NVARCHAR(50) + + +token? +NVARCHAR(255) - -syncpos:e->company:n - - - + +syncpos:ne->company:n + + + - + entityhistory - - -entityhistory - - -id -INT -PK - - -entity_id -INT -FK - - -companyuser_id -? -INT -FK - - -date -DATETIME2 - - -text -NVARCHAR(MAX) + + +entityhistory + + +id +INT +PK + + +entity_id +INT +FK + + +companyuser_id +? +INT +FK + + +date +DATETIME2 + + +text +NVARCHAR(MAX) entityhistory:sw->entity:n - - + + @@ -633,370 +515,483 @@ entityhistory:se->companyuser:n - - + + + + + + + +company:w->customergroup:n + + + + + + + + +language + + + + + + +language + + +id +INT +PK + + +iso639 +NVARCHAR(10) + + + +company:e->language:n + + + + + + + + +category + + + + + + + + +category + + +id +INT +PK + + +parent_id +? +INT +FK + + +sort +INT + + + +company:e->category:n + + + + + + + + +tax + + + + + + + +tax + + +id +INT +PK + + +rate +DECIMAL(18,4) + + + +company:e->tax:n + + + + + + + + +company:e->tax:n + + + + + + + + +company:e->tax:n + + + companysetting - - -companysetting - - -id -INT -PK - - -company_id -INT -FK - - -key -NVARCHAR(255) - - -value -NVARCHAR(MAX) - - -frontend -BIT - - -writeonly -BIT + + +companysetting + + +id +INT +PK + + +company_id +INT +FK + + +key +NVARCHAR(255) + + +value +NVARCHAR(MAX) + + +frontend +BIT + + +writeonly +BIT - -companysetting:w->company:n - - - + +companysetting:sw->company:n + + + -google_auth:e->company:n +google_auth:sw->company:n - - + + unittext - - -unittext - - -id -INT -PK - - -language_id -INT -FK - - -unit_id -INT -FK - - -symbol -NVARCHAR(50) - - -name -NVARCHAR(255) + + +unittext + + +id +INT +PK + + +unit_id +INT +FK + + +language_id +INT +FK + + +symbol +NVARCHAR(50) + + +name +NVARCHAR(255) unittext:nw->language:n - - + + unit - - - - -unit - - -id -INT -PK - - -company_id -INT -FK - - -si -NVARCHAR(50) - - -basesi -NVARCHAR(50) - - -basesifactor -FLOAT + + + + +unit + + +id +INT +PK + + +company_id +INT +FK + + +si +NVARCHAR(50) + + +basesi +NVARCHAR(50) + + +basesifactor +FLOAT unittext:se->unit:n - - + + categorytext - - -categorytext - - -id -INT -PK - - -category_id -INT -FK - - -language_id -INT -FK - - -name -NVARCHAR(255) - - -slug -NVARCHAR(255) - - -seo? -NVARCHAR(MAX) - - -desc? -NVARCHAR(MAX) + + +categorytext + + +id +INT +PK + + +category_id +INT +FK + + +language_id +INT +FK + + +name +NVARCHAR(255) + + +slug +NVARCHAR(255) + + +seo? +NVARCHAR(MAX) + + +desc? +NVARCHAR(MAX) categorytext:w->language:n - - + + -categorytext:e->category:n +categorytext:w->category:n - - + + articletext - - -articletext - - -id -INT -PK - - -article_id -INT -FK - - -language_id -INT -FK - - -name -NVARCHAR(255) - - -slug -NVARCHAR(255) - - -seo? -NVARCHAR(MAX) - - -desc? -NVARCHAR(MAX) + + +articletext + + +id +INT +PK + + +article_id +INT +FK + + +language_id +INT +FK + + +name +NVARCHAR(255) + + +slug +NVARCHAR(255) + + +seo? +NVARCHAR(MAX) + + +desc? +NVARCHAR(MAX) articletext:w->language:n - - + + article - - - - - - - - - - - - - -article - - -id -INT -PK - - -brand_id -? -INT -FK - - -fatherarticle_id -? -INT -FK - - -articlelist_id -? -INT -FK - - -optionslist_id -? -INT -FK - - -unit_id -INT -FK - - -sku? -NVARCHAR(100) - - -unitamount -FLOAT - - -weight -FLOAT - - -is_father -BIT - - -fathersort -INT - - -created_at -DATETIME2 - - -updated_at -DATETIME2 + + + + + + + + + + + + +article + + +id +INT +PK + + +brand_id +? +INT +FK + + +fatherarticle_id +? +INT +FK + + +articlelist_id +? +INT +FK + + +optionslist_id +? +INT +FK + + +unit_id +INT +FK + + +sku? +NVARCHAR(100) + + +unitamount +FLOAT + + +weight +FLOAT + + +is_father +BIT + + +fathersort +INT + + +created_at +DATETIME2 + + +updated_at +DATETIME2 articletext:e->article:n - - - - - - - -category:e->category:e - - - + + - + categoryarticle - - -categoryarticle - - -id -INT -PK - - -category_id -INT -FK - - -article_id -INT -FK + + +categoryarticle + + +id +INT +PK + + +category_id +INT +FK + + +article_id +INT +FK -categoryarticle:sw->category:n +categoryarticle:se->category:n - - + + @@ -1004,84 +999,93 @@ categoryarticle:se->article:n - - + + - + brand - - - - -brand - - -id -INT -PK - - -company_id -INT -FK - - -name -NVARCHAR(255) - - -gsprpinfo? -NVARCHAR(MAX) + + + + +brand + + +id +INT +PK + + +company_id +INT +FK + + +name +NVARCHAR(255) + + +gsprpinfo? +NVARCHAR(MAX) -brand:e->company:n +brand:w->company:n - - + + + + + + + +category:e->category:e + + + articlehistory - - -articlehistory - - -id -INT -PK - - -article_id -INT -FK - - -companyuser_id -? -INT -FK - - -date -DATETIME2 - - -text -NVARCHAR(MAX) + + +articlehistory + + +id +INT +PK + + +companyuser_id +? +INT +FK + + +article_id +INT +FK + + +date +DATETIME2 + + +text +NVARCHAR(MAX) -articlehistory:e->companyuser:n +articlehistory:w->companyuser:n - - + + @@ -1089,8 +1093,8 @@ articlehistory:ne->article:n - - + + @@ -1098,8 +1102,8 @@ article:sw->brand:n - - + + @@ -1107,54 +1111,54 @@ article:e->article:e - - + + articlelist - - - - -articlelist - - -id -INT -PK + + + + +articlelist + + +id +INT +PK article:sw->articlelist:n - - + + - + optionslist - - - - -optionslist - - -id -INT -PK + + + + +optionslist + + +id +INT +PK article:e->optionslist:n - - + + @@ -1162,77 +1166,180 @@ article:e->unit:n - - + + articleean - - -articleean - - -id -INT -PK - - -article_id -INT -FK - - -ean -NVARCHAR(50) + + +articleean + + +id +INT +PK + + +article_id +INT +FK + + +ean +NVARCHAR(50) -articleean:sw->article:n +articleean:se->article:n - - + + + + + + + +articlesupplier + + +articlesupplier + + +id +INT +PK + + +entity_id +INT +FK + + +article_id +INT +FK + + +price_id +? +INT +FK + + +sku? +NVARCHAR(100) + + +stock? +FLOAT + + +pu +FLOAT + + + +articlesupplier:w->entity:n + + + + + + + + +articlesupplier:nw->article:n + + + + + + + + +price + + + +price + + +id +INT +PK + + +customergroup_id +INT +FK + + +article_id +INT +FK + + +tax_id +INT +FK + + +minmultiplier +DECIMAL(18,4) + + +net +FLOAT + + + +articlesupplier:e->price:n + + + - + articlelistarticle - - -articlelistarticle - - -id -INT -PK - - -article_id -INT -FK - - -articlelist_id -INT -FK - - -count -INT - - -sort -INT + + +articlelistarticle + + +id +INT +PK + + +article_id +INT +FK + + +articlelist_id +INT +FK + + +count +INT + + +sort +INT -articlelistarticle:e->article:n +articlelistarticle:w->article:n - - + + @@ -1240,154 +1347,51 @@ articlelistarticle:sw->articlelist:n - - - - - - - -articlesupplier - - -articlesupplier - - -id -INT -PK - - -price_id -? -INT -FK - - -article_id -INT -FK - - -entity_id -INT -FK - - -SupplierSKU? -NVARCHAR(100) - - -SupplierStock? -FLOAT - - -pu -FLOAT - - - -articlesupplier:e->entity:n - - - - - - - - -articlesupplier:sw->article:n - - - - - - - - -price - - - -price - - -id -INT -PK - - -tax_id -INT -FK - - -article_id -INT -FK - - -customergroup_id -INT -FK - - -minmultiplier -DECIMAL(18,4) - - -net -FLOAT - - - -articlesupplier:e->price:n - - - + + - + optionslistarticle - - -optionslistarticle - - -id -INT -PK - - -article_id -INT -FK - - -optionslist_id -INT -FK - - -count -INT - - -sort -INT - - -mandated -BIT + + +optionslistarticle + + +id +INT +PK + + +article_id +INT +FK + + +optionslist_id +INT +FK + + +count +INT + + +sort +INT + + +mandated +BIT -optionslistarticle:w->article:n +optionslistarticle:sw->article:n - - + + @@ -1395,98 +1399,98 @@ optionslistarticle:se->optionslist:n - - + + pic - - - - - -pic - - -id -INT -PK - - -w -INT - - -h -INT - - -size -BIGINT - - -hash -NVARCHAR(64) - - -thumbw -INT - - -thumbh -INT - - -thumbhash -NVARCHAR(64) - - -source -NVARCHAR(MAX) - - -fullbinary -VARBINARY(MAX) - - -thumbbinary -VARBINARY(MAX) + + + + + +pic + + +id +INT +PK + + +w +INT + + +h +INT + + +size +BIGINT + + +hash +NVARCHAR(64) + + +thumbw +INT + + +thumbh +INT + + +thumbhash +NVARCHAR(64) + + +source +NVARCHAR(MAX) + + +fullbinary +VARBINARY(MAX) + + +thumbbinary +VARBINARY(MAX) categorypic - - -categorypic - - -id -INT -PK - - -pic_id -INT -FK - - -category_id -INT -FK - - -sort -INT + + +categorypic + + +id +INT +PK + + +pic_id +INT +FK + + +category_id +INT +FK + + +sort +INT -categorypic:se->category:n +categorypic:e->category:n - - + + @@ -1494,87 +1498,43 @@ categorypic:e->pic:n - - - - - - - -articlepic - - -articlepic - - -id -INT -PK - - -pic_id -INT -FK - - -article_id -INT -FK - - -sort -INT - - - -articlepic:e->article:n - - - - - - - - -articlepic:w->pic:n - - - + + - + brandpic - - -brandpic - - -id -INT -PK - - -pic_id -INT -FK - - -brand_id -INT -FK - - -sort -INT + + +brandpic + + +id +INT +PK + + +pic_id +INT +FK + + +brand_id +INT +FK + + +sort +INT brandpic:se->brand:n - - + + @@ -1582,174 +1542,166 @@ brandpic:nw->pic:n - - + + - - -ledger - - -ledger - - -id -INT -PK - - -manifestarticle_id -INT -FK - - -transaction_type -NVARCHAR(100) - - -amount -FLOAT - - -transaction_text -NVARCHAR(MAX) - - -hash_version -INT - - -prev_hash? -NVARCHAR(128) + + +articlepic + + +articlepic + + +id +INT +PK + + +pic_id +INT +FK + + +article_id +INT +FK + + +sort +INT + + + +articlepic:e->article:n + + + + + + + + +articlepic:w->pic:n + + + + + - + manifestarticle - - - -manifestarticle - - -id -INT -PK - - -manifest_id -INT -FK - - -tax_id -INT -FK - - -article_id -? -INT -FK - - -customsku? -NVARCHAR(100) - - -customname? -NVARCHAR(255) - - -amount -FLOAT - - -net -FLOAT - - -comment? -NVARCHAR(MAX) - - -rebate -FLOAT - - - -ledger:ne->manifestarticle:n - - - - - - - - -manifestarticle:e->article:n - - - - - + + + +manifestarticle + + +id +INT +PK + + +manifest_id +INT +FK + + +tax_id +INT +FK + + +sku? +NVARCHAR(100) + + +customname? +NVARCHAR(255) + + +amount +FLOAT + + +net +FLOAT + + +comment? +NVARCHAR(MAX) + + +rebate +FLOAT - + manifest - - - -manifest - - -id -INT -PK - - -company_id -INT -FK - - -entity_id -? -INT -FK - - -number -NVARCHAR(100) - - -type -NVARCHAR(100) - - -external_number? -NVARCHAR(100) - - -date -DATETIME2 + + + +manifest + + +id +INT +PK + + +entity_id +? +INT +FK + + +company_id +INT +FK + + +number +NVARCHAR(100) + + +type +NVARCHAR(100) + + +external_number? +NVARCHAR(100) + + +date +DATETIME2 -manifestarticle:nw->manifest:n +manifestarticle:sw->manifest:n - - + + - -manifestarticle:sw->tax:n - - - + +manifestarticle:e->tax:n + + + + + + + + +manifest:w->entity:n + + + @@ -1757,162 +1709,199 @@ manifest:w->company:n - - + + - - -manifest:e->entity:n - - - + + +ledger + + +ledger + + +id +INT +PK + + +manifestarticle_id +INT +FK + + +transaction_type +NVARCHAR(100) + + +amount +FLOAT + + +transaction_text +NVARCHAR(MAX) + + +hash_version +INT + + +prev_hash? +NVARCHAR(128) + + + +ledger:sw->manifestarticle:n + + + -price:e->customergroup:n +price:w->customergroup:n - - + + -price:e->article:n +price:w->article:n - - + + -price:sw->tax:n +price:se->tax:n - - + + -unit:e->company:n +unit:w->company:n - - + + posterminal - - - -posterminal - - -id -INT -PK - - -company_id -INT -FK - - -name -NVARCHAR(255) - - -token? -NVARCHAR(255) - - -pairingpin -NVARCHAR(50) + + + +posterminal + + +id +INT +PK + + +company_id +INT +FK + + +name +NVARCHAR(255) + + +token? +NVARCHAR(255) + + +pairingpin +NVARCHAR(50) - -posterminal:se->company:n - - - + +posterminal:e->company:n + + + posterminalcategory - - -posterminalcategory - - -id -INT -PK - - -category_id -INT -FK - - -posterminal_id -INT -FK + + +posterminalcategory + + +id +INT +PK + + +posterminal_id +INT +FK + + +category_id +INT +FK - -posterminalcategory:w->category:n - - - + +posterminalcategory:e->category:n + + + - + posterminalcategory:sw->posterminal:n - - - + + + __legend - - - -Legend - -PK - -primary key - -FK - -foreign key - -? - -nullable column - -— - -FOREIGN KEY constraint - -- - - -naming convention only, no constraint + + + +Legend + +PK + +primary key + +FK + +foreign key + +? + +nullable column + +— + +FOREIGN KEY constraint + +- - + +naming convention only, no constraint diff --git a/src/schema.js b/src/schema.js index ce1bab2..e8e391f 100644 --- a/src/schema.js +++ b/src/schema.js @@ -536,8 +536,8 @@ BEGIN article_id INT NOT NULL, entity_id INT NOT NULL, price_id INT NULL, - supplierSKU NVARCHAR(100) NULL, - supplierStock FLOAT NULL, + sku NVARCHAR(100) NULL, + stock FLOAT NULL, pu FLOAT NOT NULL CONSTRAINT DF_articlesupplier_pu DEFAULT 1, CONSTRAINT FK_articlesupplier_article FOREIGN KEY (article_id) REFERENCES article(id) ON DELETE CASCADE, CONSTRAINT FK_articlesupplier_entity FOREIGN KEY (entity_id) REFERENCES entity(id) ON DELETE CASCADE, @@ -572,8 +572,7 @@ BEGIN CREATE TABLE manifestarticle ( id INT IDENTITY(1,1) PRIMARY KEY, manifest_id INT NOT NULL, - article_id INT NULL, - customsku NVARCHAR(100) NULL, + sku NVARCHAR(100) NULL, customname NVARCHAR(255) NULL, amount FLOAT NOT NULL, net FLOAT NOT NULL, @@ -581,44 +580,12 @@ BEGIN rebate FLOAT NOT NULL CONSTRAINT DF_manifestarticle_rebate DEFAULT 0, tax_id INT NOT NULL, CONSTRAINT FK_manifestarticle_manifest FOREIGN KEY (manifest_id) REFERENCES manifest(id) ON DELETE CASCADE, - CONSTRAINT FK_manifestarticle_article FOREIGN KEY (article_id) REFERENCES article(id) ON DELETE SET NULL, - CONSTRAINT FK_manifestarticle_tax FOREIGN KEY (tax_id) REFERENCES tax(id) ON DELETE CASCADE, - CONSTRAINT CK_manifestarticle_article_or_custom CHECK ( - (article_id IS NOT NULL AND customsku IS NULL AND customname IS NULL) - OR (article_id IS NULL) - ) + CONSTRAINT FK_manifestarticle_tax FOREIGN KEY (tax_id) REFERENCES tax(id) ON DELETE CASCADE ); END - -IF NOT EXISTS ( - SELECT 1 FROM sys.columns - WHERE object_id = OBJECT_ID(N'dbo.manifestarticle') AND name = N'customsku' -) -BEGIN - EXEC('ALTER TABLE dbo.manifestarticle ADD customsku NVARCHAR(100) NULL'); -END - -IF NOT EXISTS ( - SELECT 1 FROM sys.columns - WHERE object_id = OBJECT_ID(N'dbo.manifestarticle') AND name = N'customname' -) -BEGIN - EXEC('ALTER TABLE dbo.manifestarticle ADD customname NVARCHAR(255) NULL'); -END - -IF NOT EXISTS ( - SELECT 1 FROM sys.check_constraints - WHERE name = N'CK_manifestarticle_article_or_custom' -) -BEGIN - EXEC('ALTER TABLE dbo.manifestarticle ADD CONSTRAINT CK_manifestarticle_article_or_custom - CHECK ( - (article_id IS NOT NULL AND customsku IS NULL AND customname IS NULL) - OR (article_id IS NULL) - )'); -END `; + export const INIT_LEDGER = ` IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'ledger') BEGIN diff --git a/src/sql/articleDelete.js b/src/sql/articleDelete.js index 785f277..7bb01c5 100644 --- a/src/sql/articleDelete.js +++ b/src/sql/articleDelete.js @@ -10,22 +10,6 @@ FROM article WHERE id = @articleId `; -export const GET_NAME_FOR_DELETE = ` -SELECT TOP 1 at.name -FROM articletext at -WHERE at.article_id = @articleId AND at.language_id = @languageId -`; - -export const DETACH_MANIFEST_ARTICLES = ` -UPDATE manifestarticle -SET article_id = NULL, - comment = CONCAT( - ISNULL(comment, ''), - CASE WHEN comment IS NULL OR comment = '' THEN '' ELSE ' ' END, - @suffix - ) -WHERE article_id = @articleId -`; export const DELETE_PICS_BY_ARTICLE = ` DELETE p diff --git a/src/sql/delivery.js b/src/sql/delivery.js index 9c6bd85..bd677cb 100644 --- a/src/sql/delivery.js +++ b/src/sql/delivery.js @@ -31,9 +31,7 @@ WHERE m.id = @id export const GET_DELIVERY_LINES = ` SELECT ma.id, - ma.article_id AS articleId, - a.sku, - ma.customsku, + ma.sku, ma.customname, ma.amount, ma.net, @@ -41,7 +39,6 @@ SELECT t.rate AS tax, ma.comment FROM manifestarticle ma -LEFT JOIN article a ON a.id = ma.article_id INNER JOIN tax t ON t.id = ma.tax_id WHERE ma.manifest_id = @manifestId ORDER BY ma.id @@ -80,8 +77,7 @@ WHERE manifest_id = @manifestId export const CREATE_LINE = ` INSERT INTO manifestarticle ( manifest_id, - article_id, - customsku, + sku, customname, amount, net, @@ -92,8 +88,7 @@ INSERT INTO manifestarticle ( OUTPUT INSERTED.id VALUES ( @manifestId, - @articleId, - @customsku, + @sku, @customname, @amount, @net, @@ -102,27 +97,3 @@ VALUES ( @taxId ) `; - -/** Resolve SKU to article id if reachable via the company category tree. */ -export const RESOLVE_ARTICLE_ID_BY_SKU = ` -;WITH category_tree AS ( - SELECT id - FROM category - WHERE id = @rootCategoryId - - UNION ALL - - SELECT c.id - FROM category c - INNER JOIN category_tree ct ON c.parent_id = ct.id -) -SELECT TOP 1 a.id -FROM article a -WHERE a.sku = @sku - AND EXISTS ( - SELECT 1 - FROM categoryarticle ca - INNER JOIN category_tree ct ON ct.id = ca.category_id - WHERE ca.article_id = a.id -) -`; diff --git a/src/sql/manifestDoc.js b/src/sql/manifestDoc.js index 9e4051b..163d0ab 100644 --- a/src/sql/manifestDoc.js +++ b/src/sql/manifestDoc.js @@ -37,9 +37,7 @@ WHERE m.id = @id export const GET_MANIFEST_LINES = ` SELECT ma.id, - ma.article_id AS articleId, - a.sku, - ma.customsku, + ma.sku, ma.customname, ma.amount, ma.net, @@ -47,7 +45,6 @@ SELECT t.rate AS tax, ma.comment FROM manifestarticle ma -LEFT JOIN article a ON a.id = ma.article_id INNER JOIN tax t ON t.id = ma.tax_id WHERE ma.manifest_id = @manifestId ORDER BY ma.id @@ -86,8 +83,7 @@ WHERE manifest_id = @manifestId export const CREATE_LINE = ` INSERT INTO manifestarticle ( manifest_id, - article_id, - customsku, + sku, customname, amount, net, @@ -98,8 +94,7 @@ INSERT INTO manifestarticle ( OUTPUT INSERTED.id VALUES ( @manifestId, - @articleId, - @customsku, + @sku, @customname, @amount, @net, @@ -108,27 +103,3 @@ VALUES ( @taxId ) `; - -/** Resolve SKU to article id if reachable via the company category tree. */ -export const RESOLVE_ARTICLE_ID_BY_SKU = ` -;WITH category_tree AS ( - SELECT id - FROM category - WHERE id = @rootCategoryId - - UNION ALL - - SELECT c.id - FROM category c - INNER JOIN category_tree ct ON c.parent_id = ct.id -) -SELECT TOP 1 a.id -FROM article a -WHERE a.sku = @sku - AND EXISTS ( - SELECT 1 - FROM categoryarticle ca - INNER JOIN category_tree ct ON ct.id = ca.category_id - WHERE ca.article_id = a.id -) -`; diff --git a/src/store/article/delete.js b/src/store/article/delete.js index 3bd631f..e4b75ee 100644 --- a/src/store/article/delete.js +++ b/src/store/article/delete.js @@ -3,10 +3,8 @@ import { DELETE_BY_ID, DELETE_OPTIONSLIST, DELETE_PICS_BY_ARTICLE, - DETACH_MANIFEST_ARTICLES, GET_CHILD_COUNT, GET_LIST_IDS, - GET_NAME_FOR_DELETE, } from '../../sql/articleDelete.js'; import resolveArticleBySku from './resolveArticleBySku.js'; import request from '../request.js'; @@ -26,7 +24,7 @@ export default function del(pool) { * await store.article.delete(42, 'SKU-1'); */ return async (googleAuthId, sku) => { - const { articleId, languageId } = await resolve(googleAuthId, sku); + const { articleId } = await resolve(googleAuthId, sku); const childCount = await pool .request() @@ -37,15 +35,6 @@ export default function del(pool) { throw new Error('Article has children'); } - const nameResult = await pool - .request() - .input('articleId', articleId) - .input('languageId', languageId) - .query(GET_NAME_FOR_DELETE); - - const name = nameResult.recordset[0]?.name ?? sku; - const suffix = `article ${name} deleted`; - const listIds = await pool .request() .input('articleId', articleId) @@ -57,11 +46,6 @@ export default function del(pool) { await tx.begin(); try { - await request(pool, tx) - .input('articleId', articleId) - .input('suffix', suffix) - .query(DETACH_MANIFEST_ARTICLES); - await request(pool, tx) .input('articleId', articleId) .query(DELETE_PICS_BY_ARTICLE); diff --git a/src/store/delivery/create.js b/src/store/delivery/create.js index ab94cbb..510a87c 100644 --- a/src/store/delivery/create.js +++ b/src/store/delivery/create.js @@ -41,7 +41,7 @@ export default function create(pool) { const lines = normalizeLines(body.lines ?? []); - const { companyId, rootCategoryId } = await access(googleAuthId); + const { companyId } = await access(googleAuthId); const tx = pool.transaction(); await tx.begin(); @@ -69,7 +69,6 @@ export default function create(pool) { await insertLines(pool, tx, { manifestId, - rootCategoryId, lines, ensureTax, }); diff --git a/src/store/delivery/update.js b/src/store/delivery/update.js index c6ee940..85a3a94 100644 --- a/src/store/delivery/update.js +++ b/src/store/delivery/update.js @@ -56,7 +56,7 @@ export default function update(pool) { normalizedLines = normalizeLines(patch.lines); } - const { companyId, rootCategoryId } = await access(googleAuthId); + const { companyId } = await access(googleAuthId); const tx = pool.transaction(); await tx.begin(); @@ -125,7 +125,6 @@ export default function update(pool) { await insertLines(pool, tx, { manifestId: id, - rootCategoryId, lines: normalizedLines, ensureTax, }); diff --git a/src/store/manifestLines.js b/src/store/manifestLines.js index e862641..9eae6e0 100644 --- a/src/store/manifestLines.js +++ b/src/store/manifestLines.js @@ -1,11 +1,11 @@ -import { CREATE_LINE, RESOLVE_ARTICLE_ID_BY_SKU } from '../sql/manifestDoc.js'; +import { CREATE_LINE } from '../sql/manifestDoc.js'; import request from './request.js'; /** * Normalizes and validates an array of manifest line inputs. * * @param {Array} lines - The raw line inputs. - * @returns {Array<{sku: string|null, customsku: string|null, customname: string|null, amount: number, net: number, rebate: number, tax: number, comment: string|null}>} The normalized lines. + * @returns {Array<{sku: string|null, customname: string|null, amount: number, net: number, rebate: number, tax: number, comment: string|null}>} The normalized lines. * @throws {Error} If the lines are invalid. */ export function normalizeLines(lines) { @@ -15,16 +15,11 @@ export function normalizeLines(lines) { return lines.map((entry) => { const sku = entry?.sku?.trim?.() ? entry.sku.trim() : null; - let customsku = entry?.customsku?.trim?.() ? entry.customsku.trim() : null; - let customname = + const customname = entry?.customname?.trim?.() ? entry.customname.trim() : null; - // If an article SKU is present, the custom fields must be null. - if (sku) { - customsku = null; - customname = null; - } else if (!customsku && !customname) { - // Must have either a catalog SKU or at least one custom field. + // Must have either an SKU or a custom name. + if (!sku && !customname) { throw new Error('Invalid lines'); } @@ -47,7 +42,7 @@ export function normalizeLines(lines) { throw new Error('Invalid lines'); } - return { sku, customsku, customname, amount, net, rebate, tax, comment }; + return { sku, customname, amount, net, rebate, tax, comment }; }); } @@ -79,9 +74,7 @@ export function parseDate(value) { export function shapeLine(row) { return { id: row.id, - articleId: row.articleId ?? null, sku: row.sku ?? null, - customsku: row.customsku ?? null, customname: row.customname ?? null, amount: row.amount, net: row.net, @@ -91,28 +84,14 @@ export function shapeLine(row) { }; } -async function resolveArticleId(pool, tx, rootCategoryId, sku) { - const result = await request(pool, tx) - .input('rootCategoryId', rootCategoryId) - .input('sku', sku) - .query(RESOLVE_ARTICLE_ID_BY_SKU); - - const articleId = result.recordset[0]?.id; - if (!articleId) { - throw new Error('Article not found'); - } - return articleId; -} - /** - * Inserts manifest lines for a document, resolving each SKU to an article id + * Inserts manifest lines for a document, storing each SKU directly * and ensuring the tax rate. * * @param {object} pool - The mssql connection pool. * @param {object} tx - The transaction. * @param {object} params - The insert parameters. * @param {number} params.manifestId - The manifest id. - * @param {number} params.rootCategoryId - The company root category id. * @param {Array} params.lines - The normalized lines. * @param {Function} params.ensureTax - The tax ensure function. * @returns {Promise} @@ -120,19 +99,15 @@ async function resolveArticleId(pool, tx, rootCategoryId, sku) { export async function insertLines( pool, tx, - { manifestId, rootCategoryId, lines, ensureTax }, + { manifestId, lines, ensureTax }, ) { for (const line of lines) { - const articleId = line.sku - ? await resolveArticleId(pool, tx, rootCategoryId, line.sku) - : null; const taxId = await ensureTax(line.tax, tx); await request(pool, tx) .input('manifestId', manifestId) - .input('articleId', articleId) - .input('customsku', line.sku ? null : line.customsku ?? null) - .input('customname', line.sku ? null : line.customname ?? null) + .input('sku', line.sku ?? null) + .input('customname', line.customname ?? null) .input('amount', line.amount) .input('net', line.net) .input('comment', line.comment) @@ -141,3 +116,4 @@ export async function insertLines( .query(CREATE_LINE); } } + diff --git a/src/store/order/create.js b/src/store/order/create.js index ee78e04..86da525 100644 --- a/src/store/order/create.js +++ b/src/store/order/create.js @@ -37,7 +37,7 @@ export default function create(pool) { : null; const lines = normalizeLines(body.lines ?? []); - const { companyId, rootCategoryId } = await access(googleAuthId); + const { companyId } = await access(googleAuthId); const tx = pool.transaction(); await tx.begin(); @@ -63,7 +63,6 @@ export default function create(pool) { await insertLines(pool, tx, { manifestId, - rootCategoryId, lines, ensureTax, }); diff --git a/src/store/order/update.js b/src/store/order/update.js index 131dbb5..347e9ec 100644 --- a/src/store/order/update.js +++ b/src/store/order/update.js @@ -52,7 +52,7 @@ export default function update(pool) { normalizedLines = normalizeLines(patch.lines); } - const { companyId, rootCategoryId } = await access(googleAuthId); + const { companyId } = await access(googleAuthId); const tx = pool.transaction(); await tx.begin(); @@ -121,7 +121,6 @@ export default function update(pool) { await insertLines(pool, tx, { manifestId: id, - rootCategoryId, lines: normalizedLines, ensureTax, }); diff --git a/src/store/quote/create.js b/src/store/quote/create.js index 42eaf58..d3f12f1 100644 --- a/src/store/quote/create.js +++ b/src/store/quote/create.js @@ -37,7 +37,7 @@ export default function create(pool) { : null; const lines = normalizeLines(body.lines ?? []); - const { companyId, rootCategoryId } = await access(googleAuthId); + const { companyId } = await access(googleAuthId); const tx = pool.transaction(); await tx.begin(); @@ -63,7 +63,6 @@ export default function create(pool) { await insertLines(pool, tx, { manifestId, - rootCategoryId, lines, ensureTax, }); diff --git a/src/store/quote/update.js b/src/store/quote/update.js index aacb9db..f799945 100644 --- a/src/store/quote/update.js +++ b/src/store/quote/update.js @@ -52,7 +52,7 @@ export default function update(pool) { normalizedLines = normalizeLines(patch.lines); } - const { companyId, rootCategoryId } = await access(googleAuthId); + const { companyId } = await access(googleAuthId); const tx = pool.transaction(); await tx.begin(); @@ -121,7 +121,6 @@ export default function update(pool) { await insertLines(pool, tx, { manifestId: id, - rootCategoryId, lines: normalizedLines, ensureTax, });