Add article.setPricesBySku to replace POS prices for a SKU.

Gives dashback a single store call that atomically replaces all price rows for the article’s poscustomergroup.
This commit is contained in:
seb
2026-08-01 05:16:50 +02:00
parent 9be9f7f74c
commit 54700a145e
5 changed files with 156 additions and 1 deletions

View File

@@ -120,6 +120,11 @@ const MENU = {
label: 'updateBySku',
hint: 'googleAuthId, sku, name → row',
},
{
value: 'article.setPricesBySku',
label: 'setPricesBySku',
hint: 'googleAuthId, sku, JSON prices → row',
},
{
value: 'article.addImage',
label: 'addImage',
@@ -456,6 +461,35 @@ async function runMethod(client, action) {
await client.article.updateBySku(Number(googleAuthId), sku, { name }),
];
}
case 'article.setPricesBySku': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const sku = await askText('sku', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (sku == null) return;
const pricesJson = await askText('prices JSON', {
placeholder: '[{"price":9.99,"tax":19}]',
validate: (v) => {
if (!v?.trim()) return 'Required';
try {
const parsed = JSON.parse(v);
if (!Array.isArray(parsed)) return 'Must be a JSON array';
} catch {
return 'Invalid JSON';
}
},
});
if (pricesJson == null) return;
return [
'result',
await client.article.setPricesBySku(
Number(googleAuthId),
sku,
JSON.parse(pricesJson),
),
];
}
case 'article.addImage': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;