@tomei/finance 0.4.5 → 0.4.7

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,156 +1,280 @@
1
-
2
1
  <!DOCTYPE html>
3
2
  <html class="no-js" lang="en">
3
+ <head>
4
+ <!-- Meta Tags -->
5
+ <meta charset="utf-8" />
6
+ <meta http-equiv="x-ua-compatible" content="ie=edge" />
7
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
8
+ <meta name="author" content="Laralink" />
9
+ <!-- Site Title -->
10
+ <title>General Purpose Invoice</title>
11
+ <link rel="stylesheet" type="text/css" href="./assets/css/style.css" />
12
+ </head>
4
13
 
5
- <head>
6
- <!-- Meta Tags -->
7
- <meta charset="utf-8">
8
- <meta http-equiv="x-ua-compatible" content="ie=edge">
9
- <meta name="viewport" content="width=device-width, initial-scale=1">
10
- <meta name="author" content="Laralink">
11
- <!-- Site Title -->
12
- <title>General Purpose Invoice</title>
13
- <link rel="stylesheet" href="assets/css/style.css">
14
- </head>
15
-
16
- <body>
17
- <div class="tm_container">
18
- <div class="tm_invoice_wrap">
19
- <div class="tm_invoice tm_style1" id="tm_download_section">
20
- <div class="tm_invoice_in">
21
- <div class="tm_invoice_head tm_align_center tm_mb20">
22
- <div class="tm_invoice_left">
23
- <div class="tm_logo"><img src="assets/img/logo.svg" alt="Logo"></div>
24
- </div>
25
- <div class="tm_invoice_right tm_text_right">
26
- <div class="tm_primary_color tm_f50 tm_text_uppercase">Invoice</div>
27
- </div>
28
- </div>
29
- <div class="tm_invoice_info tm_mb20">
30
- <div class="tm_invoice_seperator tm_gray_bg"></div>
31
- <div class="tm_invoice_info_list">
32
- <p class="tm_invoice_number tm_m0">Invoice No: <b class="tm_primary_color">#LL93784</b></p>
33
- <p class="tm_invoice_date tm_m0">Date: <b class="tm_primary_color">01.07.2022</b></p>
34
- </div>
35
- </div>
36
- <div class="tm_invoice_head tm_mb10">
37
- <div class="tm_invoice_left">
38
- <p class="tm_mb2"><b class="tm_primary_color">Invoice To:</b></p>
39
- <p>
40
- Lowell H. Dominguez <br>
41
- 84 Spilman Street, London <br>United Kingdom <br>
42
- lowell@gmail.com
43
- </p>
14
+ <body>
15
+ <div class="tm_container">
16
+ <div class="tm_invoice_wrap">
17
+ <div class="tm_invoice tm_style1" id="tm_download_section">
18
+ <div class="tm_invoice_in">
19
+ <div class="tm_invoice_head tm_align_center tm_mb20">
20
+ <div class="tm_invoice_left">
21
+ <div class="tm_logo">
22
+ <img src="./assets/img/logo.svg" alt="Logo" />
23
+ </div>
24
+ </div>
25
+ <div class="tm_invoice_right tm_text_right">
26
+ <div class="tm_primary_color tm_f50 tm_text_uppercase">
27
+ Invoice
28
+ </div>
29
+ </div>
44
30
  </div>
45
- <div class="tm_invoice_right tm_text_right">
46
- <p class="tm_mb2"><b class="tm_primary_color">Pay To:</b></p>
47
- <p>
48
- Laralink Ltd <br>
49
- 86-90 Paul Street, London<br>
50
- England EC2A 4NE <br>
51
- demo@gmail.com
52
- </p>
31
+ <div class="tm_invoice_info tm_mb20">
32
+ <div class="tm_invoice_seperator tm_gray_bg"></div>
33
+ <div class="tm_invoice_info_list">
34
+ <p class="tm_invoice_number tm_m0">
35
+ Invoice No: <b class="tm_primary_color">#LL93784</b>
36
+ </p>
37
+ <p class="tm_invoice_date tm_m0">
38
+ Date: <b class="tm_primary_color">01.07.2022</b>
39
+ </p>
40
+ </div>
53
41
  </div>
54
- </div>
55
- <div class="tm_table tm_style1 tm_mb30">
56
- <div class="tm_round_border">
57
- <div class="tm_table_responsive">
58
- <table>
59
- <thead>
60
- <tr>
61
- <th class="tm_width_3 tm_semi_bold tm_primary_color tm_gray_bg">Item</th>
62
- <th class="tm_width_4 tm_semi_bold tm_primary_color tm_gray_bg">Description</th>
63
- <th class="tm_width_2 tm_semi_bold tm_primary_color tm_gray_bg">Price</th>
64
- <th class="tm_width_1 tm_semi_bold tm_primary_color tm_gray_bg">Qty</th>
65
- <th class="tm_width_2 tm_semi_bold tm_primary_color tm_gray_bg tm_text_right">Total</th>
66
- </tr>
67
- </thead>
68
- <tbody>
69
- <tr>
70
- <td class="tm_width_3">1. Website Design</td>
71
- <td class="tm_width_4">Six web page designs and three times revision</td>
72
- <td class="tm_width_2">$350</td>
73
- <td class="tm_width_1">1</td>
74
- <td class="tm_width_2 tm_text_right">$350</td>
75
- </tr>
76
- <tr>
77
- <td class="tm_width_3">2. Web Development</td>
78
- <td class="tm_width_4">Convert pixel-perfect frontend and make it dynamic</td>
79
- <td class="tm_width_2">$600</td>
80
- <td class="tm_width_1">1</td>
81
- <td class="tm_width_2 tm_text_right">$600</td>
82
- </tr>
83
- <tr>
84
- <td class="tm_width_3">3. App Development</td>
85
- <td class="tm_width_4">Android & Ios Application Development</td>
86
- <td class="tm_width_2">$200</td>
87
- <td class="tm_width_1">2</td>
88
- <td class="tm_width_2 tm_text_right">$400</td>
89
- </tr>
90
- <tr>
91
- <td class="tm_width_3">4. Digital Marketing</td>
92
- <td class="tm_width_4">Facebook, Youtube and Google Marketing</td>
93
- <td class="tm_width_2">$100</td>
94
- <td class="tm_width_1">3</td>
95
- <td class="tm_width_2 tm_text_right">$300</td>
96
- </tr>
97
- </tbody>
98
- </table>
42
+ <div class="tm_invoice_head tm_mb10">
43
+ <div class="tm_invoice_left">
44
+ <p class="tm_mb2">
45
+ <b class="tm_primary_color">Invoice To:</b>
46
+ </p>
47
+ <p>
48
+ Lowell H. Dominguez <br />
49
+ 84 Spilman Street, London <br />United Kingdom <br />
50
+ lowell@gmail.com
51
+ </p>
52
+ </div>
53
+ <div class="tm_invoice_right tm_text_right">
54
+ <p class="tm_mb2"><b class="tm_primary_color">Pay To:</b></p>
55
+ <p>
56
+ Laralink Ltd <br />
57
+ 86-90 Paul Street, London<br />
58
+ England EC2A 4NE <br />
59
+ demo@gmail.com
60
+ </p>
99
61
  </div>
100
62
  </div>
101
- <div class="tm_invoice_footer">
102
- <div class="tm_left_footer">
103
- <p class="tm_mb2"><b class="tm_primary_color">Payment info:</b></p>
104
- <p class="tm_m0">Credit Card - 236***********928 <br>Amount: $1732</p>
63
+ <div class="tm_table tm_style1 tm_mb30">
64
+ <div class="tm_round_border">
65
+ <div class="tm_table_responsive">
66
+ <table>
67
+ <thead>
68
+ <tr>
69
+ <th
70
+ class="tm_width_3 tm_semi_bold tm_primary_color tm_gray_bg"
71
+ >
72
+ Item
73
+ </th>
74
+ <th
75
+ class="tm_width_4 tm_semi_bold tm_primary_color tm_gray_bg"
76
+ >
77
+ Description
78
+ </th>
79
+ <th
80
+ class="tm_width_2 tm_semi_bold tm_primary_color tm_gray_bg"
81
+ >
82
+ Price
83
+ </th>
84
+ <th
85
+ class="tm_width_1 tm_semi_bold tm_primary_color tm_gray_bg"
86
+ >
87
+ Qty
88
+ </th>
89
+ <th
90
+ class="tm_width_2 tm_semi_bold tm_primary_color tm_gray_bg tm_text_right"
91
+ >
92
+ Total
93
+ </th>
94
+ </tr>
95
+ </thead>
96
+ <tbody>
97
+ <tr>
98
+ <td class="tm_width_3">1. Website Design</td>
99
+ <td class="tm_width_4">
100
+ Six web page designs and three times revision
101
+ </td>
102
+ <td class="tm_width_2">$350</td>
103
+ <td class="tm_width_1">1</td>
104
+ <td class="tm_width_2 tm_text_right">$350</td>
105
+ </tr>
106
+ <tr>
107
+ <td class="tm_width_3">2. Web Development</td>
108
+ <td class="tm_width_4">
109
+ Convert pixel-perfect frontend and make it dynamic
110
+ </td>
111
+ <td class="tm_width_2">$600</td>
112
+ <td class="tm_width_1">1</td>
113
+ <td class="tm_width_2 tm_text_right">$600</td>
114
+ </tr>
115
+ <tr>
116
+ <td class="tm_width_3">3. App Development</td>
117
+ <td class="tm_width_4">
118
+ Android & Ios Application Development
119
+ </td>
120
+ <td class="tm_width_2">$200</td>
121
+ <td class="tm_width_1">2</td>
122
+ <td class="tm_width_2 tm_text_right">$400</td>
123
+ </tr>
124
+ <tr>
125
+ <td class="tm_width_3">4. Digital Marketing</td>
126
+ <td class="tm_width_4">
127
+ Facebook, Youtube and Google Marketing
128
+ </td>
129
+ <td class="tm_width_2">$100</td>
130
+ <td class="tm_width_1">3</td>
131
+ <td class="tm_width_2 tm_text_right">$300</td>
132
+ </tr>
133
+ </tbody>
134
+ </table>
135
+ </div>
105
136
  </div>
106
- <div class="tm_right_footer">
107
- <table>
108
- <tbody>
109
- <tr>
110
- <td class="tm_width_3 tm_primary_color tm_border_none tm_bold">Subtoal</td>
111
- <td class="tm_width_3 tm_primary_color tm_text_right tm_border_none tm_bold">$1650</td>
112
- </tr>
113
- <tr>
114
- <td class="tm_width_3 tm_primary_color tm_border_none tm_pt0">Tax <span class="tm_ternary_color">(5%)</span></td>
115
- <td class="tm_width_3 tm_primary_color tm_text_right tm_border_none tm_pt0">+$82</td>
116
- </tr>
117
- <tr class="tm_border_top tm_border_bottom">
118
- <td class="tm_width_3 tm_border_top_0 tm_bold tm_f16 tm_primary_color">Grand Total </td>
119
- <td class="tm_width_3 tm_border_top_0 tm_bold tm_f16 tm_primary_color tm_text_right">$1732</td>
120
- </tr>
121
- </tbody>
122
- </table>
137
+ <div class="tm_invoice_footer">
138
+ <div class="tm_left_footer">
139
+ <p class="tm_mb2">
140
+ <b class="tm_primary_color">Payment info:</b>
141
+ </p>
142
+ <p class="tm_m0">
143
+ Credit Card - 236***********928 <br />Amount: $1732
144
+ </p>
145
+ </div>
146
+ <div class="tm_right_footer">
147
+ <table>
148
+ <tbody>
149
+ <tr>
150
+ <td
151
+ class="tm_width_3 tm_primary_color tm_border_none tm_bold"
152
+ >
153
+ Subtoal
154
+ </td>
155
+ <td
156
+ class="tm_width_3 tm_primary_color tm_text_right tm_border_none tm_bold"
157
+ >
158
+ $1650
159
+ </td>
160
+ </tr>
161
+ <tr>
162
+ <td
163
+ class="tm_width_3 tm_primary_color tm_border_none tm_pt0"
164
+ >
165
+ Tax <span class="tm_ternary_color">(5%)</span>
166
+ </td>
167
+ <td
168
+ class="tm_width_3 tm_primary_color tm_text_right tm_border_none tm_pt0"
169
+ >
170
+ +$82
171
+ </td>
172
+ </tr>
173
+ <tr class="tm_border_top tm_border_bottom">
174
+ <td
175
+ class="tm_width_3 tm_border_top_0 tm_bold tm_f16 tm_primary_color"
176
+ >
177
+ Grand Total
178
+ </td>
179
+ <td
180
+ class="tm_width_3 tm_border_top_0 tm_bold tm_f16 tm_primary_color tm_text_right"
181
+ >
182
+ $1732
183
+ </td>
184
+ </tr>
185
+ </tbody>
186
+ </table>
187
+ </div>
123
188
  </div>
124
189
  </div>
190
+ <div class="tm_padd_15_20 tm_round_border">
191
+ <p class="tm_mb5">
192
+ <b class="tm_primary_color">Terms & Conditions:</b>
193
+ </p>
194
+ <ul class="tm_m0 tm_note_list">
195
+ <li>
196
+ All claims relating to quantity or shipping errors shall be
197
+ waived by Buyer unless made in writing to Seller within thirty
198
+ (30) days after delivery of goods to the address stated.
199
+ </li>
200
+ <li>
201
+ Delivery dates are not guaranteed and Seller has no liability
202
+ for damages that may be incurred due to any delay in shipment
203
+ of goods hereunder. Taxes are excluded unless otherwise
204
+ stated.
205
+ </li>
206
+ </ul>
207
+ </div>
208
+ <!-- .tm_note -->
125
209
  </div>
126
- <div class="tm_padd_15_20 tm_round_border">
127
- <p class="tm_mb5"><b class="tm_primary_color">Terms & Conditions:</b></p>
128
- <ul class="tm_m0 tm_note_list">
129
- <li>All claims relating to quantity or shipping errors shall be waived by Buyer unless made in writing to Seller within thirty (30) days after delivery of goods to the address stated.</li>
130
- <li>Delivery dates are not guaranteed and Seller has no liability for damages that may be incurred due to any delay in shipment of goods hereunder. Taxes are excluded unless otherwise stated.</li>
131
- </ul>
132
- </div><!-- .tm_note -->
133
210
  </div>
134
- </div>
135
- <div class="tm_invoice_btns tm_hide_print">
136
- <a href="javascript:window.print()" class="tm_invoice_btn tm_color1">
137
- <span class="tm_btn_icon">
138
- <svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512"><path d="M384 368h24a40.12 40.12 0 0040-40V168a40.12 40.12 0 00-40-40H104a40.12 40.12 0 00-40 40v160a40.12 40.12 0 0040 40h24" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><rect x="128" y="240" width="256" height="208" rx="24.32" ry="24.32" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><path d="M384 128v-24a40.12 40.12 0 00-40-40H168a40.12 40.12 0 00-40 40v24" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><circle cx="392" cy="184" r="24" fill='currentColor'/></svg>
139
- </span>
140
- <span class="tm_btn_text">Print</span>
141
- </a>
142
- <button id="tm_download_btn" class="tm_invoice_btn tm_color2">
143
- <span class="tm_btn_icon">
144
- <svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512"><path d="M320 336h76c55 0 100-21.21 100-75.6s-53-73.47-96-75.6C391.11 99.74 329 48 256 48c-69 0-113.44 45.79-128 91.2-60 5.7-112 35.88-112 98.4S70 336 136 336h56M192 400.1l64 63.9 64-63.9M256 224v224.03" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/></svg>
145
- </span>
146
- <span class="tm_btn_text">Download</span>
147
- </button>
211
+ <div class="tm_invoice_btns tm_hide_print">
212
+ <a href="javascript:window.print()" class="tm_invoice_btn tm_color1">
213
+ <span class="tm_btn_icon">
214
+ <svg
215
+ xmlns="http://www.w3.org/2000/svg"
216
+ class="ionicon"
217
+ viewBox="0 0 512 512"
218
+ >
219
+ <path
220
+ d="M384 368h24a40.12 40.12 0 0040-40V168a40.12 40.12 0 00-40-40H104a40.12 40.12 0 00-40 40v160a40.12 40.12 0 0040 40h24"
221
+ fill="none"
222
+ stroke="currentColor"
223
+ stroke-linejoin="round"
224
+ stroke-width="32"
225
+ />
226
+ <rect
227
+ x="128"
228
+ y="240"
229
+ width="256"
230
+ height="208"
231
+ rx="24.32"
232
+ ry="24.32"
233
+ fill="none"
234
+ stroke="currentColor"
235
+ stroke-linejoin="round"
236
+ stroke-width="32"
237
+ />
238
+ <path
239
+ d="M384 128v-24a40.12 40.12 0 00-40-40H168a40.12 40.12 0 00-40 40v24"
240
+ fill="none"
241
+ stroke="currentColor"
242
+ stroke-linejoin="round"
243
+ stroke-width="32"
244
+ />
245
+ <circle cx="392" cy="184" r="24" fill="currentColor" />
246
+ </svg>
247
+ </span>
248
+ <span class="tm_btn_text">Print</span>
249
+ </a>
250
+ <button id="tm_download_btn" class="tm_invoice_btn tm_color2">
251
+ <span class="tm_btn_icon">
252
+ <svg
253
+ xmlns="http://www.w3.org/2000/svg"
254
+ class="ionicon"
255
+ viewBox="0 0 512 512"
256
+ >
257
+ <path
258
+ d="M320 336h76c55 0 100-21.21 100-75.6s-53-73.47-96-75.6C391.11 99.74 329 48 256 48c-69 0-113.44 45.79-128 91.2-60 5.7-112 35.88-112 98.4S70 336 136 336h56M192 400.1l64 63.9 64-63.9M256 224v224.03"
259
+ fill="none"
260
+ stroke="currentColor"
261
+ stroke-linecap="round"
262
+ stroke-linejoin="round"
263
+ stroke-width="32"
264
+ />
265
+ </svg>
266
+ </span>
267
+ <span class="tm_btn_text">Download</span>
268
+ </button>
269
+ </div>
148
270
  </div>
149
271
  </div>
150
- </div>
151
- <script src="assets/js/jquery.min.js"></script>
152
- <script src="assets/js/jspdf.min.js"></script>
153
- <script src="assets/js/html2canvas.min.js"></script>
154
- <script src="assets/js/main.js"></script>
155
- </body>
156
- </html>
272
+ <script type="text/javascript" src="./assets/js/jquery.min.js"></script>
273
+ <script type="text/javascript" src="./assets/js/jspdf.min.js"></script>
274
+ <script
275
+ type="text/javascript"
276
+ src="./assets/js/html2canvas.min.js"
277
+ ></script>
278
+ <script type="text/javascript" src="./assets/js/main.js"></script>
279
+ </body>
280
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/finance",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -306,24 +306,38 @@ export default class Document extends AccountSystemEntity {
306
306
  const cssLocation = path.resolve('./invoice-template/assets/css/style.css');
307
307
  const readFileContent = util.promisify(fs.readFile);
308
308
  // const htmlString = await readFileContent(templateLocation, 'utf8');
309
- const [htmlString, cssString] = await Promise.all([
309
+ const [htmlString] = await Promise.all([
310
310
  readFileContent(templateLocation, 'utf8'),
311
- readFileContent(cssLocation, 'utf8'),
312
311
  ]);
313
312
 
314
313
  /* converting HTML to PDF */
315
314
  const browser = await puppeteer.launch();
316
315
  const page = await browser.newPage();
317
316
 
318
- /* include the CSS from the HTML directory */
319
- await page.addStyleTag({ content: cssString });
317
+ const imagePath = path.resolve('./invoice-template/assets/img/logo.svg');
318
+ const imageBuffer = await readFileContent(imagePath);
319
+ const imageDataUrl = `data:image/svg+xml;base64,${imageBuffer.toString(
320
+ 'base64',
321
+ )}`;
322
+
323
+ const imgTag = `<img src="${imageDataUrl}" alt="Logo">`;
320
324
 
321
325
  if (htmlString) {
322
326
  await page.setContent(htmlString);
327
+ await page.addStyleTag({ path: cssLocation });
328
+ const divHandle = await page.$('.tm_logo');
329
+ await divHandle.evaluate((div, imgTag) => {
330
+ div.innerHTML = imgTag;
331
+ }, imgTag);
323
332
  } else if (templateLocation) {
324
333
  await page.goto(templateLocation, {
325
334
  waitUntil: 'networkidle2',
326
335
  });
336
+ await page.addStyleTag({ path: cssLocation });
337
+ const divHandle = await page.$('.tm_logo');
338
+ await divHandle.evaluate((div, imgTag) => {
339
+ div.innerHTML = imgTag;
340
+ }, imgTag);
327
341
  } else {
328
342
  await browser.close();
329
343
  }
@@ -435,7 +449,10 @@ export default class Document extends AccountSystemEntity {
435
449
  );
436
450
 
437
451
  /* todo: needs to manipulate HTML DOM before uploading to media*/
438
- console.log(customer || 'no customer provided', '<< customer');
452
+ console.log(
453
+ customer || 'no customer provided',
454
+ '<< customer dari generate invoice',
455
+ );
439
456
 
440
457
  /* insert FileStream on htmlPayload */
441
458
  const htmlPayload: InternalMediaDto = {
@@ -482,13 +499,14 @@ export default class Document extends AccountSystemEntity {
482
499
  where: {
483
500
  DocNo: this.DocNo,
484
501
  },
485
- transaction: this._DbTransaction,
502
+ // transaction: this._DbTransaction,
486
503
  });
487
504
 
488
505
  /* storing HTML & PDF MediaId to finance_Document */
489
506
  document.DocHTMLFileMediaId = HTMLInvoiceMedia.MediaId;
490
507
  document.DocPDFFileMediaId = PDFInvoiceMedia.MediaId;
491
- await document.save({ transaction: this._DbTransaction });
508
+ await document.save();
509
+ // await document.save({ transaction: this._DbTransaction });
492
510
  } catch (err) {
493
511
  // tslint:disable-next-line:no-console
494
512
  console.log(err);