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

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

View File

@@ -16,6 +16,8 @@ const DEFAULT_TYPES = [
'shipment',
'quote',
'order',
'return',
'retoure',
];
function shape(row) {
@@ -36,7 +38,7 @@ export default function list(provider) {
/**
* 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 {object} [tx] - Optional transaction to run within.