package models

import "time"

type OrderLoker struct {
	Id                uint               `json:"id"`
	OrderCode         string             `json:"order_code"`
	Quantity          int                `json:"quantity"`
	PriceTotal        int                `json:"price_total"`
	Penyewa           string             `json:"penyewa"`
	Trxdate           time.Time          `json:"trxdate"`
	OrderLokerDetails []OrderLokerDetail `json:"details" gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;foreignKey:OrderLokerId"`
	NamaAdmin         string             `json:"nama_admin"`
	CreatedAt         time.Time          `json:"created_at"`
	UpdatedAt         time.Time          `json:"updated_at"`
}

type ResponseOrderLoker struct {
	Id         uint      `json:"id"`
	OrderCode  string    `json:"order_code"`
	Quantity   int       `json:"quantity"`
	PriceTotal int       `json:"price_total"`
	Penyewa    string    `json:"penyewa"`
	Trxdate    time.Time `json:"trxdate"`
	NamaAdmin  string    `json:"nama_admin"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

func (Obj *OrderLoker) ToResponse() *ResponseOrderLoker {
	return &ResponseOrderLoker{
		Id:         Obj.Id,
		OrderCode:  Obj.OrderCode,
		Quantity:   Obj.Quantity,
		PriceTotal: Obj.PriceTotal,
		Penyewa:    Obj.Penyewa,
		Trxdate:    Obj.Trxdate,
		NamaAdmin:  Obj.NamaAdmin,
		CreatedAt:  Obj.CreatedAt,
		UpdatedAt:  Obj.UpdatedAt,
	}
}
