Skip to content

Commit

Permalink
Merge frappe#79 Winter Sprint: Work
Browse files Browse the repository at this point in the history
  • Loading branch information
prssanna committed Feb 17, 2019
1 parent 83e7992 commit 1715116
Show file tree
Hide file tree
Showing 73 changed files with 3,220 additions and 1,604 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
.DS_Store
*.db
Thumbs.db
*test.db
*.log
.cache
/temp
Expand All @@ -11,4 +11,3 @@ Frappe Accounting*
build
!build/icons
!.gitkeep
*.db
1 change: 1 addition & 0 deletions electron/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function getSettings() {
async function saveSettings(settings) {
await writeFile(configFilePath, JSON.stringify(settings));
}
console.log(getSettings());

module.exports = {
getSettings,
Expand Down
5 changes: 5 additions & 0 deletions email/getConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const frappe = require('frappejs');
module.exports = async function getData() {
account = await frappe.getDoc('EmailAccount');
return account;
}
46 changes: 46 additions & 0 deletions email/sender.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const nodemailer = require('nodemailer');
const getConfig = require("./getConfig");
const validator = require('./validator');

module.exports = {
'sendMail': async function (mailDetails) {
if (!validator.validate(mailDetails.fromEmailAddress)) {
console.log("INVALID EMAIL");
return false;
}

let account = await getConfig();
if (mailDetails.fromEmailAddress == account.email) {
if (validator.validate(mailDetails.toEmailAddress)) {
mailDetails = {
from: mailDetails.fromEmailAddress,
to: mailDetails.toEmailAddress,
replyTo: mailDetails.toEmailAddress,
inReplyTo: mailDetails.replyId,
references: [mailDetails.replyId],
cc: mailDetails.ccEmailAddress,
bcc: mailDetails.bccEmailAddress,
subject: mailDetails.subject,
text: mailDetails.bodyText,
attachments: [{
filename: 'Invoice.pdf',
path: mailDetails.filePath,
contentType: 'application/pdf'
}],
};
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: account.email,
pass: account.password,
}
});
transporter.sendMail(mailDetails);
return true;
} else {
console.log("Sender Email Invalid");
return false;
}
}
}
};
11 changes: 11 additions & 0 deletions email/validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// + Check Confirm Password == Password

module.exports = {
validate: function (email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (reg.test(email) == false) {
return false;
}
return true;
}
}
68 changes: 51 additions & 17 deletions fixtures/countryInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"number_format": "#,###.##",
"timezones": [
"Asia/Kabul"
]
],
"fiscal_year_start": "12-20",
"fiscal_year_end": "12-21"
},
"Albania": {
"code": "al",
Expand Down Expand Up @@ -169,7 +171,9 @@
"Australia/Melbourne",
"Australia/Perth",
"Australia/Sydney"
]
],
"fiscal_year_start": "07-01",
"fiscal_year_end": "06-30"
},
"Austria": {
"code": "at",
Expand Down Expand Up @@ -223,7 +227,9 @@
"number_format": "#,###.##",
"timezones": [
"Asia/Dhaka"
]
],
"fiscal_year_start": "07-01",
"fiscal_year_end": "06-30"
},
"Barbados": {
"code": "bb",
Expand Down Expand Up @@ -488,7 +494,9 @@
"America/Whitehorse",
"America/Winnipeg",
"America/Yellowknife"
]
],
"fiscal_year_start": "04-01",
"fiscal_year_end": "03-31"
},
"Cape Verde": {
"code": "cv",
Expand Down Expand Up @@ -639,7 +647,9 @@
"number_format": "#.###,##",
"timezones": [
"America/Costa_Rica"
]
],
"fiscal_year_start": "10-01",
"fiscal_year_end": "09-30"
},
"Croatia": {
"code": "hr",
Expand Down Expand Up @@ -765,7 +775,9 @@
"number_format": "#,###.##",
"timezones": [
"Africa/Cairo"
]
],
"fiscal_year_start": "07-01",
"fiscal_year_end": "06-30"
},
"El Salvador": {
"code": "sv",
Expand Down Expand Up @@ -1113,7 +1125,9 @@
"number_format": "#,###.##",
"timezones": [
"Asia/Hong_Kong"
]
],
"fiscal_year_start": "04-01",
"fiscal_year_end": "03-31"
},
"Hungary": {
"code": "hu",
Expand Down Expand Up @@ -1150,7 +1164,9 @@
"number_format": "#,##,###.##",
"timezones": [
"Asia/Kolkata"
]
],
"fiscal_year_start": "04-01",
"fiscal_year_end": "03-31"
},
"Indonesia": {
"code": "id",
Expand All @@ -1175,7 +1191,9 @@
"number_format": "#,###.##",
"timezones": [
"Asia/Tehran"
]
],
"fiscal_year_start": "06-23",
"fiscal_year_end": "06-22"
},
"Iraq": {
"code": "iq",
Expand Down Expand Up @@ -1232,7 +1250,9 @@
"date_format": "dd/mm/yyyy",
"timezones": [
"Europe/Rome"
]
],
"fiscal_year_start": "07-01",
"fiscal_year_end": "06-30"
},
"Ivory Coast": {
"code": "ci",
Expand Down Expand Up @@ -1714,7 +1734,9 @@
"number_format": "#,###.##",
"timezones": [
"Asia/Rangoon"
]
],
"fiscal_year_start": "04-01",
"fiscal_year_end": "03-31"
},
"Namibia": {
"code": "na",
Expand Down Expand Up @@ -1782,7 +1804,9 @@
"timezones": [
"Pacific/Auckland",
"Pacific/Chatham"
]
],
"fiscal_year_start": "04-01",
"fiscal_year_end": "03-31"
},
"Nicaragua": {
"code": "ni",
Expand Down Expand Up @@ -1878,7 +1902,9 @@
"number_format": "#,###.##",
"timezones": [
"Asia/Karachi"
]
],
"fiscal_year_start": "07-01",
"fiscal_year_end": "06-30"
},
"Palau": {
"code": "pw",
Expand Down Expand Up @@ -2191,7 +2217,9 @@
"number_format": "#,###.##",
"timezones": [
"Asia/Singapore"
]
],
"fiscal_year_start": "04-01",
"fiscal_year_end": "03-31"
},
"Sint Maarten (Dutch part)": {
"code": "sx",
Expand Down Expand Up @@ -2254,7 +2282,9 @@
"number_format": "# ###.##",
"timezones": [
"Africa/Johannesburg"
]
],
"fiscal_year_start": "03-01",
"fiscal_year_end": "02-28"
},
"South Georgia and the South Sandwich Islands": {
"code": "gs",
Expand Down Expand Up @@ -2397,7 +2427,9 @@
"number_format": "#,###.##",
"timezones": [
"Asia/Bangkok"
]
],
"fiscal_year_start": "10-01",
"fiscal_year_end": "09-30"
},
"Timor-Leste": {
"code": "tl",
Expand Down Expand Up @@ -2547,7 +2579,9 @@
"number_format": "#,###.##",
"timezones": [
"Europe/London"
]
],
"fiscal_year_start": "04-01",
"fiscal_year_end": "03-31"
},
"United States": {
"code": "us",
Expand Down
Loading

0 comments on commit 1715116

Please sign in to comment.