Commit b4f8677e authored by Deni Rinaldi's avatar Deni Rinaldi

pormule

parent fcf9d9b5
...@@ -780,14 +780,13 @@ export default class BalanceSheet extends Component { ...@@ -780,14 +780,13 @@ export default class BalanceSheet extends Component {
// console.log(indexParent); // console.log(indexParent);
return a return a
} }
const handleFormula = (data, tableMeta, column) => { const handleFormula = (data, tableMeta) => {
let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g) let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let arrayJumlah = [] let arrayJumlah = []
let operator = []
arrayFormula.map((item, indexs) => { arrayFormula.map((item, indexs) => {
let index = dataTable2.findIndex((val) => val[1] == item) let index = dataTable2.findIndex((val) => val[1] == item)
if (index > 0) { if (index > 0) {
arrayJumlah.push(dataTable2[index][column]) arrayJumlah.push(dataTable2[index][tableMeta.columnIndex])
} else { } else {
arrayJumlah.push(item) arrayJumlah.push(item)
} }
...@@ -795,15 +794,33 @@ export default class BalanceSheet extends Component { ...@@ -795,15 +794,33 @@ export default class BalanceSheet extends Component {
// operator.push(item) // operator.push(item)
// } // }
}) })
let a = arrayJumlah.join("") let array = arrayJumlah
console.log(arrayJumlah); let total = 0
// if (arrayJumlah.length > 0) { let opt = ""
// console.log(arrayJumlah); array.map((item, index) => {
// let a = Number(arrayJumlah[0]) + Number(arrayJumlah[1]) if (item == "+") {
// return a opt = "tambah"
// } else { } else if (item == "-") {
// return 'Formula' opt = "kurang"
// } } else if (item == "*") {
opt = "kali"
} else if (item == "/") {
opt = "bagi"
} 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)
} else {
total += item
}
}
})
return total
} }
const columns = [{ const columns = [{
...@@ -903,10 +920,24 @@ export default class BalanceSheet extends Component { ...@@ -903,10 +920,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>{handleFormula(value, tableMeta, 6)}</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -975,10 +1006,24 @@ export default class BalanceSheet extends Component { ...@@ -975,10 +1006,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1047,10 +1092,24 @@ export default class BalanceSheet extends Component { ...@@ -1047,10 +1092,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1119,10 +1178,24 @@ export default class BalanceSheet extends Component { ...@@ -1119,10 +1178,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1191,10 +1264,24 @@ export default class BalanceSheet extends Component { ...@@ -1191,10 +1264,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1263,10 +1350,24 @@ export default class BalanceSheet extends Component { ...@@ -1263,10 +1350,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1335,10 +1436,24 @@ export default class BalanceSheet extends Component { ...@@ -1335,10 +1436,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1407,10 +1522,24 @@ export default class BalanceSheet extends Component { ...@@ -1407,10 +1522,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1479,10 +1608,24 @@ export default class BalanceSheet extends Component { ...@@ -1479,10 +1608,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1551,10 +1694,24 @@ export default class BalanceSheet extends Component { ...@@ -1551,10 +1694,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1623,10 +1780,24 @@ export default class BalanceSheet extends Component { ...@@ -1623,10 +1780,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1695,10 +1866,24 @@ export default class BalanceSheet extends Component { ...@@ -1695,10 +1866,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1767,10 +1952,24 @@ export default class BalanceSheet extends Component { ...@@ -1767,10 +1952,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1839,10 +2038,24 @@ export default class BalanceSheet extends Component { ...@@ -1839,10 +2038,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1911,10 +2124,24 @@ export default class BalanceSheet extends Component { ...@@ -1911,10 +2124,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
...@@ -1983,10 +2210,24 @@ export default class BalanceSheet extends Component { ...@@ -1983,10 +2210,24 @@ export default class BalanceSheet extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<span>Formula</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
<span>Formula Summary</span> <NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
/>
: :
tableMeta.rowData[0] === 1 ? tableMeta.rowData[0] === 1 ?
value === "" ? value === "" ?
......
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