shareneus 1.6.97 → 1.6.98

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.
@@ -94,7 +94,8 @@ function negateNumericLikeValue(value) {
94
94
  return String(normalized === 0 ? 0 : -Math.abs(normalized));
95
95
  }
96
96
  function getFirstFieldValue(item, dbFields = []) {
97
- for (const field of dbFields) {
97
+ const fields = Array.isArray(dbFields) ? dbFields : [dbFields];
98
+ for (const field of fields) {
98
99
  const value = readValue(item, field);
99
100
  if (value !== undefined && value !== null && value !== '') {
100
101
  return String(value);
@@ -103,13 +104,14 @@ function getFirstFieldValue(item, dbFields = []) {
103
104
  return '';
104
105
  }
105
106
  function readValue(item, field) {
106
- if (!item || !field) {
107
+ const normalizedField = normalizeDbFieldPath(field);
108
+ if (!item || !normalizedField) {
107
109
  return undefined;
108
110
  }
109
- if (item[field] !== undefined) {
110
- return item[field];
111
+ if (item[normalizedField] !== undefined) {
112
+ return item[normalizedField];
111
113
  }
112
- const dottedPathValue = field.split('.').reduce((current, key) => {
114
+ const dottedPathValue = normalizedField.split('.').reduce((current, key) => {
113
115
  if (current && current[key] !== undefined) {
114
116
  return current[key];
115
117
  }
@@ -118,7 +120,7 @@ function readValue(item, field) {
118
120
  if (dottedPathValue !== undefined) {
119
121
  return dottedPathValue;
120
122
  }
121
- return deepFindByKey(item, field);
123
+ return deepFindByKey(item, normalizedField);
122
124
  }
123
125
  function deepFindByKey(source, field) {
124
126
  if (!source || typeof source !== 'object') {
@@ -142,6 +144,9 @@ function getNumericAlignment(value) {
142
144
  return isNumericLike(value) ? 'right' : 'left';
143
145
  }
144
146
  function getCellAlignment(headerText, value) {
147
+ if (isRightAlignedHeader(headerText)) {
148
+ return 'right';
149
+ }
145
150
  if (isLeftAlignedHeader(headerText)) {
146
151
  return 'left';
147
152
  }
@@ -155,7 +160,11 @@ function isNumericLike(value) {
155
160
  return /^-?\d+(\.\d+)?$/.test(normalized);
156
161
  }
157
162
  function isLeftAlignedHeader(headerText) {
158
- return headerText === 'Qty' || headerText === 'Offer Qty';
163
+ return false;
164
+ }
165
+ function isRightAlignedHeader(headerText) {
166
+ const normalizedHeader = String(headerText !== null && headerText !== void 0 ? headerText : '').replace(/\s+/g, '').trim().toUpperCase();
167
+ return normalizedHeader === 'QTY' || normalizedHeader === 'OFFERQTY';
159
168
  }
160
169
  function formatNumericLikeValue(value, fixedTo, skipFixedTo = false) {
161
170
  if (skipFixedTo) {
@@ -178,7 +187,7 @@ function isExpiryField(fieldConfig) {
178
187
  }
179
188
  const dbFields = Array.isArray(fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields) ? fieldConfig.dbFields : [];
180
189
  return dbFields.some((field) => {
181
- const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
190
+ const normalized = normalizeDbFieldPath(field).toUpperCase();
182
191
  return normalized === 'EXDT' || normalized.endsWith('.EXDT') || normalized.endsWith('.EXPIRY');
183
192
  });
184
193
  }
@@ -207,7 +216,15 @@ function shouldSkipFixedTo(header) {
207
216
  }
208
217
  const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
209
218
  return dbFields.some((field) => {
210
- const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
219
+ const normalized = normalizeDbFieldPath(field).toUpperCase();
211
220
  return normalized === 'BN' || normalized === 'BNO' || normalized.endsWith('.BN');
212
221
  });
213
222
  }
223
+ function normalizeDbFieldPath(field) {
224
+ const value = String(field !== null && field !== void 0 ? field : '').trim();
225
+ if (!value) {
226
+ return '';
227
+ }
228
+ const bracketMatch = value.match(/^\[(.*)\]$/);
229
+ return bracketMatch ? bracketMatch[1].trim() : value;
230
+ }
@@ -384,7 +384,10 @@ function shouldNegateFallbackHeaderValue(item, headerText) {
384
384
  || normalized === 'LINE TOTAL';
385
385
  }
386
386
  function getDisplayValueForFallbackRow(item, dbFields = [], shouldNegate = false) {
387
+ console.log(item, dbFields, shouldNegate);
388
+ console.log((0, pdf_table_row_1.getFirstFieldValue)(item, dbFields));
387
389
  const value = (0, pdf_table_row_1.getFirstFieldValue)(item, dbFields);
390
+ console.log('value', value);
388
391
  if (!shouldNegate) {
389
392
  return value;
390
393
  }
@@ -36,7 +36,7 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
36
36
  margin: [0, 5, 0, 5]
37
37
  };
38
38
  const topColumns = {
39
- columns: buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals),
39
+ columns: buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals, totalInWords),
40
40
  columnGap: 20,
41
41
  margin: [0, 0, 0, 8]
42
42
  };
@@ -48,6 +48,7 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
48
48
  dueAmount: dueInfo.due,
49
49
  qrPayload,
50
50
  upiPhone: resolveUpiPhone(normalizedInvoice),
51
+ showInWords: taxSummary.hasData || showBankDetails,
51
52
  showDueSection,
52
53
  isPoSPrint
53
54
  });
@@ -59,7 +60,8 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
59
60
  }
60
61
  return [dividerLine, bottomColumns];
61
62
  }
62
- function buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals) {
63
+ function buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals, totalInWords) {
64
+ const inWords = totalInWords || '-';
63
65
  if (taxSummary.hasData) {
64
66
  return [
65
67
  { width: '42%', stack: buildTaxSummaryTableStack(null, taxSummary.rows, sType) },
@@ -74,24 +76,34 @@ function buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails,
74
76
  ];
75
77
  }
76
78
  return [
77
- { width: '*', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
79
+ {
80
+ width: '70%',
81
+ columns: [
82
+ { width: 'auto', text: 'In Words :', bold: true, fontSize: 9, color: '#111827' },
83
+ { width: '*', text: inWords, bold: true, fontSize: 9, color: '#111827' }
84
+ ],
85
+ columnGap: 6,
86
+ margin: [0, 0, 0, 4]
87
+ },
88
+ { width: '30%', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
78
89
  ];
79
90
  }
80
91
  function buildPostTotalsInfoSection(data) {
81
92
  const hasQr = !!(0, pdf_shared_utils_1.firstValue)(data.qrPayload);
82
93
  const inWords = data.totalInWords || '-';
83
94
  const termsText = (0, pdf_shared_utils_1.firstValue)(data.terms);
84
- const leftStack = [
85
- {
95
+ const leftStack = [];
96
+ if (data.showInWords) {
97
+ leftStack.push({
86
98
  columns: [
87
99
  { width: 'auto', text: 'In Words :', bold: true, fontSize: 9, color: '#111827' },
88
100
  { width: '*', text: inWords, bold: true, fontSize: 9, color: '#111827' }
89
101
  ],
90
102
  columnGap: 6,
91
103
  margin: [0, 0, 0, 4]
92
- }
93
- ];
94
- if (data.showDueSection) {
104
+ });
105
+ }
106
+ if (data.showDueSection && !data.isPoSPrint) {
95
107
  const paidText = `Paid : Rs.${formatAmountFixed2(data.paidAmount)}`;
96
108
  const dueText = `Due : Rs.${formatAmountFixed2(data.dueAmount)}`;
97
109
  leftStack.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.97",
3
+ "version": "1.6.98",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",