Untitled

 avatar
unknown
plain_text
3 years ago
833 B
4
Indexable
    const totalAmountReservations = (
      await this.prisma.reservation.findMany({
        where: {
          status: ReservationStatus.CONFIRMED
        },
        include: {
          roomReserved: {
            select: {
              room: {
                select: {
                  id: true,
                  roomType: {
                    select: {
                      price: true
                    }
                  }
                }
              }
            }
          }
        }
      })
    ).reduce(
      (acc, item) =>
        acc +
        item.roomReserved[0].room.roomType.price *
          item.roomReserved.length *
          Math.floor(
            (item.checkOut.getTime() - item.checkIn.getTime()) /
              (1000 * 3600 * 24)
          ),
      0
    );
Editor is loading...