expose workshop metric
This commit is contained in:
@@ -94,10 +94,10 @@ export class CronService {
|
|||||||
@Cron(CronExpression.EVERY_MINUTE)
|
@Cron(CronExpression.EVERY_MINUTE)
|
||||||
async handleRefundTicket() {
|
async handleRefundTicket() {
|
||||||
Logger.log('Handling refund ticket', 'handleRefundTicket')
|
Logger.log('Handling refund ticket', 'handleRefundTicket')
|
||||||
// get all orders where status is PENDING_REFUND or REFUNDED and has schedule.dates in future
|
// get all orders where status is REFUNDED and has schedule.dates in future
|
||||||
const orders = await this.prisma.order.findMany({
|
const orders = await this.prisma.order.findMany({
|
||||||
where: {
|
where: {
|
||||||
status: { in: [OrderStatus.PENDING_REFUND, OrderStatus.REFUNDED] },
|
status: OrderStatus.REFUNDED,
|
||||||
schedule: {
|
schedule: {
|
||||||
dates: {
|
dates: {
|
||||||
some: {
|
some: {
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ export class RefundTicketSchema extends PothosSchema {
|
|||||||
let refundAmount = 0
|
let refundAmount = 0
|
||||||
if (diffDays < 24) refundAmount = order.total
|
if (diffDays < 24) refundAmount = order.total
|
||||||
else if (diffDays < 48) refundAmount = order.total * 0.5
|
else if (diffDays < 48) refundAmount = order.total * 0.5
|
||||||
|
if (refundAmount === 0) throw new Error('Cannot refund after 72 hours')
|
||||||
// create refund ticket
|
// create refund ticket
|
||||||
const refundTicket = await this.prisma.refundTicket.create({
|
const refundTicket = await this.prisma.refundTicket.create({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -35,6 +35,18 @@ export class WorkshopSchema extends PothosSchema {
|
|||||||
serviceId: t.exposeID('serviceId', {
|
serviceId: t.exposeID('serviceId', {
|
||||||
description: 'The ID of the service that the workshop is for.',
|
description: 'The ID of the service that the workshop is for.',
|
||||||
}),
|
}),
|
||||||
|
expectedParticipants: t.exposeInt('expectedParticipants', {
|
||||||
|
description: 'The expected number of participants for the workshop.',
|
||||||
|
}),
|
||||||
|
minParticipants: t.exposeInt('minParticipants', {
|
||||||
|
description: 'The minimum number of participants for the workshop.',
|
||||||
|
}),
|
||||||
|
registeredParticipants: t.exposeInt('registeredParticipants', {
|
||||||
|
description: 'The number of participants registered for the workshop.',
|
||||||
|
}),
|
||||||
|
actualParticipants: t.exposeInt('actualParticipants', {
|
||||||
|
description: 'The number of participants actually attending the workshop.',
|
||||||
|
}),
|
||||||
imageFile: t.relation('imageFile', {
|
imageFile: t.relation('imageFile', {
|
||||||
nullable: true,
|
nullable: true,
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user