diff --git a/common/placeholders.js b/common/placeholders.js index e230a763..e394ed2c 100644 --- a/common/placeholders.js +++ b/common/placeholders.js @@ -32,7 +32,14 @@ const placeholders = [ label: 'Signature', type: placeholderTypes.ATTACHMENT, format: () => 'Signature' - } + }, + { + id: 'items', + label: 'Donation Receipt Information', + type: placeholderTypes.EMAIL, + required: true, + format: value => table(value) + }, ] function getPagePlaceholders() { @@ -59,6 +66,16 @@ function getPlaceholders(types) { return placeholders } +function table(value) { + let tableFinal = `` + let total = 0 + for (let i = 0; i < value.length; i++) { + tableFinal += `` + total += value[i].value + } + return tableFinal + `

Item

Value

"${value[i].name}"

"${value[i].value}"

Total:

"${total}"

` +} + export { placeholders as default, placeholderTypes, diff --git a/server/lib/mail/mail-helpers.js b/server/lib/mail/mail-helpers.js index c05b8d2e..6e803f41 100644 --- a/server/lib/mail/mail-helpers.js +++ b/server/lib/mail/mail-helpers.js @@ -15,7 +15,6 @@ export default { async send(toEmail, toName, identifier, bindings = null) { const settings = await Settings.findOne().lean() const mail = await mailGenerator(identifier, {...settings, ...bindings}) - if (!mail) return try { @@ -90,14 +89,14 @@ export default { }, async sendReceipt(donation) { - const {donor} = donation + const {donor, items} = donation const {firstName, lastName, email} = donor const fullName = `${firstName} ${lastName}` await this.send( email, fullName, pageIdentifiers.DONATION_RECEIPT, - {firstName, lastName, fullName} + {firstName, lastName, fullName, items} ) } } diff --git a/server/lib/seed/seed-data.js b/server/lib/seed/seed-data.js index 84411cab..aebd9c80 100644 --- a/server/lib/seed/seed-data.js +++ b/server/lib/seed/seed-data.js @@ -174,14 +174,16 @@ export const pages = [{

is committed to protecting your personal information by following responsible information handling practices and in keeping with privacy laws. All information remains strictly confidential as outlined by 's Privacy Policy that can be accessed at .

-

If you have any questions or concerns, feel free to contact us.

` +

If you have any questions or concerns, feel free to contact us.

+` }, { identifier: pageIdentifiers.DONATION_RECEIPT, title: 'Donation Receipt', type: pageTypes.EMAIL, subject: '

Receipt for Your Donation to

', body: `

Dear ,

-` +

Here you have a list of the donations our organization recibed from you:

+

` }] const commonFields = [