Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Tia-dev
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dida Adams Arizona
Tia-dev
Commits
74c9bbee
Commit
74c9bbee
authored
Dec 22, 2020
by
Riri Novita
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'riri' into 'master'
pusing See merge request
!844
parents
199e4c90
66de34a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
122 deletions
+131
-122
ProfitLossMR.js
src/container/MonthlyReport/ProfitLossMR.js
+131
-122
No files found.
src/container/MonthlyReport/ProfitLossMR.js
View file @
74c9bbee
...
...
@@ -61,20 +61,20 @@ const styleNotesEmpty = {
zIndex
:
99
,
left
:
0
}
const
StyledButton
=
withStyles
({
root
:
{
background
:
'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)'
,
borderRadius
:
3
,
border
:
0
,
color
:
'white'
,
height
:
48
,
padding
:
'0 30px'
,
boxShadow
:
'0 3px 5px 2px rgba(255, 105, 135, .3)'
,
},
label
:
{
textTransform
:
'capitalize'
,
},
})(
Input
);
//
const StyledButton = withStyles({
//
root: {
//
background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
//
borderRadius: 3,
//
border: 0,
//
color: 'white',
//
height: 48,
//
padding: '0 30px',
//
boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
//
},
//
label: {
//
textTransform: 'capitalize',
//
},
//
})(Input);
export
default
class
ProfitLossMR
extends
Component
{
constructor
(
props
)
{
...
...
@@ -88,7 +88,11 @@ export default class ProfitLossMR extends Component {
updateBy
:
'-'
,
notesUpdate
:
'-'
,
bebas
:
false
,
judulColumn
:
null
judulColumn
:
null
,
handleTekTekTek
:
0
,
saveDraft
:
true
,
buttonError
:
true
}
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
}
...
...
@@ -174,17 +178,81 @@ export default class ProfitLossMR extends Component {
"periode"
:
this
.
props
.
periode
,
"company_id"
:
this
.
props
.
company
.
company_id
,
"monthly_report_id"
:
this
.
props
.
monthlyReportId
,
"months"
:
this
.
props
.
month
.
month_id
"months"
:
this
.
props
.
month
.
month_id
,
"get_for"
:
"edit"
}
console
.
log
(
payload
);
api
.
create
().
getHierarkiMontlyReportPL
(
payload
).
then
(
response
=>
{
console
.
log
(
response
);
let
dataTable
=
[]
let
err
=
false
if
(
response
.
data
)
{
let
res
=
response
.
data
.
data
const
handlePushChild
=
(
item
)
=>
{
let
indexIDzz
=
dataTable
.
findIndex
((
val
)
=>
val
[
1
]
===
item
.
id
)
if
(
indexIDzz
===
-
1
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
res
=
response
.
data
.
data
const
handlePushChild
=
(
item
)
=>
{
let
indexIDzz
=
dataTable
.
findIndex
((
val
)
=>
val
[
1
]
===
item
.
id
)
if
(
item
.
type_report_id
===
3
)
{
if
(
item
.
profit_loss
.
mtd_vs_previous_month
==
""
&&
Number
(
item
.
profit_loss
.
percent_act_vs_previous_month
)
<
this
.
state
.
minValue
||
Number
(
item
.
profit_loss
.
percent_act_vs_previous_month
)
>
this
.
state
.
maxValue
)
{
err
=
true
}
if
(
item
.
profit_loss
.
mtd_vs_mb
==
""
&&
Number
(
item
.
profit_loss
.
percent_act_vs_mb
)
<
this
.
state
.
minValue
||
Number
(
item
.
profit_loss
.
percent_act_vs_mb
)
>
this
.
state
.
maxValue
)
{
err
=
true
}
if
(
item
.
profit_loss
.
mtd_vs_rb
==
""
&&
Number
(
item
.
profit_loss
.
percent_act_vs_rb
)
<
this
.
state
.
minValue
||
Number
(
item
.
profit_loss
.
percent_act_vs_rb
)
>
this
.
state
.
maxValue
)
{
err
=
true
}
}
if
(
indexIDzz
===
-
1
)
{
dataTable
.
push
([
item
.
type_report_id
,
item
.
id
,
item
.
parent
,
item
.
formula
,
item
.
level
,
item
.
description
,
item
.
profit_loss
.
notes
===
""
?
null
:
item
.
profit_loss
.
notes
,
item
.
profit_loss
.
rolling_outlook
===
null
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
===
""
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
===
"0"
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
,
item
.
profit_loss
.
master_budget
===
null
?
"0.0"
:
item
.
profit_loss
.
master_budget
===
""
?
"0.0"
:
item
.
profit_loss
.
master_budget
,
item
.
profit_loss
.
rolling_budget
===
null
?
"0.0"
:
item
.
profit_loss
.
rolling_budget
===
""
?
"0.0"
:
item
.
profit_loss
.
rolling_budget
,
item
.
profit_loss
.
actual
===
null
?
"0.0"
:
item
.
profit_loss
.
actual
===
""
?
"0.0"
:
item
.
profit_loss
.
actual
,
0
,
item
.
profit_loss
.
actual_previous_month
===
null
?
"0.0"
:
item
.
profit_loss
.
actual_previous_month
===
""
?
"0.0"
:
item
.
profit_loss
.
actual_previous_month
,
item
.
profit_loss
.
amount_act_vs_previous_month
===
null
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_previous_month
===
""
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_previous_month
,
item
.
profit_loss
.
percent_act_vs_previous_month
===
null
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_previous_month
===
""
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_previous_month
,
item
.
profit_loss
.
amount_act_vs_mb
===
null
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_mb
===
""
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_mb
,
item
.
profit_loss
.
percent_act_vs_mb
===
null
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_mb
===
""
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_mb
,
item
.
profit_loss
.
amount_act_vs_rb
===
null
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_rb
===
""
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_rb
,
item
.
profit_loss
.
percent_act_vs_rb
===
null
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_rb
===
""
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_rb
,
item
.
profit_loss
.
mtd_vs_previous_month
===
null
?
""
:
item
.
profit_loss
.
mtd_vs_previous_month
,
item
.
profit_loss
.
mtd_vs_mb
===
null
?
""
:
item
.
profit_loss
.
mtd_vs_mb
,
item
.
profit_loss
.
mtd_vs_rb
===
null
?
""
:
item
.
profit_loss
.
mtd_vs_rb
,
item
.
order
,
item
.
profit_loss
.
ytd_actual
===
null
?
"0.0"
:
item
.
profit_loss
.
ytd_actual
===
""
?
"0.0"
:
item
.
profit_loss
.
ytd_actual
,
])
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
res
.
map
((
item
,
index
)
=>
{
if
(
item
.
type_report_id
===
3
)
{
if
(
item
.
profit_loss
.
mtd_vs_previous_month
==
""
&&
Number
(
item
.
profit_loss
.
percent_act_vs_previous_month
)
<
this
.
state
.
minValue
||
Number
(
item
.
profit_loss
.
percent_act_vs_previous_month
)
>
this
.
state
.
maxValue
)
{
err
=
true
}
if
(
item
.
profit_loss
.
mtd_vs_mb
==
""
&&
Number
(
item
.
profit_loss
.
percent_act_vs_mb
)
<
this
.
state
.
minValue
||
Number
(
item
.
profit_loss
.
percent_act_vs_mb
)
>
this
.
state
.
maxValue
)
{
err
=
true
}
if
(
item
.
profit_loss
.
mtd_vs_rb
==
""
&&
Number
(
item
.
profit_loss
.
percent_act_vs_rb
)
<
this
.
state
.
minValue
||
Number
(
item
.
profit_loss
.
percent_act_vs_rb
)
>
this
.
state
.
maxValue
)
{
err
=
true
}
}
dataTable
.
push
([
item
.
type_report_id
,
item
.
id
,
...
...
@@ -193,7 +261,7 @@ export default class ProfitLossMR extends Component {
item
.
level
,
item
.
description
,
item
.
profit_loss
.
notes
===
""
?
null
:
item
.
profit_loss
.
notes
,
item
.
profit_loss
.
rolling_outlook
===
null
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
===
""
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
===
"0"
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
,
item
.
profit_loss
.
rolling_outlook
===
null
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
===
""
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
,
item
.
profit_loss
.
master_budget
===
null
?
"0.0"
:
item
.
profit_loss
.
master_budget
===
""
?
"0.0"
:
item
.
profit_loss
.
master_budget
,
item
.
profit_loss
.
rolling_budget
===
null
?
"0.0"
:
item
.
profit_loss
.
rolling_budget
===
""
?
"0.0"
:
item
.
profit_loss
.
rolling_budget
,
item
.
profit_loss
.
actual
===
null
?
"0.0"
:
item
.
profit_loss
.
actual
===
""
?
"0.0"
:
item
.
profit_loss
.
actual
,
...
...
@@ -211,71 +279,32 @@ export default class ProfitLossMR extends Component {
item
.
order
,
item
.
profit_loss
.
ytd_actual
===
null
?
"0.0"
:
item
.
profit_loss
.
ytd_actual
===
""
?
"0.0"
:
item
.
profit_loss
.
ytd_actual
,
])
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
}
)
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
}
)
}
}
})
if
(
err
===
true
)
{
this
.
setState
({
bebas
:
true
})
}
}
res
.
map
((
item
,
index
)
=>
{
dataTable
.
push
([
item
.
type_report_id
,
item
.
id
,
item
.
parent
,
item
.
formula
,
item
.
level
,
item
.
description
,
item
.
profit_loss
.
notes
===
""
?
null
:
item
.
profit_loss
.
notes
,
item
.
profit_loss
.
rolling_outlook
===
null
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
===
""
?
"0.0"
:
item
.
profit_loss
.
rolling_outlook
,
item
.
profit_loss
.
master_budget
===
null
?
"0.0"
:
item
.
profit_loss
.
master_budget
===
""
?
"0.0"
:
item
.
profit_loss
.
master_budget
,
item
.
profit_loss
.
rolling_budget
===
null
?
"0.0"
:
item
.
profit_loss
.
rolling_budget
===
""
?
"0.0"
:
item
.
profit_loss
.
rolling_budget
,
item
.
profit_loss
.
actual
===
null
?
"0.0"
:
item
.
profit_loss
.
actual
===
""
?
"0.0"
:
item
.
profit_loss
.
actual
,
0
,
item
.
profit_loss
.
actual_previous_month
===
null
?
"0.0"
:
item
.
profit_loss
.
actual_previous_month
===
""
?
"0.0"
:
item
.
profit_loss
.
actual_previous_month
,
item
.
profit_loss
.
amount_act_vs_previous_month
===
null
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_previous_month
===
""
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_previous_month
,
item
.
profit_loss
.
percent_act_vs_previous_month
===
null
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_previous_month
===
""
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_previous_month
,
item
.
profit_loss
.
amount_act_vs_mb
===
null
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_mb
===
""
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_mb
,
item
.
profit_loss
.
percent_act_vs_mb
===
null
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_mb
===
""
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_mb
,
item
.
profit_loss
.
amount_act_vs_rb
===
null
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_rb
===
""
?
"0.0"
:
item
.
profit_loss
.
amount_act_vs_rb
,
item
.
profit_loss
.
percent_act_vs_rb
===
null
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_rb
===
""
?
"0.0"
:
item
.
profit_loss
.
percent_act_vs_rb
,
item
.
profit_loss
.
mtd_vs_previous_month
===
null
?
""
:
item
.
profit_loss
.
mtd_vs_previous_month
,
item
.
profit_loss
.
mtd_vs_mb
===
null
?
""
:
item
.
profit_loss
.
mtd_vs_mb
,
item
.
profit_loss
.
mtd_vs_rb
===
null
?
""
:
item
.
profit_loss
.
mtd_vs_rb
,
item
.
order
,
item
.
profit_loss
.
ytd_actual
===
null
?
"0.0"
:
item
.
profit_loss
.
ytd_actual
===
""
?
"0.0"
:
item
.
profit_loss
.
ytd_actual
,
])
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
this
.
setState
({
dataTable
,
loading
:
false
,
buttonError
:
true
,
saveDraft
:
true
})
}
else
{
this
.
setState
({
loading
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
}
})
this
.
setState
({
dataTable
,
loading
:
false
,
buttonError
:
true
,
saveDraft
:
true
,
bebas
:
true
})
}
console
.
log
(
dataTable
);
let
err
=
false
dataTable
.
map
((
item
,
index
)
=>
{
if
(
item
[
19
]
==
""
&&
Number
(
item
[
14
])
<
this
.
state
.
minValue
||
Number
(
item
[
14
])
>
this
.
state
.
maxValue
)
{
err
=
true
}
if
(
item
[
20
]
==
""
&&
Number
(
item
[
16
])
<
this
.
state
.
minValue
||
Number
(
item
[
16
])
>
this
.
state
.
maxValue
)
{
err
=
true
}
if
(
item
[
21
]
==
""
&&
Number
(
item
[
18
])
<
this
.
state
.
minValue
||
Number
(
item
[
18
])
>
this
.
state
.
maxValue
)
{
err
=
true
})
}
})
if
(
err
===
true
)
{
this
.
setState
({
bebas
:
true
})
}
else
{
this
.
setState
({
dataTable
,
loading
:
false
,
buttonError
:
true
,
saveDraft
:
true
})
}
console
.
log
(
dataTable
);
})
}
...
...
@@ -522,6 +551,20 @@ export default class ProfitLossMR extends Component {
let
data
=
[]
let
err
=
false
this
.
state
.
dataTable
.
map
((
i
,
index
)
=>
{
if
(
i
[
0
]
===
3
)
{
// console.log(i);
if
(
i
[
19
]
===
""
&&
(
Number
(
i
[
14
])
<
this
.
state
.
minValue
||
Number
(
i
[
14
])
>
this
.
state
.
maxValue
))
{
console
.
log
(
'msk 1'
);
// console.log(i);
err
=
true
}
else
if
(
i
[
20
]
===
""
&&
(
Number
(
i
[
16
])
<
this
.
state
.
minValue
||
Number
(
i
[
16
])
>
this
.
state
.
maxValue
))
{
console
.
log
(
'msk 2'
);
err
=
true
}
else
if
(
i
[
21
]
===
""
&&
(
Number
(
i
[
18
])
<
this
.
state
.
minValue
||
Number
(
i
[
18
])
>
this
.
state
.
maxValue
))
{
console
.
log
(
'msk 3'
);
err
=
true
}
}
data
.
push
({
"item_report_id"
:
i
[
1
],
"notes"
:
i
[
6
],
...
...
@@ -542,20 +585,7 @@ export default class ProfitLossMR extends Component {
"mtd_vs_rb"
:
i
[
21
]
})
})
console
.
log
(
data
);
data
.
map
(
i
=>
{
if
(
i
.
mtd_vs_previous_month
===
""
&&
(
Number
(
i
.
percent_act_vs_previous_month
)
<
this
.
state
.
minValue
||
Number
(
i
.
percent_act_vs_previous_month
)
>
this
.
state
.
maxValue
))
{
// console.log('msk 1');
// console.log(i);
err
=
true
}
else
if
(
i
.
mtd_vs_mb
===
""
&&
(
Number
(
i
.
percent_act_vs_mb
)
<
this
.
state
.
minValue
||
Number
(
i
.
percent_act_vs_mb
)
>
this
.
state
.
maxValue
))
{
// console.log('msk 2');
err
=
true
}
else
if
(
i
.
mtd_vs_rb
===
""
&&
(
Number
(
i
.
percent_act_vs_rb
)
<
this
.
state
.
minValue
||
Number
(
i
.
percent_act_vs_rb
)
>
this
.
state
.
maxValue
))
{
// console.log('msk 3');
err
=
true
}
})
// console.log(JSON.stringify(data))
let
payload
=
{
...
...
@@ -569,10 +599,12 @@ export default class ProfitLossMR extends Component {
}
// console.log(JSON.stringify(payload));
api
.
create
().
validateSubmitReportPL
(
payload
).
then
((
response
)
=>
{
console
.
log
(
response
)
console
.
log
(
response
.
data
.
data
.
result
)
console
.
log
(
err
);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
if
(
response
.
data
.
data
.
result
&&
err
===
false
)
{
this
.
setState
({
loading
:
false
,
buttonError
:
false
,
editable
:
false
,
saveDraft
:
false
})
}
else
{
this
.
setState
({
loading
:
false
,
buttonError
:
true
,
editable
:
true
,
saveDraft
:
false
})
...
...
@@ -599,29 +631,6 @@ export default class ProfitLossMR extends Component {
render
()
{
let
dataTable2
=
this
.
state
.
dataTable
// const handleCalculate = () => {
// let error = false
// let messageError = ""
// dataTable2.map((item, index) => {
// if (item[19] == "" && Number(item[14]) <= this.state.minValue || Number(item[14]) >= this.state.maxValue) {
// error = true
// messageError = "MTD Explanation vs Prev. Month is Reqiured"
// }
// if (item[20] == "" && Number(item[16]) <= this.state.minValue || Number(item[16]) >= this.state.maxValue) {
// error = true
// messageError = "MTD Explanation vs MB is Reqiured"
// }
// if (item[21] == "" && Number(item[18]) <= this.state.minValue || Number(item[18]) >= this.state.maxValue) {
// error = true
// messageError = "MTD Explanation vs RB is Reqiured"
// }
// })
// if (error === true) {
// this.setState({ alert: true, messageAlert: messageError, tipeAlert: 'error', loading: false, bebas: true })
// }
// }
const
handleText
=
(
value
,
tableMeta
,
type
)
=>
{
// dataTable2[tableMeta.rowIndex][type] = value
...
...
@@ -1831,7 +1840,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'space-between'
}}
>
<
div
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
{
this
.
props
.
company
.
company_name
}
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
Period
:
{
this
.
props
.
month
.
month_valu
e
}
{
this
.
props
.
periode
}
(
rev
.{
this
.
props
.
revision
})
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
Period
:
{
String
(
this
.
props
.
month
.
month_value
).
toLocaleUpperCas
e
}
{
this
.
props
.
periode
}
(
rev
.{
this
.
props
.
revision
})
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
in
IDR
mn
<
/Typography
>
<
/div
>
<
div
style
=
{{
width
:
'50%'
}}
>
...
...
@@ -1963,7 +1972,7 @@ export default class ProfitLossMR extends Component {
marginRight
:
20
}}
onClick
=
{()
=>
{
this
.
setState
({
loading
:
true
,
bebas
:
false
},
()
=>
{
this
.
setState
({
loading
:
true
},
()
=>
{
setTimeout
(()
=>
{
this
.
handleValidate
()
},
100
);
...
...
@@ -2005,7 +2014,7 @@ export default class ProfitLossMR extends Component {
<
/button
>
<
button
type
=
"button"
disabled
=
{
this
.
state
.
butto
nError
}
// disabled={this.state.butto
nError}
onClick
=
{()
=>
this
.
state
.
buttonError
?
this
.
setState
({
alert
:
true
,
messageAlert
:
'Data is not complete !'
,
tipeAlert
:
'warning'
})
...
...
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