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

tyty

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