Files
service/erp/receivable.go
kanade 47b521845d feat(accounting): 添加做账合同追加费用功能
- 新增 append 模块处理追加费用相关逻辑
- 在 accounting 结构体中添加 Append 字段支持追加操作
- 添加 ArgsAuditAppendCost 和 ArgsAppendAddCost 等参数结构体
- 实现 AppendCost 方法用于追加费用审核流程
- 新增 PurchaseCostItem 结构体并实现 Purchase 方法获取采购合同费用
- 在 constant.go 中添加 BusinessTypeAccountingAppendCostAudit 业务类型常量
- 移除 sale/benefit.go 中的 OtherCost 字段优化成本结构
- 添加 payable.Gen 方法用于生成应付单
- 添加 receivable.Gen 方法用于生成应收单
2026-06-26 10:45:43 +08:00

154 lines
6.6 KiB
Go

package erp
import (
"context"
"time"
"git.kumo.work/shama/service/client"
"git.kumo.work/shama/service/lib/bean"
"github.com/shopspring/decimal"
)
type receivable struct {
}
type ArgsReceivableList struct {
Page bean.Page
Search ReceivableSearch
Order []OrderItem
}
type ReceivableSearch struct {
ReceivableSerial string // 收款单据号
CustomId int64 // 客户id
CustomName string // 客户名称
InvoiceSerial string // 出运发票号
CreatedAtStart *time.Time // 创建开始时间
CreatedAtEnd *time.Time // 创建结束时间
PermissionStaffIds []int64 // 权限员工id
}
type ReplyReceivableList struct {
List []ReceivableItem `json:"list"`
Total int64 `json:"total"`
}
type ReceivableItem struct {
Id int64 `json:"id"`
ReceivableSerial string `json:"receivableSerial"`
CustomName string `json:"customName"`
InvoiceSerial string `json:"invoiceSerial"`
ReceivableAmount decimal.Decimal `json:"receivableAmount"`
ReceivedAmount decimal.Decimal `json:"receivedAmount"`
OutstandingAmount decimal.Decimal `json:"outstandingAmount"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
CurrencySymbol string `json:"currencySymbol"`
CreatedStaffID int64 `json:"createdStaffID"`
Ik3cloudStatus int64 `json:"ik3CloudStatus"`
Ik3cloudErrMsg string `json:"ik3CloudErrMsg"`
Ik3cloudUpdatedAt *time.Time `json:"ik3CloudUpdatedAt"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
// List @TITLE 列表
func (r *receivable) List(ctx context.Context, args ArgsReceivableList) (reply ReplyReceivableList, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "List", args, &reply)
return
}
// Gen @TITLE 生成应收单
func (r *receivable) Gen(ctx context.Context, shipmentId int64) (err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Gen", shipmentId, &reply)
}
type ReplyReceivableInfo struct {
Id int64 `json:"id"`
ReceivableSerial string `json:"receivableSerial"`
CustomName string `json:"customName"`
InvoiceSerial string `json:"invoiceSerial"`
ReceivableAmount decimal.Decimal `json:"receivableAmount"`
ReceivedAmount decimal.Decimal `json:"receivedAmount"`
OutstandingAmount decimal.Decimal `json:"outstandingAmount"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
CurrencySymbol string `json:"currencySymbol"`
DomesticShippingCost decimal.Decimal `json:"domesticShippingCost"`
ForeignShippingCost decimal.Decimal `json:"foreignShippingCost"`
ForeignCommission decimal.Decimal `json:"foreignCommission"`
Consignee string `json:"consignee"`
CreatedStaffID int64 `json:"createdStaffID"`
Ik3cloudStatus int64 `json:"ik3CloudStatus"`
Ik3cloudErrMsg string `json:"ik3CloudErrMsg"`
Ik3cloudUpdatedAt *time.Time `json:"ik3CloudUpdatedAt"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
Products []ReceivableProductItem `json:"products"`
CustomsProducts []ReceivableCustomsProductItem `json:"customsProducts"`
}
type ReceivableProductItem struct {
Id int64 `json:"id"`
ShipmentProductId int64 `json:"shipmentProductId"`
PiSerial string `json:"piSerial"`
Name string `json:"name"`
Serial string `json:"serial"`
ReceivableCount decimal.Decimal `json:"receivableCount"`
InvoiceUnit string `json:"invoiceUnit"`
AddTaxRate decimal.Decimal `json:"addTaxRate"`
UnitPrice decimal.Decimal `json:"unitPrice"`
ExTaxUnitPrice decimal.Decimal `json:"exTaxUnitPrice"`
UnitAmount decimal.Decimal `json:"unitAmount"`
ExTaxUnitAmount decimal.Decimal `json:"exTaxUnitAmount"`
TaxAmount decimal.Decimal `json:"taxAmount"`
ExportCost decimal.Decimal `json:"exportCost"`
MinusTaxRate decimal.Decimal `json:"minusTaxRate"`
MinusTaxAmount decimal.Decimal `json:"minusTaxAmount"`
MinusTaxDifference decimal.Decimal `json:"minusTaxDifference"`
}
type ReceivableCustomsProductItem struct {
Id int64 `json:"id"`
Name string `json:"name"` // 中文品名
CustomsSerial string `json:"customsSerial"` // 海关编号
Count decimal.Decimal `json:"count"` // 数量
InvoiceUnit string `json:"invoiceUnit"` // 开票单位
AddTaxRate decimal.Decimal `json:"addTaxRate"` // 增值税率
UnitPrice decimal.Decimal `json:"unitPrice"` // 含税单价
ExTaxUnitPrice decimal.Decimal `json:"exTaxUnitPrice"` // 不含税单价
UnitAmount decimal.Decimal `json:"unitAmount"` // 价税合计
ExTaxUnitAmount decimal.Decimal `json:"exTaxUnitAmount"` // 不含税金额
TaxAmount decimal.Decimal `json:"taxAmount"` // 税额
ExportCost decimal.Decimal `json:"exportCost"` // 外销成本
MinusTaxRate decimal.Decimal `json:"minusTaxRate"` // 退税率
MinusTaxAmount decimal.Decimal `json:"minusTaxAmount"` // 退税额
MinusTaxDifference decimal.Decimal `json:"minusTaxDifference"` // 退税差额
}
// Info @TITLE 详情
func (r *receivable) Info(ctx context.Context, receivableId int64) (reply ReplyReceivableInfo, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "Info", receivableId, &reply)
return
}
// Ik3cloud @TITLE 同步
func (r *receivable) Ik3cloud(ctx context.Context, receivableId int64) (err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Ik3cloud", receivableId, &reply)
}