-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: new payment invoice module * fix edit btn on read page * fix amount showing balance * cleaning consoles and unused var * changing the amount input * constraint added on tax feild * create offer frontend feature * create lead frontend feature * revert frontend .env * revert frontend .env * revert offer model, create offer document * feature:#548 craeted new email editor page :backend init * feature:#548 craeted new email editor page :frontend init * feature:#548 created new email editor page :frontend init * feature:#548 created new email editor page :changes made * feature:#548 created new email editor page :changes made * feat: Create new component multi step select async (#469) * feat: Create new component multi step select async * feat: refactor multi-step select component to get its initial values dynamic * feat: made the multi step component more flexible --------- Co-authored-by: Maruf <thesharifi.maruf@gmail.com> * Feat: Create New Redux Settings Store (#556) * 💄 Improve UI of Settings Menu * ⚡️ improve settings performance * 🔧 Setup Redux Settings --------- Co-authored-by: Salah Eddine Lalami <50052356+idurar@users.noreply.github.com> * move backend to separate folder (#557) Co-authored-by: Salah Eddine Lalami <50052356+idurar@users.noreply.github.com> --------- Co-authored-by: polymahh <otman.elkantaoui@gmail.com> Co-authored-by: Ovilash Moitra <96794196+OvilashMoitra@users.noreply.github.com> Co-authored-by: Erando Putra <ando.putra@live.com> Co-authored-by: Erando Putra <38315094+Ando22@users.noreply.github.com> Co-authored-by: ritik kumar <sinharitik589> Co-authored-by: Maruf Sharifi <116145571+themarufsharifi@users.noreply.github.com> Co-authored-by: Maruf <thesharifi.maruf@gmail.com> Co-authored-by: Salah Eddine Lalami <50052356+idurar@users.noreply.github.com>
- Loading branch information
1 parent
4bd9a3e
commit 0cdf79d
Showing
461 changed files
with
3,395 additions
and
750 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
backend/controllers/coreControllers/emailController/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const createCRUDController = require('@/controllers/middlewaresControllers/createCRUDController'); | ||
const crudController = createCRUDController('Email'); | ||
|
||
const emailMethods = { | ||
create:crudController.create, | ||
read: crudController.read, | ||
update: crudController.update, | ||
list: crudController.list, | ||
listAll: crudController.listAll, | ||
filter: crudController.filter, | ||
search: crudController.search, | ||
}; | ||
|
||
module.exports = emailMethods; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,269 @@ | ||
const mongoose = require('mongoose'); | ||
const Model = mongoose.model('Offer'); | ||
const moment = require('moment'); | ||
const custom = require('@/controllers/middlewaresControllers/pdfController'); | ||
|
||
const createCRUDController = require('@/controllers/middlewaresControllers/createCRUDController'); | ||
const methods = createCRUDController('Offer'); | ||
|
||
delete methods['create']; | ||
delete methods['update']; | ||
|
||
methods.create = async (req, res) => { | ||
try { | ||
const { items = [], taxRate = 0, discount = 0 } = req.body; | ||
|
||
// default | ||
let subOfferTotal = 0; | ||
let subTotal = 0; | ||
let taxTotal = 0; | ||
let offerTotal = 0; | ||
let total = 0; | ||
|
||
//Calculate the items array with subTotal, total, taxTotal | ||
items.map((item) => { | ||
let itemTotal = item['quantity'] * item['price']; | ||
let itemOfferTotal = item['quantity'] * item['offerPrice']; | ||
//sub total | ||
subTotal += itemTotal; | ||
subOfferTotal += itemOfferTotal; | ||
//price total | ||
item['total'] = itemTotal; | ||
item['offerTotal'] = itemOfferTotal; | ||
}); | ||
|
||
taxTotal = subTotal * taxRate; | ||
total = subTotal + taxTotal; | ||
offerTotal = subOfferTotal + taxTotal; | ||
|
||
let body = req.body; | ||
|
||
body['subTotal'] = subTotal; | ||
body['subOfferTotal'] = subOfferTotal; | ||
body['taxTotal'] = taxTotal; | ||
body['total'] = total; | ||
body['offerTotal'] = offerTotal; | ||
body['items'] = items; | ||
|
||
// Creating a new document in the collection | ||
const result = await new Model(body).save(); | ||
const fileId = 'offer-' + result._id + '.pdf'; | ||
const updateResult = await Model.findOneAndUpdate( | ||
{ _id: result._id }, | ||
{ pdfPath: fileId }, | ||
{ | ||
new: true, | ||
} | ||
).exec(); | ||
// Returning successfull response | ||
|
||
custom.generatePdf('Offer', { filename: 'offer', format: 'A4' }, result); | ||
|
||
// Returning successfull response | ||
return res.status(200).json({ | ||
success: true, | ||
result: updateResult, | ||
message: 'Offer created successfully', | ||
}); | ||
} catch (err) { | ||
// If err is thrown by Mongoose due to required validations | ||
if (err.name == 'ValidationError') { | ||
return res.status(400).json({ | ||
success: false, | ||
result: null, | ||
message: 'Required fields are not supplied', | ||
}); | ||
} else { | ||
// Server Error | ||
return res.status(500).json({ | ||
success: false, | ||
result: null, | ||
message: 'Oops there is an Error', | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
methods.update = async (req, res) => { | ||
try { | ||
const { items = [], taxRate = 0, discount = 0 } = req.body; | ||
|
||
// default | ||
let subOfferTotal = 0; | ||
let subTotal = 0; | ||
let taxTotal = 0; | ||
let offerTotal = 0; | ||
let total = 0; | ||
// let credit = 0; | ||
|
||
//Calculate the items array with subTotal, total, taxTotal | ||
items.map((item) => { | ||
let itemTotal = item['quantity'] * item['price']; | ||
let itemOfferTotal = item['quantity'] * item['offerPrice']; | ||
//sub total | ||
subTotal += itemTotal; | ||
subOfferTotal += itemOfferTotal; | ||
//price total | ||
item['total'] = itemTotal; | ||
item['offerTotal'] = itemOfferTotal; | ||
}); | ||
taxTotal = subTotal * taxRate; | ||
total = subTotal + taxTotal; | ||
offerTotal = subOfferTotal + taxTotal; | ||
|
||
let body = req.body; | ||
|
||
body['subTotal'] = subTotal; | ||
body['subOfferTotal'] = subOfferTotal; | ||
body['taxTotal'] = taxTotal; | ||
body['total'] = total; | ||
body['offerTotal'] = offerTotal; | ||
body['items'] = items; | ||
body['pdfPath'] = 'offer-' + req.params.id + '.pdf'; | ||
// Find document by id and updates with the required fields | ||
|
||
const result = await Model.findOneAndUpdate({ _id: req.params.id, removed: false }, body, { | ||
new: true, // return the new result instead of the old one | ||
}).exec(); | ||
|
||
// Returning successfull response | ||
|
||
custom.generatePdf('Offer', { filename: 'offer', format: 'A4' }, result); | ||
return res.status(200).json({ | ||
success: true, | ||
result, | ||
message: 'we update this offer by this id: ' + req.params.id, | ||
}); | ||
} catch (err) { | ||
// If err is thrown by Mongoose due to required validations | ||
if (err.name == 'ValidationError') { | ||
return res.status(400).json({ | ||
success: false, | ||
result: null, | ||
message: 'Required fields are not supplied', | ||
}); | ||
} else { | ||
// Server Error | ||
return res.status(500).json({ | ||
success: false, | ||
result: null, | ||
message: 'Oops there is an Error', | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
methods.summary = async (req, res) => { | ||
try { | ||
let defaultType = 'month'; | ||
|
||
const { type } = req.query; | ||
|
||
if (type) { | ||
if (['week', 'month', 'year'].includes(type)) { | ||
defaultType = type; | ||
} else { | ||
return res.status(400).json({ | ||
success: false, | ||
result: null, | ||
message: 'Invalid type', | ||
}); | ||
} | ||
} | ||
|
||
const currentDate = moment(); | ||
let startDate = currentDate.clone().startOf(defaultType); | ||
let endDate = currentDate.clone().endOf(defaultType); | ||
|
||
const statuses = ['draft', 'pending', 'sent', 'expired', 'declined', 'accepted']; | ||
|
||
const result = await Model.aggregate([ | ||
{ | ||
$match: { | ||
removed: false, | ||
date: { | ||
$gte: startDate.toDate(), | ||
$lte: endDate.toDate(), | ||
}, | ||
}, | ||
}, | ||
{ | ||
$group: { | ||
_id: '$status', | ||
count: { | ||
$sum: 1, | ||
}, | ||
total_amount: { | ||
$sum: '$total', | ||
}, | ||
}, | ||
}, | ||
{ | ||
$group: { | ||
_id: null, | ||
total_count: { | ||
$sum: '$count', | ||
}, | ||
results: { | ||
$push: '$$ROOT', | ||
}, | ||
}, | ||
}, | ||
{ | ||
$unwind: '$results', | ||
}, | ||
{ | ||
$project: { | ||
_id: 0, | ||
status: '$results._id', | ||
count: '$results.count', | ||
percentage: { | ||
$round: [{ $multiply: [{ $divide: ['$results.count', '$total_count'] }, 100] }, 0], | ||
}, | ||
total_amount: '$results.total_amount', | ||
}, | ||
}, | ||
{ | ||
$sort: { | ||
status: 1, | ||
}, | ||
}, | ||
]); | ||
|
||
statuses.forEach((status) => { | ||
const found = result.find((item) => item.status === status); | ||
if (!found) { | ||
result.push({ | ||
status, | ||
count: 0, | ||
percentage: 0, | ||
total_amount: 0, | ||
}); | ||
} | ||
}); | ||
|
||
const total = result.reduce((acc, item) => acc + item.total_amount, 0).toFixed(2); | ||
|
||
const finalResult = { | ||
total, | ||
type: defaultType, | ||
performance: result, | ||
}; | ||
|
||
return res.status(200).json({ | ||
success: true, | ||
result: finalResult, | ||
message: `Successfully found all Offers for the last ${defaultType}`, | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
return res.status(500).json({ | ||
success: false, | ||
result: null, | ||
message: 'Oops there is an Error', | ||
error: error, | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = methods; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const mongoose = require('mongoose'); | ||
mongoose.Promise = global.Promise; | ||
|
||
const emailSchema = new mongoose.Schema({ | ||
emailKey: { | ||
type: String, | ||
unique: true, | ||
lowercase: true, | ||
required: true, | ||
}, | ||
emailName: { | ||
type: String, | ||
unique:true, | ||
required:true, | ||
}, | ||
emailVariables:{ | ||
type:Array | ||
}, | ||
emailBody: { | ||
type: String, | ||
required: true, | ||
}, | ||
emailSubject: { | ||
type: String, | ||
required: true, | ||
}, | ||
language:{ | ||
type:String, | ||
default:"en" | ||
}, | ||
removed: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
enabled: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
created: { | ||
type: Date, | ||
default: Date.now, | ||
}, | ||
updated: { | ||
type: Date, | ||
default: Date.now, | ||
}, | ||
}); | ||
|
||
module.exports = mongoose.model('Email', emailSchema); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.