Commit 174125dc authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

pussh bwanyaq

See merge request !868
parents 7fd0049c dd56683a
......@@ -176,6 +176,7 @@ const create = (type = "") => {
const getDetailParameter = (id) => api.get(`setting/get_setting_by_id/${id}`)
const getAllGroup = () => api.get('/setting_group/get_all_setting_group')
const getParameterByGroup = (groupID) => api.get(`/setting_type/get_all_setting_type_by_group/${groupID}`)
const getParameterByGroupName = (groupName) => api.post(`/setting/get_all_setting_by_group_name`, groupName)
const createParameter = (body) => api.post('setting/create_setting', body)
const updateParameter = (body) => api.post('setting/update_setting', body)
const checkUploadParameter = (body) => api.post('setting/check_import', body)
......@@ -532,7 +533,8 @@ const create = (type = "") => {
checkUploadMonthlyReportLOCF,
uploadMonthlyReportLOCF,
validateSubmitReportOI,
getMonthlyOI
getMonthlyOI,
getParameterByGroupName
}
}
......
......@@ -67,7 +67,11 @@ export default class CorporateAnnualTargetMR extends Component {
updateBy: '-',
notes: "",
judulColumn: null,
get_for: "view"
get_for: "view",
parameterScore: [],
totalScore: 0,
perfomanceScore: '',
buttonError: true
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -77,17 +81,27 @@ export default class CorporateAnnualTargetMR extends Component {
this.getLatestUpdate()
this.getKPIType()
this.getMaxAch()
this.getParameterGroup()
}
handleGetFor(type) {
this.setState({get_for: type}, () => {
this.getItemHierarki()
this.getLatestUpdate()
this.getKPIType()
this.getMaxAch()
})
}
getParameterGroup() {
api.create().getParameterByGroupName({
"group_name" : 'ACHIEVEMENT_KPI'
}).then((response) => {
if (response.data) {
this.setState({parameterScore: response.data.data})
}
})
}
getLatestUpdate() {
let payload = {
"report_id": this.props.report_id,
......@@ -99,7 +113,7 @@ export default class CorporateAnnualTargetMR extends Component {
}
// console.log(payload)
api.create().getLastestUpdateMR(payload).then(response => {
// console.log(JSON.stringify(response))
console.log(JSON.stringify(response))
if (response.data) {
if (response.data.status === "success") {
this.setState({
......@@ -152,7 +166,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.formula,
item.level,
item.description,
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.corporate_annual_target.weight).indexOf(".") == -1 ? item.corporate_annual_target.weight : `${Number(item.weight) * 100}%`),
item.corporate_annual_target.weight == ""? "0%" : item.corporate_annual_target.weight,
parentTrue ? item.corporate_annual_target.uom : item.uom,
parentTrue ? item.corporate_annual_target.kpi_type == "" ? null : item.corporate_annual_target.kpi_type : item.kpi_type == "" ? null : item.kpi_type,
// parentTrue ? item.corporate_annual_target.kpi_type == "" ? null : { value: item.corporate_annual_target.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
......@@ -208,7 +222,9 @@ export default class CorporateAnnualTargetMR extends Component {
}
})
// console.log(dataTable);
this.setState({ dataTable, loading: false, saveDraft: true })
this.setState({ dataTable, loading: false, saveDraft: true }, () => {
this.handleCalculate()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
......@@ -293,7 +309,7 @@ export default class CorporateAnnualTargetMR extends Component {
corporate_annual_target: payload
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
......@@ -539,14 +555,66 @@ export default class CorporateAnnualTargetMR extends Component {
this.setState({ alert: false })
}
handleCalculate(){
let total = 0
let perfomanceScore = ''
let dataTable2 = this.state.dataTable
dataTable2.map((item,index) => {
let value = String(item[15]) == 'NaN' || String(item[15]) == ''? 0 : Number(item[15])
total += value
})
total = Number(total).toFixed(2)
if ( total >= 1.00 && total <= 2.00) {
perfomanceScore = 'K'
} else if ( total >= 2.01 && total <= 2.75) {
perfomanceScore = 'C'
} else if ( total >= 2.76 && total <= 3.00) {
perfomanceScore = 'B-'
} else if ( total >= 3.01 && total <= 3.75) {
perfomanceScore = 'B'
} else if ( total >= 3.76 && total <= 4.00) {
perfomanceScore = 'B+'
} else if ( total >= 4.01 && total <= 4.75) {
perfomanceScore = 'BS'
} else {
perfomanceScore = 'IST'
}
this.setState({totalScore: total, perfomanceScore, loading: false})
}
handleBackgroundPerf(total) {
let color = 'white'
if ( total >= 1.00 && total <= 2.00) {
color = 'red'
} else if ( total >= 2.01 && total <= 2.75) {
color = 'yellow'
} else if ( total >= 2.76 && total <= 3.00) {
color = 'lightgreen'
} else if ( total >= 3.01 && total <= 3.75) {
color = 'yellowgreen'
} else if ( total >= 3.76 && total <= 4.00) {
color = 'forestgreen'
} else if ( total >= 4.01 && total <= 4.75) {
color = 'deepskyblue'
} else {
color = 'dodgerblue'
}
return color
}
render() {
let dataTable2 = this.state.dataTable
let dataDelete = this.state.dataDelete
const handleChange = (value, tableMeta) => {
const handleChange = (value, tableMeta, type) => {
let val = String(value).split(",").join("")
// let total = 0
// let lastValz = 0
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
if (type == 'text') {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
} else {
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
......@@ -705,22 +773,48 @@ export default class CorporateAnnualTargetMR extends Component {
})
}
const handleTotal = (tableMeta) => {
// let val = String(value).split(",").join("")
const handleAchiement = (tableMeta) => {
let total = 0
let lastValz = 0
dataTable2[tableMeta.rowIndex].map((item, index) => {
if (index >= 13 && index <= 24) {
let valItem = item == undefined || item == "" ? 0 : item
total += Number(valItem)
if (index == 24) {
lastValz += Number(valItem)
}
if (tableMeta.rowData[8] == 'HIB') {
let actual = tableMeta.rowData[11] == ""? 0 : Number(tableMeta.rowData[11])
let target = tableMeta.rowData[12] == ""? 0 : Number(tableMeta.rowData[12])
total = 2 - (actual / target)
} else {
let actual = tableMeta.rowData[11] == ""? 0 : Number(tableMeta.rowData[11])
let target = tableMeta.rowData[12] == ""? 0 : Number(tableMeta.rowData[12])
total = actual/target
}
total = String(total) == 'NaN' || String(total) == 'Infinity' || String(total) == '-Infinity' ? 0 : total
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(1)
return Number(total).toFixed(1)
}
const handleScore = (tableMeta) => {
let listParameter = this.state.parameterScore
let parameterKpi = tableMeta.rowData[8]
let parameterAch = String(tableMeta.rowData[9]).includes('%')? `MAX${String(tableMeta.rowData[9]).substr(0,String(tableMeta.rowData[9]).length - 1)}` : String(tableMeta.rowData[9])
let parameterMix = `${parameterKpi}_${parameterAch}`
let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase())
let totalScore = 0
listParameterFilter.map((item,index) => {
if (Number(tableMeta.rowData[13]) >= Number(item.min_value) && Number(tableMeta.rowData[13]) <= Number(item.max_value)) {
totalScore = Number(item.value)
}
})
let valz = dataTable2[tableMeta.rowIndex][11] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][11].value
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
return (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(totalScore).toFixed(1)
return Number(totalScore).toFixed(1)
}
const handleTotal = (tableMeta) => {
let total = 0
let handlePercent = String(tableMeta.rowData[6]).substr(0,String(tableMeta.rowData[6]).length-1)
if (tableMeta.rowData[12] == '' || String(tableMeta.rowData[12]) == '0' || String(tableMeta.rowData[12]) == '0.0') {
total = 0
} else {
total = Number(tableMeta.rowData[14]) * Number(handlePercent) / 100
}
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(1)
return total
}
let columns = [
......@@ -966,7 +1060,7 @@ export default class CorporateAnnualTargetMR extends Component {
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 75, borderLeft: '1px #fff solid' }}>
<Typography style={{ color: '#000', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
<Typography style={{ color: '#fff', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell>
),
customBodyRender: (value, tableMeta) => {
......@@ -983,7 +1077,7 @@ export default class CorporateAnnualTargetMR extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={Number(handleTotal(tableMeta)).toFixed(1)}
value={Number(value).toFixed(1)}
decimalScale={1}
disabled={true}
// onBlur={(event) => {
......@@ -1004,7 +1098,7 @@ export default class CorporateAnnualTargetMR extends Component {
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 75, borderLeft: '1px #fff solid' }}>
<Typography style={{ color: '#000', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
<Typography style={{ color: '#fff', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell>
),
customBodyRender: (value, tableMeta) => {
......@@ -1021,7 +1115,7 @@ export default class CorporateAnnualTargetMR extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={Number(handleTotal(tableMeta)).toFixed(1)}
value={handleAchiement(tableMeta)}
decimalScale={1}
disabled={true}
// onBlur={(event) => {
......@@ -1059,7 +1153,7 @@ export default class CorporateAnnualTargetMR extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={Number(handleTotal(tableMeta)).toFixed(1)}
value={handleScore(tableMeta)}
decimalScale={1}
disabled={true}
// onBlur={(event) => {
......@@ -1097,7 +1191,7 @@ export default class CorporateAnnualTargetMR extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 75, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={Number(handleTotal(tableMeta)).toFixed(1)}
value={handleTotal(tableMeta)}
decimalScale={1}
disabled={true}
// onBlur={(event) => {
......@@ -1137,10 +1231,10 @@ export default class CorporateAnnualTargetMR extends Component {
type="text"
placeholder=""
defaultValue={value}
disabled={this.state.get_for == 'view'? true : 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'}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
handleChange(event.target.value, tableMeta, 'text')
// // console.log(dataTable2)
}}
/>
......@@ -1187,7 +1281,7 @@ export default class CorporateAnnualTargetMR extends Component {
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ width: '50%' }}>
......@@ -1254,8 +1348,32 @@ export default class CorporateAnnualTargetMR extends Component {
</MuiThemeProvider>
)}
</div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5}}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Last Updated by : {this.state.updateBy}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>TOTAL SCORE</Typography>
</div>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalScore}</Typography>
</div>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15}}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notes}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography>
</div>
<div style={{borderStyle: 'solid', backgroundColor: this.handleBackgroundPerf(this.state.totalScore), borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</Typography>
</div>
</div>
</div>
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
......@@ -1273,7 +1391,7 @@ export default class CorporateAnnualTargetMR extends Component {
outline: 'none'
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginLeft: 5 }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
......@@ -1313,10 +1431,10 @@ export default class CorporateAnnualTargetMR extends Component {
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
this.setState({ loading: true, dataTable: dataTable2, saveDraft: false, buttonError: false }, () => {
setTimeout(() => {
// this.handleValidate()
this.setState({ loading: false })
this.handleCalculate()
}, 100);
})
}}
......@@ -1371,7 +1489,7 @@ export default class CorporateAnnualTargetMR extends Component {
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 10 }}>
{this.state.buttonError?
<LightTooltip title={"Data Incomplete"} arrow>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
......@@ -1405,6 +1523,32 @@ export default class CorporateAnnualTargetMR extends Component {
</MuiThemeProvider>
)}
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5}}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Last Updated by : {this.state.updateBy}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>TOTAL SCORE</Typography>
</div>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalScore}</Typography>
</div>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15}}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notes}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography>
</div>
<div style={{borderStyle: 'solid', backgroundColor: this.handleBackgroundPerf(this.state.totalScore), borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</Typography>
</div>
</div>
</div>
<div className="grid grid-2x" style={{ marginTop: 10, padding: 20 }}>
<div className="col-1" style={{paddingLeft: 0}}>
<button
......@@ -1535,7 +1679,7 @@ export default class CorporateAnnualTargetMR extends Component {
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onUpload={() => {
String(this.state.judul).includes("MONTHLY REPORT - PERFORMANCE CAT") ?
String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("PERFORMANCE") && String(this.state.judul).includes("CAT") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
......
......@@ -3761,8 +3761,8 @@ export default class ListOfCreditFacilities extends Component {
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography>
</div>
<div style={{border: '1px solid black', padding: 5, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalOutStand}</Typography>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', minWidth: 200, }}>{this.state.totalOutStand}</Typography>
</div>
</div>
</div>
......@@ -3771,7 +3771,7 @@ export default class ListOfCreditFacilities extends Component {
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Diff</Typography>
</div>
<div style={{borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, display: 'flex', justifyContent: 'flex-end'}}>
<div style={{borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.diff}</Typography>
</div>
</div>
......
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