shareneus 1.6.75 → 1.6.77

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.
@@ -1,14 +1,17 @@
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.CreateInvoicePDFService = CreateInvoicePDFService;
4
7
  exports.DownloadInvoicePDFService = DownloadInvoicePDFService;
5
8
  exports.GetInvoicePdfDataUrl = GetInvoicePdfDataUrl;
6
- const pdf_party_details_section_1 = require("../../../shared/party-details-section/pdf-party-details.section");
7
9
  const pdf_table_section_1 = require("../../../shared/table-section/pdf-table.section");
8
10
  const pdf_totals_section_1 = require("../../../shared/totals-section/pdf-totals.section");
9
11
  const pdf_shared_utils_1 = require("../../../shared/header-footer-section/pdf-shared.utils");
10
12
  const pdf_header_footer_section_1 = require("../../../shared/header-footer-section/pdf-header-footer.section");
11
- const shared_pdf_service_1 = require("../../../shared/shared-pdf.service");
13
+ const tr_utils_1 = require("../../../utils/tr-utils");
14
+ const jsbarcode_1 = __importDefault(require("jsbarcode"));
12
15
  const PAGE_MARGINS = [20, 20, 20, 20];
13
16
  const CELL_PADDING_LEFT = 4;
14
17
  const CELL_PADDING_RIGHT = 4;
@@ -62,13 +65,144 @@ function GetInvoicePdfDataUrl(PDFInvoiceData = {}, PrintConfigData = {}, printCo
62
65
  // }
63
66
  // });
64
67
  }
65
- function SalesReceiptHeaderData(Entity, Image, AColor, HColor, text) {
66
- return [
67
- shared_pdf_service_1.SharedPDFService.GetMainHeader(Entity, Image, AColor, HColor, text),
68
- shared_pdf_service_1.SharedPDFService.GetPrintType('Sales Receipt'),
69
- shared_pdf_service_1.SharedPDFService.HeaderAfterLine()
68
+ function CustomerInfo(InvoicePDFData) {
69
+ let CustomerTable = [
70
+ [{ text: 'Name', style: ['headerstyle'] }, { text: ':', style: ['headerstyle'] }, { text: InvoicePDFData.Customer.Name, style: ['headerstyle'] }],
71
+ [{ text: 'Doctor', style: ['headerstyle'] }, { text: ':', style: ['headerstyle'] }, { text: InvoicePDFData.Name, style: ['headerstyle'] }]
70
72
  ];
73
+ if (InvoicePDFData.Customer.Code) {
74
+ CustomerTable.unshift([{ text: 'UHID', style: ['headerstyle'] }, { text: ':', style: ['headerstyle'] }, { text: InvoicePDFData.Customer.Code, style: ['headerstyle'] }]);
75
+ }
76
+ return CustomerTable;
77
+ }
78
+ function GetBarCode(code, PrCustBar) {
79
+ if (!tr_utils_1.TrUtils.IsNull(code) && PrCustBar) {
80
+ return { svg: textToSvgBarcode(code).svg };
81
+ }
82
+ else {
83
+ return {};
84
+ }
85
+ }
86
+ function textToSvgBarcode(text) {
87
+ const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
88
+ (0, jsbarcode_1.default)(svgElement, text, {
89
+ format: "CODE128", width: 1.25, height: 25, margin: 0, marginTop: 8,
90
+ displayValue: true, fontSize: 7, textMargin: 0, fontOptions: 'bold'
91
+ });
92
+ return { svg: svgElement.outerHTML };
93
+ }
94
+ function GetPartyDetails(Entity, InvoicePDFData) {
95
+ var _a;
96
+ return {
97
+ style: 'tableExample',
98
+ table: {
99
+ widths: ['*', 'auto', '*'],
100
+ body: [
101
+ [{
102
+ // marginTop: 4,
103
+ marginLeft: 5,
104
+ // stack: [{ text: 'UHID : ' + InvoicePDFData.Customer.Code, style: ['headerstyle'] },
105
+ // { text: 'Name : ' + InvoicePDFData.Customer.Name, style: ['headerstyle'] },
106
+ // { text: 'Doctor : ' + InvoicePDFData.Name, style: ['headerstyle'] }],
107
+ table: {
108
+ lineHeight: 0.5,
109
+ body: CustomerInfo(InvoicePDFData)
110
+ }, layout: 'noBorders'
111
+ }, GetBarCode((_a = InvoicePDFData.Customer) === null || _a === void 0 ? void 0 : _a.Code, InvoicePDFData.Entity.PrCustBar),
112
+ {
113
+ // marginTop: 4,
114
+ marginRight: 5,
115
+ marginLeft: 70,
116
+ // alignment: 'right',
117
+ // stack: [{ text: 'Bill No : ' + InvoicePDFData._id, style: ['headerstyle'] },
118
+ // { text: 'Date : ' + InvoicePDFData.CrDate, style: ['headerstyle'] }]
119
+ table: {
120
+ lineHeight: 0.5,
121
+ body: [
122
+ [{ text: 'Bill No', style: ['headerstyle'] }, { text: ':', style: ['headerstyle'] }, { text: InvoicePDFData._id, style: ['headerstyle'] }],
123
+ [{ text: 'Date', style: ['headerstyle'] }, { text: ':', style: ['headerstyle'] }, { text: InvoicePDFData.CrDate, style: ['headerstyle'] }],
124
+ // [{text:'Doctor', style: ['headerstyle']}, {text:':', style: ['headerstyle']}, {text: InvoicePDFData.Name, style: ['headerstyle']}]
125
+ ]
126
+ }, layout: 'noBorders'
127
+ }]
128
+ ]
129
+ },
130
+ layout: HeaderLayOut()
131
+ };
132
+ }
133
+ function HeaderLayOut() {
134
+ return {
135
+ hLineWidth: function (i, node) {
136
+ return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0;
137
+ },
138
+ vLineWidth: function (i, node) {
139
+ return (i === 0 || i === node.table.widths.length) ? 1 : 0;
140
+ },
141
+ // hLineStyle: function (i, node) {
142
+ // return (i === 0 || i === 1) ? { dash: { length: 5, space: 5 } } : null;
143
+ // },
144
+ hLineColor: function (i, node) {
145
+ return 'gray';
146
+ },
147
+ vLineColor: function (i, node) {
148
+ return 'gray';
149
+ },
150
+ };
151
+ }
152
+ function GetMainHeaderInfo(Entity, Image, AColor, HColor, InvoicePDFData) {
153
+ if (!tr_utils_1.TrUtils.IsNull(Image)) {
154
+ return {
155
+ columns: [{ image: Image, width: 60, height: 60, marginBottom: 5 },
156
+ {
157
+ stack: [
158
+ { text: Entity.CName, style: ['headerstyle'], color: HColor, alignment: 'left', fontSize: 15 },
159
+ { text: GetAddress(Entity), alignment: 'left', style: ['headerstyle'], color: AColor },
160
+ {
161
+ columns: GetHeaderInfo(InvoicePDFData, 0)
162
+ },
163
+ { text: InvoicePDFData.HeaderName, alignment: 'center', style: ['Receiptheader1'], marginTop: 5 }
164
+ ]
165
+ }
166
+ ], columnGap: 10
167
+ };
168
+ }
169
+ else {
170
+ return {
171
+ stack: [
172
+ { text: InvoicePDFData.Entity.CName, style: ['headerstyle'], alignment: 'center', fontSize: 15 },
173
+ { text: GetAddress(InvoicePDFData.Entity), alignment: 'center', style: ['headerstyle'] },
174
+ {
175
+ columns: GetHeaderInfo(InvoicePDFData.Entity, 5, InvoicePDFData)
176
+ },
177
+ { text: InvoicePDFData.HeaderName, alignment: 'center', style: ['Receiptheader1'] }
178
+ ]
179
+ };
180
+ }
181
+ }
182
+ function GetAddress(Entity) {
183
+ return Entity.Adrs1 + ', ' + Entity.Adrs2 + ', ' + Entity.City + '-' + Entity.PIN + ', Cell : ' + Entity.Phone;
184
+ }
185
+ function GetHeaderInfo(Entity, marginleft, InvoicePDFData = {}) {
186
+ let TaxInfo = [];
187
+ if (!tr_utils_1.TrUtils.IsEmpty(Entity.GSTIN)) {
188
+ TaxInfo.push({ text: 'GSTIN : ' + Entity.GSTIN, marginTop: 2, marginLeft: marginleft, alignment: 'left', fontSize: 9, width: 'auto' });
189
+ }
190
+ if (!tr_utils_1.TrUtils.IsEmpty(Entity.DLNo)) {
191
+ TaxInfo.push({ text: 'D.L.NO : ' + Entity.DLNo, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: '*' });
192
+ }
193
+ TaxInfo.push(GetBillofSupplyName(InvoicePDFData.Settings));
194
+ return TaxInfo;
195
+ }
196
+ function GetBillofSupplyName(Settings) {
197
+ return { text: Settings.Tax === 'BS' ? ' Bill of Supply' : null, alignment: 'center', marginLeft: 15, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' };
71
198
  }
199
+ // function SalesReceiptHeaderData(Entity: any, Image: any, AColor: any, HColor: any, text: any) {
200
+ // return [
201
+ // SharedPDFService.GetMainHeader(Entity, Image, AColor, HColor, text),
202
+ // SharedPDFService.GetPrintType('Sales Receipt'),
203
+ // SharedPDFService.HeaderAfterLine()
204
+ // ]
205
+ // }
72
206
  function buildPdfDocDefinition(PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
73
207
  var _a;
74
208
  const PrintConfig = normalizePrintConfig(PDFInvoiceData, PrintConfigData);
@@ -91,11 +225,12 @@ function buildPdfDocDefinition(PDFInvoiceData = {}, PrintConfigData = {}, printC
91
225
  const availableWidth = (0, pdf_table_section_1.getAvailablePageWidth)(pageSize, requestedPageOrientation, pageMargins);
92
226
  const content = [];
93
227
  copyLabels.forEach((copyLabel, index) => {
94
- var _a, _b, _c;
228
+ var _a, _b;
95
229
  // const invoiceHeaderContent = buildDocumentHeaderSection(PrintConfig, PDFInvoiceData);
96
- const invoiceHeaderContent = SalesReceiptHeaderData(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Entity, PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Image, (_a = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) === null || _a === void 0 ? void 0 : _a.OrgNameClr, (_b = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) === null || _b === void 0 ? void 0 : _b.AdrsClr, (_c = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerData) === null || _c === void 0 ? void 0 : _c.OrgName);
230
+ const invoiceHeaderContent = [GetMainHeaderInfo(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Entity, PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Image, (_a = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) === null || _a === void 0 ? void 0 : _a.OrgNameClr, (_b = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) === null || _b === void 0 ? void 0 : _b.AdrsClr, PDFInvoiceData)];
97
231
  const invoiceHeadingContent = (0, pdf_header_footer_section_1.buildDocumentHeadingSection)(PDFInvoiceData, PrintConfig, availableWidth);
98
- const invoicePartyDetailsContent = (0, pdf_party_details_section_1.buildInvoicePartyDetailsSection)(PDFInvoiceData, PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Customer, PrintConfig);
232
+ // const invoicePartyDetailsContent = buildInvoicePartyDetailsSection(PDFInvoiceData, PrintConfig?.Customer, PrintConfig);
233
+ const invoicePartyDetailsContent = [GetPartyDetails(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Entity, PDFInvoiceData)];
99
234
  const invoiceTotalsAndNotesContent = (0, pdf_totals_section_1.buildInvoiceTotalsAndNotesSection)(PDFInvoiceData, availableWidth, PrintConfigData);
100
235
  const signatureContent = (0, pdf_totals_section_1.buildSignatureSection)(PrintConfig, PDFInvoiceData, availableWidth);
101
236
  const tableData = (0, pdf_table_section_1.buildInvoiceTableData)(PDFInvoiceData, PrintConfig, availableWidth);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.75",
3
+ "version": "1.6.77",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",