package dto

type ServiceRequisitionChecklistRequest struct {
	PreDeliveryCheck    bool `json:"pre_delivery_check"`
	DeliveryCheck       bool `json:"delivery_check"`
	PeriodicMaintenance bool `json:"periodic_maintenance"`
	Repair              bool `json:"repair"`
	Assemble            bool `json:"assemble"`
	Recondition         bool `json:"recondition"`
	Training            bool `json:"training"`
	Other               bool `json:"other"`
	Unit                bool `json:"unit"`
	PanelCabel          bool `json:"panel_cabel"`
	FuelTank            bool `json:"fuel_tank"`
	ExhaustSystem       bool `json:"exhaust_system"`
	FrontAttachment     bool `json:"front_attachment"`
	RearAttachment      bool `json:"rear_attachment"`
	Manuals             bool `json:"manuals"`
	Others              bool `json:"others"`
}

type ServiceRequisitionEquipmentRequest struct {
	No           int    `json:"no"`
	Brand        string `json:"brand"`
	Model        string `json:"model"`
	SerialNumber string `json:"serial_number"`
	Qty          int    `json:"qty"`
	MHPNo        string `json:"mhp_no"`
	TableBlock   int    `json:"table_block"`
}

type ServiceRequisitionRequest struct {
	ChargeTo          string                               `json:"charge_to"`
	CC                string                               `json:"cc"`
	Customer          string                               `json:"customer" validate:"required"`
	EquipmentLocation string                               `json:"equipment_location"`
	SalesAgreementNo  string                               `json:"spjb_no"`
	Description       string                               `json:"description"`
	Status            string                               `json:"status" validate:"required,oneof=draft submitted approved rejected archived"`
	Checklist         *ServiceRequisitionChecklistRequest  `json:"checklist"`
	Equipments        []ServiceRequisitionEquipmentRequest `json:"equipments"`
}

type LoginRequest struct {
	Username   string `json:"username" validate:"required"`
	Password   string `json:"password" validate:"required"`
	RememberMe bool   `json:"remember_me"`
}

type RefreshRequest struct {
	RefreshToken string `json:"refresh_token" validate:"required"`
}

type UserCreateRequest struct {
	FullName string `json:"full_name" validate:"required"`
	Username string `json:"username" validate:"required,min=4"`
	Password string `json:"password" validate:"required,min=6"`
	Role     string `json:"role" validate:"required,oneof=admin user superadmin manager staff"`
	BranchID uint   `json:"branch_id"`
}

type UserUpdateRequest struct {
	FullName string `json:"full_name" validate:"required"`
	Username string `json:"username" validate:"required,min=4"`
	Password string `json:"password" validate:"omitempty,min=6"`
	Role     string `json:"role" validate:"required,oneof=admin user superadmin manager staff"`
	BranchID uint   `json:"branch_id"`
}

type CreatePSORequest struct {
	PSONo        string  `json:"pso_no" validate:"required"`
	PSODate      string  `json:"pso_date" validate:"required"`
	CustomerName string  `json:"customer_name" validate:"required"`
	Amount       float64 `json:"amount" validate:"required,gt=0"`
	Remark       string  `json:"remark"`
}

type VerifyPORequest struct {
	ID uint `json:"id" validate:"required"`
}

type BulkVerifyRequest struct {
	IDs []uint `json:"ids" validate:"required,min=1"`
}

type IomRequest struct {
	ToDepartment   string `json:"to_department" validate:"required"`
	FromDepartment string `json:"from_department" validate:"required"`
	Subject        string `json:"subject" validate:"required"`
	Body           string `json:"body" validate:"required"`
	SignedBy       string `json:"signed_by" validate:"required"`
}

// UnitEntry represents one machine unit entry
type UnitEntry struct {
	Name   string `json:"name"`
	Qty    string `json:"qty"`
	Status string `json:"status"` // "running" or "standby"
}

type CreditLimitRequest struct {
	// Customer info
	Customer          string  `json:"customer" validate:"required"`
	CustomerCode      string  `json:"customer_code" validate:"required"`
	Subject           string  `json:"subject"`
	RequestedLimit    float64 `json:"requested_limit"`
	RequestedLimitRaw string  `json:"requested_limit_raw"`
	BusinessLine      string  `json:"business_line"`
	CompanyGroup      string  `json:"company_group"`

	// Units (JSON encoded from frontend)
	UnitsFromAltrak string `json:"units_from_altrak"`
	UnitsFromOther  string `json:"units_from_other"`

	// Business potential per month
	Spareparts   float64 `json:"spareparts"`
	FilterAmount float64 `json:"filter_amount"`
	Valvoline    float64 `json:"valvoline"`
	Others       float64 `json:"others"`

	// Aging A/R
	AgingAsOfDate string  `json:"aging_as_of_date"`
	AgingNotDue   float64 `json:"aging_not_due"`
	Aging1Month   float64 `json:"aging_1_month"`
	Aging2Months  float64 `json:"aging_2_months"`
	Aging3Months  float64 `json:"aging_3_months"`
	AgingOver3    float64 `json:"aging_over_3"`

	Cc string `json:"cc"`

	// Signature
	SignedBy    string `json:"signed_by"`
	SignedTitle string `json:"signed_title"`
}

type ServiceJobRequestDTO struct {
	RequestType    string `json:"request_type"` // repair, calibration
	CustomerName   string `json:"customer_name" validate:"required"`
	JobName        string `json:"job_name" validate:"required"`
	Component      string `json:"component"`
	EngineBrand    string `json:"engine_brand" validate:"required"`
	EngineModel    string `json:"engine_model" validate:"required"`
	ESN            string `json:"esn" validate:"required"`
	ToDepartment   string `json:"to_department"`
	FromDepartment string `json:"from_department"`
	SignedBy       string `json:"signed_by"`
	SignedTitle    string `json:"signed_title"`
}

// ---------------------------------------------------------
// NEW: MEMO SERVICE PARTS DTOs
// ---------------------------------------------------------

type MemoServicePartsChecklistRequest struct {
	PreDeliveryCheck    bool `json:"pre_delivery_check"`
	DeliveryCheck       bool `json:"delivery_check"`
	PeriodicMaintenance bool `json:"periodic_maintenance"`
	Repair              bool `json:"repair"`
	Assemble            bool `json:"assemble"`
	Recondition         bool `json:"recondition"`
	Training            bool `json:"training"`
	Other               bool `json:"other"`
	Unit                bool `json:"unit"`
	PanelCabel          bool `json:"panel_cabel"`
	FuelTank            bool `json:"fuel_tank"`
	ExhaustSystem       bool `json:"exhaust_system"`
	FrontAttachment     bool `json:"front_attachment"`
	RearAttachment      bool `json:"rear_attachment"`
	Manuals             bool `json:"manuals"`
	Others              bool `json:"others"`
}

type MemoServicePartsEquipmentRequest struct {
	No           int    `json:"no"`
	Brand        string `json:"brand"`
	Model        string `json:"model"`
	SerialNumber string `json:"serial_number"`
	Qty          int    `json:"qty"`
	MHPNo        string `json:"mhp_no"`
	TableBlock   int    `json:"table_block"`
}

type MemoServicePartsRequest struct {
	ChargeTo          string                             `json:"charge_to"`
	CC                string                             `json:"cc"`
	Customer          string                             `json:"customer" validate:"required"`
	EquipmentLocation string                             `json:"equipment_location"`
	SalesAgreementNo  string                             `json:"spjb_no"`
	Description       string                             `json:"description"`
	Status            string                             `json:"status" validate:"required,oneof=draft submitted approved rejected archived"`
	Checklist         *MemoServicePartsChecklistRequest  `json:"checklist"`
	Equipments        []MemoServicePartsEquipmentRequest `json:"equipments"`
	EngineUnit        string                             `json:"engine_unit"`
	ESNNumber         string                             `json:"esn_number"`
	SpvName           string                             `json:"spv_name"`
	SpvPosition       string                             `json:"spv_position"`
	To                string                             `json:"to"`
	From              string                             `json:"from"`
	Subject           string                             `json:"subject"`
}

// ---------------------------------------------------------
// NEW: MEMO SERVICE KALIBRASI DTOs
// ---------------------------------------------------------

type MemoServiceKalibrasiChecklistRequest struct {
	PreDeliveryCheck    bool `json:"pre_delivery_check"`
	DeliveryCheck       bool `json:"delivery_check"`
	PeriodicMaintenance bool `json:"periodic_maintenance"`
	Repair              bool `json:"repair"`
	Assemble            bool `json:"assemble"`
	Recondition         bool `json:"recondition"`
	Training            bool `json:"training"`
	Other               bool `json:"other"`
	Unit                bool `json:"unit"`
	PanelCabel          bool `json:"panel_cabel"`
	FuelTank            bool `json:"fuel_tank"`
	ExhaustSystem       bool `json:"exhaust_system"`
	FrontAttachment     bool `json:"front_attachment"`
	RearAttachment      bool `json:"rear_attachment"`
	Manuals             bool `json:"manuals"`
	Others              bool `json:"others"`
}

type MemoServiceKalibrasiEquipmentRequest struct {
	No           int    `json:"no"`
	Brand        string `json:"brand"`
	Model        string `json:"model"`
	SerialNumber string `json:"serial_number"`
	Qty          int    `json:"qty"`
	MHPNo        string `json:"mhp_no"`
	TableBlock   int    `json:"table_block"`
}

type MemoServiceKalibrasiRequest struct {
	ChargeTo          string                                 `json:"charge_to"`
	CC                string                                 `json:"cc"`
	Customer          string                                 `json:"customer" validate:"required"`
	EquipmentLocation string                                 `json:"equipment_location"`
	SalesAgreementNo  string                                 `json:"spjb_no"`
	Description       string                                 `json:"description"`
	Status            string                                 `json:"status" validate:"required,oneof=draft submitted approved rejected archived"`
	Checklist         *MemoServiceKalibrasiChecklistRequest  `json:"checklist"`
	Equipments        []MemoServiceKalibrasiEquipmentRequest `json:"equipments"`
	EngineUnit        string                                 `json:"engine_unit"`
	ESNNumber         string                                 `json:"esn_number"`
	ComponentName     string                                 `json:"component_name"`
	SpvName           string                                 `json:"spv_name"`
	SpvPosition       string                                 `json:"spv_position"`
	To                string                                 `json:"to"`
	From              string                                 `json:"from"`
	Subject           string                                 `json:"subject"`
}
