Commit 5837cac9 authored by Faisal Hamdi's avatar Faisal Hamdi

Merge branch 'faisal' into 'master'

fam tofixed

See merge request !1052
parents fdb96806 7cc0e206
...@@ -44,1193 +44,20 @@ export default class CorporateAnnualTargetPA extends Component { ...@@ -44,1193 +44,20 @@ export default class CorporateAnnualTargetPA extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
dataTables: [], dataTable: [],
loading: true, loading: false,
kpiTypeList: [],
maxAchList: [],
formulaYtdList: {
options: [{ value: 'SUM' }, { value: 'AVG' }, { value: 'LAST' }],
getOptionLabel: (option) => titleCase(option.value),
},
visibleCATMR: true,
updateBy: '-',
notes: "",
judulColumn: null,
get_for: "view",
parameterScore: [],
totalScore: 0,
perfomanceScore: '',
buttonError: true,
viewOnly: true,
aa: 0
} }
this.fileHandler = this.fileHandler.bind(this);
} }
componentDidMount() { componentDidMount() {
// this.getItemHierarki() // this.getItemHierarki()
this.getLatestUpdate()
this.getKPIType()
this.getMaxAch()
this.getParameterGroup()
this.handleViewOnly()
}
handleGetFor(type) {
this.setState({ get_for: type }, () => {
this.getLatestUpdate()
this.getKPIType()
this.getMaxAch()
})
}
handleViewOnly() {
let checkApprover = false
let checkLastStatus = false
let checkStatus = false
let checkPrevRev = false
if (this.props.isApprover) {
checkApprover = true
} else {
checkApprover = false
}
if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
checkLastStatus = true
} else {
checkLastStatus = false
}
if (this.props.prevRevision) {
checkPrevRev = true
} else {
checkPrevRev = false
}
if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
checkStatus = true
} else {
checkStatus = false
}
this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev})
}
getParameterGroup() {
api.create().getParameterByGroupName({
"group_name": 'ACHIEVEMENT_KPI'
}).then((response) => {
console.log(response.data)
if (response.data) {
this.setState({ parameterScore: response.data.data })
}
})
}
getLatestUpdate() {
let payload = {
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"monthly_report_id": this.props.monthlyReportId,
"months": this.props.month.month_id
}
// console.log(payload)
api.create().getLastestUpdateMR(payload).then(response => {
// console.log(JSON.stringify(response))
if (response.data) {
if (response.data.status === "success") {
this.setState({
updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update,
notes: response.data.data.notes_update === null ? "" : response.data.data.notes_update
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, typeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
// console.log('brrrrrrrr')
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
getItemHierarki() {
let payload = {
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"monthly_report_id": this.props.monthlyReportId,
"months": this.props.month.month_id,
"get_for": this.state.get_for
}
api.create().getHierarkiMontlyReportCAT(payload).then(response => {
let dataTable = []
console.log(payload);
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
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.corporate_annual_target.weight).substr(0, String(item.corporate_annual_target.weight).length - 1)
// 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 ? 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,
// parentTrue ? item.corporate_annual_target.kpi_type == "" ? null : { value: item.corporate_annual_target.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
parentTrue ? item.corporate_annual_target.max_ach == "" ? null : titleCase(item.corporate_annual_target.max_ach) : item.max_ach == "" ? null : titleCase(item.max_ach),
// parentTrue ? item.corporate_annual_target.max_ach == "" ? null : { value: titleCase(item.corporate_annual_target.max_ach) } : item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
item.corporate_annual_target.formula_ytd == "" ? null : item.corporate_annual_target.formula_ytd,
// parentTrue ? item.corporate_annual_target.formula == "" ? null : { value: item.corporate_annual_target.formula } : item.formula_ytd == "" ? null : { value: item.formula_ytd },
item.corporate_annual_target.actual_monthly == "" ? item.corporate_annual_target.actual_monthly : String(item.corporate_annual_target.actual_monthly).indexOf(".") == -1 ? Number(item.corporate_annual_target.actual_monthly) : Number(item.corporate_annual_target.actual_monthly).toFixed(1),
item.corporate_annual_target.target_monthly === null ? "0" : item.corporate_annual_target.target_monthly,
item.corporate_annual_target.achivement_monthly === null ? "0" : item.corporate_annual_target.achivement_monthly,
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.notes === null ? "" : item.corporate_annual_target.notes,
item.corporate_annual_target.actual_formula === null ? [] : item.corporate_annual_target.actual_formula,
item.order
])
// let index = dataTable.findIndex((val) => val[5] == item.description)
console.log(index, length - 1)
if (index == length -1 && item.parent_name == "LEARNING & GROWTH PERSPECTIVE") {
dataTable.push([
4,
0,
null,
"",
0,
"",
0.0,
"",
null,
null,
"",
"",
0.0,
"",
"",
"",
"",
[],
item.order + 1
])
}
}
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.formula,
item.level,
item.description,
item.weight == '' ? Number(0).toFixed(1) : Number(Number(item.weight) * 100).toFixed(1),
item.uom,
item.kpi_type == "" ? null : item.kpi_type,
// item.kpi_type == "" ? null : { value: item.kpi_type },
item.max_ach == "" ? null : titleCase(item.max_ach),
// item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
item.corporate_annual_target.formula == "" ? null : item.corporate_annual_target.formula_ytd,
// item.formula == "" ? null : { value: item.formula_ytd },
item.corporate_annual_target.actual_monthly == "" ? item.corporate_annual_target.actual_monthly : String(item.corporate_annual_target.actual_monthly).indexOf(".") == -1 ? Number(item.corporate_annual_target.actual_monthly) : Number(item.corporate_annual_target.actual_monthly).toFixed(1),
item.corporate_annual_target.target_monthly === null ? "0" : item.corporate_annual_target.target_monthly,
item.corporate_annual_target.achivement_monthly === null ? "0" : item.corporate_annual_target.achivement_monthly,
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.notes === null ? "" : item.corporate_annual_target.notes,
item.corporate_annual_target.actual_formula === null ? [] : item.corporate_annual_target.actual_formula,
item.order
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items, indexs, item.children.length)
})
}
}
})
// console.log(dataTable);
this.setState({ dataTable, loading: false, saveDraft: true }, () => {
this.handleCalculate(dataTable)
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
// console.log('terrrr')
//
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, saveDraft: true })
}
console.log(dataTable);
})
}
downloadTemplate = async () => {
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=2021`
)
console.log(res);
res = await res.blob()
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Template Monthly Report Corporate Annual Target.xlsx'
a.click();
}
}
async downloadAllData() {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
console.log(url);
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId === null ? "" : this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
)
res = await res.blob()
this.setState({ loading: false })
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Monthly Report Corporate Annual Target - Performance.xlsx';
a.click();
}
}
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
if (err) {
console.log(err);
}
else {
let isi = resp.rows.slice(3)
console.log(isi);
let payload = []
let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
weight: i[3] === undefined ? "" : (String(i[3])) === false ? "0" : String(i[3]).trim(),
uom: i[4] === undefined ? "" : (String(i[4])) === false ? "0" : String(i[4]).trim(),
jenis_kpi: i[5] === undefined ? "" : (String(i[5])) === false ? "0" : String(i[5]).trim(),
max_ach: i[6] === undefined ? "" : (String(i[6])) === false ? "0" : String(i[6]).trim(),
actual_monthly: i[7] === undefined ? "0.0" : (String(i[7])) === false ? "0" : String(i[7]).trim(),
notes: i[8] === undefined ? "" : (String(i[8])) === false ? "0" : String(i[8]).trim(),
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
months: this.props.month.month_id,
corporate_annual_target: payload,
status: "submitted"
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
checkUpload() {
this.setState({ loading: true })
api.create().checkUploadMonthlyReportCAT(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(this.state.payload)
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleCATMR: false })
let dataTable = response.data.data.map((item, index) => {
return [
item.type_report_id,
item.item_report_id,
item.parent,
item.formula,
item.level,
item.item_report,
String(item.weight).includes("%") ? String(item.weight).substr(0, String(item.weight).length - 1) : item.weight,
item.uom,
item.jenis_kpi,
item.max_ach,
item.formula_ytd,
item.actual_monthly,
item.target_monthly,
item.achivement_monthly,
item.score,
item.score_x_weight,
item.notes,
item.actual_formula === null ? [] : item.actual_formula,
item.order,
item.error
]
})
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.handleCalculate(dataTable)
this.state.dataTable.map(item => {
if (item[16].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
})
console.log(this.state.dataTable);
})
}
}
})
}
uploadCATMR(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
item_report: String(i[5]).trim(),
weight: String(i[6]),
uom: String(i[7]),
jenis_kpi: i[8] == null ? "" : i[8],
max_ach: i[9] == null ? "" : i[9],
formula_ytd: i[10] == null ? "" : i[10],
actual_monthly: String(Number(i[11]).toFixed(1)),
target_monthly: String(Number(i[12]).toFixed(1)),
achivement_monthly: String(Number(i[13]).toFixed(1)),
score: String(Number(i[14]).toFixed(1)),
score_x_weight: String(Number(i[15]).toFixed(2)),
notes: String(i[16]).trim()
})
})
let body = {
// "monthly_report_id": this.props.monthlyReportId,
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"months": this.props.month.month_id,
"corporate_annual_target": data,
"total_score": this.state.totalScore,
"performance": this.state.perfomanceScore
}
console.log(JSON.stringify(body));
api.create('UPLOAD').uploadMonthlyReportCAT(body).then(response => {
console.log(body);
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
// this.props.getReport()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
getKPIType() {
let body = {
group: 'CAT',
company_id: this.props.company.company_id,
type: 'KPI_TYPE'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
// // // console.log(data)
let inputKPI = []
data.map((item) => {
inputKPI.push({
value: item.value
})
})
let defaultProps = {
options: inputKPI,
getOptionLabel: (option) => titleCase(option.value),
};
// // // console.log(defaultProps)
this.setState({ kpiTypeList: defaultProps })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getMaxAch() {
let body = {
group: 'CAT',
company_id: this.props.company.company_id,
type: 'MAX_ACHIEVEMENT'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputMaxAch = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputMaxAch,
getOptionLabel: (option) => titleCase(option.value),
};
// setTimeout(() => {
this.setState({ maxAchList: defaultProps })
// }, 300);
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
this.getItemHierarki()
})
}
backToMonthlyReport(type) {
this.setState({ loading: true })
console.log(this.state.dataTable);
let data = []
this.state.dataTable.map(i => {
data.push({
"item_report_id": i[1],
"weight": i[6],
"uom": i[7],
"jenis_kpi": i[8] == null ? "" : i[8],
"max_ach": i[9] == null ? "" : i[9],
"formula_ytd": i[10] == null ? "" : i[10],
"actual_monthly": i[11] == null || i[11] == "" ? 0.0 : String(Number(i[11]).toFixed(1)),
"target_monthly": i[12] == null || i[12] == "" ? 0.0 : i[12],
"achivement_monthly": String(Number(i[13]).toFixed(1)),
"score": i[14],
"score_x_weight": i[15],
"notes": i[16]
})
})
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"months": this.props.month.month_id,
"corporate_annual_target": data,
"total_score": this.state.totalScore,
"performance": this.state.perfomanceScore
}
// console.log(JSON.stringify(payload));
console.log(payload);
api.create('UPLOAD').createMonthlyReportCAT(payload).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport()
} else {
this.setState({ loading: false }, () => {
this.props.saveToMonthlyReport()
})
}
} else {
this.setState({ loading: false }, () => {
// this.getSubmission()
document.body.style.overflow = 'unset';
})
}
})
} }
closeAlert() { closeAlert() {
this.setState({ alert: false }) this.setState({ alert: false })
} }
handleCalculate(datatable2) {
this.setState({ loading: true }, () => {
let total = 0
let perfomanceScore = ''
let totalWeight = 0
let datatable3 = datatable2.map((item, index) => {
// console.log(item[6])
//total weight
if (item[0] !== 1 && item[0] !== 4) {
if (item[12] == '' || String(item[12]) == '0' || String(item[12]) == '0.0') {
totalWeight += Number(0)
} else {
totalWeight += Number(item[6])
}
}
//ach
let totalAch = 0
if (item[8] == 'HIB') {
let actual = item[11] == "" ? 0 : Number(item[11])
let target = item[12] == "" ? 0 : Number(item[12])
totalAch = 2 - (actual / target)
} else {
let actual = item[11] == "" ? 0 : Number(item[11])
let target = item[12] == "" ? 0 : Number(item[12])
totalAch = actual / target
}
totalAch = String(totalAch) == 'NaN' || String(totalAch) == 'Infinity' || String(totalAch) == '-Infinity' ? 0 : totalAch
totalAch = Number(totalAch) * 100
// if (item[5] == "People Benchstrength") {
// console.log(totalAch)
// }
//score
let listParameter = this.state.parameterScore
let parameterKpi = item[8]
let parameterAch = String(item[9]).includes('%') ? `MAX${String(item[9]).substr(0, String(item[9]).length - 1)}` : String(item[9])
let parameterMix = `${parameterKpi}_${parameterAch}`
let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase())
let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id)
let totalScore = 0
let achx100 = item[9] == '100%' && (item[8] == 'HIB' || item[8] == 'HIG')? Number(totalAch) / 100 > 1 ? 1 : Number(totalAch) / 100 : Number(totalAch) / 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)
}
})
}
totalScore = Number(totalScore).toFixed(0)
//Score X Weight
let totalSW = 0
let handlePercent = ''
if (String(item[6]).includes('%')) {
handlePercent = String(item[6]).substr(0, String(item[6]).length - 1)
} else {
handlePercent = String(item[6])
}
if (item[12] == '' || String(item[12]) == '0' || String(item[12]) == '0.0') {
totalSW = 0
} else {
totalSW = (Number(totalScore) * Number(handlePercent) / 100)
}
totalSW = Number(totalSW).toFixed(2)
// console.log(totalSW)
if (item[0] !== 1 && item[0] !== 4) {
total += Number(totalSW)
}
return [
[
item[0],
item[1],
item[2],
item[3],
item[4],
item[5],
item[6],
item[7],
item[8],
item[9],
item[10],
item[11],
item[12],
totalAch,
totalScore,
totalSW,
item[16],
item[17],
item[18],
item[19],
]
]
})
console.log(totalWeight)
console.log(total)
console.log(datatable3);
totalWeight = Number(totalWeight) / 100
total = Number(Number(total).toFixed(2) / Number(totalWeight)).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 if (total >= 4.76 && total <= 5.00) {
perfomanceScore = 'IST'
}
setTimeout(() => {
this.setState({ totalScore: total, perfomanceScore, loading: false}, () => {
this.setState({loading: true})
setTimeout(() => {
this.setState({loading: false})
}, 500);
})
}, 500);
})
}
handleBackgroundPerf(total) {
// console.log(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 if (total >= 4.76 && total <= 5.00) {
color = 'dodgerblue'
}
return color
}
render() { render() {
let dataTable2 = this.state.dataTable
let dataDelete = this.state.dataDelete
const handleChange = (value, tableMeta, type) => {
let val = String(value).split(",").join("")
if (type == 'text') {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
}
}
const handleValueFormula = (value, tableMeta, column, periode, forecast) => {
// loading = true
let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
let baru = []
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 re = /^[a-zA-Z0-9_]+$/;
if (item !== "") {
if (!re.test(items)) {
baru.push(subForm)
baru.push(items)
} else {
baru.push(String(item))
}
}
})
// console.log(splitFormula)
// console.log(baru)
baru.map((item, index) => {
if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
anjay.push(item)
} else if (item == '' || item == '@') {
// } else if (item == "CurrMonth") {
// anjay.push(String(column))
// } else if (item.includes('[CM]SUM')) {
// let columnStart = 13
// let indexX = String(item).indexOf('[')
// let formulaAwal = String(item).substr(0, indexX)
// let columnEnd = 24
// let month = column - 1
// let total = 0
// // // // console.log(formulaAwal)
// if (forecast == undefined) {
// dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
// if (indexz >= columnStart && indexz <= columnStart + month) {
// let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${formulaAwal}`) && val.periode == Number(this.props.periode))
// if (indexID !== -1) {
// let valuezz = Number(value.formula[indexID].value)
// total += valuezz
// }
// }
// })
// } else {
// }
// anjay.push(String(total))
// } else if (item.includes('[CM]AVG')) {
// if (forecast == undefined) {
// anjay.push('/')
// anjay.push(column)
// }
}
else if (item.includes('X')) {
let indexX = String(item).indexOf('X')
if (indexX == 0) {
anjay.push(String(item).substr(1, String(item).length))
} else {
let formulaAwal = String(item).substr(0, indexX - 1)
let operatorX = String(item).substr(indexX - 1, 1)
let nilaiX = String(item).substr(indexX + 1, String(item).length)
if (forecast == undefined) {
// console.log(formulaAwal)
// console.log(tableMeta.rowData[17])
let indexID = tableMeta.rowData[17].findIndex((val) => val.item_formula == String(`@${formulaAwal}`) && val.periode == Number(this.props.periode))
if (indexID !== -1) {
let valuezz = tableMeta.rowData[17][indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
// // // console.log(dataTable2[tableMeta.rowIndex][30])
let array = dataTable2[tableMeta.rowIndex][18].filter((val) => val.periode == Number(column))
let valuezz = array[0].value
// // // console.log(valuezz)
anjay.push(valuezz == "" ? 0 : valuezz)
// let indexID = dataTable2[tableMeta.rowIndex][30].findIndex((val) => val.periode == Number(this.props.periode))
// if (indexID !== -1) {
// let valuezz = value.formula[indexID].value
// anjay.push(valuezz == "" ? 0 : valuezz)
// }
}
anjay.push(operatorX)
anjay.push(nilaiX)
}
} else {
if (String(item).includes('#')) {
if (forecast == undefined) {
let indexID = tableMeta.rowData[17].findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
if (indexID !== -1) {
let valuezz = tableMeta.rowData[17][indexID].value
anjay.push(valuezz == "" || valuezz == null ? "0" : valuezz)
}
}
} else {
let indexID = dataTable2.findIndex((val) => val[18] == item)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][column].value == undefined ? dataTable2[indexID][column] : dataTable2[indexID][column].value
if (item == dataTable2[tableMeta.rowIndex][18]) {
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 = []
let brpKurung = 0
anjay.map((item, index) => {
if (item == "(") {
kurung = true
// brpKurung += 1
} else if (item == ")") {
// brpKurung -= 1
// if (brpKurung == 0) {
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 = dataTable2[tableMeta.rowIndex][5] == "ROIC" ? "0" : R.equals(total, NaN) ? "0.0" : total
if (dataTable2[tableMeta.rowIndex][5] == "ROIC") {
dataTable2[tableMeta.rowIndex][column] = 0
} else {
dataTable2[tableMeta.rowIndex][column] = total
}
return total
}
const handleChangeText = (value, tableMeta) => {
// // console.log(value)
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
// this.setState({dataTable: dataTable2})
}
const handleAction = (idParent, typeReport, tableMeta) => {
if (this.props.isApprover) {
return false
} 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 (idParent !== null) {
// console.log(tableMeta)
let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
if (dataTable2[indexsss][5] == 'CUSTOMER PERSPECTIVE' || dataTable2[indexsss][5] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
return true
} else {
if (typeReport == 3) {
return true
} else {
return false
}
}
} else {
if (typeReport == null || typeReport == 3) {
return true
} else if (tableMeta !== undefined && tableMeta.rowData[0] == 1) {
let indexID = dataTable2.findIndex((val) => val[2] == tableMeta.rowData[1])
if (indexID !== -1) {
return false
} else {
return true
}
} else {
return false
}
}
// } else {
// return false
// }
}
}
const handleTambah = (data, rowIndex) => {
// console.log(dataTable2)
let newData = []
dataTable2.map((item, index) => {
newData.push(item)
if (index == rowIndex) {
newData.push([
null,
"",
item[2] == null || item[2] == "" ? item[1] : item[2],
item[3],
item[4],
"",
"",
"",
"",
null,
null,
null,
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
])
}
})
dataTable2 = newData
this.setState({ dataTable: dataTable2 }, () => {
setTimeout(() => {
this.setState({ loading: false })
// console.log(dataTable2)
}, 500)
})
}
const handleDelete = (index) => {
if (dataTable2[index][1] !== "") {
dataDelete.push(dataTable2[index][1])
}
dataTable2.splice(index, 1)
this.setState({ dataTable: dataTable2, dataDelete }, () => {
setTimeout(() => {
this.setState({ loading: false })
}, 100)
})
}
const handleAchiement = (tableMeta) => {
let total = 0
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) * 100
return Number(total) * 100
}
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() && 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(totalScore).toFixed(0)
return Number(totalScore).toFixed(0)
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(0).toFixed(0)
return Number(0).toFixed(0)
}
}
let someXXX = this.state.aa
const handleTotal = (tableMeta) => {
let total = 0
let handlePercent = ''
// if (tableMeta.rowData[5] == 'Trading profit (NPBT buah luar & plasma)') {
// console.log(dataTable2[tableMeta.rowIndex])
// }
if (tableMeta.rowData[0] == 4) {
let totalScore = 0
dataTable2.map((item,index) => {
if(item[0] !== 4 && item[0] !== 1) {
totalScore += Number(item[15])
}
})
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(totalScore).toFixed(2)
if (tableMeta.rowIndex == dataTable2.length -1) {
someXXX = Number(totalScore).toFixed(2)
console.log(someXXX)
}
return null
} else {
if (String(dataTable2[tableMeta.rowIndex][6]).includes('%')) {
// handlePercent = String(dataTable2[tableMeta.rowIndex][6])
handlePercent = String(dataTable2[tableMeta.rowIndex][6]).substr(0, String(dataTable2[tableMeta.rowIndex][6]).length - 1)
} else {
handlePercent = String(dataTable2[tableMeta.rowIndex][6])
}
// console.log(handlePercent)
if (dataTable2[tableMeta.rowIndex][12] == '' || String(dataTable2[tableMeta.rowIndex][12]) == '0' || String(dataTable2[tableMeta.rowIndex][12]) == '0.0') {
total = 0
} else {
total = Number(dataTable2[tableMeta.rowIndex][14]) * Number(handlePercent) / 100
// console.log(total)
}
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(2)
return total
}
}
const columnCatPQ = [ const columnCatPQ = [
{ {
name: "Key Performance Indicator", name: "Key Performance Indicator",
...@@ -1358,7 +185,7 @@ export default class CorporateAnnualTargetPA extends Component { ...@@ -1358,7 +185,7 @@ export default class CorporateAnnualTargetPA extends Component {
} }
} }
}, { }, {
name: `Actual ${this.props.month.month_value} ${Number(this.props.periode)}`, name: `Actual 2021`,
options: { options: {
customHeadRender: (columnMeta) => ( customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 75, borderLeft: '1px #fff solid' }}> <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 75, borderLeft: '1px #fff solid' }}>
...@@ -1369,54 +196,33 @@ export default class CorporateAnnualTargetPA extends Component { ...@@ -1369,54 +196,33 @@ export default class CorporateAnnualTargetPA extends Component {
return ( return (
<div style={{ width: 75, textAlign: 'right' }}> <div style={{ width: 75, textAlign: 'right' }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null null :
:
this.state.get_for == 'view' ?
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={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={true}
decimalScale={1}
/>
:
<div style={{ flex: 1, textAlign: 'right' }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={Number(value).toFixed(1)} value={Number(value).toFixed(1)}
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ color: this.state.get_for == 'view' ? "black" : handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) ? "#5198ea" : 'black', 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={tableMeta.rowData[5] === "ROIC" ? Number(value).toFixed(1) : tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ? Number(handleValueFormula(value, tableMeta, tableMeta.columnIndex)).toFixed(1) : Number(value).toFixed(1)} value={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.state.get_for == 'view' ? true : !handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta)}
decimalScale={1} decimalScale={1}
onBlur={(event) => { disabled={true}
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
// // console.log(dataTable2)
}}
/> />
} }
/> />
</div>
} }
</div> </div>
) )
} }
} }
}, { }, {
name: `Target ${this.props.month.month_value} ${Number(this.props.periode)}`, name: `Target 2021`,
options: { options: {
customHeadRender: (columnMeta) => ( customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 75, borderLeft: '1px #fff solid' }}> <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: 'rgb(200 224 229)', width: 75, borderLeft: '1px #fff solid' }}>
<Typography style={{ color: '#fff', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography> <Typography style={{ color: '#000', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell> </TableCell>
), ),
customBodyRender: (value, tableMeta) => { customBodyRender: (value, tableMeta) => {
...@@ -1445,7 +251,7 @@ export default class CorporateAnnualTargetPA extends Component { ...@@ -1445,7 +251,7 @@ export default class CorporateAnnualTargetPA extends Component {
} }
} }
}, { }, {
name: `Achivement ${this.props.month.month_value} ${Number(this.props.periode)} (%)`, name: `Achivement 2021 (%)`,
options: { options: {
customHeadRender: (columnMeta) => ( customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 75, borderLeft: '1px #fff solid' }}> <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 75, borderLeft: '1px #fff solid' }}>
...@@ -1457,19 +263,6 @@ export default class CorporateAnnualTargetPA extends Component { ...@@ -1457,19 +263,6 @@ export default class CorporateAnnualTargetPA extends Component {
<div style={{ width: 75, textAlign: 'right' }}> <div style={{ width: 75, textAlign: 'right' }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null : null :
this.state.get_for == 'view' ?
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={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={true}
suffix={"%"}
decimalScale={1}
/>
:
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={Number(value).toFixed(1)} value={Number(value).toFixed(1)}
...@@ -1479,8 +272,7 @@ export default class CorporateAnnualTargetPA extends Component { ...@@ -1479,8 +272,7 @@ export default class CorporateAnnualTargetPA 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=""
suffix={"%"} value={Number(value).toFixed(1)}
value={handleAchiement(tableMeta).toFixed(1)}
decimalScale={1} decimalScale={1}
disabled={true} disabled={true}
/> />
...@@ -1504,35 +296,18 @@ export default class CorporateAnnualTargetPA extends Component { ...@@ -1504,35 +296,18 @@ export default class CorporateAnnualTargetPA extends Component {
<div style={{ width: 70, textAlign: 'right' }}> <div style={{ width: 70, textAlign: 'right' }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null : null :
this.state.get_for == 'view' ?
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={Number(value).toFixed(0)}
// 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={true}
decimalScale={0}
/>
:
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={Number(value).toFixed(0)} value={Number(value).toFixed(1)}
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={handleScore(tableMeta)} value={Number(value).toFixed(1)}
decimalScale={0} decimalScale={1}
disabled={true} disabled={true}
// onBlur={(event) => {
// // updateValue(event.target.value)
// handleChange(event.target.value, tableMeta)
// // // console.log(dataTable2)
// }}
/> />
} }
/> />
...@@ -1552,31 +327,22 @@ export default class CorporateAnnualTargetPA extends Component { ...@@ -1552,31 +327,22 @@ export default class CorporateAnnualTargetPA extends Component {
customBodyRender: (value, tableMeta) => { customBodyRender: (value, tableMeta) => {
return ( return (
<div style={{ width: 75 }}> <div style={{ width: 75 }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2? {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null : null :
tableMeta.rowData[0] === 4? <FormControlLabel
handleTotal(tableMeta) style={{ margin: 0 }}
: value={Number(value).toFixed(1)}
this.state.get_for == 'view' ? control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ color: "black", 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={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)} decimalScale={1}
disabled={true} disabled={true}
decimalScale={2}
/> />
: }
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={handleTotal(tableMeta).toFixed(2)}
decimalScale={2}
disabled={true}
/> />
} }
</div> </div>
......
...@@ -401,13 +401,13 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -401,13 +401,13 @@ export default class FixedAssetsMovementMR extends Component {
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
"item_report_id": i[1], "item_report_id": i[1],
"mtd_mb": i[6], "mtd_mb": String(Number(i[6]).toFixed(1)),
"mtd_rb": i[7], "mtd_rb": String(Number(i[7]).toFixed(1)),
"mtd_actual": i[8], "mtd_actual": String(Number(i[8]).toFixed(1)),
"act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(i[9]), "act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(Number(i[9]).toFixed(1)),
"act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(i[10]), "act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(Number(i[10]).toFixed(1)),
"act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(i[11]), "act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(Number(i[11]).toFixed(1)),
"act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(i[12]) "act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(Number(i[12]).toFixed(1))
}) })
}) })
let payload = { let payload = {
......
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