Commit 0938fec9 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'GGMAC' into 'master'

push dulu

See merge request !1226
parents 87e2fd49 73ba4332
...@@ -281,7 +281,7 @@ const create = (type = "") => { ...@@ -281,7 +281,7 @@ const create = (type = "") => {
const getReportFRMR = (body) => api.post('/transaction/summary_ratio/monthly_report/get_report_hierarki', body) const getReportFRMR = (body) => api.post('/transaction/summary_ratio/monthly_report/get_report_hierarki', body)
const getReportFRLastMR = (body) => api.post('/transaction/summary_ratio/monthly_report_last_year/get_report_hierarki', body) const getReportFRLastMR = (body) => api.post('/transaction/summary_ratio/monthly_report_last_year/get_report_hierarki', body)
const getReportBSSuma = (body) => api.post('/transaction/summary_balance_sheet/summary/get_report_hierarki', body) const getReportBSSuma = (body) => api.post('/transaction/summary_balance_sheet/summary/get_report_hierarki', body)
const getDashboardCAT = (body) => api.post('/dashboard/cat', body) const getDashboardCAT = (body) => api.post('/transaction/dashboard/get_dashboard_cat', body)
const getHierarkiReportYtd = (body) => api.post('/transaction/summary_ytd/summary/get_report_hierarki', body) const getHierarkiReportYtd = (body) => api.post('/transaction/summary_ytd/summary/get_report_hierarki', body)
const getHierarkiReportHistorical = (body) => api.post('/transaction/summary_historical/summary/get_report_hierarki', body) const getHierarkiReportHistorical = (body) => api.post('/transaction/summary_historical/summary/get_report_hierarki', body)
const getHierarkiReportMTD = (body) => api.post('/transaction/summary_mtd/summary/get_report_hierarki', body) const getHierarkiReportMTD = (body) => api.post('/transaction/summary_mtd/summary/get_report_hierarki', body)
......
...@@ -172,10 +172,9 @@ export default class BudgetTahunan extends Component { ...@@ -172,10 +172,9 @@ export default class BudgetTahunan extends Component {
if (response.data.status === "success") { if (response.data.status === "success") {
// // // console.log(response); // // // console.log(response);
if (response.data.data.is_approver === true) { if (response.data.data.is_approver === true) {
this.setState({ isApprover: true, permissionhandle: true, checkApprover: true }, () => this.setState({ isApprover: true, permissionhandle: true, checkApprover: true }, () => {
{ this.getPeriode()
this.getPeriode() })
})
} else { } else {
this.setState({ isApprover: false, permissionhandle: false, checkApprover: false }, () => this.setState({ isApprover: false, permissionhandle: false, checkApprover: false }, () =>
this.getDetailUser()) this.getDetailUser())
...@@ -214,7 +213,7 @@ export default class BudgetTahunan extends Component { ...@@ -214,7 +213,7 @@ export default class BudgetTahunan extends Component {
}) })
if (companyData.length > 0) { if (companyData.length > 0) {
companyData = companyData.sort((a,b) => a.company_name.localeCompare(b.company_name)) companyData = companyData.sort((a, b) => a.company_name.localeCompare(b.company_name))
} }
let defaultProps = { let defaultProps = {
...@@ -287,7 +286,7 @@ export default class BudgetTahunan extends Component { ...@@ -287,7 +286,7 @@ export default class BudgetTahunan extends Component {
let indexC = String(item.current_status).toLocaleUpperCase().indexOf('C') let indexC = String(item.current_status).toLocaleUpperCase().indexOf('C')
let status_approv = '' let status_approv = ''
if (String(item.current_status).toLocaleUpperCase().includes('CC')) { if (String(item.current_status).toLocaleUpperCase().includes('CC')) {
status_approv = `${String(item.current_status).substr(0,indexC)}${String(item.current_status).substr(indexC+1,String(item.current_status).length)}` status_approv = `${String(item.current_status).substr(0, indexC)}${String(item.current_status).substr(indexC + 1, String(item.current_status).length)}`
} else { } else {
status_approv = String(item.current_status) status_approv = String(item.current_status)
} }
...@@ -382,7 +381,7 @@ export default class BudgetTahunan extends Component { ...@@ -382,7 +381,7 @@ export default class BudgetTahunan extends Component {
}) })
if (arrayBaru.length > 0) { if (arrayBaru.length > 0) {
arrayBaru = arrayBaru.sort((a,b) => a.company_name.localeCompare(b.company_name)) arrayBaru = arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name))
} }
let defaultProps = { let defaultProps = {
...@@ -413,7 +412,7 @@ export default class BudgetTahunan extends Component { ...@@ -413,7 +412,7 @@ export default class BudgetTahunan extends Component {
api.create().getLastPeriod(this.state.company.company_id).then(response => { api.create().getLastPeriod(this.state.company.company_id).then(response => {
// // console.log(response); // // console.log(response);
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ lastPeriod: this.state.userType !== ''? this.state.lastPeriod : response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => { this.setState({ lastPeriod: this.state.userType !== '' ? this.state.lastPeriod : response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => {
this.getPeriode() this.getPeriode()
}) })
} }
...@@ -514,7 +513,7 @@ export default class BudgetTahunan extends Component { ...@@ -514,7 +513,7 @@ export default class BudgetTahunan extends Component {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
"periode": this.state.periode.periode, "periode": this.state.periode.periode,
"is_approver": this.state.permissionhandle? this.state.permissionhandle : this.state.isApprover "is_approver": this.state.permissionhandle ? this.state.permissionhandle : this.state.isApprover
} }
console.log(payload) console.log(payload)
api.create().getSubmission(payload).then(response => { api.create().getSubmission(payload).then(response => {
...@@ -538,7 +537,7 @@ export default class BudgetTahunan extends Component { ...@@ -538,7 +537,7 @@ export default class BudgetTahunan extends Component {
this.getCashFlow(type) this.getCashFlow(type)
this.getPL(type) this.getPL(type)
} else { } else {
this.setState({loading: false}) this.setState({ loading: false })
} }
// this.getFR(type) // this.getFR(type)
api.create().checkApprover().then(response => { api.create().checkApprover().then(response => {
...@@ -673,7 +672,7 @@ export default class BudgetTahunan extends Component { ...@@ -673,7 +672,7 @@ export default class BudgetTahunan extends Component {
}) })
console.log(dataTable) console.log(dataTable)
this.setState({ dbCF: dataTable }, () => { this.setState({ dbCF: dataTable }, () => {
this.olahDataCashFlow(this.state.dbCF, type) this.olahDataCashFlow(this.state.dbCF, type)
}) })
} }
}) })
...@@ -689,7 +688,7 @@ export default class BudgetTahunan extends Component { ...@@ -689,7 +688,7 @@ export default class BudgetTahunan extends Component {
let items = String(item).substr(Number(String(item).length) - 1, 1) let items = String(item).substr(Number(String(item).length) - 1, 1)
let subForm = String(item).substr(0, Number(String(item).length) - 1) let subForm = String(item).substr(0, Number(String(item).length) - 1)
let re = /^[a-zA-Z0-9_]+$/; let re = /^[a-zA-Z0-9_]+$/;
if (item !== "") { if (item !== "" && item !== '@') {
if (!re.test(items)) { if (!re.test(items)) {
baru.push(subForm) baru.push(subForm)
baru.push(items) baru.push(items)
...@@ -707,15 +706,37 @@ export default class BudgetTahunan extends Component { ...@@ -707,15 +706,37 @@ export default class BudgetTahunan extends Component {
if (String(item).includes('[M-1]')) { if (String(item).includes('[M-1]')) {
if (forecast !== undefined) { if (forecast !== undefined) {
let forecastt = 0 let forecastt = 0
if (column == 19) {
let tst = String(item).replace('[M-1]', '')
let data = 18
let period = this.state.periode.periode - 1
let indexID = tableMeta[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
if (indexID !== -1) {
let valuezz = tableMeta[data].formula[indexID].value
if (tableMeta[5] == "Cash at the beginning period") {
// console.log(dataTable2[tableMeta.rowIndex+1])
// console.log(dataTable2[tableMeta.rowIndex+1][data].value)
let valuezzz = dataTable2[indexDBCF + 1][data].value
forecastt += Number(valuezzz == "" ? 0 : valuezzz)
} else {
forecastt += Number(valuezz == "" ? 0 : valuezz)
}
}
}
if (column == 20) { if (column == 20) {
let tst = String(item).replace('[M-1]', '') let tst = String(item).replace('[M-1]', '')
let data = 18 let data = 18
let period = this.state.periode.periode let period = this.state.periode.periode
let indexID = tableMeta[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period) let indexID = tableMeta[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = tableMeta[data].formula[indexID].value let valuezz = tableMeta[data].formula[indexID].value
forecastt += Number(valuezz == "" ? 0 : valuezz) if (tableMeta[5] == "Cash at the beginning period") {
let valuezzz = dataTable2[indexDBCF + 1][19]
forecastt += Number(valuezzz == "" ? 0 : valuezzz)
} else {
forecastt += Number(valuezz == "" ? 0 : valuezz)
}
} }
} }
...@@ -725,7 +746,12 @@ export default class BudgetTahunan extends Component { ...@@ -725,7 +746,12 @@ export default class BudgetTahunan extends Component {
let indexID = forecast.findIndex((val) => String(val.item_formula).replace('forecast_', '') == String(`@${tst}`) && val.periode == period) let indexID = forecast.findIndex((val) => String(val.item_formula).replace('forecast_', '') == String(`@${tst}`) && val.periode == period)
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = forecast[indexID].value let valuezz = forecast[indexID].value
forecastt += Number(valuezz == "" ? 0 : valuezz) if (tableMeta[5] == "Cash at the beginning period") {
let valuezzz = dataTable2[indexDBCF + 1][20]
forecastt += Number(valuezzz == "" ? 0 : valuezzz)
} else {
forecastt += Number(valuezz == "" ? 0 : valuezz)
}
} }
} }
...@@ -738,7 +764,12 @@ export default class BudgetTahunan extends Component { ...@@ -738,7 +764,12 @@ export default class BudgetTahunan extends Component {
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = tableMeta[data].formula[indexID].value let valuezz = tableMeta[data].formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz) if (tableMeta[5] == "Cash at the beginning period" && column != 7) {
let valuezzz = dataTable2[indexDBCF + 1][data].value
anjay.push(valuezzz == "" ? 0 : valuezzz)
} else {
anjay.push(valuezz == "" ? 0 : valuezz)
}
} }
} }
} else { } else {
...@@ -929,6 +960,14 @@ export default class BudgetTahunan extends Component { ...@@ -929,6 +960,14 @@ export default class BudgetTahunan extends Component {
} }
}) })
// if(tableMeta[5] == '2.1 Additional fixed assets and CIP' && column == 7) {
// console.log(splitFormula)
// console.log(baru)
// console.log(anjay)
// console.log(anjay2)
// console.log(total)
// }
total = R.equals(total, NaN) ? "0.0" : Number(total).toFixed(1) total = R.equals(total, NaN) ? "0.0" : Number(total).toFixed(1)
return total return total
} }
...@@ -938,97 +977,179 @@ export default class BudgetTahunan extends Component { ...@@ -938,97 +977,179 @@ export default class BudgetTahunan extends Component {
let dataTable2 = this.state.dbCF let dataTable2 = this.state.dbCF
// let indexID = dataTable2.findIndex((val) => tableMeta[1] == val[1]) // let indexID = dataTable2.findIndex((val) => tableMeta[1] == val[1])
// if (indexID != -1) { // if (indexID != -1) {
total = this.handleValueFormula(index, dataTable2[index][column], tableMeta, column, periode, dataTable2[index][25]) total = this.handleValueFormula(index, dataTable2[index][column], tableMeta, column, periode, dataTable2[index][25])
// } // }
return total return total
} }
olahDataCashFlow(dbCF, type) { olahDataCashFlow(dbCF, type) {
dbCF.map((item,index) => { dbCF.map((item, index) => {
if(item[0] == 5 || item[0] == 6 || item[0] == 7) { if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormula(index,item[7],item,7) item[7].value = this.handleValueFormula(index, item[7], item, 7)
item[8].value = this.handleValueFormula(index,item[8],item,8) item[8].value = this.handleValueFormula(index, item[8], item, 8)
item[9].value = this.handleValueFormula(index,item[9],item,9) item[9].value = this.handleValueFormula(index, item[9], item, 9)
item[10].value = this.handleValueFormula(index,item[10],item,10) item[10].value = this.handleValueFormula(index, item[10], item, 10)
item[11].value = this.handleValueFormula(index,item[11],item,11) item[11].value = this.handleValueFormula(index, item[11], item, 11)
item[12].value = this.handleValueFormula(index,item[12],item,12) item[12].value = this.handleValueFormula(index, item[12], item, 12)
item[13].value = this.handleValueFormula(index,item[13],item,13) item[13].value = this.handleValueFormula(index, item[13], item, 13)
item[14].value = this.handleValueFormula(index,item[14],item,14) item[14].value = this.handleValueFormula(index, item[14], item, 14)
item[15].value = this.handleValueFormula(index,item[15],item,15) item[15].value = this.handleValueFormula(index, item[15], item, 15)
item[16].value = this.handleValueFormula(index,item[16],item,16) item[16].value = this.handleValueFormula(index, item[16], item, 16)
item[17].value = this.handleValueFormula(index,item[17],item,17) item[17].value = this.handleValueFormula(index, item[17], item, 17)
item[18].value = this.handleValueFormula(index,item[18],item,18) item[18].value = this.handleValueFormula(index, item[18], item, 18)
item[19] = this.handleForecast(index, item, `${Number(this.state.periode.periode)}`, 19)
item[20] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 1}`, 20) item[20] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
item[21] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 2}`, 21) item[21] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
} }
}) })
// console.log(dbCF) // console.log(dbCF)
this.setState({dbCF}, () => { this.setState({ dbCF }, () => {
this.payloadCF(type) this.payloadCF(type)
}) })
} }
payloadCF(type) { payloadCF(type) {
let listCF = [] let listCF = []
this.state.dbCF.map((item,index) => { this.state.dbCF.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormula(index, item[7], item, 7)
item[8].value = this.handleValueFormula(index, item[8], item, 8)
item[9].value = this.handleValueFormula(index, item[9], item, 9)
item[10].value = this.handleValueFormula(index, item[10], item, 10)
item[11].value = this.handleValueFormula(index, item[11], item, 11)
item[12].value = this.handleValueFormula(index, item[12], item, 12)
item[13].value = this.handleValueFormula(index, item[13], item, 13)
item[14].value = this.handleValueFormula(index, item[14], item, 14)
item[15].value = this.handleValueFormula(index, item[15], item, 15)
item[16].value = this.handleValueFormula(index, item[16], item, 16)
item[17].value = this.handleValueFormula(index, item[17], item, 17)
item[18].value = this.handleValueFormula(index, item[18], item, 18)
item[19] = this.handleForecast(index, item, `${Number(this.state.periode.periode)}`, 19)
item[20] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
item[21] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
}
listCF.push(item)
})
this.payloadCFOneMore(listCF, type)
}
payloadCFOneMore(list, type) {
let listCF = []
list.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormula(index, item[7], item, 7)
item[8].value = this.handleValueFormula(index, item[8], item, 8)
item[9].value = this.handleValueFormula(index, item[9], item, 9)
item[10].value = this.handleValueFormula(index, item[10], item, 10)
item[11].value = this.handleValueFormula(index, item[11], item, 11)
item[12].value = this.handleValueFormula(index, item[12], item, 12)
item[13].value = this.handleValueFormula(index, item[13], item, 13)
item[14].value = this.handleValueFormula(index, item[14], item, 14)
item[15].value = this.handleValueFormula(index, item[15], item, 15)
item[16].value = this.handleValueFormula(index, item[16], item, 16)
item[17].value = this.handleValueFormula(index, item[17], item, 17)
item[18].value = this.handleValueFormula(index, item[18], item, 18)
item[19] = this.handleForecast(index, item, `${Number(this.state.periode.periode)}`, 19)
item[20] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
item[21] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
}
listCF.push(item)
})
this.payloadCFOneMoreAgain(listCF, type)
}
payloadCFOneMoreAgain(list, type) {
let listCF = []
list.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormula(index, item[7], item, 7)
item[8].value = this.handleValueFormula(index, item[8], item, 8)
item[9].value = this.handleValueFormula(index, item[9], item, 9)
item[10].value = this.handleValueFormula(index, item[10], item, 10)
item[11].value = this.handleValueFormula(index, item[11], item, 11)
item[12].value = this.handleValueFormula(index, item[12], item, 12)
item[13].value = this.handleValueFormula(index, item[13], item, 13)
item[14].value = this.handleValueFormula(index, item[14], item, 14)
item[15].value = this.handleValueFormula(index, item[15], item, 15)
item[16].value = this.handleValueFormula(index, item[16], item, 16)
item[17].value = this.handleValueFormula(index, item[17], item, 17)
item[18].value = this.handleValueFormula(index, item[18], item, 18)
item[19] = this.handleForecast(index, item, `${Number(this.state.periode.periode)}`, 19)
item[20] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
item[21] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
}
listCF.push(item)
})
this.olahDataCashFlowOneMore(listCF, type)
}
olahDataCashFlowOneMore(list, type) {
console.log(list)
let listCF = []
list.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) { if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
// if (item[7].value == "" || item[7].value == 0 || item[7].value == "0.0") { // if (item[7].value == "" || item[7].value == 0 || item[7].value == "0.0") {
item[7].value = this.handleValueFormula(index,item[7],item,7) item[7].value = this.handleValueFormula(index, item[7], item, 7)
// } // }
// if (item[8].value == "" || item[8].value == 0 || item[8].value == "0.0") { // if (item[8].value == "" || item[8].value == 0 || item[8].value == "0.0") {
item[8].value = this.handleValueFormula(index,item[8],item,8) item[8].value = this.handleValueFormula(index, item[8], item, 8)
// } // }
// if (item[9].value == "" || item[9].value == 0 || item[9].value == "0.0") { // if (item[9].value == "" || item[9].value == 0 || item[9].value == "0.0") {
item[9].value = this.handleValueFormula(index,item[9],item,9) item[9].value = this.handleValueFormula(index, item[9], item, 9)
// } // }
// if (item[10].value == "" || item[10].value == 0 || item[10].value == "0.0") { // if (item[10].value == "" || item[10].value == 0 || item[10].value == "0.0") {
item[10].value = this.handleValueFormula(index,item[10],item,10) item[10].value = this.handleValueFormula(index, item[10], item, 10)
// } // }
// if (item[11].value == "" || item[11].value == 0 || item[11].value == "0.0") { // if (item[11].value == "" || item[11].value == 0 || item[11].value == "0.0") {
item[11].value = this.handleValueFormula(index,item[11],item,11) item[11].value = this.handleValueFormula(index, item[11], item, 11)
// } // }
// if (item[12].value == "" || item[12].value == 0 || item[12].value == "0.0") { // if (item[12].value == "" || item[12].value == 0 || item[12].value == "0.0") {
item[12].value = this.handleValueFormula(index,item[12],item,12) item[12].value = this.handleValueFormula(index, item[12], item, 12)
// } // }
// if (item[13].value == "" || item[13].value == 0 || item[13].value == "0.0") { // if (item[13].value == "" || item[13].value == 0 || item[13].value == "0.0") {
item[13].value = this.handleValueFormula(index,item[13],item,13) item[13].value = this.handleValueFormula(index, item[13], item, 13)
// } // }
// if (item[14].value == "" || item[14].value == 0 || item[14].value == "0.0") { // if (item[14].value == "" || item[14].value == 0 || item[14].value == "0.0") {
item[14].value = this.handleValueFormula(index,item[14],item,14) item[14].value = this.handleValueFormula(index, item[14], item, 14)
// } // }
// if (item[15].value == "" || item[15].value == 0 || item[15].value == "0.0") { // if (item[15].value == "" || item[15].value == 0 || item[15].value == "0.0") {
item[15].value = this.handleValueFormula(index,item[15],item,15) item[15].value = this.handleValueFormula(index, item[15], item, 15)
// } // }
// if (item[16].value == "" || item[16].value == 0 || item[16].value == "0.0") { // if (item[16].value == "" || item[16].value == 0 || item[16].value == "0.0") {
item[16].value = this.handleValueFormula(index,item[16],item,16) item[16].value = this.handleValueFormula(index, item[16], item, 16)
// } // }
// if (item[17].value == "" || item[17].value == 0 || item[17].value == "0.0") { // if (item[17].value == "" || item[17].value == 0 || item[17].value == "0.0") {
item[17].value = this.handleValueFormula(index,item[17],item,17) item[17].value = this.handleValueFormula(index, item[17], item, 17)
// } // }
// if (item[18].value == "" || item[18].value == 0 || item[18].value == "0.0") { // if (item[18].value == "" || item[18].value == 0 || item[18].value == "0.0") {
item[18].value = this.handleValueFormula(index,item[18],item,18) item[18].value = this.handleValueFormula(index, item[18], item, 18)
// } // }
item[19] = this.handleForecast(index, item, `${Number(this.state.periode.periode)}`, 19)
// if (item[20] == "" || item[20] == 0 || item[20] == "0.0") { // if (item[20] == "" || item[20] == 0 || item[20] == "0.0") {
item[20] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 1}`, 20) item[20] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
// } // }
// if (item[21] == "" || item[21] == 0 || item[21] == "0.0") { // if (item[21] == "" || item[21] == 0 || item[21] == "0.0") {
item[21] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 2}`, 21) item[21] = this.handleForecast(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
// } // }
} }
listCF.push( listCF.push(
{ {
...@@ -1036,21 +1157,21 @@ export default class BudgetTahunan extends Component { ...@@ -1036,21 +1157,21 @@ export default class BudgetTahunan extends Component {
"parent": item[2], "parent": item[2],
"formula": String(item[3]), "formula": String(item[3]),
"item_name": item[5], "item_name": item[5],
"january": String(item[7].value == undefined? item[7] : Number(item[7].value).toFixed(1)), "january": String(item[7].value == undefined ? item[7] : Number(item[7].value).toFixed(1)),
"february": String(item[8].value == undefined? item[8] : Number(item[8].value).toFixed(1)), "february": String(item[8].value == undefined ? item[8] : Number(item[8].value).toFixed(1)),
"march": String(item[9].value == undefined? item[9] : Number(item[9].value).toFixed(1)), "march": String(item[9].value == undefined ? item[9] : Number(item[9].value).toFixed(1)),
"april": String(item[10].value == undefined? item[10] : Number(item[10].value).toFixed(1)), "april": String(item[10].value == undefined ? item[10] : Number(item[10].value).toFixed(1)),
"may": String(item[11].value == undefined? item[11] : Number(item[11].value).toFixed(1)), "may": String(item[11].value == undefined ? item[11] : Number(item[11].value).toFixed(1)),
"june": String(item[12].value == undefined? item[12] : Number(item[12].value).toFixed(1)), "june": String(item[12].value == undefined ? item[12] : Number(item[12].value).toFixed(1)),
"july": String(item[13].value == undefined? item[13] : Number(item[13].value).toFixed(1)), "july": String(item[13].value == undefined ? item[13] : Number(item[13].value).toFixed(1)),
"august": String(item[14].value == undefined? item[14] : Number(item[14].value).toFixed(1)), "august": String(item[14].value == undefined ? item[14] : Number(item[14].value).toFixed(1)),
"september": String(item[15].value == undefined? item[15] : Number(item[15].value).toFixed(1)), "september": String(item[15].value == undefined ? item[15] : Number(item[15].value).toFixed(1)),
"october": String(item[16].value == undefined? item[16] : Number(item[16].value).toFixed(1)), "october": String(item[16].value == undefined ? item[16] : Number(item[16].value).toFixed(1)),
"november": String(item[17].value == undefined? item[17] : Number(item[17].value).toFixed(1)), "november": String(item[17].value == undefined ? item[17] : Number(item[17].value).toFixed(1)),
"december": String(item[18].value == undefined? item[18] : Number(item[18].value).toFixed(1)), "december": String(item[18].value == undefined ? item[18] : Number(item[18].value).toFixed(1)),
"total_current_year": String(item[19]), "total_current_year": String(item[19] != '' ? Number(item[19]).toFixed(1) : item[19]),
"total_next_year": String(item[20] != ''? Number(item[20]).toFixed(1) : item[20]), "total_next_year": String(item[20] != '' ? Number(item[20]).toFixed(1) : item[20]),
"total_more_year": String(item[21] != ''? Number(item[21]).toFixed(1) : item[21]), "total_more_year": String(item[21] != '' ? Number(item[21]).toFixed(1) : item[21]),
"kpi_type": "", "kpi_type": "",
"max_ach": "", "max_ach": "",
"pic": "", "pic": "",
...@@ -1058,13 +1179,13 @@ export default class BudgetTahunan extends Component { ...@@ -1058,13 +1179,13 @@ export default class BudgetTahunan extends Component {
"total_actual_before": "", "total_actual_before": "",
"uom": "", "uom": "",
"weight": "" "weight": ""
} }
) )
}) })
// console.log(listCF) console.log(listCF)
this.setState({dbCF: listCF} , () => { this.setState({ dbCF: listCF }, () => {
// if (this.state.submissionID != null) { // if (this.state.submissionID != null) {
// this.createCashFlow() // this.createCashFlow()
// } // }
...@@ -1089,7 +1210,7 @@ export default class BudgetTahunan extends Component { ...@@ -1089,7 +1210,7 @@ export default class BudgetTahunan extends Component {
console.log(this.state.dbCF) console.log(this.state.dbCF)
console.log(JSON.stringify(payload)) console.log(JSON.stringify(payload))
api.create().createReportCF(payload).then((res) => { api.create().createReportCF(payload).then((res) => {
this.setState({loading: false}) this.setState({ loading: false })
console.log(res) console.log(res)
// if (response.data) { // if (response.data) {
// if (response.data.status === "success") { // if (response.data.status === "success") {
...@@ -1118,7 +1239,7 @@ export default class BudgetTahunan extends Component { ...@@ -1118,7 +1239,7 @@ export default class BudgetTahunan extends Component {
api.create().getPLID(payloadID).then(response => { api.create().getPLID(payloadID).then(response => {
console.log(response); console.log(response);
if (response) { if (response) {
PLID = response.data.data == null ? null : response.data.data.profit_loss_id PLID = response.data.data == null ? null : response.data.data.profit_loss_id
} else { } else {
PLID = null PLID = null
} }
...@@ -1169,7 +1290,7 @@ export default class BudgetTahunan extends Component { ...@@ -1169,7 +1290,7 @@ export default class BudgetTahunan extends Component {
item.profit_detail.forecast_formula == null ? [] : item.profit_detail.forecast_formula, item.profit_detail.forecast_formula == null ? [] : item.profit_detail.forecast_formula,
item.profit_detail.notes item.profit_detail.notes
]) ])
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items, indexs) => { item.children.map((items, indexs) => {
...@@ -1218,18 +1339,18 @@ export default class BudgetTahunan extends Component { ...@@ -1218,18 +1339,18 @@ export default class BudgetTahunan extends Component {
}) })
console.log(dataTable) console.log(dataTable)
this.setState({ dbPL: dataTable }, () => { this.setState({ dbPL: dataTable }, () => {
this.olahDataPL(this.state.dbPL, type) this.olahDataPL(this.state.dbPL, type)
}) })
} else { } else {
this.setState({ dbPL: [], previewTable: false, previewDownload: false }) this.setState({ dbPL: [], previewTable: false, previewDownload: false })
} }
}) })
}) })
}) })
} }
handleValueFormulaDBPL = (indexDBCF, value, tableMeta, column, periode, forecast) => { handleValueFormulaDBPL = (indexDBCF, value, tableMeta, column, periode, forecast) => {
...@@ -1275,11 +1396,11 @@ export default class BudgetTahunan extends Component { ...@@ -1275,11 +1396,11 @@ export default class BudgetTahunan extends Component {
if (String(item).includes('[M-1]')) { if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '') let tst = String(item).replace('[M-1]', '')
let data = column == 7 ? 18 : column - 1 let data = column == 7 ? 18 : column - 1
let period = data == 18 ? Number(this.props.periode) - 1 : this.props.periode let period = data == 18 ? Number(this.state.periode.periode) - 1 : this.state.periode.periode
let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period) let indexID = tableMeta[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = tableMeta.rowData[data].formula[indexID].value let valuezz = tableMeta[data].formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
} }
} else { } else {
...@@ -1333,7 +1454,7 @@ export default class BudgetTahunan extends Component { ...@@ -1333,7 +1454,7 @@ export default class BudgetTahunan extends Component {
} }
} }
}) })
let total = 0 let total = 0
let opt = "" let opt = ""
let totalPrio = 0 let totalPrio = 0
...@@ -1364,7 +1485,7 @@ export default class BudgetTahunan extends Component { ...@@ -1364,7 +1485,7 @@ export default class BudgetTahunan extends Component {
totalPrio += Number(items) totalPrio += Number(items)
} }
} }
}) })
if (index == anjay2.length - 1) { if (index == anjay2.length - 1) {
if (opt == "tambah") { if (opt == "tambah") {
...@@ -1451,25 +1572,25 @@ export default class BudgetTahunan extends Component { ...@@ -1451,25 +1572,25 @@ export default class BudgetTahunan extends Component {
} }
olahDataPL(dbPL, type) { olahDataPL(dbPL, type) {
dbPL.map((item,index) => { dbPL.map((item, index) => {
if(item[0] == 5 || item[0] == 6 || item[0] == 7) { if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormulaDBPL(index,item[7],item,7) item[7].value = this.handleValueFormulaDBPL(index, item[7], item, 7)
item[8].value = this.handleValueFormulaDBPL(index,item[8],item,8) item[8].value = this.handleValueFormulaDBPL(index, item[8], item, 8)
item[9].value = this.handleValueFormulaDBPL(index,item[9],item,9) item[9].value = this.handleValueFormulaDBPL(index, item[9], item, 9)
item[10].value = this.handleValueFormulaDBPL(index,item[10],item,10) item[10].value = this.handleValueFormulaDBPL(index, item[10], item, 10)
item[11].value = this.handleValueFormulaDBPL(index,item[11],item,11) item[11].value = this.handleValueFormulaDBPL(index, item[11], item, 11)
item[12].value = this.handleValueFormulaDBPL(index,item[12],item,12) item[12].value = this.handleValueFormulaDBPL(index, item[12], item, 12)
item[13].value = this.handleValueFormulaDBPL(index,item[13],item,13) item[13].value = this.handleValueFormulaDBPL(index, item[13], item, 13)
item[14].value = this.handleValueFormulaDBPL(index,item[14],item,14) item[14].value = this.handleValueFormulaDBPL(index, item[14], item, 14)
item[15].value = this.handleValueFormulaDBPL(index,item[15],item,15) item[15].value = this.handleValueFormulaDBPL(index, item[15], item, 15)
item[16].value = this.handleValueFormulaDBPL(index,item[16],item,16) item[16].value = this.handleValueFormulaDBPL(index, item[16], item, 16)
item[17].value = this.handleValueFormulaDBPL(index,item[17],item,17) item[17].value = this.handleValueFormulaDBPL(index, item[17], item, 17)
item[18].value = this.handleValueFormulaDBPL(index,item[18],item,18) item[18].value = this.handleValueFormulaDBPL(index, item[18], item, 18)
item[20] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 1}`, 20) item[20] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
item[21] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 2}`, 21) item[21] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
} }
}) })
this.setState({dbPL}, () => { this.setState({ dbPL }, () => {
this.payloadPL(type) this.payloadPL(type)
}) })
} }
...@@ -1477,92 +1598,92 @@ export default class BudgetTahunan extends Component { ...@@ -1477,92 +1598,92 @@ export default class BudgetTahunan extends Component {
payloadPL(type) { payloadPL(type) {
let listPL = [] let listPL = []
// console.log(this.state.dbPL) // console.log(this.state.dbPL)
this.state.dbPL.map((item,index) => { this.state.dbPL.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) { if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
// if (item[7].value == "" || item[7].value == 0 || item[7].value == "0.0") { // if (item[7].value == "" || item[7].value == 0 || item[7].value == "0.0") {
item[7].value = this.handleValueFormulaDBPL(index,item[7],item,7) item[7].value = this.handleValueFormulaDBPL(index, item[7], item, 7)
// } // }
// if (item[8].value == "" || item[8].value == 0 || item[8].value == "0.0") { // if (item[8].value == "" || item[8].value == 0 || item[8].value == "0.0") {
item[8].value = this.handleValueFormulaDBPL(index,item[8],item,8) item[8].value = this.handleValueFormulaDBPL(index, item[8], item, 8)
// } // }
// if (item[9].value == "" || item[9].value == 0 || item[9].value == "0.0") { // if (item[9].value == "" || item[9].value == 0 || item[9].value == "0.0") {
item[9].value = this.handleValueFormulaDBPL(index,item[9],item,9) item[9].value = this.handleValueFormulaDBPL(index, item[9], item, 9)
// } // }
// if (item[10].value == "" || item[10].value == 0 || item[10].value == "0.0") { // if (item[10].value == "" || item[10].value == 0 || item[10].value == "0.0") {
item[10].value = this.handleValueFormulaDBPL(index,item[10],item,10) item[10].value = this.handleValueFormulaDBPL(index, item[10], item, 10)
// } // }
// if (item[11].value == "" || item[11].value == 0 || item[11].value == "0.0") { // if (item[11].value == "" || item[11].value == 0 || item[11].value == "0.0") {
item[11].value = this.handleValueFormulaDBPL(index,item[11],item,11) item[11].value = this.handleValueFormulaDBPL(index, item[11], item, 11)
// } // }
// if (item[12].value == "" || item[12].value == 0 || item[12].value == "0.0") { // if (item[12].value == "" || item[12].value == 0 || item[12].value == "0.0") {
item[12].value = this.handleValueFormulaDBPL(index,item[12],item,12) item[12].value = this.handleValueFormulaDBPL(index, item[12], item, 12)
// } // }
// if (item[13].value == "" || item[13].value == 0 || item[13].value == "0.0") { // if (item[13].value == "" || item[13].value == 0 || item[13].value == "0.0") {
item[13].value = this.handleValueFormulaDBPL(index,item[13],item,13) item[13].value = this.handleValueFormulaDBPL(index, item[13], item, 13)
// } // }
// if (item[14].value == "" || item[14].value == 0 || item[14].value == "0.0") { // if (item[14].value == "" || item[14].value == 0 || item[14].value == "0.0") {
item[14].value = this.handleValueFormulaDBPL(index,item[14],item,14) item[14].value = this.handleValueFormulaDBPL(index, item[14], item, 14)
// } // }
// if (item[15].value == "" || item[15].value == 0 || item[15].value == "0.0") { // if (item[15].value == "" || item[15].value == 0 || item[15].value == "0.0") {
item[15].value = this.handleValueFormulaDBPL(index,item[15],item,15) item[15].value = this.handleValueFormulaDBPL(index, item[15], item, 15)
// } // }
// if (item[16].value == "" || item[16].value == 0 || item[16].value == "0.0") { // if (item[16].value == "" || item[16].value == 0 || item[16].value == "0.0") {
item[16].value = this.handleValueFormulaDBPL(index,item[16],item,16) item[16].value = this.handleValueFormulaDBPL(index, item[16], item, 16)
// } // }
// if (item[17].value == "" || item[17].value == 0 || item[17].value == "0.0") { // if (item[17].value == "" || item[17].value == 0 || item[17].value == "0.0") {
item[17].value = this.handleValueFormulaDBPL(index,item[17],item,17) item[17].value = this.handleValueFormulaDBPL(index, item[17], item, 17)
// } // }
// if (item[18].value == "" || item[18].value == 0 || item[18].value == "0.0") { // if (item[18].value == "" || item[18].value == 0 || item[18].value == "0.0") {
item[18].value = this.handleValueFormulaDBPL(index,item[18],item,18) item[18].value = this.handleValueFormulaDBPL(index, item[18], item, 18)
// } // }
// if (item[20] == "" || item[20] == 0 || item[20] == "0.0") { // if (item[20] == "" || item[20] == 0 || item[20] == "0.0") {
item[20] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 1}`, 20) item[20] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
// } // }
// if (item[21] == "" || item[21] == 0 || item[21] == "0.0") { // if (item[21] == "" || item[21] == 0 || item[21] == "0.0") {
item[21] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 2}`, 21) item[21] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
// } // }
} }
listPL.push( listPL.push(
{ {
"item_report_id": item[1], "item_report_id": item[1],
"january": String(item[7].value == undefined? item[7] : Number(item[7].value).toFixed(1)), "january": String(item[7].value == undefined ? item[7] : Number(item[7].value).toFixed(1)),
"february": String(item[8].value == undefined? item[8] : Number(item[8].value).toFixed(1)), "february": String(item[8].value == undefined ? item[8] : Number(item[8].value).toFixed(1)),
"march": String(item[9].value == undefined? item[9] : Number(item[9].value).toFixed(1)), "march": String(item[9].value == undefined ? item[9] : Number(item[9].value).toFixed(1)),
"april": String(item[10].value == undefined? item[10] : Number(item[10].value).toFixed(1)), "april": String(item[10].value == undefined ? item[10] : Number(item[10].value).toFixed(1)),
"may": String(item[11].value == undefined? item[11] : Number(item[11].value).toFixed(1)), "may": String(item[11].value == undefined ? item[11] : Number(item[11].value).toFixed(1)),
"june": String(item[12].value == undefined? item[12] : Number(item[12].value).toFixed(1)), "june": String(item[12].value == undefined ? item[12] : Number(item[12].value).toFixed(1)),
"july": String(item[13].value == undefined? item[13] : Number(item[13].value).toFixed(1)), "july": String(item[13].value == undefined ? item[13] : Number(item[13].value).toFixed(1)),
"august": String(item[14].value == undefined? item[14] : Number(item[14].value).toFixed(1)), "august": String(item[14].value == undefined ? item[14] : Number(item[14].value).toFixed(1)),
"september": String(item[15].value == undefined? item[15] : Number(item[15].value).toFixed(1)), "september": String(item[15].value == undefined ? item[15] : Number(item[15].value).toFixed(1)),
"october": String(item[16].value == undefined? item[16] : Number(item[16].value).toFixed(1)), "october": String(item[16].value == undefined ? item[16] : Number(item[16].value).toFixed(1)),
"november": String(item[17].value == undefined? item[17] : Number(item[17].value).toFixed(1)), "november": String(item[17].value == undefined ? item[17] : Number(item[17].value).toFixed(1)),
"december": String(item[18].value == undefined? item[18] : Number(item[18].value).toFixed(1)), "december": String(item[18].value == undefined ? item[18] : Number(item[18].value).toFixed(1)),
"total_current_year": String(item[19]), "total_current_year": String(item[19]),
"total_next_year": String(item[20] != ''? Number(item[20]).toFixed(1) : item[20]), "total_next_year": String(item[20] != '' ? Number(item[20]).toFixed(1) : item[20]),
"total_more_year": String(item[21] != ''? Number(item[21]).toFixed(1) : item[21]), "total_more_year": String(item[21] != '' ? Number(item[21]).toFixed(1) : item[21]),
"notes": String(item[26]), "notes": String(item[26]),
} }
) )
}) })
// console.log(listPL) // console.log(listPL)
this.setState({dbPL: listPL} , () => { this.setState({ dbPL: listPL }, () => {
// if (this.state.submissionID != null) { // if (this.state.submissionID != null) {
// this.createDBPL() // this.createDBPL()
// } // }
...@@ -1590,7 +1711,7 @@ export default class BudgetTahunan extends Component { ...@@ -1590,7 +1711,7 @@ export default class BudgetTahunan extends Component {
console.log(JSON.stringify(payload)) console.log(JSON.stringify(payload))
api.create().createReportPLMB(payload).then((res) => { api.create().createReportPLMB(payload).then((res) => {
console.log(res) console.log(res)
this.setState({loading: false}) this.setState({ loading: false })
// if (response.data) { // if (response.data) {
// if (response.data.status === "success") { // if (response.data.status === "success") {
// this.props.saveToMonthlyReport() // this.props.saveToMonthlyReport()
...@@ -1618,7 +1739,7 @@ export default class BudgetTahunan extends Component { ...@@ -1618,7 +1739,7 @@ export default class BudgetTahunan extends Component {
api.create().getFRID(payloadID).then(response => { api.create().getFRID(payloadID).then(response => {
console.log(response); console.log(response);
if (response) { if (response) {
FRID = response.data.data == null ? null : response.data.data.ratio_id FRID = response.data.data == null ? null : response.data.data.ratio_id
} else { } else {
FRID = null FRID = null
} }
...@@ -1666,7 +1787,7 @@ export default class BudgetTahunan extends Component { ...@@ -1666,7 +1787,7 @@ export default class BudgetTahunan extends Component {
Number(item.ratio.total_next_year).toFixed(2), Number(item.ratio.total_next_year).toFixed(2),
Number(item.ratio.total_more_year).toFixed(2), Number(item.ratio.total_more_year).toFixed(2),
]) ])
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items, indexs) => { item.children.map((items, indexs) => {
...@@ -1711,18 +1832,18 @@ export default class BudgetTahunan extends Component { ...@@ -1711,18 +1832,18 @@ export default class BudgetTahunan extends Component {
}) })
this.setState({ dbFR: dataTable, loading: false }, () => { this.setState({ dbFR: dataTable, loading: false }, () => {
console.log(this.state.dbFR) console.log(this.state.dbFR)
this.olahDataFR(this.state.dbFR, type) this.olahDataFR(this.state.dbFR, type)
}) })
} else { } else {
this.setState({ dbFR: [], previewTable: false, loading: false, previewDownload: false }) this.setState({ dbFR: [], previewTable: false, loading: false, previewDownload: false })
} }
}) })
}) })
}) })
} }
handleFormulaRatio = (value, tableMeta, month) => { handleFormulaRatio = (value, tableMeta, month) => {
...@@ -1736,7 +1857,7 @@ export default class BudgetTahunan extends Component { ...@@ -1736,7 +1857,7 @@ export default class BudgetTahunan extends Component {
total += Number(dataTable2[35][7 + index]) total += Number(dataTable2[35][7 + index])
// console.log(index); // console.log(index);
} }
total = total/month total = total / month
} }
let hasil = Number(value) / total let hasil = Number(value) / total
// console.log(value) // console.log(value)
...@@ -1747,28 +1868,28 @@ export default class BudgetTahunan extends Component { ...@@ -1747,28 +1868,28 @@ export default class BudgetTahunan extends Component {
olahDataFR(dbFR, type) { olahDataFR(dbFR, type) {
// let totalCY = 0 // let totalCY = 0
dbFR.map((item,index) => { dbFR.map((item, index) => {
if(item[0] != 4 || item[0] != 1) { if (item[0] != 4 || item[0] != 1) {
if (item[5] === "Return on Invested Capital - YTD (ROIC)" ) { if (item[5] === "Return on Invested Capital - YTD (ROIC)") {
item[7] = this.handleFormulaRatio(item[7],item,1) item[7] = this.handleFormulaRatio(item[7], item, 1)
item[8] = this.handleFormulaRatio(item[8],item,2) item[8] = this.handleFormulaRatio(item[8], item, 2)
item[9] = this.handleFormulaRatio(item[9],item,3) item[9] = this.handleFormulaRatio(item[9], item, 3)
item[10] = this.handleFormulaRatio(item[10],item,4) item[10] = this.handleFormulaRatio(item[10], item, 4)
item[11] = this.handleFormulaRatio(item[11],item,5) item[11] = this.handleFormulaRatio(item[11], item, 5)
item[12] = this.handleFormulaRatio(item[12],item,6) item[12] = this.handleFormulaRatio(item[12], item, 6)
item[13] = this.handleFormulaRatio(item[13],item,7) item[13] = this.handleFormulaRatio(item[13], item, 7)
item[14] = this.handleFormulaRatio(item[14],item,8) item[14] = this.handleFormulaRatio(item[14], item, 8)
item[15] = this.handleFormulaRatio(item[15],item,9) item[15] = this.handleFormulaRatio(item[15], item, 9)
item[16] = this.handleFormulaRatio(item[16],item,10) item[16] = this.handleFormulaRatio(item[16], item, 10)
item[17] = this.handleFormulaRatio(item[17],item,11) item[17] = this.handleFormulaRatio(item[17], item, 11)
item[18] = this.handleFormulaRatio(item[18],item,12) item[18] = this.handleFormulaRatio(item[18], item, 12)
item[19] = this.handleFormulaRatio(item[19],item,13) item[19] = this.handleFormulaRatio(item[19], item, 13)
item[20] = this.handleFormulaRatio(item[20],item,14) item[20] = this.handleFormulaRatio(item[20], item, 14)
// totalCY = Number(item[7]) + Number(item[8]) + Number(item[9]) + Number(item[10]) + Number(item[11]) + Number(item[12]) + Number(item[13]) + Number(item[14]) + Number(item[15]) + Number(item[16]) + Number(item[17]) + Number(item[18]) // totalCY = Number(item[7]) + Number(item[8]) + Number(item[9]) + Number(item[10]) + Number(item[11]) + Number(item[12]) + Number(item[13]) + Number(item[14]) + Number(item[15]) + Number(item[16]) + Number(item[17]) + Number(item[18])
} }
} }
}) })
this.setState({dbFR}, () => { this.setState({ dbFR }, () => {
this.payloadFR(type) this.payloadFR(type)
}) })
} }
...@@ -1777,9 +1898,9 @@ export default class BudgetTahunan extends Component { ...@@ -1777,9 +1898,9 @@ export default class BudgetTahunan extends Component {
let listFR = [] let listFR = []
// console.log(this.state.dbFR) // console.log(this.state.dbFR)
let totalCY = 0 let totalCY = 0
this.state.dbFR.map((item,index) => { this.state.dbFR.map((item, index) => {
if (item[0] != 4 || item[0] != 1) { if (item[0] != 4 || item[0] != 1) {
if (item[5] === "Return on Invested Capital - YTD (ROIC)" ) { if (item[5] === "Return on Invested Capital - YTD (ROIC)") {
// item[7] = this.handleFormulaRatio(item[7],item,1) // item[7] = this.handleFormulaRatio(item[7],item,1)
// item[8] = this.handleFormulaRatio(item[8],item,2) // item[8] = this.handleFormulaRatio(item[8],item,2)
// item[9] = this.handleFormulaRatio(item[9],item,3) // item[9] = this.handleFormulaRatio(item[9],item,3)
...@@ -1794,36 +1915,36 @@ export default class BudgetTahunan extends Component { ...@@ -1794,36 +1915,36 @@ export default class BudgetTahunan extends Component {
// item[18] = this.handleFormulaRatio(item[18],item,12) // item[18] = this.handleFormulaRatio(item[18],item,12)
// item[19] = this.handleFormulaRatio(item[19],item,13) // item[19] = this.handleFormulaRatio(item[19],item,13)
// item[20] = this.handleFormulaRatio(item[20],item,14) // item[20] = this.handleFormulaRatio(item[20],item,14)
} }
totalCY = Number(item[7]) + Number(item[8]) + Number(item[9]) + Number(item[10]) + Number(item[11]) + Number(item[12]) + Number(item[13]) + Number(item[14]) + Number(item[15]) + Number(item[16]) + Number(item[17]) + Number(item[18]) totalCY = Number(item[7]) + Number(item[8]) + Number(item[9]) + Number(item[10]) + Number(item[11]) + Number(item[12]) + Number(item[13]) + Number(item[14]) + Number(item[15]) + Number(item[16]) + Number(item[17]) + Number(item[18])
} }
listFR.push( listFR.push(
{ {
"item_report_id": item[1], "item_report_id": item[1],
"january": String(item[7] == undefined || item[7] == 'Infinity' || item[7] == '-Infinity'? "0.0" : Number(item[7]).toFixed(2)), "january": String(item[7] == undefined || item[7] == 'Infinity' || item[7] == '-Infinity' ? "0.0" : Number(item[7]).toFixed(2)),
"february": String(item[8] == undefined || item[8] == 'Infinity' || item[8] == '-Infinity'? "0.0" : Number(item[8]).toFixed(2)), "february": String(item[8] == undefined || item[8] == 'Infinity' || item[8] == '-Infinity' ? "0.0" : Number(item[8]).toFixed(2)),
"march": String(item[9] == undefined || item[9] == 'Infinity' || item[9] == '-Infinity'? "0.0" : Number(item[9]).toFixed(2)), "march": String(item[9] == undefined || item[9] == 'Infinity' || item[9] == '-Infinity' ? "0.0" : Number(item[9]).toFixed(2)),
"april": String(item[10] == undefined || item[10] == 'Infinity' || item[10] == '-Infinity'? "0.0" : Number(item[10]).toFixed(2)), "april": String(item[10] == undefined || item[10] == 'Infinity' || item[10] == '-Infinity' ? "0.0" : Number(item[10]).toFixed(2)),
"may": String(item[11] == undefined || item[11] == 'Infinity' || item[11] == '-Infinity'? "0.0" : Number(item[11]).toFixed(2)), "may": String(item[11] == undefined || item[11] == 'Infinity' || item[11] == '-Infinity' ? "0.0" : Number(item[11]).toFixed(2)),
"june": String(item[12] == undefined || item[12] == 'Infinity' || item[12] == '-Infinity'? "0.0" : Number(item[12]).toFixed(2)), "june": String(item[12] == undefined || item[12] == 'Infinity' || item[12] == '-Infinity' ? "0.0" : Number(item[12]).toFixed(2)),
"july": String(item[13] == undefined || item[13] == 'Infinity' || item[13] == '-Infinity'? "0.0" : Number(item[13]).toFixed(2)), "july": String(item[13] == undefined || item[13] == 'Infinity' || item[13] == '-Infinity' ? "0.0" : Number(item[13]).toFixed(2)),
"august": String(item[14] == undefined || item[14] == 'Infinity' || item[14] == '-Infinity'? "0.0" : Number(item[14]).toFixed(2)), "august": String(item[14] == undefined || item[14] == 'Infinity' || item[14] == '-Infinity' ? "0.0" : Number(item[14]).toFixed(2)),
"september": String(item[15] == undefined || item[15] == 'Infinity' || item[15] == '-Infinity'? "0.0" : Number(item[15]).toFixed(2)), "september": String(item[15] == undefined || item[15] == 'Infinity' || item[15] == '-Infinity' ? "0.0" : Number(item[15]).toFixed(2)),
"october": String(item[16] == undefined || item[16] == 'Infinity' || item[16] == '-Infinity'? "0.0" : Number(item[16]).toFixed(2)), "october": String(item[16] == undefined || item[16] == 'Infinity' || item[16] == '-Infinity' ? "0.0" : Number(item[16]).toFixed(2)),
"november": String(item[17] == undefined || item[17] == 'Infinity' || item[17] == '-Infinity'? "0.0" : Number(item[17]).toFixed(2)), "november": String(item[17] == undefined || item[17] == 'Infinity' || item[17] == '-Infinity' ? "0.0" : Number(item[17]).toFixed(2)),
"december": String(item[18] == undefined || item[18] == 'Infinity' || item[18] == '-Infinity'? "0.0" : Number(item[18]).toFixed(2)), "december": String(item[18] == undefined || item[18] == 'Infinity' || item[18] == '-Infinity' ? "0.0" : Number(item[18]).toFixed(2)),
"total_current_year": String(totalCY == undefined || totalCY == 'Infinity' || totalCY == '-Infinity'? "0.0" : Number(totalCY).toFixed(2)), "total_current_year": String(totalCY == undefined || totalCY == 'Infinity' || totalCY == '-Infinity' ? "0.0" : Number(totalCY).toFixed(2)),
"total_next_year": String(item[19] != '' || item[19] != 'Infinity' || item[19] != '-Infinity'? Number(item[19]).toFixed(2) : item[19]), "total_next_year": String(item[19] != '' || item[19] != 'Infinity' || item[19] != '-Infinity' ? Number(item[19]).toFixed(2) : item[19]),
"total_more_year": String(item[20] != '' || item[20] != 'Infinity' || item[20] != '-Infinity'? Number(item[20]).toFixed(2) : item[20]), "total_more_year": String(item[20] != '' || item[20] != 'Infinity' || item[20] != '-Infinity' ? Number(item[20]).toFixed(2) : item[20]),
} }
) )
}) })
console.log(listFR) console.log(listFR)
console.log('subOD',this.state.submissionID) console.log('subOD', this.state.submissionID)
this.setState({dbFR: listFR} , () => { this.setState({ dbFR: listFR }, () => {
if (this.state.submissionID != null) { if (this.state.submissionID != null) {
this.createDBFR() this.createDBFR()
} }
...@@ -1874,7 +1995,7 @@ export default class BudgetTahunan extends Component { ...@@ -1874,7 +1995,7 @@ export default class BudgetTahunan extends Component {
let indexC = String(item.status_approval).toLocaleUpperCase().indexOf('C') let indexC = String(item.status_approval).toLocaleUpperCase().indexOf('C')
let status_approv = '' let status_approv = ''
if (String(item.status_approval).toLocaleUpperCase().includes('CC')) { if (String(item.status_approval).toLocaleUpperCase().includes('CC')) {
status_approv = `${String(item.status_approval).substr(0,indexC)}${String(item.status_approval).substr(indexC+1,String(item.status_approval).length)}` status_approv = `${String(item.status_approval).substr(0, indexC)}${String(item.status_approval).substr(indexC + 1, String(item.status_approval).length)}`
} else { } else {
status_approv = String(item.status_approval) status_approv = String(item.status_approval)
} }
...@@ -1938,7 +2059,7 @@ export default class BudgetTahunan extends Component { ...@@ -1938,7 +2059,7 @@ export default class BudgetTahunan extends Component {
this.setState({ prevRevision: false }) this.setState({ prevRevision: false })
} }
} }
if (String(i.report_name).toLocaleLowerCase() == "profit loss" || String(i.report_name).toLocaleLowerCase() == "balance sheet" || String(i.report_name).toLocaleLowerCase() == "fixed assets movement" ) { if (String(i.report_name).toLocaleLowerCase() == "profit loss" || String(i.report_name).toLocaleLowerCase() == "balance sheet" || String(i.report_name).toLocaleLowerCase() == "fixed assets movement") {
if (String(i.current_status).toLocaleLowerCase() == "submitted") { if (String(i.current_status).toLocaleLowerCase() == "submitted") {
PLBSFAMSubmitted += 1 PLBSFAMSubmitted += 1
} }
...@@ -2008,7 +2129,7 @@ export default class BudgetTahunan extends Component { ...@@ -2008,7 +2129,7 @@ export default class BudgetTahunan extends Component {
visibleFAM: false, visibleFAM: false,
visibleTP: false, visibleTP: false,
visibleCF: true, visibleCF: true,
PLBSFAMSubmitted: PLBSFAMSubmitted == 3? true : false PLBSFAMSubmitted: PLBSFAMSubmitted == 3 ? true : false
}) })
} }
}) })
...@@ -2064,7 +2185,7 @@ export default class BudgetTahunan extends Component { ...@@ -2064,7 +2185,7 @@ export default class BudgetTahunan extends Component {
this.setState({ alert: false }) this.setState({ alert: false })
} }
saveToMasterBudget(data,type) { saveToMasterBudget(data, type) {
this.setState({ loading: true }, () => { this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
}) })
...@@ -2077,15 +2198,15 @@ export default class BudgetTahunan extends Component { ...@@ -2077,15 +2198,15 @@ export default class BudgetTahunan extends Component {
this.getSubmission(type) this.getSubmission(type)
} else { } else {
// this.setState({ loading: false }, () => { // this.setState({ loading: false }, () => {
this.getSubmission() this.getSubmission()
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
// }) // })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false}, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false }, () => {
this.getSubmission() this.getSubmission()
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
}) })
} }
} else { } else {
this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false }, () => { this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false }, () => {
......
...@@ -47,6 +47,7 @@ export default class CashFlow extends Component { ...@@ -47,6 +47,7 @@ export default class CashFlow extends Component {
componentDidMount() { componentDidMount() {
this.setState({ loading: true }) this.setState({ loading: true })
console.log(this.props.PLBSFAMSubmitted)
this.getSettingControl() this.getSettingControl()
} }
...@@ -264,7 +265,25 @@ export default class CashFlow extends Component { ...@@ -264,7 +265,25 @@ export default class CashFlow extends Component {
} }
}) })
console.log(dataTable); console.log(dataTable);
this.setState({ dataTable, loading: false, dataReal: res, editable: true }) this.setState({ dataTable, loading: false, dataReal: res, editable: true }, () => {
this.setState({loading: true}, () => {
setTimeout(() => {
this.setState({loading: false}, () => {
this.setState({loading: true}, () => {
setTimeout(() => {
this.setState({loading: false}, () => {
this.setState({loading: true}, () => {
setTimeout(() => {
this.setState({loading: false})
}, 500);
})
})
}, 500);
})
})
}, 500);
})
})
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -345,20 +364,37 @@ export default class CashFlow extends Component { ...@@ -345,20 +364,37 @@ export default class CashFlow extends Component {
if (String(item).includes('[M-1]')) { if (String(item).includes('[M-1]')) {
if (forecast !== undefined) { if (forecast !== undefined) {
let forecastt = 0 let forecastt = 0
if (column == 19) {
let tst = String(item).replace('[M-1]', '')
let data = 18
let period = this.props.periode - 1
let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
if (indexID !== -1) {
let valuezz = tableMeta.rowData[data].formula[indexID].value
if (tableMeta.rowData[5] == "Cash at the beginning period") {
// console.log(dataTable2[tableMeta.rowIndex+1])
// console.log(dataTable2[tableMeta.rowIndex+1][data].value)
let valuezzz = dataTable2[tableMeta.rowIndex+1][data].value
forecastt += Number(valuezzz == "" ? 0 : valuezzz)
} else {
forecastt += Number(valuezz == "" ? 0 : valuezz)
}
}
}
if (column == 20) { if (column == 20) {
let tst = String(item).replace('[M-1]', '') let tst = String(item).replace('[M-1]', '')
let data = 18 let data = 18
let period = this.props.periode let period = this.props.periode
let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period) let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
if (tableMeta.rowData[5] == "Cash at the end of the period") {
console.log(tableMeta.rowData[18]);
console.log(indexID);
console.log(tst);
console.log(period);
}
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = tableMeta.rowData[data].formula[indexID].value let valuezz = tableMeta.rowData[data].formula[indexID].value
forecastt += Number(valuezz == "" ? 0 : valuezz) if (tableMeta.rowData[5] == "Cash at the beginning period") {
let valuezzz = dataTable2[tableMeta.rowIndex+1][19]
forecastt += Number(valuezzz == "" ? 0 : valuezzz)
} else {
forecastt += Number(valuezz == "" ? 0 : valuezz)
}
} }
} }
...@@ -368,7 +404,12 @@ export default class CashFlow extends Component { ...@@ -368,7 +404,12 @@ export default class CashFlow extends Component {
let indexID = forecast.findIndex((val) => String(val.item_formula).replace('forecast_', '') == String(`@${tst}`) && val.periode == period) let indexID = forecast.findIndex((val) => String(val.item_formula).replace('forecast_', '') == String(`@${tst}`) && val.periode == period)
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = forecast[indexID].value let valuezz = forecast[indexID].value
forecastt += Number(valuezz == "" ? 0 : valuezz) if (tableMeta.rowData[5] == "Cash at the beginning period") {
let valuezzz = dataTable2[tableMeta.rowIndex+1][20]
forecastt += Number(valuezzz == "" ? 0 : valuezzz)
} else {
forecastt += Number(valuezz == "" ? 0 : valuezz)
}
} }
} }
...@@ -381,7 +422,18 @@ export default class CashFlow extends Component { ...@@ -381,7 +422,18 @@ export default class CashFlow extends Component {
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = tableMeta.rowData[data].formula[indexID].value let valuezz = tableMeta.rowData[data].formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz) if (tableMeta.rowData[5] == "Cash at the beginning period" && column != 7) {
// console.log(data)
// console.log(dataTable2[tableMeta.rowIndex+1][5])
// console.log(dataTable2[tableMeta.rowIndex+1][data])
// console.log(dataTable2[tableMeta.rowIndex-1][data].value)
// console.log(dataTable2[tableMeta.rowIndex][data].value)
// console.log(dataTable2[tableMeta.rowIndex+1][data].value)
let valuezzz = dataTable2[tableMeta.rowIndex+1][data].value
anjay.push(valuezzz == "" ? 0 : valuezzz)
} else {
anjay.push(valuezz == "" ? 0 : valuezz)
}
} }
} }
} else { } else {
...@@ -583,6 +635,13 @@ export default class CashFlow extends Component { ...@@ -583,6 +635,13 @@ export default class CashFlow extends Component {
// // console.log(tableMeta.rowData[5]) // // console.log(tableMeta.rowData[5])
// if (tableMeta.rowData[5] == "1.5 Other non-current assets") { // if (tableMeta.rowData[5] == "1.5 Other non-current assets") {
// if (forecast !== undefined) { // if (forecast !== undefined) {
// if (column == 19) {
// console.log(splitFormula)
// console.log(baru)
// console.log(anjay)
// console.log(anjay2)
// console.log(total)
// }
// if (String(tableMeta.rowData[5]).toLocaleUpperCase() == "4.0 CASH FLOW MOVEMENT" && column == 7) { // if (String(tableMeta.rowData[5]).toLocaleUpperCase() == "4.0 CASH FLOW MOVEMENT" && column == 7) {
// console.log(splitFormula) // console.log(splitFormula)
// console.log(baru) // console.log(baru)
...@@ -593,6 +652,14 @@ export default class CashFlow extends Component { ...@@ -593,6 +652,14 @@ export default class CashFlow extends Component {
// } // }
// } // }
if(tableMeta.rowData[5] == '2.1 Additional fixed assets and CIP' && column == 7) {
console.log(splitFormula)
console.log(baru)
console.log(anjay)
console.log(anjay2)
console.log(total)
}
if (dataTable2[tableMeta.rowIndex][column].value == undefined) { if (dataTable2[tableMeta.rowIndex][column].value == undefined) {
dataTable2[tableMeta.rowIndex][column] = total dataTable2[tableMeta.rowIndex][column] = total
} else { } else {
...@@ -2724,6 +2791,87 @@ export default class CashFlow extends Component { ...@@ -2724,6 +2791,87 @@ export default class CashFlow extends Component {
options: { options: {
display: false display: false
} }
}, {
name: "",
options: {
// display: false,
customHeadRender: (columnMeta) => (
<th style={{ ...style2, color: '#fff', backgroundColor: '#07a7d0', top: 0, zIndex: 102, fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)", padding: 0 }} >
{/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell> */}
<div style={{ borderBottom: "1px #fff solid", backgroundColor: '#1c71b8', textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
<div className="grid grid-1x" style={{ ...style2, color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
<div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, backgroundColor: '#07a7d0' }}>
<span>{"ForeCast"}</span>
</div>
</div>
</th>
),
setCellProps: () => ({ style2 }),
customBodyRender: (value, tableMeta, updateValue) => {
return (
<div style={{ textAlign: 'right' }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
tableMeta.rowData[0] === 7 ?
(Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1) >= Number(this.state.minValue) && Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1) <= Number(this.state.maxValue)) ?
<NumberFormat
thousandSeparator={true}
style={{
fontSize: 12,
textAlign: 'right',
borderColor: 'transparent',
margin: 0,
width: 96,
backgroundColor: 'transparent',
color: 'black'
}}
type="text"
placeholder=""
disabled={true}
value={Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1)}
/> :
<LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
<NumberFormat
thousandSeparator={true}
style={{
fontSize: 12,
textAlign: 'right',
borderColor: 'transparent',
margin: 0,
width: 96,
backgroundColor: 'transparent',
color: 'red'
}}
type="text"
placeholder=""
disabled={true}
value={Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1)}
/>
</LightTooltip>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1)}
/>
}
/>
</div>}
</div>
)
}
}
}, { }, {
name: `${Number(this.props.periode) + 1}`, name: `${Number(this.props.periode) + 1}`,
options: { options: {
...@@ -2804,8 +2952,7 @@ export default class CashFlow extends Component { ...@@ -2804,8 +2952,7 @@ export default class CashFlow extends Component {
) )
} }
} }
}, }, {
{
name: `${Number(this.props.periode) + 2}`, name: `${Number(this.props.periode) + 2}`,
options: { options: {
customHeadRender: (columnMeta) => ( customHeadRender: (columnMeta) => (
......
...@@ -232,15 +232,19 @@ export default class DashboardCAT extends Component { ...@@ -232,15 +232,19 @@ export default class DashboardCAT extends Component {
getDasboardCAT() { getDasboardCAT() {
let payload = { let payload = {
"company_id" : this.state.company.company_id, "company_id" : this.state.company.company_id,
"year" : this.state.periode.periode "periode" : this.state.periode.periode,
"months": this.state.month.month_id
} }
let dataDashboard = []
api.create().getDashboardCAT(payload).then((res) => { api.create().getDashboardCAT(payload).then((res) => {
if (res.data.status == 'success') { if (res.data.status == 'success') {
console.log(res) console.log(res)
this.setState({loading: false, dataDashboard: res.data.data}) // let resp = res.data.data
} else { this.setState({loading: false, dataDashboard : res.data.data})
this.setState({loading: false}) }
} // else {
// this.setState({loading: false})
// }
// conole.log(JSON.stringify(payload)) // conole.log(JSON.stringify(payload))
}) })
} }
...@@ -332,7 +336,7 @@ export default class DashboardCAT extends Component { ...@@ -332,7 +336,7 @@ export default class DashboardCAT extends Component {
</div> </div>
</div> </div>
{!this.state.loading && this.state.dataDashboard.length > 0 && <div className="padding-20px" style={{ display: 'flex' }}> {!this.state.loading && <div className="padding-20px" style={{ display: 'flex' }}>
<Paper style={{ marginTop: 10, }}> <Paper style={{ marginTop: 10, }}>
<AppBar position="static" style={{ borderTopRightRadius: 10, borderTopLeftRadius: 10 }}> <AppBar position="static" style={{ borderTopRightRadius: 10, borderTopLeftRadius: 10 }}>
<Tabs indicatorColor="primary" value={this.state.tab} onChange={this.selectTab} aria-label="simple tabs example" style={{ backgroundColor: '#354960', borderColor: 'transparent',borderTopRightRadius: 10, borderTopLeftRadius: 10 }}> <Tabs indicatorColor="primary" value={this.state.tab} onChange={this.selectTab} aria-label="simple tabs example" style={{ backgroundColor: '#354960', borderColor: 'transparent',borderTopRightRadius: 10, borderTopLeftRadius: 10 }}>
......
...@@ -3,6 +3,9 @@ import ReactSpeedometer from "react-d3-speedometer" ...@@ -3,6 +3,9 @@ import ReactSpeedometer from "react-d3-speedometer"
import { GridList, Paper, Typography, GridListTile } from '@material-ui/core' import { GridList, Paper, Typography, GridListTile } from '@material-ui/core'
import Images from '../../assets/Images' import Images from '../../assets/Images'
import LineChart from 'react-linechart'; import LineChart from 'react-linechart';
import { titleCase } from '../../library/Utils';
import NumberFormat from 'react-number-format';
import { tr } from 'date-fns/locale';
export default class ExceutiveScoreboard extends Component { export default class ExceutiveScoreboard extends Component {
constructor(props) { constructor(props) {
...@@ -15,17 +18,23 @@ export default class ExceutiveScoreboard extends Component { ...@@ -15,17 +18,23 @@ export default class ExceutiveScoreboard extends Component {
{ judul: "Internal Perspective", kpi: 5, rank: 'C', value: 2.61, status: 'down' }, { judul: "Internal Perspective", kpi: 5, rank: 'C', value: 2.61, status: 'down' },
{ judul: "Financial", kpi: 5, rank: 'B+', value: 3.52, status: 'up' }, { judul: "Financial", kpi: 5, rank: 'B+', value: 3.52, status: 'up' },
], ],
data: this.props.data, arraySpeedo: [],
data: [],
newData: [],
dataPayload: this.props.dataPayload, dataPayload: this.props.dataPayload,
selectIndex: null selectIndex: null,
loading: false
} }
} }
componentDidMount() { componentDidMount() {
console.log(this.props.data) // console.log()
console.log(this.state.dataPayload) console.log(this.state.dataPayload)
let arrOverAll = [] let arrOverAll = []
let newData = []
let totalOverAll = 0 let totalOverAll = 0
this.setState({loading: true})
this.olahDataChart()
if (this.state.data.length > 0) { if (this.state.data.length > 0) {
this.state.data.map((item,index) => { this.state.data.map((item,index) => {
if(item.parent == null || item.parent == 'null') { if(item.parent == null || item.parent == 'null') {
...@@ -45,7 +54,6 @@ export default class ExceutiveScoreboard extends Component { ...@@ -45,7 +54,6 @@ export default class ExceutiveScoreboard extends Component {
this.state.dataPayload.month.month_id == 11? Number(item.month11 == null? 0 : item.month11) : this.state.dataPayload.month.month_id == 11? Number(item.month11 == null? 0 : item.month11) :
Number(item.month12 == null? 0 : item.month12) Number(item.month12 == null? 0 : item.month12)
} }
}) })
let indexFinancial = arrOverAll.findIndex((val) => String(val.item_name).toLocaleLowerCase().includes('financial')) let indexFinancial = arrOverAll.findIndex((val) => String(val.item_name).toLocaleLowerCase().includes('financial'))
...@@ -88,6 +96,106 @@ export default class ExceutiveScoreboard extends Component { ...@@ -88,6 +96,106 @@ export default class ExceutiveScoreboard extends Component {
} }
olahDataChart() {
let arrayChart = []
this.state.data.map((item,index) => {
let arrayChildChart = []
// if (item.parent != null) {
item.month.map((items,indexs) => {
arrayChildChart.push({
x: indexs,
y: items.value == null? indexs : items.value
})
})
arrayChart.push({
...item,
arrayChildChart: [{
color: "steelblue",
points: arrayChildChart
}]
})
// } else {
// arrayChart.push(item)
// }
})
console.log(arrayChart)
let arrayDataParent = arrayChart.filter((val) => val.parent == null || val.parent == 'null')
let arrayDataChild = arrayChart.filter((val) => val.parent != null || val.parent != 'null')
let arraySpeedo = []
this.setState({newData: arrayChart}, () => {
arrayDataParent.map((item,index) => {
// console.log(arrayDataChild.filter((val) => val.parent == item.item_report_id))
if (index == 0) {
arraySpeedo.push({
company_id: item.company_id,
decprev: item.decprev,
id: 99,
item_name: "Overall",
item_report_id: 9999,
arrayChildChart: [],
child: arrayDataChild,
month: item.month
})
}
arraySpeedo.push({
...item, child: arrayDataChild.filter((val) => val.parent == item.item_report_id)
})
})
console.log(arraySpeedo)
arraySpeedo.map((item,index) => {
if (item.id != 99) {
let indexID = arraySpeedo.findIndex((val) => item.item_report_id == val.item_report_id)
let indexMonthIDParent = item.month.findIndex((val) => val.name == `month${this.state.dataPayload.month.month_id}`)
let total = 0
item.child.map((items,indexs) => {
let specMonth = items.month.filter((val) => val.name == `month${this.state.dataPayload.month.month_id}`)
total += Number(specMonth[0].value)
})
arraySpeedo[indexID].month[indexMonthIDParent].value = total
}
})
let totalOverAll = 0
// arraySpeedo.map((item,index) => {
// let indexMonthIDParent = item.month.findIndex((val) => val.name == `month${this.state.dataPayload.month.month_id}`)
// if (item.id != 99) {
// totalOverAll += item.month[indexMonthIDParent].value
// }
// })
// let indexOverall = arraySpeedo.findIndex((val) => val.id == 99)
// let indexMonthIDParent = arraySpeedo[indexOverall].month.findIndex((val) => val.name == `month${this.state.dataPayload.month.month_id}`)
// arraySpeedo[indexOverall].month[indexMonthIDParent].value = totalOverAll
console.log('skl', totalOverAll)
console.log('part2', arraySpeedo)
this.setState({arraySpeedo, loading: false})
// arraySpeedo.map((item,index) => {
// if (index == 0) {
// arraySpeedoNew.push(item)
// } else {
// arraySpeedoNew.push(item)
// }
// })
})
}
handleValueChild(item) {
let data = this.state.newData.filter((val) => val.parent != null)
let indexID = data.findIndex((val) => val.item_name == item.item_name)
let indexMonthID = data[indexID].month.findIndex((val) => val.name == `month${this.state.dataPayload.month.month_id}`)
return data[indexID].month[indexMonthID].value == null? 0 : data[indexID].month[indexMonthID].value
}
handleValueSpeedo(item) {
let indexMonthID = item.month.findIndex((val) => val.name == `month${this.state.dataPayload.month.month_id}`)
return item.month[indexMonthID].value
}
render() { render() {
let { selectIndex } = this.state let { selectIndex } = this.state
...@@ -109,15 +217,15 @@ export default class ExceutiveScoreboard extends Component { ...@@ -109,15 +217,15 @@ export default class ExceutiveScoreboard extends Component {
return ( return (
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
<div style={{ display: 'flex', width: '100%', justifyContent: 'space-between', flexFlow: 'wrap' }}> <div style={{ display: 'flex', width: '100%', justifyContent: 'space-between', flexFlow: 'wrap' }}>
{this.state.listDummy.map((item, index) => { {/* {!this.state.loading && this.state.arraySpeedo.map((item, index) => {
return ( return (
<div style={{ padding: 10, backgroundColor: this.state.selectIndex === index ? '#6885a6' : '#fff', borderRadius: 6, paddingBottom: 20, margin: 10, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)' }} onClick={() => this.setState({ selectIndex: index }, () => console.log(this.state.data))}> <div style={{ padding: 10, backgroundColor: this.state.selectIndex === index ? '#6885a6' : '#fff', borderRadius: 6, paddingBottom: 20, margin: 10, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)' }} onClick={() => this.setState({ selectIndex: index }, () => console.log(item))}>
<span style={{ fontSize: '17px', color: this.state.selectIndex === index ? '#fff' : '#7e8085' }}>{item.judul}</span> <span style={{ fontSize: '17px', color: this.state.selectIndex === index ? '#fff' : '#7e8085', maxWidth: 100}}>{item.item_name}</span>
<div style={{ backgroundColor: 'transparent', display: 'flex', marginTop: index === 0 ? 54 : 30, placeContent: 'center' }}> <div style={{ backgroundColor: 'transparent', display: 'flex', marginTop: index === 0 ? 54 : 30, placeContent: 'center' }}>
<div> <div>
{index != 0 ? {index != 0 ?
<div> <div>
<span style={{ textAlign: 'center', fontSize: '24px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>{item.kpi}</span> <span style={{ textAlign: 'center', fontSize: '24px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>{item.child.length}</span>
<span style={{ textAlign: 'center', fontSize: '11px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>KPIs</span> </div> : null} <span style={{ textAlign: 'center', fontSize: '11px', color: selectIndex === index ? "#fff" : '#4b4b4b' }}>KPIs</span> </div> : null}
<div style={{ backgroundColor: index === 2 ? "#7cd532" : index === 3 ? "#fcff00" : index === 4 ? "#00b440" : "#00b1f7", textAlign: 'center', width: 40, height: 21 }}> <div style={{ backgroundColor: index === 2 ? "#7cd532" : index === 3 ? "#fcff00" : index === 4 ? "#00b440" : "#00b1f7", textAlign: 'center', width: 40, height: 21 }}>
<Typography style={{ textAlign: 'center' }}>{item.rank}</Typography> <Typography style={{ textAlign: 'center' }}>{item.rank}</Typography>
...@@ -131,9 +239,9 @@ export default class ExceutiveScoreboard extends Component { ...@@ -131,9 +239,9 @@ export default class ExceutiveScoreboard extends Component {
"#d8d8d8" "#d8d8d8"
]} ]}
needleColor={this.state.selectIndex === index ? "#fff" : '#4b4b4b'} needleColor={this.state.selectIndex === index ? "#fff" : '#4b4b4b'}
value={item.value} value={this.handleValueSpeedo(item)}
maxValue={5} maxValue={5}
customSegmentStops={[0, item.value, 5]} customSegmentStops={[0, this.handleValueSpeedo(item), 5]}
width={200} width={200}
height={140} height={140}
ringWidth={25} ringWidth={25}
...@@ -141,29 +249,29 @@ export default class ExceutiveScoreboard extends Component { ...@@ -141,29 +249,29 @@ export default class ExceutiveScoreboard extends Component {
/> />
<div style={{ backgroundColor: 'transparent', display: 'flex', marginTop: 20, placeContent: 'center' }}> <div style={{ backgroundColor: 'transparent', display: 'flex', marginTop: 20, placeContent: 'center' }}>
<div style={{ textAlign: '-webkit-center' }}> <div style={{ textAlign: '-webkit-center' }}>
{item.status === "up" ? {item.id === 99 ?
<img src={Images.up} /> : <img src={Images.down} />} <img src={Images.up} /> : <img src={Images.down} />}
<Typography style={{ fontSize: 16, color: this.state.selectIndex === index ? '#fff' : '#4b4b4b' }}>vs Last Month</Typography> <Typography style={{ fontSize: 16, color: this.state.selectIndex === index ? '#fff' : '#4b4b4b' }}>vs Last Month</Typography>
</div> </div>
</div> </div>
</div> </div>
) )
})} })} */}
</div> </div>
<div style={{padding: 10, marginTop: 10, display: 'flex', width: '100%' }}> <div style={{padding: 10, marginTop: 10, display: 'flex', width: '100%' }}>
<GridList cellHeight={250} cols={3}> {/* <GridList cellHeight={250} cols={3}>
{yuk.map((tile) => ( {this.state.newData.filter((val) => val.parent != null).map((tile) => (
<GridListTile key={tile} cols={1} style={{}}> <GridListTile key={tile} cols={1} style={{}}>
<div style={{ maxWidth: 566, height: 233, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', padding: 20, marginLeft: 5, marginTop: 5, marginRight: 5, display: 'inline-grid'}}> <div style={{ maxWidth: 566, height: 233, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', padding: 20, marginLeft: 5, marginTop: 5, marginRight: 5, display: 'inline-grid'}}>
<div> <div>
<span style={{ fontSize: 17 }}>YTD Revenue</span> <span style={{ fontSize: 17 }}>{titleCase(tile.item_name)}</span>
<Typography style={{ fontSize: 24, fontWeight: 'bold' }}>1,016,489.78</Typography> <Typography style={{ fontSize: 24, fontWeight: 'bold' }}><NumberFormat value={this.handleValueChild(tile)} displayType={'text'} thousandSeparator={true} prefix={'Rp. '}/></Typography>
<Typography style={{ fontSize: 16, fontWeight: 'bold' }}>In IDR mn</Typography> <Typography style={{ fontSize: 16, fontWeight: 'bold' }}>In IDR mn</Typography>
</div> </div>
<LineChart <LineChart
width={400} width={400}
height={50} height={50}
data={data} data={tile.arrayChildChart}
yMin={0} yMin={0}
yMax={10} yMax={10}
hideXAxis={true} hideXAxis={true}
...@@ -174,7 +282,7 @@ export default class ExceutiveScoreboard extends Component { ...@@ -174,7 +282,7 @@ export default class ExceutiveScoreboard extends Component {
</div> </div>
</GridListTile> </GridListTile>
))} ))}
</GridList> </GridList> */}
</div> </div>
{/* <div style={{ width: 566, height: 233, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', padding: 20, justifyContent: 'space-between', display: 'grid', margin: 10 }}> {/* <div style={{ width: 566, height: 233, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)', padding: 20, justifyContent: 'space-between', display: 'grid', margin: 10 }}>
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Paper, Typography } from '@material-ui/core' // import { Paper, Typography } from '@material-ui/core'
import Images from '../../assets/Images' import Images from '../../assets/Images'
import { GridList, Paper, Typography, GridListTile } from '@material-ui/core'
export default class StrategiMap extends Component { export default class StrategiMap extends Component {
constructor(props) {
super(props)
this.state = {
dataStrategy: this.props.data.strategy_map.category
}
}
componentDidMount() {
console.log(this.props.data.strategy_map);
}
render() { render() {
return ( return (
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
<Paper style={{ borderRadius: 10, boxShadow: '0 0 4px 0 rgba(0, 0, 0, 0.5)' }}> <Paper style={{ borderRadius: 10, boxShadow: '0 0 4px 0 rgba(0, 0, 0, 0.5)', width: '100%' }}>
<div style={{ height: 56, borderTopLeftRadius: 10, borderTopRightRadius: 10, backgroundColor: '#f1f1f1', display: 'flex' }}> <div style={{ height: 56, borderTopLeftRadius: 10, borderTopRightRadius: 10, backgroundColor: '#f1f1f1', display: 'flex' }}>
<div style={{ width: '25%', borderRight: 'solid 1px #d8d8d8', display: 'grid', alignContent: 'center', paddingLeft: 20 }}> <div style={{ width: '25%', borderRight: 'solid 1px #d8d8d8', display: 'grid', alignContent: 'center', paddingLeft: 20 }}>
<Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 12 }}>Category</Typography> <Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 12 }}>Category</Typography>
...@@ -15,49 +28,45 @@ export default class StrategiMap extends Component { ...@@ -15,49 +28,45 @@ export default class StrategiMap extends Component {
<Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 12 }}>KPI</Typography> <Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 12 }}>KPI</Typography>
</div> </div>
</div> </div>
<div style={{ display: 'flex' }}>
<div style={{ width: '25%', borderRight: 'solid 1px #d8d8d8', display: 'grid', paddingLeft: 20, paddingTop: 20 }}> {this.state.dataStrategy.map((item, index) => {
<div style={{ borderBottom: 'solid 1px #d8d8d8' }}> return (
<Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 14, fontFamily: 'Nunito Sans, sans-serif' }}>Financial Perspective</Typography> <div style={{ display: 'flex' }}>
</div> <div style={{ width: '25%', borderRight: 'solid 1px #d8d8d8', display: 'grid', paddingLeft: 20, paddingTop: 20 }}>
</div> <div style={{ borderBottom: 'solid 1px #d8d8d8' }}>
<div style={{ width: '75%', borderRight: 'solid 1px #d8d8d8', paddingRight: 20 }}> <Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 14, fontFamily: 'Nunito Sans, sans-serif' }}>{item.category_name}</Typography>
<div style={{ display: 'flex', alignContent: 'center', padding: 20, borderBottom: 'solid 1px #d8d8d8' }}>
<div style={{ display: 'flex', width: 220, borderRadius: 6 }}>
<div style={{ display: 'grid', alignContent: 'center', backgroundColor: '#6885a6', width: 152, borderTopLeftRadius: 6, borderBottomLeftRadius: 6 }}>
<Typography style={{ color: '#fff', fontSize: 12, justifySelf: 'center' }}>Revenue</Typography>
</div>
<div style={{ backgroundColor: '#cbf4a8', width: 68, borderTopRightRadius: 6, borderBottomRightRadius: 6, textAlign: 'center', paddingTop: 10, paddingBottom: 10 }}>
<img src={Images.up} />
<Typography style={{ color: '#4b4b4b', fontSize: 10, textAlign: 'center' }}>{'vs'}</Typography>
<Typography style={{ color: '#4b4b4b', fontSize: 10, textAlign: 'center' }}>{'Last Month'}</Typography>
</div>
</div>
<div style={{ display: 'flex', width: 220, borderRadius: 6, marginLeft: 20 }}>
<div style={{ display: 'grid', alignContent: 'center', backgroundColor: '#6885a6', width: 152, borderTopLeftRadius: 6, borderBottomLeftRadius: 6 }}>
<Typography style={{ color: '#fff', fontSize: 12, justifySelf: 'center' }}>EDITDA</Typography>
</div>
<div style={{ backgroundColor: '#cbf4a8', width: 68, borderTopRightRadius: 6, borderBottomRightRadius: 6, textAlign: 'center', paddingTop: 10, paddingBottom: 10 }}>
<img src={Images.up} />
<Typography style={{ color: '#4b4b4b', fontSize: 10, textAlign: 'center' }}>{'vs'}</Typography>
<Typography style={{ color: '#4b4b4b', fontSize: 10, textAlign: 'center' }}>{'Last Month'}</Typography>
</div> </div>
</div> </div>
<div style={{ display: 'flex', width: 220, borderRadius: 6, marginLeft: 20 }}> <div style={{ width: '75%', borderRight: 'solid 1px #d8d8d8', paddingRight: 20 }}>
<div style={{ display: 'grid', alignContent: 'center', backgroundColor: '#6885a6', width: 152, borderTopLeftRadius: 6, borderBottomLeftRadius: 6 }}> <div style={{ display: 'flex', alignContent: 'center', padding: 20, borderBottom: 'solid 1px #d8d8d8' }}>
<Typography style={{ color: '#fff', fontSize: 12, justifySelf: 'center' }}>TPAT</Typography> <GridList cellHeight={100} cols={3}>
</div> {item.nodes.length < 1?
<div style={{ backgroundColor: '#faaaaa', width: 68, borderTopRightRadius: 6, borderBottomRightRadius: 6, textAlign: 'center', paddingTop: 10, paddingBottom: 10 }}> <div style={{height: 75}}/>
<img src={Images.down} /> :
<Typography style={{ color: '#4b4b4b', fontSize: 10, textAlign: 'center' }}>{'vs'}</Typography> item.nodes.map((items, indexs) => {
<Typography style={{ color: '#4b4b4b', fontSize: 10, textAlign: 'center' }}>{'Last Month'}</Typography> return (
<GridListTile key={items} cols={item.nodes.length == 1? 3 : item.nodes.length == 2? 2 : 1} style={{}}>
<div style={{ display: 'flex', minWidth: 5, borderRadius: 6, marginLeft: 10}}>
<div style={{ display: 'grid', alignContent: 'center', backgroundColor: '#6885a6', width: 5, borderTopLeftRadius: 6, borderBottomLeftRadius: 6, padding: 10 }}>
<Typography style={{ color: '#fff', fontSize: 12, textAlign: 'center' }}>{items.item_name}</Typography>
</div>
<div style={{ backgroundColor: items.is_higher ? '#cbf4a8' : '#faaaaa', width: 68, borderTopRightRadius: 6, borderBottomRightRadius: 6, textAlign: 'center', paddingTop: 10, paddingBottom: 10 }}>
<img src={items.is_higher ? Images.up : Images.down} />
<Typography style={{ color: '#4b4b4b', fontSize: 10, textAlign: 'center' }}>{'vs'}</Typography>
<Typography style={{ color: '#4b4b4b', fontSize: 10, textAlign: 'center' }}>{'Last Month'}</Typography>
</div>
</div>
</GridListTile>
)
})}
</GridList>
</div> </div>
</div> </div>
</div> </div>
</div> )
</div> })}
<div style={{ display: 'flex' }}> {/* <div style={{ display: 'flex' }}>
<div style={{ width: '25%', borderRight: 'solid 1px #d8d8d8', display: 'grid', paddingLeft: 20, paddingTop: 20 }}> <div style={{ width: '25%', borderRight: 'solid 1px #d8d8d8', display: 'grid', paddingLeft: 20, paddingTop: 20 }}>
<div style={{ borderBottom: 'solid 1px #d8d8d8' }}> <div style={{ borderBottom: 'solid 1px #d8d8d8' }}>
<Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 14, fontFamily: 'Nunito Sans, sans-serif' }}>Customer Perspective</Typography> <Typography style={{ color: '#656565', fontWeight: 'bold', fontSize: 14, fontFamily: 'Nunito Sans, sans-serif' }}>Customer Perspective</Typography>
...@@ -149,7 +158,7 @@ export default class StrategiMap extends Component { ...@@ -149,7 +158,7 @@ export default class StrategiMap extends Component {
</div> </div>
</div> </div>
</div> </div>
</div> </div> */}
</Paper> </Paper>
</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