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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user