init to statistics and manage pos type users
This commit is contained in:
@@ -9,8 +9,6 @@ import { EnumsModule } from './modules/enums/enums.module'
|
||||
import { PosModule } from './modules/pos/pos.module'
|
||||
import { SalesInvoiceItemsModule } from './modules/pos/sales-invoices/sales-invoice-items/sales-invoice-items.module'
|
||||
import { SalesInvoicePaymentsModule } from './modules/pos/sales-invoices/sales-invoice-payments/sales-invoice-payments.module'
|
||||
import { ServiceCategoriesModule } from './modules/service-categories/service-categories.module'
|
||||
import { ServicesModule } from './modules/services/services.module'
|
||||
import { TriggerLogsModule } from './modules/trigger-logs/trigger-logs.module'
|
||||
import { UploadersModule } from './modules/uploaders/uploaders.module'
|
||||
import { PrismaModule } from './prisma/prisma.module'
|
||||
@@ -26,8 +24,6 @@ import { PrismaModule } from './prisma/prisma.module'
|
||||
AuthModule,
|
||||
SalesInvoiceItemsModule,
|
||||
SalesInvoicePaymentsModule,
|
||||
ServiceCategoriesModule,
|
||||
ServicesModule,
|
||||
TriggerLogsModule,
|
||||
UploadersModule,
|
||||
],
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
// src/common/guards/permissions.guard.ts
|
||||
import { ITokenPayload } from '@/modules/auth/auth.utils'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { ExecutionContext, ForbiddenException, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
ExecutionContext,
|
||||
ForbiddenException,
|
||||
Injectable,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common'
|
||||
import { Request as ExpressRequest } from 'express'
|
||||
|
||||
@Injectable()
|
||||
@@ -12,8 +17,12 @@ export class ConsumerGuard {
|
||||
tokenPayload: ITokenPayload,
|
||||
context: ExecutionContext,
|
||||
): Promise<boolean> {
|
||||
if (!tokenPayload || tokenPayload.type !== 'CONSUMER') {
|
||||
throw new ForbiddenException('شما دسترسی لازم را ندارید.')
|
||||
if (
|
||||
!tokenPayload ||
|
||||
tokenPayload.type !== 'CONSUMER' ||
|
||||
tokenPayload.role !== 'OWNER'
|
||||
) {
|
||||
throw new UnauthorizedException()
|
||||
}
|
||||
|
||||
const consumer = await this.prisma.consumer.findFirst({
|
||||
|
||||
@@ -62,7 +62,7 @@ export class JwtAuthGuard implements CanActivate {
|
||||
if (req.url.startsWith('/api/v1/consumer')) {
|
||||
await this.consumerGuard.canActivate(tokenPayload, context)
|
||||
} else if (req.url.startsWith('/api/v1/pos')) {
|
||||
await this.consumerGuard.canActivate(tokenPayload, context)
|
||||
// await this.consumerGuard.canActivate(tokenPayload, context)
|
||||
await this.posGuard.canActivate(tokenPayload, context)
|
||||
} else if (tokenPayload.type != 'ADMIN') {
|
||||
throw new ForbiddenException('شما دسترسی لازم را ندارید')
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -258,7 +258,7 @@ export type ConsumerAccountCreateInput = {
|
||||
consumer: Prisma.ConsumerCreateNestedOneWithoutConsumer_accountsInput
|
||||
account: Prisma.AccountCreateNestedOneWithoutConsumer_accountInput
|
||||
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutAccountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedCreateInput = {
|
||||
@@ -269,7 +269,7 @@ export type ConsumerAccountUncheckedCreateInput = {
|
||||
consumer_id: string
|
||||
account_id: string
|
||||
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutAccountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUpdateInput = {
|
||||
@@ -280,7 +280,7 @@ export type ConsumerAccountUpdateInput = {
|
||||
consumer?: Prisma.ConsumerUpdateOneRequiredWithoutConsumer_accountsNestedInput
|
||||
account?: Prisma.AccountUpdateOneRequiredWithoutConsumer_accountNestedInput
|
||||
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutAccountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedUpdateInput = {
|
||||
@@ -291,7 +291,7 @@ export type ConsumerAccountUncheckedUpdateInput = {
|
||||
consumer_id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
account_id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutAccountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountCreateManyInput = {
|
||||
@@ -485,7 +485,7 @@ export type ConsumerAccountCreateWithoutAccountInput = {
|
||||
updated_at?: Date | string
|
||||
consumer: Prisma.ConsumerCreateNestedOneWithoutConsumer_accountsInput
|
||||
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutAccountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedCreateWithoutAccountInput = {
|
||||
@@ -495,7 +495,7 @@ export type ConsumerAccountUncheckedCreateWithoutAccountInput = {
|
||||
updated_at?: Date | string
|
||||
consumer_id: string
|
||||
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutAccountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountCreateOrConnectWithoutAccountInput = {
|
||||
@@ -521,7 +521,7 @@ export type ConsumerAccountUpdateWithoutAccountInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
consumer?: Prisma.ConsumerUpdateOneRequiredWithoutConsumer_accountsNestedInput
|
||||
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutAccountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedUpdateWithoutAccountInput = {
|
||||
@@ -531,7 +531,7 @@ export type ConsumerAccountUncheckedUpdateWithoutAccountInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
consumer_id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutAccountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountCreateWithoutConsumerInput = {
|
||||
@@ -541,7 +541,7 @@ export type ConsumerAccountCreateWithoutConsumerInput = {
|
||||
updated_at?: Date | string
|
||||
account: Prisma.AccountCreateNestedOneWithoutConsumer_accountInput
|
||||
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutAccountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedCreateWithoutConsumerInput = {
|
||||
@@ -551,7 +551,7 @@ export type ConsumerAccountUncheckedCreateWithoutConsumerInput = {
|
||||
updated_at?: Date | string
|
||||
account_id: string
|
||||
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutAccountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountCreateOrConnectWithoutConsumerInput = {
|
||||
@@ -599,7 +599,7 @@ export type ConsumerAccountCreateWithoutPermissionInput = {
|
||||
updated_at?: Date | string
|
||||
consumer: Prisma.ConsumerCreateNestedOneWithoutConsumer_accountsInput
|
||||
account: Prisma.AccountCreateNestedOneWithoutConsumer_accountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutAccountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedCreateWithoutPermissionInput = {
|
||||
@@ -609,7 +609,7 @@ export type ConsumerAccountUncheckedCreateWithoutPermissionInput = {
|
||||
updated_at?: Date | string
|
||||
consumer_id: string
|
||||
account_id: string
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutAccountInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountCreateOrConnectWithoutPermissionInput = {
|
||||
@@ -635,7 +635,7 @@ export type ConsumerAccountUpdateWithoutPermissionInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
consumer?: Prisma.ConsumerUpdateOneRequiredWithoutConsumer_accountsNestedInput
|
||||
account?: Prisma.AccountUpdateOneRequiredWithoutConsumer_accountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutAccountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedUpdateWithoutPermissionInput = {
|
||||
@@ -645,7 +645,7 @@ export type ConsumerAccountUncheckedUpdateWithoutPermissionInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
consumer_id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
account_id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutAccountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountCreateWithoutSales_invoicesInput = {
|
||||
@@ -719,7 +719,7 @@ export type ConsumerAccountUpdateWithoutConsumerInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
account?: Prisma.AccountUpdateOneRequiredWithoutConsumer_accountNestedInput
|
||||
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutAccountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedUpdateWithoutConsumerInput = {
|
||||
@@ -729,7 +729,7 @@ export type ConsumerAccountUncheckedUpdateWithoutConsumerInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
account_id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutAccountNestedInput
|
||||
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
|
||||
}
|
||||
|
||||
export type ConsumerAccountUncheckedUpdateManyWithoutConsumerInput = {
|
||||
|
||||
@@ -262,7 +262,7 @@ export type SalesInvoiceWhereInput = {
|
||||
pos_id?: Prisma.StringFilter<"SalesInvoice"> | string
|
||||
customer?: Prisma.XOR<Prisma.CustomerNullableScalarRelationFilter, Prisma.CustomerWhereInput> | null
|
||||
pos?: Prisma.XOR<Prisma.PosScalarRelationFilter, Prisma.PosWhereInput>
|
||||
account?: Prisma.XOR<Prisma.ConsumerAccountScalarRelationFilter, Prisma.ConsumerAccountWhereInput>
|
||||
consumer_account?: Prisma.XOR<Prisma.ConsumerAccountScalarRelationFilter, Prisma.ConsumerAccountWhereInput>
|
||||
items?: Prisma.SalesInvoiceItemListRelationFilter
|
||||
payments?: Prisma.SalesInvoicePaymentListRelationFilter
|
||||
}
|
||||
@@ -281,7 +281,7 @@ export type SalesInvoiceOrderByWithRelationInput = {
|
||||
pos_id?: Prisma.SortOrder
|
||||
customer?: Prisma.CustomerOrderByWithRelationInput
|
||||
pos?: Prisma.PosOrderByWithRelationInput
|
||||
account?: Prisma.ConsumerAccountOrderByWithRelationInput
|
||||
consumer_account?: Prisma.ConsumerAccountOrderByWithRelationInput
|
||||
items?: Prisma.SalesInvoiceItemOrderByRelationAggregateInput
|
||||
payments?: Prisma.SalesInvoicePaymentOrderByRelationAggregateInput
|
||||
_relevance?: Prisma.SalesInvoiceOrderByRelevanceInput
|
||||
@@ -304,7 +304,7 @@ export type SalesInvoiceWhereUniqueInput = Prisma.AtLeast<{
|
||||
pos_id?: Prisma.StringFilter<"SalesInvoice"> | string
|
||||
customer?: Prisma.XOR<Prisma.CustomerNullableScalarRelationFilter, Prisma.CustomerWhereInput> | null
|
||||
pos?: Prisma.XOR<Prisma.PosScalarRelationFilter, Prisma.PosWhereInput>
|
||||
account?: Prisma.XOR<Prisma.ConsumerAccountScalarRelationFilter, Prisma.ConsumerAccountWhereInput>
|
||||
consumer_account?: Prisma.XOR<Prisma.ConsumerAccountScalarRelationFilter, Prisma.ConsumerAccountWhereInput>
|
||||
items?: Prisma.SalesInvoiceItemListRelationFilter
|
||||
payments?: Prisma.SalesInvoicePaymentListRelationFilter
|
||||
}, "id" | "code">
|
||||
@@ -356,7 +356,7 @@ export type SalesInvoiceCreateInput = {
|
||||
updated_at?: Date | string
|
||||
customer?: Prisma.CustomerCreateNestedOneWithoutSales_invoicesInput
|
||||
pos: Prisma.PosCreateNestedOneWithoutSales_invoicesInput
|
||||
account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
consumer_account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutInvoiceInput
|
||||
payments?: Prisma.SalesInvoicePaymentCreateNestedManyWithoutInvoiceInput
|
||||
}
|
||||
@@ -388,7 +388,7 @@ export type SalesInvoiceUpdateInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
customer?: Prisma.CustomerUpdateOneWithoutSales_invoicesNestedInput
|
||||
pos?: Prisma.PosUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
consumer_account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
items?: Prisma.SalesInvoiceItemUpdateManyWithoutInvoiceNestedInput
|
||||
payments?: Prisma.SalesInvoicePaymentUpdateManyWithoutInvoiceNestedInput
|
||||
}
|
||||
@@ -517,45 +517,45 @@ export type SalesInvoiceScalarRelationFilter = {
|
||||
isNot?: Prisma.SalesInvoiceWhereInput
|
||||
}
|
||||
|
||||
export type SalesInvoiceCreateNestedManyWithoutAccountInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutAccountInput, Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput> | Prisma.SalesInvoiceCreateWithoutAccountInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutAccountInput | Prisma.SalesInvoiceCreateOrConnectWithoutAccountInput[]
|
||||
createMany?: Prisma.SalesInvoiceCreateManyAccountInputEnvelope
|
||||
export type SalesInvoiceCreateNestedManyWithoutConsumer_accountInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutConsumer_accountInput, Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput> | Prisma.SalesInvoiceCreateWithoutConsumer_accountInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutConsumer_accountInput | Prisma.SalesInvoiceCreateOrConnectWithoutConsumer_accountInput[]
|
||||
createMany?: Prisma.SalesInvoiceCreateManyConsumer_accountInputEnvelope
|
||||
connect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
}
|
||||
|
||||
export type SalesInvoiceUncheckedCreateNestedManyWithoutAccountInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutAccountInput, Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput> | Prisma.SalesInvoiceCreateWithoutAccountInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutAccountInput | Prisma.SalesInvoiceCreateOrConnectWithoutAccountInput[]
|
||||
createMany?: Prisma.SalesInvoiceCreateManyAccountInputEnvelope
|
||||
export type SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutConsumer_accountInput, Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput> | Prisma.SalesInvoiceCreateWithoutConsumer_accountInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutConsumer_accountInput | Prisma.SalesInvoiceCreateOrConnectWithoutConsumer_accountInput[]
|
||||
createMany?: Prisma.SalesInvoiceCreateManyConsumer_accountInputEnvelope
|
||||
connect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
}
|
||||
|
||||
export type SalesInvoiceUpdateManyWithoutAccountNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutAccountInput, Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput> | Prisma.SalesInvoiceCreateWithoutAccountInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutAccountInput | Prisma.SalesInvoiceCreateOrConnectWithoutAccountInput[]
|
||||
upsert?: Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutAccountInput | Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutAccountInput[]
|
||||
createMany?: Prisma.SalesInvoiceCreateManyAccountInputEnvelope
|
||||
export type SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutConsumer_accountInput, Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput> | Prisma.SalesInvoiceCreateWithoutConsumer_accountInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutConsumer_accountInput | Prisma.SalesInvoiceCreateOrConnectWithoutConsumer_accountInput[]
|
||||
upsert?: Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutConsumer_accountInput | Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutConsumer_accountInput[]
|
||||
createMany?: Prisma.SalesInvoiceCreateManyConsumer_accountInputEnvelope
|
||||
set?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
disconnect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
delete?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
connect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
update?: Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutAccountInput | Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutAccountInput[]
|
||||
updateMany?: Prisma.SalesInvoiceUpdateManyWithWhereWithoutAccountInput | Prisma.SalesInvoiceUpdateManyWithWhereWithoutAccountInput[]
|
||||
update?: Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutConsumer_accountInput | Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutConsumer_accountInput[]
|
||||
updateMany?: Prisma.SalesInvoiceUpdateManyWithWhereWithoutConsumer_accountInput | Prisma.SalesInvoiceUpdateManyWithWhereWithoutConsumer_accountInput[]
|
||||
deleteMany?: Prisma.SalesInvoiceScalarWhereInput | Prisma.SalesInvoiceScalarWhereInput[]
|
||||
}
|
||||
|
||||
export type SalesInvoiceUncheckedUpdateManyWithoutAccountNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutAccountInput, Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput> | Prisma.SalesInvoiceCreateWithoutAccountInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutAccountInput | Prisma.SalesInvoiceCreateOrConnectWithoutAccountInput[]
|
||||
upsert?: Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutAccountInput | Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutAccountInput[]
|
||||
createMany?: Prisma.SalesInvoiceCreateManyAccountInputEnvelope
|
||||
export type SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutConsumer_accountInput, Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput> | Prisma.SalesInvoiceCreateWithoutConsumer_accountInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutConsumer_accountInput | Prisma.SalesInvoiceCreateOrConnectWithoutConsumer_accountInput[]
|
||||
upsert?: Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutConsumer_accountInput | Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutConsumer_accountInput[]
|
||||
createMany?: Prisma.SalesInvoiceCreateManyConsumer_accountInputEnvelope
|
||||
set?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
disconnect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
delete?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
connect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[]
|
||||
update?: Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutAccountInput | Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutAccountInput[]
|
||||
updateMany?: Prisma.SalesInvoiceUpdateManyWithWhereWithoutAccountInput | Prisma.SalesInvoiceUpdateManyWithWhereWithoutAccountInput[]
|
||||
update?: Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutConsumer_accountInput | Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutConsumer_accountInput[]
|
||||
updateMany?: Prisma.SalesInvoiceUpdateManyWithWhereWithoutConsumer_accountInput | Prisma.SalesInvoiceUpdateManyWithWhereWithoutConsumer_accountInput[]
|
||||
deleteMany?: Prisma.SalesInvoiceScalarWhereInput | Prisma.SalesInvoiceScalarWhereInput[]
|
||||
}
|
||||
|
||||
@@ -679,7 +679,7 @@ export type SalesInvoiceUpdateOneRequiredWithoutPaymentsNestedInput = {
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.SalesInvoiceUpdateToOneWithWhereWithoutPaymentsInput, Prisma.SalesInvoiceUpdateWithoutPaymentsInput>, Prisma.SalesInvoiceUncheckedUpdateWithoutPaymentsInput>
|
||||
}
|
||||
|
||||
export type SalesInvoiceCreateWithoutAccountInput = {
|
||||
export type SalesInvoiceCreateWithoutConsumer_accountInput = {
|
||||
id?: string
|
||||
code: string
|
||||
total_amount: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
@@ -694,7 +694,7 @@ export type SalesInvoiceCreateWithoutAccountInput = {
|
||||
payments?: Prisma.SalesInvoicePaymentCreateNestedManyWithoutInvoiceInput
|
||||
}
|
||||
|
||||
export type SalesInvoiceUncheckedCreateWithoutAccountInput = {
|
||||
export type SalesInvoiceUncheckedCreateWithoutConsumer_accountInput = {
|
||||
id?: string
|
||||
code: string
|
||||
total_amount: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
@@ -709,30 +709,30 @@ export type SalesInvoiceUncheckedCreateWithoutAccountInput = {
|
||||
payments?: Prisma.SalesInvoicePaymentUncheckedCreateNestedManyWithoutInvoiceInput
|
||||
}
|
||||
|
||||
export type SalesInvoiceCreateOrConnectWithoutAccountInput = {
|
||||
export type SalesInvoiceCreateOrConnectWithoutConsumer_accountInput = {
|
||||
where: Prisma.SalesInvoiceWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutAccountInput, Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput>
|
||||
create: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutConsumer_accountInput, Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput>
|
||||
}
|
||||
|
||||
export type SalesInvoiceCreateManyAccountInputEnvelope = {
|
||||
data: Prisma.SalesInvoiceCreateManyAccountInput | Prisma.SalesInvoiceCreateManyAccountInput[]
|
||||
export type SalesInvoiceCreateManyConsumer_accountInputEnvelope = {
|
||||
data: Prisma.SalesInvoiceCreateManyConsumer_accountInput | Prisma.SalesInvoiceCreateManyConsumer_accountInput[]
|
||||
skipDuplicates?: boolean
|
||||
}
|
||||
|
||||
export type SalesInvoiceUpsertWithWhereUniqueWithoutAccountInput = {
|
||||
export type SalesInvoiceUpsertWithWhereUniqueWithoutConsumer_accountInput = {
|
||||
where: Prisma.SalesInvoiceWhereUniqueInput
|
||||
update: Prisma.XOR<Prisma.SalesInvoiceUpdateWithoutAccountInput, Prisma.SalesInvoiceUncheckedUpdateWithoutAccountInput>
|
||||
create: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutAccountInput, Prisma.SalesInvoiceUncheckedCreateWithoutAccountInput>
|
||||
update: Prisma.XOR<Prisma.SalesInvoiceUpdateWithoutConsumer_accountInput, Prisma.SalesInvoiceUncheckedUpdateWithoutConsumer_accountInput>
|
||||
create: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutConsumer_accountInput, Prisma.SalesInvoiceUncheckedCreateWithoutConsumer_accountInput>
|
||||
}
|
||||
|
||||
export type SalesInvoiceUpdateWithWhereUniqueWithoutAccountInput = {
|
||||
export type SalesInvoiceUpdateWithWhereUniqueWithoutConsumer_accountInput = {
|
||||
where: Prisma.SalesInvoiceWhereUniqueInput
|
||||
data: Prisma.XOR<Prisma.SalesInvoiceUpdateWithoutAccountInput, Prisma.SalesInvoiceUncheckedUpdateWithoutAccountInput>
|
||||
data: Prisma.XOR<Prisma.SalesInvoiceUpdateWithoutConsumer_accountInput, Prisma.SalesInvoiceUncheckedUpdateWithoutConsumer_accountInput>
|
||||
}
|
||||
|
||||
export type SalesInvoiceUpdateManyWithWhereWithoutAccountInput = {
|
||||
export type SalesInvoiceUpdateManyWithWhereWithoutConsumer_accountInput = {
|
||||
where: Prisma.SalesInvoiceScalarWhereInput
|
||||
data: Prisma.XOR<Prisma.SalesInvoiceUpdateManyMutationInput, Prisma.SalesInvoiceUncheckedUpdateManyWithoutAccountInput>
|
||||
data: Prisma.XOR<Prisma.SalesInvoiceUpdateManyMutationInput, Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountInput>
|
||||
}
|
||||
|
||||
export type SalesInvoiceScalarWhereInput = {
|
||||
@@ -762,7 +762,7 @@ export type SalesInvoiceCreateWithoutPosInput = {
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
customer?: Prisma.CustomerCreateNestedOneWithoutSales_invoicesInput
|
||||
account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
consumer_account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutInvoiceInput
|
||||
payments?: Prisma.SalesInvoicePaymentCreateNestedManyWithoutInvoiceInput
|
||||
}
|
||||
@@ -818,7 +818,7 @@ export type SalesInvoiceCreateWithoutCustomerInput = {
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
pos: Prisma.PosCreateNestedOneWithoutSales_invoicesInput
|
||||
account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
consumer_account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutInvoiceInput
|
||||
payments?: Prisma.SalesInvoicePaymentCreateNestedManyWithoutInvoiceInput
|
||||
}
|
||||
@@ -875,7 +875,7 @@ export type SalesInvoiceCreateWithoutItemsInput = {
|
||||
updated_at?: Date | string
|
||||
customer?: Prisma.CustomerCreateNestedOneWithoutSales_invoicesInput
|
||||
pos: Prisma.PosCreateNestedOneWithoutSales_invoicesInput
|
||||
account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
consumer_account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
payments?: Prisma.SalesInvoicePaymentCreateNestedManyWithoutInvoiceInput
|
||||
}
|
||||
|
||||
@@ -921,7 +921,7 @@ export type SalesInvoiceUpdateWithoutItemsInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
customer?: Prisma.CustomerUpdateOneWithoutSales_invoicesNestedInput
|
||||
pos?: Prisma.PosUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
consumer_account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
payments?: Prisma.SalesInvoicePaymentUpdateManyWithoutInvoiceNestedInput
|
||||
}
|
||||
|
||||
@@ -951,7 +951,7 @@ export type SalesInvoiceCreateWithoutPaymentsInput = {
|
||||
updated_at?: Date | string
|
||||
customer?: Prisma.CustomerCreateNestedOneWithoutSales_invoicesInput
|
||||
pos: Prisma.PosCreateNestedOneWithoutSales_invoicesInput
|
||||
account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
consumer_account: Prisma.ConsumerAccountCreateNestedOneWithoutSales_invoicesInput
|
||||
items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutInvoiceInput
|
||||
}
|
||||
|
||||
@@ -997,7 +997,7 @@ export type SalesInvoiceUpdateWithoutPaymentsInput = {
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
customer?: Prisma.CustomerUpdateOneWithoutSales_invoicesNestedInput
|
||||
pos?: Prisma.PosUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
consumer_account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
items?: Prisma.SalesInvoiceItemUpdateManyWithoutInvoiceNestedInput
|
||||
}
|
||||
|
||||
@@ -1016,7 +1016,7 @@ export type SalesInvoiceUncheckedUpdateWithoutPaymentsInput = {
|
||||
items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutInvoiceNestedInput
|
||||
}
|
||||
|
||||
export type SalesInvoiceCreateManyAccountInput = {
|
||||
export type SalesInvoiceCreateManyConsumer_accountInput = {
|
||||
id?: string
|
||||
code: string
|
||||
total_amount: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
@@ -1029,7 +1029,7 @@ export type SalesInvoiceCreateManyAccountInput = {
|
||||
pos_id: string
|
||||
}
|
||||
|
||||
export type SalesInvoiceUpdateWithoutAccountInput = {
|
||||
export type SalesInvoiceUpdateWithoutConsumer_accountInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
total_amount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
@@ -1044,7 +1044,7 @@ export type SalesInvoiceUpdateWithoutAccountInput = {
|
||||
payments?: Prisma.SalesInvoicePaymentUpdateManyWithoutInvoiceNestedInput
|
||||
}
|
||||
|
||||
export type SalesInvoiceUncheckedUpdateWithoutAccountInput = {
|
||||
export type SalesInvoiceUncheckedUpdateWithoutConsumer_accountInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
total_amount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
@@ -1059,7 +1059,7 @@ export type SalesInvoiceUncheckedUpdateWithoutAccountInput = {
|
||||
payments?: Prisma.SalesInvoicePaymentUncheckedUpdateManyWithoutInvoiceNestedInput
|
||||
}
|
||||
|
||||
export type SalesInvoiceUncheckedUpdateManyWithoutAccountInput = {
|
||||
export type SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
total_amount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
@@ -1095,7 +1095,7 @@ export type SalesInvoiceUpdateWithoutPosInput = {
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
customer?: Prisma.CustomerUpdateOneWithoutSales_invoicesNestedInput
|
||||
account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
consumer_account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
items?: Prisma.SalesInvoiceItemUpdateManyWithoutInvoiceNestedInput
|
||||
payments?: Prisma.SalesInvoicePaymentUpdateManyWithoutInvoiceNestedInput
|
||||
}
|
||||
@@ -1151,7 +1151,7 @@ export type SalesInvoiceUpdateWithoutCustomerInput = {
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
pos?: Prisma.PosUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
consumer_account?: Prisma.ConsumerAccountUpdateOneRequiredWithoutSales_invoicesNestedInput
|
||||
items?: Prisma.SalesInvoiceItemUpdateManyWithoutInvoiceNestedInput
|
||||
payments?: Prisma.SalesInvoicePaymentUpdateManyWithoutInvoiceNestedInput
|
||||
}
|
||||
@@ -1238,7 +1238,7 @@ export type SalesInvoiceSelect<ExtArgs extends runtime.Types.Extensions.Internal
|
||||
pos_id?: boolean
|
||||
customer?: boolean | Prisma.SalesInvoice$customerArgs<ExtArgs>
|
||||
pos?: boolean | Prisma.PosDefaultArgs<ExtArgs>
|
||||
account?: boolean | Prisma.ConsumerAccountDefaultArgs<ExtArgs>
|
||||
consumer_account?: boolean | Prisma.ConsumerAccountDefaultArgs<ExtArgs>
|
||||
items?: boolean | Prisma.SalesInvoice$itemsArgs<ExtArgs>
|
||||
payments?: boolean | Prisma.SalesInvoice$paymentsArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.SalesInvoiceCountOutputTypeDefaultArgs<ExtArgs>
|
||||
@@ -1264,7 +1264,7 @@ export type SalesInvoiceOmit<ExtArgs extends runtime.Types.Extensions.InternalAr
|
||||
export type SalesInvoiceInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
customer?: boolean | Prisma.SalesInvoice$customerArgs<ExtArgs>
|
||||
pos?: boolean | Prisma.PosDefaultArgs<ExtArgs>
|
||||
account?: boolean | Prisma.ConsumerAccountDefaultArgs<ExtArgs>
|
||||
consumer_account?: boolean | Prisma.ConsumerAccountDefaultArgs<ExtArgs>
|
||||
items?: boolean | Prisma.SalesInvoice$itemsArgs<ExtArgs>
|
||||
payments?: boolean | Prisma.SalesInvoice$paymentsArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.SalesInvoiceCountOutputTypeDefaultArgs<ExtArgs>
|
||||
@@ -1275,7 +1275,7 @@ export type $SalesInvoicePayload<ExtArgs extends runtime.Types.Extensions.Intern
|
||||
objects: {
|
||||
customer: Prisma.$CustomerPayload<ExtArgs> | null
|
||||
pos: Prisma.$PosPayload<ExtArgs>
|
||||
account: Prisma.$ConsumerAccountPayload<ExtArgs>
|
||||
consumer_account: Prisma.$ConsumerAccountPayload<ExtArgs>
|
||||
items: Prisma.$SalesInvoiceItemPayload<ExtArgs>[]
|
||||
payments: Prisma.$SalesInvoicePaymentPayload<ExtArgs>[]
|
||||
}
|
||||
@@ -1633,7 +1633,7 @@ export interface Prisma__SalesInvoiceClient<T, Null = never, ExtArgs extends run
|
||||
readonly [Symbol.toStringTag]: "PrismaPromise"
|
||||
customer<T extends Prisma.SalesInvoice$customerArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.SalesInvoice$customerArgs<ExtArgs>>): Prisma.Prisma__CustomerClient<runtime.Types.Result.GetResult<Prisma.$CustomerPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
pos<T extends Prisma.PosDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.PosDefaultArgs<ExtArgs>>): Prisma.Prisma__PosClient<runtime.Types.Result.GetResult<Prisma.$PosPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions>
|
||||
account<T extends Prisma.ConsumerAccountDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccountDefaultArgs<ExtArgs>>): Prisma.Prisma__ConsumerAccountClient<runtime.Types.Result.GetResult<Prisma.$ConsumerAccountPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions>
|
||||
consumer_account<T extends Prisma.ConsumerAccountDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccountDefaultArgs<ExtArgs>>): Prisma.Prisma__ConsumerAccountClient<runtime.Types.Result.GetResult<Prisma.$ConsumerAccountPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions>
|
||||
items<T extends Prisma.SalesInvoice$itemsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.SalesInvoice$itemsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SalesInvoiceItemPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
payments<T extends Prisma.SalesInvoice$paymentsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.SalesInvoice$paymentsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SalesInvoicePaymentPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
/**
|
||||
|
||||
@@ -75,6 +75,12 @@ export class LicensesService {
|
||||
id: partner_id,
|
||||
},
|
||||
}
|
||||
} else if (currentLicense?.partner_id) {
|
||||
dataToUpdate.partner = {
|
||||
disconnect: {
|
||||
id: currentLicense?.partner_id,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if (starts_at) {
|
||||
|
||||
@@ -18,7 +18,7 @@ export class AuthController {
|
||||
if (result?.data?.accessToken) {
|
||||
// @ts-ignore
|
||||
res.cookie('accessToken', result.data.accessToken, {
|
||||
httpOnly: true,
|
||||
httpOnly: false,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
sameSite: 'lax',
|
||||
maxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
|
||||
@@ -34,7 +34,7 @@ export class AuthController {
|
||||
if (result?.data?.accessToken) {
|
||||
// @ts-ignore
|
||||
res.cookie('accessToken', result.data.accessToken, {
|
||||
httpOnly: true,
|
||||
httpOnly: false,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
sameSite: 'lax',
|
||||
maxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { checkAndDecodeJwtToken } from '@/common/utils/jwt-user.util'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { ForbiddenException, Injectable, NestMiddleware } from '@nestjs/common'
|
||||
import {
|
||||
ForbiddenException,
|
||||
Injectable,
|
||||
NestMiddleware,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
|
||||
@@ -22,7 +27,7 @@ export class ConsumerMiddleware implements NestMiddleware {
|
||||
tokenAccount?.type !== 'CONSUMER' ||
|
||||
!(tokenAccount.role === 'OWNER' || tokenAccount.role === 'MANAGER')
|
||||
) {
|
||||
return doForbidden()
|
||||
throw new UnauthorizedException()
|
||||
}
|
||||
|
||||
const consumerAccount = await this.prisma.consumerAccount.findUnique({
|
||||
@@ -43,10 +48,15 @@ export class ConsumerMiddleware implements NestMiddleware {
|
||||
account_id: consumerAccount.id,
|
||||
id: consumerAccount.consumer_id,
|
||||
}
|
||||
console.log(consumerAccount)
|
||||
|
||||
req.decodedToken = tokenAccount
|
||||
|
||||
return next()
|
||||
} catch (error) {
|
||||
if (error && typeof error === 'object') {
|
||||
throw error
|
||||
}
|
||||
return doForbidden()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ConsumerController } from './consumer.controller'
|
||||
import { ConsumerMiddleware } from './consumer.middleware'
|
||||
import { ConsumerService } from './consumer.service'
|
||||
import { ConsumerCustomersModule } from './customers/customers.module'
|
||||
import { ConsumerStatisticsModule } from './statistics/statistics.module'
|
||||
|
||||
@Module({
|
||||
controllers: [ConsumerController],
|
||||
@@ -13,6 +14,7 @@ import { ConsumerCustomersModule } from './customers/customers.module'
|
||||
ConsumerAccountsModule,
|
||||
ConsumerBusinessActivitiesModule,
|
||||
ConsumerCustomersModule,
|
||||
ConsumerStatisticsModule,
|
||||
],
|
||||
providers: [JwtService, ConsumerService],
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ export class ConsumerService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async getInfo(consumer_id: string) {
|
||||
const consumer = await this.prisma.consumer.findUnique({
|
||||
const consumer = await this.prisma.consumer.findUniqueOrThrow({
|
||||
where: {
|
||||
id: consumer_id,
|
||||
},
|
||||
|
||||
@@ -31,7 +31,7 @@ export class CustomerSaleInvoicesService {
|
||||
},
|
||||
},
|
||||
},
|
||||
account: {
|
||||
consumer_account: {
|
||||
select: {
|
||||
role: true,
|
||||
consumer: {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
||||
import { Controller, Get } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { SaleInvoicesService } from './saleInvoices.service'
|
||||
|
||||
@ApiTags('ConsumerStatistics')
|
||||
@Controller('consumer/statistics')
|
||||
export class StatisticsController {
|
||||
constructor(private readonly service: SaleInvoicesService) {}
|
||||
|
||||
@Get('invoices')
|
||||
async getInvoices(@TokenAccount('userId') consumerId: string) {
|
||||
return this.service.getInvoices(consumerId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { PrismaModule } from '@/prisma/prisma.module'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { StatisticsController } from './saleInvoices.controller'
|
||||
import { SaleInvoicesService } from './saleInvoices.service'
|
||||
|
||||
@Module({
|
||||
imports: [PrismaModule],
|
||||
controllers: [StatisticsController],
|
||||
providers: [SaleInvoicesService],
|
||||
exports: [SaleInvoicesService],
|
||||
})
|
||||
export class ConsumerSaleInvoicesModule {}
|
||||
@@ -0,0 +1,113 @@
|
||||
import {
|
||||
SalesInvoiceWhereInput,
|
||||
SalesInvoiceWhereUniqueInput,
|
||||
} from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
|
||||
@Injectable()
|
||||
export class SaleInvoicesService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
private readonly defaultSelect = {
|
||||
id: true,
|
||||
code: true,
|
||||
total_amount: true,
|
||||
unknown_customer: true,
|
||||
invoice_date: true,
|
||||
consumer_account: {
|
||||
select: {
|
||||
role: true,
|
||||
account: {
|
||||
select: {
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
pos: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
complex: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
business_activity: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
customer: {
|
||||
select: {
|
||||
id: true,
|
||||
type: true,
|
||||
customer_legal: {
|
||||
select: {
|
||||
company_name: true,
|
||||
},
|
||||
},
|
||||
customer_individual: {
|
||||
select: {
|
||||
first_name: true,
|
||||
last_name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
async getInvoices(consumer_id: string, page = 1, pageSize = 10) {
|
||||
const invoicesWhere: SalesInvoiceWhereInput = {
|
||||
consumer_account: {
|
||||
consumer_id,
|
||||
},
|
||||
}
|
||||
const [invoices, count] = await this.prisma.$transaction(async tx => [
|
||||
await tx.salesInvoice.findMany({
|
||||
where: invoicesWhere,
|
||||
select: this.defaultSelect,
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
}),
|
||||
await tx.salesInvoice.count({ where: invoicesWhere }),
|
||||
])
|
||||
return ResponseMapper.paginate(invoices, { page, pageSize, count })
|
||||
}
|
||||
|
||||
async getInvoice(consumer_id: string, id: string) {
|
||||
const invoicesWhere: SalesInvoiceWhereUniqueInput = {
|
||||
id,
|
||||
consumer_account: {
|
||||
consumer_id,
|
||||
},
|
||||
}
|
||||
const invoice = await this.prisma.salesInvoice.findUniqueOrThrow({
|
||||
where: invoicesWhere,
|
||||
select: {
|
||||
...this.defaultSelect,
|
||||
notes: true,
|
||||
created_at: true,
|
||||
items: {
|
||||
select: {
|
||||
id: true,
|
||||
good: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
return ResponseMapper.single(invoice)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
||||
import { Controller, Get } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { StatisticsService } from './statistics.service'
|
||||
|
||||
@ApiTags('ConsumerStatistics')
|
||||
@Controller('consumer/statistics')
|
||||
export class StatisticsController {
|
||||
constructor(private readonly service: StatisticsService) {}
|
||||
|
||||
@Get('invoices')
|
||||
async getInvoices(@TokenAccount('userId') consumerId: string) {
|
||||
return this.service.getInvoices(consumerId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { PrismaModule } from '@/prisma/prisma.module'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { StatisticsController } from './statistics.controller'
|
||||
import { StatisticsService } from './statistics.service'
|
||||
|
||||
@Module({
|
||||
imports: [PrismaModule],
|
||||
controllers: [StatisticsController],
|
||||
providers: [StatisticsService],
|
||||
exports: [StatisticsService],
|
||||
})
|
||||
export class ConsumerStatisticsModule {}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
|
||||
@Injectable()
|
||||
export class StatisticsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async getInvoices(consumer_id: string) {
|
||||
const startOfToday = new Date()
|
||||
startOfToday.setHours(0, 0, 0, 0)
|
||||
|
||||
const invoices = await this.prisma.salesInvoice.findMany({
|
||||
where: {
|
||||
consumer_account: {
|
||||
consumer_id,
|
||||
},
|
||||
created_at: {
|
||||
gte: startOfToday,
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
total_amount: true,
|
||||
created_at: true,
|
||||
consumer_account: {
|
||||
select: {
|
||||
role: true,
|
||||
account: {
|
||||
select: {
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
pos: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
complex: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
business_activity: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
return ResponseMapper.list(invoices)
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,13 @@ export class PosController {
|
||||
async getInfo(@PosInfo('pos_id') pos_id: string, @Res({ passthrough: true }) res) {
|
||||
const result = await this.service.getInfo(pos_id)
|
||||
|
||||
console.log('firstaaaaa')
|
||||
if (result) {
|
||||
console.log('first')
|
||||
|
||||
// @ts-ignore
|
||||
res.cookie('posId', pos_id, {
|
||||
httpOnly: true,
|
||||
httpOnly: false,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
sameSite: 'lax',
|
||||
maxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
|
||||
|
||||
@@ -4,8 +4,8 @@ import { PrismaService } from '@/prisma/prisma.service'
|
||||
import {
|
||||
ForbiddenException,
|
||||
Injectable,
|
||||
MisdirectedException,
|
||||
NestMiddleware,
|
||||
PreconditionFailedException,
|
||||
} from '@nestjs/common'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
@@ -32,6 +32,11 @@ export class PosMiddleware implements NestMiddleware {
|
||||
return doForbidden()
|
||||
}
|
||||
|
||||
if (req.url.startsWith('/api/v1/pos/accessible')) {
|
||||
req.decodedToken = tokenAccount!
|
||||
return next()
|
||||
}
|
||||
|
||||
if (!posId || typeof posId !== 'string') {
|
||||
const pos = await this.prisma.pos.findMany({
|
||||
where: {
|
||||
@@ -46,6 +51,13 @@ export class PosMiddleware implements NestMiddleware {
|
||||
},
|
||||
},
|
||||
},
|
||||
permission_pos: {
|
||||
some: {
|
||||
permission: {
|
||||
consumer_account_id: account_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -54,7 +66,8 @@ export class PosMiddleware implements NestMiddleware {
|
||||
}
|
||||
if (pos.length === 1) {
|
||||
posId = pos[0].id
|
||||
} else throw new MisdirectedException()
|
||||
} else
|
||||
throw new PreconditionFailedException('پایانهی مورد نظر خود را انتخاب کنید.')
|
||||
}
|
||||
|
||||
const pos = await this.prisma.pos.findUnique({
|
||||
|
||||
@@ -68,6 +68,29 @@ export class PosService {
|
||||
},
|
||||
},
|
||||
},
|
||||
permission_pos: {
|
||||
some: {
|
||||
permission: {
|
||||
consumer_account_id: account_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
complex: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
business_activity: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ export class SalesInvoicesService {
|
||||
// id: newCustomerId || undefined,
|
||||
// },
|
||||
// },
|
||||
account: {
|
||||
consumer_account: {
|
||||
connect: {
|
||||
id: consumer_account_id,
|
||||
},
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsOptional, IsString } from 'class-validator'
|
||||
|
||||
export class CreateServiceCategoryDto {
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
name: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({ required: false })
|
||||
description?: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({ required: false })
|
||||
imageUrl?: string
|
||||
}
|
||||
|
||||
export class UpdateServiceCategoryDto extends PartialType(CreateServiceCategoryDto) {}
|
||||
@@ -1,22 +0,0 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common'
|
||||
import { ServiceCategoriesService } from './service-categories.service'
|
||||
|
||||
@Controller('service_categories')
|
||||
export class ServiceCategoriesController {
|
||||
constructor(private readonly serviceCategoriesService: ServiceCategoriesService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.serviceCategoriesService.findAll()
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.serviceCategoriesService.findOne(+id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() data: any) {
|
||||
return this.serviceCategoriesService.create(data)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { ServiceCategoriesController } from './service-categories.controller'
|
||||
import { ServiceCategoriesService } from './service-categories.service'
|
||||
|
||||
@Module({
|
||||
controllers: [ServiceCategoriesController],
|
||||
providers: [ServiceCategoriesService],
|
||||
})
|
||||
export class ServiceCategoriesModule {}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
|
||||
@Injectable()
|
||||
export class ServiceCategoriesService {
|
||||
findAll() {
|
||||
// TODO: Implement fetching all service categories
|
||||
return []
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
// TODO: Implement fetching a single service category
|
||||
return {}
|
||||
}
|
||||
|
||||
create(data: any) {
|
||||
// TODO: Implement service category creation
|
||||
return data
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsNumber, IsOptional, IsString } from 'class-validator'
|
||||
|
||||
export class CreateServiceDto {
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
name: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({ required: false })
|
||||
description?: string
|
||||
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
sku: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({ required: false })
|
||||
barcode?: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({ required: false })
|
||||
categoryId?: string
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiProperty({ required: false })
|
||||
baseSalePrice?: number
|
||||
}
|
||||
|
||||
export class UpdateServiceDto extends PartialType(CreateServiceDto) {}
|
||||
@@ -1,22 +0,0 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common'
|
||||
import { ServicesService } from './services.service'
|
||||
|
||||
@Controller('services')
|
||||
export class ServicesController {
|
||||
constructor(private readonly servicesService: ServicesService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.servicesService.findAll()
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.servicesService.findOne(+id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() data: any) {
|
||||
return this.servicesService.create(data)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { ServicesController } from './services.controller'
|
||||
import { ServicesService } from './services.service'
|
||||
|
||||
@Module({
|
||||
controllers: [ServicesController],
|
||||
providers: [ServicesService],
|
||||
})
|
||||
export class ServicesModule {}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
|
||||
@Injectable()
|
||||
export class ServicesService {
|
||||
findAll() {
|
||||
// TODO: Implement fetching all services
|
||||
return []
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
// TODO: Implement fetching a single service
|
||||
return {}
|
||||
}
|
||||
|
||||
create(data: any) {
|
||||
// TODO: Implement service creation
|
||||
return data
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user