Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-049
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-049
2021-049
Commits
53e4abe0
Commit
53e4abe0
authored
Jul 03, 2021
by
Gihan76
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Financial Details adding routes form with DB done!
parent
d80cf719
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
307 additions
and
0 deletions
+307
-0
BackEnd/WebBackEnd/models/finance.model.js
BackEnd/WebBackEnd/models/finance.model.js
+28
-0
BackEnd/WebBackEnd/routes/finance.route.js
BackEnd/WebBackEnd/routes/finance.route.js
+47
-0
WebFrontEnd/smartcoach-frontend/src/Components/Admin/add_financial_details.js
...ch-frontend/src/Components/Admin/add_financial_details.js
+232
-0
No files found.
BackEnd/WebBackEnd/models/finance.model.js
0 → 100644
View file @
53e4abe0
const
mongoose
=
require
(
'
mongoose
'
);
const
Schema
=
mongoose
.
Schema
;
let
FinanceSchema
=
new
Schema
({
// name : {type:String,required:true},
account_month
:
{
type
:
String
,
required
:
true
},
direct_income
:
{
type
:
String
,
required
:
true
},
indirect_income
:
{
type
:
String
,
required
:
true
},
total_income
:
{
type
:
String
,
required
:
true
},
direct_expenses
:
{
type
:
String
,
required
:
true
},
indirect_expenses
:
{
type
:
String
,
required
:
true
},
total_expenses
:
{
type
:
String
,
required
:
true
},
gross_revenue
:
{
type
:
String
,
required
:
true
}
},{
timestamps
:
true
});
// function getPrice(num){
// return (num/100).toFixed(2);
// }
//
// function setPrice(num){
// return num*100;
// }
const
Finance
=
mongoose
.
model
(
'
finance
'
,
FinanceSchema
);
module
.
exports
=
Finance
;
\ No newline at end of file
BackEnd/WebBackEnd/routes/finance.route.js
0 → 100644
View file @
53e4abe0
const
router
=
require
(
'
express
'
).
Router
();
//import models
const
Finance
=
require
(
'
../models/finance.model
'
);
let
Tutor
=
require
(
'
../models/tutor.user.model
'
);
router
.
route
(
'
/tutors
'
).
get
((
req
,
res
)
=>
{
Tutor
.
find
({},
{
tutor_name
:
1
,
_id
:
0
})
.
then
(
tutors
=>
res
.
json
(
tutors
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
});
router
.
route
(
'
/
'
).
get
((
req
,
res
)
=>
{
Finance
.
find
()
.
then
(
financedetails
=>
res
.
json
(
financedetails
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error :
'
+
err
));
});
router
.
route
(
'
/store
'
).
post
((
req
,
res
)
=>
{
// const tutname = req.body.tutname;
const
account_month
=
req
.
body
.
account_month
;
const
direct_income
=
req
.
body
.
direct_income
;
const
indirect_income
=
req
.
body
.
indirect_income
;
const
total_income
=
req
.
body
.
total_income
;
const
direct_expenses
=
req
.
body
.
direct_expenses
;
const
indirect_expenses
=
req
.
body
.
indirect_expenses
;
const
total_expenses
=
req
.
body
.
total_expenses
;
const
gross_revenue
=
req
.
body
.
gross_revenue
;
const
newFinancialDetails
=
new
Finance
({
// tutname,
account_month
,
direct_income
,
indirect_income
,
total_income
,
direct_expenses
,
indirect_expenses
,
total_expenses
,
gross_revenue
});
newFinancialDetails
.
save
()
.
then
(()
=>
res
.
json
(
'
Financial Details Added!
'
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error :
'
+
err
));
});
module
.
exports
=
router
;
\ No newline at end of file
WebFrontEnd/smartcoach-frontend/src/Components/Admin/add_financial_details.js
0 → 100644
View file @
53e4abe0
import
React
,
{
Component
}
from
"
react
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
axios
from
"
axios
"
;
// const TutorsNames = props => (
// <option>{props.tutors}</option>
// );
export
default
class
AddFinancialDetails
extends
Component
{
// nameList(){
// return this.state.tutors.map(currentcateogory => {
// return <TutorsNames name={currentcateogory} key={currentcateogory._id} />;
// })
// }
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
account_month
:
''
,
direct_income
:
''
,
indirect_income
:
''
,
total_income
:
''
,
direct_expenses
:
''
,
indirect_expenses
:
''
,
total_expenses
:
''
,
gross_revenue
:
''
};
}
onChangeHandler
=
e
=>
{
this
.
setState
({
[
e
.
target
.
name
]:
e
.
target
.
value
})
}
onSubmitHandler
=
e
=>
{
e
.
preventDefault
();
const
financialDetails
=
{
account_month
:
this
.
state
.
account_month
,
direct_income
:
this
.
state
.
direct_income
,
indirect_income
:
this
.
state
.
indirect_income
,
total_income
:
this
.
state
.
total_income
,
direct_expenses
:
this
.
state
.
direct_expenses
,
indirect_expenses
:
this
.
state
.
indirect_expenses
,
total_expenses
:
this
.
state
.
total_expenses
,
gross_revenue
:
this
.
state
.
gross_revenue
}
console
.
log
(
`Form submitted:`
);
console
.
log
(
`account_month:
${
this
.
state
.
account_month
}
`
);
console
.
log
(
`direct_income:
${
this
.
state
.
direct_income
}
`
);
console
.
log
(
`indirect_income:
${
this
.
state
.
indirect_income
}
`
);
console
.
log
(
`total_income:
${
this
.
state
.
total_income
}
`
);
console
.
log
(
`direct_expenses:
${
this
.
state
.
direct_expenses
}
`
);
console
.
log
(
`indirect_expenses:
${
this
.
state
.
indirect_expenses
}
`
);
console
.
log
(
`total_expenses:
${
this
.
state
.
total_expenses
}
`
);
console
.
log
(
`gross_revenue:
${
this
.
state
.
gross_revenue
}
`
);
// console.log(financialDetails);
// axios({
// method: 'post',
// url: 'http://localhost:5000/admin/finance/store',
// headers: {},
// data: financialDetails,
// }).then(res => console.log(res.data));
axios
.
post
(
'
http://localhost:5000/admin/finance/store
'
,
financialDetails
)
.
then
(
res
=>
console
.
log
(
res
.
data
));
// .catch(//swal("Good job!", "You clicked the button!", "warning"
// );
// window.location = '/admin/mstaff';
}
// componentDidMount() {
// axios.get('http://localhost:5000/admin/finance/tutors')
// .then(response => {
// this.setState({ tutors : response.data})
// console.log(this.state);
// })
// .catch(error =>{
// console.log(error);
// })
// }
calctot
(){
let
dinc
=
parseInt
(
document
.
getElementById
(
'
dirIncome
'
).
value
,
10
);
let
indinc
=
parseInt
(
document
.
getElementById
(
'
indIncome
'
).
value
,
10
);
document
.
getElementById
(
'
sincome
'
).
innerHTML
=
dinc
+
indinc
;
let
totincusd
=
parseFloat
((
dinc
+
indinc
)
/
199.56
).
toFixed
(
2
);
document
.
getElementById
(
'
totIncomeUSD
'
).
value
=
totincusd
;
let
dexp
=
parseInt
(
document
.
getElementById
(
'
dirExpenses
'
).
value
,
10
);
let
indexp
=
parseInt
(
document
.
getElementById
(
'
indExpenses
'
).
value
,
10
);
document
.
getElementById
(
'
sexpenses
'
).
innerHTML
=
dexp
+
indexp
;
let
totexpusd
=
parseFloat
((
dexp
+
indexp
)
/
199.56
).
toFixed
(
2
);
document
.
getElementById
(
'
totExpensesUSD
'
).
value
=
totexpusd
;
let
totincome
=
dinc
+
indinc
;
let
totexpense
=
dexp
+
indexp
;
let
totrev
=
totincome
-
totexpense
;
document
.
getElementById
(
'
srevenue
'
).
innerHTML
=
totrev
;
let
totrevusd
=
parseFloat
((
totincome
-
totexpense
)
/
199.56
).
toFixed
(
2
);
document
.
getElementById
(
'
totRevenueUSD
'
).
value
=
totrevusd
;
}
placeHolders
()
{
document
.
getElementById
(
"
dirIncome
"
).
placeholder
=
"
Direct Income
"
;
document
.
getElementById
(
"
indIncome
"
).
placeholder
=
"
Indirect Income
"
;
document
.
getElementById
(
"
dirExpenses
"
).
placeholder
=
"
Direct Expenses
"
;
document
.
getElementById
(
"
indExpenses
"
).
placeholder
=
"
Indirect Expenses
"
;
}
render
()
{
return
(
<
div
>
<
div
className
=
"
app-page-title
"
>
<
div
className
=
"
page-title-wrapper
"
>
<
div
className
=
"
page-title-heading
"
>
<
div
className
=
"
page-title-icon
"
>
<
i
className
=
"
pe-7s-display1 fa fa-line-chart
"
><
/i
>
<
/div
>
<
div
>
Add
Financial
Details
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
main-card mb-3 card
"
>
<
div
className
=
"
card-body
"
>
<
form
onSubmit
=
{
this
.
onSubmitHandler
}
>
{
/*<div className="position-relative row form-group">*/
}
{
/* <label htmlFor="tutorName" className="col-sm-2 col-form-label">Tutor</label>*/
}
{
/* <div className="col-sm-3">*/
}
{
/* /!*<input name="email" id="exampleEmail" placeholder="with a placeholder" type="email" className="form-control" />*!/*/
}
{
/* <select name="name" id="tutorName" className="form-control">*/
}
{
/* {this.nameList()}*/
}
{
/* </select>*/
}
{
/* </div>*/
}
{
/*</div>*/
}
<
div
className
=
"
position-relative row form-group
"
>
<
label
htmlFor
=
"
accMonth
"
className
=
"
col-sm-2 col-form-label
"
>
Account
Month
<
/label
>
<
div
className
=
"
col-sm-3
"
>
<
input
type
=
"
month
"
name
=
"
account_month
"
id
=
"
accMonth
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeHandler
}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
position-relative row form-group
"
>
<
label
htmlFor
=
"
dirIncome
"
className
=
"
col-sm-2 col-form-label
"
>
Direct
Income
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
Rs
.)
<
/span><span style={{color:"red"}}>*</
span
><
/label
>
<
div
className
=
"
col-sm-4
"
>
<
input
onClick
=
{
this
.
placeHolders
}
type
=
"
number
"
min
=
"
0.00
"
step
=
"
1
"
name
=
"
direct_income
"
id
=
"
dirIncome
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeHandler
}
/
>
<
/div
>
<
label
htmlFor
=
"
indIncome
"
className
=
"
col-sm-2 col-form-label
"
>
Indirect
Income
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
Rs
.)
<
/span><span style={{color:"red"}}>*</
span
><
/label
>
<
div
className
=
"
col-sm-4
"
>
<
input
onBlur
=
{
this
.
calctot
}
onClick
=
{
this
.
placeHolders
}
type
=
"
number
"
min
=
"
0.00
"
step
=
"
1
"
name
=
"
indirect_income
"
id
=
"
indIncome
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeHandler
}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
position-relative row form-group
"
>
<
label
htmlFor
=
"
totIncome
"
className
=
"
col-sm-2 col-form-label
"
>
Total
Income
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
Rs
.)
<
/span><span style={{color:"red"}}>*</
span
><
/label
>
<
div
className
=
"
col-sm-4
"
>
<
input
type
=
"
number
"
min
=
"
0.00
"
name
=
"
total_income
"
id
=
"
totIncome
"
className
=
"
form-control
"
style
=
{{
backgroundColor
:
"
#e7ebcc
"
,
color
:
"
black
"
}}
onChange
=
{
this
.
onChangeHandler
}
/
>
<
small
className
=
"
form-text text-muted
"
>
Gross
Income
:
Rs
.
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
id
=
"
sincome
"
>
0.00
<
/span>👆</
small
>
<
/div
>
<
label
htmlFor
=
"
totIncomeUSD
"
className
=
"
col-sm-2 col-form-label
"
>
Total
Income
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
$
)
<
/span></
label
>
<
div
className
=
"
col-sm-4
"
>
<
input
readOnly
=
"
readonly
"
type
=
"
number
"
min
=
"
0.00
"
name
=
"
totincomeusd
"
id
=
"
totIncomeUSD
"
className
=
"
form-control
"
style
=
{{
backgroundColor
:
"
blue
"
,
color
:
"
white
"
}}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
position-relative row form-group
"
>
<
label
htmlFor
=
"
dirExpenses
"
className
=
"
col-sm-2 col-form-label
"
>
Direct
Expenses
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
Rs
.)
<
/span><span style={{color:"red"}}>*</
span
><
/label
>
<
div
className
=
"
col-sm-4
"
>
<
input
onClick
=
{
this
.
placeHolders
}
type
=
"
number
"
min
=
"
0.00
"
step
=
"
1
"
id
=
"
dirExpenses
"
name
=
"
direct_expenses
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeHandler
}
/
>
<
/div
>
<
label
htmlFor
=
"
indExpenses
"
className
=
"
col-sm-2 col-form-label
"
>
Indirect
Expenses
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
Rs
.)
<
/span><span style={{color:"red"}}>*</
span
><
/label
>
<
div
className
=
"
col-sm-4
"
>
<
input
onBlur
=
{
this
.
calctot
}
onClick
=
{
this
.
placeHolders
}
type
=
"
number
"
min
=
"
0.00
"
step
=
"
1
"
id
=
"
indExpenses
"
name
=
"
indirect_expenses
"
className
=
"
form-control
"
onChange
=
{
this
.
onChangeHandler
}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
position-relative row form-group
"
>
<
label
htmlFor
=
"
totExpenses
"
className
=
"
col-sm-2 col-form-label
"
>
Total
Expenses
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
Rs
.)
<
/span><span style={{color:"red"}}>*</
span
><
/label
>
<
div
className
=
"
col-sm-4
"
>
<
input
type
=
"
number
"
min
=
"
0.00
"
name
=
"
total_expenses
"
id
=
"
totExpenses
"
className
=
"
form-control
"
style
=
{{
backgroundColor
:
"
#e7ebcc
"
,
color
:
"
black
"
}}
onChange
=
{
this
.
onChangeHandler
}
/
>
<
small
className
=
"
form-text text-muted
"
>
Gross
Expenses
:
Rs
.
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
id
=
"
sexpenses
"
>
0.00
<
/span>👆</
small
>
<
/div
>
<
label
htmlFor
=
"
totExpensesUSD
"
className
=
"
col-sm-2 col-form-label
"
>
Total
Expenses
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
$
)
<
/span></
label
>
<
div
className
=
"
col-sm-4
"
>
<
input
readOnly
=
"
readonly
"
type
=
"
number
"
min
=
"
0.00
"
name
=
"
totexpensesusd
"
id
=
"
totExpensesUSD
"
className
=
"
form-control
"
style
=
{{
backgroundColor
:
"
blue
"
,
color
:
"
white
"
}}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
position-relative row form-group
"
>
<
label
htmlFor
=
"
totRevenue
"
className
=
"
col-sm-2 col-form-label
"
>
Gross
Revenue
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
Rs
.)
<
/span></
label
>
<
div
className
=
"
col-sm-4
"
>
<
input
type
=
"
number
"
min
=
"
0.00
"
name
=
"
gross_revenue
"
id
=
"
totRevenue
"
className
=
"
form-control
"
style
=
{{
backgroundColor
:
"
#e7ebcc
"
,
color
:
"
black
"
}}
onChange
=
{
this
.
onChangeHandler
}
/
>
<
small
className
=
"
form-text text-muted
"
>
Gross
Revenue
:
Rs
.
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
id
=
"
srevenue
"
>
0.00
<
/span>👆</
small
>
<
/div
>
<
label
htmlFor
=
"
totRevenueUSD
"
className
=
"
col-sm-2 col-form-label
"
>
Gross
Revenue
<
span
style
=
{{
fontWeight
:
"
bold
"
}}
>
(
$
)
<
/span></
label
>
<
div
className
=
"
col-sm-4
"
>
<
input
readOnly
=
"
readonly
"
type
=
"
number
"
min
=
"
0.00
"
name
=
"
totrevenueusd
"
id
=
"
totRevenueUSD
"
className
=
"
form-control
"
style
=
{{
backgroundColor
:
"
blue
"
,
color
:
"
white
"
}}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
position-relative row form-group
"
>
<
div
className
=
"
col-sm-12
"
>
<
button
className
=
"
btn btn-primary
"
style
=
{{
width
:
"
150px
"
}}
type
=
"
submit
"
>
Save
Details
<
/button
>
<
/div
>
<
/div
>
<
/form
>
<
/div
>
<
/div
>
<
/div
>
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment