shareneus 1.6.95 → 1.6.97

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.
@@ -194,12 +194,12 @@ function GetHeaderInfo(Entity, marginleft, InvoicePDFData = {}) {
194
194
  if (!tr_utils_1.TrUtils.IsEmpty(Entity.DLNo)) {
195
195
  TaxInfo.push({ text: 'D.L.NO : ' + Entity.DLNo, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: '*' });
196
196
  }
197
- TaxInfo.push(GetBillofSupplyName(InvoicePDFData.Settings));
197
+ // TaxInfo.push(GetBillofSupplyName(InvoicePDFData.Settings));
198
198
  return TaxInfo;
199
199
  }
200
- function GetBillofSupplyName(Settings) {
201
- return { text: Settings.Tax === 'BS' ? ' Bill of Supply' : null, alignment: 'center', marginLeft: 15, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' };
202
- }
200
+ // function GetBillofSupplyName(Settings: any) {
201
+ // return { text: Settings.Tax === 'BS' ? ' Bill of Supply' : null, alignment: 'center', marginLeft: 15, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' };
202
+ // }
203
203
  // function SalesReceiptHeaderData(Entity: any, Image: any, AColor: any, HColor: any, text: any) {
204
204
  // return [
205
205
  // SharedPDFService.GetMainHeader(Entity, Image, AColor, HColor, text),
@@ -18,6 +18,8 @@ function GetTableHeader(itemsHeader) {
18
18
  text: itemTitle,
19
19
  width: itemWidth,
20
20
  bold: (_l = item.bold) !== null && _l !== void 0 ? _l : true,
21
+ fontSize: 9,
22
+ alignment: resolveHeaderAlignment(itemTitle),
21
23
  dbFields: itemDbFields,
22
24
  stackParent: stackTitle,
23
25
  stackSeq: typeof stackSeq === 'number' ? stackSeq : Number.MAX_SAFE_INTEGER
@@ -191,7 +193,7 @@ function buildHeaderRows(headerConfig, sType = '') {
191
193
  const hasDiscGroup = hasDiscPercent && hasDiscAmount;
192
194
  const hasGroupedHeaders = hasTaxPercent || hasTaxAmount || hasDiscGroup;
193
195
  if (!hasGroupedHeaders) {
194
- const singleRow = headerConfig.map((header) => (Object.assign({ text: header.text, dbFields: header.dbFields, stackFields: header.stackFields }, getHeaderCellStyle())));
196
+ const singleRow = headerConfig.map((header) => (Object.assign({ text: header.text, alignment: header.alignment, dbFields: header.dbFields, stackFields: header.stackFields }, getHeaderCellStyle())));
195
197
  return [singleRow];
196
198
  }
197
199
  const topRow = [];
@@ -246,7 +248,7 @@ function buildHeaderRows(headerConfig, sType = '') {
246
248
  if (hasDiscGroup && isDiscountAmountHeader(header.text)) {
247
249
  continue;
248
250
  }
249
- topRow.push(Object.assign({ text: header.text, rowSpan: 2 }, getHeaderCellStyle()));
251
+ topRow.push(Object.assign({ text: header.text, rowSpan: 2, alignment: header.alignment }, getHeaderCellStyle()));
250
252
  subRow.push({});
251
253
  }
252
254
  return [topRow, subRow];
@@ -272,6 +274,13 @@ function normalizeHeaderText(value) {
272
274
  .trim()
273
275
  .toUpperCase();
274
276
  }
277
+ function resolveHeaderAlignment(title) {
278
+ const normalizedTitle = normalizeHeaderText(title);
279
+ if (normalizedTitle === 'LINETOTAL' || normalizedTitle === 'PRICE' || normalizedTitle === 'QTY') {
280
+ return 'right';
281
+ }
282
+ return undefined;
283
+ }
275
284
  function getHeaderCellStyle() {
276
285
  return {
277
286
  bold: true,
@@ -7,6 +7,7 @@ exports.getCellAlignment = getCellAlignment;
7
7
  const pdf_table_config_1 = require("./pdf-table.config");
8
8
  const my_date_1 = require("../../utils/my-date");
9
9
  function buildDataRow(item, index, headerConfig, fixedTo = 2) {
10
+ console.log('Building data row for headerConfig:', headerConfig);
10
11
  return headerConfig.map((column) => {
11
12
  var _a;
12
13
  if (column.type === 'tax') {
@@ -201,15 +202,12 @@ function formatExpiryDateValue(value) {
201
202
  function shouldSkipFixedTo(header) {
202
203
  var _a;
203
204
  const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
204
- if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text === 'BATCH' || text === 'BATCH NO' || text === 'BATCH NO.') {
205
+ if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO') {
205
206
  return true;
206
207
  }
207
208
  const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
208
209
  return dbFields.some((field) => {
209
210
  const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
210
- return normalized === 'BNO'
211
- || normalized.endsWith('.BNO')
212
- || normalized.endsWith('.BN')
213
- || normalized.includes('BATCH');
211
+ return normalized === 'BN' || normalized === 'BNO' || normalized.endsWith('.BN');
214
212
  });
215
213
  }
@@ -520,7 +520,9 @@ function hasDisplayValue(value) {
520
520
  return true;
521
521
  }
522
522
  function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
523
+ var _a;
523
524
  const subtotal = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['SIndTotal', 'STotal', 'SubTotal', 'SubTot', 'TaxableAmount', 'TaxableValue']);
525
+ const isPoSPrint = isTruthy((_a = printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.IsPoSPrint) !== null && _a !== void 0 ? _a : printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.isPoSPrint);
524
526
  const showDetailedDisc = isTruthy((0, pdf_shared_utils_1.firstValue)(printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.ShowDetailedDisc));
525
527
  const itemsDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.PDisc));
526
528
  const servicesDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.LDisc));
@@ -539,6 +541,7 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
539
541
  const returnTotal = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.RetTotal);
540
542
  const finalTotalRaw = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.FinalTotal, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Total, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.GrandTotal, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.NetTotal);
541
543
  const finalTotal = parseNumber(finalTotalRaw);
544
+ const paidAmount = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Paid', 'PaidAmount', 'PaidAmt', 'ReceivedAmount', 'RecAmt']);
542
545
  let totalBeforeRound = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['TotalBeforeRound', 'BeforeRoundTotal', 'PreRoundTotal']);
543
546
  if (totalBeforeRound === 0) {
544
547
  if (finalTotalRaw) {
@@ -552,6 +555,8 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
552
555
  }
553
556
  }
554
557
  const resolvedFinalTotal = finalTotalRaw ? finalTotal : totalBeforeRound + roundOff;
558
+ const dueFromInvoice = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Due', 'DueAmount', 'DueAmt', 'Balance', 'BalAmt']);
559
+ const dueAmount = dueFromInvoice !== 0 ? dueFromInvoice : Math.max(0, resolvedFinalTotal - paidAmount);
555
560
  const discountLines = (showDetailedDisc
556
561
  ? [
557
562
  { label: 'Items Discount', amount: itemsDiscount },
@@ -561,7 +566,7 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
561
566
  : [
562
567
  { label: 'Discount', amount: (0, math_operations_1.Add)(overalItemsDiscount, overalServicesDiscount) }
563
568
  ])
564
- .filter((line) => Math.abs(parseNumber(line === null || line === void 0 ? void 0 : line.amount)) > 0);
569
+ .filter((line) => parseNumber(line === null || line === void 0 ? void 0 : line.amount) !== 0);
565
570
  const totalLines = [
566
571
  { label: 'SubTotal', amount: subtotal },
567
572
  ...discountLines,
@@ -569,10 +574,11 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
569
574
  { label: 'Return Total', amount: returnTotal },
570
575
  { label: 'Total', amount: totalBeforeRound },
571
576
  { label: 'Rounding', amount: roundOff },
572
- { label: 'Final Total', amount: resolvedFinalTotal }
577
+ ...(roundOff !== 0 ? [{ label: 'Final Total', amount: resolvedFinalTotal }] : []),
578
+ ...(isPoSPrint ? [{ label: 'Due', amount: dueAmount }] : [])
573
579
  ];
574
580
  const lines = totalLines
575
- .filter((line) => Math.abs(parseNumber(line === null || line === void 0 ? void 0 : line.amount)) > 0)
581
+ .filter((line) => parseNumber(line === null || line === void 0 ? void 0 : line.amount) !== 0)
576
582
  .map((line) => ({ label: line.label, value: formatAmountFixed2(parseNumber(line === null || line === void 0 ? void 0 : line.amount)) }));
577
583
  const hasData = lines.some((line) => hasDisplayValue(line === null || line === void 0 ? void 0 : line.value));
578
584
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.95",
3
+ "version": "1.6.97",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",