Commit c214903c authored by Faisal Hamdi's avatar Faisal Hamdi

Merge branch 'faisal' into 'master'

Faisal

See merge request !1419
parents a6a73f8c 99b41a7d
...@@ -38,8 +38,8 @@ export default class SubHolding extends Component { ...@@ -38,8 +38,8 @@ export default class SubHolding extends Component {
{ value: 7, label: 'Balance Sheet - Summary' }, { value: 7, label: 'Balance Sheet - Summary' },
{ value: 8, label: 'Profit Loss - Summary' }, { value: 8, label: 'Profit Loss - Summary' },
{ value: 9, label: 'Financial Ratio - Summary' }, { value: 9, label: 'Financial Ratio - Summary' },
{ value: 10, label: 'CAT Performance Quarterly' }, { value: 11, label: 'CAT Performance Quarterly' },
{ value: 11, label: 'CAT Performance Appraisal' }, { value: 10, label: 'CAT Performance Appraisal' },
], ],
report: null, report: null,
loading: false, loading: false,
...@@ -2881,7 +2881,7 @@ export default class SubHolding extends Component { ...@@ -2881,7 +2881,7 @@ export default class SubHolding extends Component {
}) })
}) })
}) })
} else if (this.state.report.value === 10) { } else if (this.state.report.value === 11) {
let dbCATPQ = []; let dbCATPQ = [];
let payloadCATPQ = {...payload, report_id: 17, quarter: this.state.quarter.name} let payloadCATPQ = {...payload, report_id: 17, quarter: this.state.quarter.name}
api.create().getReportCATPQ(payloadCATPQ).then(response => { api.create().getReportCATPQ(payloadCATPQ).then(response => {
...@@ -2967,7 +2967,7 @@ export default class SubHolding extends Component { ...@@ -2967,7 +2967,7 @@ export default class SubHolding extends Component {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} }
}) })
} else if (this.state.report.value === 11) { } else if (this.state.report.value === 10) {
let dbCATPA = [] let dbCATPA = []
let payloadCATPA = {...payload, months: this.state.month.month_id, get_for: "view"} let payloadCATPA = {...payload, months: this.state.month.month_id, get_for: "view"}
api.create().getReportCATPA(payloadCATPA).then(response => { api.create().getReportCATPA(payloadCATPA).then(response => {
...@@ -2981,6 +2981,55 @@ export default class SubHolding extends Component { ...@@ -2981,6 +2981,55 @@ export default class SubHolding extends Component {
if (indexIDzz === -1) { if (indexIDzz === -1) {
let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE' let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE'
let weight = String(item.corporate_annual_target.weight).substr(0, String(item.corporate_annual_target.weight).length - 1) let weight = String(item.corporate_annual_target.weight).substr(0, String(item.corporate_annual_target.weight).length - 1)
let achivementYtd = 0
if (item.formula_ytd == 'HIB') {
let actual = item.corporate_annual_target.actual_ytd == "" ? 0 : Number(item.corporate_annual_target.actual_ytd)
let target = item.corporate_annual_target.target_ytd == "" ? 0 : Number(item.corporate_annual_target.target_ytd)
if (target < 0) {
if (actual > target) {
achivementYtd = (actual / target) - 1
} else {
achivementYtd = (actual / target)
}
} else if (target == 0) {
if (target >= actual) {
achivementYtd = 1.26
} else {
achivementYtd = 0
}
} else {
if (actual == target) {
achivementYtd = (actual / target)
} else {
achivementYtd = 2 - (actual / target)
}
}
} else {
let actual = item.corporate_annual_target.actual_ytd == "" ? 0 : Number(item.corporate_annual_target.actual_ytd)
let target = item.corporate_annual_target.target_ytd == "" ? 0 : Number(item.corporate_annual_target.target_ytd)
if (target < 0) {
if (actual >= target) {
achivementYtd = ((target - actual) / target) + 1
} else {
achivementYtd = (target - actual) / target
}
} else if (target == 0) {
if (target <= actual) {
achivementYtd = 1.26
} else {
achivementYtd = 0
}
} else {
// if (actual <= target) {
achivementYtd = (actual / target)
// } else {
// achivementYtd = 1 - (actual / target)
// }
}
}
// total = String(total) == 'NaN' || String(total) == 'Infinity' || String(total) == '-Infinity' ? 0 : total
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) * 100
dbCATPA.push([ dbCATPA.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -2995,7 +3044,7 @@ export default class SubHolding extends Component { ...@@ -2995,7 +3044,7 @@ export default class SubHolding extends Component {
item.formula_ytd, item.formula_ytd,
item.corporate_annual_target.actual_ytd, item.corporate_annual_target.actual_ytd,
item.corporate_annual_target.target_ytd, item.corporate_annual_target.target_ytd,
item.corporate_annual_target.achivement_ytd, isNaN(achivementYtd) || achivementYtd == 'Infinity' || achivementYtd == '-Infinity'? 0 : (Number(achivementYtd) * 100),
item.corporate_annual_target.score, item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight, item.corporate_annual_target.score_x_weight,
item.order item.order
...@@ -3821,9 +3870,9 @@ export default class SubHolding extends Component { ...@@ -3821,9 +3870,9 @@ export default class SubHolding extends Component {
a.download = 'Report Financial Ratio - Summary.xlsx'; a.download = 'Report Financial Ratio - Summary.xlsx';
a.click(); a.click();
} }
} else if (this.state.report.value === 10) { } else if (this.state.report.value === 11) {
let res = await fetch( let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/performance_quarterly/export?submission_id=${this.state.submissionID === null ? "" : this.state.submissionID}&&report_id=4&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.revisionType}` `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/performance_quarterly/export?submission_id=${this.state.submissionID === null ? "" : this.state.submissionID}&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.revisionType}`
) )
res = await res.blob() res = await res.blob()
this.setState({ loading: false }) this.setState({ loading: false })
...@@ -3834,10 +3883,11 @@ export default class SubHolding extends Component { ...@@ -3834,10 +3883,11 @@ export default class SubHolding extends Component {
a.download = 'Report CAT Performance Quarterly.xlsx'; a.download = 'Report CAT Performance Quarterly.xlsx';
a.click(); a.click();
} }
} else if (this.state.report.value === 11) { } else if (this.state.report.value === 10) {
let res = await fetch( let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/performance_appraisal/export?submission_id=${this.state.submissionID === null ? "" : this.state.submissionID}&&report_id=4&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.revisionType}` `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/performance_appraisal/export?submission_id=${this.state.submissionID === null ? "" : this.state.submissionID}&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.revisionType}`
) )
console.log(res);
res = await res.blob() res = await res.blob()
this.setState({ loading: false }) this.setState({ loading: false })
if (res.size > 0) { if (res.size > 0) {
......
...@@ -38,7 +38,8 @@ export default class TableSubHolding extends Component { ...@@ -38,7 +38,8 @@ export default class TableSubHolding extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
perfomanceScoreColor: '#fff' perfomanceScoreColor: '#fff',
parameterScore: [],
} }
} }
...@@ -1049,6 +1050,39 @@ export default class TableSubHolding extends Component { ...@@ -1049,6 +1050,39 @@ export default class TableSubHolding extends Component {
return total return total
} }
const handleScore = (tableMeta) => {
console.log(tableMeta);
console.log(this.state.parameterScore);
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() && String(val.company_name).toLocaleLowerCase() === "default")
let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id)
let totalScore = 0
let achx100 = tableMeta.rowData[9] == '100%' && (tableMeta.rowData[8] == 'HIB' || tableMeta.rowData[8] == 'HIG') ? Number(tableMeta.rowData[13]) / 100 > 1 ? 1 : Number(tableMeta.rowData[13]) / 100 : Number(tableMeta.rowData[13]) / 100
if (listParameterFilterCompany.length == 0) {
listParameterFilter.map((item, index) => {
if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
totalScore = Number(item.value)
}
})
} else {
listParameterFilterCompany.map((item, index) => {
if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
totalScore = Number(item.value)
}
})
}
if (Number(tableMeta.rowData[12]) == Number(0)) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(0).toFixed(0)
return Number(0).toFixed(0)
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(totalScore).toFixed(0)
return Number(totalScore).toFixed(0)
}
}
const columnDBBS = [{ const columnDBBS = [{
name: "", name: "",
options: { options: {
...@@ -27367,7 +27401,7 @@ export default class TableSubHolding extends Component { ...@@ -27367,7 +27401,7 @@ export default class TableSubHolding extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={Number(value).toFixed(2)} value={Number(value).toFixed(1)}
disabled={true} disabled={true}
/> />
} }
...@@ -27399,7 +27433,7 @@ export default class TableSubHolding extends Component { ...@@ -27399,7 +27433,7 @@ export default class TableSubHolding extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={Number(value).toFixed(2)} value={Number(value).toFixed(1)}
disabled={true} disabled={true}
/> />
} }
...@@ -27432,7 +27466,7 @@ export default class TableSubHolding extends Component { ...@@ -27432,7 +27466,7 @@ export default class TableSubHolding extends Component {
type="text" type="text"
placeholder="" placeholder=""
suffix={'%'} suffix={'%'}
value={Number(value).toFixed(2)} value={Number(value).toFixed(1)}
disabled={true} disabled={true}
/> />
} }
...@@ -27457,15 +27491,22 @@ export default class TableSubHolding extends Component { ...@@ -27457,15 +27491,22 @@ export default class TableSubHolding extends Component {
null : null :
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={Number(value).toFixed(1)} value={Number(value).toFixed(0)}
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={Number(value).toFixed(2)} value={handleScore(tableMeta)}
// value={Number(value).toFixed(1)}
decimalScale={0}
disabled={true} disabled={true}
// onBlur={(event) => {
// // updateValue(event.target.value)
// handleChange(event.target.value, tableMeta)
// // // console.log(dataTable2)
// }}
/> />
} }
/> />
...@@ -27496,7 +27537,7 @@ export default class TableSubHolding extends Component { ...@@ -27496,7 +27537,7 @@ export default class TableSubHolding extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={Number(value).toFixed(2)} value={Number(value).toFixed(1)}
disabled={true} disabled={true}
/> />
} }
...@@ -27521,12 +27562,12 @@ export default class TableSubHolding extends Component { ...@@ -27521,12 +27562,12 @@ export default class TableSubHolding extends Component {
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
columns={this.props.type === 2 ? columnDBBS : this.props.type === 1 ? columnDBPLDetail : this.props.type === 3 ? columnDBPL : this.props.type === 4 ? columnDBFR : this.props.type === 5 ? columnDBTP : this.props.type === 7 ? columnSummaryBS : this.props.type === 21 ? columnDBOI : this.props.type === 6? columnDBCF : this.props.type === 8 ? columnSummaryPL : this.props.type === 9 ? columnSummaryFR : this.props.type === 10 ? columnCatPQ : this.props.type === 11 ? columnCatPA : columns} columns={this.props.type === 2 ? columnDBBS : this.props.type === 1 ? columnDBPLDetail : this.props.type === 3 ? columnDBPL : this.props.type === 4 ? columnDBFR : this.props.type === 5 ? columnDBTP : this.props.type === 7 ? columnSummaryBS : this.props.type === 21 ? columnDBOI : this.props.type === 6? columnDBCF : this.props.type === 8 ? columnSummaryPL : this.props.type === 9 ? columnSummaryFR : this.props.type === 11 ? columnCatPQ : this.props.type === 10 ? columnCatPA : columns}
options={options} options={options}
/> />
</MuiThemeProvider> </MuiThemeProvider>
</div> </div>
{this.props.type === 11 ? {this.props.type === 10 ?
<div style={{ paddingBottom: 15 }}> <div style={{ paddingBottom: 15 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5 }}> <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5 }}>
<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