|
1 | 1 | import { GetSMTPEmails } from "../../Config";
|
2 | 2 | import { IInvoice } from "@interface/Invoice.interface";
|
3 | 3 | import { SendEmail } from "../Send";
|
| 4 | +import UseStyles from "../Templates/General/UseStyles"; |
| 5 | +import { stripIndent } from "common-tags"; |
4 | 6 |
|
5 | 7 | export const InvoiceNotifiedReport = async (invoices: IInvoice[]) =>
|
6 | 8 | {
|
7 |
| - GetSMTPEmails().then((emails) => |
| 9 | + GetSMTPEmails().then(async (emails) => |
8 | 10 | {
|
9 |
| - for(const email of emails) |
| 11 | + for await(const email of emails) |
10 | 12 | {
|
11 | 13 | SendEmail(email, "Invoice(s) Notified", {
|
12 | 14 | isHTML: true,
|
13 |
| - body: ` |
14 |
| - <h1>Invoice(s) Notified</h1> |
15 |
| - <p> |
16 |
| - ${invoices.length} invoices have been notified. |
17 |
| - </p> |
18 |
| - <p> |
19 |
| - The following invoices have been notified: |
20 |
| - ${invoices.map((invoice) => `<br><strong>${invoice.id}</strong>`).join("")} |
21 |
| - </p> |
22 |
| - ` |
| 15 | + body: await UseStyles(stripIndent` |
| 16 | + <div> |
| 17 | + <h1>Invoice(s) Notified</h1> |
| 18 | + <p> |
| 19 | + ${invoices.length} invoices have been notified. |
| 20 | + </p> |
| 21 | + <p> |
| 22 | + The following invoices have been notified: |
| 23 | + ${invoices.map((invoice) => `<br><strong>${invoice.id}</strong>`).join("")} |
| 24 | + </p> |
| 25 | + </div> |
| 26 | + `) |
23 | 27 | });
|
24 | 28 | }
|
25 | 29 | })
|
26 | 30 | };
|
27 | 31 |
|
28 | 32 | export const InvoiceLateReport = async (invoices: IInvoice[]) =>
|
29 | 33 | {
|
30 |
| - GetSMTPEmails().then((emails) => |
| 34 | + GetSMTPEmails().then(async (emails) => |
31 | 35 | {
|
32 |
| - for(const email of emails) |
| 36 | + for await(const email of emails) |
33 | 37 | {
|
34 | 38 | SendEmail(email, "Invoice(s) Late Reminder", {
|
35 | 39 | isHTML: true,
|
36 |
| - body: ` |
37 |
| - <h1>Invoice(s) Reminded</h1> |
38 |
| - <p> |
39 |
| - ${invoices.length} invoices have been reminded. |
40 |
| - </p> |
41 |
| - <p> |
42 |
| - The following invoices have been reminded: |
43 |
| - ${invoices.map((invoice) => `<br><strong>${invoice.id}</strong>`).join("")} |
44 |
| - </p> |
45 |
| - ` |
| 40 | + body: await UseStyles(stripIndent` |
| 41 | + <div> |
| 42 | + <h1>Invoice(s) Reminded</h1> |
| 43 | + <p> |
| 44 | + ${invoices.length} invoices have been reminded. |
| 45 | + </p> |
| 46 | + <p> |
| 47 | + The following invoices have been reminded: |
| 48 | + ${invoices.map((invoice) => `<br><strong>${invoice.id}</strong>`).join("")} |
| 49 | + </p> |
| 50 | + </div> |
| 51 | + `) |
46 | 52 | });
|
47 | 53 | }
|
48 | 54 | })
|
49 | 55 | };
|
50 | 56 |
|
51 | 57 | export const InvoiceCreatedReport = async (invoices: IInvoice[]) =>
|
52 | 58 | {
|
53 |
| - GetSMTPEmails().then((emails) => |
| 59 | + GetSMTPEmails().then(async (emails) => |
54 | 60 | {
|
55 |
| - for(const email of emails) |
| 61 | + for await(const email of emails) |
56 | 62 | {
|
57 | 63 | SendEmail(email, "Invoice(s) Created", {
|
58 | 64 | isHTML: true,
|
59 |
| - body: ` |
60 |
| - <h1>Invoice(s) Created</h1> |
61 |
| - <p> |
62 |
| - ${invoices.length} invoices have been created. |
63 |
| - </p> |
64 |
| - <p> |
65 |
| - The following invoices have been created: |
66 |
| - ${invoices.map((invoice) => `<br><strong>${invoice.id}</strong>`).join("")} |
67 |
| - </p> |
68 |
| - ` |
| 65 | + body: await UseStyles(stripIndent` |
| 66 | + <div> |
| 67 | + <h1>Invoice(s) Created</h1> |
| 68 | + <p> |
| 69 | + ${invoices.length} invoices have been created. |
| 70 | + </p> |
| 71 | + <p> |
| 72 | + The following invoices have been created: |
| 73 | + ${invoices.map((invoice) => `<br><strong>${invoice.id}</strong>`).join("")} |
| 74 | + </p> |
| 75 | + </div> |
| 76 | + `) |
69 | 77 | });
|
70 | 78 | }
|
71 | 79 | })
|
|
0 commit comments