gm-mcp 1.1.1 → 1.1.3
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/index.js +4 -2
- package/dist/services/lark-base.service.d.ts +12 -2
- package/dist/services/lark-base.service.js +32 -6
- package/dist/services/lark.service.js +1 -1
- package/dist/test.js +5 -3
- package/dist/tools/lark-tool.js +32 -11
- package/package.json +1 -1
- package/src/index.ts +5 -2
- package/src/services/lark-base.service.ts +51 -9
- package/src/services/lark.service.ts +1 -1
- package/src/test.ts +8 -4
- package/src/tools/lark-tool.ts +43 -12
package/dist/index.js
CHANGED
|
@@ -69,8 +69,10 @@ exports.server.tool("statistic_salary_x3_in_range", "Get statistic salary x3 wit
|
|
|
69
69
|
sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK,
|
|
70
70
|
});
|
|
71
71
|
}));
|
|
72
|
-
exports.server.tool("debt_collection_by_month", "The company's debt collection
|
|
73
|
-
month: zod_1.default.string({
|
|
72
|
+
exports.server.tool("debt_collection_by_month", "The company's debt collection information by month", {
|
|
73
|
+
month: zod_1.default.string({
|
|
74
|
+
description: "Month to get data,if year is not provided, please use current year (in Vietnam timezone) instead of, month must be represented with format MM/yyyy",
|
|
75
|
+
}),
|
|
74
76
|
company_name: zod_1.default.string({ description: "Company name to get data" }),
|
|
75
77
|
}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
78
|
const { month, company_name } = args;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { LarkRecord } from "./types/lark.type";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function fetchLarkBaseRecords(p: {
|
|
3
3
|
view_id: string;
|
|
4
4
|
field_names: string[];
|
|
5
|
-
|
|
5
|
+
app_token: string;
|
|
6
|
+
table_id: string;
|
|
7
|
+
page_size: number;
|
|
8
|
+
page_token?: string;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
items: LarkRecord[];
|
|
11
|
+
page_token: string;
|
|
12
|
+
has_more: boolean;
|
|
13
|
+
total: number;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function fetchDebtCollectionRecords(page_token?: string): Promise<LarkRecord[]>;
|
|
@@ -12,22 +12,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.fetchLarkBaseRecords = fetchLarkBaseRecords;
|
|
16
|
+
exports.fetchDebtCollectionRecords = fetchDebtCollectionRecords;
|
|
16
17
|
const axios_1 = __importDefault(require("axios"));
|
|
17
18
|
const lark_service_1 = require("./lark.service");
|
|
18
|
-
|
|
19
|
+
const report_columns_1 = require("./constants/report-columns");
|
|
20
|
+
// Must replace by env config later
|
|
21
|
+
const DEBT_COLLECTION_VIEW_ID = "vewI23hNnx";
|
|
22
|
+
const DEBT_COLLECTION_TABLE_ID = "tblQGKjGd8MnK5qs";
|
|
23
|
+
const DEBT_COLLECTION_APP_TOKEN = "V5akbIXqfaBvXqs8twfl6rALgLd";
|
|
24
|
+
function fetchLarkBaseRecords(p) {
|
|
19
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
26
|
const access_token = yield (0, lark_service_1.getLarkTenantAccessToken)();
|
|
27
|
+
const { view_id, table_id, app_token, field_names, page_size, page_token } = p;
|
|
21
28
|
const appToken = "V5akbIXqfaBvXqs8twfl6rALgLd";
|
|
22
29
|
const tableId = "tblQGKjGd8MnK5qs";
|
|
23
|
-
const url = `https://open.larksuite.com/open-apis/bitable/v1/apps/${
|
|
30
|
+
const url = `https://open.larksuite.com/open-apis/bitable/v1/apps/${app_token}/tables/${table_id}/records/search`;
|
|
24
31
|
return axios_1.default
|
|
25
|
-
.post(url,
|
|
26
|
-
params: { page_size
|
|
32
|
+
.post(url, { view_id, field_names }, {
|
|
33
|
+
params: { page_size, page_token },
|
|
27
34
|
headers: {
|
|
28
35
|
Authorization: "Bearer " + access_token,
|
|
29
36
|
},
|
|
30
37
|
})
|
|
31
|
-
.then((res) => res.data.data
|
|
38
|
+
.then((res) => res.data.data);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function fetchDebtCollectionRecords(page_token) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const fieldNames = report_columns_1.REPORT_COLUMS.map((item) => item.field_name);
|
|
44
|
+
const { has_more, items, page_token: nextPageToken, total, } = yield fetchLarkBaseRecords({
|
|
45
|
+
view_id: DEBT_COLLECTION_VIEW_ID,
|
|
46
|
+
field_names: fieldNames,
|
|
47
|
+
app_token: DEBT_COLLECTION_APP_TOKEN,
|
|
48
|
+
table_id: DEBT_COLLECTION_TABLE_ID,
|
|
49
|
+
page_size: 500,
|
|
50
|
+
page_token: page_token,
|
|
51
|
+
});
|
|
52
|
+
console.log(total);
|
|
53
|
+
if (!has_more) {
|
|
54
|
+
return items;
|
|
55
|
+
}
|
|
56
|
+
const result = [...items];
|
|
57
|
+
return result.concat(yield fetchDebtCollectionRecords(nextPageToken));
|
|
32
58
|
});
|
|
33
59
|
}
|
|
@@ -146,7 +146,7 @@ function sendReportOpsGroup(data) {
|
|
|
146
146
|
const messageContent = {
|
|
147
147
|
type: "template",
|
|
148
148
|
data: {
|
|
149
|
-
template_id:
|
|
149
|
+
template_id: DEBT_COLLECTION_CARD_ID,
|
|
150
150
|
// template_id: 'ctp_AAdI5Sp48YUT',
|
|
151
151
|
template_variable: {
|
|
152
152
|
title,
|
package/dist/test.js
CHANGED
|
@@ -14,9 +14,11 @@ const lark_tool_1 = require("./tools/lark-tool");
|
|
|
14
14
|
function setupTest() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
(0, env_1.ensureEnvVariables)();
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
17
|
+
// const r = await fetchDebtCollectionRecords();
|
|
18
|
+
// console.log(r.length);
|
|
19
|
+
// const compnay = "BGG";
|
|
20
|
+
// const month = "12/2025";
|
|
21
|
+
const res = yield (0, lark_tool_1.debtCollectionRateTool)({ sendMessageToLark: true, companyName: 'SHYANG', monthDate: '07/2025' });
|
|
20
22
|
console.log(res);
|
|
21
23
|
// const fieldNames = REPORT_COLUMS.map((item) => item.field_name);
|
|
22
24
|
// try {
|
package/dist/tools/lark-tool.js
CHANGED
|
@@ -18,6 +18,9 @@ const lark_service_1 = require("../services/lark.service");
|
|
|
18
18
|
const companyKey = "CÔNG TY";
|
|
19
19
|
const preiodKey = "KỲ LƯƠNG";
|
|
20
20
|
const debtCollectionRateKey = "TỈ LỆ THU NỢ";
|
|
21
|
+
const debReductionMonthKey = "THÁNG CẮT NỢ";
|
|
22
|
+
const productKey = "Loại Sản phẩm";
|
|
23
|
+
const monthReductionDebtKey = "THÁNG CẮT NỢ";
|
|
21
24
|
function debtCollectionRateTool(options) {
|
|
22
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
26
|
const { sendMessageToLark, companyName, monthDate } = options;
|
|
@@ -28,28 +31,38 @@ function debtCollectionRateTool(options) {
|
|
|
28
31
|
const { month, year } = monthParts;
|
|
29
32
|
const fieldNames = report_columns_1.REPORT_COLUMS.map((item) => item.field_name);
|
|
30
33
|
try {
|
|
31
|
-
const records = yield (0, lark_base_service_1.
|
|
34
|
+
const records = yield (0, lark_base_service_1.fetchDebtCollectionRecords)();
|
|
32
35
|
// console.log(records);
|
|
33
36
|
// Find by name first
|
|
34
|
-
const companyNames = records.map((item) => (item.fields[
|
|
37
|
+
const companyNames = records.map((item) => (item.fields[companyKey] || ""));
|
|
35
38
|
// console.log(companyNames);
|
|
36
39
|
// const searchTems = "DENKO";
|
|
37
40
|
// const monthTerm = "12";
|
|
38
41
|
const foundName = (0, search_like_1.searchLike)(companyName, companyNames)[0];
|
|
39
|
-
const companiesMatchName = records.filter((item) => item.fields[
|
|
42
|
+
const companiesMatchName = records.filter((item) => item.fields[companyKey] === foundName);
|
|
40
43
|
// console.log(companiesMatchName);
|
|
41
|
-
// Find by
|
|
44
|
+
// Find by debt reduction month, search fully match
|
|
45
|
+
const foundMonths = companiesMatchName.filter((item) => compareReductionDebtMonth(item.fields[debReductionMonthKey], month.toString()));
|
|
42
46
|
const foundMonth = (0, search_like_1.searchLike)(month.toString(), companiesMatchName.map((item) => item.fields["KỲ LƯƠNG"]))[0];
|
|
43
|
-
console.log(
|
|
47
|
+
console.log(foundMonths);
|
|
44
48
|
const finalCompnay = companiesMatchName.find((item) => item.fields["KỲ LƯƠNG"] === foundMonth);
|
|
49
|
+
// console.log(finalCompnay);
|
|
50
|
+
const messages = [];
|
|
51
|
+
for (const item of foundMonths) {
|
|
52
|
+
messages.push([
|
|
53
|
+
`Sản phẩm: ${item.fields[productKey] || "N/A"}`,
|
|
54
|
+
`Kỳ lương: ${(item === null || item === void 0 ? void 0 : item.fields[preiodKey]) || "N/A"}`,
|
|
55
|
+
`Tháng cắt nợ: ${item.fields[monthReductionDebtKey] || "N/A"}`,
|
|
56
|
+
`Tỷ lệ thu nợ: ${typeof item.fields[debtCollectionRateKey] === "undefined"
|
|
57
|
+
? "N/A"
|
|
58
|
+
: round(Number(item.fields[debtCollectionRateKey]))}%`,
|
|
59
|
+
].join("<br>"));
|
|
60
|
+
}
|
|
61
|
+
// return {} as any;
|
|
45
62
|
if (sendMessageToLark) {
|
|
46
63
|
yield (0, lark_service_1.sendReportOpsGroup)({
|
|
47
|
-
title:
|
|
48
|
-
message_content:
|
|
49
|
-
`Công ty: ${(finalCompnay === null || finalCompnay === void 0 ? void 0 : finalCompnay.fields[companyKey]) || "N/A"}`,
|
|
50
|
-
`Kỳ lương: ${(finalCompnay === null || finalCompnay === void 0 ? void 0 : finalCompnay.fields[preiodKey]) || "N/A"}`,
|
|
51
|
-
`Tỷ lệ thu nợ: ${Number(finalCompnay === null || finalCompnay === void 0 ? void 0 : finalCompnay.fields[debtCollectionRateKey]) * 100}%`,
|
|
52
|
-
].join("<hr>"),
|
|
64
|
+
title: `Tỉ lệ thu nợ - ${foundName}`,
|
|
65
|
+
message_content: messages.join("<hr>"),
|
|
53
66
|
});
|
|
54
67
|
}
|
|
55
68
|
return { content: [{ type: "text", text: JSON.stringify(finalCompnay) }] };
|
|
@@ -60,3 +73,11 @@ function debtCollectionRateTool(options) {
|
|
|
60
73
|
}
|
|
61
74
|
});
|
|
62
75
|
}
|
|
76
|
+
function compareReductionDebtMonth(a, b) {
|
|
77
|
+
const _a = a.toLowerCase().trim().replace("tháng", "");
|
|
78
|
+
const _b = b.toLowerCase().trim().replace("tháng", "");
|
|
79
|
+
return parseInt(_a, 10) === parseInt(_b, 10);
|
|
80
|
+
}
|
|
81
|
+
function round(x) {
|
|
82
|
+
return Math.round(x * 10000) / 100;
|
|
83
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -91,9 +91,12 @@ server.tool(
|
|
|
91
91
|
|
|
92
92
|
server.tool(
|
|
93
93
|
"debt_collection_by_month",
|
|
94
|
-
"The company's debt collection
|
|
94
|
+
"The company's debt collection information by month",
|
|
95
95
|
{
|
|
96
|
-
month: z.string({
|
|
96
|
+
month: z.string({
|
|
97
|
+
description:
|
|
98
|
+
"Month to get data,if year is not provided, please use current year (in Vietnam timezone) instead of, month must be represented with format MM/yyyy",
|
|
99
|
+
}),
|
|
97
100
|
company_name: z.string({ description: "Company name to get data" }),
|
|
98
101
|
},
|
|
99
102
|
async (args) => {
|
|
@@ -1,18 +1,60 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { LarkRecord } from "./types/lark.type";
|
|
3
3
|
import { getLarkTenantAccessToken } from "./lark.service";
|
|
4
|
+
import { REPORT_COLUMS } from "./constants/report-columns";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
// Must replace by env config later
|
|
7
|
+
const DEBT_COLLECTION_VIEW_ID = "vewI23hNnx";
|
|
8
|
+
const DEBT_COLLECTION_TABLE_ID = "tblQGKjGd8MnK5qs";
|
|
9
|
+
const DEBT_COLLECTION_APP_TOKEN = "V5akbIXqfaBvXqs8twfl6rALgLd";
|
|
10
|
+
|
|
11
|
+
export async function fetchLarkBaseRecords(p: {
|
|
12
|
+
view_id: string;
|
|
13
|
+
field_names: string[];
|
|
14
|
+
app_token: string;
|
|
15
|
+
table_id: string;
|
|
16
|
+
page_size: number;
|
|
17
|
+
page_token?: string;
|
|
18
|
+
}) {
|
|
6
19
|
const access_token = await getLarkTenantAccessToken();
|
|
20
|
+
const { view_id, table_id, app_token, field_names, page_size, page_token } = p;
|
|
7
21
|
const appToken = "V5akbIXqfaBvXqs8twfl6rALgLd";
|
|
8
22
|
const tableId = "tblQGKjGd8MnK5qs";
|
|
9
|
-
const url = `https://open.larksuite.com/open-apis/bitable/v1/apps/${
|
|
23
|
+
const url = `https://open.larksuite.com/open-apis/bitable/v1/apps/${app_token}/tables/${table_id}/records/search`;
|
|
10
24
|
return axios
|
|
11
|
-
.post<{ data: { items: LarkRecord[] } }>(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
.post<{ data: { items: LarkRecord[]; page_token: string; has_more: boolean; total: number } }>(
|
|
26
|
+
url,
|
|
27
|
+
{ view_id, field_names },
|
|
28
|
+
{
|
|
29
|
+
params: { page_size, page_token },
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: "Bearer " + access_token,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
.then((res) => res.data.data);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function fetchDebtCollectionRecords(page_token?: string): Promise<LarkRecord[]> {
|
|
39
|
+
const fieldNames = REPORT_COLUMS.map((item) => item.field_name);
|
|
40
|
+
const {
|
|
41
|
+
has_more,
|
|
42
|
+
items,
|
|
43
|
+
page_token: nextPageToken,
|
|
44
|
+
total,
|
|
45
|
+
} = await fetchLarkBaseRecords({
|
|
46
|
+
view_id: DEBT_COLLECTION_VIEW_ID,
|
|
47
|
+
field_names: fieldNames,
|
|
48
|
+
app_token: DEBT_COLLECTION_APP_TOKEN,
|
|
49
|
+
table_id: DEBT_COLLECTION_TABLE_ID,
|
|
50
|
+
page_size: 500,
|
|
51
|
+
page_token: page_token,
|
|
52
|
+
});
|
|
53
|
+
console.log(total);
|
|
54
|
+
|
|
55
|
+
if (!has_more) {
|
|
56
|
+
return items;
|
|
57
|
+
}
|
|
58
|
+
const result: LarkRecord[] = [...items];
|
|
59
|
+
return result.concat(await fetchDebtCollectionRecords(nextPageToken));
|
|
18
60
|
}
|
|
@@ -104,7 +104,7 @@ export async function sendReportOpsGroup(data: { title: string; message_content:
|
|
|
104
104
|
const messageContent = {
|
|
105
105
|
type: "template",
|
|
106
106
|
data: {
|
|
107
|
-
template_id:
|
|
107
|
+
template_id: DEBT_COLLECTION_CARD_ID,
|
|
108
108
|
// template_id: 'ctp_AAdI5Sp48YUT',
|
|
109
109
|
template_variable: {
|
|
110
110
|
title,
|
package/src/test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureEnvVariables, getEnv } from "./env";
|
|
2
2
|
import { searchLike } from "./helpers/search-like";
|
|
3
3
|
import { REPORT_COLUMS } from "./services/constants/report-columns";
|
|
4
|
-
import {
|
|
4
|
+
import { fetchDebtCollectionRecords, fetchLarkBaseRecords } from "./services/lark-base.service";
|
|
5
5
|
import { sendLarkTextMessage, sendMessageToX3Group } from "./services/lark.service";
|
|
6
6
|
import {
|
|
7
7
|
statisticX3RangeTool,
|
|
@@ -14,9 +14,13 @@ import { debtCollectionRateTool } from "./tools/lark-tool";
|
|
|
14
14
|
|
|
15
15
|
async function setupTest() {
|
|
16
16
|
ensureEnvVariables();
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
17
|
+
|
|
18
|
+
// const r = await fetchDebtCollectionRecords();
|
|
19
|
+
// console.log(r.length);
|
|
20
|
+
|
|
21
|
+
// const compnay = "BGG";
|
|
22
|
+
// const month = "12/2025";
|
|
23
|
+
const res = await debtCollectionRateTool({ sendMessageToLark: true, companyName: 'SHYANG', monthDate: '07/2025' });
|
|
20
24
|
console.log(res);
|
|
21
25
|
|
|
22
26
|
// const fieldNames = REPORT_COLUMS.map((item) => item.field_name);
|
package/src/tools/lark-tool.ts
CHANGED
|
@@ -2,12 +2,15 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types";
|
|
|
2
2
|
import { extractMonth } from "../helpers";
|
|
3
3
|
import { searchLike } from "../helpers/search-like";
|
|
4
4
|
import { REPORT_COLUMS } from "../services/constants/report-columns";
|
|
5
|
-
import {
|
|
5
|
+
import { fetchDebtCollectionRecords, fetchLarkBaseRecords } from "../services/lark-base.service";
|
|
6
6
|
import { sendReportOpsGroup } from "../services/lark.service";
|
|
7
7
|
|
|
8
8
|
const companyKey = "CÔNG TY";
|
|
9
9
|
const preiodKey = "KỲ LƯƠNG";
|
|
10
10
|
const debtCollectionRateKey = "TỈ LỆ THU NỢ";
|
|
11
|
+
const debReductionMonthKey = "THÁNG CẮT NỢ";
|
|
12
|
+
const productKey = "Loại Sản phẩm";
|
|
13
|
+
const monthReductionDebtKey = "THÁNG CẮT NỢ";
|
|
11
14
|
|
|
12
15
|
export async function debtCollectionRateTool(options: {
|
|
13
16
|
sendMessageToLark: boolean;
|
|
@@ -22,34 +25,52 @@ export async function debtCollectionRateTool(options: {
|
|
|
22
25
|
const { month, year } = monthParts;
|
|
23
26
|
const fieldNames = REPORT_COLUMS.map((item) => item.field_name);
|
|
24
27
|
try {
|
|
25
|
-
const records = await
|
|
28
|
+
const records = await fetchDebtCollectionRecords();
|
|
26
29
|
// console.log(records);
|
|
27
30
|
|
|
28
31
|
// Find by name first
|
|
29
|
-
const companyNames = records.map((item) => (item.fields[
|
|
32
|
+
const companyNames = records.map((item) => (item.fields[companyKey] || "") as string);
|
|
30
33
|
// console.log(companyNames);
|
|
31
34
|
// const searchTems = "DENKO";
|
|
32
35
|
// const monthTerm = "12";
|
|
33
36
|
const foundName = searchLike(companyName, companyNames)[0];
|
|
34
|
-
const companiesMatchName = records.filter((item) => item.fields[
|
|
37
|
+
const companiesMatchName = records.filter((item) => item.fields[companyKey] === foundName);
|
|
35
38
|
// console.log(companiesMatchName);
|
|
36
39
|
|
|
37
|
-
// Find by
|
|
40
|
+
// Find by debt reduction month, search fully match
|
|
41
|
+
const foundMonths = companiesMatchName.filter((item) =>
|
|
42
|
+
compareReductionDebtMonth(item.fields[debReductionMonthKey], month.toString())
|
|
43
|
+
);
|
|
38
44
|
const foundMonth = searchLike(
|
|
39
45
|
month.toString(),
|
|
40
46
|
companiesMatchName.map((item) => item.fields["KỲ LƯƠNG"])
|
|
41
47
|
)[0];
|
|
42
|
-
console.log(
|
|
48
|
+
console.log(foundMonths);
|
|
43
49
|
const finalCompnay = companiesMatchName.find((item) => item.fields["KỲ LƯƠNG"] === foundMonth);
|
|
50
|
+
// console.log(finalCompnay);
|
|
51
|
+
|
|
52
|
+
const messages: string[] = [];
|
|
53
|
+
for (const item of foundMonths) {
|
|
54
|
+
messages.push(
|
|
55
|
+
[
|
|
56
|
+
`Sản phẩm: ${item.fields[productKey] || "N/A"}`,
|
|
57
|
+
`Kỳ lương: ${item?.fields[preiodKey] || "N/A"}`,
|
|
58
|
+
`Tháng cắt nợ: ${item.fields[monthReductionDebtKey] || "N/A"}`,
|
|
59
|
+
`Tỷ lệ thu nợ: ${
|
|
60
|
+
typeof item.fields[debtCollectionRateKey] === "undefined"
|
|
61
|
+
? "N/A"
|
|
62
|
+
: round(Number(item.fields[debtCollectionRateKey]))
|
|
63
|
+
}%`,
|
|
64
|
+
].join("<br>")
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// return {} as any;
|
|
44
69
|
|
|
45
70
|
if (sendMessageToLark) {
|
|
46
71
|
await sendReportOpsGroup({
|
|
47
|
-
title:
|
|
48
|
-
message_content:
|
|
49
|
-
`Công ty: ${finalCompnay?.fields[companyKey] || "N/A"}`,
|
|
50
|
-
`Kỳ lương: ${finalCompnay?.fields[preiodKey] || "N/A"}`,
|
|
51
|
-
`Tỷ lệ thu nợ: ${Number(finalCompnay?.fields[debtCollectionRateKey]) * 100}%`,
|
|
52
|
-
].join("<hr>"),
|
|
72
|
+
title: `Tỉ lệ thu nợ - ${foundName}`,
|
|
73
|
+
message_content: messages.join("<hr>"),
|
|
53
74
|
});
|
|
54
75
|
}
|
|
55
76
|
return { content: [{ type: "text", text: JSON.stringify(finalCompnay) }] };
|
|
@@ -58,3 +79,13 @@ export async function debtCollectionRateTool(options: {
|
|
|
58
79
|
return { content: [{ type: "text", text: JSON.stringify(e) }] };
|
|
59
80
|
}
|
|
60
81
|
}
|
|
82
|
+
|
|
83
|
+
function compareReductionDebtMonth(a: string, b: string) {
|
|
84
|
+
const _a = a.toLowerCase().trim().replace("tháng", "");
|
|
85
|
+
const _b = b.toLowerCase().trim().replace("tháng", "");
|
|
86
|
+
return parseInt(_a, 10) === parseInt(_b, 10);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function round(x: number) {
|
|
90
|
+
return Math.round(x * 10000) / 100;
|
|
91
|
+
}
|