shareneus 1.5.93 → 1.5.94

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.
@@ -73,9 +73,40 @@ function getHeadersBySequence(headers) {
73
73
  .map((entry) => entry.header);
74
74
  }
75
75
  function getRenderableColumns(headerConfig) {
76
+ const hasTaxPercent = headerConfig.some((header) => isTaxPercentHeader(header));
77
+ const hasTaxAmount = headerConfig.some((header) => isTaxAmountHeader(header));
78
+ const hasTaxGroup = hasTaxPercent && hasTaxAmount;
76
79
  const columns = [];
77
80
  for (const header of headerConfig) {
78
- if (isTaxPercentHeader(header)) {
81
+ if (hasTaxGroup && isTaxPercentHeader(header)) {
82
+ columns.push({
83
+ type: 'tax',
84
+ taxKind: 'rate',
85
+ dbField: 'CGST',
86
+ width: getTaxSubWidth(header.width),
87
+ }, {
88
+ type: 'tax',
89
+ taxKind: 'amount',
90
+ dbField: 'CGST',
91
+ width: getTaxSubWidth(header.width),
92
+ });
93
+ continue;
94
+ }
95
+ if (hasTaxGroup && isTaxAmountHeader(header)) {
96
+ columns.push({
97
+ type: 'tax',
98
+ taxKind: 'rate',
99
+ dbField: 'SGST',
100
+ width: getTaxSubWidth(header.width),
101
+ }, {
102
+ type: 'tax',
103
+ taxKind: 'amount',
104
+ dbField: 'SGST',
105
+ width: getTaxSubWidth(header.width),
106
+ });
107
+ continue;
108
+ }
109
+ if (!hasTaxGroup && isTaxPercentHeader(header)) {
79
110
  columns.push({
80
111
  type: 'tax',
81
112
  taxKind: 'rate',
@@ -89,7 +120,7 @@ function getRenderableColumns(headerConfig) {
89
120
  });
90
121
  continue;
91
122
  }
92
- if (isTaxAmountHeader(header)) {
123
+ if (!hasTaxGroup && isTaxAmountHeader(header)) {
93
124
  columns.push({
94
125
  type: 'tax',
95
126
  taxKind: 'amount',
@@ -112,11 +143,13 @@ function getRenderableColumns(headerConfig) {
112
143
  return columns;
113
144
  }
114
145
  function buildHeaderRows(headerConfig) {
115
- const hasTaxGroup = headerConfig.some((header) => isTaxPercentHeader(header) || isTaxAmountHeader(header));
146
+ const hasTaxPercent = headerConfig.some((header) => isTaxPercentHeader(header));
147
+ const hasTaxAmount = headerConfig.some((header) => isTaxAmountHeader(header));
148
+ const hasTaxGroup = hasTaxPercent && hasTaxAmount;
116
149
  const hasDiscPercent = headerConfig.some((header) => header.text === 'Disc %');
117
150
  const hasDiscAmount = headerConfig.some((header) => isDiscountAmountHeader(header.text));
118
151
  const hasDiscGroup = hasDiscPercent && hasDiscAmount;
119
- const hasGroupedHeaders = hasTaxGroup || hasDiscGroup;
152
+ const hasGroupedHeaders = hasTaxPercent || hasTaxAmount || hasDiscGroup;
120
153
  if (!hasGroupedHeaders) {
121
154
  const singleRow = headerConfig.map((header) => (Object.assign({ text: header.text, dbFields: header.dbFields, stackFields: header.stackFields }, getHeaderCellStyle())));
122
155
  return [singleRow];
@@ -124,12 +157,22 @@ function buildHeaderRows(headerConfig) {
124
157
  const topRow = [];
125
158
  const subRow = [];
126
159
  for (const header of headerConfig) {
127
- if (isTaxPercentHeader(header)) {
160
+ if (hasTaxGroup && isTaxPercentHeader(header)) {
161
+ topRow.push(Object.assign({ text: 'CGST', colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
162
+ subRow.push(Object.assign({ text: '%', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'Amt', alignment: 'center' }, getHeaderCellStyle()));
163
+ continue;
164
+ }
165
+ if (hasTaxGroup && isTaxAmountHeader(header)) {
166
+ topRow.push(Object.assign({ text: 'SGST/UGST', colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
167
+ subRow.push(Object.assign({ text: '%', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'Amt', alignment: 'center' }, getHeaderCellStyle()));
168
+ continue;
169
+ }
170
+ if (!hasTaxGroup && isTaxPercentHeader(header)) {
128
171
  topRow.push(Object.assign({ text: header.text, colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
129
172
  subRow.push(Object.assign({ text: 'CGST', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'SGST/UGST', alignment: 'center' }, getHeaderCellStyle()));
130
173
  continue;
131
174
  }
132
- if (isTaxAmountHeader(header)) {
175
+ if (!hasTaxGroup && isTaxAmountHeader(header)) {
133
176
  topRow.push(Object.assign({ text: header.text, colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
134
177
  subRow.push(Object.assign({ text: 'CGST', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'SGST/UGST', alignment: 'center' }, getHeaderCellStyle()));
135
178
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.5.93",
3
+ "version": "1.5.94",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",