package com.erp.tenant.entity.finance;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.erp.tenant.entity.common.BaseEntity;

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

/**
 * 对账记录实体
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("reconciliations")
public class Reconciliation extends BaseEntity {

    // ==================== 对账状态 ====================
    /** 状态：待对账 */
    public static final int STATUS_PENDING = 0;
    /** 状态：已完成 */
    public static final int STATUS_COMPLETED = 1;
    /** 状态：有差异 */
    public static final int STATUS_DIFF = 2;

    @TableId(type = IdType.AUTO)
    private Long id;

    /** 对账单号 */
    @TableField("reconcile_no")
    private String reconcileNo;

    /** 对方名称 */
    @TableField("counterparty_name")
    private String counterpartyName;

    /** 对账周期开始 */
    @TableField("period_start")
    private LocalDateTime periodStart;

    /** 对账周期结束 */
    @TableField("period_end")
    private LocalDateTime periodEnd;

    /** 我方应收/应付金额 */
    @TableField("our_amount")
    private BigDecimal ourAmount;

    /** 对方确认金额 */
    @TableField("counterparty_amount")
    private BigDecimal counterpartyAmount;

    /** 差异金额 */
    @TableField("diff_amount")
    private BigDecimal diffAmount;

    /** 状态 */
    private Integer status;

    /** 完成时间 */
    @TableField("completed_at")
    private LocalDateTime completedAt;

    /** 完成人 */
    @TableField("completed_by")
    private Long completedBy;

    /** 备注 */
    private String remark;

    public String getStatusText() {
        return switch (status) {
            case STATUS_PENDING -> "待对账";
            case STATUS_COMPLETED -> "已完成";
            case STATUS_DIFF -> "有差异";
            default -> "未知";
        };
    }
}
