Commit 004a6e53 authored by Riri Novita's avatar Riri Novita

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into riri

parents 716f1f9e 8afce5c3
...@@ -128,6 +128,8 @@ export default class BalanceSheetMR extends Component { ...@@ -128,6 +128,8 @@ export default class BalanceSheetMR extends Component {
item.balance_sheet.mtd_vs_previous_month === "" ? "0" : item.balance_sheet.mtd_vs_previous_month, item.balance_sheet.mtd_vs_previous_month === "" ? "0" : item.balance_sheet.mtd_vs_previous_month,
item.balance_sheet.mtd_vs_mb === "" ? "0" : item.balance_sheet.mtd_vs_mb, item.balance_sheet.mtd_vs_mb === "" ? "0" : item.balance_sheet.mtd_vs_mb,
item.balance_sheet.mtd_vs_rb === "" ? "0" : item.balance_sheet.mtd_vs_rb, item.balance_sheet.mtd_vs_rb === "" ? "0" : item.balance_sheet.mtd_vs_rb,
item.balance_sheet.actual_formula,
item.order
]) ])
} }
if (item.children !== null) { if (item.children !== null) {
...@@ -160,6 +162,8 @@ export default class BalanceSheetMR extends Component { ...@@ -160,6 +162,8 @@ export default class BalanceSheetMR extends Component {
item.balance_sheet.mtd_vs_previous_month === "" ? "0" : item.balance_sheet.mtd_vs_previous_month, item.balance_sheet.mtd_vs_previous_month === "" ? "0" : item.balance_sheet.mtd_vs_previous_month,
item.balance_sheet.mtd_vs_mb === "" ? "0" : item.balance_sheet.mtd_vs_mb, item.balance_sheet.mtd_vs_mb === "" ? "0" : item.balance_sheet.mtd_vs_mb,
item.balance_sheet.mtd_vs_rb === "" ? "0" : item.balance_sheet.mtd_vs_rb, item.balance_sheet.mtd_vs_rb === "" ? "0" : item.balance_sheet.mtd_vs_rb,
item.balance_sheet.actual_formula,
item.order
]) ])
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
...@@ -279,13 +283,15 @@ export default class BalanceSheetMR extends Component { ...@@ -279,13 +283,15 @@ export default class BalanceSheetMR extends Component {
item.mtd_vs_previous_month === "" ? "" : item.mtd_vs_previous_month, item.mtd_vs_previous_month === "" ? "" : item.mtd_vs_previous_month,
item.mtd_vs_mb === "" ? "" : item.mtd_vs_mb, item.mtd_vs_mb === "" ? "" : item.mtd_vs_mb,
item.mtd_vs_rb === "" ? "" : item.mtd_vs_rb === null ? 0 : item.mtd_vs_rb, item.mtd_vs_rb === "" ? "" : item.mtd_vs_rb === null ? 0 : item.mtd_vs_rb,
item.actual_formula,
item.orders,
item.error item.error
] ]
}) })
console.log(dataTable) console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[20].length > 0) { if (item[22].length > 0) {
// console.log('masuk') // console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true }) this.setState({ buttonError: true, errorPreview: true, editable: true })
} }
...@@ -485,6 +491,213 @@ export default class BalanceSheetMR extends Component { ...@@ -485,6 +491,213 @@ export default class BalanceSheetMR extends Component {
return total return total
} }
const handleValueFormula = (tableMeta, colIdx) => {
// loading = true
let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
let baru = []
let anjay = []
splitFormula.map((item, index) => {
let items = String(item).substr(Number(String(item).length) - 1, 1)
let subForm = String(item).substr(0, Number(String(item).length) - 1)
let re = /^[a-zA-Z0-9_]+$/;
if (item !== "") {
if (items == ']') {
baru.push(String(item))
} else if (!re.test(items)) {
baru.push(subForm)
baru.push(items)
} else {
baru.push(String(item))
}
}
})
baru.map((item, index) => {
if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
anjay.push(item)
} else {
if (String(item).includes('#')) {
if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
let indexID = dataTable2.findIndex((val) => val[21] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][9]
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
let data = tableMeta.rowData[20]
let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
if (indexID !== -1) {
let valuezz = data[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
} else {
if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
let indexID = dataTable2.findIndex((val) => val[21] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][9]
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
let indexID = dataTable2.findIndex((val) => val[21] == item)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][colIdx]
if (item == dataTable2[tableMeta.rowIndex][22]) {
anjay.push(0)
} else {
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
if (item === '(-1)') {
anjay.push(-1)
}
}
}
}
}
})
let anjay2 = []
let kurung = false
let item1 = []
anjay.map((item, index) => {
if (item == "(") {
kurung = true
} else if (item == ")") {
kurung = false
anjay2.push(item1)
item1 = []
} else {
if (kurung) {
item1.push(item)
} else {
anjay2.push(item)
}
}
})
let total = 0
let opt = ""
let totalPrio = 0
let optPrio = ""
let prio = false
anjay2.map((item, index) => {
if (Array.isArray(item)) {
prio = true
item.map((items, indexs) => {
if (items == "+") {
optPrio = "tambah"
} else if (items == "-") {
optPrio = "kurang"
} else if (items == "*") {
optPrio = "kali"
} else if (items == "/") {
optPrio = "bagi"
} else {
if (optPrio == "tambah") {
totalPrio = Number(totalPrio) + Number(items)
} else if (optPrio == "kurang") {
totalPrio = Number(totalPrio) - Number(items)
} else if (optPrio == "kali") {
totalPrio = Number(totalPrio) * Number(items)
} else if (optPrio == "bagi") {
totalPrio = Number(totalPrio) / Number(items) == NaN ? 0 : Number(totalPrio) / Number(items)
} else {
totalPrio += Number(items)
}
}
})
if (index == anjay2.length - 1) {
if (opt == "tambah") {
total = Number(total) + Number(totalPrio)
} else if (opt == "kurang") {
total = Number(total) - Number(totalPrio)
} else if (opt == "kali") {
total = Number(total) * Number(totalPrio)
} else if (opt == "bagi") {
total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
} else {
total += Number(totalPrio)
}
}
} else {
if (item == "+") {
opt = "tambah"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "-") {
opt = "kurang"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "*") {
opt = "kali"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "/") {
opt = "bagi"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else {
if (opt == "tambah") {
total = Number(total) + Number(item)
} else if (opt == "kurang") {
total = Number(total) - Number(item)
} else if (opt == "kali") {
total = Number(total) * Number(item)
} else if (opt == "bagi") {
total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
} else {
total += Number(item)
}
}
}
})
total = R.equals(total, NaN) ? "0.0" : total
// // // total = R.equals(total, NaN) ? "0.0" : total
// // // console.log(dataTable2[tableMeta.rowIndex][22])
// // // console.log(tableMeta.rowData[5])
// // 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][colIdx].value == undefined) {
dataTable2[tableMeta.rowIndex][colIdx] = total
// } else {
// dataTable2[tableMeta.rowIndex][column].value = total
// }
// loading = false
return total
}
let columns = [ let columns = [
{ {
name: "", name: "",
...@@ -624,6 +837,23 @@ export default class BalanceSheetMR extends Component { ...@@ -624,6 +837,23 @@ export default class BalanceSheetMR extends Component {
value={Number(handleValue(tableMeta, 0)).toFixed(1)} value={Number(handleValue(tableMeta, 0)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(tableMeta, 7)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -658,6 +888,23 @@ export default class BalanceSheetMR extends Component { ...@@ -658,6 +888,23 @@ export default class BalanceSheetMR extends Component {
value={Number(handleValue(tableMeta, 1)).toFixed(1)} value={Number(handleValue(tableMeta, 1)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(tableMeta, 8)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -701,6 +948,23 @@ export default class BalanceSheetMR extends Component { ...@@ -701,6 +948,23 @@ export default class BalanceSheetMR extends Component {
} }
/> />
</div> : </div> :
tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(tableMeta, 9)).toFixed(1)}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1303,6 +1567,12 @@ export default class BalanceSheetMR extends Component { ...@@ -1303,6 +1567,12 @@ export default class BalanceSheetMR extends Component {
options: { options: {
display: false display: false
} }
},
{
name: "",
options: {
display: false
}
} }
] ]
......
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