@plolink/sdk 2.0.1 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/invoice-application/index.cjs +164 -0
- package/dist/modules/invoice-application/index.cjs.map +1 -0
- package/dist/modules/invoice-application/index.d.cts +311 -0
- package/dist/modules/invoice-application/index.d.ts +311 -0
- package/dist/modules/invoice-application/index.js +162 -0
- package/dist/modules/invoice-application/index.js.map +1 -0
- package/dist/modules/psychology-test/index.cjs +2 -0
- package/dist/modules/psychology-test/index.cjs.map +1 -1
- package/dist/modules/psychology-test/index.d.cts +8 -0
- package/dist/modules/psychology-test/index.d.ts +8 -0
- package/dist/modules/psychology-test/index.js +2 -0
- package/dist/modules/psychology-test/index.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkY3UJVC2L_cjs = require('../../chunk-Y3UJVC2L.cjs');
|
|
4
|
+
|
|
5
|
+
// src/modules/invoice-application/index.ts
|
|
6
|
+
var InvoiceApplication = class {
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 获取团队财务选项
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* 返回当前用户有申请开票权限的团队列表及其财务信息。
|
|
15
|
+
* 包含每个团队的可开票金额、消费金额、已开票金额和余额。
|
|
16
|
+
*
|
|
17
|
+
* @returns 团队财务选项列表
|
|
18
|
+
* @throws {PlolinkError} 当请求失败时抛出
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const teams = await invoiceApp.getTeamFinancialOptions();
|
|
23
|
+
* teams.forEach(team => {
|
|
24
|
+
* console.log(`${team.teamName}: 可开票 ${team.invoiceableAmount}`);
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
async getTeamFinancialOptions() {
|
|
29
|
+
return this.client.axiosInstance.get("/api/v1/payments/teams/financial-options");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 创建开票申请
|
|
33
|
+
*
|
|
34
|
+
* @description
|
|
35
|
+
* 创建跨团队开票申请。支持同时为多个团队申请开票,
|
|
36
|
+
* 申请单将提交给财务审核。
|
|
37
|
+
*
|
|
38
|
+
* @param params - 开票申请参数
|
|
39
|
+
* @returns 创建结果,包含申请单ID和创建时间
|
|
40
|
+
* @throws {PlolinkError} 当参数无效或创建失败时抛出
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // 单团队申请
|
|
45
|
+
* const result = await invoiceApp.create({
|
|
46
|
+
* teams: [{ teamId: 'team-1', amount: 1000 }],
|
|
47
|
+
* invoiceType: 'VAT_SPECIAL',
|
|
48
|
+
* invoiceTitle: 'Test Company Ltd',
|
|
49
|
+
* taxNumber: '91110000XXX',
|
|
50
|
+
* remark: 'January invoice'
|
|
51
|
+
* });
|
|
52
|
+
* console.log(`申请单ID: ${result.id}`);
|
|
53
|
+
*
|
|
54
|
+
* // 跨团队申请
|
|
55
|
+
* const result = await invoiceApp.create({
|
|
56
|
+
* teams: [
|
|
57
|
+
* { teamId: 'team-1', amount: 500 },
|
|
58
|
+
* { teamId: 'team-2', amount: 300 }
|
|
59
|
+
* ],
|
|
60
|
+
* invoiceType: 'VAT_NORMAL',
|
|
61
|
+
* invoiceTitle: 'Test Company Ltd',
|
|
62
|
+
* taxNumber: '91110000XXX'
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
async create(params) {
|
|
67
|
+
const { teams, invoiceType, invoiceTitle, taxNumber, businessModule, businessCode, businessId, remark } = params;
|
|
68
|
+
if (!teams || teams.length === 0) {
|
|
69
|
+
throw new chunkY3UJVC2L_cjs.PlolinkError("teams is required and must not be empty", "INVALID_PARAMS");
|
|
70
|
+
}
|
|
71
|
+
for (const team of teams) {
|
|
72
|
+
if (!team.teamId) {
|
|
73
|
+
throw new chunkY3UJVC2L_cjs.PlolinkError("teamId is required for each team", "INVALID_PARAMS");
|
|
74
|
+
}
|
|
75
|
+
if (!team.amount || team.amount <= 0) {
|
|
76
|
+
throw new chunkY3UJVC2L_cjs.PlolinkError("amount must be greater than 0 for each team", "INVALID_PARAMS");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!invoiceType) {
|
|
80
|
+
throw new chunkY3UJVC2L_cjs.PlolinkError("invoiceType is required", "INVALID_PARAMS");
|
|
81
|
+
}
|
|
82
|
+
if (!invoiceTitle) {
|
|
83
|
+
throw new chunkY3UJVC2L_cjs.PlolinkError("invoiceTitle is required", "INVALID_PARAMS");
|
|
84
|
+
}
|
|
85
|
+
if (!taxNumber) {
|
|
86
|
+
throw new chunkY3UJVC2L_cjs.PlolinkError("taxNumber is required", "INVALID_PARAMS");
|
|
87
|
+
}
|
|
88
|
+
this.client.logger.info("Creating invoice application", {
|
|
89
|
+
teamCount: teams.length,
|
|
90
|
+
totalAmount: teams.reduce((sum, t) => sum + t.amount, 0),
|
|
91
|
+
invoiceType
|
|
92
|
+
});
|
|
93
|
+
return this.client.axiosInstance.post("/api/v1/payments/invoice/applications", {
|
|
94
|
+
teams,
|
|
95
|
+
invoiceType,
|
|
96
|
+
invoiceTitle,
|
|
97
|
+
taxNumber,
|
|
98
|
+
businessModule,
|
|
99
|
+
businessCode,
|
|
100
|
+
businessId,
|
|
101
|
+
remark
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 分页查询申请单列表
|
|
106
|
+
*
|
|
107
|
+
* @description
|
|
108
|
+
* 分页查询当前用户提交的发票申请单列表,支持按状态筛选。
|
|
109
|
+
*
|
|
110
|
+
* @param params - 查询参数
|
|
111
|
+
* @returns 分页申请单列表
|
|
112
|
+
* @throws {PlolinkError} 当请求失败时抛出
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // 查询所有申请单
|
|
117
|
+
* const result = await invoiceApp.list({ page: 1, pageSize: 20 });
|
|
118
|
+
* console.log(`共 ${result.total} 条申请单`);
|
|
119
|
+
*
|
|
120
|
+
* // 按状态筛选
|
|
121
|
+
* const pending = await invoiceApp.list({ status: 'PENDING' });
|
|
122
|
+
* const approved = await invoiceApp.list({ status: 'APPROVED' });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
async list(params = {}) {
|
|
126
|
+
const { page = 1, pageSize = 20, status } = params;
|
|
127
|
+
return this.client.axiosInstance.get("/api/v1/payments/invoice/applications", {
|
|
128
|
+
params: { page, pageSize, status }
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 查询申请单详情
|
|
133
|
+
*
|
|
134
|
+
* @description
|
|
135
|
+
* 根据申请单ID查询详细信息,包括各团队的申请金额和审核状态。
|
|
136
|
+
*
|
|
137
|
+
* @param id - 申请单ID
|
|
138
|
+
* @returns 申请单详情
|
|
139
|
+
* @throws {PlolinkError} 当申请单不存在或请求失败时抛出
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const detail = await invoiceApp.getById('application-id');
|
|
144
|
+
* console.log(`状态: ${detail.status}`);
|
|
145
|
+
* console.log(`总金额: ${detail.totalAmount}`);
|
|
146
|
+
* console.log(`发票号: ${detail.invoiceNumber || '未填写'}`);
|
|
147
|
+
*
|
|
148
|
+
* // 查看各团队详情
|
|
149
|
+
* detail.details.forEach(d => {
|
|
150
|
+
* console.log(`${d.teamName}: ${d.amount}`);
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
async getById(id) {
|
|
155
|
+
if (!id) {
|
|
156
|
+
throw new chunkY3UJVC2L_cjs.PlolinkError("id is required", "INVALID_PARAMS");
|
|
157
|
+
}
|
|
158
|
+
return this.client.axiosInstance.get(`/api/v1/payments/invoice/applications/${id}`);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
exports.InvoiceApplication = InvoiceApplication;
|
|
163
|
+
//# sourceMappingURL=index.cjs.map
|
|
164
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/invoice-application/index.ts"],"names":["PlolinkError"],"mappings":"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","file":"index.cjs","sourcesContent":["/**\n * 发票申请模块\n *\n * @description\n * 提供跨团队发票申请相关功能,包括:\n * - 获取有申请开票权限的团队财务选项\n * - 创建跨团队开票申请\n * - 分页查询申请单列表\n * - 查询申请单详情\n *\n * @example\n * ```typescript\n * import { PlolinkClient } from '@plolink/sdk';\n * import { InvoiceApplication } from '@plolink/sdk/invoice-application';\n *\n * const client = new PlolinkClient({\n * token: 'sk-your-api-key'\n * });\n *\n * const invoiceApp = new InvoiceApplication(client);\n *\n * // 获取可申请开票的团队列表\n * const teams = await invoiceApp.getTeamFinancialOptions();\n *\n * // 创建开票申请\n * const result = await invoiceApp.create({\n * teams: [{ teamId: 'team-1', amount: 1000 }],\n * invoiceType: 'VAT_SPECIAL',\n * invoiceTitle: 'Company Name',\n * taxNumber: '91110000XXX'\n * });\n *\n * // 查询申请单列表\n * const list = await invoiceApp.list({ page: 1, pageSize: 20 });\n *\n * // 查询申请单详情\n * const detail = await invoiceApp.getById(result.id);\n * ```\n *\n * @module invoice-application\n */\n\nimport { PlolinkClient } from '../../core/client';\nimport { PlolinkError } from '../../core/error';\nimport type {\n CreateInvoiceApplicationParams,\n CreateInvoiceApplicationResult,\n ListInvoiceApplicationsParams,\n PaginatedInvoiceApplications,\n InvoiceApplicationDetail,\n TeamFinancialOption,\n} from '../../types/invoice-application';\n\nexport type {\n InvoiceApplicationStatus,\n CreateInvoiceApplicationParams,\n CreateInvoiceApplicationResult,\n ListInvoiceApplicationsParams,\n InvoiceApplicationListItem,\n PaginatedInvoiceApplications,\n InvoiceApplicationDetail,\n TeamFinancialOption,\n} from '../../types/invoice-application';\n\n/**\n * 发票申请模块\n */\nexport class InvoiceApplication {\n private client: PlolinkClient;\n\n constructor(client: PlolinkClient) {\n this.client = client;\n }\n\n /**\n * 获取团队财务选项\n *\n * @description\n * 返回当前用户有申请开票权限的团队列表及其财务信息。\n * 包含每个团队的可开票金额、消费金额、已开票金额和余额。\n *\n * @returns 团队财务选项列表\n * @throws {PlolinkError} 当请求失败时抛出\n *\n * @example\n * ```typescript\n * const teams = await invoiceApp.getTeamFinancialOptions();\n * teams.forEach(team => {\n * console.log(`${team.teamName}: 可开票 ${team.invoiceableAmount}`);\n * });\n * ```\n */\n public async getTeamFinancialOptions(): Promise<TeamFinancialOption[]> {\n return this.client.axiosInstance.get('/api/v1/payments/teams/financial-options');\n }\n\n /**\n * 创建开票申请\n *\n * @description\n * 创建跨团队开票申请。支持同时为多个团队申请开票,\n * 申请单将提交给财务审核。\n *\n * @param params - 开票申请参数\n * @returns 创建结果,包含申请单ID和创建时间\n * @throws {PlolinkError} 当参数无效或创建失败时抛出\n *\n * @example\n * ```typescript\n * // 单团队申请\n * const result = await invoiceApp.create({\n * teams: [{ teamId: 'team-1', amount: 1000 }],\n * invoiceType: 'VAT_SPECIAL',\n * invoiceTitle: 'Test Company Ltd',\n * taxNumber: '91110000XXX',\n * remark: 'January invoice'\n * });\n * console.log(`申请单ID: ${result.id}`);\n *\n * // 跨团队申请\n * const result = await invoiceApp.create({\n * teams: [\n * { teamId: 'team-1', amount: 500 },\n * { teamId: 'team-2', amount: 300 }\n * ],\n * invoiceType: 'VAT_NORMAL',\n * invoiceTitle: 'Test Company Ltd',\n * taxNumber: '91110000XXX'\n * });\n * ```\n */\n public async create(\n params: CreateInvoiceApplicationParams,\n ): Promise<CreateInvoiceApplicationResult> {\n const { teams, invoiceType, invoiceTitle, taxNumber, businessModule, businessCode, businessId, remark } = params;\n\n // 参数验证\n if (!teams || teams.length === 0) {\n throw new PlolinkError('teams is required and must not be empty', 'INVALID_PARAMS');\n }\n\n for (const team of teams) {\n if (!team.teamId) {\n throw new PlolinkError('teamId is required for each team', 'INVALID_PARAMS');\n }\n if (!team.amount || team.amount <= 0) {\n throw new PlolinkError('amount must be greater than 0 for each team', 'INVALID_PARAMS');\n }\n }\n\n if (!invoiceType) {\n throw new PlolinkError('invoiceType is required', 'INVALID_PARAMS');\n }\n\n if (!invoiceTitle) {\n throw new PlolinkError('invoiceTitle is required', 'INVALID_PARAMS');\n }\n\n if (!taxNumber) {\n throw new PlolinkError('taxNumber is required', 'INVALID_PARAMS');\n }\n\n this.client.logger.info('Creating invoice application', {\n teamCount: teams.length,\n totalAmount: teams.reduce((sum, t) => sum + t.amount, 0),\n invoiceType,\n });\n\n return this.client.axiosInstance.post('/api/v1/payments/invoice/applications', {\n teams,\n invoiceType,\n invoiceTitle,\n taxNumber,\n businessModule,\n businessCode,\n businessId,\n remark,\n });\n }\n\n /**\n * 分页查询申请单列表\n *\n * @description\n * 分页查询当前用户提交的发票申请单列表,支持按状态筛选。\n *\n * @param params - 查询参数\n * @returns 分页申请单列表\n * @throws {PlolinkError} 当请求失败时抛出\n *\n * @example\n * ```typescript\n * // 查询所有申请单\n * const result = await invoiceApp.list({ page: 1, pageSize: 20 });\n * console.log(`共 ${result.total} 条申请单`);\n *\n * // 按状态筛选\n * const pending = await invoiceApp.list({ status: 'PENDING' });\n * const approved = await invoiceApp.list({ status: 'APPROVED' });\n * ```\n */\n public async list(\n params: ListInvoiceApplicationsParams = {},\n ): Promise<PaginatedInvoiceApplications> {\n const { page = 1, pageSize = 20, status } = params;\n\n return this.client.axiosInstance.get('/api/v1/payments/invoice/applications', {\n params: { page, pageSize, status },\n });\n }\n\n /**\n * 查询申请单详情\n *\n * @description\n * 根据申请单ID查询详细信息,包括各团队的申请金额和审核状态。\n *\n * @param id - 申请单ID\n * @returns 申请单详情\n * @throws {PlolinkError} 当申请单不存在或请求失败时抛出\n *\n * @example\n * ```typescript\n * const detail = await invoiceApp.getById('application-id');\n * console.log(`状态: ${detail.status}`);\n * console.log(`总金额: ${detail.totalAmount}`);\n * console.log(`发票号: ${detail.invoiceNumber || '未填写'}`);\n *\n * // 查看各团队详情\n * detail.details.forEach(d => {\n * console.log(`${d.teamName}: ${d.amount}`);\n * });\n * ```\n */\n public async getById(id: string): Promise<InvoiceApplicationDetail> {\n if (!id) {\n throw new PlolinkError('id is required', 'INVALID_PARAMS');\n }\n\n return this.client.axiosInstance.get(`/api/v1/payments/invoice/applications/${id}`);\n }\n}\n"]}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { P as PlolinkClient } from '../../client-CAjIQKPm.cjs';
|
|
2
|
+
import '../../core-77EbLgbp.cjs';
|
|
3
|
+
import 'axios';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 发票申请模块类型
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 申请单状态
|
|
10
|
+
*/
|
|
11
|
+
type InvoiceApplicationStatus = 'PENDING' | 'APPROVED' | 'REJECTED';
|
|
12
|
+
/**
|
|
13
|
+
* 创建开票申请参数
|
|
14
|
+
*/
|
|
15
|
+
interface CreateInvoiceApplicationParams {
|
|
16
|
+
/** 团队列表,每个团队包含团队ID和申请金额 */
|
|
17
|
+
teams: Array<{
|
|
18
|
+
/** 团队ID */
|
|
19
|
+
teamId: string;
|
|
20
|
+
/** 申请金额 */
|
|
21
|
+
amount: number;
|
|
22
|
+
}>;
|
|
23
|
+
/** 发票类型 */
|
|
24
|
+
invoiceType: string;
|
|
25
|
+
/** 发票抬头 */
|
|
26
|
+
invoiceTitle: string;
|
|
27
|
+
/** 税号 */
|
|
28
|
+
taxNumber: string;
|
|
29
|
+
/** 业务模块(可选) */
|
|
30
|
+
businessModule?: string;
|
|
31
|
+
/** 业务编码(可选) */
|
|
32
|
+
businessCode?: string;
|
|
33
|
+
/** 业务ID(可选) */
|
|
34
|
+
businessId?: string;
|
|
35
|
+
/** 备注(可选) */
|
|
36
|
+
remark?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 创建开票申请响应
|
|
40
|
+
*/
|
|
41
|
+
interface CreateInvoiceApplicationResult {
|
|
42
|
+
/** 申请单ID */
|
|
43
|
+
id: string;
|
|
44
|
+
/** 创建时间 */
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 申请单列表查询参数
|
|
49
|
+
*/
|
|
50
|
+
interface ListInvoiceApplicationsParams {
|
|
51
|
+
/** 页码,从1开始,默认1 */
|
|
52
|
+
page?: number;
|
|
53
|
+
/** 每页条数,默认20 */
|
|
54
|
+
pageSize?: number;
|
|
55
|
+
/** 申请单状态筛选 */
|
|
56
|
+
status?: InvoiceApplicationStatus;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 申请单列表项
|
|
60
|
+
*/
|
|
61
|
+
interface InvoiceApplicationListItem {
|
|
62
|
+
/** 申请单ID */
|
|
63
|
+
id: string;
|
|
64
|
+
/** 总金额 */
|
|
65
|
+
totalAmount: string;
|
|
66
|
+
/** 发票抬头 */
|
|
67
|
+
invoiceTitle: string;
|
|
68
|
+
/** 申请单状态 */
|
|
69
|
+
status: InvoiceApplicationStatus;
|
|
70
|
+
/** 创建时间 */
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
/** 涉及团队数量 */
|
|
73
|
+
teamCount: number;
|
|
74
|
+
/** 业务模块 */
|
|
75
|
+
businessModule: string;
|
|
76
|
+
/** 业务编码 */
|
|
77
|
+
businessCode: string;
|
|
78
|
+
/** 业务ID */
|
|
79
|
+
businessId: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 分页申请单列表结果
|
|
83
|
+
*/
|
|
84
|
+
interface PaginatedInvoiceApplications {
|
|
85
|
+
/** 申请单列表 */
|
|
86
|
+
list: InvoiceApplicationListItem[];
|
|
87
|
+
/** 总条数 */
|
|
88
|
+
total: number;
|
|
89
|
+
/** 当前页码 */
|
|
90
|
+
page: number;
|
|
91
|
+
/** 每页条数 */
|
|
92
|
+
pageSize: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 申请单详情中的团队信息
|
|
96
|
+
*/
|
|
97
|
+
interface InvoiceApplicationTeamDetail {
|
|
98
|
+
/** 团队ID */
|
|
99
|
+
teamId: string;
|
|
100
|
+
/** 团队名称 */
|
|
101
|
+
teamName: string;
|
|
102
|
+
/** 申请金额 */
|
|
103
|
+
amount: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 申请单详情
|
|
107
|
+
*/
|
|
108
|
+
interface InvoiceApplicationDetail {
|
|
109
|
+
/** 申请单ID */
|
|
110
|
+
id: string;
|
|
111
|
+
/** 申请单状态 */
|
|
112
|
+
status: InvoiceApplicationStatus;
|
|
113
|
+
/** 发票类型 */
|
|
114
|
+
invoiceType: string;
|
|
115
|
+
/** 发票抬头 */
|
|
116
|
+
invoiceTitle: string;
|
|
117
|
+
/** 税号 */
|
|
118
|
+
taxNumber: string;
|
|
119
|
+
/** 总金额 */
|
|
120
|
+
totalAmount: string;
|
|
121
|
+
/** 业务模块 */
|
|
122
|
+
businessModule: string;
|
|
123
|
+
/** 业务编码 */
|
|
124
|
+
businessCode: string;
|
|
125
|
+
/** 业务ID */
|
|
126
|
+
businessId: string;
|
|
127
|
+
/** 备注 */
|
|
128
|
+
remark: string;
|
|
129
|
+
/** 发票号(审核通过后填写) */
|
|
130
|
+
invoiceNumber: string;
|
|
131
|
+
/** 发票文件Key(审核通过后填写) */
|
|
132
|
+
fileKey: string;
|
|
133
|
+
/** 审核人ID */
|
|
134
|
+
reviewerId: string;
|
|
135
|
+
/** 审核时间 */
|
|
136
|
+
reviewedAt: Date | null;
|
|
137
|
+
/** 创建时间 */
|
|
138
|
+
createdAt: Date;
|
|
139
|
+
/** 团队详情列表 */
|
|
140
|
+
details: InvoiceApplicationTeamDetail[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 团队财务选项
|
|
144
|
+
*/
|
|
145
|
+
interface TeamFinancialOption {
|
|
146
|
+
/** 团队ID */
|
|
147
|
+
teamId: string;
|
|
148
|
+
/** 团队名称 */
|
|
149
|
+
teamName: string;
|
|
150
|
+
/** 可开票金额 */
|
|
151
|
+
invoiceableAmount: string;
|
|
152
|
+
/** 消费金额 */
|
|
153
|
+
consumptionAmount: string;
|
|
154
|
+
/** 已开票金额 */
|
|
155
|
+
invoicedAmount: string;
|
|
156
|
+
/** 余额 */
|
|
157
|
+
balance: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 发票申请模块
|
|
162
|
+
*
|
|
163
|
+
* @description
|
|
164
|
+
* 提供跨团队发票申请相关功能,包括:
|
|
165
|
+
* - 获取有申请开票权限的团队财务选项
|
|
166
|
+
* - 创建跨团队开票申请
|
|
167
|
+
* - 分页查询申请单列表
|
|
168
|
+
* - 查询申请单详情
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* import { PlolinkClient } from '@plolink/sdk';
|
|
173
|
+
* import { InvoiceApplication } from '@plolink/sdk/invoice-application';
|
|
174
|
+
*
|
|
175
|
+
* const client = new PlolinkClient({
|
|
176
|
+
* token: 'sk-your-api-key'
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* const invoiceApp = new InvoiceApplication(client);
|
|
180
|
+
*
|
|
181
|
+
* // 获取可申请开票的团队列表
|
|
182
|
+
* const teams = await invoiceApp.getTeamFinancialOptions();
|
|
183
|
+
*
|
|
184
|
+
* // 创建开票申请
|
|
185
|
+
* const result = await invoiceApp.create({
|
|
186
|
+
* teams: [{ teamId: 'team-1', amount: 1000 }],
|
|
187
|
+
* invoiceType: 'VAT_SPECIAL',
|
|
188
|
+
* invoiceTitle: 'Company Name',
|
|
189
|
+
* taxNumber: '91110000XXX'
|
|
190
|
+
* });
|
|
191
|
+
*
|
|
192
|
+
* // 查询申请单列表
|
|
193
|
+
* const list = await invoiceApp.list({ page: 1, pageSize: 20 });
|
|
194
|
+
*
|
|
195
|
+
* // 查询申请单详情
|
|
196
|
+
* const detail = await invoiceApp.getById(result.id);
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* @module invoice-application
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 发票申请模块
|
|
204
|
+
*/
|
|
205
|
+
declare class InvoiceApplication {
|
|
206
|
+
private client;
|
|
207
|
+
constructor(client: PlolinkClient);
|
|
208
|
+
/**
|
|
209
|
+
* 获取团队财务选项
|
|
210
|
+
*
|
|
211
|
+
* @description
|
|
212
|
+
* 返回当前用户有申请开票权限的团队列表及其财务信息。
|
|
213
|
+
* 包含每个团队的可开票金额、消费金额、已开票金额和余额。
|
|
214
|
+
*
|
|
215
|
+
* @returns 团队财务选项列表
|
|
216
|
+
* @throws {PlolinkError} 当请求失败时抛出
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* const teams = await invoiceApp.getTeamFinancialOptions();
|
|
221
|
+
* teams.forEach(team => {
|
|
222
|
+
* console.log(`${team.teamName}: 可开票 ${team.invoiceableAmount}`);
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
getTeamFinancialOptions(): Promise<TeamFinancialOption[]>;
|
|
227
|
+
/**
|
|
228
|
+
* 创建开票申请
|
|
229
|
+
*
|
|
230
|
+
* @description
|
|
231
|
+
* 创建跨团队开票申请。支持同时为多个团队申请开票,
|
|
232
|
+
* 申请单将提交给财务审核。
|
|
233
|
+
*
|
|
234
|
+
* @param params - 开票申请参数
|
|
235
|
+
* @returns 创建结果,包含申请单ID和创建时间
|
|
236
|
+
* @throws {PlolinkError} 当参数无效或创建失败时抛出
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* // 单团队申请
|
|
241
|
+
* const result = await invoiceApp.create({
|
|
242
|
+
* teams: [{ teamId: 'team-1', amount: 1000 }],
|
|
243
|
+
* invoiceType: 'VAT_SPECIAL',
|
|
244
|
+
* invoiceTitle: 'Test Company Ltd',
|
|
245
|
+
* taxNumber: '91110000XXX',
|
|
246
|
+
* remark: 'January invoice'
|
|
247
|
+
* });
|
|
248
|
+
* console.log(`申请单ID: ${result.id}`);
|
|
249
|
+
*
|
|
250
|
+
* // 跨团队申请
|
|
251
|
+
* const result = await invoiceApp.create({
|
|
252
|
+
* teams: [
|
|
253
|
+
* { teamId: 'team-1', amount: 500 },
|
|
254
|
+
* { teamId: 'team-2', amount: 300 }
|
|
255
|
+
* ],
|
|
256
|
+
* invoiceType: 'VAT_NORMAL',
|
|
257
|
+
* invoiceTitle: 'Test Company Ltd',
|
|
258
|
+
* taxNumber: '91110000XXX'
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
create(params: CreateInvoiceApplicationParams): Promise<CreateInvoiceApplicationResult>;
|
|
263
|
+
/**
|
|
264
|
+
* 分页查询申请单列表
|
|
265
|
+
*
|
|
266
|
+
* @description
|
|
267
|
+
* 分页查询当前用户提交的发票申请单列表,支持按状态筛选。
|
|
268
|
+
*
|
|
269
|
+
* @param params - 查询参数
|
|
270
|
+
* @returns 分页申请单列表
|
|
271
|
+
* @throws {PlolinkError} 当请求失败时抛出
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* // 查询所有申请单
|
|
276
|
+
* const result = await invoiceApp.list({ page: 1, pageSize: 20 });
|
|
277
|
+
* console.log(`共 ${result.total} 条申请单`);
|
|
278
|
+
*
|
|
279
|
+
* // 按状态筛选
|
|
280
|
+
* const pending = await invoiceApp.list({ status: 'PENDING' });
|
|
281
|
+
* const approved = await invoiceApp.list({ status: 'APPROVED' });
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
list(params?: ListInvoiceApplicationsParams): Promise<PaginatedInvoiceApplications>;
|
|
285
|
+
/**
|
|
286
|
+
* 查询申请单详情
|
|
287
|
+
*
|
|
288
|
+
* @description
|
|
289
|
+
* 根据申请单ID查询详细信息,包括各团队的申请金额和审核状态。
|
|
290
|
+
*
|
|
291
|
+
* @param id - 申请单ID
|
|
292
|
+
* @returns 申请单详情
|
|
293
|
+
* @throws {PlolinkError} 当申请单不存在或请求失败时抛出
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* const detail = await invoiceApp.getById('application-id');
|
|
298
|
+
* console.log(`状态: ${detail.status}`);
|
|
299
|
+
* console.log(`总金额: ${detail.totalAmount}`);
|
|
300
|
+
* console.log(`发票号: ${detail.invoiceNumber || '未填写'}`);
|
|
301
|
+
*
|
|
302
|
+
* // 查看各团队详情
|
|
303
|
+
* detail.details.forEach(d => {
|
|
304
|
+
* console.log(`${d.teamName}: ${d.amount}`);
|
|
305
|
+
* });
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
getById(id: string): Promise<InvoiceApplicationDetail>;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export { type CreateInvoiceApplicationParams, type CreateInvoiceApplicationResult, InvoiceApplication, type InvoiceApplicationDetail, type InvoiceApplicationListItem, type InvoiceApplicationStatus, type ListInvoiceApplicationsParams, type PaginatedInvoiceApplications, type TeamFinancialOption };
|