- 新增 append 模块处理追加费用相关逻辑 - 在 accounting 结构体中添加 Append 字段支持追加操作 - 添加 ArgsAuditAppendCost 和 ArgsAppendAddCost 等参数结构体 - 实现 AppendCost 方法用于追加费用审核流程 - 新增 PurchaseCostItem 结构体并实现 Purchase 方法获取采购合同费用 - 在 constant.go 中添加 BusinessTypeAccountingAppendCostAudit 业务类型常量 - 移除 sale/benefit.go 中的 OtherCost 字段优化成本结构 - 添加 payable.Gen 方法用于生成应付单 - 添加 receivable.Gen 方法用于生成应收单
106 lines
2.7 KiB
Go
106 lines
2.7 KiB
Go
package accounting
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.kumo.work/shama/service/client"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type cost struct {
|
|
}
|
|
|
|
type CostItem struct {
|
|
Id int64 `json:"id"`
|
|
FactoryId int64 `json:"factoryId"`
|
|
FactoryName string `json:"factoryName"`
|
|
FactoryShortName string `json:"factoryShortName"`
|
|
Name string `json:"name"`
|
|
Amount decimal.Decimal `json:"amount"`
|
|
Remarks string `json:"remarks"`
|
|
CreatedAt *time.Time `json:"createdAt"`
|
|
UpdatedAt *time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
// All @TITLE 获取费用
|
|
func (c *cost) All(ctx context.Context, accountingId int64) (reply []CostItem, err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "All", accountingId, &reply)
|
|
return
|
|
}
|
|
|
|
type PurchaseCostItem struct {
|
|
Id int64 `json:"id"`
|
|
FactoryId int64 `json:"factoryId"`
|
|
FactoryName string `json:"factoryName"`
|
|
PiSerial string `json:"piSerial"`
|
|
PoSerial string `json:"poSerial"`
|
|
BatchNo int64 `json:"batchNo"`
|
|
Name string `json:"name"`
|
|
Amount decimal.Decimal `json:"amount"`
|
|
Remarks string `json:"remarks"`
|
|
CreatedAt *time.Time `json:"createdAt"`
|
|
UpdatedAt *time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
// Purchase @TITLE 采购合同费用
|
|
func (c *cost) Purchase(ctx context.Context, accountingId int64) (reply []PurchaseCostItem, err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "Purchase", accountingId, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsCostAdd struct {
|
|
AccountingId int64 // 做账合同ID
|
|
CostAdd
|
|
}
|
|
|
|
type CostAdd struct {
|
|
FactoryId int64 // 工厂id
|
|
Name string // 费用名
|
|
Amount decimal.Decimal // 金额
|
|
Remarks string // 备注信息
|
|
}
|
|
|
|
// 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 // 费用ID
|
|
CostAdd
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
// Delete @TITLE 删除费用
|
|
func (c *cost) Delete(ctx context.Context, costIds []int64) (err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
return xClient.Call(ctx, "Delete", costIds, &reply)
|
|
}
|