package dao

import (
	"github.com/shopspring/decimal"
	"server/global"
)

type FeeDetails struct {
	global.GVA_MODEL
	ReimbursementId uint            `json:"reimbursementId" form:"reimbursementId" gorm:"comment:报销id"`
	Genre           string          `json:"genre" form:"genre" gorm:"comment:项目类型"`
	Subject         string          `json:"subject" form:"subject" gorm:"comment:科目"`
	Remarks         string          `json:"remarks" form:"remarks" gorm:"comment:备注"`
	FeePrice        decimal.Decimal `json:"feePrice" form:"feePrice" gorm:"comment:报销金额;type:decimal(10,2)"`
}

func (FeeDetails) TableName() string {
	return "fee_details"
}

// TODO:费用详情查询

// QueryFeeDetails 查询费用详情
func QueryFeeDetails(id int) (feeDetails []FeeDetails, err error) {
	err = global.GVA_DB.Model(&FeeDetails{}).Where("reimbursement_id = ?", id).Find(&feeDetails).Error
	return feeDetails, err
}

// TODO:费用详情新增

// TODO:费用详情修改

// TODO:费用详情删除

// DeleteFeeDetails 删除费用详情
func DeleteFeeDetails(id uint) error {
	return global.GVA_DB.Unscoped().Where("reimbursement_id = ?", id).Delete(&FeeDetails{}).Error
}
