@keshavsoft/tallyextract 1.8.2 → 1.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keshavsoft/tallyextract",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,11 +19,6 @@ const startFunc = ({ inTallyJson, inClientData }) => {
19
19
  inTallyJson, inClientData
20
20
  });
21
21
 
22
- // changeVoucherDate({
23
- // inData: data,
24
- // inDate: LocalClientData.customerDetails.InvoiceDate
25
- // });
26
-
27
22
  data.tallymessage[0].allinventoryentries = LocalInventoryItem;
28
23
  data.tallymessage[0].ledgerentries = LocalLedgerItem;
29
24
 
@@ -0,0 +1,47 @@
1
+ const startFunc = ({ inTallyJson, inClientData }) => {
2
+ try {
3
+ let data = inTallyJson;
4
+
5
+ const LocalClientData = inClientData;
6
+
7
+ changeCustomerDetails({
8
+ inLedgerName: LocalClientData.customerDetails.LedgerName,
9
+ inData: data,
10
+ inGstregistrationtype: LocalClientData.customerDetails.GstRegistrationType,
11
+ inPartygstin: LocalClientData.customerDetails.PartyGSTIN
12
+ });
13
+
14
+ changeVoucherDate({
15
+ inData: data,
16
+ inDate: LocalClientData.customerDetails.InvoiceDate
17
+ });
18
+
19
+ return data;
20
+ } catch (err) {
21
+ console.error("Import Failed");
22
+ console.log(err.response?.data || err.message);
23
+ };
24
+ };
25
+
26
+ const changeCustomerDetails = ({ inLedgerName, inData, inGstregistrationtype, inPartygstin }) => {
27
+ const CommonLedgerName = inLedgerName;
28
+
29
+ inData.tallymessage[0].partyname = CommonLedgerName;
30
+ inData.tallymessage[0].basicbuyername = CommonLedgerName;
31
+ inData.tallymessage[0].partyledgername = CommonLedgerName;
32
+ inData.tallymessage[0].consigneemailingname = CommonLedgerName;
33
+ inData.tallymessage[0].partymailingname = CommonLedgerName;
34
+ inData.tallymessage[0].basicbasepartyname = CommonLedgerName;
35
+ inData.tallymessage[0].gstregistrationtype = inGstregistrationtype;
36
+ inData.tallymessage[0].partygstin = inPartygstin;
37
+ };
38
+
39
+ const changeVoucherDate = ({ inData, inDate }) => {
40
+ const localDate = inDate;
41
+
42
+ inData.tallymessage[0].date = localDate;
43
+ inData.tallymessage[0].vchstatusdate = localDate;
44
+ inData.tallymessage[0].effectivedate = localDate;
45
+ };
46
+
47
+ export default startFunc;
@@ -0,0 +1,24 @@
1
+ import path from "path";
2
+ import { fileURLToPath } from "url";
3
+ import { startFunc as prepareInventory } from "./prepareInventory.js";
4
+ // --------------------------------------------------
5
+
6
+ // Creates inventory entries array from items.json
7
+ const startFunc = ({ inItemsJsonAsArray }) => {
8
+ let LocalArray = [];
9
+ const LocalInItemsJsonAsArray = inItemsJsonAsArray;
10
+
11
+ return LocalInItemsJsonAsArray.map(element => {
12
+ return prepareInventory({
13
+ inItemName: element.StockItemNameToImport,
14
+ inTaxPer: element.TaxPer,
15
+ inUom: element.Uom,
16
+ inRate: element.Rate,
17
+ inQty: element.Qty
18
+ });
19
+ });
20
+
21
+ return CommonFileDataAsJson;
22
+ };
23
+
24
+ export { startFunc };
@@ -0,0 +1,89 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import { fileURLToPath } from "url";
5
+
6
+ import inventoryJson from "../../Import/Templates/inventory.json" with {type: "json"};
7
+
8
+ // Prepares single inventory entry
9
+ const startFunc = ({ inItemName, inTaxPer, inUom, inRate, inQty }) => {
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ // const filePath = path.join(__dirname, "../../Import/Templates/inventory.json");
15
+
16
+ // let template = fs.readFileSync(filePath, "utf8");
17
+
18
+ // let data = JSON.parse(template);
19
+
20
+ let data = structuredClone(inventoryJson);
21
+
22
+ const LocalItemName = inItemName;
23
+ const LocalUom = inUom;
24
+ const LocalQty = inQty;
25
+ const LocalRate = inRate;
26
+
27
+ const LocalRateWithTax = LocalRate * (1 + (inTaxPer / 100));
28
+ const LocalAmount = LocalRate * LocalQty;
29
+
30
+ data.hsnitemsource = LocalItemName;
31
+ data.gstitemsource = LocalItemName;
32
+ data.stockitemname = LocalItemName;
33
+
34
+ data.mrprate = `${LocalRateWithTax}.00/${LocalUom}`;
35
+ data.inclvatrate = `${LocalRateWithTax}.00/${LocalUom}`;
36
+
37
+
38
+ // --------------------------------------------------
39
+ // Quantity & Amount
40
+ // --------------------------------------------------
41
+
42
+ data.amount = `${LocalAmount}.00`;
43
+ data.rate = `${LocalRate}.00/${LocalUom}`;
44
+ data.actualqty = `${LocalQty}.00 ${LocalUom}`;
45
+ data.billedqty = `${LocalQty}.00 ${LocalUom}`;
46
+
47
+
48
+ // --------------------------------------------------
49
+ // Batch Allocation
50
+ // --------------------------------------------------
51
+
52
+ data.batchallocations[0].amount = LocalRate * LocalQty;
53
+ data.batchallocations[0].actualqty = `${LocalQty}.00 ${LocalUom}`;
54
+ data.batchallocations[0].billedqty = `${LocalQty}.00 ${LocalUom}`;
55
+
56
+
57
+ // --------------------------------------------------
58
+ // Accounting Allocation
59
+ // --------------------------------------------------
60
+
61
+ data.accountingallocations[0].classrate = `${LocalRate}.00`;
62
+ data.accountingallocations[0].amount = `${LocalAmount}.00`;
63
+
64
+ updateRateDetails(data.ratedetails, inTaxPer);
65
+
66
+ return data;
67
+ };
68
+
69
+ // Update GST ratedetails safely
70
+ const updateRateDetails = (ratedetails, taxPer) => {
71
+ const half = (taxPer / 2).toFixed(2);
72
+ const full = Number(taxPer).toFixed(2);
73
+
74
+ ratedetails.forEach(row => {
75
+ switch (row.gstratedutyhead) {
76
+ case "CGST":
77
+ row.gstrate = half;
78
+ break;
79
+ case "SGST/UTGST":
80
+ row.gstrate = half;
81
+ break;
82
+ case "IGST":
83
+ row.gstrate = full;
84
+ break;
85
+ }
86
+ });
87
+ };
88
+
89
+ export { startFunc };
@@ -0,0 +1,46 @@
1
+ import path from "path";
2
+ import { fileURLToPath } from "url";
3
+ import { startFunc as prepareLedger } from "./prepareLedger.js";
4
+ import prepareGstLedgers from "./prepareGstLedgers.js";
5
+ // Creates ledger entries for voucher
6
+ const startFunc = ({ inItemsJsonAsArray, inLedgerDetails }) => {
7
+ let LocalArray = [];
8
+
9
+ const LocalInItemsJsonAsArray = inItemsJsonAsArray;
10
+
11
+ const LocalAmount = LocalInItemsJsonAsArray.map(element => {
12
+ return element.Rate * element.Qty * (1 + (element.TaxPer / 100));
13
+ });
14
+
15
+ const LocalOnlyAmount = LocalInItemsJsonAsArray.map(element => {
16
+ return element.Rate * element.Qty;
17
+ });
18
+
19
+ const amountSum = LocalAmount.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
20
+ const onlyAmountSum = LocalOnlyAmount.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
21
+
22
+ const LocalLedgerEntry = prepareLedger({
23
+ inLedgerName: inLedgerDetails.LedgerName,
24
+ inAmount: `-${amountSum}.00`
25
+ });
26
+
27
+ LocalArray.push(LocalLedgerEntry);
28
+
29
+ const LocalCGST = prepareGstLedgers({
30
+ inLedgerName: "CGST Output",
31
+ inAmount: `${(amountSum - onlyAmountSum) / 2}.00`
32
+ });
33
+
34
+ LocalArray.push(LocalCGST);
35
+
36
+ const LocalSGST = prepareGstLedgers({
37
+ inLedgerName: "SGST Output",
38
+ inAmount: `${(amountSum - onlyAmountSum) / 2}.00`
39
+ });
40
+
41
+ LocalArray.push(LocalSGST);
42
+
43
+ return LocalArray;
44
+ };
45
+
46
+ export { startFunc };
@@ -0,0 +1,29 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import { fileURLToPath } from "url";
5
+
6
+ import ledgersJson from "../../Import/Templates/ledgers.json" with {type: "json"};
7
+
8
+ // Prepares single ledger entry
9
+ const startFunc = ({ inLedgerName, inAmount }) => {
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ // const filePath = path.join(__dirname, "../../Import/Templates/ledgers.json");
15
+
16
+ // let template = fs.readFileSync(filePath, "utf8");
17
+
18
+ // let data = JSON.parse(template);
19
+
20
+ let data = structuredClone(ledgersJson);
21
+
22
+ data.ledgername = inLedgerName;
23
+ data.amount = inAmount;
24
+ data.vatexpamount = inAmount;
25
+
26
+ return data;
27
+ };
28
+
29
+ export default startFunc;
@@ -0,0 +1,29 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import { fileURLToPath } from "url";
5
+
6
+ import ledgersJson from "../../Import/Templates/ledgers.json" with {type: "json"};
7
+
8
+ // Prepares single ledger entry
9
+ const startFunc = ({ inLedgerName, inAmount }) => {
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ // const filePath = path.join(__dirname, "../../Import/Templates/ledgers.json");
15
+
16
+ // let template = fs.readFileSync(filePath, "utf8");
17
+
18
+ // let data = JSON.parse(template);
19
+
20
+ let data = structuredClone(ledgersJson);
21
+
22
+ data.ledgername = inLedgerName;
23
+ data.amount = inAmount;
24
+ data.isdeemedpositive = true;
25
+
26
+ return data;
27
+ };
28
+
29
+ export { startFunc };
@@ -0,0 +1,20 @@
1
+ import { startFunc as prepareClientData } from "./prepareClientData.js";
2
+ import { startFunc as prepareTallyJson } from "./prepareTallyJson/entryFile.js";
3
+
4
+ const startFunc = ({ inClientData }) => {
5
+ try {
6
+ let data = prepareTallyJson();
7
+
8
+ const fromClientData = prepareClientData({
9
+ inTallyJson: data,
10
+ inClientData
11
+ });
12
+
13
+ return fromClientData;
14
+ } catch (err) {
15
+ console.error("Import Failed");
16
+ console.log(err.response?.data || err.message);
17
+ };
18
+ };
19
+
20
+ export default startFunc;
@@ -0,0 +1,53 @@
1
+ import { startFunc as ForLedger } from "./ForLedger/entryFile.js";
2
+ import { startFunc as ForInventory } from "./ForInventory/entryFile.js";
3
+ import changeCustomerDetails from "./ChangeCustomerDetails/index.js";
4
+
5
+ const startFunc = ({ inTallyJson, inClientData }) => {
6
+ try {
7
+ let data = inTallyJson;
8
+
9
+ const LocalClientData = inClientData;
10
+
11
+ const LocalInventoryItem = ForInventory({ inItemsJsonAsArray: LocalClientData.allinventoryentries });
12
+
13
+ const LocalLedgerItem = ForLedger({
14
+ inItemsJsonAsArray: LocalClientData.allinventoryentries,
15
+ inLedgerDetails: LocalClientData.customerDetails
16
+ });
17
+
18
+ changeCustomerDetails({
19
+ inTallyJson, inClientData
20
+ });
21
+
22
+ data.tallymessage[0].allinventoryentries = LocalInventoryItem;
23
+ data.tallymessage[0].ledgerentries = LocalLedgerItem;
24
+
25
+ return data;
26
+ } catch (err) {
27
+ console.error("Import Failed");
28
+ console.log(err.response?.data || err.message);
29
+ };
30
+ };
31
+
32
+ const changeCustomerDetails1 = ({ inLedgerName, inData }) => {
33
+ const CommonLedgerName = inLedgerName;
34
+
35
+ inData.tallymessage[0].partyname = CommonLedgerName;
36
+ inData.tallymessage[0].basicbuyername = CommonLedgerName;
37
+ inData.tallymessage[0].partyledgername = CommonLedgerName;
38
+ inData.tallymessage[0].consigneemailingname = CommonLedgerName;
39
+ inData.tallymessage[0].partymailingname = CommonLedgerName;
40
+ inData.tallymessage[0].basicbasepartyname = CommonLedgerName;
41
+ inData.tallymessage[0].gstregistrationtype = "Regular";
42
+ inData.tallymessage[0].partygstin = "37BEVPS3045F1Z1";
43
+ };
44
+
45
+ const changeVoucherDate = ({ inData, inDate }) => {
46
+ const localDate = inDate;
47
+
48
+ inData.tallymessage[0].date = localDate;
49
+ inData.tallymessage[0].vchstatusdate = localDate;
50
+ inData.tallymessage[0].effectivedate = localDate;
51
+ };
52
+
53
+ export { startFunc };
@@ -0,0 +1,29 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import { fileURLToPath } from "url";
5
+
6
+ import templateJson from "../../Import/Templates/template.json" with {type: "json"};
7
+
8
+ const startFunc = () => {
9
+ try {
10
+
11
+ // const __filename = fileURLToPath(import.meta.url);
12
+ // const __dirname = path.dirname(__filename);
13
+
14
+ // const filePath = path.join(__dirname, "../../Import/Templates/template.json");
15
+
16
+ // let template = fs.readFileSync(filePath, "utf8");
17
+
18
+ // let data = JSON.parse(template);
19
+
20
+ const data = structuredClone(templateJson);
21
+
22
+ return data;
23
+ } catch (err) {
24
+ console.error("Import Failed");
25
+ console.log(err.response?.data || err.message);
26
+ };
27
+ };
28
+
29
+ export { startFunc };
@@ -0,0 +1,16 @@
1
+ import { sendToTally } from "../core/impotToTally.js";
2
+ import prepareDataObject from "./PrepareDataObjectV1/entryFile.js";
3
+
4
+ import { validateImportVoucherInput } from "./utils/validateInput.js";
5
+
6
+ const importVoucherV1 = async (inClientData) => {
7
+ validateImportVoucherInput(inClientData); // 🔥 early fail
8
+
9
+ const bodyToSend = prepareDataObject({ inClientData });
10
+
11
+ return await sendToTally(bodyToSend);
12
+
13
+ return await true;
14
+ };
15
+
16
+ export default importVoucherV1;
@@ -2,4 +2,5 @@
2
2
  export { ledger } from "./ledger.js";
3
3
  export { stockItems } from "./stockitems.js";
4
4
 
5
- export { importVoucher } from "./importVoucher.js";
5
+ export { importVoucher } from "./importVoucher.js";
6
+ export * from "./importVoucherV1.js";