tally-xml-tdl 1.21.1 → 1.21.2
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/package.json +1 -1
- package/src/index.js +42 -42
- package/src/v21/company/index.js +7 -7
- package/src/v21/core/execute/index.js +4 -4
- package/src/v21/core/index.js +22 -22
- package/src/v21/createApi.js +74 -64
- package/src/v21/index.js +6 -6
- package/src/v21/masters/index.js +30 -7
- package/src/v21/vouchers/index.js +5 -5
- package/src/v21/vouchers/purchases/index.js +7 -7
- package/src/v21/vouchers/sales/index.js +7 -7
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { readdirSync, existsSync } from "node:fs";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
|
|
5
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
|
|
7
|
-
// 1. Discover all version directories (v1, v2, ... vN) sorted highest first
|
|
8
|
-
const versionFolders = readdirSync(__dirname, { withFileTypes: true })
|
|
9
|
-
.filter(entry => entry.isDirectory() && /^v\d+$/.test(entry.name))
|
|
10
|
-
.map(entry => ({ name: entry.name, n: Number(entry.name.slice(1)) }))
|
|
11
|
-
.sort((a, b) => b.n - a.n);
|
|
12
|
-
|
|
13
|
-
const latestVersion = versionFolders[0]?.name || "v17";
|
|
14
|
-
|
|
15
|
-
let company;
|
|
16
|
-
let masters;
|
|
17
|
-
let vouchers;
|
|
18
|
-
|
|
19
|
-
const versionIndexPath = resolve(__dirname, latestVersion, "index.js");
|
|
20
|
-
|
|
21
|
-
if (existsSync(versionIndexPath)) {
|
|
22
|
-
const versionModule = await import(pathToFileURL(versionIndexPath).href);
|
|
23
|
-
company = versionModule.company ?? versionModule.default;
|
|
24
|
-
masters = versionModule.masters;
|
|
25
|
-
vouchers = versionModule.vouchers;
|
|
26
|
-
} else {
|
|
27
|
-
const mainUrl = pathToFileURL(resolve(__dirname, latestVersion, "main.js")).href;
|
|
28
|
-
const mastersUrl = pathToFileURL(resolve(__dirname, latestVersion, "masters", "index.js")).href;
|
|
29
|
-
const vouchersUrl = pathToFileURL(resolve(__dirname, latestVersion, "vouchers", "index.js")).href;
|
|
30
|
-
|
|
31
|
-
const [mainModule, mastersModule, vouchersModule] = await Promise.all([
|
|
32
|
-
import(mainUrl),
|
|
33
|
-
import(mastersUrl),
|
|
34
|
-
import(vouchersUrl)
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
company = mainModule.company ?? mainModule.default;
|
|
38
|
-
masters = mastersModule;
|
|
39
|
-
vouchers = vouchersModule;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { company, masters, vouchers, latestVersion as version };
|
|
1
|
+
import { readdirSync, existsSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
// 1. Discover all version directories (v1, v2, ... vN) sorted highest first
|
|
8
|
+
const versionFolders = readdirSync(__dirname, { withFileTypes: true })
|
|
9
|
+
.filter(entry => entry.isDirectory() && /^v\d+$/.test(entry.name))
|
|
10
|
+
.map(entry => ({ name: entry.name, n: Number(entry.name.slice(1)) }))
|
|
11
|
+
.sort((a, b) => b.n - a.n);
|
|
12
|
+
|
|
13
|
+
const latestVersion = versionFolders[0]?.name || "v17";
|
|
14
|
+
|
|
15
|
+
let company;
|
|
16
|
+
let masters;
|
|
17
|
+
let vouchers;
|
|
18
|
+
|
|
19
|
+
const versionIndexPath = resolve(__dirname, latestVersion, "index.js");
|
|
20
|
+
|
|
21
|
+
if (existsSync(versionIndexPath)) {
|
|
22
|
+
const versionModule = await import(pathToFileURL(versionIndexPath).href);
|
|
23
|
+
company = versionModule.company ?? versionModule.default;
|
|
24
|
+
masters = versionModule.masters;
|
|
25
|
+
vouchers = versionModule.vouchers;
|
|
26
|
+
} else {
|
|
27
|
+
const mainUrl = pathToFileURL(resolve(__dirname, latestVersion, "main.js")).href;
|
|
28
|
+
const mastersUrl = pathToFileURL(resolve(__dirname, latestVersion, "masters", "index.js")).href;
|
|
29
|
+
const vouchersUrl = pathToFileURL(resolve(__dirname, latestVersion, "vouchers", "index.js")).href;
|
|
30
|
+
|
|
31
|
+
const [mainModule, mastersModule, vouchersModule] = await Promise.all([
|
|
32
|
+
import(mainUrl),
|
|
33
|
+
import(mastersUrl),
|
|
34
|
+
import(vouchersUrl)
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
company = mainModule.company ?? mainModule.default;
|
|
38
|
+
masters = mastersModule;
|
|
39
|
+
vouchers = vouchersModule;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { company, masters, vouchers, latestVersion as version };
|
|
43
43
|
export default company;
|
package/src/v21/company/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import tdlMessage from "../tdlMessage.json" with { type: "json" };
|
|
2
|
-
import { createCompanyApi } from "../createApi.js";
|
|
3
|
-
|
|
4
|
-
const { all } = createCompanyApi(tdlMessage.company);
|
|
5
|
-
|
|
6
|
-
export { all };
|
|
7
|
-
export default { all };
|
|
1
|
+
import tdlMessage from "../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createCompanyApi } from "../createApi.js";
|
|
3
|
+
|
|
4
|
+
const { all } = createCompanyApi(tdlMessage.company);
|
|
5
|
+
|
|
6
|
+
export { all };
|
|
7
|
+
export default { all };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import executeXml from "./executeXml.js";
|
|
2
|
-
|
|
3
|
-
export { executeXml };
|
|
4
|
-
export default executeXml;
|
|
1
|
+
import executeXml from "./executeXml.js";
|
|
2
|
+
|
|
3
|
+
export { executeXml };
|
|
4
|
+
export default executeXml;
|
package/src/v21/core/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
// Sub-modules
|
|
2
|
-
export * as transport from "./transport/index.js";
|
|
3
|
-
export * as response from "./response/index.js";
|
|
4
|
-
export * as execute from "./execute/index.js";
|
|
5
|
-
|
|
6
|
-
// Direct Core Exports
|
|
7
|
-
export {
|
|
8
|
-
sendXml,
|
|
9
|
-
sendToTally
|
|
10
|
-
} from "./transport/index.js";
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
xmlToJson
|
|
14
|
-
} from "./response/index.js";
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
executeXml
|
|
18
|
-
} from "./execute/index.js";
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
buildXml
|
|
22
|
-
} from "./buildXml.js";
|
|
1
|
+
// Sub-modules
|
|
2
|
+
export * as transport from "./transport/index.js";
|
|
3
|
+
export * as response from "./response/index.js";
|
|
4
|
+
export * as execute from "./execute/index.js";
|
|
5
|
+
|
|
6
|
+
// Direct Core Exports
|
|
7
|
+
export {
|
|
8
|
+
sendXml,
|
|
9
|
+
sendToTally
|
|
10
|
+
} from "./transport/index.js";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
xmlToJson
|
|
14
|
+
} from "./response/index.js";
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
executeXml
|
|
18
|
+
} from "./execute/index.js";
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
buildXml
|
|
22
|
+
} from "./buildXml.js";
|
package/src/v21/createApi.js
CHANGED
|
@@ -1,64 +1,74 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { executeXml } from "./core/index.js";
|
|
5
|
-
import { buildXml } from "./core/buildXml.js";
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const body = fs.readFileSync(path.join(__dirname, "body.xml"), "utf8");
|
|
9
|
-
|
|
10
|
-
const createVoucherApi = (tdlMessageString) => {
|
|
11
|
-
const period = async (company, fromDate, toDate) => {
|
|
12
|
-
const staticVariables = `<SVCURRENTCOMPANY>${company}</SVCURRENTCOMPANY>
|
|
13
|
-
<SVFROMDATE TYPE="Date">${fromDate}</SVFROMDATE><SVTODATE TYPE="Date">${toDate}</SVTODATE>`;
|
|
14
|
-
|
|
15
|
-
const xml = buildXml(body, {
|
|
16
|
-
staticVariables,
|
|
17
|
-
tdlMessage: tdlMessageString
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return await executeXml(xml);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const all = async (company) => {
|
|
24
|
-
const staticVariables = `<SVCURRENTCOMPANY>${company}</SVCURRENTCOMPANY>`;
|
|
25
|
-
|
|
26
|
-
const xml = buildXml(body, {
|
|
27
|
-
staticVariables,
|
|
28
|
-
tdlMessage: tdlMessageString
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return await executeXml(xml);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return { period, all };
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const createMasterApi = (tdlMessageString) => {
|
|
38
|
-
const all = async (company, jsonId) => {
|
|
39
|
-
const staticVariables = `<SVCURRENTCOMPANY>${company}</SVCURRENTCOMPANY>`;
|
|
40
|
-
|
|
41
|
-
const xml = buildXml(body, {
|
|
42
|
-
staticVariables,
|
|
43
|
-
tdlMessage: tdlMessageString[jsonId]
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return await executeXml(xml);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { executeXml } from "./core/index.js";
|
|
5
|
+
import { buildXml } from "./core/buildXml.js";
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const body = fs.readFileSync(path.join(__dirname, "body.xml"), "utf8");
|
|
9
|
+
|
|
10
|
+
const createVoucherApi = (tdlMessageString) => {
|
|
11
|
+
const period = async (company, fromDate, toDate) => {
|
|
12
|
+
const staticVariables = `<SVCURRENTCOMPANY>${company}</SVCURRENTCOMPANY>
|
|
13
|
+
<SVFROMDATE TYPE="Date">${fromDate}</SVFROMDATE><SVTODATE TYPE="Date">${toDate}</SVTODATE>`;
|
|
14
|
+
|
|
15
|
+
const xml = buildXml(body, {
|
|
16
|
+
staticVariables,
|
|
17
|
+
tdlMessage: tdlMessageString
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return await executeXml(xml);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const all = async (company) => {
|
|
24
|
+
const staticVariables = `<SVCURRENTCOMPANY>${company}</SVCURRENTCOMPANY>`;
|
|
25
|
+
|
|
26
|
+
const xml = buildXml(body, {
|
|
27
|
+
staticVariables,
|
|
28
|
+
tdlMessage: tdlMessageString
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return await executeXml(xml);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return { period, all };
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const createMasterApi = (tdlMessageString) => {
|
|
38
|
+
const all = async (company, jsonId) => {
|
|
39
|
+
const staticVariables = `<SVCURRENTCOMPANY>${company}</SVCURRENTCOMPANY>`;
|
|
40
|
+
|
|
41
|
+
const xml = buildXml(body, {
|
|
42
|
+
staticVariables,
|
|
43
|
+
tdlMessage: tdlMessageString[jsonId]
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return await executeXml(xml);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const api = { all };
|
|
50
|
+
|
|
51
|
+
if (tdlMessageString && typeof tdlMessageString === "object") {
|
|
52
|
+
for (const [key, msg] of Object.entries(tdlMessageString)) {
|
|
53
|
+
const fn = async (company) => all(company, key);
|
|
54
|
+
fn.all = fn;
|
|
55
|
+
api[key] = fn;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return api;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const createCompanyApi = (tdlMessageString) => {
|
|
63
|
+
const all = async () => {
|
|
64
|
+
const xml = buildXml(body, {
|
|
65
|
+
tdlMessage: tdlMessageString
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return await executeXml(xml);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return { all };
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { createVoucherApi, createMasterApi, createCompanyApi };
|
package/src/v21/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import company from "./company/index.js";
|
|
2
|
-
import masters from "./masters/index.js";
|
|
3
|
-
import vouchers from "./vouchers/index.js";
|
|
4
|
-
|
|
5
|
-
export { company, masters, vouchers };
|
|
6
|
-
export default company;
|
|
1
|
+
import company from "./company/index.js";
|
|
2
|
+
import masters from "./masters/index.js";
|
|
3
|
+
import vouchers from "./vouchers/index.js";
|
|
4
|
+
|
|
5
|
+
export { company, masters, vouchers };
|
|
6
|
+
export default company;
|
package/src/v21/masters/index.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import tdlMessage from "../tdlMessage.json" with { type: "json" };
|
|
2
|
-
import { createMasterApi } from "../createApi.js";
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import tdlMessage from "../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../createApi.js";
|
|
3
|
+
|
|
4
|
+
const masterApi = createMasterApi(tdlMessage.masters);
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
uom,
|
|
9
|
+
stockItems,
|
|
10
|
+
stockItemsWithBaseUnits,
|
|
11
|
+
ledgerNames,
|
|
12
|
+
ledgerNamesWithDetails,
|
|
13
|
+
ledgerNamesMoreDetails,
|
|
14
|
+
stockGroups,
|
|
15
|
+
stockGroupsAndParent
|
|
16
|
+
} = masterApi;
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
all,
|
|
20
|
+
uom,
|
|
21
|
+
stockItems,
|
|
22
|
+
stockItemsWithBaseUnits,
|
|
23
|
+
ledgerNames,
|
|
24
|
+
ledgerNamesWithDetails,
|
|
25
|
+
ledgerNamesMoreDetails,
|
|
26
|
+
stockGroups,
|
|
27
|
+
stockGroupsAndParent
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default masterApi;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as purchases from "./purchases/index.js";
|
|
2
|
-
import * as sales from "./sales/index.js";
|
|
3
|
-
|
|
4
|
-
export { purchases, sales };
|
|
5
|
-
export default { purchases, sales };
|
|
1
|
+
import * as purchases from "./purchases/index.js";
|
|
2
|
+
import * as sales from "./sales/index.js";
|
|
3
|
+
|
|
4
|
+
export { purchases, sales };
|
|
5
|
+
export default { purchases, sales };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
-
import { createVoucherApi } from "../../createApi.js";
|
|
3
|
-
|
|
4
|
-
const { period, all } = createVoucherApi(tdlMessage.vouchers.purchases);
|
|
5
|
-
|
|
6
|
-
export { period, all };
|
|
7
|
-
export default { period, all };
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createVoucherApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const { period, all } = createVoucherApi(tdlMessage.vouchers.purchases);
|
|
5
|
+
|
|
6
|
+
export { period, all };
|
|
7
|
+
export default { period, all };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
-
import { createVoucherApi } from "../../createApi.js";
|
|
3
|
-
|
|
4
|
-
const { period, all } = createVoucherApi(tdlMessage.vouchers.sales);
|
|
5
|
-
|
|
6
|
-
export { period, all };
|
|
7
|
-
export default { period, all };
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createVoucherApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const { period, all } = createVoucherApi(tdlMessage.vouchers.sales);
|
|
5
|
+
|
|
6
|
+
export { period, all };
|
|
7
|
+
export default { period, all };
|