forked from pallasite99/rentavo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimplementation_node_basic.js
More file actions
32 lines (28 loc) · 1.15 KB
/
implementation_node_basic.js
File metadata and controls
32 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# base nodejs implementation
const fs = require('fs');
// Mock loading data from a file (JSON format for simplicity)
function loadData(filePath) {
if (!fs.existsSync(filePath)) {
throw new Error("File not found");
}
const data = fs.readFileSync(filePath, 'utf8');
return JSON.parse(data);
}
// Mock sending an email
function sendEmail(recipient, subject, body) {
console.log(`Email sent to ${recipient}`);
console.log(`Subject: ${subject}`);
console.log(`Body: ${body}`);
return true;
}
// Function to send rental reminders
function sendRentalReminders(filePath) {
const tenants = loadData(filePath);
tenants.forEach((tenant) => {
const { Name, Email, "Due Amount": dueAmount, "Due Date": dueDate } = tenant;
const subject = `Rental Payment Reminder for ${Name}`;
const body = `Dear ${Name},\n\nThis is a friendly reminder that your rental payment of $${dueAmount} is due on ${dueDate}. Please ensure the payment is completed by then.\n\nBest regards,\nYour Property Management Team`;
sendEmail(Email, subject, body);
});
}
module.exports = { loadData, sendEmail, sendRentalReminders };