tally-xml-tdl 1.22.4 → 1.23.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/package.json +1 -1
- package/src/index.js +2 -2
- package/src/v22/bodyAsData.xml +16 -0
- package/src/v22/createApi.js +20 -1
- package/src/v22/index.js +3 -2
- package/src/v22/masters/Godown/index.js +20 -0
- package/src/v22/masters/Ledger/index.js +22 -22
- package/src/v22/masters/StockGroup/index.js +18 -18
- package/src/v22/masters/StockItem/index.js +20 -20
- package/src/v22/masters/Unit/index.js +16 -16
- package/src/v22/masters/index.js +64 -57
- package/src/v22/reports/index.js +11 -0
- package/src/v22/reports/stockSummary/index.js +10 -0
- package/src/v22/reports.json +6 -0
- package/src/v22/tdlMessage.json +8 -2
- package/src/v23/body.xml +25 -0
- package/src/v23/bodyAsData.xml +16 -0
- package/src/v23/company/index.js +7 -0
- package/src/v23/core/buildXml.js +9 -0
- package/src/v23/core/execute/executeXml.js +16 -0
- package/src/v23/core/execute/index.js +4 -0
- package/src/v23/core/index.js +22 -0
- package/src/v23/core/response/index.js +2 -0
- package/src/v23/core/response/xmlToJson.js +18 -0
- package/src/v23/core/transport/http.js +40 -0
- package/src/v23/core/transport/index.js +1 -0
- package/src/v23/createApi.js +106 -0
- package/src/v23/index.js +7 -0
- package/src/v23/masters/Godown/index.js +20 -0
- package/src/v23/masters/Ledger/index.js +22 -0
- package/src/v23/masters/StockGroup/index.js +18 -0
- package/src/v23/masters/StockItem/index.js +20 -0
- package/src/v23/masters/Unit/index.js +16 -0
- package/src/v23/masters/index.js +64 -0
- package/src/v23/reports/index.js +11 -0
- package/src/v23/reports/stockSummary/index.js +10 -0
- package/src/v23/reports.json +6 -0
- package/src/v23/tdlMessage.json +37 -0
- package/src/v23/vouchers/index.js +5 -0
- package/src/v23/vouchers/purchases/index.js +7 -0
- package/src/v23/vouchers/sales/index.js +7 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export { default } from "./
|
|
1
|
+
export * from "./v23/index.js";
|
|
2
|
+
export { default } from "./v23/index.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<ENVELOPE>
|
|
2
|
+
<HEADER>
|
|
3
|
+
<VERSION>1</VERSION>
|
|
4
|
+
<TALLYREQUEST>Export</TALLYREQUEST>
|
|
5
|
+
<TYPE>Data</TYPE>
|
|
6
|
+
<ID>{{ID}}</ID>
|
|
7
|
+
</HEADER>
|
|
8
|
+
<BODY>
|
|
9
|
+
<DESC>
|
|
10
|
+
<STATICVARIABLES>
|
|
11
|
+
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
|
|
12
|
+
{{STATICVARIABLES}}
|
|
13
|
+
</STATICVARIABLES>
|
|
14
|
+
</DESC>
|
|
15
|
+
</BODY>
|
|
16
|
+
</ENVELOPE>
|
package/src/v22/createApi.js
CHANGED
|
@@ -6,6 +6,7 @@ import { buildXml } from "./core/buildXml.js";
|
|
|
6
6
|
|
|
7
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
const body = fs.readFileSync(path.join(__dirname, "body.xml"), "utf8");
|
|
9
|
+
const bodyAsData = fs.readFileSync(path.join(__dirname, "bodyAsData.xml"), "utf8");
|
|
9
10
|
|
|
10
11
|
const createVoucherApi = (tdlMessageString) => {
|
|
11
12
|
const period = async (company, fromDate, toDate) => {
|
|
@@ -84,4 +85,22 @@ const createCompanyApi = (tdlMessageString) => {
|
|
|
84
85
|
return { all };
|
|
85
86
|
};
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
const createReportApi = (arg) => {
|
|
89
|
+
const inId = typeof arg === "string" ? arg : (arg?.inId || arg?.id);
|
|
90
|
+
const inStaticVariables = typeof arg === "object" ? (arg?.inStaticVariables || arg?.staticVariables || "") : "";
|
|
91
|
+
|
|
92
|
+
const localId = inId;
|
|
93
|
+
const defaultStatic = inStaticVariables;
|
|
94
|
+
|
|
95
|
+
return async (company, extraStatic = "") => {
|
|
96
|
+
const localCompany = company;
|
|
97
|
+
const staticVariables = `<SVCURRENTCOMPANY>${localCompany}</SVCURRENTCOMPANY>${defaultStatic}${extraStatic}`;
|
|
98
|
+
const xml = bodyAsData
|
|
99
|
+
.replace("{{ID}}", localId)
|
|
100
|
+
.replace("{{STATICVARIABLES}}", staticVariables);
|
|
101
|
+
|
|
102
|
+
return await executeXml(xml);
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { createVoucherApi, createMasterApi, createCompanyApi, createReportApi };
|
package/src/v22/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import company from "./company/index.js";
|
|
2
|
-
import masters, { Unit, StockItem, Ledger, StockGroup } from "./masters/index.js";
|
|
2
|
+
import masters, { Unit, StockItem, Ledger, StockGroup, Godown } from "./masters/index.js";
|
|
3
3
|
import vouchers from "./vouchers/index.js";
|
|
4
|
+
import reports, { stockSummary } from "./reports/index.js";
|
|
4
5
|
|
|
5
|
-
export { company, masters, vouchers, Unit, StockItem, Ledger, StockGroup };
|
|
6
|
+
export { company, masters, vouchers, reports, Unit, StockItem, Ledger, StockGroup, Godown, stockSummary };
|
|
6
7
|
export default company;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const godownApi = createMasterApi({ inTdlMessage: tdlMessage.masters.Godown });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names,
|
|
9
|
+
withParent,
|
|
10
|
+
withDetails
|
|
11
|
+
} = godownApi;
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
all,
|
|
15
|
+
names,
|
|
16
|
+
withParent,
|
|
17
|
+
withDetails
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default godownApi;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
-
import { createMasterApi } from "../../createApi.js";
|
|
3
|
-
|
|
4
|
-
const ledgerApi = createMasterApi({ inTdlMessage: tdlMessage.masters.Ledger });
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
all,
|
|
8
|
-
names,
|
|
9
|
-
withDetails,
|
|
10
|
-
moreDetails,
|
|
11
|
-
withGstDetails
|
|
12
|
-
} = ledgerApi;
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
all,
|
|
16
|
-
names,
|
|
17
|
-
withDetails,
|
|
18
|
-
moreDetails,
|
|
19
|
-
withGstDetails
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default ledgerApi;
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const ledgerApi = createMasterApi({ inTdlMessage: tdlMessage.masters.Ledger });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names,
|
|
9
|
+
withDetails,
|
|
10
|
+
moreDetails,
|
|
11
|
+
withGstDetails
|
|
12
|
+
} = ledgerApi;
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
all,
|
|
16
|
+
names,
|
|
17
|
+
withDetails,
|
|
18
|
+
moreDetails,
|
|
19
|
+
withGstDetails
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default ledgerApi;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
-
import { createMasterApi } from "../../createApi.js";
|
|
3
|
-
|
|
4
|
-
const stockGroupApi = createMasterApi({ inTdlMessage: tdlMessage.masters.StockGroup });
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
all,
|
|
8
|
-
names,
|
|
9
|
-
withParent
|
|
10
|
-
} = stockGroupApi;
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
all,
|
|
14
|
-
names,
|
|
15
|
-
withParent
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default stockGroupApi;
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const stockGroupApi = createMasterApi({ inTdlMessage: tdlMessage.masters.StockGroup });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names,
|
|
9
|
+
withParent
|
|
10
|
+
} = stockGroupApi;
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
all,
|
|
14
|
+
names,
|
|
15
|
+
withParent
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default stockGroupApi;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
-
import { createMasterApi } from "../../createApi.js";
|
|
3
|
-
|
|
4
|
-
const stockItemApi = createMasterApi({ inTdlMessage: tdlMessage.masters.StockItem });
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
all,
|
|
8
|
-
names,
|
|
9
|
-
withBaseUnits,
|
|
10
|
-
withBatches
|
|
11
|
-
} = stockItemApi;
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
all,
|
|
15
|
-
names,
|
|
16
|
-
withBaseUnits,
|
|
17
|
-
withBatches
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default stockItemApi;
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const stockItemApi = createMasterApi({ inTdlMessage: tdlMessage.masters.StockItem });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names,
|
|
9
|
+
withBaseUnits,
|
|
10
|
+
withBatches
|
|
11
|
+
} = stockItemApi;
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
all,
|
|
15
|
+
names,
|
|
16
|
+
withBaseUnits,
|
|
17
|
+
withBatches
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default stockItemApi;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
-
import { createMasterApi } from "../../createApi.js";
|
|
3
|
-
|
|
4
|
-
const unitApi = createMasterApi({ inTdlMessage: tdlMessage.masters.Unit });
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
all,
|
|
8
|
-
names
|
|
9
|
-
} = unitApi;
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
all,
|
|
13
|
-
names
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default unitApi;
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const unitApi = createMasterApi({ inTdlMessage: tdlMessage.masters.Unit });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names
|
|
9
|
+
} = unitApi;
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
all,
|
|
13
|
+
names
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default unitApi;
|
package/src/v22/masters/index.js
CHANGED
|
@@ -1,57 +1,64 @@
|
|
|
1
|
-
import Unit from "./Unit/index.js";
|
|
2
|
-
import StockItem from "./StockItem/index.js";
|
|
3
|
-
import Ledger from "./Ledger/index.js";
|
|
4
|
-
import StockGroup from "./StockGroup/index.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Unit
|
|
48
|
-
StockItem
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
import Unit from "./Unit/index.js";
|
|
2
|
+
import StockItem from "./StockItem/index.js";
|
|
3
|
+
import Ledger from "./Ledger/index.js";
|
|
4
|
+
import StockGroup from "./StockGroup/index.js";
|
|
5
|
+
import Godown from "./Godown/index.js";
|
|
6
|
+
|
|
7
|
+
const all = async (company, type, variant = "all") => {
|
|
8
|
+
const localCompany = company;
|
|
9
|
+
const localType = type;
|
|
10
|
+
const localVariant = variant;
|
|
11
|
+
|
|
12
|
+
const target = masters[localType];
|
|
13
|
+
if (!target) {
|
|
14
|
+
throw new Error(`Master type '${localType}' not found.`);
|
|
15
|
+
}
|
|
16
|
+
if (typeof target[localVariant] === "function") {
|
|
17
|
+
return await target[localVariant](localCompany);
|
|
18
|
+
}
|
|
19
|
+
if (typeof target.all === "function") {
|
|
20
|
+
return await target.all(localCompany, localVariant);
|
|
21
|
+
}
|
|
22
|
+
return await target(localCompany);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const masters = {
|
|
26
|
+
all,
|
|
27
|
+
Unit,
|
|
28
|
+
StockItem,
|
|
29
|
+
Ledger,
|
|
30
|
+
StockGroup,
|
|
31
|
+
Godown,
|
|
32
|
+
// Aliases for convenience
|
|
33
|
+
unit: Unit,
|
|
34
|
+
stockItem: StockItem,
|
|
35
|
+
stockItems: StockItem,
|
|
36
|
+
ledger: Ledger,
|
|
37
|
+
ledgers: Ledger,
|
|
38
|
+
stockGroup: StockGroup,
|
|
39
|
+
stockGroups: StockGroup,
|
|
40
|
+
godown: Godown,
|
|
41
|
+
godowns: Godown,
|
|
42
|
+
uom: Unit
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
all,
|
|
47
|
+
Unit,
|
|
48
|
+
StockItem,
|
|
49
|
+
Ledger,
|
|
50
|
+
StockGroup,
|
|
51
|
+
Godown,
|
|
52
|
+
Unit as unit,
|
|
53
|
+
StockItem as stockItem,
|
|
54
|
+
StockItem as stockItems,
|
|
55
|
+
Ledger as ledger,
|
|
56
|
+
Ledger as ledgers,
|
|
57
|
+
StockGroup as stockGroup,
|
|
58
|
+
StockGroup as stockGroups,
|
|
59
|
+
Godown as godown,
|
|
60
|
+
Godown as godowns,
|
|
61
|
+
Unit as uom
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default masters;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import reportsJson from "../../reports.json" with { type: "json" };
|
|
2
|
+
import { createReportApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const stockSummary = createReportApi({
|
|
5
|
+
inId: reportsJson.stockSummary.id,
|
|
6
|
+
inStaticVariables: reportsJson.stockSummary.staticVariables
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { stockSummary };
|
|
10
|
+
export default stockSummary;
|
package/src/v22/tdlMessage.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"company": "<TYPE>Company</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
3
3
|
"vouchers": {
|
|
4
|
-
"purchases": "<TYPE>Vouchers:VoucherType</TYPE><CHILDOF>$$$$VchTypePurchase</CHILDOF><BELONGSTO>Yes</BELONGSTO><FETCH>Date, VoucherNumber, VoucherTypeName, PartyLedgerName, Amount, AllInventoryEntries</FETCH>",
|
|
5
|
-
"sales": "<TYPE>Vouchers:VoucherType</TYPE><CHILDOF>$$$$VchTypeSales</CHILDOF><BELONGSTO>Yes</BELONGSTO><FETCH>Date, VoucherNumber, VoucherTypeName, PartyLedgerName, Amount, AllInventoryEntries</FETCH>"
|
|
4
|
+
"purchases": "<TYPE>Vouchers:VoucherType</TYPE><CHILDOF>$$$$VchTypePurchase</CHILDOF><BELONGSTO>Yes</BELONGSTO><FETCH>Date, VoucherNumber, VoucherTypeName, PartyLedgerName, Amount, AllInventoryEntries, AllLedgerEntries</FETCH>",
|
|
5
|
+
"sales": "<TYPE>Vouchers:VoucherType</TYPE><CHILDOF>$$$$VchTypeSales</CHILDOF><BELONGSTO>Yes</BELONGSTO><FETCH>Date, VoucherNumber, VoucherTypeName, PartyLedgerName, Amount, AllInventoryEntries, AllLedgerEntries</FETCH>"
|
|
6
6
|
},
|
|
7
7
|
"masters": {
|
|
8
8
|
"Unit": {
|
|
@@ -26,6 +26,12 @@
|
|
|
26
26
|
"all": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
27
27
|
"names": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
28
28
|
"withParent": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>Parent</FETCH>"
|
|
29
|
+
},
|
|
30
|
+
"Godown": {
|
|
31
|
+
"all": "<TYPE>Godown</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
32
|
+
"names": "<TYPE>Godown</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
33
|
+
"withParent": "<TYPE>Godown</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>Parent</FETCH>",
|
|
34
|
+
"withDetails": "<TYPE>Godown</TYPE><FETCH>*</FETCH>"
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
}
|
package/src/v23/body.xml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<ENVELOPE>
|
|
2
|
+
<HEADER>
|
|
3
|
+
<VERSION>1</VERSION>
|
|
4
|
+
<TALLYREQUEST>Export</TALLYREQUEST>
|
|
5
|
+
<TYPE>Collection</TYPE>
|
|
6
|
+
<ID>TDLID</ID>
|
|
7
|
+
</HEADER>
|
|
8
|
+
|
|
9
|
+
<BODY>
|
|
10
|
+
<DESC>
|
|
11
|
+
<STATICVARIABLES>
|
|
12
|
+
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
|
|
13
|
+
{{STATICVARIABLES}}
|
|
14
|
+
</STATICVARIABLES>
|
|
15
|
+
|
|
16
|
+
<TDL>
|
|
17
|
+
<TDLMESSAGE>
|
|
18
|
+
<COLLECTION NAME="TDLID">
|
|
19
|
+
{{TDLMESSAGE}}
|
|
20
|
+
</COLLECTION>
|
|
21
|
+
</TDLMESSAGE>
|
|
22
|
+
</TDL>
|
|
23
|
+
</DESC>
|
|
24
|
+
</BODY>
|
|
25
|
+
</ENVELOPE>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<ENVELOPE>
|
|
2
|
+
<HEADER>
|
|
3
|
+
<VERSION>1</VERSION>
|
|
4
|
+
<TALLYREQUEST>Export</TALLYREQUEST>
|
|
5
|
+
<TYPE>Data</TYPE>
|
|
6
|
+
<ID>{{ID}}</ID>
|
|
7
|
+
</HEADER>
|
|
8
|
+
<BODY>
|
|
9
|
+
<DESC>
|
|
10
|
+
<STATICVARIABLES>
|
|
11
|
+
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
|
|
12
|
+
{{STATICVARIABLES}}
|
|
13
|
+
</STATICVARIABLES>
|
|
14
|
+
</DESC>
|
|
15
|
+
</BODY>
|
|
16
|
+
</ENVELOPE>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/v4/core/execute/executeXml.js
|
|
2
|
+
import { sendXml } from "../transport/http.js";
|
|
3
|
+
import { xmlToJson } from "../response/xmlToJson.js";
|
|
4
|
+
|
|
5
|
+
const startFunc = async (
|
|
6
|
+
xml,
|
|
7
|
+
{ url = "http://localhost:9000" } = {}
|
|
8
|
+
) => {
|
|
9
|
+
const rawXml = await sendXml({ xml, url });
|
|
10
|
+
|
|
11
|
+
const json = xmlToJson(rawXml);
|
|
12
|
+
// console.log("json :", json);
|
|
13
|
+
return json;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default startFunc;
|
|
@@ -0,0 +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";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { XMLParser } from "fast-xml-parser";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts XML string into a JavaScript Object.
|
|
5
|
+
* Preserves XML attributes using the `@_` prefix.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} xml - The XML string to parse.
|
|
8
|
+
* @param {object} [options] - Optional XMLParser configurations.
|
|
9
|
+
* @returns {object} The parsed JavaScript object.
|
|
10
|
+
*/
|
|
11
|
+
export const xmlToJson = (xml, options = {}) => {
|
|
12
|
+
const parser = new XMLParser({
|
|
13
|
+
ignoreAttributes: false,
|
|
14
|
+
...options
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return parser.parse(xml);
|
|
18
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { xmlToJson } from "../response/xmlToJson.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sends a raw XML string to Tally via HTTP POST and returns the raw response text.
|
|
5
|
+
*
|
|
6
|
+
* @param {object} params
|
|
7
|
+
* @param {string} params.xml - The XML payload to send.
|
|
8
|
+
* @param {string} [params.url="http://localhost:9000"] - Tally HTTP endpoint URL.
|
|
9
|
+
* @returns {Promise<string>} Raw XML response text from Tally.
|
|
10
|
+
*/
|
|
11
|
+
export const sendXml = async ({
|
|
12
|
+
xml,
|
|
13
|
+
url = "http://localhost:9000"
|
|
14
|
+
} = {}) => {
|
|
15
|
+
const res = await fetch(url, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: {
|
|
18
|
+
"Content-Type": "text/xml"
|
|
19
|
+
},
|
|
20
|
+
body: xml
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return await res.text();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Sends an XML payload to Tally via HTTP POST and parses the response to JSON.
|
|
28
|
+
*
|
|
29
|
+
* @param {object} params
|
|
30
|
+
* @param {string} params.xml - The XML string to send.
|
|
31
|
+
* @param {string} [params.url="http://localhost:9000"] - Tally HTTP endpoint URL.
|
|
32
|
+
* @returns {Promise<object>} Parsed JSON response from Tally.
|
|
33
|
+
*/
|
|
34
|
+
export const sendToTally = async ({
|
|
35
|
+
xml,
|
|
36
|
+
url = "http://localhost:9000"
|
|
37
|
+
} = {}) => {
|
|
38
|
+
const text = await sendXml({ xml, url });
|
|
39
|
+
return xmlToJson(text);
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sendXml, sendToTally } from "./http.js";
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
const bodyAsData = fs.readFileSync(path.join(__dirname, "bodyAsData.xml"), "utf8");
|
|
10
|
+
|
|
11
|
+
const createVoucherApi = (tdlMessageString) => {
|
|
12
|
+
const period = async (company, fromDate, toDate) => {
|
|
13
|
+
const staticVariables = `<SVCURRENTCOMPANY>${company}</SVCURRENTCOMPANY>
|
|
14
|
+
<SVFROMDATE TYPE="Date">${fromDate}</SVFROMDATE><SVTODATE TYPE="Date">${toDate}</SVTODATE>`;
|
|
15
|
+
|
|
16
|
+
const xml = buildXml(body, {
|
|
17
|
+
staticVariables,
|
|
18
|
+
tdlMessage: tdlMessageString
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return await executeXml(xml);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const all = async (company) => {
|
|
25
|
+
const staticVariables = `<SVCURRENTCOMPANY>${company}</SVCURRENTCOMPANY>`;
|
|
26
|
+
|
|
27
|
+
const xml = buildXml(body, {
|
|
28
|
+
staticVariables,
|
|
29
|
+
tdlMessage: tdlMessageString
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return await executeXml(xml);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return { period, all };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const createMasterApi = (arg) => {
|
|
39
|
+
const inTdlMessage = (arg && typeof arg === "object" && "inTdlMessage" in arg) ? arg.inTdlMessage : arg;
|
|
40
|
+
const localTdlMessage = inTdlMessage;
|
|
41
|
+
|
|
42
|
+
const all = async (company, jsonId = "all") => {
|
|
43
|
+
const localCompany = company;
|
|
44
|
+
const localJsonId = jsonId;
|
|
45
|
+
const staticVariables = `<SVCURRENTCOMPANY>${localCompany}</SVCURRENTCOMPANY>`;
|
|
46
|
+
|
|
47
|
+
let messageTemplate;
|
|
48
|
+
if (typeof localTdlMessage === "string") {
|
|
49
|
+
messageTemplate = localTdlMessage;
|
|
50
|
+
} else if (localTdlMessage && typeof localTdlMessage === "object") {
|
|
51
|
+
messageTemplate = localTdlMessage[localJsonId] || localTdlMessage.all || localTdlMessage.names || Object.values(localTdlMessage)[0];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const xml = buildXml(body, {
|
|
55
|
+
staticVariables,
|
|
56
|
+
tdlMessage: messageTemplate
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return await executeXml(xml);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const mainFn = async (company) => all(company, "all");
|
|
63
|
+
mainFn.all = (company, jsonId) => (jsonId ? all(company, jsonId) : all(company, "all"));
|
|
64
|
+
|
|
65
|
+
if (localTdlMessage && typeof localTdlMessage === "object") {
|
|
66
|
+
for (const [key, msg] of Object.entries(localTdlMessage)) {
|
|
67
|
+
const fn = async (company) => all(company, key);
|
|
68
|
+
fn.all = fn;
|
|
69
|
+
mainFn[key] = fn;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return mainFn;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const createCompanyApi = (tdlMessageString) => {
|
|
77
|
+
const all = async () => {
|
|
78
|
+
const xml = buildXml(body, {
|
|
79
|
+
tdlMessage: tdlMessageString
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return await executeXml(xml);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return { all };
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const createReportApi = (arg) => {
|
|
89
|
+
const inId = typeof arg === "string" ? arg : (arg?.inId || arg?.id);
|
|
90
|
+
const inStaticVariables = typeof arg === "object" ? (arg?.inStaticVariables || arg?.staticVariables || "") : "";
|
|
91
|
+
|
|
92
|
+
const localId = inId;
|
|
93
|
+
const defaultStatic = inStaticVariables;
|
|
94
|
+
|
|
95
|
+
return async (company, extraStatic = "") => {
|
|
96
|
+
const localCompany = company;
|
|
97
|
+
const staticVariables = `<SVCURRENTCOMPANY>${localCompany}</SVCURRENTCOMPANY>${defaultStatic}${extraStatic}`;
|
|
98
|
+
const xml = bodyAsData
|
|
99
|
+
.replace("{{ID}}", localId)
|
|
100
|
+
.replace("{{STATICVARIABLES}}", staticVariables);
|
|
101
|
+
|
|
102
|
+
return await executeXml(xml);
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { createVoucherApi, createMasterApi, createCompanyApi, createReportApi };
|
package/src/v23/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import company from "./company/index.js";
|
|
2
|
+
import masters, { Unit, StockItem, Ledger, StockGroup, Godown } from "./masters/index.js";
|
|
3
|
+
import vouchers from "./vouchers/index.js";
|
|
4
|
+
import reports, { stockSummary } from "./reports/index.js";
|
|
5
|
+
|
|
6
|
+
export { company, masters, vouchers, reports, Unit, StockItem, Ledger, StockGroup, Godown, stockSummary };
|
|
7
|
+
export default company;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const godownApi = createMasterApi({ inTdlMessage: tdlMessage.masters.Godown });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names,
|
|
9
|
+
withParent,
|
|
10
|
+
withDetails
|
|
11
|
+
} = godownApi;
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
all,
|
|
15
|
+
names,
|
|
16
|
+
withParent,
|
|
17
|
+
withDetails
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default godownApi;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const ledgerApi = createMasterApi({ inTdlMessage: tdlMessage.masters.Ledger });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names,
|
|
9
|
+
withDetails,
|
|
10
|
+
moreDetails,
|
|
11
|
+
withGstDetails
|
|
12
|
+
} = ledgerApi;
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
all,
|
|
16
|
+
names,
|
|
17
|
+
withDetails,
|
|
18
|
+
moreDetails,
|
|
19
|
+
withGstDetails
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default ledgerApi;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const stockGroupApi = createMasterApi({ inTdlMessage: tdlMessage.masters.StockGroup });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names,
|
|
9
|
+
withParent
|
|
10
|
+
} = stockGroupApi;
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
all,
|
|
14
|
+
names,
|
|
15
|
+
withParent
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default stockGroupApi;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const stockItemApi = createMasterApi({ inTdlMessage: tdlMessage.masters.StockItem });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names,
|
|
9
|
+
withBaseUnits,
|
|
10
|
+
withBatches
|
|
11
|
+
} = stockItemApi;
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
all,
|
|
15
|
+
names,
|
|
16
|
+
withBaseUnits,
|
|
17
|
+
withBatches
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default stockItemApi;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import tdlMessage from "../../tdlMessage.json" with { type: "json" };
|
|
2
|
+
import { createMasterApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const unitApi = createMasterApi({ inTdlMessage: tdlMessage.masters.Unit });
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
all,
|
|
8
|
+
names
|
|
9
|
+
} = unitApi;
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
all,
|
|
13
|
+
names
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default unitApi;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Unit from "./Unit/index.js";
|
|
2
|
+
import StockItem from "./StockItem/index.js";
|
|
3
|
+
import Ledger from "./Ledger/index.js";
|
|
4
|
+
import StockGroup from "./StockGroup/index.js";
|
|
5
|
+
import Godown from "./Godown/index.js";
|
|
6
|
+
|
|
7
|
+
const all = async (company, type, variant = "all") => {
|
|
8
|
+
const localCompany = company;
|
|
9
|
+
const localType = type;
|
|
10
|
+
const localVariant = variant;
|
|
11
|
+
|
|
12
|
+
const target = masters[localType];
|
|
13
|
+
if (!target) {
|
|
14
|
+
throw new Error(`Master type '${localType}' not found.`);
|
|
15
|
+
}
|
|
16
|
+
if (typeof target[localVariant] === "function") {
|
|
17
|
+
return await target[localVariant](localCompany);
|
|
18
|
+
}
|
|
19
|
+
if (typeof target.all === "function") {
|
|
20
|
+
return await target.all(localCompany, localVariant);
|
|
21
|
+
}
|
|
22
|
+
return await target(localCompany);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const masters = {
|
|
26
|
+
all,
|
|
27
|
+
Unit,
|
|
28
|
+
StockItem,
|
|
29
|
+
Ledger,
|
|
30
|
+
StockGroup,
|
|
31
|
+
Godown,
|
|
32
|
+
// Aliases for convenience
|
|
33
|
+
unit: Unit,
|
|
34
|
+
stockItem: StockItem,
|
|
35
|
+
stockItems: StockItem,
|
|
36
|
+
ledger: Ledger,
|
|
37
|
+
ledgers: Ledger,
|
|
38
|
+
stockGroup: StockGroup,
|
|
39
|
+
stockGroups: StockGroup,
|
|
40
|
+
godown: Godown,
|
|
41
|
+
godowns: Godown,
|
|
42
|
+
uom: Unit
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
all,
|
|
47
|
+
Unit,
|
|
48
|
+
StockItem,
|
|
49
|
+
Ledger,
|
|
50
|
+
StockGroup,
|
|
51
|
+
Godown,
|
|
52
|
+
Unit as unit,
|
|
53
|
+
StockItem as stockItem,
|
|
54
|
+
StockItem as stockItems,
|
|
55
|
+
Ledger as ledger,
|
|
56
|
+
Ledger as ledgers,
|
|
57
|
+
StockGroup as stockGroup,
|
|
58
|
+
StockGroup as stockGroups,
|
|
59
|
+
Godown as godown,
|
|
60
|
+
Godown as godowns,
|
|
61
|
+
Unit as uom
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default masters;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import reportsJson from "../../reports.json" with { type: "json" };
|
|
2
|
+
import { createReportApi } from "../../createApi.js";
|
|
3
|
+
|
|
4
|
+
const stockSummary = createReportApi({
|
|
5
|
+
inId: reportsJson.stockSummary.id,
|
|
6
|
+
inStaticVariables: reportsJson.stockSummary.staticVariables
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { stockSummary };
|
|
10
|
+
export default stockSummary;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"company": "<TYPE>Company</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
3
|
+
"vouchers": {
|
|
4
|
+
"purchases": "<TYPE>Vouchers:VoucherType</TYPE><CHILDOF>$$$$VchTypePurchase</CHILDOF><BELONGSTO>Yes</BELONGSTO><FETCH>Date, VoucherNumber, VoucherTypeName, PartyLedgerName, Amount, AllInventoryEntries, AllLedgerEntries</FETCH>",
|
|
5
|
+
"sales": "<TYPE>Vouchers:VoucherType</TYPE><CHILDOF>$$$$VchTypeSales</CHILDOF><BELONGSTO>Yes</BELONGSTO><FETCH>Date, VoucherNumber, VoucherTypeName, PartyLedgerName, Amount, AllInventoryEntries, AllLedgerEntries</FETCH>"
|
|
6
|
+
},
|
|
7
|
+
"masters": {
|
|
8
|
+
"Unit": {
|
|
9
|
+
"all": "<TYPE>Unit</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
10
|
+
"names": "<TYPE>Unit</TYPE><FETCH>$$Alias:Name</FETCH>"
|
|
11
|
+
},
|
|
12
|
+
"StockItem": {
|
|
13
|
+
"all": "<TYPE>StockItem</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
14
|
+
"names": "<TYPE>StockItem</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
15
|
+
"withBaseUnits": "<TYPE>StockItem</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>BaseUnits</FETCH>",
|
|
16
|
+
"withBatches": "<TYPE>StockItem</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>BaseUnits</FETCH><FETCH>BatchAllocations.*</FETCH>"
|
|
17
|
+
},
|
|
18
|
+
"Ledger": {
|
|
19
|
+
"all": "<TYPE>Ledger</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
20
|
+
"names": "<TYPE>Ledger</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
21
|
+
"withDetails": "<TYPE>Ledger</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>GSTRegistrationType</FETCH><FETCH>GSTIN</FETCH>",
|
|
22
|
+
"moreDetails": "<TYPE>Ledger</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>LEDGSTREGDETAILS.LIST</FETCH>",
|
|
23
|
+
"withGstDetails": "<TYPE>Ledger</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>LEDGSTREGDETAILS.LIST</FETCH>"
|
|
24
|
+
},
|
|
25
|
+
"StockGroup": {
|
|
26
|
+
"all": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
27
|
+
"names": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
28
|
+
"withParent": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>Parent</FETCH>"
|
|
29
|
+
},
|
|
30
|
+
"Godown": {
|
|
31
|
+
"all": "<TYPE>Godown</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
32
|
+
"names": "<TYPE>Godown</TYPE><FETCH>$$Alias:Name</FETCH>",
|
|
33
|
+
"withParent": "<TYPE>Godown</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>Parent</FETCH>",
|
|
34
|
+
"withDetails": "<TYPE>Godown</TYPE><FETCH>*</FETCH>"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|