import { Field, Float, Int, ObjectType } from '@nestjs/graphql';
import { Interval } from 'date-fns';
import { IntervalObjectType } from 'src/core/base/interval.object-type';

@ObjectType('KPI')
export class KPIObjectType {
  @Field(() => Float)
  value: number;
  @Field(() => KPIMetadataObjectType)
  meta: {
    tourAmount: number;
    availableTime: number;
    baseValue: number;
    breakEven: number;
  };
}

@ObjectType('KPIByCar')
export class KPIByCarObjectType {
  @Field()
  carName: string;
  @Field(() => KPIObjectType)
  kpi: KPIObjectType;
}

@ObjectType('TimePerTourKPISummary')
export class TimePerTourKPISummaryObjectType {
  @Field(() => IntervalObjectType)
  interval: Interval;
  @Field(() => KPIObjectType)
  kpi: KPIObjectType;
  @Field(() => [KPIByCarObjectType])
  cars: KPIByCarObjectType[];
}

@ObjectType('KPIMetadata')
export class KPIMetadataObjectType {
  @Field(() => Float)
  tourAmount: number;
  @Field(() => Float)
  availableTime: number;
  @Field(() => Float)
  baseValue: number;
  @Field(() => Float)
  breakEven: number;
}

@ObjectType('TimePerTourUpdate')
export class TimePerTourUpdateObjectType {
  @Field()
  job: string;
}

@ObjectType('TimePerTourMetric')
export class TimePerTourMetricObjectType {
  @Field(() => IntervalObjectType)
  interval: Interval;
  @Field(() => Float)
  availableTime: number;
  @Field(() => Float)
  tourAmount: number;
  @Field(() => Float)
  breakEven: number;
  @Field(() => Float)
  revenue: number;
  @Field(() => Float)
  averageRevenue: number;
  @Field(() => Float)
  personnelCost: number;
  @Field(() => Float)
  consumptionCost: number;
  @Field(() => Float)
  forecast: number;
  @Field(() => Float)
  forecastRevenue: number;
  @Field(() => [TimePerTourMetricCategoryAmountObjectType])
  categoryAmounts: TimePerTourMetricCategoryAmountObjectType[];
}

@ObjectType('TimePerTourMetricCategoryAmount')
export class TimePerTourMetricCategoryAmountObjectType {
  @Field()
  category: string;
  @Field(() => Int)
  amount: number;
}
