feat(erp): 添加费用报销模块

- 新增费用报销主模块结构体及接口定义
- 实现费用列表、添加、编辑、删除功能
- 定义费用项数据结构和传输参数
- 集成客户端调用逻辑
- 支持分页查询和搜索条件过滤
- 提供费用详情查看接口
This commit is contained in:
2025-12-12 15:11:58 +08:00
parent d682f333a1
commit 436c60c2d0
5 changed files with 224 additions and 0 deletions

View File

@@ -15,4 +15,5 @@ type Erp struct {
Payable payable Payable payable
Receivable receivable Receivable receivable
Receipt receipt Receipt receipt
Expense expense
} }

113
erp/expense.go Normal file
View File

@@ -0,0 +1,113 @@
package erp
import (
"context"
"time"
"git.kumo.work/shama/service/client"
expense2 "git.kumo.work/shama/service/erp/expense"
"git.kumo.work/shama/service/lib/bean"
"github.com/shopspring/decimal"
)
type expense struct {
expense2.Expense
}
type ArgsExpenseList struct {
Page bean.Page
Search ExpenseSearch
}
type ExpenseSearch struct {
ExpenseSerial string // 报销单号
CreatedAtStart *time.Time // 创建开始时间
CreatedAtEnd *time.Time // 创建结束时间
}
type ReplyExpenseList struct {
List []ExpenseItem `json:"list"`
Total int64 `json:"total"`
}
type ExpenseItem struct {
Id int64 `json:"id"`
ExpenseSerial string `json:"expenseSerial"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencySymbol string `json:"currencySymbol"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
Remarks string `json:"remarks"`
Amount decimal.Decimal `json:"amount"`
CreatedStaffId int64 `json:"createdStaffId"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
// List @TITLE 列表
func (r *expense) List(ctx context.Context, args ArgsExpenseList) (reply ReplyExpenseList, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "List", args, &reply)
return
}
type ArgsExpenseAdd struct {
StaffId int64
ExpenseAdd
}
type ExpenseAdd struct {
Currency string // 币种
CurrencyName string // 币种名称
CurrencySymbol string // 币种符号
CurrencyRate decimal.Decimal // 币种汇率
Remarks string // 备注
Amount decimal.Decimal // 金额
}
// Add @TITLE 添加
func (r *expense) Add(ctx context.Context, args ArgsExpenseAdd) (expenseId int64, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "Add", args, &expenseId)
return
}
type ReplyExpenseInfo struct {
Id int64 `json:"id"`
ExpenseSerial string `json:"expenseSerial"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencySymbol string `json:"currencySymbol"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
Amount decimal.Decimal `json:"amount"`
Remarks string `json:"remarks"`
CreatedStaffId int64 `json:"createdStaffId"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
// Info @TITLE 详情
func (r *expense) Info(ctx context.Context, expenseId int64) (reply ReplyExpenseInfo, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "Info", expenseId, &reply)
return
}
type ArgsExpenseEdit struct {
ExpenseId int64
ExpenseAdd
}
// Edit @TITLE 编辑
func (r *expense) Edit(ctx context.Context, args ArgsExpenseEdit) (err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Edit", args, &reply)
}

95
erp/expense/cost.go Normal file
View File

@@ -0,0 +1,95 @@
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)
}

5
erp/expense/expense.go Normal file
View File

@@ -0,0 +1,5 @@
package expense
type Expense struct {
Cost cost
}

View File

@@ -56,6 +56,16 @@ func (d *department) Info(ctx context.Context, departmentId int64) (reply Depart
return return
} }
// Infos @TITLE 部门详情
func (d *department) Infos(ctx context.Context, departmentIds []int64) (reply []DepartmentItem, err error) {
xClient, err := client.GetClient(d)
if err != nil {
return
}
err = xClient.Call(ctx, "Infos", departmentIds, &reply)
return
}
type ArgsDepartmentEdit struct { type ArgsDepartmentEdit struct {
DepartmentId int64 // 部门id DepartmentId int64 // 部门id
ArgsDepartmentAdd ArgsDepartmentAdd