package com.goldenchart.entity;

import jakarta.persistence.*;
import lombok.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Entity
@Table(name = "gc_paper_trade")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class GcPaperTrade {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "account_id", nullable = false)
    private Long accountId;

    @Column(name = "symbol", length = 50, nullable = false)
    private String symbol;

    @Column(name = "side", length = 10, nullable = false)
    private String side;

    @Column(name = "order_kind", length = 20, nullable = false)
    @Builder.Default
    private String orderKind = "limit";

    @Column(name = "source", length = 20, nullable = false)
    @Builder.Default
    private String source = "MANUAL";

    @Column(name = "strategy_id")
    private Long strategyId;

    @Column(name = "price", precision = 20, scale = 2, nullable = false)
    private BigDecimal price;

    @Column(name = "quantity", precision = 30, scale = 12, nullable = false)
    private BigDecimal quantity;

    @Column(name = "gross_amount", precision = 20, scale = 2, nullable = false)
    private BigDecimal grossAmount;

    @Column(name = "fee_amount", precision = 20, scale = 2, nullable = false)
    @Builder.Default
    private BigDecimal feeAmount = BigDecimal.ZERO;

    @Column(name = "net_amount", precision = 20, scale = 2, nullable = false)
    private BigDecimal netAmount;

    @Column(name = "cash_after", precision = 20, scale = 2, nullable = false)
    private BigDecimal cashAfter;

    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;

    @PrePersist
    protected void onCreate() {
        createdAt = LocalDateTime.now();
    }
}
