import { defineKbxScreen, type KbxGridColumn } from '@kbx/ui'

export interface ItemPriceRow {
  clientId: string
  itemId: string | null
  itemCode: string
  itemName: string
  effectiveDate: string
  unitPrice: number
  remark: string
}

export const itemPriceScreen = defineKbxScreen({
  id: 'ERP-PRICE-001',
  version: '1.0.0',
  module: 'ERP',
  type: 'fast-entry', templateCode:'T04',
  title: '품목 단가 일괄등록',
  description: '품목별 적용일과 표준단가를 Excel처럼 연속 입력하고 한 번에 저장합니다.',
  helpKey: 'ERP-PRICE-001',
  permissions: ['erp.item.price.read', 'erp.item.read'],
  commands: [
    { id: 'new', label: '신규', group: 'edit' },
    { id: 'save', label: '저장', group: 'edit', variant: 'primary', shortcut: 'F8', permission: 'erp.item.price.write' },
    { id: 'excel', label: '엑셀', group: 'output' },
  ],
  telemetry: { enabled: true },
})

export const itemPriceColumns: KbxGridColumn<ItemPriceRow>[] = [
  { field:'itemCode', header:'품목코드', type:'lookup', width:140, pinned:'left', editable:true, lookup:{entity:'item'} },
  { field:'itemName', header:'품목명', width:220 },
  { field:'effectiveDate', header:'적용일', type:'date', width:120, editable:true },
  { field:'unitPrice', header:'단가', type:'money', width:130, editable:true },
  { field:'remark', header:'비고', width:260, editable:true },
]
