shareneus 1.5.55 → 1.5.57

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.
Files changed (30) hide show
  1. package/dist/accounting/invoice/inv-print.service.js +8 -8
  2. package/dist/accounting/invoice/invoice-pdf/invoice-pdf.service.d.ts +96 -0
  3. package/dist/accounting/invoice/invoice-pdf/invoice-pdf.service.js +155 -0
  4. package/dist/accounting/payment-receive/payment-receipt-pdf/receipt-pdf.service.d.ts +1000 -0
  5. package/dist/accounting/payment-receive/payment-receipt-pdf/receipt-pdf.service.js +419 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.js +20 -1
  8. package/dist/shared/header-footer-section/pdf-header-footer.section.d.ts +118 -0
  9. package/dist/shared/header-footer-section/pdf-header-footer.section.js +345 -0
  10. package/dist/shared/header-footer-section/pdf-shared.utils.d.ts +5 -0
  11. package/dist/shared/header-footer-section/pdf-shared.utils.js +48 -0
  12. package/dist/shared/party-details-section/pdf-party-details.section.d.ts +11 -0
  13. package/dist/shared/party-details-section/pdf-party-details.section.js +240 -0
  14. package/dist/shared/table-section/pdf-table.config.d.ts +6 -0
  15. package/dist/shared/table-section/pdf-table.config.js +9 -0
  16. package/dist/shared/table-section/pdf-table.header.d.ts +3 -0
  17. package/dist/shared/table-section/pdf-table.header.js +155 -0
  18. package/dist/shared/table-section/pdf-table.row.d.ts +14 -0
  19. package/dist/shared/table-section/pdf-table.row.js +125 -0
  20. package/dist/shared/table-section/pdf-table.section.d.ts +9 -0
  21. package/dist/shared/table-section/pdf-table.section.js +290 -0
  22. package/dist/shared/totals-section/pdf-totals.section.d.ts +49 -0
  23. package/dist/shared/totals-section/pdf-totals.section.js +411 -0
  24. package/dist/tax/index.d.ts +9 -0
  25. package/dist/tax/index.js +21 -0
  26. package/dist/tax/tax-calculator.d.ts +275 -0
  27. package/dist/tax/tax-calculator.js +555 -0
  28. package/dist/tax/tax.types.d.ts +290 -0
  29. package/dist/tax/tax.types.js +11 -0
  30. package/package.json +1 -1
@@ -109,10 +109,10 @@ function GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST
109
109
  }
110
110
  else if (IsProforma) {
111
111
  // InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
112
- if (PartsPrint) {
112
+ if (PartsPrint && !LaborPrint) {
113
113
  InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (PARTS)';
114
114
  }
115
- else if (LaborPrint) {
115
+ else if (LaborPrint && !PartsPrint) {
116
116
  InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (LABOR)';
117
117
  }
118
118
  else {
@@ -147,10 +147,10 @@ function GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST
147
147
  // }
148
148
  if (InvoicePrintData.Settings.Tax === 'BS') {
149
149
  // InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
150
- if (PartsPrint) {
150
+ if (PartsPrint && !LaborPrint) {
151
151
  InvoicePrintData.HeaderName = 'BILL OF SUPPLY (PARTS)';
152
152
  }
153
- else if (LaborPrint) {
153
+ else if (LaborPrint && !PartsPrint) {
154
154
  InvoicePrintData.HeaderName = 'BILL OF SUPPLY (LABOR)';
155
155
  }
156
156
  else {
@@ -163,10 +163,10 @@ function GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST
163
163
  InvoicePrintData.HeaderName = 'TAX SALES RECEIPT';
164
164
  }
165
165
  else {
166
- if (PartsPrint) {
166
+ if (PartsPrint && !LaborPrint) {
167
167
  InvoicePrintData.HeaderName = 'TAX INVOICE (PARTS)';
168
168
  }
169
- else if (LaborPrint) {
169
+ else if (LaborPrint && !PartsPrint) {
170
170
  InvoicePrintData.HeaderName = 'TAX INVOICE (LABOR)';
171
171
  }
172
172
  else {
@@ -180,10 +180,10 @@ function GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST
180
180
  }
181
181
  else {
182
182
  // InvoicePrintData.HeaderName = 'INVOICE';
183
- if (PartsPrint) {
183
+ if (PartsPrint && !LaborPrint) {
184
184
  InvoicePrintData.HeaderName = 'INVOICE (PARTS)';
185
185
  }
186
- else if (LaborPrint) {
186
+ else if (LaborPrint && !PartsPrint) {
187
187
  InvoicePrintData.HeaderName = 'INVOICE (LABOR)';
188
188
  }
189
189
  else {
@@ -0,0 +1,96 @@
1
+ export declare function CreateInvoicePDFService(PDFInvoiceData?: any, PrintConfigData?: any, printCopies?: string[]): {
2
+ footer?: ((_currentPage: number, pageCount: number) => {
3
+ margin: number[];
4
+ columns: {
5
+ text: string;
6
+ alignment: string;
7
+ fontSize: number;
8
+ color: string;
9
+ }[];
10
+ }) | undefined;
11
+ watermark?: {
12
+ text: string;
13
+ color: string;
14
+ opacity: number;
15
+ bold: boolean;
16
+ } | undefined;
17
+ background?: (() => {
18
+ image: string;
19
+ width: number;
20
+ opacity: number;
21
+ alignment: string;
22
+ margin: number[];
23
+ }) | undefined;
24
+ pageSize: string;
25
+ pageOrientation: "portrait" | "landscape";
26
+ pageMargins: [number, number, number, number];
27
+ content: any[];
28
+ info: {
29
+ title: string;
30
+ subject: string;
31
+ };
32
+ };
33
+ export declare function DownloadPDFService(filename?: string, PDFInvoiceData?: any, PrintConfigData?: any, printCopies?: string[]): {
34
+ footer?: ((_currentPage: number, pageCount: number) => {
35
+ margin: number[];
36
+ columns: {
37
+ text: string;
38
+ alignment: string;
39
+ fontSize: number;
40
+ color: string;
41
+ }[];
42
+ }) | undefined;
43
+ watermark?: {
44
+ text: string;
45
+ color: string;
46
+ opacity: number;
47
+ bold: boolean;
48
+ } | undefined;
49
+ background?: (() => {
50
+ image: string;
51
+ width: number;
52
+ opacity: number;
53
+ alignment: string;
54
+ margin: number[];
55
+ }) | undefined;
56
+ pageSize: string;
57
+ pageOrientation: "portrait" | "landscape";
58
+ pageMargins: [number, number, number, number];
59
+ content: any[];
60
+ info: {
61
+ title: string;
62
+ subject: string;
63
+ };
64
+ };
65
+ export declare function GetPdfDataUrl(PDFInvoiceData?: any, PrintConfigData?: any, printCopies?: string[]): {
66
+ footer?: ((_currentPage: number, pageCount: number) => {
67
+ margin: number[];
68
+ columns: {
69
+ text: string;
70
+ alignment: string;
71
+ fontSize: number;
72
+ color: string;
73
+ }[];
74
+ }) | undefined;
75
+ watermark?: {
76
+ text: string;
77
+ color: string;
78
+ opacity: number;
79
+ bold: boolean;
80
+ } | undefined;
81
+ background?: (() => {
82
+ image: string;
83
+ width: number;
84
+ opacity: number;
85
+ alignment: string;
86
+ margin: number[];
87
+ }) | undefined;
88
+ pageSize: string;
89
+ pageOrientation: "portrait" | "landscape";
90
+ pageMargins: [number, number, number, number];
91
+ content: any[];
92
+ info: {
93
+ title: string;
94
+ subject: string;
95
+ };
96
+ };
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateInvoicePDFService = CreateInvoicePDFService;
4
+ exports.DownloadPDFService = DownloadPDFService;
5
+ exports.GetPdfDataUrl = GetPdfDataUrl;
6
+ const pdf_party_details_section_1 = require("../../../shared/party-details-section/pdf-party-details.section");
7
+ const pdf_table_section_1 = require("../../../shared/table-section/pdf-table.section");
8
+ const pdf_totals_section_1 = require("../../../shared/totals-section/pdf-totals.section");
9
+ const pdf_shared_utils_1 = require("../../../shared/header-footer-section/pdf-shared.utils");
10
+ const pdf_header_footer_section_1 = require("../../../shared/header-footer-section/pdf-header-footer.section");
11
+ const PAGE_SIZE = 'A4';
12
+ const PAGE_MARGINS = [20, 20, 20, 20];
13
+ const CELL_PADDING_LEFT = 4;
14
+ const CELL_PADDING_RIGHT = 4;
15
+ const BORDER_WIDTH = 0.5;
16
+ const TABLE_BORDER_COLOR = '#d3d3d3';
17
+ function CreateInvoicePDFService(PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
18
+ const dd = buildPdfDocDefinition(PDFInvoiceData, PrintConfigData, printCopies);
19
+ // pdfMake.createPdf(dd).open();
20
+ return dd;
21
+ }
22
+ function DownloadPDFService(filename = 'invoice.pdf', PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
23
+ const dd = buildPdfDocDefinition(PDFInvoiceData, PrintConfigData, printCopies);
24
+ // pdfMake.createPdf(dd).download(filename);
25
+ return dd;
26
+ }
27
+ function GetPdfDataUrl(PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
28
+ const dd = buildPdfDocDefinition(PDFInvoiceData, PrintConfigData, printCopies);
29
+ // const pdfDoc: any = pdfMake.createPdf(dd);
30
+ return dd;
31
+ // return new Promise((resolve, reject) => {
32
+ // let settled = false;
33
+ // const done = (value: string) => {
34
+ // if (!settled) {
35
+ // settled = true;
36
+ // resolve(value);
37
+ // }
38
+ // };
39
+ // const fail = (error: any) => {
40
+ // if (!settled) {
41
+ // settled = true;
42
+ // reject(error);
43
+ // }
44
+ // };
45
+ // try {
46
+ // if (typeof pdfDoc.getDataUrl === 'function') {
47
+ // const result = pdfDoc.getDataUrl((dataUrl: string) => done(dataUrl));
48
+ // if (result && typeof result.then === 'function') {
49
+ // result.then((dataUrl: string) => done(dataUrl)).catch(fail);
50
+ // }
51
+ // return;
52
+ // }
53
+ // if (typeof pdfDoc.getBlob === 'function') {
54
+ // const result = pdfDoc.getBlob((blob: Blob) => done(URL.createObjectURL(blob)));
55
+ // if (result && typeof result.then === 'function') {
56
+ // result.then((blob: Blob) => done(URL.createObjectURL(blob))).catch(fail);
57
+ // }
58
+ // return;
59
+ // }
60
+ // fail(new Error('No supported preview API found on pdf document instance.'));
61
+ // } catch (error) {
62
+ // fail(error);
63
+ // }
64
+ // });
65
+ }
66
+ function buildPdfDocDefinition(PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
67
+ console.log('Building PDF with data:', PDFInvoiceData);
68
+ const PrintConfig = normalizePrintConfig(PDFInvoiceData, PrintConfigData);
69
+ const pageOrientation = (0, pdf_header_footer_section_1.resolvePageOrientation)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.pageOrientation);
70
+ const pageMargins = (0, pdf_header_footer_section_1.resolvePageMargins)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.pageMargins);
71
+ const availableWidth = (0, pdf_table_section_1.getAvailablePageWidth)(PAGE_SIZE, pageOrientation, pageMargins);
72
+ const copyLabels = normalizeCopyLabels(printCopies);
73
+ const watermark = (0, pdf_header_footer_section_1.buildWatermark)(PrintConfig);
74
+ const background = (0, pdf_header_footer_section_1.buildLogoWatermarkBackground)(PrintConfig);
75
+ const footer = (0, pdf_header_footer_section_1.buildFooter)(PrintConfig);
76
+ const content = [];
77
+ copyLabels.forEach((copyLabel, index) => {
78
+ const invoiceHeaderContent = (0, pdf_header_footer_section_1.buildDocumentHeaderSection)(PrintConfig, PDFInvoiceData);
79
+ const invoiceHeadingContent = (0, pdf_header_footer_section_1.buildDocumentHeadingSection)(PDFInvoiceData, PrintConfig, availableWidth);
80
+ const invoicePartyDetailsContent = (0, pdf_party_details_section_1.buildInvoicePartyDetailsSection)(PDFInvoiceData);
81
+ const invoiceTotalsAndNotesContent = (0, pdf_totals_section_1.buildInvoiceTotalsAndNotesSection)(PDFInvoiceData, availableWidth);
82
+ const signatureContent = (0, pdf_totals_section_1.buildSignatureSection)(PrintConfig, PDFInvoiceData);
83
+ const tableData = (0, pdf_table_section_1.buildInvoiceTableData)(PDFInvoiceData, PrintConfig, availableWidth);
84
+ if (index > 0) {
85
+ content.push({ text: '', pageBreak: 'before' });
86
+ }
87
+ if (copyLabel) {
88
+ content.push({
89
+ text: copyLabel,
90
+ alignment: 'right',
91
+ bold: true,
92
+ fontSize: 8,
93
+ margin: [0, 0, 0, 2]
94
+ });
95
+ }
96
+ content.push(...invoiceHeaderContent, ...invoiceHeadingContent, ...invoicePartyDetailsContent, {
97
+ table: {
98
+ lineHeight: 2,
99
+ headerRows: tableData.headerRows.length,
100
+ widths: tableData.widths,
101
+ body: tableData.body
102
+ },
103
+ layout: {
104
+ paddingLeft: () => CELL_PADDING_LEFT,
105
+ paddingRight: () => CELL_PADDING_RIGHT,
106
+ vLineWidth: () => BORDER_WIDTH,
107
+ hLineWidth: () => BORDER_WIDTH,
108
+ vLineColor: () => TABLE_BORDER_COLOR,
109
+ hLineColor: () => TABLE_BORDER_COLOR
110
+ }
111
+ }, ...invoiceTotalsAndNotesContent, ...signatureContent);
112
+ });
113
+ const dd = Object.assign(Object.assign(Object.assign({ pageSize: PAGE_SIZE, pageOrientation: pageOrientation, pageMargins: pageMargins, content: content, info: {
114
+ title: 'invoice',
115
+ subject: Array.isArray(printCopies) ? printCopies.join(', ') : ''
116
+ } }, (background ? { background } : {})), (watermark ? { watermark } : {})), (footer ? { footer } : {}));
117
+ return dd;
118
+ }
119
+ function normalizeCopyLabels(printCopies = []) {
120
+ const labels = Array.isArray(printCopies)
121
+ ? printCopies
122
+ .map((entry) => (0, pdf_shared_utils_1.toStr)(entry).trim())
123
+ .filter((entry) => !!entry)
124
+ : [];
125
+ return labels.length > 0 ? labels : [''];
126
+ }
127
+ function normalizePrintConfig(PDFInvoiceData, PrintConfigData) {
128
+ var _a, _b;
129
+ const config = PrintConfigData || {};
130
+ const itemsHeader = Array.isArray(config === null || config === void 0 ? void 0 : config.itemsHeader) ? config.itemsHeader : [];
131
+ const headerData = (config === null || config === void 0 ? void 0 : config.headerData) ? config.headerData : (0, pdf_header_footer_section_1.deriveHeaderDataFromInvoice)(PDFInvoiceData);
132
+ const pageMargins = (0, pdf_header_footer_section_1.resolvePageMargins)((_a = config === null || config === void 0 ? void 0 : config.pageMargins) !== null && _a !== void 0 ? _a : PAGE_MARGINS);
133
+ const watermarkText = (0, pdf_shared_utils_1.toStr)(config === null || config === void 0 ? void 0 : config.watermarkText);
134
+ const watermark = !!(config === null || config === void 0 ? void 0 : config.watermark);
135
+ const watermarkEnabled = !!(config === null || config === void 0 ? void 0 : config.watermarkEnabled);
136
+ const footerText = (0, pdf_shared_utils_1.toStr)(config === null || config === void 0 ? void 0 : config.footerText);
137
+ const headerStyles = (0, pdf_header_footer_section_1.normalizeHeaderStyle)((_b = config === null || config === void 0 ? void 0 : config.headerStyles) !== null && _b !== void 0 ? _b : {});
138
+ const fixedTo = normalizeFixedTo(config === null || config === void 0 ? void 0 : config.fixedTo);
139
+ return Object.assign(Object.assign({}, config), { itemsHeader,
140
+ headerData,
141
+ pageMargins,
142
+ watermarkText,
143
+ watermark,
144
+ watermarkEnabled,
145
+ footerText,
146
+ headerStyles,
147
+ fixedTo });
148
+ }
149
+ function normalizeFixedTo(value) {
150
+ const parsed = Number(value);
151
+ if (!Number.isFinite(parsed) || parsed < 0) {
152
+ return 2;
153
+ }
154
+ return Math.floor(parsed);
155
+ }