import { DateTime } from 'luxon'
import { BaseModel, column, belongsTo } from '@adonisjs/lucid/orm'
import type { BelongsTo } from '@adonisjs/lucid/types/relations'
import Proforma from './proforma.js'

export default class ProformaItem extends BaseModel {
  @column({ isPrimary: true })
  declare id: number

  @column()
  declare proformaId: number

  @column()
  declare produto: string

  @column()
  declare descricao: string

  @column()
  declare quantidade: number

  @column()
  declare precoUnitario: number

  @column()
  declare subtotal: number

  @column.dateTime({ autoCreate: true })
  declare createdAt: DateTime

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  declare updatedAt: DateTime

  @belongsTo(() => Proforma)
  declare proforma: BelongsTo<typeof Proforma>
}