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
a8a9582a
Commit
a8a9582a
authored
Apr 14, 2021
by
d.arizona
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create db profitlos olPA
parent
40940c40
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
588 additions
and
77 deletions
+588
-77
index.js
src/api/index.js
+6
-2
OutlookPA.js
src/container/OutlookPA.js
+503
-4
ProfitLossOLPA.js
src/container/OutlookPA/ProfitLossOLPA.js
+79
-71
No files found.
src/api/index.js
View file @
a8a9582a
...
...
@@ -361,7 +361,9 @@ const create = (type = "") => {
const
createPeriodeRevisionOLPA
=
(
body
)
=>
api
.
post
(
'transaction/outlook_pa/create_periode_revision'
,
body
)
const
getHierarkiCFOLPA
=
(
body
)
=>
api
.
post
(
'transaction/cash_flow/outlook_pa/get_report_hierarki'
,
body
)
const
createCFOLPA
=
(
body
)
=>
api
.
post
(
'transaction/cash_flow/outlook_pa/create_outlook_report'
,
body
)
const
getHierarkiDBPLOLPA
=
(
body
)
=>
api
.
post
(
'transaction/db_profit_loss/outlook_pa/get_report_hierarki'
,
body
)
const
createDBPLOLPA
=
(
body
)
=>
api
.
post
(
'transaction/db_profit_loss/outlook_pa/create_outlook_report'
,
body
)
// Monthly
const
getMonthlyReport
=
(
body
)
=>
api
.
post
(
'transaction/monthly_report/get_all_report'
,
body
)
const
submitMonthlyReport
=
(
body
)
=>
api
.
post
(
'transaction/monthly_report/submit_monthly_report'
,
body
)
...
...
@@ -792,7 +794,9 @@ const create = (type = "") => {
getRollingOutlookCF
,
createRollingOutlookCF
,
getHierarkiCFOLPA
,
createCFOLPA
createCFOLPA
,
getHierarkiDBPLOLPA
,
createDBPLOLPA
}
}
...
...
src/container/OutlookPA.js
View file @
a8a9582a
...
...
@@ -18,6 +18,7 @@ import { DatePicker } from '@material-ui/pickers';
import
BalanceSheetOLPA
from
'./OutlookPA/BalanceSheetOLPA'
;
import
moment
from
'moment'
;
import
CorporateAnnualTargetOLPA
from
'./OutlookPA/CorporateAnnualTargetOLPA'
;
import
*
as
R
from
'ramda'
var
ct
=
require
(
"../library/CustomTable"
);
const
getMuiTheme
=
()
=>
createMuiTheme
(
ct
.
customTable
());
...
...
@@ -67,7 +68,8 @@ export default class OutlookPA extends Component {
btnApprove
:
false
,
listStatus
:
[],
selectedStatus
:
[],
prevRevision
:
false
prevRevision
:
false
,
dbPL
:
[]
}
this
.
myRef
=
React
.
createRef
()
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
...
...
@@ -456,7 +458,7 @@ export default class OutlookPA extends Component {
})
}
getOutlookPAID
()
{
getOutlookPAID
(
type
)
{
this
.
setState
({
loading
:
true
})
let
payload
=
{
"company_id"
:
this
.
state
.
company
.
company_id
,
...
...
@@ -478,6 +480,12 @@ export default class OutlookPA extends Component {
// console.log(this.state.lastStatus);
this
.
historyApproval
()
this
.
getLatestPeriodSubmit
()
if
(
type
!=
undefined
&&
type
==
'PL'
)
{
// this.getCashFlow(type)
this
.
getPL
(
type
)
}
else
{
this
.
setState
({
loading
:
false
})
}
api
.
create
().
checkApproverOLPA
().
then
(
response
=>
{
// console.log(response);
if
(
response
.
data
.
data
.
is_approver
===
true
)
{
...
...
@@ -698,14 +706,14 @@ export default class OutlookPA extends Component {
this
.
setState
({
alert
:
false
})
}
saveToOLPA
(
data
)
{
saveToOLPA
(
data
,
type
)
{
this
.
setState
({
loading
:
true
})
// console.log(JSON.stringify(data));
api
.
create
(
'UPLOAD'
).
createReportOLPA
(
data
).
then
(
response
=>
{
console
.
log
(
response
);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getOutlookPAID
()
this
.
getOutlookPAID
(
type
)
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
,
handleTekTekTek
:
0
},
()
=>
{
document
.
body
.
style
.
overflow
=
'unset'
;
...
...
@@ -793,6 +801,497 @@ export default class OutlookPA extends Component {
}
getPL
(
type
)
{
let
PLID
=
null
let
payloadID
=
{
"periode"
:
this
.
state
.
periode
.
periode
,
"company_id"
:
this
.
state
.
company
.
company_id
}
console
.
log
(
payloadID
);
api
.
create
().
getPLID
(
payloadID
).
then
(
response
=>
{
console
.
log
(
response
);
if
(
response
)
{
PLID
=
response
.
data
.
data
==
null
?
null
:
response
.
data
.
data
.
profit_loss_id
}
else
{
PLID
=
null
}
this
.
setState
({
PLID
},
()
=>
{
let
payload
=
{
"report_id"
:
28
,
"revision"
:
Number
(
this
.
state
.
lastRevision
),
"periode"
:
this
.
state
.
periode
.
periode
,
"company_id"
:
this
.
state
.
company
.
company_id
,
"submission_id"
:
this
.
state
.
PLID
,
}
api
.
create
().
getHierarkiDBPLOLPA
(
payload
).
then
(
response
=>
{
// console.log(response);
let
dataTable
=
[]
if
(
response
.
data
)
{
// let dataTable = []
console
.
log
(
response
)
let
res
=
response
.
data
.
data
const
handlePushChild
=
(
item
)
=>
{
dataTable
.
push
([
item
.
type_report_id
,
item
.
id
,
item
.
parent
,
item
.
formula
,
item
.
level
,
item
.
description
,
item
.
profit_detail_outlook
.
total_actual_before
===
null
?
"0"
:
item
.
profit_detail_outlook
.
total_actual_before
===
""
?
"0"
:
item
.
profit_detail_outlook
.
total_actual_before
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
january
,
formula
:
item
.
profit_detail_outlook
.
january_formula
}
:
item
.
profit_detail_outlook
.
january
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
february
,
formula
:
item
.
profit_detail_outlook
.
february_formula
}
:
item
.
profit_detail_outlook
.
february
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
march
,
formula
:
item
.
profit_detail_outlook
.
march_formula
}
:
item
.
profit_detail_outlook
.
march
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
april
,
formula
:
item
.
profit_detail_outlook
.
april_formula
}
:
item
.
profit_detail_outlook
.
april
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
may
,
formula
:
item
.
profit_detail_outlook
.
may_formula
}
:
item
.
profit_detail_outlook
.
may
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
june
,
formula
:
item
.
profit_detail_outlook
.
june_formula
}
:
item
.
profit_detail_outlook
.
june
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
july
,
formula
:
item
.
profit_detail_outlook
.
july_formula
}
:
item
.
profit_detail_outlook
.
july
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
august
,
formula
:
item
.
profit_detail_outlook
.
august_formula
}
:
item
.
profit_detail_outlook
.
august
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
september
,
formula
:
item
.
profit_detail_outlook
.
september_formula
}
:
item
.
profit_detail_outlook
.
september
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
october
,
formula
:
item
.
profit_detail_outlook
.
october_formula
}
:
item
.
profit_detail_outlook
.
october
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
november
,
formula
:
item
.
profit_detail_outlook
.
november_formula
}
:
item
.
profit_detail_outlook
.
november
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
december
,
formula
:
item
.
profit_detail_outlook
.
december_formula
}
:
item
.
profit_detail_outlook
.
december
,
item
.
profit_detail_outlook
.
total_current_year
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
0
:
item
.
profit_detail_outlook
.
total_next_year
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
0
:
item
.
profit_detail_outlook
.
total_more_year
,
item
.
order
,
item
.
condition_it_should_be
,
item
.
condition_if_wrong
,
item
.
profit_detail_outlook
.
forecast_formula
==
null
?
[]
:
item
.
profit_detail_outlook
.
forecast_formula
,
item
.
profit_detail_outlook
.
notes
])
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
res
.
map
((
item
,
index
)
=>
{
dataTable
.
push
([
item
.
type_report_id
,
item
.
id
,
item
.
parent
,
item
.
formula
,
item
.
level
,
item
.
description
,
item
.
profit_detail_outlook
.
total_actual_before
===
null
?
"0"
:
item
.
profit_detail_outlook
.
total_actual_before
===
""
?
"0"
:
item
.
profit_detail_outlook
.
total_actual_before
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
january
,
formula
:
item
.
profit_detail_outlook
.
january_formula
}
:
item
.
profit_detail_outlook
.
january
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
february
,
formula
:
item
.
profit_detail_outlook
.
february_formula
}
:
item
.
profit_detail_outlook
.
february
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
march
,
formula
:
item
.
profit_detail_outlook
.
march_formula
}
:
item
.
profit_detail_outlook
.
march
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
april
,
formula
:
item
.
profit_detail_outlook
.
april_formula
}
:
item
.
profit_detail_outlook
.
april
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
may
,
formula
:
item
.
profit_detail_outlook
.
may_formula
}
:
item
.
profit_detail_outlook
.
may
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
june
,
formula
:
item
.
profit_detail_outlook
.
june_formula
}
:
item
.
profit_detail_outlook
.
june
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
july
,
formula
:
item
.
profit_detail_outlook
.
july_formula
}
:
item
.
profit_detail_outlook
.
july
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
august
,
formula
:
item
.
profit_detail_outlook
.
august_formula
}
:
item
.
profit_detail_outlook
.
august
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
september
,
formula
:
item
.
profit_detail_outlook
.
september_formula
}
:
item
.
profit_detail_outlook
.
september
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
october
,
formula
:
item
.
profit_detail_outlook
.
october_formula
}
:
item
.
profit_detail_outlook
.
october
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
november
,
formula
:
item
.
profit_detail_outlook
.
november_formula
}
:
item
.
profit_detail_outlook
.
november
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
{
value
:
item
.
profit_detail_outlook
.
december
,
formula
:
item
.
profit_detail_outlook
.
december_formula
}
:
item
.
profit_detail_outlook
.
december
,
item
.
profit_detail_outlook
.
total_current_year
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
0
:
item
.
profit_detail_outlook
.
total_next_year
,
item
.
type_report_id
==
5
||
item
.
type_report_id
==
6
||
item
.
type_report_id
==
7
?
0
:
item
.
profit_detail_outlook
.
total_more_year
,
item
.
order
,
item
.
condition_it_should_be
,
item
.
condition_if_wrong
,
item
.
profit_detail_outlook
.
forecast_formula
==
null
?
[]
:
item
.
profit_detail_outlook
.
forecast_formula
,
item
.
profit_detail_outlook
.
notes
])
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
})
// console.log(dataTable)
this
.
setState
({
dbPL
:
dataTable
},
()
=>
{
this
.
olahDataPL
(
this
.
state
.
dbPL
,
type
)
})
}
else
{
this
.
setState
({
dbPL
:
[],
previewTable
:
false
,
previewDownload
:
false
})
}
})
})
})
}
handleValueFormulaDBPL
=
(
indexDBCF
,
value
,
tableMeta
,
column
,
periode
,
forecast
)
=>
{
let
splitFormula
=
String
(
tableMeta
[
3
]).
split
(
/
([
()@
])
/
)
// let splitFormula = String(tableMeta.rowData[3]).split('@')
let
baru
=
[]
let
anjay
=
[]
let
dataTable2
=
this
.
state
.
dbPL
// if (forecast !== undefined) {
// console.log(tableMeta)
// }
splitFormula
.
map
((
item
,
index
)
=>
{
let
items
=
String
(
item
).
substr
(
Number
(
String
(
item
).
length
)
-
1
,
1
)
let
subForm
=
String
(
item
).
substr
(
0
,
Number
(
String
(
item
).
length
)
-
1
)
let
re
=
/^
[
a-zA-Z0-9_
]
+$/
;
let
asd
=
''
if
(
item
!==
""
)
{
if
(
!
re
.
test
(
items
))
{
baru
.
push
(
subForm
)
baru
.
push
(
items
)
}
else
{
baru
.
push
(
String
(
item
))
}
}
})
baru
.
map
((
item
,
index
)
=>
{
if
(
item
==
'-'
||
item
==
'+'
||
item
==
'/'
||
item
==
'*'
||
item
==
'('
||
item
==
')'
)
{
anjay
.
push
(
item
)
}
else
{
if
(
String
(
item
).
includes
(
'#'
))
{
if
(
forecast
!==
undefined
)
{
let
forecastt
=
0
forecast
.
map
((
items
,
index
)
=>
{
if
(
items
.
periode
==
periode
)
{
forecastt
+=
Number
(
items
.
value
)
}
})
anjay
.
push
(
forecastt
)
}
else
{
if
(
String
(
item
).
includes
(
'[M-1]'
))
{
let
tst
=
String
(
item
).
replace
(
'[M-1]'
,
''
)
let
data
=
column
==
7
?
18
:
column
-
1
let
period
=
data
==
18
?
Number
(
this
.
state
.
periode
.
periode
)
-
1
:
this
.
state
.
periode
.
periode
let
indexID
=
tableMeta
[
data
].
formula
.
findIndex
((
val
)
=>
val
.
item_formula
==
String
(
`@
${
tst
}
`
)
&&
val
.
periode
==
period
)
if
(
indexID
!==
-
1
)
{
let
valuezz
=
tableMeta
[
data
].
formula
[
indexID
].
value
anjay
.
push
(
valuezz
==
""
?
0
:
valuezz
)
}
}
else
{
// console.log(item)
let
indexID
=
value
.
formula
.
findIndex
((
val
)
=>
val
.
item_formula
==
String
(
`@
${
item
}
`
)
&&
val
.
periode
==
Number
(
this
.
state
.
periode
.
periode
))
if
(
indexID
!==
-
1
)
{
let
valuezz
=
value
.
formula
[
indexID
].
value
anjay
.
push
(
valuezz
==
""
?
0
:
valuezz
)
}
}
}
}
else
{
let
indexID
=
dataTable2
.
findIndex
((
val
)
=>
val
[
22
]
==
item
)
if
(
indexID
!==
-
1
)
{
// if (forecast !== undefined) {
// console.log(dataTable2[indexID])
// console.log(column)
// console.log(dataTable2[indexID][column])
// }
if
(
forecast
!=
undefined
)
{
// console.log(dataTable2[indexID][column])
}
let
valuezz
=
dataTable2
[
indexID
][
column
].
value
==
undefined
?
dataTable2
[
indexID
][
column
]
:
dataTable2
[
indexID
][
column
].
value
anjay
.
push
(
valuezz
==
""
?
0
:
valuezz
)
}
else
{
if
(
item
===
'(-1)'
)
{
anjay
.
push
(
-
1
)
}
}
}
}
})
let
anjay2
=
[]
let
kurung
=
false
let
item1
=
[]
anjay
.
map
((
item
,
index
)
=>
{
if
(
item
==
"("
)
{
kurung
=
true
}
else
if
(
item
==
")"
)
{
kurung
=
false
anjay2
.
push
(
item1
)
item1
=
[]
}
else
{
if
(
kurung
)
{
item1
.
push
(
item
)
}
else
{
anjay2
.
push
(
item
)
}
}
})
let
total
=
0
let
opt
=
""
let
totalPrio
=
0
let
optPrio
=
""
let
prio
=
false
anjay2
.
map
((
item
,
index
)
=>
{
if
(
Array
.
isArray
(
item
))
{
prio
=
true
item
.
map
((
items
,
indexs
)
=>
{
if
(
items
==
"+"
)
{
optPrio
=
"tambah"
}
else
if
(
items
==
"-"
)
{
optPrio
=
"kurang"
}
else
if
(
items
==
"*"
)
{
optPrio
=
"kali"
}
else
if
(
items
==
"/"
)
{
optPrio
=
"bagi"
}
else
{
if
(
optPrio
==
"tambah"
)
{
totalPrio
=
Number
(
totalPrio
)
+
Number
(
items
)
}
else
if
(
optPrio
==
"kurang"
)
{
totalPrio
=
Number
(
totalPrio
)
-
Number
(
items
)
}
else
if
(
optPrio
==
"kali"
)
{
totalPrio
=
Number
(
totalPrio
)
*
Number
(
items
)
}
else
if
(
optPrio
==
"bagi"
)
{
totalPrio
=
Number
(
totalPrio
)
/
Number
(
items
)
==
NaN
?
0
:
Number
(
totalPrio
)
/
Number
(
items
)
}
else
{
totalPrio
+=
Number
(
items
)
}
}
})
if
(
index
==
anjay2
.
length
-
1
)
{
if
(
opt
==
"tambah"
)
{
total
=
Number
(
total
)
+
Number
(
totalPrio
)
}
else
if
(
opt
==
"kurang"
)
{
total
=
Number
(
total
)
-
Number
(
totalPrio
)
}
else
if
(
opt
==
"kali"
)
{
total
=
Number
(
total
)
*
Number
(
totalPrio
)
}
else
if
(
opt
==
"bagi"
)
{
total
=
Number
(
total
)
/
Number
(
totalPrio
)
==
NaN
?
0
:
Number
(
total
)
/
Number
(
totalPrio
)
}
else
{
total
+=
Number
(
totalPrio
)
}
}
}
else
{
// console.log(item.length)
if
(
item
==
"+"
)
{
opt
=
"tambah"
if
(
prio
)
{
total
=
Number
(
Number
(
totalPrio
)
+
Number
(
total
))
prio
=
false
totalPrio
=
0
optPrio
=
""
}
}
else
if
(
item
==
"-"
)
{
opt
=
"kurang"
if
(
prio
)
{
total
=
Number
(
Number
(
totalPrio
)
+
Number
(
total
))
prio
=
false
totalPrio
=
0
optPrio
=
""
}
}
else
if
(
item
==
"*"
)
{
opt
=
"kali"
if
(
prio
)
{
total
=
Number
(
Number
(
totalPrio
)
+
Number
(
total
))
prio
=
false
totalPrio
=
0
optPrio
=
""
}
}
else
if
(
item
==
"/"
)
{
opt
=
"bagi"
if
(
prio
)
{
total
=
Number
(
Number
(
totalPrio
)
+
Number
(
total
))
prio
=
false
totalPrio
=
0
optPrio
=
""
}
}
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
=
Number
(
total
)
/
Number
(
item
)
==
NaN
?
0
:
Number
(
total
)
/
Number
(
item
)
}
else
{
total
+=
Number
(
item
)
}
}
}
})
if
(
String
(
tableMeta
[
5
])
==
"Cost of Goods Sold (COGS)"
&&
column
==
20
)
{
console
.
log
(
splitFormula
)
console
.
log
(
baru
)
console
.
log
(
anjay
)
console
.
log
(
anjay2
)
console
.
log
(
total
)
}
total
=
R
.
equals
(
total
,
NaN
)
?
"0.0"
:
total
return
total
}
handleForecastDBPL
=
(
index
,
tableMeta
,
periode
,
column
)
=>
{
let
total
=
0
let
dataTable2
=
this
.
state
.
dbPL
if
(
tableMeta
[
3
].
includes
(
'#PL'
))
{
dataTable2
[
index
][
25
].
map
((
item
,
index
)
=>
{
if
(
item
.
periode
==
periode
)
{
total
+=
Number
(
item
.
value
)
}
})
}
else
{
total
=
this
.
handleValueFormulaDBPL
(
dataTable2
[
index
][
column
],
tableMeta
[
column
],
tableMeta
,
column
,
periode
,
dataTable2
[
index
][
25
])
}
return
total
}
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
)
item
[
8
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
8
],
item
,
8
)
item
[
9
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
9
],
item
,
9
)
item
[
10
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
10
],
item
,
10
)
item
[
11
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
11
],
item
,
11
)
item
[
12
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
12
],
item
,
12
)
item
[
13
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
13
],
item
,
13
)
item
[
14
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
14
],
item
,
14
)
item
[
15
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
15
],
item
,
15
)
item
[
16
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
16
],
item
,
16
)
item
[
17
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
17
],
item
,
17
)
item
[
18
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
18
],
item
,
18
)
item
[
20
]
=
this
.
handleForecastDBPL
(
index
,
item
,
`
${
Number
(
this
.
state
.
periode
.
periode
)
+
1
}
`
,
20
)
item
[
21
]
=
this
.
handleForecastDBPL
(
index
,
item
,
`
${
Number
(
this
.
state
.
periode
.
periode
)
+
2
}
`
,
21
)
}
})
this
.
setState
({
dbPL
},
()
=>
{
this
.
payloadPL
(
type
)
})
}
payloadPL
(
type
)
{
let
listPL
=
[]
// console.log(this.state.dbPL)
this
.
state
.
dbPL
.
map
((
item
,
index
)
=>
{
if
(
item
[
0
]
==
5
||
item
[
0
]
==
6
||
item
[
0
]
==
7
)
{
// if (item[7].value == "" || item[7].value == 0 || item[7].value == "0.0") {
item
[
7
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
7
],
item
,
7
)
// }
// if (item[8].value == "" || item[8].value == 0 || item[8].value == "0.0") {
item
[
8
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
8
],
item
,
8
)
// }
// if (item[9].value == "" || item[9].value == 0 || item[9].value == "0.0") {
item
[
9
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
9
],
item
,
9
)
// }
// if (item[10].value == "" || item[10].value == 0 || item[10].value == "0.0") {
item
[
10
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
10
],
item
,
10
)
// }
// if (item[11].value == "" || item[11].value == 0 || item[11].value == "0.0") {
item
[
11
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
11
],
item
,
11
)
// }
// if (item[12].value == "" || item[12].value == 0 || item[12].value == "0.0") {
item
[
12
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
12
],
item
,
12
)
// }
// if (item[13].value == "" || item[13].value == 0 || item[13].value == "0.0") {
item
[
13
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
13
],
item
,
13
)
// }
// if (item[14].value == "" || item[14].value == 0 || item[14].value == "0.0") {
item
[
14
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
14
],
item
,
14
)
// }
// if (item[15].value == "" || item[15].value == 0 || item[15].value == "0.0") {
item
[
15
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
15
],
item
,
15
)
// }
// if (item[16].value == "" || item[16].value == 0 || item[16].value == "0.0") {
item
[
16
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
16
],
item
,
16
)
// }
// if (item[17].value == "" || item[17].value == 0 || item[17].value == "0.0") {
item
[
17
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
17
],
item
,
17
)
// }
// if (item[18].value == "" || item[18].value == 0 || item[18].value == "0.0") {
item
[
18
].
value
=
this
.
handleValueFormulaDBPL
(
index
,
item
[
18
],
item
,
18
)
// }
// if (item[20] == "" || item[20] == 0 || item[20] == "0.0") {
item
[
20
]
=
this
.
handleForecastDBPL
(
index
,
item
,
`
${
Number
(
this
.
state
.
periode
.
periode
)
+
1
}
`
,
20
)
// }
// if (item[21] == "" || item[21] == 0 || item[21] == "0.0") {
item
[
21
]
=
this
.
handleForecastDBPL
(
index
,
item
,
`
${
Number
(
this
.
state
.
periode
.
periode
)
+
2
}
`
,
21
)
// }
}
listPL
.
push
(
{
"item_report_id"
:
item
[
1
],
"january"
:
String
(
item
[
7
].
value
==
undefined
?
item
[
7
]
:
Number
(
item
[
7
].
value
).
toFixed
(
1
)),
"february"
:
String
(
item
[
8
].
value
==
undefined
?
item
[
8
]
:
Number
(
item
[
8
].
value
).
toFixed
(
1
)),
"march"
:
String
(
item
[
9
].
value
==
undefined
?
item
[
9
]
:
Number
(
item
[
9
].
value
).
toFixed
(
1
)),
"april"
:
String
(
item
[
10
].
value
==
undefined
?
item
[
10
]
:
Number
(
item
[
10
].
value
).
toFixed
(
1
)),
"may"
:
String
(
item
[
11
].
value
==
undefined
?
item
[
11
]
:
Number
(
item
[
11
].
value
).
toFixed
(
1
)),
"june"
:
String
(
item
[
12
].
value
==
undefined
?
item
[
12
]
:
Number
(
item
[
12
].
value
).
toFixed
(
1
)),
"july"
:
String
(
item
[
13
].
value
==
undefined
?
item
[
13
]
:
Number
(
item
[
13
].
value
).
toFixed
(
1
)),
"august"
:
String
(
item
[
14
].
value
==
undefined
?
item
[
14
]
:
Number
(
item
[
14
].
value
).
toFixed
(
1
)),
"september"
:
String
(
item
[
15
].
value
==
undefined
?
item
[
15
]
:
Number
(
item
[
15
].
value
).
toFixed
(
1
)),
"october"
:
String
(
item
[
16
].
value
==
undefined
?
item
[
16
]
:
Number
(
item
[
16
].
value
).
toFixed
(
1
)),
"november"
:
String
(
item
[
17
].
value
==
undefined
?
item
[
17
]
:
Number
(
item
[
17
].
value
).
toFixed
(
1
)),
"december"
:
String
(
item
[
18
].
value
==
undefined
?
item
[
18
]
:
Number
(
item
[
18
].
value
).
toFixed
(
1
)),
"total_current_year"
:
String
(
item
[
19
]),
"total_next_year"
:
String
(
item
[
20
]
!=
''
?
Number
(
item
[
20
]).
toFixed
(
1
)
:
item
[
20
]),
"total_more_year"
:
String
(
item
[
21
]
!=
''
?
Number
(
item
[
21
]).
toFixed
(
1
)
:
item
[
21
]),
"notes"
:
String
(
item
[
26
]),
}
)
})
// console.log(listPL)
this
.
setState
({
dbPL
:
listPL
},
()
=>
{
// if (this.state.submissionID != null) {
// this.createDBPL()
// }
if
(
type
!=
undefined
)
{
if
(
type
==
'PL'
)
{
console
.
log
(
'tarik sis'
)
this
.
createDBPL
()
}
}
})
}
createDBPL
()
{
let
payload
=
{
// "submission_id": this.state.submissionID,
"company_id"
:
this
.
state
.
company
.
company_id
,
"periode"
:
this
.
state
.
periode
.
periode
,
"report_id"
:
28
,
"status"
:
"submitted"
,
"profit_loss_id"
:
this
.
state
.
PLID
,
"profit_loss_olpa"
:
this
.
state
.
dbPL
,
"months"
:
0
,
}
console
.
log
(
this
.
state
.
dbPL
)
// console.log(JSON.stringify(payload))
api
.
create
().
createDBPLOLPA
(
payload
).
then
((
res
)
=>
{
console
.
log
(
res
)
this
.
setState
({
loading
:
false
})
})
}
render
()
{
const
handleMaxDate
=
()
=>
{
let
handleDate
=
Number
(
moment
(
this
.
state
.
maxDateRevision
).
format
(
'YYYYMMDD'
))
-
Number
(
moment
(
this
.
state
.
minDateRevision
).
format
(
'YYYYMMDD'
))
...
...
src/container/OutlookPA/ProfitLossOLPA.js
View file @
a8a9582a
...
...
@@ -166,10 +166,46 @@ export default class ProfitLossOLPA extends Component {
let
dataTable
=
[]
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
res
=
response
.
data
.
data
const
handlePushChild
=
(
item
)
=>
{
let
indexIDzz
=
dataTable
.
findIndex
((
val
)
=>
val
[
1
]
===
item
.
id
)
if
(
indexIDzz
===
-
1
)
{
let
res
=
response
.
data
.
data
const
handlePushChild
=
(
item
)
=>
{
let
indexIDzz
=
dataTable
.
findIndex
((
val
)
=>
val
[
1
]
===
item
.
id
)
if
(
indexIDzz
===
-
1
)
{
dataTable
.
push
([
item
.
type_report_id
,
item
.
id
,
item
.
parent
,
item
.
formula
,
item
.
level
,
item
.
description
,
item
.
profit_loss
.
notes
===
""
?
null
:
item
.
profit_loss
.
notes
,
item
.
profit_loss
.
total_actual_before
===
null
?
"0.0"
:
item
.
profit_loss
.
total_actual_before
===
""
?
"0"
:
item
.
profit_loss
.
total_actual_before
,
Number
(
item
.
profit_loss
.
january
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
february
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
march
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
april
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
may
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
june
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
july
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
august
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
september
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
october
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
november
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
december
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
total_current_year
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
ytd_october
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
nov_dec
).
toFixed
(
1
),
item
.
order
])
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
res
.
map
((
item
,
index
)
=>
{
dataTable
.
push
([
item
.
type_report_id
,
item
.
id
,
...
...
@@ -196,50 +232,14 @@ export default class ProfitLossOLPA extends Component {
Number
(
item
.
profit_loss
.
nov_dec
).
toFixed
(
1
),
item
.
order
])
}
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
res
.
map
((
item
,
index
)
=>
{
dataTable
.
push
([
item
.
type_report_id
,
item
.
id
,
item
.
parent
,
item
.
formula
,
item
.
level
,
item
.
description
,
item
.
profit_loss
.
notes
===
""
?
null
:
item
.
profit_loss
.
notes
,
item
.
profit_loss
.
total_actual_before
===
null
?
"0.0"
:
item
.
profit_loss
.
total_actual_before
===
""
?
"0"
:
item
.
profit_loss
.
total_actual_before
,
Number
(
item
.
profit_loss
.
january
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
february
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
march
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
april
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
may
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
june
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
july
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
august
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
september
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
october
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
november
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
december
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
total_current_year
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
ytd_october
).
toFixed
(
1
),
Number
(
item
.
profit_loss
.
nov_dec
).
toFixed
(
1
),
item
.
order
])
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
if
(
item
.
children
!==
null
)
{
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
map
((
items
,
indexs
)
=>
{
handlePushChild
(
items
)
})
}
}
}
})
})
console
.
log
(
dataTable
)
this
.
setState
({
dataTable
,
loading
:
false
,
buttonError
:
true
,
editable
:
true
})
}
else
{
...
...
@@ -318,7 +318,11 @@ export default class ProfitLossOLPA extends Component {
}
console
.
log
(
data
);
this
.
setState
({
loading
:
false
})
this
.
props
.
saveToOLPA
(
payload
)
if
(
type
==
'submitted'
)
{
this
.
props
.
saveToOLPA
(
payload
,
'PL'
)
}
else
{
this
.
props
.
saveToOLPA
(
payload
)
}
this
.
props
.
onClickClose
()
}
...
...
@@ -474,7 +478,11 @@ export default class ProfitLossOLPA extends Component {
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
props
.
onClickClose
()
this
.
props
.
getReport
()
if
(
type
==
'submitted'
)
{
this
.
props
.
getReport
(
'PL'
)
}
else
{
this
.
props
.
getReport
()
}
}
else
{
alert
(
response
.
data
.
status
)
}
...
...
@@ -1847,7 +1855,7 @@ export default class ProfitLossOLPA extends Component {
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
,
marginTop
:
10
,
marginRight
:
5
}}
>
{
item
.
latest_update
}
<
/Typography
>
)
})
:
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
,
marginTop
:
10
,
marginRight
:
5
}}
>-<
/Typography
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
,
marginTop
:
10
,
marginRight
:
5
}}
>-<
/Typography
>
}
<
/div
>
<
/div
>
...
...
@@ -1877,27 +1885,27 @@ export default class ProfitLossOLPA extends Component {
<
div
className
=
"col-2"
>
<
/div>
:
<
div
className
=
"col-2"
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
maxWidth
:
'100%'
,
paddingRight
:
5
}}
>
{
this
.
state
.
get_for
==
'view'
&&
this
.
state
.
viewOnly
&&
<
button
className
=
"button"
type
=
"button"
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
marginRight
:
20
}}
onClick
=
{()
=>
{
this
.
setState
({
loading
:
true
,
refresh
:
true
},
()
=>
{
this
.
handleGetFor
(
'edit'
)
})
}}
>
<
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'
}}
>
Edit
<
/Typography
>
<
/div
>
<
/button>
}
{
this
.
state
.
get_for
==
'view'
&&
this
.
state
.
viewOnly
&&
<
button
className
=
"button"
type
=
"button"
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
marginRight
:
20
}}
onClick
=
{()
=>
{
this
.
setState
({
loading
:
true
,
refresh
:
true
},
()
=>
{
this
.
handleGetFor
(
'edit'
)
})
}}
>
<
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'
}}
>
Edit
<
/Typography
>
<
/div
>
<
/button>
}
{
this
.
state
.
get_for
==
'edit'
&&
<
button
className
=
"button"
type
=
"button"
...
...
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