Commit 251a7fde authored by d.arizona's avatar d.arizona

apdet kuy

parent a8ff0f7c
...@@ -12,6 +12,7 @@ import { Alert, Autocomplete } from '@material-ui/lab'; ...@@ -12,6 +12,7 @@ import { Alert, Autocomplete } from '@material-ui/lab';
import UploadFile from '../../library/Upload'; import UploadFile from '../../library/Upload';
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import { PropagateLoader } from 'react-spinners'; import { PropagateLoader } from 'react-spinners';
import * as R from 'ramda'
const LightTooltip = withStyles((theme) => ({ const LightTooltip = withStyles((theme) => ({
tooltip: { tooltip: {
...@@ -180,6 +181,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -180,6 +181,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score, item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight, item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight,
item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes, item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes,
item.corporate_annual_target.actual_formula === null? [] : item.corporate_annual_target.actual_formula
]) ])
} }
if (item.children !== null) { if (item.children !== null) {
...@@ -212,6 +214,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -212,6 +214,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score, item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight, item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight,
item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes, item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes,
item.corporate_annual_target.actual_formula === null? [] : item.corporate_annual_target.actual_formula
]) ])
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
...@@ -342,6 +345,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -342,6 +345,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.score_x_weight, item.score_x_weight,
item.notes, item.notes,
item.order, item.order,
item.actual_formula === null? [] : item.actual_formula,
item.error item.error
] ]
}) })
...@@ -608,25 +612,218 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -608,25 +612,218 @@ export default class CorporateAnnualTargetMR extends Component {
let dataDelete = this.state.dataDelete let dataDelete = this.state.dataDelete
const handleChange = (value, tableMeta, type) => { const handleChange = (value, tableMeta, type) => {
let val = String(value).split(",").join("") let val = String(value).split(",").join("")
// let total = 0
// let lastValz = 0
if (type == 'text') { if (type == 'text') {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
} else { } else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
} }
// dataTable2[tableMeta.rowIndex].map((item, index) => { }
// if (index >= 13 && index <= 24) {
// let valItem = item == undefined || item == "" ? 0 : item const handleValueFormula = (tableMeta, colIdx) => {
// total += Number(valItem) let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
// if (index == 24) { let baru = []
// lastValz += Number(valItem) let anjay = []
// } 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 valz = dataTable2[tableMeta.rowIndex][11] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][11].value let re = /^[a-zA-Z0-9_]+$/;
// dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz)) if (item !== "") {
// // // console.log(dataTable2[tableMeta.rowIndex]) if (items == ']') {
baru.push(String(item))
} else if (!re.test(items)) {
baru.push(subForm)
baru.push(items)
} else {
baru.push(String(item))
}
}
})
// console.log(baru);
let tambahan = false
let opet = ""
baru.map((item, index) => {
if (item == 'X') {
tambahan = true
} else if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
anjay.push(item)
} else {
if (String(item).includes('#')) {
if (String(item).includes('[M-1]')) {
let tst = '@' + String(item).replace('[M-1]', '[M1]')
console.log(tst);
let indexID = dataTable2[tableMeta.rowIndex][17].findIndex((val) => val.item_formula == tst)
if (indexID !== -1) {
let valuezz = dataTable2[tableMeta.rowIndex][17][indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
let data = tableMeta.rowData[17] == null? [] : tableMeta.rowData[17]
let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
if (indexID !== -1) {
let valuezz = data[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
} else {
if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
let indexID = dataTable2.findIndex((val) => val[17] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][8]
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
let indexID = dataTable2.findIndex((val) => val[17] == item)
if (item == 'X-1') {
anjay.push(-1)
} else if (tambahan) {
if (item == '-' || item == '+' || item == '/' || item == '*') {
opet = item
} else {
anjay.push(opet == ''? Number(item) : Number(String(opet + String(item))))
tambahan = false
opet = ""
}
} else {
if (indexID !== -1) {
let valuezz = dataTable2[indexID][colIdx]
if (item == dataTable2[tableMeta.rowIndex][28]) {
anjay.push(0)
} else {
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
if (item === '(-1)') {
anjay.push(-1)
}
}
}
}
}
}
})
console.log(baru)
console.log(anjay)
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 {
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)
}
}
}
})
total = R.equals(total, NaN) ? "0.0" : total
dataTable2[tableMeta.rowIndex][colIdx] = total
return total
} }
const handleChangeDropdown = (value, tableMeta) => { const handleChangeDropdown = (value, tableMeta) => {
...@@ -682,13 +879,18 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -682,13 +879,18 @@ export default class CorporateAnnualTargetMR extends Component {
if (this.props.isApprover) { if (this.props.isApprover) {
return false return false
} else { } else {
if ((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')) { // if ((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')) {
if (idParent !== null) { if (idParent !== null) {
console.log(tableMeta)
let indexsss = dataTable2.findIndex((val) => val[1] == idParent) let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
if (dataTable2[indexsss][6] == 'CUSTOMER PERSPECTIVE' || dataTable2[indexsss][6] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') { if (dataTable2[indexsss][5] == 'CUSTOMER PERSPECTIVE' || dataTable2[indexsss][5] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
return true return true
} else { } else {
return false if (typeReport == 3) {
return true
} else {
return false
}
} }
} else { } else {
if (typeReport == null || typeReport == 3) { if (typeReport == null || typeReport == 3) {
...@@ -704,9 +906,9 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -704,9 +906,9 @@ export default class CorporateAnnualTargetMR extends Component {
return false return false
} }
} }
} else { // } else {
return false // return false
} // }
} }
} }
...@@ -785,8 +987,8 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -785,8 +987,8 @@ export default class CorporateAnnualTargetMR extends Component {
total = actual/target total = actual/target
} }
total = String(total) == 'NaN' || String(total) == 'Infinity' || String(total) == '-Infinity' ? 0 : total total = String(total) == 'NaN' || String(total) == 'Infinity' || String(total) == '-Infinity' ? 0 : total
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) * 100
return Number(total).toFixed(1) return Number(total)*100
} }
const handleScore = (tableMeta) => { const handleScore = (tableMeta) => {
...@@ -796,8 +998,9 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -796,8 +998,9 @@ export default class CorporateAnnualTargetMR extends Component {
let parameterMix = `${parameterKpi}_${parameterAch}` let parameterMix = `${parameterKpi}_${parameterAch}`
let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase()) let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase())
let totalScore = 0 let totalScore = 0
let achx100 = Number(tableMeta.rowData[13])/100
listParameterFilter.map((item,index) => { listParameterFilter.map((item,index) => {
if (Number(tableMeta.rowData[13]) >= Number(item.min_value) && Number(tableMeta.rowData[13]) <= Number(item.max_value)) { if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
totalScore = Number(item.value) totalScore = Number(item.value)
} }
}) })
...@@ -882,8 +1085,8 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -882,8 +1085,8 @@ export default class CorporateAnnualTargetMR extends Component {
</div> </div>
: :
<div style={{ width: 300 }}> <div style={{ width: 300 }}>
{tableMeta.rowData[30] ? {tableMeta.rowData[18] ?
tableMeta.rowData[30].length > 0 ? tableMeta.rowData[18].length > 0 ?
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}> <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<LightTooltip title={"Report Items Not Registered"} arrow> <LightTooltip title={"Report Items Not Registered"} arrow>
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span> <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
...@@ -1034,12 +1237,12 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1034,12 +1237,12 @@ export default class CorporateAnnualTargetMR extends Component {
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ color: this.state.get_for == 'view'? "black" : "#5198ea", fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: this.state.get_for == 'view'? "black" : handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta)? "#5198ea" : 'black', fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={Number(value).toFixed(1)} value={ tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6? Number(handleValueFormula(tableMeta, tableMeta.columnIndex)) : Number(value).toFixed(1)}
// disabled={this.props.isApprover ? true : ((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') ? false : true)} // disabled={this.props.isApprover ? true : ((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') ? false : true)}
disabled={this.state.get_for == 'view'} disabled={this.state.get_for == 'view'? true : !handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta)}
decimalScale={1} decimalScale={1}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
...@@ -1246,7 +1449,14 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1246,7 +1449,14 @@ export default class CorporateAnnualTargetMR extends Component {
) )
} }
} }
} },
{
name: "",
options: {
display: false
}
},
] ]
const loadingComponent = ( const loadingComponent = (
......
...@@ -622,27 +622,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -622,27 +622,7 @@ export default class FixedAssetsMovementMR extends Component {
}) })
total = R.equals(total, NaN) ? "0.0" : total total = R.equals(total, NaN) ? "0.0" : total
// // // total = R.equals(total, NaN) ? "0.0" : total
// // // console.log(dataTable2[tableMeta.rowIndex][22])
// // // console.log(tableMeta.rowData[5])
// // if (tableMeta.rowData[5] == "1.5 Other non-current assets") {
// // if (forecast !== undefined) {
// // if (String(tableMeta.rowData[5]) == "Depreciation & amortisation") {
// console.log(splitFormula)
// console.log(baru)
// console.log(anjay)
// console.log(anjay2)
// console.log(total)
// // console.log(dataTable2[tableMeta.rowIndex])
// // }
// // }
// if (dataTable2[tableMeta.rowIndex][colIdx].value == undefined) {
dataTable2[tableMeta.rowIndex][colIdx] = total dataTable2[tableMeta.rowIndex][colIdx] = total
// } else {
// dataTable2[tableMeta.rowIndex][column].value = total
// }
// loading = false
return total return total
} }
...@@ -819,18 +799,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -819,18 +799,7 @@ export default class FixedAssetsMovementMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{ {
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
tableMeta.rowData[0] === 5 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(tableMeta, 6)).toFixed(1)}
/>
</span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -855,17 +824,6 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -855,17 +824,6 @@ export default class FixedAssetsMovementMR extends Component {
{ {
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
tableMeta.rowData[0] === 5?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(tableMeta, 7)).toFixed(1)}
/>
</span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment