shareneus 1.5.64 → 1.5.66
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.
- package/dist/accounting/invoice/invoice-pdf/invoice-pdf.service.js +8 -8
- package/dist/shared/header-footer-section/pdf-header-footer.section.js +23 -23
- package/dist/shared/party-details-section/pdf-party-details.section.d.ts +1 -1
- package/dist/shared/party-details-section/pdf-party-details.section.js +105 -14
- package/dist/shared/table-section/pdf-table.row.js +39 -2
- package/package.json +1 -1
|
@@ -76,7 +76,7 @@ function buildPdfDocDefinition(PDFInvoiceData = {}, PrintConfigData = {}, printC
|
|
|
76
76
|
copyLabels.forEach((copyLabel, index) => {
|
|
77
77
|
const invoiceHeaderContent = (0, pdf_header_footer_section_1.buildDocumentHeaderSection)(PrintConfig, PDFInvoiceData);
|
|
78
78
|
const invoiceHeadingContent = (0, pdf_header_footer_section_1.buildDocumentHeadingSection)(PDFInvoiceData, PrintConfig, availableWidth);
|
|
79
|
-
const invoicePartyDetailsContent = (0, pdf_party_details_section_1.buildInvoicePartyDetailsSection)(PDFInvoiceData);
|
|
79
|
+
const invoicePartyDetailsContent = (0, pdf_party_details_section_1.buildInvoicePartyDetailsSection)(PDFInvoiceData, PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Customer);
|
|
80
80
|
const invoiceTotalsAndNotesContent = (0, pdf_totals_section_1.buildInvoiceTotalsAndNotesSection)(PDFInvoiceData, availableWidth);
|
|
81
81
|
const signatureContent = (0, pdf_totals_section_1.buildSignatureSection)(PrintConfig, PDFInvoiceData, availableWidth);
|
|
82
82
|
const tableData = (0, pdf_table_section_1.buildInvoiceTableData)(PDFInvoiceData, PrintConfig, availableWidth);
|
|
@@ -124,16 +124,16 @@ function normalizeCopyLabels(printCopies = []) {
|
|
|
124
124
|
return labels.length > 0 ? labels : [''];
|
|
125
125
|
}
|
|
126
126
|
function normalizePrintConfig(PDFInvoiceData, PrintConfigData) {
|
|
127
|
-
var _a, _b;
|
|
127
|
+
var _a, _b, _c;
|
|
128
128
|
const config = PrintConfigData || {};
|
|
129
129
|
const itemsHeader = Array.isArray(config === null || config === void 0 ? void 0 : config.TableConfig) ? config.TableConfig : [];
|
|
130
130
|
const headerData = (config === null || config === void 0 ? void 0 : config.headerData) ? config.headerData : (0, pdf_header_footer_section_1.deriveHeaderDataFromInvoice)(PDFInvoiceData);
|
|
131
|
-
const pageMargins = (0, pdf_header_footer_section_1.resolvePageMargins)((_a = config === null || config === void 0 ? void 0 : config.
|
|
132
|
-
const watermarkText = (0, pdf_shared_utils_1.toStr)(config === null || config === void 0 ? void 0 : config.
|
|
133
|
-
const watermark = !!(config === null || config === void 0 ? void 0 : config.
|
|
134
|
-
const watermarkEnabled = !!(config === null || config === void 0 ? void 0 : config.
|
|
135
|
-
const footerText = (0, pdf_shared_utils_1.toStr)(config === null || config === void 0 ? void 0 : config.
|
|
136
|
-
const headerStyles = (0, pdf_header_footer_section_1.normalizeHeaderStyle)((
|
|
131
|
+
const pageMargins = (0, pdf_header_footer_section_1.resolvePageMargins)((_a = config === null || config === void 0 ? void 0 : config.Margin) !== null && _a !== void 0 ? _a : PAGE_MARGINS);
|
|
132
|
+
const watermarkText = (0, pdf_shared_utils_1.toStr)(config === null || config === void 0 ? void 0 : config.WatermarkText);
|
|
133
|
+
const watermark = !!(config === null || config === void 0 ? void 0 : config.Watermark);
|
|
134
|
+
const watermarkEnabled = !!(config === null || config === void 0 ? void 0 : config.WatermarkEnabled);
|
|
135
|
+
const footerText = (0, pdf_shared_utils_1.toStr)((_b = config === null || config === void 0 ? void 0 : config.Footer) === null || _b === void 0 ? void 0 : _b.Text);
|
|
136
|
+
const headerStyles = (0, pdf_header_footer_section_1.normalizeHeaderStyle)((_c = config === null || config === void 0 ? void 0 : config.headerStyles) !== null && _c !== void 0 ? _c : {
|
|
137
137
|
OrgNameFsize: config === null || config === void 0 ? void 0 : config.OrgNameFsize,
|
|
138
138
|
OrgNameClr: config === null || config === void 0 ? void 0 : config.OrgNameClr,
|
|
139
139
|
AdrsFsize: config === null || config === void 0 ? void 0 : config.AdrsFsize,
|
|
@@ -110,8 +110,8 @@ function buildDocumentHeaderSection(PrintConfig, DocumentData = {}) {
|
|
|
110
110
|
AdrsFsize: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.AdrsFsize,
|
|
111
111
|
AdrsClr: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.AdrsClr
|
|
112
112
|
});
|
|
113
|
-
const headerSettings = normalizeHeaderSettings((_t = (_s = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.
|
|
114
|
-
if (!headerSettings.
|
|
113
|
+
const headerSettings = normalizeHeaderSettings((_t = (_s = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Header) !== null && _s !== void 0 ? _s : PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Header) !== null && _t !== void 0 ? _t : {});
|
|
114
|
+
if (!headerSettings.Show) {
|
|
115
115
|
return [];
|
|
116
116
|
}
|
|
117
117
|
const hasOrganizationData = !!(((_u = mergedHeaderData.organization) === null || _u === void 0 ? void 0 : _u.cName) || ((_v = mergedHeaderData.organization) === null || _v === void 0 ? void 0 : _v.address1)
|
|
@@ -119,13 +119,13 @@ function buildDocumentHeaderSection(PrintConfig, DocumentData = {}) {
|
|
|
119
119
|
|| ((_z = mergedHeaderData.organization) === null || _z === void 0 ? void 0 : _z.pin) || ((_0 = mergedHeaderData.organization) === null || _0 === void 0 ? void 0 : _0.gstin) || ((_1 = mergedHeaderData.organization) === null || _1 === void 0 ? void 0 : _1.email)
|
|
120
120
|
|| ((_2 = mergedHeaderData.organization) === null || _2 === void 0 ? void 0 : _2.phone) || ((_3 = mergedHeaderData.organization) === null || _3 === void 0 ? void 0 : _3.phone2) || ((_4 = mergedHeaderData.organization) === null || _4 === void 0 ? void 0 : _4.dlNo)
|
|
121
121
|
|| ((_5 = mergedHeaderData.organization) === null || _5 === void 0 ? void 0 : _5.cin) || ((_6 = mergedHeaderData.organization) === null || _6 === void 0 ? void 0 : _6.pan));
|
|
122
|
-
const hasLogo = !!mergedHeaderData.logoDataUrl && headerSettings.
|
|
122
|
+
const hasLogo = !!mergedHeaderData.logoDataUrl && headerSettings.ShowLogo;
|
|
123
123
|
if (!hasOrganizationData && !hasLogo) {
|
|
124
124
|
return [];
|
|
125
125
|
}
|
|
126
|
-
const textAlignment = toPdfAlignment(headerSettings.
|
|
126
|
+
const textAlignment = toPdfAlignment(headerSettings.Position);
|
|
127
127
|
const organizationStack = buildOrganizationStack(mergedHeaderData.organization, headerStyles, textAlignment);
|
|
128
|
-
const headerContent = buildHeaderContentWithLogo(mergedHeaderData.logoDataUrl, hasLogo, organizationStack, headerSettings.
|
|
128
|
+
const headerContent = buildHeaderContentWithLogo(mergedHeaderData.logoDataUrl, hasLogo, organizationStack, headerSettings.LogoPosition, textAlignment);
|
|
129
129
|
return [{
|
|
130
130
|
columns: [
|
|
131
131
|
Object.assign({ width: '*' }, headerContent)
|
|
@@ -155,8 +155,8 @@ function buildDocumentHeadingSection(PDFInvoiceData, PrintConfig, availableWidth
|
|
|
155
155
|
];
|
|
156
156
|
}
|
|
157
157
|
function buildWatermark(PrintConfig) {
|
|
158
|
-
const value = (0, pdf_shared_utils_1.firstValue)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.
|
|
159
|
-
const isEnabled = !!((PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.
|
|
158
|
+
const value = (0, pdf_shared_utils_1.firstValue)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.WatermarkText);
|
|
159
|
+
const isEnabled = !!((PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Watermark) || (PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.WatermarkEnabled) || value);
|
|
160
160
|
if (!isEnabled) {
|
|
161
161
|
return null;
|
|
162
162
|
}
|
|
@@ -172,8 +172,8 @@ function buildWatermark(PrintConfig) {
|
|
|
172
172
|
}
|
|
173
173
|
function buildLogoWatermarkBackground(PrintConfig, DocumentData = {}) {
|
|
174
174
|
var _a;
|
|
175
|
-
const value = (0, pdf_shared_utils_1.firstValue)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.
|
|
176
|
-
const isEnabled = !!((PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.
|
|
175
|
+
const value = (0, pdf_shared_utils_1.firstValue)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.WatermarkText);
|
|
176
|
+
const isEnabled = !!((PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Watermark) || (PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.WatermarkEnabled) || value);
|
|
177
177
|
if (!isEnabled || value) {
|
|
178
178
|
return null;
|
|
179
179
|
}
|
|
@@ -197,16 +197,16 @@ function resolveDocumentLogoDataUrl(DocumentData) {
|
|
|
197
197
|
}
|
|
198
198
|
function buildFooter(PrintConfig) {
|
|
199
199
|
var _a, _b, _c, _d, _e;
|
|
200
|
-
const footerConfig = (_b = (_a = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.
|
|
201
|
-
const showFooter = (footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.
|
|
200
|
+
const footerConfig = (_b = (_a = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Footer) !== null && _a !== void 0 ? _a : PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Footer) !== null && _b !== void 0 ? _b : {};
|
|
201
|
+
const showFooter = (footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.Show) !== false && (footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.Show) !== false;
|
|
202
202
|
if (!showFooter) {
|
|
203
203
|
return null;
|
|
204
204
|
}
|
|
205
|
-
const value = (0, pdf_shared_utils_1.firstValue)((_d = (_c = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.
|
|
205
|
+
const value = (0, pdf_shared_utils_1.firstValue)((_d = (_c = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.Text) !== null && _c !== void 0 ? _c : footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.Text) !== null && _d !== void 0 ? _d : PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.FooterText);
|
|
206
206
|
if (!value) {
|
|
207
207
|
return null;
|
|
208
208
|
}
|
|
209
|
-
const textAlignment = normalizeFooterAlignment((_e = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.
|
|
209
|
+
const textAlignment = normalizeFooterAlignment((_e = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.Position) !== null && _e !== void 0 ? _e : footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.Position);
|
|
210
210
|
const pageAlignment = textAlignment === 'right' ? 'left' : 'right';
|
|
211
211
|
return (_currentPage, pageCount) => ({
|
|
212
212
|
margin: [20, 0, 20, 6],
|
|
@@ -228,10 +228,10 @@ function normalizeFooterAlignment(value) {
|
|
|
228
228
|
}
|
|
229
229
|
function buildOrganizationStack(organization, headerStyles, alignment) {
|
|
230
230
|
const stack = [];
|
|
231
|
-
const orgNameFontSize = (0, pdf_shared_utils_1.readPositiveNumber)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.
|
|
232
|
-
const orgAddressFontSize = (0, pdf_shared_utils_1.readPositiveNumber)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.
|
|
233
|
-
const orgNameFontColor = (0, pdf_shared_utils_1.normalizeColor)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.
|
|
234
|
-
const orgAddressFontColor = (0, pdf_shared_utils_1.normalizeColor)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.
|
|
231
|
+
const orgNameFontSize = (0, pdf_shared_utils_1.readPositiveNumber)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.OrgNameFsize, DEFAULT_ORG_NAME_FONT_SIZE);
|
|
232
|
+
const orgAddressFontSize = (0, pdf_shared_utils_1.readPositiveNumber)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.AdrsFsize, DEFAULT_ORG_ADDRESS_FONT_SIZE);
|
|
233
|
+
const orgNameFontColor = (0, pdf_shared_utils_1.normalizeColor)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.OrgNameClr, DEFAULT_ORG_NAME_FONT_COLOR);
|
|
234
|
+
const orgAddressFontColor = (0, pdf_shared_utils_1.normalizeColor)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.AdrsClr, DEFAULT_ORG_ADDRESS_FONT_COLOR);
|
|
235
235
|
if (organization === null || organization === void 0 ? void 0 : organization.cName) {
|
|
236
236
|
stack.push({ text: organization.cName, bold: true, fontSize: orgNameFontSize, color: orgNameFontColor, lineHeight: 1.1, alignment });
|
|
237
237
|
}
|
|
@@ -278,13 +278,13 @@ function buildOrganizationStack(organization, headerStyles, alignment) {
|
|
|
278
278
|
return stack;
|
|
279
279
|
}
|
|
280
280
|
function normalizeHeaderSettings(value) {
|
|
281
|
-
const
|
|
282
|
-
const
|
|
281
|
+
const Position = normalizePosition(value === null || value === void 0 ? void 0 : value.Position, DEFAULT_HEADER_POSITION);
|
|
282
|
+
const LogoPosition = normalizeLogoPosition(value === null || value === void 0 ? void 0 : value.LogoPosition, DEFAULT_LOGO_POSITION);
|
|
283
283
|
return {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
284
|
+
Position,
|
|
285
|
+
LogoPosition,
|
|
286
|
+
Show: (value === null || value === void 0 ? void 0 : value.Show) !== false,
|
|
287
|
+
ShowLogo: (value === null || value === void 0 ? void 0 : value.ShowLogo) !== false
|
|
288
288
|
};
|
|
289
289
|
}
|
|
290
290
|
function normalizePosition(value, fallback) {
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.buildInvoicePartyDetailsSection = buildInvoicePartyDetailsSection;
|
|
7
|
+
const jsbarcode_1 = __importDefault(require("jsbarcode"));
|
|
4
8
|
const pdf_shared_utils_1 = require("../header-footer-section/pdf-shared.utils");
|
|
5
|
-
function buildInvoicePartyDetailsSection(PDFInvoiceData) {
|
|
9
|
+
function buildInvoicePartyDetailsSection(PDFInvoiceData, customerLayout) {
|
|
6
10
|
const invoiceData = PDFInvoiceData || {};
|
|
7
11
|
const billTo = resolveBillToDetails(invoiceData);
|
|
8
12
|
const shipTo = resolveShipToDetails(invoiceData);
|
|
9
13
|
const insurance = resolveInsuranceDetails(invoiceData);
|
|
10
14
|
const useInsurance = !!insurance.name;
|
|
11
15
|
const secondaryParty = useInsurance ? insurance : shipTo;
|
|
16
|
+
const showBarCode = resolveShowBarCode(invoiceData);
|
|
17
|
+
const billToCode = resolveBillToCode(invoiceData);
|
|
12
18
|
const otherDetails = resolveOtherDetails(invoiceData);
|
|
13
|
-
const
|
|
19
|
+
const shouldShowSecondaryBarcode = !secondaryParty.hasData && showBarCode && !!billToCode;
|
|
20
|
+
const billToStack = billTo.hasData ? buildPartyStack('Bill To', billTo, customerLayout) : [{ text: '' }];
|
|
14
21
|
const secondaryTitle = useInsurance ? 'Insurance' : 'Ship To';
|
|
15
|
-
const secondaryStack = secondaryParty.hasData
|
|
22
|
+
const secondaryStack = secondaryParty.hasData
|
|
23
|
+
? buildPartyStack(secondaryTitle, secondaryParty, customerLayout)
|
|
24
|
+
: (shouldShowSecondaryBarcode ? buildBarcodeStack(billToCode) : [{ text: '' }]);
|
|
16
25
|
const otherDetailsStack = otherDetails.hasData ? buildOtherDetailsStack(otherDetails) : [{ text: '' }];
|
|
17
|
-
const hasAnyData = billTo.hasData || secondaryParty.hasData || otherDetails.hasData;
|
|
26
|
+
const hasAnyData = billTo.hasData || secondaryParty.hasData || shouldShowSecondaryBarcode || otherDetails.hasData;
|
|
18
27
|
if (!hasAnyData) {
|
|
19
28
|
return [{
|
|
20
29
|
text: '',
|
|
@@ -32,7 +41,7 @@ function buildInvoicePartyDetailsSection(PDFInvoiceData) {
|
|
|
32
41
|
}];
|
|
33
42
|
}
|
|
34
43
|
function resolveBillToDetails(invoiceData) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f;
|
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
36
45
|
const billTo = (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.BillTo) || (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Customer) || (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Cust) || {};
|
|
37
46
|
const address = normalizeAddress((billTo === null || billTo === void 0 ? void 0 : billTo.Adrs)
|
|
38
47
|
|| ((_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.BillTo) === null || _a === void 0 ? void 0 : _a.Adrs)
|
|
@@ -44,12 +53,14 @@ function resolveBillToDetails(invoiceData) {
|
|
|
44
53
|
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);
|
|
45
54
|
const contactInfo = resolvePhoneFromContacts(billTo === null || billTo === void 0 ? void 0 : billTo.Cons);
|
|
46
55
|
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);
|
|
56
|
+
const ownerName = (0, pdf_shared_utils_1.firstValue)((_g = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Cust) === null || _g === void 0 ? void 0 : _g.Name);
|
|
47
57
|
return {
|
|
48
58
|
name,
|
|
49
59
|
addressLines: billTo === null || billTo === void 0 ? void 0 : billTo.Adrs,
|
|
50
60
|
gstin,
|
|
51
61
|
phoneType: contactInfo.type,
|
|
52
62
|
phoneNumber: contactInfo.number || directPhone,
|
|
63
|
+
ownerName,
|
|
53
64
|
hasData: !!(name || gstin || contactInfo.number || directPhone || hasAddress(address))
|
|
54
65
|
};
|
|
55
66
|
}
|
|
@@ -80,27 +91,37 @@ function resolveInsuranceDetails(invoiceData) {
|
|
|
80
91
|
};
|
|
81
92
|
}
|
|
82
93
|
function resolveOtherDetails(invoiceData) {
|
|
83
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
94
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
84
95
|
const invoiceDate = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.DDate, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.InvDt, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Date, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.CrDate);
|
|
85
96
|
const invoiceNumber = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData._id, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Code, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.InvNo, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.No);
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
const productName = [
|
|
98
|
+
(_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Product) === null || _a === void 0 ? void 0 : _a.Make,
|
|
99
|
+
(_b = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Product) === null || _b === void 0 ? void 0 : _b.Model,
|
|
100
|
+
(_c = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Product) === null || _c === void 0 ? void 0 : _c.Var
|
|
101
|
+
]
|
|
102
|
+
.map((value) => String(value !== null && value !== void 0 ? value : '').trim())
|
|
103
|
+
.filter((value) => !!value)
|
|
104
|
+
.join(' ');
|
|
105
|
+
const vehicleDetails = (0, pdf_shared_utils_1.firstValue)(productName, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.VehNo, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.VehicleNo, (_d = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Vehicle) === null || _d === void 0 ? void 0 : _d.RegNo, (_e = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Vehicle) === null || _e === void 0 ? void 0 : _e.No, (_f = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Vehicle) === null || _f === void 0 ? void 0 : _f.Details, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.VehicleDetails);
|
|
106
|
+
const Milage = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.MIn, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.MOut, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Milage);
|
|
107
|
+
const RegnNo = (_g = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Product) === null || _g === void 0 ? void 0 : _g.RegNo;
|
|
108
|
+
const EngNo = (_h = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Product) === null || _h === void 0 ? void 0 : _h.EngNo;
|
|
109
|
+
const ChassisNo = (_j = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Product) === null || _j === void 0 ? void 0 : _j.VIN;
|
|
90
110
|
const lines = [
|
|
91
111
|
{ label: 'Invoice#', value: invoiceNumber },
|
|
92
112
|
{ label: 'Date', value: invoiceDate ? formatDisplayDate(invoiceDate) : '' },
|
|
113
|
+
{ label: 'Vehicle', value: vehicleDetails },
|
|
93
114
|
{ label: 'Regn. No', value: (0, pdf_shared_utils_1.firstValue)(RegnNo) },
|
|
94
115
|
{ label: 'Engine No', value: (0, pdf_shared_utils_1.firstValue)(EngNo) },
|
|
95
116
|
{ label: 'Chassis No', value: (0, pdf_shared_utils_1.firstValue)(ChassisNo) },
|
|
96
|
-
{ label: '
|
|
117
|
+
{ label: 'Milage', value: Milage }
|
|
97
118
|
].filter((line) => !!line.value);
|
|
98
119
|
return {
|
|
99
120
|
lines,
|
|
100
121
|
hasData: lines.length > 0
|
|
101
122
|
};
|
|
102
123
|
}
|
|
103
|
-
function buildPartyStack(title, party) {
|
|
124
|
+
function buildPartyStack(title, party, customerLayout) {
|
|
104
125
|
const stack = [
|
|
105
126
|
{ text: title, bold: true, fontSize: 9, color: '#374151', margin: [0, 0, 0, 4] }
|
|
106
127
|
];
|
|
@@ -108,8 +129,8 @@ function buildPartyStack(title, party) {
|
|
|
108
129
|
stack.push({
|
|
109
130
|
text: party.name,
|
|
110
131
|
bold: true,
|
|
111
|
-
fontSize: 9,
|
|
112
|
-
color: '#111827',
|
|
132
|
+
fontSize: (customerLayout === null || customerLayout === void 0 ? void 0 : customerLayout.NameFsize) || 9,
|
|
133
|
+
color: (customerLayout === null || customerLayout === void 0 ? void 0 : customerLayout.NameClr) || '#111827',
|
|
113
134
|
// background: '#e5e7eb',
|
|
114
135
|
margin: [0, 0, 0, 2]
|
|
115
136
|
});
|
|
@@ -130,6 +151,24 @@ function buildPartyStack(title, party) {
|
|
|
130
151
|
const phoneLabel = (party === null || party === void 0 ? void 0 : party.phoneType) ? `Phone(${party.phoneType})` : 'Phone';
|
|
131
152
|
stack.push({ text: `${phoneLabel} : ${party.phoneNumber}`, fontSize: 8, lineHeight: 1.05 });
|
|
132
153
|
}
|
|
154
|
+
if (title === 'Bill To' && (party === null || party === void 0 ? void 0 : party.ownerName)) {
|
|
155
|
+
stack.push({
|
|
156
|
+
text: [
|
|
157
|
+
{ text: 'Owner Details', bold: true },
|
|
158
|
+
{ text: ' : ', bold: true },
|
|
159
|
+
{ text: party.ownerName, bold: false }
|
|
160
|
+
],
|
|
161
|
+
fontSize: 8.5,
|
|
162
|
+
color: '#111827',
|
|
163
|
+
margin: [0, 3, 0, 1]
|
|
164
|
+
});
|
|
165
|
+
stack.push({
|
|
166
|
+
canvas: [
|
|
167
|
+
{ type: 'line', x1: 0, y1: 0, x2: 170, y2: 0, lineWidth: 0.5, lineColor: '#111827' }
|
|
168
|
+
],
|
|
169
|
+
margin: [0, 2, 0, 0]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
133
172
|
return stack;
|
|
134
173
|
}
|
|
135
174
|
function buildOtherDetailsStack(otherDetails) {
|
|
@@ -150,6 +189,19 @@ function buildOtherDetailsStack(otherDetails) {
|
|
|
150
189
|
}
|
|
151
190
|
return stack;
|
|
152
191
|
}
|
|
192
|
+
function buildBarcodeStack(code) {
|
|
193
|
+
const svg = textToSvgBarcode(code);
|
|
194
|
+
if (!svg) {
|
|
195
|
+
return [{ text: '' }];
|
|
196
|
+
}
|
|
197
|
+
return [
|
|
198
|
+
{
|
|
199
|
+
svg,
|
|
200
|
+
width: 160,
|
|
201
|
+
margin: [0, 8, 0, 0]
|
|
202
|
+
}
|
|
203
|
+
];
|
|
204
|
+
}
|
|
153
205
|
function hasAddress(address) {
|
|
154
206
|
const normalizedAddress = normalizeAddress(address);
|
|
155
207
|
if (!normalizedAddress) {
|
|
@@ -225,6 +277,45 @@ function formatDisplayDate(value) {
|
|
|
225
277
|
}
|
|
226
278
|
return value;
|
|
227
279
|
}
|
|
280
|
+
function resolveShowBarCode(invoiceData) {
|
|
281
|
+
var _a;
|
|
282
|
+
return isTruthy(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.ShowBarCode) || isTruthy((_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _a === void 0 ? void 0 : _a.PrCustBar) || isTruthy(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.PrCustBar);
|
|
283
|
+
}
|
|
284
|
+
function resolveBillToCode(invoiceData) {
|
|
285
|
+
var _a, _b, _c;
|
|
286
|
+
return (0, pdf_shared_utils_1.firstValue)((_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.BillTo) === null || _a === void 0 ? void 0 : _a.Code, (_b = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Customer) === null || _b === void 0 ? void 0 : _b.Code, (_c = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Cust) === null || _c === void 0 ? void 0 : _c.Code);
|
|
287
|
+
}
|
|
288
|
+
function isTruthy(value) {
|
|
289
|
+
if (typeof value === 'boolean') {
|
|
290
|
+
return value;
|
|
291
|
+
}
|
|
292
|
+
if (typeof value === 'number') {
|
|
293
|
+
return value !== 0;
|
|
294
|
+
}
|
|
295
|
+
if (typeof value === 'string') {
|
|
296
|
+
const normalized = value.trim().toLowerCase();
|
|
297
|
+
return normalized === 'true' || normalized === '1' || normalized === 'yes';
|
|
298
|
+
}
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
function textToSvgBarcode(text) {
|
|
302
|
+
if (!text || typeof document === 'undefined') {
|
|
303
|
+
return '';
|
|
304
|
+
}
|
|
305
|
+
const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
306
|
+
(0, jsbarcode_1.default)(svgElement, text, {
|
|
307
|
+
format: "CODE128",
|
|
308
|
+
width: 1.25,
|
|
309
|
+
height: 24,
|
|
310
|
+
margin: 0,
|
|
311
|
+
marginTop: 6,
|
|
312
|
+
displayValue: true,
|
|
313
|
+
fontSize: 7,
|
|
314
|
+
textMargin: 0,
|
|
315
|
+
fontOptions: 'bold'
|
|
316
|
+
});
|
|
317
|
+
return svgElement.outerHTML;
|
|
318
|
+
}
|
|
228
319
|
function resolvePhoneFromContacts(contacts) {
|
|
229
320
|
if (!Array.isArray(contacts)) {
|
|
230
321
|
return { type: '', number: '' };
|
|
@@ -5,6 +5,7 @@ exports.getFirstFieldValue = getFirstFieldValue;
|
|
|
5
5
|
exports.getNumericAlignment = getNumericAlignment;
|
|
6
6
|
exports.getCellAlignment = getCellAlignment;
|
|
7
7
|
const pdf_table_config_1 = require("./pdf-table.config");
|
|
8
|
+
const my_date_1 = require("../../utils/my-date");
|
|
8
9
|
function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
9
10
|
return headerConfig.map((column) => {
|
|
10
11
|
var _a;
|
|
@@ -18,10 +19,10 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
|
18
19
|
const serial = String(index + 1);
|
|
19
20
|
return { text: serial, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, alignment: getNumericAlignment(serial) };
|
|
20
21
|
}
|
|
21
|
-
const mainValue =
|
|
22
|
+
const mainValue = formatFieldValue(item, header, fixedTo);
|
|
22
23
|
const stackedLines = ((_a = header.stackFields) !== null && _a !== void 0 ? _a : [])
|
|
23
24
|
.map((stackField) => {
|
|
24
|
-
const stackValue =
|
|
25
|
+
const stackValue = formatFieldValue(item, stackField, fixedTo);
|
|
25
26
|
if (!stackValue) {
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
@@ -43,6 +44,13 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
|
43
44
|
};
|
|
44
45
|
});
|
|
45
46
|
}
|
|
47
|
+
function formatFieldValue(item, fieldConfig, fixedTo) {
|
|
48
|
+
const rawValue = getFirstFieldValue(item, fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields);
|
|
49
|
+
if (isExpiryField(fieldConfig)) {
|
|
50
|
+
return formatExpiryDateValue(rawValue);
|
|
51
|
+
}
|
|
52
|
+
return formatNumericLikeValue(rawValue, fixedTo, shouldSkipFixedTo(fieldConfig));
|
|
53
|
+
}
|
|
46
54
|
function getTaxValue(item, taxName, taxKind) {
|
|
47
55
|
const fields = taxKind === 'rate'
|
|
48
56
|
? [`${taxName}Perc`, taxName]
|
|
@@ -126,6 +134,35 @@ function formatNumericLikeValue(value, fixedTo, skipFixedTo = false) {
|
|
|
126
134
|
}
|
|
127
135
|
return normalized.toFixed(fixedTo);
|
|
128
136
|
}
|
|
137
|
+
function isExpiryField(fieldConfig) {
|
|
138
|
+
var _a;
|
|
139
|
+
const text = String((_a = fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
|
|
140
|
+
if (text === 'EXPIRY' || text === 'EXPIRY DATE' || text === 'EXDT') {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
const dbFields = Array.isArray(fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields) ? fieldConfig.dbFields : [];
|
|
144
|
+
return dbFields.some((field) => {
|
|
145
|
+
const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
|
|
146
|
+
return normalized === 'EXDT' || normalized.endsWith('.EXDT') || normalized.endsWith('.EXPIRY');
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function formatExpiryDateValue(value) {
|
|
150
|
+
if (!value) {
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
const input = String(value).trim();
|
|
154
|
+
if (!input) {
|
|
155
|
+
return '';
|
|
156
|
+
}
|
|
157
|
+
if (/^\d{2}\/\d{2}$/.test(input)) {
|
|
158
|
+
return input;
|
|
159
|
+
}
|
|
160
|
+
const parsed = new Date(input);
|
|
161
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
162
|
+
return input;
|
|
163
|
+
}
|
|
164
|
+
return my_date_1.MyDate.ConvertUTCDateToReadableExDate(input) || input;
|
|
165
|
+
}
|
|
129
166
|
function shouldSkipFixedTo(header) {
|
|
130
167
|
var _a;
|
|
131
168
|
const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
|