Commit 608931d4 authored by d.arizona's avatar d.arizona

tyty

parent 997afa80
......@@ -135,7 +135,7 @@ export default class CashFlow extends Component {
}
}
})
this.setState({ dataTable, loading: false, dataReal: res, editable: true }, () => console.log(dataTable))
this.setState({ dataTable, loading: false, dataReal: res, editable: true })
})
}
......@@ -162,21 +162,17 @@ export default class CashFlow extends Component {
render() {
let dataTable2 = this.state.dataTable
let loading = false
const handleValueFormula = (value, tableMeta, column, periode, forecast) => {
loading = true
let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
// let splitFormula = String(tableMeta.rowData[3]).split('@')
let baru = []
let anjay = []
// if (forecast !== undefined) {
// console.log(tableMeta)
// }
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_]+$/;
let asd = ''
if (item !== "") {
if (!re.test(items)) {
baru.push(subForm)
......@@ -187,21 +183,39 @@ export default class CashFlow extends Component {
}
})
let handledoubleFC = 0
baru.map((item, index) => {
if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
anjay.push(item)
} else {
if (String(item).includes('#')) {
if (forecast !== undefined) {
let forecastt = 0
forecast.map((items, index) => {
if (items.periode == periode) {
forecastt += Number(items.value)
if (String(item).includes('[M-1]')) {
if (forecast !== undefined) {
let forecastt = 0
if (column == 20) {
let tst = String(item).replace('[M-1]', '')
let data = 18
let period = this.props.periode
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
forecastt += Number(valuezz == "" ? 0 : valuezz)
}
}
})
anjay.push(forecastt)
} else {
if (String(item).includes('[M-1]')) {
if (column == 21) {
let tst = String(item).replace('[M-1]', '')
let period = Number(this.props.periode) + 1
let indexID = forecast.findIndex((val) => String(val.item_formula).replace('forecast_', '') == String(`@${tst}`) && val.periode == period)
if (indexID !== -1) {
let valuezz = forecast[indexID].value
forecastt += Number(valuezz == "" ? 0 : valuezz)
}
}
anjay.push(forecastt)
} else {
let tst = String(item).replace('[M-1]', '')
let data = column == 7 ? 18 : column - 1
let period = data == 18 ? Number(this.props.periode) - 1 : this.props.periode
......@@ -211,6 +225,14 @@ export default class CashFlow extends Component {
let valuezz = tableMeta.rowData[data].formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
} else {
if (forecast !== undefined) {
let indexID = forecast.findIndex((val) => String(val.item_formula).replace('forecast_', '') == String(`@${item}`) && val.periode == Number(periode))
if (indexID !== -1) {
let valuezz = forecast[indexID].value
anjay.push(valuezz == "" ? 0 : Number(valuezz))
}
} else {
let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
if (indexID !== -1) {
......@@ -219,18 +241,15 @@ export default class CashFlow extends Component {
}
}
}
} else {
let indexID = dataTable2.findIndex((val) => val[22] == item)
if (indexID !== -1) {
// if (forecast !== undefined) {
// console.log(dataTable2[indexID])
// console.log(column)
// console.log(dataTable2[indexID][column])
// }
let valuezz = dataTable2[indexID][column].value == undefined ? dataTable2[indexID][column] : dataTable2[indexID][column].value
anjay.push(valuezz == "" ? 0 : valuezz)
if (item == dataTable2[tableMeta.rowIndex][22]) {
anjay.push(0)
} else {
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
if (item === '(-1)') {
anjay.push(-1)
......@@ -259,10 +278,6 @@ export default class CashFlow extends Component {
}
})
// if (tableMeta.rowData[5] == "1.0 Cash inflow/ (outflow) from Operating Activities") {
// console.log(anjay2)
// }
let total = 0
let opt = ""
let totalPrio = 0
......@@ -309,7 +324,6 @@ export default class CashFlow extends Component {
}
}
} else {
// console.log(item.length)
if (item == "+") {
opt = "tambah"
if (prio) {
......@@ -362,32 +376,30 @@ export default class CashFlow extends Component {
// // total = R.equals(total, NaN) ? "0.0" : total
// // console.log(dataTable2[tableMeta.rowIndex][22])
// // console.log(tableMeta.rowData[5])
// // if (tableMeta.rowData[5] == 'Beginning Balance') {
// console.log(baru)
// console.log(anjay)
// console.log(anjay2)
// console.log(total)
// if (tableMeta.rowData[5] == "1.5 Other non-current assets") {
// if (forecast !== undefined) {
// if (String(tableMeta.rowData[5]) == "Depreciation & amortisation") {
// console.log(splitFormula)
// console.log(baru)
// console.log(anjay)
// console.log(anjay2)
// console.log(total)
// console.log(dataTable2[tableMeta.rowIndex])
// }
// }
if (dataTable2[tableMeta.rowIndex][column].value == undefined) {
// console.log([tableMeta.rowIndex][tableMeta.columnIndex])
dataTable2[tableMeta.rowIndex][column] = total
} else {
dataTable2[tableMeta.rowIndex][column].value = total
}
loading = false
return total
}
const handleForecast = (tableMeta, periode, column) => {
let total = 0
// console.log(tableMeta.rowData)
// console.log(tableMeta.rowIndex)
// console.log(total)
// dataTable2[tableMeta.rowIndex][column] = total
total = handleValueFormula(dataTable2[tableMeta.rowIndex][column], tableMeta, column, periode, dataTable2[tableMeta.rowIndex][25])
// console.log(total)
return total
}
......@@ -2061,6 +2073,61 @@ export default class CashFlow extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
tableMeta.rowData[0] === 7 ?
Number(handleForecast(tableMeta, `${Number(this.props.periode) + 1}`, 20)).toFixed(1) === Number(tableMeta.rowData[23] == "" ? "0" : tableMeta.rowData[23]).toFixed(1) ?
<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) + 1}`, 20)).toFixed(1)}
/> : tableMeta.rowData[24] === "STOPPER" ?
<LightTooltip title={`Value Should be ${tableMeta.rowData[23] == "" ? "0" : tableMeta.rowData[23]}`} 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) + 1}`, 20)).toFixed(1)}
/>
</LightTooltip> :
<LightTooltip title={`Value Should be ${tableMeta.rowData[23] == "" ? "0" : tableMeta.rowData[23]}`} 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) + 1}`, 20)).toFixed(1)}
/>
</LightTooltip>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2105,6 +2172,61 @@ export default class CashFlow extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
tableMeta.rowData[0] === 7 ?
Number(handleForecast(tableMeta, `${Number(this.props.periode) + 2}`, 21)).toFixed(1) === Number(tableMeta.rowData[23] == "" ? "0" : tableMeta.rowData[23]).toFixed(1) ?
<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) + 2}`, 21)).toFixed(1)}
/> : tableMeta.rowData[24] === "STOPPER" ?
<LightTooltip title={`Value Should be ${tableMeta.rowData[23] == "" ? "0" : tableMeta.rowData[23]}`} 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) + 2}`, 21)).toFixed(1)}
/>
</LightTooltip> :
<LightTooltip title={`Value Should be ${tableMeta.rowData[23] == "" ? "0" : tableMeta.rowData[23]}`} 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) + 2}`, 21)).toFixed(1)}
/>
</LightTooltip>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2197,14 +2319,14 @@ export default class CashFlow extends Component {
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
{loading || (this.state.loading && loadingComponent)}
{!loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</MuiThemeProvider>}
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
......
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