Skip to content

Commit

Permalink
Update email wording and invoice format
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmckendry committed Nov 4, 2023
1 parent 713aab9 commit 9c59bd6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
9 changes: 8 additions & 1 deletion invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,21 @@ func sendEmail(dog Dog) error {
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}

ownerFirstName := strings.Split(dog.OwnerName, " ")[0]
fromFirstName := strings.Split(os.Getenv("FROM_NAME"), " ")[0]

walkOrWalks := "walk"
if dog.Quantity > 1 {
walkOrWalks = "walks"
}

m := gomail.NewMessage()
m.SetHeader("From", fmt.Sprintf("Canine Club<%s>", os.Getenv("SMTP_USER")))
m.SetHeader("To", fmt.Sprintf("%s <%s>", dog.OwnerName, dog.Email))
m.SetHeader("Subject", "Canine Club - Invoice for "+dog.Name)
m.SetBody(
"text/html",
"Hi "+ownerFirstName+",<br><br>Here is your invoice for "+dog.Name+".<br><br>Kind regards,<br>Canine Club",
"Hi "+ownerFirstName+",<br><br>Please find attached the invoice for "+dog.Name+"'s "+walkOrWalks+" this week.<p style='font-weight:lighter;'>Please use '<b>"+dog.Name+"</b>' as the reference when making payment. Also note that payment is due by "+nextMonday().Format("Monday, 2 January 2006")+
".</p><br>Any questions let me know,<br>Thank you!<br><br>"+fromFirstName+"<br>Canine Club",
)
m.Attach(invoiceFile)

Expand Down
1 change: 1 addition & 0 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func SetRoutes(app *fiber.App) {
"FromName": os.Getenv("FROM_NAME"),
"FromAddress": os.Getenv("FROM_ADDRESS"),
"FromCity": os.Getenv("FROM_CITY"),
"AccountNumber": os.Getenv("ACCOUNT_NUMBER"),
"Name": dog.Name,
"OwnerName": dog.OwnerName,
"Address": dog.Address,
Expand Down
18 changes: 18 additions & 0 deletions views/invoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,24 @@
<td></td>
<td>Total: ${{.Total}}</td>
</tr>

<tr class="information">
<td colspan="3">
<table>
<tr>
<td>
<b
>Please pay into the bank acoount of
{{.FromName}}:</b
>
<h2>{{.AccountNumber}}</h2>
</td>
<td></td>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion views/row-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
type="text"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
data-include-edit="{{.ID}}"
name="pricePerWalk"
name="price"
value="{{.Price}}"
/>
</td>
Expand Down

0 comments on commit 9c59bd6

Please sign in to comment.