shareneus 1.7.315 → 1.7.317

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.
@@ -85,7 +85,7 @@ function buildPartyDetailsSectionLayout(config) {
85
85
  }];
86
86
  }
87
87
  function resolveSalesBillToDetails(transactionData) {
88
- var _a, _b, _c, _d, _e, _f, _g;
88
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
89
89
  const billTo = (transactionData === null || transactionData === void 0 ? void 0 : transactionData.BillTo) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.Customer) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.Cust) || {};
90
90
  const address = normalizeAddress((billTo === null || billTo === void 0 ? void 0 : billTo.Adrs)
91
91
  || ((_a = transactionData === null || transactionData === void 0 ? void 0 : transactionData.BillTo) === null || _a === void 0 ? void 0 : _a.Adrs)
@@ -94,10 +94,10 @@ function resolveSalesBillToDetails(transactionData) {
94
94
  || ((_b = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Customer) === null || _b === void 0 ? void 0 : _b.Adrs)
95
95
  || ((_c = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Cust) === null || _c === void 0 ? void 0 : _c.Adrs));
96
96
  const name = (0, pdf_shared_utils_1.firstValue)(billTo === null || billTo === void 0 ? void 0 : billTo.Name, billTo === null || billTo === void 0 ? void 0 : billTo.CName, (_d = transactionData === null || transactionData === void 0 ? void 0 : transactionData.BillTo) === null || _d === void 0 ? void 0 : _d.Name, (_e = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Customer) === null || _e === void 0 ? void 0 : _e.Name, (_f = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Cust) === null || _f === void 0 ? void 0 : _f.Name, transactionData === null || transactionData === void 0 ? void 0 : transactionData.CustomerName);
97
- const gstin = (0, pdf_shared_utils_1.firstValue)(billTo === null || billTo === void 0 ? void 0 : billTo.GSTIN, billTo === null || billTo === void 0 ? void 0 : billTo.GSTNo);
97
+ const gstin = (0, pdf_shared_utils_1.firstValue)((_g = billTo === null || billTo === void 0 ? void 0 : billTo.TaxId) === null || _g === void 0 ? void 0 : _g.GSTIN, (_h = billTo === null || billTo === void 0 ? void 0 : billTo.TaxId) === null || _h === void 0 ? void 0 : _h.GSTNo);
98
98
  const contactInfo = resolvePhoneFromContacts(billTo === null || billTo === void 0 ? void 0 : billTo.Cons);
99
99
  const directPhone = (0, pdf_shared_utils_1.firstValue)(billTo === null || billTo === void 0 ? void 0 : billTo.Ph, billTo === null || billTo === void 0 ? void 0 : billTo.Phone, billTo === null || billTo === void 0 ? void 0 : billTo.Mobile);
100
- const ownerName = (0, pdf_shared_utils_1.firstValue)((_g = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Cust) === null || _g === void 0 ? void 0 : _g.Name);
100
+ const ownerName = (0, pdf_shared_utils_1.firstValue)((_j = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Cust) === null || _j === void 0 ? void 0 : _j.Name);
101
101
  return {
102
102
  name,
103
103
  addressLines: buildAddressLines(address),
@@ -109,12 +109,13 @@ function resolveSalesBillToDetails(transactionData) {
109
109
  };
110
110
  }
111
111
  function resolveSalesShipToDetails(transactionData) {
112
+ var _a, _b;
112
113
  const shipTo = (transactionData === null || transactionData === void 0 ? void 0 : transactionData.ShipTo) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.ShippmentTo) || {};
113
114
  const address = normalizeAddress((shipTo === null || shipTo === void 0 ? void 0 : shipTo.Adrs)
114
115
  || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.ShipAddress)
115
116
  || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.ShipToAddress));
116
117
  const name = (0, pdf_shared_utils_1.firstValue)(shipTo === null || shipTo === void 0 ? void 0 : shipTo.Name, shipTo === null || shipTo === void 0 ? void 0 : shipTo.CName);
117
- const gstin = (0, pdf_shared_utils_1.firstValue)(shipTo === null || shipTo === void 0 ? void 0 : shipTo.GSTIN, shipTo === null || shipTo === void 0 ? void 0 : shipTo.GSTNo);
118
+ const gstin = (0, pdf_shared_utils_1.firstValue)((_a = shipTo === null || shipTo === void 0 ? void 0 : shipTo.TaxId) === null || _a === void 0 ? void 0 : _a.GSTIN, (_b = shipTo === null || shipTo === void 0 ? void 0 : shipTo.TaxId) === null || _b === void 0 ? void 0 : _b.GSTNo);
118
119
  return {
119
120
  name,
120
121
  addressLines: buildAddressLines(address),
@@ -123,7 +124,7 @@ function resolveSalesShipToDetails(transactionData) {
123
124
  };
124
125
  }
125
126
  function resolvePurchaseBFromDetails(transactionData) {
126
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
127
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
127
128
  const billTo = (transactionData === null || transactionData === void 0 ? void 0 : transactionData.BFrom) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.BillTo) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.Vendor) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.Vnd) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.Supplier) || {};
128
129
  const address = normalizeAddress((billTo === null || billTo === void 0 ? void 0 : billTo.Adrs)
129
130
  || ((_a = transactionData === null || transactionData === void 0 ? void 0 : transactionData.BFrom) === null || _a === void 0 ? void 0 : _a.Adrs)
@@ -135,7 +136,7 @@ function resolvePurchaseBFromDetails(transactionData) {
135
136
  || ((_d = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Vnd) === null || _d === void 0 ? void 0 : _d.Adrs)
136
137
  || ((_e = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Supplier) === null || _e === void 0 ? void 0 : _e.Adrs));
137
138
  const name = (0, pdf_shared_utils_1.firstValue)(billTo === null || billTo === void 0 ? void 0 : billTo.Name, billTo === null || billTo === void 0 ? void 0 : billTo.CName, (_f = transactionData === null || transactionData === void 0 ? void 0 : transactionData.BFrom) === null || _f === void 0 ? void 0 : _f.Name, (_g = transactionData === null || transactionData === void 0 ? void 0 : transactionData.BillTo) === null || _g === void 0 ? void 0 : _g.Name, (_h = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Vendor) === null || _h === void 0 ? void 0 : _h.Name, (_j = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Vnd) === null || _j === void 0 ? void 0 : _j.Name, (_k = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Supplier) === null || _k === void 0 ? void 0 : _k.Name, transactionData === null || transactionData === void 0 ? void 0 : transactionData.BFromName, transactionData === null || transactionData === void 0 ? void 0 : transactionData.VendorName);
138
- const gstin = (0, pdf_shared_utils_1.firstValue)(billTo === null || billTo === void 0 ? void 0 : billTo.GSTIN, billTo === null || billTo === void 0 ? void 0 : billTo.GSTNo);
139
+ const gstin = (0, pdf_shared_utils_1.firstValue)((_l = billTo === null || billTo === void 0 ? void 0 : billTo.TaxId) === null || _l === void 0 ? void 0 : _l.GSTIN, (_m = billTo === null || billTo === void 0 ? void 0 : billTo.TaxId) === null || _m === void 0 ? void 0 : _m.GSTNo);
139
140
  const contactInfo = resolvePhoneFromContacts(billTo === null || billTo === void 0 ? void 0 : billTo.Contact);
140
141
  const directPhone = (0, pdf_shared_utils_1.firstValue)(billTo === null || billTo === void 0 ? void 0 : billTo.Ph, billTo === null || billTo === void 0 ? void 0 : billTo.Phone, billTo === null || billTo === void 0 ? void 0 : billTo.Mobile);
141
142
  return {
@@ -188,13 +189,14 @@ function resolvePurchaseOtherDetails(transactionData, printConfig = {}) {
188
189
  };
189
190
  }
190
191
  function resolvePurchaseShipFromDetails(transactionData) {
192
+ var _a, _b;
191
193
  const shipFrom = (transactionData === null || transactionData === void 0 ? void 0 : transactionData.SFrom) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.ShipFrom) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.From) || {};
192
194
  const address = normalizeAddress((shipFrom === null || shipFrom === void 0 ? void 0 : shipFrom.Adrs)
193
195
  || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.SFromAddress)
194
196
  || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.ShipFromAddress)
195
197
  || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.FromAddress));
196
198
  const name = (0, pdf_shared_utils_1.firstValue)(shipFrom === null || shipFrom === void 0 ? void 0 : shipFrom.Name, shipFrom === null || shipFrom === void 0 ? void 0 : shipFrom.CName, shipFrom === null || shipFrom === void 0 ? void 0 : shipFrom.WhName, transactionData === null || transactionData === void 0 ? void 0 : transactionData.SFromName, transactionData === null || transactionData === void 0 ? void 0 : transactionData.ShipFromName);
197
- const gstin = (0, pdf_shared_utils_1.firstValue)(shipFrom === null || shipFrom === void 0 ? void 0 : shipFrom.GSTIN, shipFrom === null || shipFrom === void 0 ? void 0 : shipFrom.GSTNo);
199
+ const gstin = (0, pdf_shared_utils_1.firstValue)((_a = shipFrom === null || shipFrom === void 0 ? void 0 : shipFrom.TaxId) === null || _a === void 0 ? void 0 : _a.GSTIN, (_b = shipFrom === null || shipFrom === void 0 ? void 0 : shipFrom.TaxId) === null || _b === void 0 ? void 0 : _b.GSTNo);
198
200
  return {
199
201
  name,
200
202
  addressLines: buildAddressLines(address),
@@ -203,10 +205,11 @@ function resolvePurchaseShipFromDetails(transactionData) {
203
205
  };
204
206
  }
205
207
  function resolveInsuranceDetails(transactionData) {
208
+ var _a, _b;
206
209
  const insurance = (transactionData === null || transactionData === void 0 ? void 0 : transactionData.Insurance) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.Ins) || (transactionData === null || transactionData === void 0 ? void 0 : transactionData.Insurer) || {};
207
210
  const address = normalizeAddress((insurance === null || insurance === void 0 ? void 0 : insurance.Adrs) || (insurance === null || insurance === void 0 ? void 0 : insurance.Address));
208
211
  const name = (0, pdf_shared_utils_1.firstValue)(insurance === null || insurance === void 0 ? void 0 : insurance.Name, insurance === null || insurance === void 0 ? void 0 : insurance.Company, insurance === null || insurance === void 0 ? void 0 : insurance.Provider, insurance === null || insurance === void 0 ? void 0 : insurance.InsName);
209
- const gstin = (0, pdf_shared_utils_1.firstValue)(insurance === null || insurance === void 0 ? void 0 : insurance.GSTIN, insurance === null || insurance === void 0 ? void 0 : insurance.GSTNo);
212
+ const gstin = (0, pdf_shared_utils_1.firstValue)((_a = insurance === null || insurance === void 0 ? void 0 : insurance.TaxId) === null || _a === void 0 ? void 0 : _a.GSTIN, (_b = insurance === null || insurance === void 0 ? void 0 : insurance.TaxId) === null || _b === void 0 ? void 0 : _b.GSTNo);
210
213
  return {
211
214
  name,
212
215
  addressLines: buildAddressLines(address),
@@ -107,7 +107,7 @@ function getRenderableColumns(headerConfig, sType = '') {
107
107
  columns.push({
108
108
  type: 'tax',
109
109
  taxKind: 'rate',
110
- dbField: 'IGST',
110
+ dbField: 'GST',
111
111
  width: header.width,
112
112
  });
113
113
  continue;
@@ -116,7 +116,7 @@ function getRenderableColumns(headerConfig, sType = '') {
116
116
  columns.push({
117
117
  type: 'tax',
118
118
  taxKind: 'amount',
119
- dbField: 'IGST',
119
+ dbField: 'GST',
120
120
  width: header.width,
121
121
  });
122
122
  continue;
@@ -154,13 +154,8 @@ function getRenderableColumns(headerConfig, sType = '') {
154
154
  columns.push({
155
155
  type: 'tax',
156
156
  taxKind: 'rate',
157
- dbField: 'CGST',
158
- width: getTaxSubWidth(header.width, 'rate'),
159
- }, {
160
- type: 'tax',
161
- taxKind: 'rate',
162
- dbField: 'SGST',
163
- width: getTaxSubWidth(header.width, 'rate'),
157
+ dbField: 'GST',
158
+ width: header.width,
164
159
  });
165
160
  continue;
166
161
  }
@@ -168,13 +163,8 @@ function getRenderableColumns(headerConfig, sType = '') {
168
163
  columns.push({
169
164
  type: 'tax',
170
165
  taxKind: 'amount',
171
- dbField: 'CGST',
172
- width: getTaxSubWidth(header.width, 'amount'),
173
- }, {
174
- type: 'tax',
175
- taxKind: 'amount',
176
- dbField: 'SGST',
177
- width: getTaxSubWidth(header.width, 'amount'),
166
+ dbField: 'GST',
167
+ width: header.width,
178
168
  });
179
169
  continue;
180
170
  }
@@ -194,9 +184,9 @@ function buildHeaderRows(headerConfig, sType = '') {
194
184
  const hasDiscPercent = headerConfig.some((header) => header.text === 'Disc %');
195
185
  const hasDiscAmount = headerConfig.some((header) => isDiscountAmountHeader(header.text));
196
186
  const hasDiscGroup = hasDiscPercent && hasDiscAmount;
197
- const hasGroupedHeaders = hasTaxPercent || hasTaxAmount || hasDiscGroup;
187
+ const hasGroupedHeaders = hasTaxGroup || hasDiscGroup;
198
188
  if (!hasGroupedHeaders) {
199
- const singleRow = headerConfig.map((header) => (Object.assign({ text: header.text, alignment: header.alignment, dbFields: header.dbFields, stackFields: header.stackFields }, getHeaderCellStyle())));
189
+ const singleRow = headerConfig.map((header) => (Object.assign({ text: getSingleTaxHeaderText(header), alignment: header.alignment, dbFields: header.dbFields, stackFields: header.stackFields }, getHeaderCellStyle())));
200
190
  return [singleRow];
201
191
  }
202
192
  const topRow = [];
@@ -213,12 +203,12 @@ function buildHeaderRows(headerConfig, sType = '') {
213
203
  continue;
214
204
  }
215
205
  if (isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
216
- topRow.push(Object.assign({ text: 'IGST %', rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
206
+ topRow.push(Object.assign({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
217
207
  subRow.push({});
218
208
  continue;
219
209
  }
220
210
  if (isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
221
- topRow.push(Object.assign({ text: 'IGST Amt', rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
211
+ topRow.push(Object.assign({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
222
212
  subRow.push({});
223
213
  continue;
224
214
  }
@@ -234,13 +224,13 @@ function buildHeaderRows(headerConfig, sType = '') {
234
224
  continue;
235
225
  }
236
226
  if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
237
- topRow.push(Object.assign({ text: header.text, colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
238
- subRow.push(Object.assign({ text: 'CGST', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'SGST/UGST', alignment: 'center' }, getHeaderCellStyle()));
227
+ topRow.push(Object.assign({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
228
+ subRow.push({});
239
229
  continue;
240
230
  }
241
231
  if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
242
- topRow.push(Object.assign({ text: header.text, colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
243
- subRow.push(Object.assign({ text: 'CGST', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'SGST/UGST', alignment: 'center' }, getHeaderCellStyle()));
232
+ topRow.push(Object.assign({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
233
+ subRow.push({});
244
234
  continue;
245
235
  }
246
236
  if (hasDiscGroup && header.text === 'Disc %') {
@@ -272,9 +262,18 @@ function isTaxPercentHeader(header) {
272
262
  function isTaxAmountHeader(header) {
273
263
  return normalizeHeaderText(header === null || header === void 0 ? void 0 : header.text) === 'TAXAMOUNT';
274
264
  }
265
+ function getSingleTaxHeaderText(header) {
266
+ if (isTaxPercentHeader(header)) {
267
+ return 'GST(%)';
268
+ }
269
+ if (isTaxAmountHeader(header)) {
270
+ return 'GST Amt';
271
+ }
272
+ return header.text;
273
+ }
275
274
  function isTaxHeaderConfig(header) {
276
- var _a, _b, _c;
277
- const title = (_c = (_b = (_a = header === null || header === void 0 ? void 0 : header.title) !== null && _a !== void 0 ? _a : header === null || header === void 0 ? void 0 : header.CustTitle) !== null && _b !== void 0 ? _b : header === null || header === void 0 ? void 0 : header.Tital) !== null && _c !== void 0 ? _c : header === null || header === void 0 ? void 0 : header.text;
275
+ var _a, _b, _c, _d;
276
+ const title = (_d = (_c = (_b = (_a = header === null || header === void 0 ? void 0 : header.Title) !== null && _a !== void 0 ? _a : header === null || header === void 0 ? void 0 : header.Tital) !== null && _b !== void 0 ? _b : header === null || header === void 0 ? void 0 : header.CustTitle) !== null && _c !== void 0 ? _c : header === null || header === void 0 ? void 0 : header.Tital) !== null && _d !== void 0 ? _d : header === null || header === void 0 ? void 0 : header.text;
278
277
  const normalizedTitle = normalizeHeaderText(title);
279
278
  return normalizedTitle === 'TAX%' || normalizedTitle === 'TAXAMOUNT';
280
279
  }
@@ -59,6 +59,20 @@ function formatFieldValue(item, fieldConfig, fixedTo) {
59
59
  return formatNumericLikeValue(signedValue, fixedTo, shouldSkipFixedTo(fieldConfig));
60
60
  }
61
61
  function getTaxValue(item, taxName, taxKind) {
62
+ if (taxName === 'GST') {
63
+ if (taxKind === 'rate') {
64
+ return getCombinedTaxValue(item, ['CombinedTaxPercentage', 'GSTPerc'], [
65
+ ['CGSTPerc', 'CGST'],
66
+ ['SGSTPerc', 'SGST'],
67
+ ['IGSTPerc', 'IGST']
68
+ ]);
69
+ }
70
+ return getCombinedTaxValue(item, ['TotalTaxAmount', 'TaxAmount', 'GSTAmt'], [
71
+ ['CGSTAmt', 'CGST'],
72
+ ['SGSTAmt', 'SGST'],
73
+ ['IGSTAmt', 'IGST']
74
+ ]);
75
+ }
62
76
  if (taxName === 'IGST') {
63
77
  const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
64
78
  return getFirstFieldValue(item, fields);
@@ -68,6 +82,23 @@ function getTaxValue(item, taxName, taxKind) {
68
82
  : [`${taxName}Amt`, taxName];
69
83
  return getFirstFieldValue(item, fields);
70
84
  }
85
+ function getCombinedTaxValue(item, combinedFields, componentFieldGroups) {
86
+ const combinedValue = getFirstFieldValue(item, combinedFields);
87
+ if (combinedValue) {
88
+ return combinedValue;
89
+ }
90
+ const values = componentFieldGroups
91
+ .map((fields) => getFirstFieldValue(item, fields))
92
+ .filter((value) => value !== '');
93
+ if (values.length === 0) {
94
+ return '';
95
+ }
96
+ const numericValues = values.map((value) => Number(value.replace(/,/g, '').trim()));
97
+ if (numericValues.some((value) => !Number.isFinite(value))) {
98
+ return values[0];
99
+ }
100
+ return String(numericValues.reduce((sum, value) => sum + value, 0));
101
+ }
71
102
  function shouldRenderNegativeTaxAmount(item, column) {
72
103
  return !!(item === null || item === void 0 ? void 0 : item.Ret) && (column === null || column === void 0 ? void 0 : column.taxKind) === 'amount';
73
104
  }
@@ -262,6 +262,9 @@ function buildSectionTotalRow(columns, label, totals, fixedTo) {
262
262
  if (column.dbField === 'IGST' && column.taxKind === 'amount') {
263
263
  return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
264
264
  }
265
+ if (column.dbField === 'GST' && column.taxKind === 'amount') {
266
+ return buildTotalValueCell(formatAmount(totals.cgstAmount + totals.sgstAmount + totals.igstAmount, fixedTo));
267
+ }
265
268
  return buildTotalValueCell('');
266
269
  }
267
270
  const headerText = (_b = (_a = column.header) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.315",
3
+ "version": "1.7.317",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -104,8 +104,8 @@ function resolveSalesBillToDetails(transactionData: any) {
104
104
  transactionData?.CustomerName
105
105
  );
106
106
  const gstin = firstValue(
107
- billTo?.GSTIN,
108
- billTo?.GSTNo
107
+ billTo?.TaxId?.GSTIN,
108
+ billTo?.TaxId?.GSTNo
109
109
  );
110
110
  const contactInfo = resolvePhoneFromContacts(billTo?.Cons);
111
111
  const directPhone = firstValue(billTo?.Ph, billTo?.Phone, billTo?.Mobile);
@@ -129,7 +129,7 @@ function resolveSalesShipToDetails(transactionData: any) {
129
129
  || transactionData?.ShipToAddress
130
130
  );
131
131
  const name = firstValue(shipTo?.Name, shipTo?.CName);
132
- const gstin = firstValue(shipTo?.GSTIN, shipTo?.GSTNo);
132
+ const gstin = firstValue(shipTo?.TaxId?.GSTIN, shipTo?.TaxId?.GSTNo);
133
133
  return {
134
134
  name,
135
135
  addressLines: buildAddressLines(address),
@@ -163,8 +163,8 @@ function resolvePurchaseBFromDetails(transactionData: any) {
163
163
  transactionData?.VendorName
164
164
  );
165
165
  const gstin = firstValue(
166
- billTo?.GSTIN,
167
- billTo?.GSTNo
166
+ billTo?.TaxId?.GSTIN,
167
+ billTo?.TaxId?.GSTNo
168
168
  );
169
169
  const contactInfo = resolvePhoneFromContacts(billTo?.Contact);
170
170
  const directPhone = firstValue(billTo?.Ph, billTo?.Phone, billTo?.Mobile);
@@ -237,7 +237,7 @@ function resolvePurchaseShipFromDetails(transactionData: any) {
237
237
  transactionData?.SFromName,
238
238
  transactionData?.ShipFromName
239
239
  );
240
- const gstin = firstValue(shipFrom?.GSTIN, shipFrom?.GSTNo);
240
+ const gstin = firstValue(shipFrom?.TaxId?.GSTIN, shipFrom?.TaxId?.GSTNo);
241
241
 
242
242
  return {
243
243
  name,
@@ -256,7 +256,7 @@ function resolveInsuranceDetails(transactionData: any) {
256
256
  insurance?.Provider,
257
257
  insurance?.InsName
258
258
  );
259
- const gstin = firstValue(insurance?.GSTIN, insurance?.GSTNo);
259
+ const gstin = firstValue(insurance?.TaxId?.GSTIN, insurance?.TaxId?.GSTNo);
260
260
  return {
261
261
  name,
262
262
  addressLines: buildAddressLines(address),
@@ -117,7 +117,7 @@ export function getRenderableColumns(headerConfig: any[], sType: string = '') {
117
117
  columns.push({
118
118
  type: 'tax',
119
119
  taxKind: 'rate',
120
- dbField: 'IGST',
120
+ dbField: 'GST',
121
121
  width: header.width,
122
122
  });
123
123
  continue;
@@ -127,7 +127,7 @@ export function getRenderableColumns(headerConfig: any[], sType: string = '') {
127
127
  columns.push({
128
128
  type: 'tax',
129
129
  taxKind: 'amount',
130
- dbField: 'IGST',
130
+ dbField: 'GST',
131
131
  width: header.width,
132
132
  });
133
133
  continue;
@@ -171,38 +171,22 @@ export function getRenderableColumns(headerConfig: any[], sType: string = '') {
171
171
  }
172
172
 
173
173
  if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
174
- columns.push(
175
- {
176
- type: 'tax',
177
- taxKind: 'rate',
178
- dbField: 'CGST',
179
- width: getTaxSubWidth(header.width, 'rate'),
180
- },
181
- {
182
- type: 'tax',
183
- taxKind: 'rate',
184
- dbField: 'SGST',
185
- width: getTaxSubWidth(header.width, 'rate'),
186
- }
187
- );
174
+ columns.push({
175
+ type: 'tax',
176
+ taxKind: 'rate',
177
+ dbField: 'GST',
178
+ width: header.width,
179
+ });
188
180
  continue;
189
181
  }
190
182
 
191
183
  if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
192
- columns.push(
193
- {
194
- type: 'tax',
195
- taxKind: 'amount',
196
- dbField: 'CGST',
197
- width: getTaxSubWidth(header.width, 'amount'),
198
- },
199
- {
200
- type: 'tax',
201
- taxKind: 'amount',
202
- dbField: 'SGST',
203
- width: getTaxSubWidth(header.width, 'amount'),
204
- }
205
- );
184
+ columns.push({
185
+ type: 'tax',
186
+ taxKind: 'amount',
187
+ dbField: 'GST',
188
+ width: header.width,
189
+ });
206
190
  continue;
207
191
  }
208
192
 
@@ -223,11 +207,11 @@ export function buildHeaderRows(headerConfig: any[], sType: string = '') {
223
207
  const hasDiscPercent = headerConfig.some((header: any) => header.text === 'Disc %');
224
208
  const hasDiscAmount = headerConfig.some((header: any) => isDiscountAmountHeader(header.text));
225
209
  const hasDiscGroup = hasDiscPercent && hasDiscAmount;
226
- const hasGroupedHeaders = hasTaxPercent || hasTaxAmount || hasDiscGroup;
210
+ const hasGroupedHeaders = hasTaxGroup || hasDiscGroup;
227
211
 
228
212
  if (!hasGroupedHeaders) {
229
213
  const singleRow = headerConfig.map((header: any) => ({
230
- text: header.text,
214
+ text: getSingleTaxHeaderText(header),
231
215
  alignment: header.alignment,
232
216
  dbFields: header.dbFields,
233
217
  stackFields: header.stackFields,
@@ -259,13 +243,13 @@ export function buildHeaderRows(headerConfig: any[], sType: string = '') {
259
243
  }
260
244
 
261
245
  if (isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
262
- topRow.push({ text: 'IGST %', rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
246
+ topRow.push({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
263
247
  subRow.push({});
264
248
  continue;
265
249
  }
266
250
 
267
251
  if (isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
268
- topRow.push({ text: 'IGST Amt', rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
252
+ topRow.push({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
269
253
  subRow.push({});
270
254
  continue;
271
255
  }
@@ -296,26 +280,14 @@ export function buildHeaderRows(headerConfig: any[], sType: string = '') {
296
280
  }
297
281
 
298
282
  if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
299
- topRow.push(
300
- { text: header.text, colSpan: 2, alignment: 'center', ...getHeaderCellStyle() },
301
- {}
302
- );
303
- subRow.push(
304
- { text: 'CGST', alignment: 'center', ...getHeaderCellStyle() },
305
- { text: 'SGST/UGST', alignment: 'center', ...getHeaderCellStyle() }
306
- );
283
+ topRow.push({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
284
+ subRow.push({});
307
285
  continue;
308
286
  }
309
287
 
310
288
  if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
311
- topRow.push(
312
- { text: header.text, colSpan: 2, alignment: 'center', ...getHeaderCellStyle() },
313
- {}
314
- );
315
- subRow.push(
316
- { text: 'CGST', alignment: 'center', ...getHeaderCellStyle() },
317
- { text: 'SGST/UGST', alignment: 'center', ...getHeaderCellStyle() }
318
- );
289
+ topRow.push({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
290
+ subRow.push({});
319
291
  continue;
320
292
  }
321
293
 
@@ -362,8 +334,18 @@ function isTaxAmountHeader(header: any) {
362
334
  return normalizeHeaderText(header?.text) === 'TAXAMOUNT';
363
335
  }
364
336
 
337
+ function getSingleTaxHeaderText(header: any) {
338
+ if (isTaxPercentHeader(header)) {
339
+ return 'GST(%)';
340
+ }
341
+ if (isTaxAmountHeader(header)) {
342
+ return 'GST Amt';
343
+ }
344
+ return header.text;
345
+ }
346
+
365
347
  function isTaxHeaderConfig(header: any) {
366
- const title = header?.title ?? header?.CustTitle ?? header?.Tital ?? header?.text;
348
+ const title = header?.Title ?? header?.Tital ?? header?.CustTitle ?? header?.Tital ?? header?.text;
367
349
  const normalizedTitle = normalizeHeaderText(title);
368
350
  return normalizedTitle === 'TAX%' || normalizedTitle === 'TAXAMOUNT';
369
351
  }
@@ -59,16 +59,53 @@ function formatFieldValue(item: any, fieldConfig: any, fixedTo: number) {
59
59
  return formatNumericLikeValue(signedValue, fixedTo, shouldSkipFixedTo(fieldConfig));
60
60
  }
61
61
 
62
- function getTaxValue(item: any, taxName: 'CGST' | 'SGST' | 'IGST', taxKind: 'rate' | 'amount') {
63
- if (taxName === 'IGST') {
64
- const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
65
- return getFirstFieldValue(item, fields);
66
- }
62
+ function getTaxValue(item: any, taxName: 'CGST' | 'SGST' | 'IGST' | 'GST', taxKind: 'rate' | 'amount') {
63
+ if (taxName === 'GST') {
64
+ if (taxKind === 'rate') {
65
+ return getCombinedTaxValue(item, ['CombinedTaxPercentage', 'GSTPerc'], [
66
+ ['CGSTPerc', 'CGST'],
67
+ ['SGSTPerc', 'SGST'],
68
+ ['IGSTPerc', 'IGST']
69
+ ]);
70
+ }
71
+ return getCombinedTaxValue(item, ['TotalTaxAmount', 'TaxAmount', 'GSTAmt'], [
72
+ ['CGSTAmt', 'CGST'],
73
+ ['SGSTAmt', 'SGST'],
74
+ ['IGSTAmt', 'IGST']
75
+ ]);
76
+ }
77
+
78
+ if (taxName === 'IGST') {
79
+ const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
80
+ return getFirstFieldValue(item, fields);
81
+ }
67
82
  const fields = taxKind === 'rate'
68
83
  ? [`${taxName}Perc`, taxName]
69
84
  : [`${taxName}Amt`, taxName];
70
- return getFirstFieldValue(item, fields);
71
- }
85
+ return getFirstFieldValue(item, fields);
86
+ }
87
+
88
+ function getCombinedTaxValue(item: any, combinedFields: string[], componentFieldGroups: string[][]) {
89
+ const combinedValue = getFirstFieldValue(item, combinedFields);
90
+ if (combinedValue) {
91
+ return combinedValue;
92
+ }
93
+
94
+ const values = componentFieldGroups
95
+ .map((fields: string[]) => getFirstFieldValue(item, fields))
96
+ .filter((value: string) => value !== '');
97
+
98
+ if (values.length === 0) {
99
+ return '';
100
+ }
101
+
102
+ const numericValues = values.map((value: string) => Number(value.replace(/,/g, '').trim()));
103
+ if (numericValues.some((value: number) => !Number.isFinite(value))) {
104
+ return values[0];
105
+ }
106
+
107
+ return String(numericValues.reduce((sum: number, value: number) => sum + value, 0));
108
+ }
72
109
 
73
110
  function shouldRenderNegativeTaxAmount(item: any, column: any) {
74
111
  return !!item?.Ret && column?.taxKind === 'amount';
@@ -275,11 +275,14 @@ function buildSectionTotalRow(columns: any[], label: string, totals: any, fixedT
275
275
  if (column.dbField === 'SGST' && column.taxKind === 'amount') {
276
276
  return buildTotalValueCell(formatAmount(totals.sgstAmount, fixedTo));
277
277
  }
278
- if (column.dbField === 'IGST' && column.taxKind === 'amount') {
279
- return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
280
- }
281
- return buildTotalValueCell('');
282
- }
278
+ if (column.dbField === 'IGST' && column.taxKind === 'amount') {
279
+ return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
280
+ }
281
+ if (column.dbField === 'GST' && column.taxKind === 'amount') {
282
+ return buildTotalValueCell(formatAmount(totals.cgstAmount + totals.sgstAmount + totals.igstAmount, fixedTo));
283
+ }
284
+ return buildTotalValueCell('');
285
+ }
283
286
 
284
287
  const headerText = column.header?.text ?? '';
285
288
  if (headerText === 'Description') {