This commit is contained in:
seb
2026-10-28 18:33:32 +01:00
parent 2d4d894881
commit 2ded87abb7
3 changed files with 11 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ Ensures a number sequence row exists for a company and type, inferring the compa
*Source: `src/store/numbers/list.js`* *Source: `src/store/numbers/list.js`*
Lists the number sequences of the user's selected company. Ensures that default sequences ('sku', 'entity', 'delivery', 'adjustment', 'shipment', 'quote', 'order') exist. Lists the number sequences of the user's selected company. Ensures that default sequences ('sku', 'entity', 'delivery', 'adjustment', 'shipment', 'quote', 'order', 'return', 'retoure') exist.
**Parameters** **Parameters**

View File

@@ -27,8 +27,13 @@ export async function ensureNumberType(runner, companyId, type) {
let res = await runner.query(getSql, { companyId, type }); let res = await runner.query(getSql, { companyId, type });
let row = res.rows[0]; let row = res.rows[0];
// If already exists and is configured (has prefix or padding > 0, or not order/quote), return row // If already exists and is configured (has prefix or padding > 0, or not order/quote/return/retoure), return row
if (row && (row.prefix || row.padding > 0 || (type !== 'order' && type !== 'quote'))) { if (
row &&
(row.prefix ||
row.padding > 0 ||
(type !== 'order' && type !== 'quote' && type !== 'return' && type !== 'retoure'))
) {
return row; return row;
} }

View File

@@ -16,6 +16,8 @@ const DEFAULT_TYPES = [
'shipment', 'shipment',
'quote', 'quote',
'order', 'order',
'return',
'retoure',
]; ];
function shape(row) { function shape(row) {
@@ -36,7 +38,7 @@ export default function list(provider) {
/** /**
* Lists the number sequences of the user's selected company. * Lists the number sequences of the user's selected company.
* Ensures that default sequences ('sku', 'entity', 'delivery', 'adjustment', 'shipment', 'quote', 'order') exist. * Ensures that default sequences ('sku', 'entity', 'delivery', 'adjustment', 'shipment', 'quote', 'order', 'return', 'retoure') exist.
* *
* @param {number} googleAuthId - The id of the Google auth user. * @param {number} googleAuthId - The id of the Google auth user.
* @param {object} [tx] - Optional transaction to run within. * @param {object} [tx] - Optional transaction to run within.