Multi-environment and multi-user construction
This commit is contained in:
@@ -96,10 +96,24 @@ export class ChequeRemindersService {
|
||||
|
||||
const staff = await this.prisma.user.findMany({
|
||||
where: {
|
||||
organizationId: row.organizationId,
|
||||
OR: [
|
||||
{ role: { in: ['owner', 'admin'] } },
|
||||
...(row.ownerId ? [{ id: row.ownerId }] : []),
|
||||
{
|
||||
memberships: {
|
||||
some: {
|
||||
organizationId: row.organizationId,
|
||||
role: { in: ['owner', 'admin'] },
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
...(row.ownerId
|
||||
? [
|
||||
{
|
||||
id: row.ownerId,
|
||||
memberships: { some: { organizationId: row.organizationId } },
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
select: { id: true, mobile: true },
|
||||
|
||||
@@ -75,7 +75,17 @@ export class CommissionsService {
|
||||
|
||||
const fixed = invoice.commissionFixedAmount;
|
||||
const overridePercent = invoice.commissionPercent;
|
||||
const defaultPercent = Number(invoice.owner?.commissionPercent ?? 0);
|
||||
const membership = invoice.ownerId
|
||||
? await this.prisma.membership.findFirst({
|
||||
where: {
|
||||
userId: invoice.ownerId,
|
||||
organizationId,
|
||||
isActive: true,
|
||||
},
|
||||
select: { commissionPercent: true },
|
||||
})
|
||||
: null;
|
||||
const defaultPercent = Number(membership?.commissionPercent ?? 0);
|
||||
const percent =
|
||||
fixed != null
|
||||
? payable > 0
|
||||
|
||||
Reference in New Issue
Block a user