feat: enhance deactivation logic for conflicting active contract templates to handle null contract types and user types
This commit is contained in:
parent
aa98d9ac37
commit
bdee857828
@ -166,12 +166,18 @@ class DocumentTemplateRepository {
|
||||
SET state = 'inactive', updatedAt = NOW()
|
||||
WHERE id <> ?
|
||||
AND type = 'contract'
|
||||
AND contract_type = ?
|
||||
AND (
|
||||
contract_type = ?
|
||||
OR (contract_type IS NULL AND ? = 'contract')
|
||||
)
|
||||
AND lang = ?
|
||||
AND state = 'active'
|
||||
AND user_type IN (${overlap.map(() => '?').join(', ')})
|
||||
AND (
|
||||
user_type IN (${overlap.map(() => '?').join(', ')})
|
||||
OR user_type IS NULL
|
||||
)
|
||||
`;
|
||||
const params = [excludeId, safeContractType, safeLang, ...overlap];
|
||||
const params = [excludeId, safeContractType, safeContractType, safeLang, ...overlap];
|
||||
try {
|
||||
if (conn) {
|
||||
const [res] = await conn.execute(query, params);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user