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
bdbad4ac
Commit
bdbad4ac
authored
Nov 23, 2020
by
Riri Novita
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formula plmr
parent
a71a975e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
272 additions
and
48 deletions
+272
-48
ProfitLossMR.js
src/container/MonthlyReport/ProfitLossMR.js
+272
-48
No files found.
src/container/MonthlyReport/ProfitLossMR.js
View file @
bdbad4ac
...
...
@@ -5,6 +5,7 @@ import ReactTooltip from 'react-tooltip';
import
Images
from
'../../assets/Images'
;
import
api
from
'../../api'
;
import
NumberFormat
from
'react-number-format'
;
import
*
as
R
from
'ramda'
;
const
LightTooltip
=
withStyles
((
theme
)
=>
({
tooltip
:
{
...
...
@@ -98,6 +99,7 @@ export default class ProfitLossMR extends Component {
item
.
profit_loss
.
mtd_vs_previous_month
===
null
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_previous_month
===
""
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_previous_month
,
item
.
profit_loss
.
mtd_vs_mb
===
null
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_mb
===
""
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_mb
,
item
.
profit_loss
.
mtd_vs_rb
===
null
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_rb
===
""
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_rb
,
item
.
order
])
}
if
(
item
.
children
!==
null
)
{
...
...
@@ -132,6 +134,7 @@ export default class ProfitLossMR extends Component {
item
.
profit_loss
.
mtd_vs_previous_month
===
null
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_previous_month
===
""
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_previous_month
,
item
.
profit_loss
.
mtd_vs_mb
===
null
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_mb
===
""
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_mb
,
item
.
profit_loss
.
mtd_vs_rb
===
null
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_rb
===
""
?
"0.0"
:
item
.
profit_loss
.
mtd_vs_rb
,
item
.
order
,
])
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
...
...
@@ -146,26 +149,128 @@ export default class ProfitLossMR extends Component {
})
}
handleValidate
()
{
// let data = []
// console.log(JSON.stringify(this.state.dataTable))
// this.state.dataTable.map(i => {
// data.push({
// item_report_id: i[1],
// notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
// total_actual_before: String(i[7]),
// january: i[0] === 3 && i[8] === "" ? "0" : String(i[8]),
// february: i[0] === 3 && i[9] === "" ? "0" : String(i[9]),
// march: i[0] === 3 && i[10] === "" ? "0" : String(i[10]),
// april: i[0] === 3 && i[11] === "" ? "0" : String(i[11]),
// may: i[0] === 3 && i[12] === "" ? "0" : String(i[12]),
// june: i[0] === 3 && i[13] === "" ? "0" : String(i[13]),
// july: i[0] === 3 && i[14] === "" ? "0" : String(i[14]),
// august: i[0] === 3 && i[15] === "" ? "0" : String(i[15]),
// september: i[0] === 3 && i[16] === "" ? "0" : String(i[16]),
// october: i[0] === 3 && i[17] === "" ? "0" : String(i[17]),
// november: i[0] === 3 && i[18] === "" ? "0" : String(i[18]),
// december: i[0] === 3 && i[19] === "" ? "0" : String(i[19]),
// total_current_year: i[0] === 3 && i[20] === "" ? "0" : String(i[20]),
// total_next_year: i[0] === 3 && i[21] === "" ? "0" : String(i[21]),
// total_more_year: i[0] === 3 && i[22] === "" ? "0" : String(i[22])
// })
// })
// let payload = {
// "submission_id": this.props.submissionID,
// "company_id": this.props.company.company_id,
// "periode": this.props.periode,
// "report_id": this.props.report_id,
// "profit_loss": data,
// "status": "submitted"
// }
// console.log(payload)
// api.create().validateSubmitReport(payload).then((response) => {
// // console.log(response)
// if (response.data.data.result) {
// this.setState({ loading: false, buttonError: false, editable: false })
// } else {
this
.
setState
({
loading
:
false
,
buttonError
:
true
,
editable
:
true
})
// }
// })
}
render
()
{
let
dataTable2
=
this
.
state
.
dataTable
const
handleNotes
=
(
value
,
tableMeta
)
=>
{
console
.
log
(
value
)
let
a
=
dataTable2
[
tableMeta
.
rowIndex
][
tableMeta
.
columnIndex
]
=
value
console
.
log
(
dataTable2
[
tableMeta
.
rowIndex
]);
//
console.log(dataTable2[tableMeta.rowIndex]);
}
const
handleChange
=
(
value
,
tableMeta
,
indexChilds
)
=>
{
console
.
log
(
dataTable2
)
let
val
=
String
(
value
).
split
(
","
).
join
(
""
)
dataTable2
[
tableMeta
.
rowIndex
][
tableMeta
.
columnIndex
]
=
Number
(
val
)
// if (indexChilds == 0) {
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// }
// else if (indexChilds == 1) {
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// }
// else if (indexChilds == 2) {
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// }
dataTable2
[
tableMeta
.
rowIndex
][
10
]
=
Number
(
val
)
}
const
handleFormula
=
(
data
,
tableMeta
,
month
,
type
)
=>
{
let
arrayFormula
=
tableMeta
.
rowData
[
3
].
match
(
/
[
a-zA-Z
]
+|
[
0-9
]
+|
[
-!$%^&*()_+|~=`{}
\[\]
:";'<>?,.
\/]
+
(?:\.[
0-9
]
+@|
)
/g
)
let
arrayJumlah
=
[]
let
tambahan
=
false
let
opet
=
""
arrayFormula
.
map
((
item
,
indexs
)
=>
{
if
(
item
==
'X'
)
{
tambahan
=
true
}
else
if
(
item
==
'-'
||
item
==
'+'
||
item
==
'/'
||
item
==
'*'
)
{
arrayJumlah
.
push
(
item
)
}
else
{
let
index
=
dataTable2
.
findIndex
((
val
)
=>
val
[
22
]
==
item
)
if
(
tambahan
)
{
if
(
item
==
'-'
||
item
==
'+'
||
item
==
'/'
||
item
==
'*'
)
{
opet
=
item
}
else
{
arrayJumlah
.
push
(
opet
==
''
?
Number
(
item
)
:
Number
(
String
(
opet
+
String
(
item
))))
tambahan
=
false
opet
=
""
}
}
else
{
if
(
index
!=
-
1
)
{
arrayJumlah
.
push
(
dataTable2
[
index
][
tableMeta
.
columnIndex
+
type
])
if
(
tableMeta
.
rowData
[
5
]
===
'Unit Business/ Brand/ SubCo 1'
)
{
console
.
log
(
dataTable2
[
index
][
tableMeta
.
columnIndex
+
type
]);
console
.
log
(
arrayJumlah
);
}
}
}
}
})
let
array
=
arrayJumlah
let
total
=
0
let
opt
=
""
array
.
map
((
item
,
index
)
=>
{
if
(
item
==
"+"
)
{
opt
=
"tambah"
}
else
if
(
item
==
"-"
)
{
opt
=
"kurang"
}
else
if
(
item
==
"*"
)
{
opt
=
"kali"
}
else
if
(
item
==
"/"
)
{
opt
=
"bagi"
}
else
{
if
(
opt
==
"tambah"
)
{
total
=
Number
(
total
)
+
Number
(
item
)
}
else
if
(
opt
==
"kurang"
)
{
total
=
Number
(
total
)
-
Number
(
item
)
}
else
if
(
opt
==
"kali"
)
{
total
=
Number
(
total
)
*
Number
(
item
)
}
else
if
(
opt
==
"bagi"
)
{
total
=
R
.
equals
((
Number
(
total
)
/
Number
(
item
)),
NaN
)
?
'0'
:
Number
(
total
)
/
Number
(
item
)
}
else
{
total
+=
item
}
}
})
let
a
=
dataTable2
[
tableMeta
.
rowIndex
][
tableMeta
.
columnIndex
+
type
]
=
Number
(
total
)
return
a
}
let
columns
=
[
{
...
...
@@ -296,21 +401,21 @@ export default class ProfitLossMR extends Component {
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
val
}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
style
=
{{
fontSize
:
12
,
textAlign
:
'right'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
}}
type
=
"text"
placeholder
=
""
disabled
=
{
true
}
value
=
{
Number
(
val
).
toFixed
(
1
)}
/
>
}
/
>
<
/div
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
val
}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
style
=
{{
fontSize
:
12
,
textAlign
:
'right'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
}}
type
=
"text"
placeholder
=
""
disabled
=
{
true
}
value
=
{
Number
(
val
).
toFixed
(
1
)}
/
>
}
/
>
<
/div
>
}
<
/div
>
)
...
...
@@ -354,10 +459,11 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
tableMeta
.
rowData
[
0
]
===
6
?
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
value
}
value
=
{
tableMeta
.
rowData
[
10
]
}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
...
...
@@ -365,7 +471,24 @@ export default class ProfitLossMR extends Component {
type
=
"text"
placeholder
=
""
disabled
=
{
true
}
value
=
{
Number
(
value
).
toFixed
(
1
)}
value
=
{
Number
(
handleFormula
(
value
,
tableMeta
,
1
,
0
)).
toFixed
(
1
)}
/
>
}
/
>
<
/div>
:
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
tableMeta
.
rowData
[
8
]}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
style
=
{{
fontSize
:
12
,
textAlign
:
'right'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
}}
type
=
"text"
placeholder
=
""
disabled
=
{
true
}
value
=
{
tableMeta
.
rowData
[
8
]}
/
>
}
/
>
...
...
@@ -377,10 +500,28 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
tableMeta
.
rowData
[
0
]
===
6
?
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
tableMeta
.
rowData
[
10
]}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
style
=
{{
fontSize
:
12
,
textAlign
:
'right'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
}}
type
=
"text"
placeholder
=
""
disabled
=
{
true
}
value
=
{
Number
(
handleFormula
(
value
,
tableMeta
,
1
,
1
)).
toFixed
(
1
)}
/
>
}
/
>
<
/div>
:
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
value
}
value
=
{
tableMeta
.
rowData
[
9
]
}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
...
...
@@ -388,7 +529,7 @@ export default class ProfitLossMR extends Component {
type
=
"text"
placeholder
=
""
disabled
=
{
true
}
value
=
{
Number
(
value
).
toFixed
(
1
)
}
value
=
{
tableMeta
.
rowData
[
9
]
}
/
>
}
/
>
...
...
@@ -404,7 +545,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
value
}
value
=
{
tableMeta
.
rowData
[
10
]
}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
...
...
@@ -412,7 +553,7 @@ export default class ProfitLossMR extends Component {
type
=
"text"
placeholder
=
""
disabled
=
{
true
}
value
=
{
Number
(
value
).
toFixed
(
1
)
}
value
=
{
tableMeta
.
rowData
[
10
]
}
/
>
}
/
>
...
...
@@ -421,7 +562,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
value
}
value
=
{
tableMeta
.
rowData
[
10
]
}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
...
...
@@ -429,7 +570,7 @@ export default class ProfitLossMR extends Component {
type
=
"text"
placeholder
=
""
disabled
=
{
true
}
value
=
{
Number
(
value
).
toFixed
(
1
)}
value
=
{
Number
(
handleFormula
(
value
,
tableMeta
,
1
,
2
)
).
toFixed
(
1
)}
/
>
}
/
>
...
...
@@ -440,17 +581,17 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
value
}
value
=
{
tableMeta
.
rowData
[
10
]
}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
style
=
{{
color
:
"#5198ea"
,
fontSize
:
12
,
textAlign
:
'right'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
}}
type
=
"text"
placeholder
=
""
value
=
{
Number
(
value
).
toFixed
(
1
)
}
value
=
{
tableMeta
.
rowData
[
10
]
}
onBlur
=
{(
event
)
=>
{
handleChange
(
event
.
target
.
value
,
tableMeta
,
2
)
//
console.log(dataTable2)
handleChange
(
event
.
target
.
value
,
tableMeta
)
console
.
log
(
dataTable2
)
}}
/
>
}
...
...
@@ -572,7 +713,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
13
]
}
<
/div
>
<
/div
>
...
...
@@ -580,7 +721,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
14
]
}
<
/div
>
<
/div
>
...
...
@@ -592,7 +733,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
15
]
}
<
/div
>
<
/div
>
...
...
@@ -600,7 +741,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
16
]
}
<
/div
>
<
/div
>
...
...
@@ -612,7 +753,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
17
]
}
<
/div
>
<
/div
>
...
...
@@ -620,7 +761,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
18
]
}
<
/div
>
<
/div
>
...
...
@@ -668,7 +809,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
19
]
}
<
/div
>
<
/div
>
...
...
@@ -676,7 +817,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
20
]
}
<
/div
>
<
/div
>
...
...
@@ -684,7 +825,7 @@ export default class ProfitLossMR extends Component {
<
div
style
=
{{
textAlign
:
'right'
,
width
:
90
}}
>
{
tableMeta
.
rowData
[
0
]
===
4
?
null
:
val
tableMeta
.
rowData
[
21
]
}
<
/div
>
<
/div
>
...
...
@@ -694,6 +835,12 @@ export default class ProfitLossMR extends Component {
}
}
},
{
name
:
""
,
options
:
{
display
:
false
}
}
]
return
(
...
...
@@ -794,6 +941,83 @@ export default class ProfitLossMR extends Component {
<
/div
>
<
/button
>
<
/div
>
<
div
className
=
"col-2"
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
maxWidth
:
'100%'
}}
>
<
button
className
=
"button"
type
=
"button"
disabled
=
{
this
.
state
.
buttonError
}
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
this
.
state
.
buttonError
===
true
?
'default'
:
'pointer'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
marginRight
:
20
}}
onClick
=
{()
=>
{
this
.
setState
({
loading
:
true
,
dataTable
:
dataTable2
,
buttonDraft
:
false
},
()
=>
{
setTimeout
(()
=>
{
this
.
setState
({
loading
:
false
})
// this.handleValidate()
},
100
);
})
}}
>
<
div
style
=
{{
backgroundColor
:
'#fff'
,
width
:
105
,
height
:
25
,
borderRadius
:
3
,
justifyContent
:
'center'
,
display
:
'flex'
,
alignItems
:
'center'
,
border
:
'solid 1px #354960'
}}
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#354960'
,
textAlign
:
'center'
}}
>
Calculate
<
/Typography
>
<
/div
>
<
/button
>
<
button
type
=
"button"
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
this
.
state
.
editable
!==
true
?
'pointer'
:
'default'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
marginRight
:
20
}}
// onClick={() =>
// this.state.editable === true ?
// null :
// this.setState({ loading: true }, () =>
// this.state.handleTekTekTek == 1 ? null :
// this.setState({ handleTekTekTek: 1 }, () => {
// setTimeout(() => {
// this.uploadProfitLoss('draft')
// }, 100);
// })
// )
// }
>
<
div
style
=
{{
backgroundColor
:
'#354960'
,
width
:
105
,
height
:
25
,
borderRadius
:
3
,
justifyContent
:
'center'
,
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#fff'
,
textAlign
:
'center'
}}
>
Save
as
Draft
<
/Typography
>
<
/div
>
<
/button
>
<
button
type
=
"button"
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
this
.
state
.
editable
!==
true
?
'pointer'
:
'default'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
}}
// onClick={() =>
// this.state.editable === true ?
// null :
// this.setState({ loading: true }, () =>
// this.state.handleTekTekTek == 1 ? null :
// this.setState({ handleTekTekTek: 1 }, () => {
// setTimeout(() => {
// this.uploadProfitLoss('submitted')
// }, 100);
// })
// )
// }
>
<
div
style
=
{{
backgroundColor
:
'#354960'
,
width
:
105
,
height
:
25
,
borderRadius
:
3
,
justifyContent
:
'center'
,
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#fff'
,
textAlign
:
'center'
}}
>
Save
&
Complete
<
/Typography
>
<
/div
>
<
/button
>
<
/div
>
<
/div
>
<
/Paper
>
<
/div
>
...
...
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