shareneus 1.6.14 → 1.6.16

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.
@@ -1,3 +1,3 @@
1
1
  export declare function GetTableHeader(itemsHeader: any[]): any[];
2
- export declare function getRenderableColumns(headerConfig: any[]): any[];
3
- export declare function buildHeaderRows(headerConfig: any[]): any[][];
2
+ export declare function getRenderableColumns(headerConfig: any[], sType?: string): any[];
3
+ export declare function buildHeaderRows(headerConfig: any[], sType?: string): any[][];
@@ -72,13 +72,48 @@ function getHeadersBySequence(headers) {
72
72
  })
73
73
  .map((entry) => entry.header);
74
74
  }
75
- function getRenderableColumns(headerConfig) {
75
+ function getRenderableColumns(headerConfig, sType = '') {
76
+ const isInter = sType === 'Inter';
76
77
  const hasTaxPercent = headerConfig.some((header) => isTaxPercentHeader(header));
77
78
  const hasTaxAmount = headerConfig.some((header) => isTaxAmountHeader(header));
78
79
  const hasTaxGroup = hasTaxPercent && hasTaxAmount;
79
80
  const columns = [];
80
81
  for (const header of headerConfig) {
81
- if (hasTaxGroup && isTaxPercentHeader(header)) {
82
+ // --- Inter / IGST ---
83
+ if (isInter && hasTaxGroup && isTaxPercentHeader(header)) {
84
+ columns.push({
85
+ type: 'tax',
86
+ taxKind: 'rate',
87
+ dbField: 'IGST',
88
+ width: getTaxSubWidth(header.width),
89
+ });
90
+ continue;
91
+ }
92
+ if (isInter && hasTaxGroup && isTaxAmountHeader(header)) {
93
+ columns.push({
94
+ type: 'tax',
95
+ taxKind: 'amount',
96
+ dbField: 'IGST',
97
+ width: getTaxSubWidth(header.width),
98
+ });
99
+ continue;
100
+ }
101
+ if (isInter && !hasTaxGroup && (isTaxPercentHeader(header) || isTaxAmountHeader(header))) {
102
+ columns.push({
103
+ type: 'tax',
104
+ taxKind: 'rate',
105
+ dbField: 'IGST',
106
+ width: getTaxSubWidth(header.width),
107
+ }, {
108
+ type: 'tax',
109
+ taxKind: 'amount',
110
+ dbField: 'IGST',
111
+ width: getTaxSubWidth(header.width),
112
+ });
113
+ continue;
114
+ }
115
+ // --- Intra / CGST + SGST ---
116
+ if (!isInter && hasTaxGroup && isTaxPercentHeader(header)) {
82
117
  columns.push({
83
118
  type: 'tax',
84
119
  taxKind: 'rate',
@@ -92,7 +127,7 @@ function getRenderableColumns(headerConfig) {
92
127
  });
93
128
  continue;
94
129
  }
95
- if (hasTaxGroup && isTaxAmountHeader(header)) {
130
+ if (!isInter && hasTaxGroup && isTaxAmountHeader(header)) {
96
131
  columns.push({
97
132
  type: 'tax',
98
133
  taxKind: 'rate',
@@ -106,7 +141,7 @@ function getRenderableColumns(headerConfig) {
106
141
  });
107
142
  continue;
108
143
  }
109
- if (!hasTaxGroup && isTaxPercentHeader(header)) {
144
+ if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
110
145
  columns.push({
111
146
  type: 'tax',
112
147
  taxKind: 'rate',
@@ -120,7 +155,7 @@ function getRenderableColumns(headerConfig) {
120
155
  });
121
156
  continue;
122
157
  }
123
- if (!hasTaxGroup && isTaxAmountHeader(header)) {
158
+ if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
124
159
  columns.push({
125
160
  type: 'tax',
126
161
  taxKind: 'amount',
@@ -142,7 +177,8 @@ function getRenderableColumns(headerConfig) {
142
177
  }
143
178
  return columns;
144
179
  }
145
- function buildHeaderRows(headerConfig) {
180
+ function buildHeaderRows(headerConfig, sType = '') {
181
+ const isInter = sType === 'Inter';
146
182
  const hasTaxPercent = headerConfig.some((header) => isTaxPercentHeader(header));
147
183
  const hasTaxAmount = headerConfig.some((header) => isTaxAmountHeader(header));
148
184
  const hasTaxGroup = hasTaxPercent && hasTaxAmount;
@@ -157,22 +193,39 @@ function buildHeaderRows(headerConfig) {
157
193
  const topRow = [];
158
194
  const subRow = [];
159
195
  for (const header of headerConfig) {
160
- if (hasTaxGroup && isTaxPercentHeader(header)) {
196
+ // --- Inter / IGST ---
197
+ if (isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
198
+ topRow.push(Object.assign({ text: 'IGST %', rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
199
+ subRow.push({});
200
+ continue;
201
+ }
202
+ if (isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
203
+ topRow.push(Object.assign({ text: 'IGST Amt', rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
204
+ subRow.push({});
205
+ continue;
206
+ }
207
+ if (isInter && hasTaxGroup && (isTaxPercentHeader(header) || isTaxAmountHeader(header))) {
208
+ topRow.push(Object.assign({ text: 'IGST', colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
209
+ subRow.push(Object.assign({ text: '%', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'Amt', alignment: 'center' }, getHeaderCellStyle()));
210
+ continue;
211
+ }
212
+ // --- Intra / CGST + SGST ---
213
+ if (!isInter && hasTaxGroup && isTaxPercentHeader(header)) {
161
214
  topRow.push(Object.assign({ text: 'CGST', colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
162
215
  subRow.push(Object.assign({ text: '%', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'Amt', alignment: 'center' }, getHeaderCellStyle()));
163
216
  continue;
164
217
  }
165
- if (hasTaxGroup && isTaxAmountHeader(header)) {
218
+ if (!isInter && hasTaxGroup && isTaxAmountHeader(header)) {
166
219
  topRow.push(Object.assign({ text: 'SGST/UGST', colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
167
220
  subRow.push(Object.assign({ text: '%', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'Amt', alignment: 'center' }, getHeaderCellStyle()));
168
221
  continue;
169
222
  }
170
- if (!hasTaxGroup && isTaxPercentHeader(header)) {
223
+ if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
171
224
  topRow.push(Object.assign({ text: header.text, colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
172
225
  subRow.push(Object.assign({ text: 'CGST', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'SGST/UGST', alignment: 'center' }, getHeaderCellStyle()));
173
226
  continue;
174
227
  }
175
- if (!hasTaxGroup && isTaxAmountHeader(header)) {
228
+ if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
176
229
  topRow.push(Object.assign({ text: header.text, colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
177
230
  subRow.push(Object.assign({ text: 'CGST', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'SGST/UGST', alignment: 'center' }, getHeaderCellStyle()));
178
231
  continue;
@@ -53,6 +53,10 @@ function formatFieldValue(item, fieldConfig, fixedTo) {
53
53
  return formatNumericLikeValue(rawValue, fixedTo, shouldSkipFixedTo(fieldConfig));
54
54
  }
55
55
  function getTaxValue(item, taxName, taxKind) {
56
+ if (taxName === 'IGST') {
57
+ const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
58
+ return getFirstFieldValue(item, fields);
59
+ }
56
60
  const fields = taxKind === 'rate'
57
61
  ? [`${taxName}Perc`, taxName]
58
62
  : [`${taxName}Amt`, taxName];
@@ -12,11 +12,13 @@ const CELL_PADDING_LEFT = 4;
12
12
  const CELL_PADDING_RIGHT = 4;
13
13
  const BORDER_WIDTH = 0.5;
14
14
  function buildInvoiceTableData(PDFInvoiceData, PrintConfig, availableWidth) {
15
+ var _a;
15
16
  const items = Array.isArray(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Items) ? PDFInvoiceData.Items : [];
16
17
  const services = Array.isArray(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Ops) ? PDFInvoiceData.Ops : [];
18
+ const sType = (_a = PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.SType) !== null && _a !== void 0 ? _a : '';
17
19
  const headerConfig = (0, pdf_table_header_1.GetTableHeader)(PrintConfig.TableConfig)[0];
18
- const renderColumns = (0, pdf_table_header_1.getRenderableColumns)(headerConfig);
19
- const headerRows = (0, pdf_table_header_1.buildHeaderRows)(headerConfig);
20
+ const renderColumns = (0, pdf_table_header_1.getRenderableColumns)(headerConfig, sType);
21
+ const headerRows = (0, pdf_table_header_1.buildHeaderRows)(headerConfig, sType);
20
22
  const fixedTo = resolveFixedTo(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.fixedTo);
21
23
  let body;
22
24
  let widths;
@@ -91,6 +93,7 @@ function calculateSectionTotals(rows) {
91
93
  acc.discountAmount += readNumericValue(row, ['Disc']);
92
94
  acc.cgstAmount += readNumericValue(row, ['CGSTAmt', 'CGST']);
93
95
  acc.sgstAmount += readNumericValue(row, ['SGSTAmt', 'SGST']);
96
+ acc.igstAmount += readNumericValue(row, ['IGSTAmt', 'IGST']);
94
97
  acc.lineTotal += readNumericValue(row, ['LineTotal']);
95
98
  return acc;
96
99
  }, {
@@ -99,6 +102,7 @@ function calculateSectionTotals(rows) {
99
102
  discountAmount: 0,
100
103
  cgstAmount: 0,
101
104
  sgstAmount: 0,
105
+ igstAmount: 0,
102
106
  lineTotal: 0
103
107
  });
104
108
  }
@@ -182,6 +186,16 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
182
186
  return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
183
187
  }
184
188
  }
189
+ if (header.text === 'IGST %') {
190
+ const value = (0, pdf_table_row_1.getFirstFieldValue)(item, ['IGSTPerc']);
191
+ const renderedValue = formatNumericLikeValue(value, fixedTo);
192
+ return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
193
+ }
194
+ if (header.text === 'IGST Amt') {
195
+ const value = (0, pdf_table_row_1.getFirstFieldValue)(item, ['IGSTAmt']);
196
+ const renderedValue = formatNumericLikeValue(value, fixedTo);
197
+ return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
198
+ }
185
199
  if (header.text === 'S.No') {
186
200
  const value = String(index + 1);
187
201
  return { text: value, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(value) };
@@ -222,6 +236,9 @@ function buildSectionTotalRow(columns, label, totals, fixedTo) {
222
236
  if (column.dbField === 'SGST' && column.taxKind === 'amount') {
223
237
  return buildTotalValueCell(formatAmount(totals.sgstAmount, fixedTo));
224
238
  }
239
+ if (column.dbField === 'IGST' && column.taxKind === 'amount') {
240
+ return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
241
+ }
225
242
  return buildTotalValueCell('');
226
243
  }
227
244
  const headerText = (_b = (_a = column.header) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '';
@@ -251,6 +268,9 @@ function buildFallbackSectionTotalRow(fallbackHeaderRow, label, totals, fixedTo)
251
268
  if (header.text === 'SGST' && header.taxKind === 'amount') {
252
269
  return buildTotalValueCell(formatAmount(totals.sgstAmount, fixedTo));
253
270
  }
271
+ if (header.text === 'IGST Amt' && header.taxKind === 'amount') {
272
+ return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
273
+ }
254
274
  if (header.text === 'Description') {
255
275
  return buildTotalLabelCell(label);
256
276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.14",
3
+ "version": "1.6.16",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",