Files
service/erp/expense/cost.go
kanade 436c60c2d0 feat(erp): 添加费用报销模块
- 新增费用报销主模块结构体及接口定义
- 实现费用列表、添加、编辑、删除功能
- 定义费用项数据结构和传输参数
- 集成客户端调用逻辑
- 支持分页查询和搜索条件过滤
- 提供费用详情查看接口
2025-12-12 15:11:58 +08:00

96 lines
2.2 KiB
Go

package expense
import (
"context"
"time"
"git.kumo.work/shama/service/client"
"git.kumo.work/shama/service/lib/bean"
"github.com/shopspring/decimal"
)
type cost struct {
}
type ArgsCostList struct {
Page bean.Page
Search CostSearch
}
type CostSearch struct {
ExpenseId int64 // 报销单ID
}
type ReplyCostList struct {
List []CostItem `json:"list"`
Total int64 `json:"total"`
}
type CostItem struct {
Id int64 `json:"id"`
ExpenseId int64 `json:"expenseId"`
Date time.Time `json:"date"`
Type int64 `json:"type"`
Value string `json:"value"`
Amount decimal.Decimal `json:"amount"`
DepartmentId int64 `json:"departmentId"`
InvoiceSerial string `json:"invoiceSerial"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
// List @TITLE 列表
func (c *cost) List(ctx context.Context, args ArgsCostList) (reply ReplyCostList, err error) {
xClient, err := client.GetClient(c)
if err != nil {
return
}
err = xClient.Call(ctx, "List", args, &reply)
return
}
type ArgsCostAdd struct {
ExpenseId int64 // 报销单ID
Date time.Time // 费用日期
Type int64 // 费用类型
Value string // 费用名称
Amount decimal.Decimal // 金额
DepartmentId int64 // 部门
}
// Add @TITLE 添加
func (c *cost) Add(ctx context.Context, args ArgsCostAdd) (err error) {
xClient, err := client.GetClient(c)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Add", args, &reply)
}
type ArgsCostEdit struct {
CostId int64
ArgsCostAdd
}
// Edit @TITLE 编辑
func (c *cost) Edit(ctx context.Context, args ArgsCostEdit) (err error) {
xClient, err := client.GetClient(c)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Edit", args, &reply)
}
type ArgsCostDelete struct {
ExpenseId int64 // 报销单ID
CostIds []int64
}
// Delete @TITLE 删除
func (c *cost) Delete(ctx context.Context, args ArgsCostDelete) (err error) {
xClient, err := client.GetClient(c)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Delete", args, &reply)
}