feat: implement user-scoped receipt aliases with global fallback; enhance alias management in admin panel
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -208,11 +208,20 @@ export class ReceiptImportService {
|
||||
// Hämta alias och produkter parallellt — filtrera på userId om angivet
|
||||
const productFilter = userId ? { isActive: true, ownerId: userId } : { isActive: true };
|
||||
const aliasFilter = userId
|
||||
? { product: { ownerId: userId } }
|
||||
: {};
|
||||
? {
|
||||
OR: [
|
||||
{ ownerId: userId, isGlobal: false },
|
||||
{ isGlobal: true },
|
||||
],
|
||||
}
|
||||
: { isGlobal: true };
|
||||
const [aliases, products] = await Promise.all([
|
||||
this.prisma.receiptAlias.findMany({
|
||||
where: aliasFilter,
|
||||
orderBy: [
|
||||
{ isGlobal: 'asc' },
|
||||
{ id: 'asc' },
|
||||
],
|
||||
select: { receiptName: true, productId: true, product: { select: { id: true, name: true, canonicalName: true, categoryId: true, categoryRef: { select: { id: true, name: true } } } } },
|
||||
}),
|
||||
this.prisma.product.findMany({
|
||||
|
||||
Reference in New Issue
Block a user