PayrollManagementSystem/frontend/src/api/receipts.ts
liuwenxin a4794489b1 fix(T+与核算): 对齐抵顶口径和托管说明
根据审查结果统一以物抵顶的线下核实口径,移除当前模型、初始化脚本和前端接口中的自动折算误导文案。\n补充业务接入必须持有共享 T+ 命名锁的执行契约,明确来源快照稳定性依赖。\nWindows 部署说明区分新 supervisor 与旧任务迁移检查,避免现场并行启动旧 worker。\n\n影响范围:T+ 托管文档、业务接入契约、回款/台账模型注释和参数试算说明。\n\nCo-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-06 14:49:06 +08:00

118 lines
4.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { request } from './request'
import type { PageData } from './types'
/**
* 回款列表项(对应后端 `ReceiptOut`;字段契约纯蛇形直出)。
*
* amount 字符串直出(金额红线);payment_days 为派生值:未指定发货
* 批次时为 null,指定后 = 发货日到回款日的天数(发货日计第 1 天)。
*/
export interface ReceiptItem {
id: number
receipt_batch_no: string
business_id: number
business_no: string
shipment_id: number | null
shipment_no: string | null
/** 回款到账日,ISO 串(YYYY-MM-DD);M3 核算按此日匹配参数版本 */
receipt_date: string
/** 回款金额(元),字符串直出 */
amount: string
/** 以物抵顶标记:1是 0否(特殊绩效线下核实,系统不自动折算) */
is_barter: number
/** 核算状态:0未核算 1已核算(已核算禁改禁删) */
settlement_status: number
confirmation_status: number
confirmed_by: string | null
confirmed_at: string | null
confirmation_revision: string
payment_days: number | null
remark: string | null
}
export interface ReceiptQueryParams {
pageNum?: number
pageSize?: number
business_id?: number
/** 回款到账日起(含),ISO 串 */
date_from?: string
/** 回款到账日止(含),ISO 串 */
date_to?: string
is_barter?: number
settlement_status?: number
confirmation_status?: number
}
/**
* 新增回款:业务必选,发货批次可暂不指定(手动指定)。
*
* shipment_id 须与本回款同属一个业务(后端强校验,数据完整性红线)。
*/
export interface ReceiptCreateParams {
business_id: number
shipment_id?: number | null
receipt_date: string
/** 数字字符串,非负,最多两位小数 */
amount: string
is_barter?: number
remark?: string | null
}
/**
* 编辑回款:全量替换语义;不含 business_id(挂靠业务创建时定死)。
*
* shipment_id 传 null = 清除指定(回到「暂未指定」)。
*/
export interface ReceiptUpdateParams {
shipment_id?: number | null
receipt_date: string
amount: string
is_barter?: number
remark?: string | null
}
/** 以物抵顶筛选项 */
export const BARTER_OPTIONS = [
{ label: '以物抵顶', value: 1 },
{ label: '货币回款', value: 0 },
] as const
/** 核算状态筛选项(与列表标签文案一致) */
export const SETTLEMENT_OPTIONS = [
{ label: '已核算', value: 1 },
{ label: '未核算', value: 0 },
] as const
/** 分页查询回款(附业务号/发货单号与回款天数派生值) */
export function listReceipts(params: ReceiptQueryParams): Promise<PageData<ReceiptItem>> {
return request({ url: '/v1/business/receipts', method: 'get', params })
}
export function getConfirmationPolicy(): Promise<{ enabled: boolean }> {
return request({ url: '/v1/business/receipts/confirmation-policy', method: 'get' })
}
export function confirmReceipt(row: ReceiptItem): Promise<ReceiptItem> {
return request({ url: `/v1/business/receipts/${row.id}/confirm`, method: 'post', data: { expected_revision: row.confirmation_revision } })
}
/** 新增回款(批次号自动生成 HK 前缀;业务须执行中) */
export function createReceipt(data: ReceiptCreateParams): Promise<ReceiptItem> {
return request({ url: '/v1/business/receipts', method: 'post', data })
}
/** 回款详情(含回款天数派生值) */
export function getReceiptDetail(receiptId: number): Promise<ReceiptItem> {
return request({ url: `/v1/business/receipts/${receiptId}`, method: 'get' })
}
/** 编辑回款(全量替换;已核算回款后端拒绝) */
export function updateReceipt(receiptId: number, data: ReceiptUpdateParams): Promise<ReceiptItem> {
return request({ url: `/v1/business/receipts/${receiptId}`, method: 'put', data })
}
/** 删除回款(已核算/业务非执行中时后端拒绝;业务回款合计自动回退) */
export function deleteReceipt(receiptId: number): Promise<null> {
return request({ url: `/v1/business/receipts/${receiptId}`, method: 'delete' })
}