import { CiecaPfl } from "../decoder/decode-pfl.interface";
import { DecodedPfmLine } from "../decoder/decode-pfm.interface";
import { DecodedPfpLine } from "../decoder/decode-pfp.interface";
import { DecodedStlLine } from "../decoder/decode-stl.interface";
import { DecodedTtlLine } from "../decoder/decode-ttl.interface";

export interface TaxRate {
  prt_type: string;
  prt_discp: number;
  prt_mktyp: boolean;
  prt_mkupp: number;
  prt_tax_in: boolean;
  prt_tax_rt: number;
}

export interface BillTaxRates {
  local_tax_rate: number;
  state_tax_rate: number;
  federal_tax_rate: number;
}

export interface PaintCodes {
  paint_cd1: string | null;
  paint_cd2: string | null;
  paint_cd3: string | null;
}

export interface AreaOfDamage {
  impact1: string;
  impact2: string | null;
}

// Jobline export interface
export interface Jobline {
  tran_code: string;
  act_price: number;
  db_ref: string;
  db_price: number;
  db_hrs: number;
  glass_flag: boolean;
  id: string;
  lbr_amt: number;
  lbr_hrs_j: boolean;
  lbr_inc: boolean;
  lbr_op: string;
  lbr_op_j: boolean;
  lbr_tax: boolean;
  lbr_typ_j: boolean;
  line_desc: string;
  line_ind: string;
  line_no: number;
  line_ref: number;
  location: string | null;
  misc_amt: number;
  misc_sublt: boolean;
  misc_tax: boolean;
  mod_lb_hrs: number;
  mod_lbr_ty: string;
  oem_partno: string;
  op_code_desc: string;
  paint_stg: number;
  paint_tone: number;
  part_qty: number;
  part_type: string;
  price_inc: boolean;
  price_j: boolean;
  prt_dsmk_m: number;
  prt_dsmk_p: number;
  tax_part: boolean;
  unq_seq: number;
  alt_co_id: string | null;
  alt_overrd: boolean;
  alt_part_i: boolean;
  alt_partm: string | null;
  alt_partno: string | null;
  bett_amt: number;
  bett_pctg: number;
  bett_tax: boolean;
  bett_type: string | null;
  cert_part: boolean;
  est_seq: string | null;
}

// Parts Order Line export interface
export interface PartsOrderLine {
  jobline: Jobline;
  act_price: number;
  id: string;
  db_price: number;
  line_desc: string;
  quantity: number;
  part_type: string;
  priceChange: boolean;
}

// Vehicle export interface
export interface Vehicle {
  v_bstyle: string;
  v_type: string;
  v_trimcode: string | null;
  v_tone: string;
  v_stage: string;
  v_prod_dt: string | null;
  v_options: string | null;
  v_paint_codes: PaintCodes;
  v_model_yr: string;
  v_model_desc: string;
  v_mldgcode: string | null;
  v_makecode: string;
  v_make_desc: string;
  v_engine: string;
  v_cond: string;
  v_color: string | null;
  trim_color: string | null;
  shopid: string;
  plate_no: string;
  plate_st: string;
  db_v_code: string;
  v_vin: string;
}

// Bodyshop export interface
export interface Bodyshop {
  shopname: string;
  bill_tax_rates: BillTaxRates;
}

// Job export interface
export interface Job {
  bodyshop: Bodyshop;
  ro_number: string;
  clm_no: string;
  asgn_no: string;
  asgn_date: string;
  state_tax_rate: number | null;
  area_of_damage: AreaOfDamage;
  asgn_type: string | null;
  ciecaid: string;
  cieca_pfl: CiecaPfl;
  clm_addr1: string | null;
  clm_city: string | null;
  clm_addr2: string | null;
  clm_ct_fn: string | null;
  clm_ct_ln: string | null;
  clm_ct_ph: string | null;
  clm_ct_phx: string | null;
  clm_ctry: string | null;
  clm_ea: string | null;
  clm_fax: string | null;
  clm_faxx: string | null;
  clm_ofc_id: string | null;
  clm_ofc_nm: string | null;
  clm_ph1: string | null;
  clm_ph1x: string | null;
  clm_ph2: string | null;
  clm_ph2x: string | null;
  clm_st: string | null;
  clm_title: string | null;
  clm_total: number;
  clm_zip: string | null;
  ded_amt: number;
  est_addr1: string | null;
  est_addr2: string | null;
  est_city: string | null;
  est_co_nm: string | null;
  est_ct_fn: string;
  est_ctry: string | null;
  est_ct_ln: string;
  est_ea: string;
  est_ph1: string | null;
  est_st: string | null;
  est_zip: string | null;
  g_bett_amt: number;
  id: string;
  ins_addr1: string | null;
  ins_city: string | null;
  ins_addr2: string | null;
  ins_co_id: string | null;
  ins_co_nm: string;
  ins_ct_fn: string | null;
  ins_ct_ln: string | null;
  ins_ct_ph: string | null;
  ins_ct_phx: string | null;
  ins_ctry: string | null;
  ins_ea: string | null;
  ins_fax: string | null;
  ins_faxx: string | null;
  ins_memo: string | null;
  ins_ph1: string | null;
  ins_ph1x: string | null;
  ins_ph2: string | null;
  ins_ph2x: string | null;
  ins_st: string | null;
  ins_title: string | null;
  ins_zip: string | null;
  insd_addr1: string;
  insd_addr2: string | null;
  insd_city: string;
  insd_co_nm: string | null;
  insd_ctry: string | null;
  insd_ea: string | null;
  insd_fax: string | null;
  insd_faxx: string | null;
  insd_fn: string;
  insd_ln: string;
  insd_ph1: string;
  insd_ph1x: string | null;
  insd_ph2: string;
  insd_ph2x: string | null;
  insd_st: string;
  insd_title: string | null;
  insd_zip: string;
  loss_cat: string;
  loss_date: string;
  loss_desc: string;
  loss_of_use: string | null;
  loss_type: string;
  ownr_addr1: string;
  ownr_addr2: string | null;
  ownr_city: string;
  ownr_co_nm: string | null;
  ownr_ctry: string | null;
  ownr_ea: string | null;
  ownr_fax: string | null;
  ownr_faxx: string | null;
  ownr_ph1: string;
  ownr_fn: string;
  ownr_ln: string;
  ownr_ph1x: string | null;
  ownr_ph2: string;
  ownr_ph2x: string | null;
  ownr_st: string;
  ownr_title: string | null;
  ownr_zip: string;
  parts_tax_rates: Record<string, DecodedPfpLine>;
  pay_amt: number;
  pay_date: string | null;
  pay_type: string | null;
  pay_chknm: string;
  payee_nms: string | null;
  plate_no: string;
  plate_st: string;
  po_number: string | null;
  policy_no: string;
  tax_lbr_rt: number;
  tax_levies_rt: number;
  tax_paint_mat_rt: number;
  tax_predis: number;
  tax_prethr: number;
  tax_pstthr: number;
  tax_registration_number: string | null;
  tax_str_rt: number;
  tax_shop_mat_rt: number;
  tax_sub_rt: number;
  tax_thramt: number;
  tax_tow_rt: number;
  theft_ind: boolean;
  tlos_ind: boolean;
  towin: boolean;
  v_color: string | null;
  v_make_desc: string;
  v_model_desc: string;
  v_model_yr: string;
  v_vin: string;
  vehicle: Vehicle;
  agt_zip: string | null;
  agt_st: string | null;
  agt_ph2x: string | null;
  agt_ph2: string | null;
  agt_ph1x: string | null;
  agt_ph1: string | null;
  agt_lic_no: string | null;
  agt_faxx: string | null;
  agt_fax: string | null;
  agt_ea: string | null;
  agt_ctry: string | null;
  agt_ct_phx: string | null;
  agt_ct_ph: string | null;
  agt_ct_ln: string | null;
  agt_ct_fn: string | null;
  agt_co_nm: string | null;
  agt_co_id: string | null;
  agt_city: string | null;
  agt_addr1: string | null;
  agt_addr2: string | null;
  adj_g_disc: number;
  rate_matd: number | null;
  rate_mash: number;
  rate_mapa: number;
  rate_mahw: number;
  rate_macs: number;
  rate_mabl: number | null;
  rate_ma3s: number;
  rate_ma2t: number;
  rate_ma2s: number;
  rate_lau: number;
  rate_las: number;
  rate_lar: number;
  rate_lam: number;
  rate_lag: number;
  rate_laf: number;
  rate_lae: number | null;
  rate_lad: number | null;
  rate_lab: number;
  rate_laa: number;
  rate_la4: number;
  rate_la3: number;
  rate_la2: number;
  rate_la1: number;
  materials: Record<string, DecodedPfmLine>;
  cieca_stl: {
    data: Array<DecodedStlLine>;
  };
  cieca_ttl: { data: DecodedTtlLine };
}

// Main Parts Order export interface
export interface EmsPartsOrder {
  parts_order_lines: PartsOrderLine[];
  job: Job;
}
