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
73e8675b
Commit
73e8675b
authored
Jul 25, 2023
by
Riri Novita
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
balikin code simulasi MB
parent
4fb1c8bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
160 additions
and
1256 deletions
+160
-1256
BalanceSheet.js
src/container/BudgetTahunan/BalanceSheet.js
+64
-328
BudgetTahunan.js
src/container/BudgetTahunan/BudgetTahunan.js
+66
-110
CashFlow.js
src/container/BudgetTahunan/CashFlow.js
+4
-27
CorporateAnnualTarget.js
src/container/BudgetTahunan/CorporateAnnualTarget.js
+26
-534
FixedAssetsMovement.js
src/container/BudgetTahunan/FixedAssetsMovement.js
+0
-257
No files found.
src/container/BudgetTahunan/BalanceSheet.js
View file @
73e8675b
...
...
@@ -61,10 +61,8 @@ export default class BalanceSheet extends Component {
messageAlert
:
''
,
defaultCurrencyUpload
:
this
.
props
.
defaultCurrency
,
visibleAlertSave
:
false
,
visibleButtonUpload
:
false
}
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
this
.
fileHandlerSimulasi
=
this
.
fileHandlerSimulasi
.
bind
(
this
);
}
componentDidMount
()
{
...
...
@@ -375,55 +373,6 @@ export default class BalanceSheet extends Component {
});
}
fileHandlerSimulasi
=
(
event
)
=>
{
let
fileObj
=
event
ExcelRenderer
(
fileObj
,
(
err
,
resp
)
=>
{
// console.log(resp)
if
(
err
)
{
// console.log(err);
}
else
{
let
isi
=
resp
.
rows
.
slice
(
3
)
// console.log(resp.rows[2]);
let
payload
=
[]
let
reg
=
/^
[
-+
]?(?:[
0-9
]
+,
)
*
[
0-9
]
+
(?:\.[
0-9
]
+
)?
$/
;
isi
.
map
((
i
,
index
)
=>
{
if
(
i
.
length
>
0
)
{
payload
.
push
({
item_report_id
:
i
[
0
]
===
undefined
?
""
:
String
(
i
[
0
]).
trim
(),
item_report
:
i
[
1
]
===
undefined
?
""
:
String
(
i
[
1
]).
trim
(),
total_actual_before
:
i
[
2
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
2
]))
===
false
?
"0"
:
String
(
i
[
2
]).
trim
(),
january
:
i
[
3
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
3
]))
===
false
?
"0"
:
String
(
i
[
3
]).
trim
(),
february
:
i
[
4
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
4
]))
===
false
?
"0"
:
String
(
i
[
4
]).
trim
(),
march
:
i
[
5
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
5
]))
===
false
?
"0"
:
String
(
i
[
5
]).
trim
(),
april
:
i
[
6
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
6
]))
===
false
?
"0"
:
String
(
i
[
6
]).
trim
(),
may
:
i
[
7
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
7
]))
===
false
?
"0"
:
String
(
i
[
7
]).
trim
(),
june
:
i
[
8
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
8
]))
===
false
?
"0"
:
String
(
i
[
8
]).
trim
(),
july
:
i
[
9
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
9
]))
===
false
?
"0"
:
String
(
i
[
9
]).
trim
(),
august
:
i
[
10
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
10
]))
===
false
?
"0"
:
String
(
i
[
10
]).
trim
(),
september
:
i
[
11
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
11
]))
===
false
?
"0"
:
String
(
i
[
11
]).
trim
(),
october
:
i
[
12
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
12
]))
===
false
?
"0"
:
String
(
i
[
12
]).
trim
(),
november
:
i
[
13
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
13
]))
===
false
?
"0"
:
String
(
i
[
13
]).
trim
(),
december
:
i
[
14
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
14
]))
===
false
?
"0"
:
String
(
i
[
14
]).
trim
(),
total_current_year
:
i
[
15
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
15
]))
===
false
?
"0"
:
String
(
i
[
15
]).
trim
(),
total_next_year
:
i
[
16
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
16
]))
===
false
?
"0"
:
String
(
i
[
16
]).
trim
(),
total_more_year
:
i
[
17
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
17
]))
===
false
?
"0"
:
String
(
i
[
17
]).
trim
()
})
}
})
let
body
=
{
company_id
:
this
.
props
.
company
.
company_id
,
periode
:
this
.
props
.
periode
,
report_id
:
this
.
props
.
report_id
,
balance_sheet
:
payload
,
status
:
'submitted'
}
// console.log(body)
this
.
setState
({
payload
:
body
,
judul
:
resp
.
rows
[
1
][
0
],
judulColumn
:
resp
.
rows
[
2
]
})
}
});
}
checkUpload
()
{
let
payload
=
{
...
this
.
state
.
payload
,
...
...
@@ -490,135 +439,6 @@ export default class BalanceSheet extends Component {
})
}
checkUploadSimulasi
()
{
let
payload
=
{
...
this
.
state
.
payload
,
currency_id
:
this
.
state
.
defaultCurrencyUpload
?.
id
}
api
.
create
().
checkUploadMB
(
payload
).
then
(
response
=>
{
// console.log(response)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
setState
({
visibleUpload
:
false
,
visibleBalanceSheet
:
false
,
loading
:
true
,
visibleButtonUpload
:
true
})
let
dataTable
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
return
[
item
.
type_report_id
,
item
.
item_report_id
,
item
.
parent
,
item
.
formula
,
item
.
level
,
item
.
item_report
,
item
.
total_actual_before
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
january
,
formula
:
item
.
january_formula
}
:
Number
(
item
.
january
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
february
,
formula
:
item
.
february_formula
}
:
Number
(
item
.
february
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
march
,
formula
:
item
.
march_formula
}
:
Number
(
item
.
march
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
april
,
formula
:
item
.
april_formula
}
:
Number
(
item
.
april
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
may
,
formula
:
item
.
may_formula
}
:
Number
(
item
.
may
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
june
,
formula
:
item
.
june_formula
}
:
Number
(
item
.
june
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
july
,
formula
:
item
.
july_formula
}
:
Number
(
item
.
july
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
august
,
formula
:
item
.
august_formula
}
:
Number
(
item
.
august
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
september
,
formula
:
item
.
september_formula
}
:
Number
(
item
.
september
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
october
,
formula
:
item
.
october_formula
}
:
Number
(
item
.
october
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
november
,
formula
:
item
.
november_formula
}
:
Number
(
item
.
november
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
december
,
formula
:
item
.
december_formula
}
:
Number
(
item
.
december
).
toFixed
(
1
),
Number
(
item
.
total_current_year
).
toFixed
(
1
),
Number
(
item
.
total_next_year
).
toFixed
(
1
),
Number
(
item
.
total_more_year
).
toFixed
(
1
),
item
.
orders
,
item
.
condition_it_should_be
,
item
.
condition_if_wrong
,
item
.
forecast_formula
==
null
?
[]
:
item
.
forecast_formula
,
item
.
error
]
})
this
.
setState
({
dataTable
,
dataLoaded
:
true
,
loading
:
false
,
buttonError
:
false
,
editable
:
true
,
errorPreview
:
false
,
saveDraft
:
true
},
()
=>
{
this
.
state
.
dataTable
.
map
(
item
=>
{
if
(
item
[
26
].
length
>
0
)
{
// console.log('error')
this
.
setState
({
buttonError
:
true
,
errorPreview
:
true
,
editable
:
true
,
saveDraft
:
true
})
}
})
// console.log(this.state.dataTable);
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
uploadSimulasi
(
type
)
{
let
data
=
[]
this
.
state
.
dataTable
.
map
(
i
=>
{
data
.
push
({
item_report_id
:
i
[
1
],
total_actual_before
:
String
(
Number
(
i
[
6
]).
toFixed
(
1
)),
january
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
7
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
7
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
7
]).
toFixed
(
1
)),
february
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
8
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
8
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
8
]).
toFixed
(
1
)),
march
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
9
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
9
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
9
]).
toFixed
(
1
)),
april
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
10
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
10
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
10
]).
toFixed
(
1
)),
may
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
11
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
11
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
11
]).
toFixed
(
1
)),
june
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
12
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
12
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
12
]).
toFixed
(
1
)),
july
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
13
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
13
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
13
]).
toFixed
(
1
)),
august
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
14
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
14
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
14
]).
toFixed
(
1
)),
september
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
15
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
15
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
15
]).
toFixed
(
1
)),
october
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
16
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
16
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
16
]).
toFixed
(
1
)),
november
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
17
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
17
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
17
]).
toFixed
(
1
)),
december
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
18
].
value
).
toFixed
(
1
))
:
i
[
0
]
===
3
&&
i
[
18
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
18
]).
toFixed
(
1
)),
total_current_year
:
i
[
0
]
===
3
&&
i
[
19
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
19
]).
toFixed
(
1
)),
total_next_year
:
i
[
0
]
===
3
&&
i
[
20
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
20
]).
toFixed
(
1
)),
total_more_year
:
i
[
0
]
===
3
&&
i
[
21
]
===
""
?
"0.0"
:
String
(
Number
(
i
[
21
]).
toFixed
(
1
)),
})
})
let
body
=
{
submission_id
:
this
.
props
.
submissionID
,
company_id
:
this
.
props
.
company
.
company_id
,
periode
:
this
.
props
.
periode
,
report_id
:
this
.
props
.
report_id
,
currency_id
:
this
.
state
.
defaultCurrencyUpload
?.
id
,
balance_sheet
:
data
,
status
:
type
}
console
.
log
(
body
)
api
.
create
().
uploadSimulasiMB
(
body
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
props
.
onClickClose
()
this
.
props
.
getReport
(
'BS'
,
'simulasiBS'
)
// let bodyRatioBs = {
// "report": 'ratio',
// "submissionId": this.props.submissionID,
// "periode": this.props.periode,
// "companyId": this.props.company.company_id,
// "currency_id": this.props.defaultCurrency.id,
// }
// api.create().triggerRatioMB(bodyRatioBs).then((res) => {
// console.log(res)
// this.setState({ loading: false })
// })
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
'Error saving data. Please try again'
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
uploadBalanceSheet
(
type
)
{
let
data
=
[]
this
.
state
.
dataTable
.
map
(
i
=>
{
...
...
@@ -3644,84 +3464,68 @@ export default class BalanceSheet extends Component {
}
<
/div
>
<
div
style
=
{{
width
:
'50%'
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
}}
>
<
ReactTooltip
border
=
{
true
}
id
=
"template"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
a
data
-
tip
=
{
'Upload Simulasi'
}
data
-
for
=
"upload"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
setState
({
visibleUploadSimulasi
:
true
,
buttonDraft
:
true
})}
>
<
img
src
=
{
Images
.
simulasiUpload
}
style
=
{{
width
:
40
,
height
:
40
,
marginRight
:
3
}}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"upload"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
this
.
state
.
dataTable
.
length
==
0
?
null
:
this
.
props
.
isApprover
==
true
?
null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
// <a data-tip={'Download'} data-for="download">
// <button
// style={{
// backgroundColor: 'transparent',
// cursor: 'pointer',
// borderColor: 'transparent',
// margin: 5
// }}
// onClick={() =>
// this.setState({ loading: true }, () => {
// setTimeout(() => {
// this.downloadAllData()
// }, 100);
// })}
// >
// <img src={Images.download} />
// </button>
// </a>
// <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
// </div>
:
<
div
style
=
{{
justifyContent
:
'flex-end'
,
display
:
'flex'
,
flexFlow
:
'wrap'
}}
>
{((
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
===
'SUBMIT'
||
this
.
props
.
lastStatus
===
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
))
&&
(
<
div
>
<
a
data
-
tip
=
{
'Download Template'
}
data
-
for
=
"template"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
downloadTemplate
()}
>
<
img
src
=
{
Images
.
template
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"template"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/div
>
)}
{((
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
===
'SUBMIT'
||
this
.
props
.
lastStatus
===
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
))
&&
(
<
div
>
<
a
data
-
tip
=
{
'Upload'
}
data
-
for
=
"upload"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
setState
({
visibleUpload
:
true
})}
>
<
img
src
=
{
Images
.
upload
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"upload"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/div
>
)}
{
/* <a data-tip={'Download'} data-for="download">
{
this
.
state
.
dataTable
.
length
==
0
?
null
:
this
.
props
.
isApprover
==
true
?
null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
// <a data-tip={'Download'} data-for="download">
// <button
// style={{
// backgroundColor: 'transparent',
// cursor: 'pointer',
// borderColor: 'transparent',
// margin: 5
// }}
// onClick={() =>
// this.setState({ loading: true }, () => {
// setTimeout(() => {
// this.downloadAllData()
// }, 100);
// })}
// >
// <img src={Images.download} />
// </button>
// </a>
// <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
// </div>
:
<
div
style
=
{{
justifyContent
:
'flex-end'
,
display
:
'flex'
,
flexFlow
:
'wrap'
}}
>
{((
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
===
'SUBMIT'
||
this
.
props
.
lastStatus
===
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
))
&&
(
<
div
>
<
a
data
-
tip
=
{
'Download Template'
}
data
-
for
=
"template"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
downloadTemplate
()}
>
<
img
src
=
{
Images
.
template
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"template"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/div
>
)}
{((
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
===
'SUBMIT'
||
this
.
props
.
lastStatus
===
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
))
&&
(
<
div
>
<
a
data
-
tip
=
{
'Upload'
}
data
-
for
=
"upload"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
setState
({
visibleUpload
:
true
})}
>
<
img
src
=
{
Images
.
upload
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"upload"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/div
>
)}
{
/* <a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
...
...
@@ -3740,9 +3544,8 @@ export default class BalanceSheet extends Component {
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */
}
<
/div
>
}
<
/div
>
<
/div
>
}
<
/div
>
<
/div
>
...
...
@@ -4030,73 +3833,6 @@ export default class BalanceSheet extends Component {
<
/div
>
)}
{
this
.
state
.
visibleUploadSimulasi
&&
(
<
div
className
=
"test app-popup-show"
>
<
div
className
=
"popup-content background-white border-radius"
style
=
{{
borderRadius
:
8
}}
>
<
div
className
=
"popup-panel grid grid-2x main-color"
style
=
{{
height
:
64
,
borderTopRightRadius
:
8
,
borderTopLeftRadius
:
8
}}
>
<
div
className
=
"col-1"
style
=
{{
maxWidth
:
"inherit"
,
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
div
className
=
"popup-title"
>
<
span
style
=
{{
color
:
'#fff'
,
fontSize
:
16
,
fontWeight
:
'bold'
}}
>
Upload
File
Simulasi
<
/span
>
<
/div
>
<
/div
>
<
div
className
=
"col-2 content-right"
style
=
{{
maxWidth
:
"inherit"
,
alignSelf
:
'center'
}}
>
<
button
type
=
"button"
className
=
"btn btn-circle btn-white"
onClick
=
{()
=>
this
.
setState
({
visibleUploadSimulasi
:
false
})}
>
<
img
src
=
{
Images
.
close
}
/
>
<
/button
>
<
/div
>
<
/div
>
<
div
style
=
{{
padding
:
'25px 30px'
}}
>
<
UploadFile
type
=
{
this
.
state
.
uploadStatusSimulasi
}
percentage
=
{
this
.
state
.
percentageSimulasi
}
result
=
{
this
.
state
.
resultSimulasi
}
acceptedFiles
=
{[
"xlsx"
]}
onHandle
=
{(
dt
)
=>
{
this
.
fileHandlerSimulasi
(
dt
)
this
.
setState
({
uploadStatusSimulasi
:
'idle'
,
percentageSimulasi
:
'0'
})
}}
onUpload
=
{()
=>
{
String
(
this
.
state
.
judul
).
includes
(
"MASTER"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"BUDGET"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"BALANCE"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"SHEET"
)
?
this
.
checkUploadSimulasi
()
:
this
.
setState
({
alert
:
true
,
messageAlert
:
"Invalid Template"
,
tipeAlert
:
'warning'
})
}}
/
>
<
/div
>
{
this
.
state
.
visibleButtonUpload
&&
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
margin
:
'0px 32px 16px'
}}
>
<
div
>
<
button
type
=
"button"
// disabled={this.state.buttonError}
onClick
=
{()
=>
this
.
setState
({
handleDoubleClick
:
1
,
loading
:
true
},
()
=>
{
this
.
uploadSimulasi
(
'submitted'
)
})}
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
}}
>
<
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
Data
<
/Typography
>
<
/div
>
<
/button
>
<
/div
>
<
/div
>
}
{
/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */
}
<
/div
>
<
/div
>
)}
{
this
.
state
.
visibleAlertSave
&&
(
<
div
className
=
"test app-popup-show"
>
<
div
className
=
"popup-content border-radius"
style
=
{{
background
:
'#FFF27D'
,
borderRadius
:
10
,
width
:
715
,
height
:
238
}}
>
...
...
src/container/BudgetTahunan/BudgetTahunan.js
View file @
73e8675b
...
...
@@ -614,8 +614,7 @@ export default class BudgetTahunan extends Component {
})
}
getSubmission
(
type
,
trigger
)
{
console
.
log
(
trigger
);
getSubmission
(
type
)
{
this
.
setState
({
loading
:
true
},
()
=>
{
document
.
body
.
style
.
overflow
=
'hidden'
;
})
...
...
@@ -668,35 +667,20 @@ export default class BudgetTahunan extends Component {
}
if
(
type
!=
undefined
&&
type
==
'PL'
)
{
// this.getCashFlow(type)
this
.
getPL
(
type
,
trigger
)
this
.
getPL
(
type
)
}
else
if
(
type
!=
undefined
&&
type
==
'BS'
)
{
if
(
trigger
===
'simulasiBS'
)
{
let
bodyRatioBs
=
{
"report"
:
'ratio'
,
"submissionId"
:
this
.
state
.
submissionID
,
"periode"
:
this
.
state
.
periode
.
periode
,
"companyId"
:
this
.
state
.
company
.
company_id
,
"currency_id"
:
this
.
state
.
defaultCurrency
.
id
,
}
// console.log(bodyRatioBs);
api
.
create
().
triggerRatioMBSimulasi
(
bodyRatioBs
).
then
((
res
)
=>
{
console
.
log
(
res
)
this
.
setState
({
loading
:
false
})
})
}
else
{
let
bodyRatioBs
=
{
"report"
:
'ratio'
,
"submissionId"
:
this
.
state
.
submissionID
,
"periode"
:
this
.
state
.
periode
.
periode
,
"companyId"
:
this
.
state
.
company
.
company_id
,
"currency_id"
:
this
.
state
.
defaultCurrency
.
id
,
}
// console.log(bodyRatioBs);
api
.
create
().
triggerRatioMB
(
bodyRatioBs
).
then
((
res
)
=>
{
console
.
log
(
res
)
this
.
setState
({
loading
:
false
})
})
let
bodyRatioBs
=
{
"report"
:
'ratio'
,
"submissionId"
:
this
.
state
.
submissionID
,
"periode"
:
this
.
state
.
periode
.
periode
,
"companyId"
:
this
.
state
.
company
.
company_id
,
"currency_id"
:
this
.
state
.
defaultCurrency
.
id
,
}
// console.log(bodyRatioBs);
api
.
create
().
triggerRatioMB
(
bodyRatioBs
).
then
((
res
)
=>
{
console
.
log
(
res
)
this
.
setState
({
loading
:
false
})
})
}
else
{
this
.
setState
({
loading
:
false
})
}
...
...
@@ -1320,60 +1304,40 @@ export default class BudgetTahunan extends Component {
})
}
createCashFlow
(
payload
,
trigger
)
{
console
.
log
(
trigger
);
if
(
trigger
===
"simulasi"
)
{
api
.
create
().
createReportCFSimulasi
(
payload
).
then
((
res
)
=>
{
console
.
log
(
res
)
// this.getSubmission()
if
(
res
.
data
)
{
if
(
res
.
data
.
status
===
"success"
)
{
this
.
setState
({
visibleCF
:
false
,
visibleBudgetTahunan
:
true
})
this
.
getSubmission
()
}
else
{
if
(
res
.
data
.
message
==
"Please Set Up Rate Currency First"
)
{
this
.
setState
({
visibleAlertSave
:
true
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
res
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
})
}
}
}
})
}
else
{
api
.
create
().
createReportCF
(
payload
).
then
((
res
)
=>
{
console
.
log
(
res
)
// this.getSubmission()
if
(
res
.
data
)
{
if
(
res
.
data
.
status
===
"success"
)
{
this
.
setState
({
visibleCF
:
false
,
visibleBudgetTahunan
:
true
})
this
.
getSubmission
()
createCashFlow
(
payload
)
{
api
.
create
().
createReportCF
(
payload
).
then
((
res
)
=>
{
console
.
log
(
res
)
// this.getSubmission()
if
(
res
.
data
)
{
if
(
res
.
data
.
status
===
"success"
)
{
this
.
setState
({
visibleCF
:
false
,
visibleBudgetTahunan
:
true
})
this
.
getSubmission
()
}
else
{
if
(
res
.
data
.
message
==
"Please Set Up Rate Currency First"
)
{
this
.
setState
({
visibleAlertSave
:
true
})
}
else
{
if
(
res
.
data
.
message
==
"Please Set Up Rate Currency First"
)
{
this
.
setState
({
visibleAlertSave
:
true
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
res
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
})
}
this
.
setState
({
alert
:
true
,
messageAlert
:
res
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
})
}
}
// if (response.data) {
// if (response.data.status === "success"
) {
// this.props.saveToMonthlyReport()
// } else {
// this.setState({ loading: false }, () =>
{
// this.props.saveToMonthlyReport()
// }
)
// }
// } else {
// this.setState({ loading: false }, () =>
{
// // this.getSubmission()
// document.body.style.overflow = 'unset';
// })
// }
})
}
}
// if (response.data
) {
// if (response.data.status === "success") {
// this.props.saveToMonthlyReport()
// } else
{
// this.setState({ loading: false }, () => {
// this.props.saveToMonthlyReport(
)
// })
// }
// } else
{
// this.setState({ loading: false }, () => {
// // this.getSubmission()
// document.body.style.overflow = 'unset';
// })
// }
}
)
}
getPL
(
type
,
trigger
)
{
getPL
(
type
)
{
let
PLID
=
null
let
payloadID
=
{
"periode"
:
this
.
state
.
periode
.
periode
,
...
...
@@ -1484,7 +1448,7 @@ export default class BudgetTahunan extends Component {
})
// console.log(dataTable)
this
.
setState
({
dbPL
:
dataTable
},
()
=>
{
this
.
olahDataPL
(
this
.
state
.
dbPL
,
type
,
trigger
)
this
.
olahDataPL
(
this
.
state
.
dbPL
,
type
)
})
}
else
{
this
.
setState
({
dbPL
:
[],
previewTable
:
false
,
previewDownload
:
false
})
...
...
@@ -1723,7 +1687,7 @@ export default class BudgetTahunan extends Component {
return
total
}
olahDataPL
(
dbPL
,
type
,
trigger
)
{
olahDataPL
(
dbPL
,
type
)
{
dbPL
.
map
((
item
,
index
)
=>
{
if
(
item
[
0
]
==
5
||
item
[
0
]
==
6
||
item
[
0
]
==
7
)
{
item
[
7
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
7
],
item
,
7
)
...
...
@@ -1743,11 +1707,11 @@ export default class BudgetTahunan extends Component {
}
})
this
.
setState
({
dbPL
},
()
=>
{
this
.
payloadPL
(
type
,
trigger
)
this
.
payloadPL
(
type
)
})
}
payloadPL
(
type
,
trigger
)
{
payloadPL
(
type
)
{
let
listPL
=
[]
// console.log(this.state.dbPL)
this
.
state
.
dbPL
.
map
((
item
,
index
)
=>
{
...
...
@@ -1842,14 +1806,13 @@ export default class BudgetTahunan extends Component {
if
(
type
!=
undefined
)
{
if
(
type
==
'PL'
)
{
// console.log('tarik sis')
this
.
createDBPL
(
trigger
)
this
.
createDBPL
()
}
}
})
}
createDBPL
(
trigger
)
{
console
.
log
(
trigger
);
createDBPL
()
{
let
payload
=
{
// "submission_id": this.state.submissionID,
"company_id"
:
this
.
state
.
company
.
company_id
,
...
...
@@ -1863,31 +1826,24 @@ export default class BudgetTahunan extends Component {
}
// console.log(this.state.dbCF)
// console.log(JSON.stringify(payload))
if
(
trigger
===
"simulasiPL"
)
{
api
.
create
().
createReportPLMBSimulasi
(
payload
).
then
((
res
)
=>
{
// console.log(res)
this
.
setState
({
loading
:
false
})
})
}
else
{
api
.
create
().
createReportPLMB
(
payload
).
then
((
res
)
=>
{
// console.log(res)
this
.
setState
({
loading
:
false
})
// if (response.data) {
// if (response.data.status === "success") {
// this.props.saveToMonthlyReport()
// } else {
// this.setState({ loading: false }, () => {
// this.props.saveToMonthlyReport()
// })
// }
// } else {
// this.setState({ loading: false }, () => {
// // this.getSubmission()
// document.body.style.overflow = 'unset';
// })
// }
})
}
api
.
create
().
createReportPLMB
(
payload
).
then
((
res
)
=>
{
// console.log(res)
this
.
setState
({
loading
:
false
})
// if (response.data) {
// if (response.data.status === "success") {
// this.props.saveToMonthlyReport()
// } else {
// this.setState({ loading: false }, () => {
// this.props.saveToMonthlyReport()
// })
// }
// } else {
// this.setState({ loading: false }, () => {
// // this.getSubmission()
// document.body.style.overflow = 'unset';
// })
// }
})
}
getFR
(
type
)
{
...
...
src/container/BudgetTahunan/CashFlow.js
View file @
73e8675b
...
...
@@ -336,7 +336,7 @@ export default class CashFlow extends Component {
this
.
setState
({
alert
:
false
})
}
olahDataCashFlow
(
dataTable2
,
trigger
)
{
olahDataCashFlow
(
dataTable2
)
{
console
.
log
(
dataTable2
)
let
listCF
=
[]
dataTable2
.
map
((
item
,
index
)
=>
{
...
...
@@ -373,10 +373,10 @@ export default class CashFlow extends Component {
})
console
.
log
(
listCF
)
this
.
createCashFlow
(
listCF
,
trigger
)
this
.
createCashFlow
(
listCF
)
}
createCashFlow
(
dbcf
,
trigger
)
{
createCashFlow
(
dbcf
)
{
let
payload
=
{
"submission_id"
:
this
.
props
.
submissionID
,
"company_id"
:
this
.
props
.
company
.
company_id
,
...
...
@@ -388,7 +388,7 @@ export default class CashFlow extends Component {
}
console
.
log
(
dbcf
)
console
.
log
(
JSON
.
stringify
(
payload
))
this
.
props
.
createCashFlow
(
payload
,
trigger
)
this
.
props
.
createCashFlow
(
payload
)
// this.props.onClickClose()
}
...
...
@@ -3340,29 +3340,6 @@ export default class CashFlow extends Component {
<
/button
>
<
/div
>
<
div
className
=
"col-2"
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
maxWidth
:
'100%'
}}
>
<
button
type
=
"button"
// disabled={this.state.buttonError}
onClick
=
{()
=>
// this.state.buttonError ?
// this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
// :
this
.
state
.
handleDoubleClick
==
1
?
null
:
this
.
setState
({
handleDoubleClick
:
1
},
()
=>
{
this
.
olahDataCashFlow
(
dataTable2
,
"simulasi"
)
})}
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
this
.
state
.
buttonError
===
true
?
'default'
:
'pointer'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
marginRight
:
15
}}
>
<
div
style
=
{{
backgroundColor
:
'#cd5c5c'
,
width
:
105
,
height
:
25
,
borderRadius
:
3
,
justifyContent
:
'center'
,
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#fff'
,
textAlign
:
'center'
}}
>
Save
Data
Simulasi
<
/Typography
>
<
/div
>
<
/button
>
{
this
.
props
.
isApprover
===
true
||
dataTable2
.
length
==
0
?
null
:
(
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
===
'SUBMIT'
||
this
.
props
.
lastStatus
===
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
)
?
<
button
...
...
src/container/BudgetTahunan/CorporateAnnualTarget.js
View file @
73e8675b
...
...
@@ -87,10 +87,8 @@ export default class CorporateAnnualTarget extends Component {
handleDataSalah
:
false
,
defaultCurrencyUpload
:
this
.
props
.
defaultCurrency
,
visibleAlertSave
:
false
,
visibleButtonUpload
:
false
}
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
this
.
fileHandlerSimulasi
=
this
.
fileHandlerSimulasi
.
bind
(
this
);
}
...
...
@@ -438,128 +436,6 @@ export default class CorporateAnnualTarget extends Component {
});
}
fileHandlerSimulasi
=
(
event
)
=>
{
let
fileObj
=
event
ExcelRenderer
(
fileObj
,
(
err
,
resp
)
=>
{
// // // // // console.log(resp)
if
(
err
)
{
// // // // console.log(err);
}
else
{
let
isi
=
resp
.
rows
.
slice
(
3
)
// // console.log(isi);
let
payload
=
[]
let
reg
=
/^
[
-+
]?(?:[
0-9
]
+,
)
*
[
0-9
]
+
(?:\.[
0-9
]
+
)?
$/
;
let
newValidate
=
false
isi
.
map
((
i
,
index
)
=>
{
if
(
i
.
length
>
0
)
{
let
total
=
0
let
lastValz
=
0
let
nilaiTotal
=
0
if
(
i
[
6
]
!==
undefined
)
{
if
(
i
[
6
]
==
'SUM'
||
i
[
6
]
==
'AVG'
||
i
[
6
]
==
'LAST'
)
{
i
.
map
((
items
,
indexs
)
=>
{
if
(
indexs
>=
8
&&
indexs
<=
19
)
{
let
valItem
=
items
==
undefined
||
items
==
""
?
0
:
items
total
+=
Number
(
valItem
)
if
(
index
==
19
)
{
lastValz
+=
Number
(
valItem
)
}
}
})
}
nilaiTotal
=
i
[
6
]
==
'SUM'
?
total
:
i
[
6
]
==
'AVG'
?
total
/
12
:
lastValz
}
if
(
String
(
i
[
1
]).
trim
().
toLocaleUpperCase
()
==
"CUSTOMER PERSPECTIVE"
)
{
newValidate
=
true
}
if
(
String
(
i
[
1
]).
trim
().
toLocaleUpperCase
()
==
"LEARNING & GROWTH PERSPECTIVE"
)
{
newValidate
=
false
}
if
(
i
[
0
]
===
undefined
||
i
[
0
]
===
null
)
{
if
(
newValidate
)
{
payload
.
push
({
item_report_id
:
i
[
0
]
===
undefined
?
0
:
reg
.
test
(
String
(
i
[
0
]))
===
false
?
0
:
String
(
i
[
0
]).
trim
(),
item_report
:
i
[
1
]
===
undefined
?
""
:
String
(
i
[
1
]).
trim
(),
weight
:
i
[
2
]
===
undefined
?
""
:
(
String
(
i
[
2
]).
includes
(
'%'
)
?
Number
(
String
(
i
[
2
]).
substr
(
0
,
String
(
i
[
2
]).
length
-
1
))
:
String
(
Number
(
i
[
2
]
*
100
).
toFixed
(
1
))
+
'%'
),
uom
:
i
[
3
]
===
undefined
?
""
:
String
(
i
[
3
]).
trim
(),
kpi_type
:
i
[
4
]
===
undefined
?
""
:
String
(
i
[
4
]).
trim
(),
max_ach
:
i
[
5
]
===
undefined
?
""
:
String
(
i
[
5
]).
toLocaleLowerCase
()
!==
'unlimited'
?
(
String
(
i
[
5
]).
includes
(
'%'
)
?
String
(
i
[
5
].
trim
())
:
String
(
Number
(
i
[
5
]
*
100
)
+
'%'
))
:
String
(
i
[
5
]).
trim
(),
formula
:
i
[
6
]
===
undefined
?
""
:
String
(
i
[
6
]).
trim
(),
total_actual_before
:
i
[
7
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
7
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
7
]),
1
)).
trim
(),
january
:
i
[
8
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
8
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
8
]),
1
)).
trim
(),
february
:
i
[
9
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
9
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
9
]),
1
)).
trim
(),
march
:
i
[
10
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
10
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
10
]),
1
)).
trim
(),
april
:
i
[
11
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
11
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
11
]),
1
)).
trim
(),
may
:
i
[
12
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
12
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
12
]),
1
)).
trim
(),
june
:
i
[
13
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
13
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
13
]),
1
)).
trim
(),
july
:
i
[
14
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
14
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
14
]),
1
)).
trim
(),
august
:
i
[
15
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
15
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
15
]),
1
)).
trim
(),
september
:
i
[
16
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
16
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
16
]),
1
)).
trim
(),
october
:
i
[
17
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
17
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
17
]),
1
)).
trim
(),
november
:
i
[
18
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
18
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
18
]),
1
)).
trim
(),
december
:
i
[
19
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
19
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
19
]),
1
)).
trim
(),
total_current_year
:
i
[
20
]
==
0
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
20
]),
1
)).
trim
(),
total_next_year
:
i
[
21
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
21
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
21
]),
1
)).
trim
(),
total_more_year
:
i
[
22
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
22
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
22
]),
1
)).
trim
(),
strategic
:
i
[
23
]
===
undefined
?
""
:
String
(
i
[
23
]).
trim
(),
pic
:
i
[
24
]
===
undefined
?
""
:
String
(
i
[
24
]).
trim
()
})
}
}
else
{
payload
.
push
({
item_report_id
:
i
[
0
]
===
undefined
?
0
:
reg
.
test
(
String
(
i
[
0
]))
===
false
?
0
:
String
(
i
[
0
]).
trim
(),
item_report
:
i
[
1
]
===
undefined
?
""
:
String
(
i
[
1
]).
trim
(),
weight
:
i
[
2
]
===
undefined
?
""
:
(
String
(
i
[
2
]).
includes
(
'%'
)
?
Number
(
String
(
i
[
2
]).
substr
(
0
,
String
(
i
[
2
]).
length
-
1
))
:
String
(
Number
(
i
[
2
]
*
100
).
toFixed
(
1
))
+
'%'
),
uom
:
i
[
3
]
===
undefined
?
""
:
String
(
i
[
3
]).
trim
(),
kpi_type
:
i
[
4
]
===
undefined
?
""
:
String
(
i
[
4
]).
trim
(),
max_ach
:
i
[
5
]
===
undefined
?
""
:
String
(
i
[
5
]).
toLocaleLowerCase
()
!==
'unlimited'
?
(
String
(
i
[
5
]).
includes
(
'%'
)
?
String
(
i
[
5
].
trim
())
:
String
(
Number
(
i
[
5
]
*
100
)
+
'%'
))
:
String
(
i
[
5
]).
trim
(),
formula
:
i
[
6
]
===
undefined
?
""
:
String
(
i
[
6
]).
trim
(),
total_actual_before
:
i
[
7
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
7
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
7
]),
1
)).
trim
(),
january
:
i
[
8
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
8
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
8
]),
1
)).
trim
(),
february
:
i
[
9
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
9
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
9
]),
1
)).
trim
(),
march
:
i
[
10
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
10
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
10
]),
1
)).
trim
(),
april
:
i
[
11
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
11
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
11
]),
1
)).
trim
(),
may
:
i
[
12
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
12
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
12
]),
1
)).
trim
(),
june
:
i
[
13
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
13
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
13
]),
1
)).
trim
(),
july
:
i
[
14
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
14
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
14
]),
1
)).
trim
(),
august
:
i
[
15
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
15
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
15
]),
1
)).
trim
(),
september
:
i
[
16
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
16
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
16
]),
1
)).
trim
(),
october
:
i
[
17
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
17
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
17
]),
1
)).
trim
(),
november
:
i
[
18
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
18
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
18
]),
1
)).
trim
(),
december
:
i
[
19
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
19
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
19
]),
1
)).
trim
(),
total_current_year
:
i
[
20
]
==
0
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
20
]),
1
)).
trim
(),
total_next_year
:
i
[
21
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
21
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
21
]),
1
)).
trim
(),
total_more_year
:
i
[
22
]
===
undefined
?
"0.0"
:
reg
.
test
(
String
(
i
[
22
]))
===
false
?
"0.0"
:
String
(
roundMath
(
Number
(
i
[
22
]),
1
)).
trim
(),
strategic
:
i
[
23
]
===
undefined
?
""
:
String
(
i
[
23
]).
trim
(),
pic
:
i
[
24
]
===
undefined
?
""
:
String
(
i
[
24
]).
trim
()
})
}
// // console.log(i[2])
// // // console.log(Number(i[2] * 100))
// // // // // console.log(i[2] === undefined ? "" : String(Number(i[2]*100)).length > 3? String(Number(i[2]*100).toFixed(0) + '%') : String(Number(i[2]*100)) + '%')
}
})
// // console.log(payload)
let
body
=
{
company_id
:
this
.
props
.
company
.
company_id
,
periode
:
this
.
props
.
periode
,
report_id
:
this
.
props
.
report_id
,
status
:
''
,
cat
:
payload
,
status
:
'submitted'
}
// // // // console.log(body)
this
.
setState
({
payload
:
body
,
judul
:
resp
.
rows
[
1
][
0
]
})
}
});
}
checkUpload
()
{
let
payload
=
{
...
this
.
state
.
payload
,
...
...
@@ -709,195 +585,6 @@ export default class CorporateAnnualTarget extends Component {
})
}
checkUploadSimulasi
()
{
let
payload
=
{
...
this
.
state
.
payload
,
currency_id
:
this
.
state
.
defaultCurrencyUpload
?.
id
}
this
.
setState
({
loading
:
true
,
dataTable
:
[]
})
let
dataDelete
=
this
.
state
.
dataDelete
api
.
create
().
getIdDeleteFromExcel
(
payload
).
then
((
response
)
=>
{
if
(
response
.
data
)
{
// // // // // console.log(response.data)
let
idDelete
=
response
.
data
.
data
.
item_report_id
if
(
idDelete
.
length
>
0
)
{
idDelete
.
map
((
item
,
index
)
=>
{
dataDelete
.
push
(
item
)
})
this
.
setState
({
dataDelete
})
}
}
})
console
.
log
(
payload
)
api
.
create
().
checkUploadMB
(
payload
).
then
(
response
=>
{
// // console.log(JSON.stringify(this.state.payload));
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
// this.setState({ visibleUpload: false, visibleCAT: false })
this
.
setState
({
visibleUpload
:
false
,
visibleCAT
:
false
,
visibleButtonUpload
:
true
})
let
dataTable
=
[]
let
custoId
=
0
let
bisnsId
=
0
let
dataDelete
=
this
.
state
.
dataDelete
let
dataFin
=
this
.
state
.
dataFin
let
dataLearn
=
this
.
state
.
dataLearn
let
newValidate
=
false
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
if
(
item
.
item_report
==
'CUSTOMER PERSPECTIVE'
)
{
custoId
=
item
.
item_report_id
}
if
(
item
.
item_report
==
'INTERNAL BUSINESS PROCESS PERSPECTIVE'
)
{
bisnsId
=
item
.
item_report_id
}
if
(
String
(
item
.
item_report
).
trim
().
toLocaleUpperCase
()
==
"CUSTOMER PERSPECTIVE"
)
{
newValidate
=
true
}
if
(
String
(
item
.
item_report
).
trim
().
toLocaleUpperCase
()
==
"LEARNING & GROWTH PERSPECTIVE"
)
{
newValidate
=
false
}
if
(
item
.
type_report_id
!==
4
&&
item
.
parent
!==
null
&&
(
item
.
parent
==
custoId
||
item
.
parent
==
bisnsId
))
{
let
indexCust
=
this
.
state
.
dataCustomerPrs
.
findIndex
((
val
)
=>
val
.
name
==
item
.
item_report
)
let
indexBisn
=
this
.
state
.
dataInternalBsn
.
findIndex
((
val
)
=>
val
.
name
==
item
.
item_report
)
if
(
indexCust
!==
-
1
&&
item
.
item_report_id
==
0
)
{
dataDelete
.
push
(
this
.
state
.
dataCustomerPrs
[
indexCust
].
id
)
}
if
(
indexBisn
!==
-
1
&&
item
.
item_report_id
==
0
)
{
dataDelete
.
push
(
this
.
state
.
dataInternalBsn
[
indexBisn
].
id
)
}
}
if
(
newValidate
==
false
)
{
let
indexIDx
=
dataFin
.
findIndex
((
val
)
=>
String
(
val
.
name
).
toLocaleLowerCase
()
==
String
(
item
.
item_report
).
toLocaleLowerCase
())
let
indexIDz
=
dataLearn
.
findIndex
((
val
)
=>
String
(
val
.
name
).
toLocaleLowerCase
()
==
String
(
item
.
item_report
).
toLocaleLowerCase
())
if
(
indexIDx
!=
-
1
)
{
dataFin
[
indexIDx
].
check
=
true
}
if
(
indexIDz
!=
-
1
)
{
dataLearn
[
indexIDz
].
check
=
true
}
}
dataTable
.
push
([
item
.
type_report_id
,
item
.
item_report_id
,
item
.
parent
,
item
.
formula
,
item
.
level
==
null
?
1
:
item
.
level
,
""
,
item
.
item_report
,
item
.
type_report_id
==
1
?
(
`
${
String
(
item
.
weight
).
includes
(
'%'
)
?
String
(
item
.
weight
)
:
String
((
Number
(
item
.
weight
)
*
100
)
+
'% '
)}
`
)
:
(
String
(
item
.
weight
)),
item
.
uom
,
item
.
kpi_type
==
""
||
item
.
kpi_type
==
null
?
null
:
{
value
:
item
.
kpi_type
},
item
.
max_ach
==
""
||
item
.
max_ach
==
null
?
null
:
{
value
:
titleCase
(
item
.
max_ach
)
},
item
.
formula_ytd
==
""
||
item
.
formula_ytd
==
null
?
null
:
{
value
:
item
.
formula_ytd
},
item
.
total_actual_before
==
""
?
item
.
total_actual_before
:
String
(
item
.
total_actual_before
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
total_actual_before
)
:
Number
(
item
.
total_actual_before
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
january
).
toFixed
(
1
)
:
{
value
:
item
.
january
,
formula
:
item
.
january_formula
}
:
item
.
january
==
""
?
item
.
january
:
String
(
item
.
january
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
january
)
:
Number
(
item
.
january
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
february
).
toFixed
(
1
)
:
{
value
:
item
.
february
,
formula
:
item
.
february_formula
}
:
item
.
february
==
""
?
item
.
february
:
String
(
item
.
february
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
february
)
:
Number
(
item
.
february
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
march
).
toFixed
(
1
)
:
{
value
:
item
.
march
,
formula
:
item
.
march_formula
}
:
item
.
march
==
""
?
item
.
march
:
String
(
item
.
march
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
march
)
:
Number
(
item
.
march
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
april
).
toFixed
(
1
)
:
{
value
:
item
.
april
,
formula
:
item
.
april_formula
}
:
item
.
april
==
""
?
item
.
april
:
String
(
item
.
april
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
april
)
:
Number
(
item
.
april
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
may
).
toFixed
(
1
)
:
{
value
:
item
.
may
,
formula
:
item
.
may_formula
}
:
item
.
may
==
""
?
item
.
may
:
String
(
item
.
may
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
may
)
:
Number
(
item
.
may
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
june
).
toFixed
(
1
)
:
{
value
:
item
.
june
,
formula
:
item
.
june_formula
}
:
item
.
june
==
""
?
item
.
june
:
String
(
item
.
june
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
june
)
:
Number
(
item
.
june
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
july
).
toFixed
(
1
)
:
{
value
:
item
.
july
,
formula
:
item
.
july_formula
}
:
item
.
july
==
""
?
item
.
july
:
String
(
item
.
july
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
july
)
:
Number
(
item
.
july
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
august
).
toFixed
(
1
)
:
{
value
:
item
.
august
,
formula
:
item
.
august_formula
}
:
item
.
august
==
""
?
item
.
august
:
String
(
item
.
august
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
august
)
:
Number
(
item
.
august
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
september
).
toFixed
(
1
)
:
{
value
:
item
.
september
,
formula
:
item
.
september_formula
}
:
item
.
september
==
""
?
item
.
september
:
String
(
item
.
september
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
september
)
:
Number
(
item
.
september
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
october
).
toFixed
(
1
)
:
{
value
:
item
.
october
,
formula
:
item
.
october_formula
}
:
item
.
october
==
""
?
item
.
october
:
String
(
item
.
october
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
october
)
:
Number
(
item
.
october
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
november
).
toFixed
(
1
)
:
{
value
:
item
.
november
,
formula
:
item
.
november_formula
}
:
item
.
november
==
""
?
item
.
november
:
String
(
item
.
november
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
november
)
:
Number
(
item
.
november
).
toFixed
(
1
),
item
.
parent_name
==
"FINANCIAL PERSPECTIVE"
?
item
.
type_report_id
==
3
?
Number
(
item
.
december
).
toFixed
(
1
)
:
{
value
:
item
.
december
,
formula
:
item
.
december_formula
}
:
item
.
december
==
""
?
item
.
december
:
String
(
item
.
december
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
december
)
:
Number
(
item
.
december
).
toFixed
(
1
),
item
.
total_current_year
===
"NaN"
?
"0.0"
:
item
.
total_current_year
==
""
?
item
.
total_current_year
:
String
(
item
.
total_current_year
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
total_current_year
)
:
Number
(
item
.
total_current_year
).
toFixed
(
1
),
item
.
total_next_year
==
""
?
item
.
total_next_year
:
String
(
item
.
total_next_year
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
total_next_year
)
:
Number
(
item
.
total_next_year
).
toFixed
(
1
),
item
.
total_more_year
==
""
?
item
.
total_more_year
:
String
(
item
.
total_more_year
).
indexOf
(
"."
)
==
-
1
?
Number
(
item
.
total_more_year
)
:
Number
(
item
.
total_more_year
).
toFixed
(
1
),
item
.
strategic
,
item
.
pic
,
item
.
forecast_formula
,
item
.
orders
,
item
.
error
])
})
let
checkDataFin
=
dataFin
.
filter
((
val
)
=>
val
.
check
==
false
)
let
checkDataLearn
=
dataLearn
.
filter
((
val
)
=>
val
.
check
==
false
)
let
handleDataSalah
=
this
.
state
.
handleDataSalah
if
(
checkDataFin
.
length
>
0
||
checkDataLearn
.
length
>
0
)
{
handleDataSalah
=
true
}
// // console.log(indexCheck)
// // // // console.log(this.state.buttonError)
console
.
log
(
dataTable
)
this
.
setState
({
dataTable
,
dataLoaded
:
true
,
loading
:
false
,
buttonError
:
false
,
editable
:
true
,
dataDelete
,
handleDataSalah
},
()
=>
{
this
.
state
.
dataTable
.
map
(
item
=>
{
if
(
item
[
30
].
length
>
0
)
{
// // // // console.log('masuk')
this
.
setState
({
buttonError
:
true
,
errorPreview
:
true
,
editable
:
true
})
}
})
// // // // // console.log(this.state.dataTable);
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
uploadSimulasi
(
type
)
{
let
payload
=
{
...
this
.
state
.
payload
,
currency_id
:
this
.
state
.
defaultCurrencyUpload
?.
id
}
this
.
setState
({
loading
:
true
,
dataTable
:
[]
})
// let dataDelete = this.state.dataDelete
// api.create().getIdDeleteFromExcel(payload).then((response) => {
// if (response.data) {
// // // // // // console.log(response.data)
// let idDelete = response.data.data.item_report_id
// if (idDelete.length > 0) {
// idDelete.map((item, index) => {
// dataDelete.push(item)
// })
// this.setState({ dataDelete })
// }
// }
// })
console
.
log
(
payload
)
api
.
create
().
uploadSimulasiMB
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
props
.
getReport
(
'CAT'
)
this
.
props
.
onClickClose
()
this
.
setState
({
loading
:
false
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
'Error saving data. Please try again'
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
uploadCAT
(
type
)
{
// let dataDelete = this.state.dataDelete
// // // // console.log(dataDelete)
...
...
@@ -912,99 +599,6 @@ export default class CorporateAnnualTarget extends Component {
}
uploadSimulasi
(
type
)
{
// let dataDelete = this.state.dataDelete
// // // // console.log(dataDelete)
let
payload
=
{
"item_report_id"
:
this
.
state
.
dataDelete
}
if
(
this
.
state
.
dataDelete
.
length
>
0
)
{
api
.
create
().
deleteAllItemReport
(
payload
).
then
((
response
)
=>
{
this
.
functionUploadSimulasi
(
type
)
})
}
else
{
this
.
functionUploadSimulasi
(
type
)
}
}
functionUploadSimulasi
(
type
)
{
let
data
=
[]
let
stateFR
=
false
// // // console.log(this.state.dataTable)
this
.
state
.
dataTable
.
map
(
i
=>
{
if
(
i
[
2
]
!==
null
)
{
let
indexID
=
this
.
state
.
dataTable
.
findIndex
((
val
)
=>
val
[
1
]
==
i
[
2
])
if
(
indexID
!==
-
1
)
{
if
(
this
.
state
.
dataTable
[
indexID
][
6
]
===
'FINANCIAL PERSPECTIVE'
)
{
stateFR
=
true
}
else
{
stateFR
=
false
}
}
}
else
{
stateFR
=
false
}
data
.
push
({
"item_report_id"
:
i
[
1
]
==
""
||
i
[
1
]
==
null
?
0
:
i
[
1
],
"item_report"
:
String
(
i
[
6
]),
"weight"
:
String
(
i
[
7
]),
"uom"
:
String
(
i
[
8
]),
"kpi_type"
:
i
[
9
]
==
null
?
""
:
i
[
9
].
value
,
"max_ach"
:
i
[
10
]
==
null
?
""
:
i
[
10
].
value
,
"formula"
:
i
[
11
]
==
null
?
""
:
i
[
11
].
value
,
"total_actual_before"
:
String
(
i
[
12
])
==
""
?
"0.0"
:
String
(
i
[
12
]),
"january"
:
i
[
13
].
value
!=
undefined
?
String
(
Number
(
i
[
13
].
value
).
toFixed
(
1
))
:
String
(
i
[
13
]),
"february"
:
i
[
14
].
value
!=
undefined
?
String
(
Number
(
i
[
14
].
value
).
toFixed
(
1
))
:
String
(
i
[
14
]),
"march"
:
i
[
15
].
value
!=
undefined
?
String
(
Number
(
i
[
15
].
value
).
toFixed
(
1
))
:
String
(
i
[
15
]),
"april"
:
i
[
16
].
value
!=
undefined
?
String
(
Number
(
i
[
16
].
value
).
toFixed
(
1
))
:
String
(
i
[
16
]),
"may"
:
i
[
17
].
value
!=
undefined
?
String
(
Number
(
i
[
17
].
value
).
toFixed
(
1
))
:
String
(
i
[
17
]),
"june"
:
i
[
18
].
value
!=
undefined
?
String
(
Number
(
i
[
18
].
value
).
toFixed
(
1
))
:
String
(
i
[
18
]),
"july"
:
i
[
19
].
value
!=
undefined
?
String
(
Number
(
i
[
19
].
value
).
toFixed
(
1
))
:
String
(
i
[
19
]),
"august"
:
i
[
20
].
value
!=
undefined
?
String
(
Number
(
i
[
20
].
value
).
toFixed
(
1
))
:
String
(
i
[
20
]),
"september"
:
i
[
21
].
value
!=
undefined
?
String
(
Number
(
i
[
21
].
value
).
toFixed
(
1
))
:
String
(
i
[
21
]),
"october"
:
i
[
22
].
value
!=
undefined
?
String
(
Number
(
i
[
22
].
value
).
toFixed
(
1
))
:
String
(
i
[
22
]),
"november"
:
i
[
23
].
value
!=
undefined
?
String
(
Number
(
i
[
23
].
value
).
toFixed
(
1
))
:
String
(
i
[
23
]),
"december"
:
i
[
24
].
value
!=
undefined
?
String
(
Number
(
i
[
24
].
value
).
toFixed
(
1
))
:
String
(
i
[
24
]),
"total_current_year"
:
String
(
Number
(
i
[
25
]).
toFixed
(
1
))
==
""
?
"0.0"
:
String
(
Number
(
i
[
25
]).
toFixed
(
1
)),
"total_next_year"
:
String
(
Number
(
i
[
26
]).
toFixed
(
1
))
==
""
?
"0.0"
:
String
(
Number
(
i
[
26
]).
toFixed
(
1
)),
"total_more_year"
:
String
(
Number
(
i
[
27
]).
toFixed
(
1
))
==
""
?
"0.0"
:
String
(
Number
(
i
[
27
]).
toFixed
(
1
)),
"strategic"
:
String
(
i
[
28
]),
"pic"
:
String
(
i
[
29
])
})
})
let
body
=
{
"report_id"
:
this
.
props
.
report_id
,
// "revision": Number(this.props.revision),
"periode"
:
this
.
props
.
periode
,
"company_id"
:
this
.
props
.
company
.
company_id
,
"submission_id"
:
this
.
props
.
submissionID
,
"currency_id"
:
this
.
state
.
defaultCurrencyUpload
?.
id
,
"status"
:
type
,
"cat"
:
data
}
// // console.log(data);
// // console.log(JSON.stringify(body))
api
.
create
(
'UPLOAD'
).
uploadSimulasiMB
(
body
).
then
(
response
=>
{
console
.
log
(
response
);
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
props
.
getReport
(
body
,
'CAT'
)
this
.
setState
({
loading
:
false
})
this
.
props
.
onClickClose
()
// this.props.getReport()
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
'Error saving data. Please try again'
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
functionUpload
(
type
)
{
let
data
=
[]
let
stateFR
=
false
...
...
@@ -4191,28 +3785,11 @@ export default class CorporateAnnualTarget extends Component {
}
<
/div
>
<
div
style
=
{{
width
:
'50%'
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
}}
>
<
ReactTooltip
border
=
{
true
}
id
=
"template"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
a
data
-
tip
=
{
'Upload Simulasi'
}
data
-
for
=
"upload"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
setState
({
visibleUploadSimulasi
:
true
,
buttonDraft
:
true
})}
>
<
img
src
=
{
Images
.
simulasiUpload
}
style
=
{{
width
:
40
,
height
:
40
,
marginRight
:
3
}}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"upload"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
this
.
state
.
dataTable
.
length
==
0
?
null
:
this
.
props
.
isApprover
==
true
?
null
:
<
div
style
=
{{
justifyContent
:
'flex-end'
,
display
:
'flex'
,
flexFlow
:
'wrap'
}}
>
{
/* <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload Simulasi'} data-for="upload">
{
this
.
state
.
dataTable
.
length
==
0
?
null
:
this
.
props
.
isApprover
==
true
?
null
:
<
div
style
=
{{
justifyContent
:
'flex-end'
,
display
:
'flex'
,
flexFlow
:
'wrap'
}}
>
{((
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
==
'SUBMIT'
||
this
.
props
.
lastStatus
==
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
))
&&
<
a
data
-
tip
=
{
'Download Template'
}
data
-
for
=
"template"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
...
...
@@ -4220,41 +3797,27 @@ export default class CorporateAnnualTarget extends Component {
borderColor
:
'transparent'
,
margin
:
5
}}
onClick={() => this.
setState({ visibleUploadSimulasi: true, buttonDraft: true }
)}
onClick
=
{()
=>
this
.
downloadTemplate
(
)}
>
<img src={Images.
simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }
} />
<
img
src
=
{
Images
.
template
}
/
>
<
/button
>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" /> */
}
{((
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
==
'SUBMIT'
||
this
.
props
.
lastStatus
==
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
))
&&
<
a
data
-
tip
=
{
'Download Template'
}
data
-
for
=
"template"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
downloadTemplate
()}
>
<
img
src
=
{
Images
.
template
}
/
>
<
/button
>
<
/a>
}
<
ReactTooltip
border
=
{
true
}
id
=
"template"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{((
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
==
'SUBMIT'
||
this
.
props
.
lastStatus
==
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
))
&&
<
a
data
-
tip
=
{
'Upload'
}
data
-
for
=
"upload"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
setState
({
visibleUpload
:
true
,
buttonDraft
:
true
})}
>
<
img
src
=
{
Images
.
upload
}
/
>
<
/button
>
<
/a>
}
<
ReactTooltip
border
=
{
true
}
id
=
"upload"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
/* <a data-tip={'Download'} data-for="download">
<
/a>
}
<
ReactTooltip
border
=
{
true
}
id
=
"template"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{((
!
this
.
props
.
truelyApprover
)
&&
(
this
.
props
.
lastStatus
==
'SUBMIT'
||
this
.
props
.
lastStatus
==
'REVISION'
)
&&
this
.
props
.
prevRevision
===
false
&&
(
this
.
props
.
status
===
'revision'
||
this
.
props
.
status
===
'not-yet'
||
this
.
props
.
status
===
'draft'
||
this
.
props
.
status
===
'submitted'
))
&&
<
a
data
-
tip
=
{
'Upload'
}
data
-
for
=
"upload"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
setState
({
visibleUpload
:
true
,
buttonDraft
:
true
})}
>
<
img
src
=
{
Images
.
upload
}
/
>
<
/button
>
<
/a>
}
<
ReactTooltip
border
=
{
true
}
id
=
"upload"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
/* <a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
...
...
@@ -4273,9 +3836,8 @@ export default class CorporateAnnualTarget extends Component {
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */
}
<
/div
>
}
<
/div
>
<
/div
>
}
<
/div
>
<
/div
>
...
...
@@ -4565,76 +4127,6 @@ export default class CorporateAnnualTarget extends Component {
)
}
{
this
.
state
.
visibleUploadSimulasi
&&
(
<
div
className
=
"test app-popup-show"
>
<
div
className
=
"popup-content background-white border-radius"
style
=
{{
borderRadius
:
8
}}
>
<
div
className
=
"popup-panel grid grid-2x main-color"
style
=
{{
height
:
64
,
borderTopRightRadius
:
8
,
borderTopLeftRadius
:
8
}}
>
<
div
className
=
"col-1"
style
=
{{
maxWidth
:
"inherit"
,
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
div
className
=
"popup-title"
>
<
span
style
=
{{
color
:
'#fff'
,
fontSize
:
16
,
fontWeight
:
'bold'
}}
>
Upload
File
Simulasi
<
/span
>
<
/div
>
<
/div
>
<
div
className
=
"col-2 content-right"
style
=
{{
maxWidth
:
"inherit"
,
alignSelf
:
'center'
}}
>
<
button
type
=
"button"
className
=
"btn btn-circle btn-white"
onClick
=
{()
=>
this
.
setState
({
visibleUploadSimulasi
:
false
})}
>
<
img
src
=
{
Images
.
close
}
/
>
<
/button
>
<
/div
>
<
/div
>
<
div
style
=
{{
padding
:
'25px 30px'
}}
>
<
UploadFile
type
=
{
this
.
state
.
uploadStatusSimulasi
}
percentage
=
{
this
.
state
.
percentageSimulasi
}
result
=
{
this
.
state
.
resultSimulasi
}
acceptedFiles
=
{[
"xlsx"
]}
onHandle
=
{(
dt
)
=>
{
this
.
fileHandlerSimulasi
(
dt
)
this
.
setState
({
uploadStatusSimulasi
:
'idle'
,
percentageSimulasi
:
'0'
})
}}
onUpload
=
{()
=>
{
String
(
this
.
state
.
judul
).
includes
(
"MASTER"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"BUDGET"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"CAT"
)
?
this
.
checkUploadSimulasi
()
:
this
.
setState
({
alert
:
true
,
messageAlert
:
"Invalid Template"
,
tipeAlert
:
'warning'
})
}}
/
>
<
/div
>
{
this
.
state
.
visibleButtonUpload
&&
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
margin
:
'0px 32px 16px'
}}
>
<
div
>
<
button
type
=
"button"
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
outline
:
'none'
}}
onClick
=
{()
=>
this
.
setState
({
handleDoubleClick
:
1
},
()
=>
{
setTimeout
(()
=>
{
this
.
uploadSimulasi
(
"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
>
}
{
/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> (Simulasi) Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */
}
<
/div
>
<
/div
>
)
}
{
this
.
state
.
visibleAlertSave
&&
(
<
div
className
=
"test app-popup-show"
>
...
...
src/container/BudgetTahunan/FixedAssetsMovement.js
View file @
73e8675b
...
...
@@ -51,11 +51,9 @@ export default class FixedAssetsMovement extends Component {
handleDoubleClick
:
0
,
defaultCurrencyUpload
:
this
.
props
.
defaultCurrency
,
visibleAlertSave
:
false
,
visibleButtonUpload
:
false
}
this
.
handleValue
=
this
.
handleValue
.
bind
(
this
)
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
this
.
fileHandlerSimulasi
=
this
.
fileHandlerSimulasi
.
bind
(
this
);
}
componentDidMount
()
{
...
...
@@ -340,55 +338,6 @@ export default class FixedAssetsMovement extends Component {
});
}
fileHandlerSimulasi
=
(
event
)
=>
{
let
fileObj
=
event
ExcelRenderer
(
fileObj
,
(
err
,
resp
)
=>
{
// // console.log(resp)
if
(
err
)
{
// console.log(err);
}
else
{
let
isi
=
resp
.
rows
.
slice
(
3
)
// // console.log(resp.rows[2]);
let
payload
=
[]
let
reg
=
/^
[
-+
]?(?:[
0-9
]
+,
)
*
[
0-9
]
+
(?:\.[
0-9
]
+
)?
$/
;
isi
.
map
((
i
,
index
)
=>
{
if
(
i
.
length
>
0
)
{
payload
.
push
({
item_report_id
:
i
[
0
]
===
undefined
?
""
:
String
(
i
[
0
]).
trim
(),
item_report
:
i
[
1
]
===
undefined
?
""
:
String
(
i
[
1
]).
trim
(),
total_actual_before
:
i
[
2
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
2
]))
===
false
?
"0"
:
String
(
i
[
2
]).
trim
(),
january
:
i
[
3
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
3
]))
===
false
?
"0"
:
String
(
i
[
3
]).
trim
(),
february
:
i
[
4
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
4
]))
===
false
?
"0"
:
String
(
i
[
4
]).
trim
(),
march
:
i
[
5
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
5
]))
===
false
?
"0"
:
String
(
i
[
5
]).
trim
(),
april
:
i
[
6
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
6
]))
===
false
?
"0"
:
String
(
i
[
6
]).
trim
(),
may
:
i
[
7
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
7
]))
===
false
?
"0"
:
String
(
i
[
7
]).
trim
(),
june
:
i
[
8
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
8
]))
===
false
?
"0"
:
String
(
i
[
8
]).
trim
(),
july
:
i
[
9
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
9
]))
===
false
?
"0"
:
String
(
i
[
9
]).
trim
(),
august
:
i
[
10
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
10
]))
===
false
?
"0"
:
String
(
i
[
10
]).
trim
(),
september
:
i
[
11
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
11
]))
===
false
?
"0"
:
String
(
i
[
11
]).
trim
(),
october
:
i
[
12
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
12
]))
===
false
?
"0"
:
String
(
i
[
12
]).
trim
(),
november
:
i
[
13
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
13
]))
===
false
?
"0"
:
String
(
i
[
13
]).
trim
(),
december
:
i
[
14
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
14
]))
===
false
?
"0"
:
String
(
i
[
14
]).
trim
(),
total_current_year
:
i
[
15
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
15
]))
===
false
?
"0"
:
String
(
i
[
15
]).
trim
(),
total_next_year
:
i
[
16
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
16
]))
===
false
?
"0"
:
String
(
i
[
16
]).
trim
(),
total_more_year
:
i
[
17
]
===
undefined
?
"0"
:
reg
.
test
(
String
(
i
[
17
]))
===
false
?
"0"
:
String
(
i
[
17
]).
trim
()
})
}
})
let
body
=
{
company_id
:
this
.
props
.
company
.
company_id
,
periode
:
this
.
props
.
periode
,
report_id
:
this
.
props
.
report_id
,
fixed_asset_movement
:
payload
,
status
:
'submitted'
}
// // console.log(body)
this
.
setState
({
payload
:
body
,
judul
:
resp
.
rows
[
1
][
0
],
judulColumn
:
resp
.
rows
[
2
]
})
}
});
}
checkUpload
()
{
let
payload
=
{
...
this
.
state
.
payload
,
...
...
@@ -459,128 +408,6 @@ export default class FixedAssetsMovement extends Component {
})
}
checkUploadSimulasi
()
{
let
payload
=
{
...
this
.
state
.
payload
,
currency_id
:
this
.
state
.
defaultCurrencyUpload
?.
id
}
api
.
create
().
checkUploadMB
(
payload
).
then
(
response
=>
{
// // console.log(JSON.stringify(this.state.payload));
// // console.log(response)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
setState
({
visibleUpload
:
false
,
visibleFixedAssetsMovement
:
false
,
loading
:
true
,
visibleButtonUpload
:
true
})
let
dataTable
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
return
[
item
.
type_report_id
,
item
.
item_report_id
,
item
.
parent
,
item
.
formula
,
item
.
level
,
item
.
item_report
,
item
.
total_actual_before
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
january
,
formula
:
item
.
january_formula
}
:
Number
(
item
.
january
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
february
,
formula
:
item
.
february_formula
}
:
Number
(
item
.
february
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
march
,
formula
:
item
.
march_formula
}
:
Number
(
item
.
march
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
april
,
formula
:
item
.
april_formula
}
:
Number
(
item
.
april
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
may
,
formula
:
item
.
may_formula
}
:
Number
(
item
.
may
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
june
,
formula
:
item
.
june_formula
}
:
Number
(
item
.
june
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
july
,
formula
:
item
.
july_formula
}
:
Number
(
item
.
july
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
august
,
formula
:
item
.
august_formula
}
:
Number
(
item
.
august
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
september
,
formula
:
item
.
september_formula
}
:
Number
(
item
.
september
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
october
,
formula
:
item
.
october_formula
}
:
Number
(
item
.
october
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
november
,
formula
:
item
.
november_formula
}
:
Number
(
item
.
november
).
toFixed
(
1
),
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
?
{
value
:
item
.
december
,
formula
:
item
.
december_formula
}
:
Number
(
item
.
december
).
toFixed
(
1
),
Number
(
item
.
total_current_year
).
toFixed
(
1
),
Number
(
item
.
total_next_year
).
toFixed
(
1
),
Number
(
item
.
total_more_year
).
toFixed
(
1
),
item
.
orders
,
item
.
forecast_formula
,
item
.
before_formula
,
item
.
error
]
})
this
.
setState
({
dataTable
,
dataLoaded
:
true
,
loading
:
false
,
buttonError
:
false
,
editable
:
true
},
()
=>
{
this
.
state
.
dataTable
.
map
(
item
=>
{
if
(
item
[
24
].
length
>
0
)
{
// // console.log('masuk')
this
.
setState
({
buttonError
:
true
,
errorPreview
:
true
,
editable
:
true
})
}
})
// // console.log(this.state.dataTable);
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
})
}
uploadSimulasi
(
type
)
{
let
data
=
[]
this
.
state
.
dataTable
.
map
(
i
=>
{
data
.
push
({
item_report_id
:
i
[
1
],
total_actual_before
:
String
(
Number
(
i
[
6
]).
toFixed
(
1
)),
january
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
7
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
7
]).
toFixed
(
1
)),
february
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
8
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
8
]).
toFixed
(
1
)),
march
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
9
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
9
]).
toFixed
(
1
)),
april
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
10
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
10
]).
toFixed
(
1
)),
may
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
11
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
11
]).
toFixed
(
1
)),
june
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
12
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
12
]).
toFixed
(
1
)),
july
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
13
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
13
]).
toFixed
(
1
)),
august
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
14
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
14
]).
toFixed
(
1
)),
september
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
15
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
15
]).
toFixed
(
1
)),
october
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
16
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
16
]).
toFixed
(
1
)),
november
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
17
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
17
]).
toFixed
(
1
)),
december
:
i
[
0
]
===
5
||
i
[
0
]
===
6
?
String
(
Number
(
i
[
18
].
value
).
toFixed
(
1
))
:
String
(
Number
(
i
[
18
]).
toFixed
(
1
)),
total_current_year
:
String
(
Number
(
i
[
19
]).
toFixed
(
1
)),
total_next_year
:
String
(
Number
(
i
[
20
]).
toFixed
(
1
)),
total_more_year
:
String
(
Number
(
i
[
21
]).
toFixed
(
1
))
})
})
let
body
=
{
submission_id
:
this
.
props
.
submissionID
,
company_id
:
this
.
props
.
company
.
company_id
,
periode
:
this
.
props
.
periode
,
report_id
:
this
.
props
.
report_id
,
currency_id
:
this
.
state
.
defaultCurrencyUpload
?.
id
,
fixed_asset_movement
:
data
,
status
:
type
}
console
.
log
(
body
)
api
.
create
().
uploadSimulasiMB
(
body
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
props
.
onClickClose
()
this
.
props
.
getReport
(
'FAM'
)
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
'Error saving data. Please try again'
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
uploadFAM
(
type
)
{
console
.
log
(
"masuk ga?"
);
let
data
=
[]
...
...
@@ -2816,22 +2643,6 @@ export default class FixedAssetsMovement extends Component {
}
<
/div
>
<
div
style
=
{{
width
:
'50%'
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
}}
>
<
ReactTooltip
border
=
{
true
}
id
=
"template"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
a
data
-
tip
=
{
'Upload Simulasi'
}
data
-
for
=
"upload"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
margin
:
5
}}
onClick
=
{()
=>
this
.
setState
({
visibleUploadSimulasi
:
true
,
buttonDraft
:
true
})}
>
<
img
src
=
{
Images
.
simulasiUpload
}
style
=
{{
width
:
40
,
height
:
40
,
marginRight
:
3
}}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"upload"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
this
.
state
.
dataTable
.
length
==
0
?
null
:
this
.
props
.
isApprover
==
true
?
null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
...
...
@@ -2914,7 +2725,6 @@ export default class FixedAssetsMovement extends Component {
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */
}
<
/div
>
}
<
/div
>
<
/div
>
<
/div
>
...
...
@@ -3206,73 +3016,6 @@ export default class FixedAssetsMovement extends Component {
<
/div
>
)}
{
this
.
state
.
visibleUploadSimulasi
&&
(
<
div
className
=
"test app-popup-show"
>
<
div
className
=
"popup-content background-white border-radius"
style
=
{{
borderRadius
:
8
}}
>
<
div
className
=
"popup-panel grid grid-2x main-color"
style
=
{{
height
:
64
,
borderTopRightRadius
:
8
,
borderTopLeftRadius
:
8
}}
>
<
div
className
=
"col-1"
style
=
{{
maxWidth
:
"inherit"
,
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
div
className
=
"popup-title"
>
<
span
style
=
{{
color
:
'#fff'
,
fontSize
:
16
,
fontWeight
:
'bold'
}}
>
Upload
File
Simulasi
<
/span
>
<
/div
>
<
/div
>
<
div
className
=
"col-2 content-right"
style
=
{{
maxWidth
:
"inherit"
,
alignSelf
:
'center'
}}
>
<
button
type
=
"button"
className
=
"btn btn-circle btn-white"
onClick
=
{()
=>
this
.
setState
({
visibleUploadSimulasi
:
false
})}
>
<
img
src
=
{
Images
.
close
}
/
>
<
/button
>
<
/div
>
<
/div
>
<
div
style
=
{{
padding
:
'25px 30px'
}}
>
<
UploadFile
type
=
{
this
.
state
.
uploadStatusSimulasi
}
percentage
=
{
this
.
state
.
percentageSimulasi
}
result
=
{
this
.
state
.
resultSimulasi
}
acceptedFiles
=
{[
"xlsx"
]}
onHandle
=
{(
dt
)
=>
{
this
.
fileHandlerSimulasi
(
dt
)
this
.
setState
({
uploadStatusSimulasi
:
'idle'
,
percentageSimulasi
:
'0'
})
}}
onUpload
=
{()
=>
{
String
(
this
.
state
.
judul
).
includes
(
"MASTER"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"BUDGET"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"FIXED"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"ASSETS"
)
&&
String
(
this
.
state
.
judul
).
includes
(
"MOVEMENT"
)
?
this
.
checkUploadSimulasi
()
:
this
.
setState
({
alert
:
true
,
messageAlert
:
"Invalid Template"
,
tipeAlert
:
'warning'
})
}}
/
>
<
/div
>
{
this
.
state
.
visibleButtonUpload
&&
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
margin
:
'0px 32px 16px'
}}
>
<
div
>
<
button
type
=
"button"
// disabled={this.state.buttonError}
onClick
=
{()
=>
this
.
setState
({
handleDoubleClick
:
1
,
loading
:
true
},
()
=>
{
this
.
uploadSimulasi
(
'submitted'
)
})}
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
}}
>
<
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
Data
<
/Typography
>
<
/div
>
<
/button
>
<
/div
>
<
/div
>
}
{
/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */
}
<
/div
>
<
/div
>
)}
{
this
.
state
.
visibleAlertSave
&&
(
<
div
className
=
"test app-popup-show"
>
<
div
className
=
"popup-content border-radius"
style
=
{{
background
:
'#FFF27D'
,
borderRadius
:
10
,
width
:
715
,
height
:
238
}}
>
...
...
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