Commit 0417ffcb authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'GGMAC' into 'master'

update issue

See merge request !1531
parents b678956e a673f6d2
......@@ -33,7 +33,11 @@ export default class DashboardCAT extends Component {
selectedKPI: [],
listKPI: [],
selectedMonth: [],
rawData: null
rawData: null,
reportIDCAT: null,
monthlyReportID: null,
revisionCAT: 0,
tableCAT: []
}
}
......@@ -48,7 +52,7 @@ export default class DashboardCAT extends Component {
console.log(dataStorageCAT)
// console.log(this.props.location.state.rawData.companyId)
console.log(this.state.selectedKPI)
this.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData}, () => {
this.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData }, () => {
this.getDetailUser()
})
})
......@@ -70,6 +74,114 @@ export default class DashboardCAT extends Component {
}
}
getMonthlyReportID() {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"months": this.state.month.month_id,
"is_approver": false
}
api.create().getMonthlyReportID(payload).then(response => {
if (response.data.data) {
this.setState({ monthlyReportID: response.data.data.monthly_report_id })
} else {
this.setState({ monthlyReportID: null })
}
this.getReport()
})
}
getReport() {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"report_type": "Monthly Report",
"months": this.state.month.month_id,
}
api.create().getMonthlyReport(payload).then(response => {
if (response.data.data) {
let indexID = response.data.data.findIndex((val) => val.report_name == "CAT")
this.setState({reportIDCAT: response.data.data[indexID].report_id, revisionCAT: response.data.data[indexID].revision}, () => {
console.log(this.state.reportIDCAT, this.state.revisionCAT)
this.getItemHierarki()
})
} else {
this.setState({reportIDCAT: null})
}
console.log(response)
})
}
getItemHierarki() {
let payload = {
"report_id": this.state.reportIDCAT,
"revision": this.state.revisionCAT,
"periode": this.state.periode.periode,
"company_id": this.state.company.company_id,
"monthly_report_id": this.state.monthlyReportID,
"months": this.state.month.month_id,
"get_for": 'view'
}
api.create().getHierarkiMontlyReportCAT(payload).then(response => {
let dataTable = []
if (response.data.data) {
let res = response.data.data
const handlePushChild = (item, index, length) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE'
let weight = String(item.weight).includes('%')? String(item.weight).substr(0, String(item.weight).length - 1) : String(item.weight)
let weightTB = String(item.corporate_annual_target.weight).includes('%')? String(item.corporate_annual_target.weight).substr(0, String(item.corporate_annual_target.weight).length - 1) : String(item.corporate_annual_target.weight)
// console.log(weight)
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
// item.corporate_annual_target.weight == "" ? Number(0).toFixed(1) : Number(weight).toFixed(1),
parentTrue ? weight : weightTB,
parentTrue ? item.corporate_annual_target.uom : item.uom,
parentTrue ? item.corporate_annual_target.jenis_kpi == "" ? null : item.corporate_annual_target.jenis_kpi : item.jenis_kpi == "" ? null : item.kpi_type,
])
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
// console.log(indexs, item.children.length)
handlePushChild(items, indexs, item.children.length)
})
}
}
}
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.level,
item.description,
item.uom,
item.kpi_type == "" ? null : item.kpi_type,
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items, indexs, item.children.length)
})
}
}
})
this.setState({tableCAT: dataTable}, () => {
console.log(this.state.tableCAT)
})
} else {
this.setState({tableCAT: []})
}
})
}
getDetailUser() {
console.log(this.state.rawData)
let userId = localStorage.getItem(Constant.USER)
......@@ -288,6 +400,7 @@ export default class DashboardCAT extends Component {
this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index], selectedMonth }, () => {
this.getDasboardCAT()
// this.getMonthlyReportID()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -306,6 +419,7 @@ export default class DashboardCAT extends Component {
}
getDasboardCAT() {
this.getMonthlyReportID()
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
......@@ -537,9 +651,9 @@ export default class DashboardCAT extends Component {
<Paper style={{ marginTop: 10, minWidth: this.props.open ? this.props.width - 360 : this.props.width - 100 }}>
<AppBar position="static" style={{ borderTopRightRadius: 10, borderTopLeftRadius: 10 }}>
<Tabs indicatorColor="white" value={this.state.tab} onChange={this.selectTab} aria-label="simple tabs example" style={{ backgroundColor: '#354960', borderColor: 'transparent', borderTopRightRadius: 10, borderTopLeftRadius: 10 }}>
<Tab label="Executive Scoreboard" style={{ color: 'white', fontSize: 11, width: 50, fontWeight: 'bold', backgroundColor: this.state.tab == 0? '#6c84a1' : '#354960' }} />
<Tab label="Strategy Map" style={{ color: 'white', fontSize: 11, width: 50, fontWeight: 'bold', backgroundColor: this.state.tab == 1? '#6c84a1' : '#354960' }} />
<Tab label="KPIs" style={{ color: 'white', fontSize: 11, width: 50, fontWeight: 'bold', backgroundColor: this.state.tab == 2? '#6c84a1' : '#354960' }} />
<Tab label="Executive Scoreboard" style={{ color: 'white', fontSize: 11, width: 50, fontWeight: 'bold', backgroundColor: this.state.tab == 0 ? '#6c84a1' : '#354960' }} />
<Tab label="Strategy Map" style={{ color: 'white', fontSize: 11, width: 50, fontWeight: 'bold', backgroundColor: this.state.tab == 1 ? '#6c84a1' : '#354960' }} />
<Tab label="KPIs" style={{ color: 'white', fontSize: 11, width: 50, fontWeight: 'bold', backgroundColor: this.state.tab == 2 ? '#6c84a1' : '#354960' }} />
</Tabs>
</AppBar>
{this.state.tab === 0 ?
......@@ -548,7 +662,7 @@ export default class DashboardCAT extends Component {
this.state.tab === 1 ?
<StrategiMap height={this.props.height} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
:
<KPIs height={this.props.height} selectedMonth={this.state.selectedMonth} width={this.props.open ? this.props.width - 360 : this.props.width - 100} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
<KPIs height={this.props.height} tableCAT={this.state.tableCAT} selectedMonth={this.state.selectedMonth} width={this.props.open ? this.props.width - 360 : this.props.width - 100} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
}
</Paper>
</div>}
......
......@@ -25,12 +25,19 @@ export default class StrategiMap extends Component {
this.olahDataKPI()
}
handleKPI(name) {
let arrayCAT = this.props.tableCAT
let indexID = this.props.tableCAT.findIndex((val) => String(val[5]).toLocaleLowerCase() == String(name).toLocaleLowerCase())
return arrayCAT[indexID][8]
}
olahDataKPI() {
console.log(this.state.dataStrategy)
let arrayNew = this.state.dataStrategyNew
this.state.dataStrategy.map((item, index) => {
let arrayNodes = []
item.nodes.map((itemz, indexz) => {
let kpi = this.handleKPI(itemz.item_name)
let act = []
let mbv = []
let yoy = []
......@@ -88,7 +95,7 @@ export default class StrategiMap extends Component {
sortMin = [minYOY]
sortMax = [maxYOY]
}
arrayNodes.push({ ...itemz, trends: { act, mbv, yoy, minACT, maxACT, minMBV, maxMBV, minYOY, maxYOY, sortMin, sortMax } })
arrayNodes.push({ ...itemz, kpi, trends: { act, mbv, yoy, minACT, maxACT, minMBV, maxMBV, minYOY, maxYOY, sortMin, sortMax } })
})
arrayNew.push({ ...item, nodes: arrayNodes })
})
......@@ -166,11 +173,11 @@ export default class StrategiMap extends Component {
}
if (actMo > prevMo) {
isHigh = 'true'
isHigh = item.kpi == 'HIG' ? 'true' : 'false'
} else if (actMo == prevMo) {
isHigh = 'same'
} else {
isHigh = 'false'
isHigh = item.kpi == 'HIB' ? 'true' : 'false'
}
return isHigh
......@@ -185,8 +192,9 @@ export default class StrategiMap extends Component {
let trendsMBLength = trendsMB.length
actMR = trendsAct[trendsActLength-1]
actMB = trendsMB[trendsMBLength-1]
let percentage = String(item.achievement).includes('%')? Number(String(item.achievement).substr(0,String(item.achievement).length -1)) : Number(item.achievement)
if (actMR < actMB) {
if (percentage < 100) {
isHigh = false
} else {
isHigh = true
......
......@@ -190,7 +190,7 @@ export default class BalanceSheetMR extends Component {
// if (item.balance_sheet.mtd_vs_previous_month == "" && Number(item.balance_sheet.percent_act_vs_previous_month) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_previous_month) > this.state.maxValue) {
// err = true
// }
if (item.balance_sheet.mtd_vs_mb == "" && Number(item.balance_sheet.percent_act_vs_mb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_mb) > this.state.maxValue) {
if (item.balance_sheet.mtd_vs_mb == "" && Number(item.balance_sheet.percent_act_vs_mb).toFixed(1) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_mb).toFixed(1) > this.state.maxValue) {
err = true
}
// if (item.balance_sheet.mtd_vs_rb == "" && Number(item.balance_sheet.percent_act_vs_rb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_rb) > this.state.maxValue) {
......@@ -238,7 +238,7 @@ export default class BalanceSheetMR extends Component {
// if (item.balance_sheet.mtd_vs_previous_month == "" && Number(item.balance_sheet.percent_act_vs_previous_month) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_previous_month) > this.state.maxValue) {
// err = true
// }
if (item.balance_sheet.mtd_vs_mb == "" && Number(item.balance_sheet.percent_act_vs_mb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_mb) > this.state.maxValue) {
if (item.balance_sheet.mtd_vs_mb == "" && Number(item.balance_sheet.percent_act_vs_mb).toFixed(1) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_mb).toFixed(1) > this.state.maxValue) {
err = true
}
// if (item.balance_sheet.mtd_vs_rb == "" && Number(item.balance_sheet.percent_act_vs_rb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_rb) > this.state.maxValue) {
......@@ -376,7 +376,7 @@ export default class BalanceSheetMR extends Component {
let err = false
let dataTable = response.data.data.map((item, index) => {
if (item.type_report_id === 3) {
if (item.mtd_vs_mb == "" && Number(item.percent_act_vs_mb) < this.state.minValue || Number(item.percent_act_vs_mb) > this.state.maxValue) {
if (item.mtd_vs_mb == "" && Number(item.percent_act_vs_mb).toFixed(1) < this.state.minValue || Number(item.percent_act_vs_mb).toFixed(1) > this.state.maxValue) {
err = true
}
}
......@@ -1820,7 +1820,7 @@ export default class BalanceSheetMR extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[12]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[12]).toFixed(1) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
suffix={'%'}
......@@ -1964,7 +1964,7 @@ export default class BalanceSheetMR extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[14]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[14]).toFixed(1) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
......@@ -2108,7 +2108,7 @@ export default class BalanceSheetMR extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[16]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[16]).toFixed(1) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
......@@ -2259,7 +2259,7 @@ export default class BalanceSheetMR extends Component {
defaultValue={tableMeta.rowData[17]}
inputProps={{
style: {
color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? "#5198ea" : '#5198ea',
color: Number(tableMeta.rowData[12]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[12]).toFixed(1) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'left'
}
}}
......@@ -2298,7 +2298,7 @@ export default class BalanceSheetMR extends Component {
style={{ margin: 0 }}
// value={value}
control={
tableMeta.rowData[18] === "" && (Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue) ?
tableMeta.rowData[18] === "" && (Number(tableMeta.rowData[14]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[14]).toFixed(1) > this.state.maxValue) ?
<LightTooltip title={"MTD Explanation vs MB is Reqiured"} arrow>
<Input
disableUnderline={true}
......@@ -2371,7 +2371,7 @@ export default class BalanceSheetMR extends Component {
defaultValue={tableMeta.rowData[18]}
inputProps={{
style: {
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : '#5198ea',
color: Number(tableMeta.rowData[14]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[14]).toFixed(1) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'left'
}
}}
......@@ -2481,7 +2481,7 @@ export default class BalanceSheetMR extends Component {
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? "#5198ea" : '#5198ea',
color: Number(tableMeta.rowData[16]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[16]).toFixed(1) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'left'
}
}}
......
......@@ -237,7 +237,7 @@ export default class ProfitLossMR extends Component {
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (item.type_report_id === 3) {
if (item.profit_loss.mtd_vs_mb == "" && Number(item.profit_loss.percent_act_vs_mb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_mb) > this.state.maxValue) {
if (item.profit_loss.mtd_vs_mb == "" && Number(item.profit_loss.percent_act_vs_mb).toFixed(1) < this.state.minValue || Number(item.profit_loss.percent_act_vs_mb).toFixed(1) > this.state.maxValue) {
err = true
}
}
......@@ -279,7 +279,7 @@ export default class ProfitLossMR extends Component {
}
res.map((item, index) => {
if (item.type_report_id === 3) {
if (item.profit_loss.mtd_vs_mb == "" && Number(item.profit_loss.percent_act_vs_mb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_mb) > this.state.maxValue) {
if (item.profit_loss.mtd_vs_mb == "" && Number(item.profit_loss.percent_act_vs_mb).toFixed(1) < this.state.minValue || Number(item.profit_loss.percent_act_vs_mb).toFixed(1) > this.state.maxValue) {
err = true
}
}
......@@ -610,7 +610,7 @@ export default class ProfitLossMR extends Component {
this.state.dataTable.map((i, index) => {
if (i[0] === 3) {
// console.log(i);
if (i[19] === "" && (Number(i[16]) < this.state.minValue || Number(i[16]) > this.state.maxValue)) {
if (i[19] === "" && (Number(i[16]).toFixed(1) < this.state.minValue || Number(i[16]).toFixed(1) > this.state.maxValue)) {
console.log('msk 1');
// console.log(i);
err = true
......@@ -1533,7 +1533,7 @@ export default class ProfitLossMR extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? 'red' : '#000000b0', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[14]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[14]).toFixed(1) > this.state.maxValue ? 'red' : '#000000b0', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
suffix={'%'}
......@@ -1612,7 +1612,7 @@ export default class ProfitLossMR extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? 'red' : '#000000b0', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[16]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[16]).toFixed(1) > this.state.maxValue ? 'red' : '#000000b0', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
suffix={'%'}
type="text"
placeholder=""
......@@ -1693,7 +1693,7 @@ export default class ProfitLossMR extends Component {
style={{ color: 'red', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
style={{ color: Number(tableMeta.rowData[18]) < this.state.minValue || Number(tableMeta.rowData[18]) > this.state.maxValue ? 'red' : '#000000b0', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[18]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[18]).toFixed(1) > this.state.maxValue ? 'red' : '#000000b0', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
suffix={'%'}
disabled={true}
value={Number(handleVariancePercent(tableMeta, 3, 5)).toFixed(1)}
......@@ -1790,7 +1790,7 @@ export default class ProfitLossMR extends Component {
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? "#5198ea" : '#5198ea',
color: Number(tableMeta.rowData[16]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[16]).toFixed(1) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'left'
}
}}
......@@ -1803,7 +1803,7 @@ export default class ProfitLossMR extends Component {
style={{ margin: 0 }}
// value={tableMeta.rowData[19]}
control={
tableMeta.rowData[19] === "" && (Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue) ?
tableMeta.rowData[19] === "" && (Number(tableMeta.rowData[16]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[16]).toFixed(1) > this.state.maxValue) ?
<LightTooltipError title={"MTD Explanation vs MB is Reqiured"} arrow>
<Input
disableUnderline={true}
......@@ -1839,7 +1839,7 @@ export default class ProfitLossMR extends Component {
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? "#5198ea" : '#5198ea',
color: Number(tableMeta.rowData[16]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[16]).toFixed(1) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'left'
}
}}
......
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