Commit d43bf08e authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

Didam

See merge request !918
parents 957f8eb1 9e22c668
......@@ -112,6 +112,7 @@ export default class CashFlowMR extends Component {
}
}
})
console.log(dataTable)
this.setState({ dataTable, loading: false })
}
})
......@@ -137,124 +138,208 @@ export default class CashFlowMR extends Component {
render() {
let dataTable2 = this.state.dataTable
const handleValueFormula = (value, tableMeta, column, periode, forecast) => {
let splitFormula = String(tableMeta.rowData[3]).split('@')
const handleValueFormula = (tableMeta, colIdx) => {
// loading = true
// console.log(tableMeta);
// "@44[M-1]#BS"
let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
let baru = []
let anjay = []
// console.log(splitFormula);
splitFormula.map((item, index) => {
let items = String(item).substr(Number(String(item).length) - 1, 1)
let re = /^[a-zA-Z0-9]+$/;
let asd = ''
let subForm = String(item).substr(0, Number(String(item).length) - 1)
// console.log(item);
// console.log(items);
// console.log(subForm);
let re = /^[a-zA-Z0-9_]+$/;
if (item !== "") {
if (!re.test(items)) {
if (String(item).substr(Number(String(item).length) - 1, 1) === ']') {
if (items == ']') {
baru.push(String(item))
} else {
baru.push(String(item).substr(0, Number(String(item).length) - 1))
baru.push(String(item).substr(Number(String(item).length) - 1, 1))
}
} else if (!re.test(items)) {
baru.push(subForm)
baru.push(items)
} else {
baru.push(String(item))
}
}
})
// if (tableMeta.columnIndex == 7) {
// console.log(splitFormula)
// console.log(baru)
// }
// console.log(baru)
// console.log(baru);
let tambahan = false
let opet = ""
baru.map((item, index) => {
if (item == '-' || item == '+' || item == '/' || item == '*') {
if (item == 'X') {
tambahan = true
} else 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)
}
})
anjay.push(forecastt)
} else if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '[M1]')
let data = tableMeta.columnIndex
// console.log(tableMeta.columnIndex)
let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`))
// console.log(indexID)
if (String(item).includes('[M-1]')) {
let tst = '@' + String(item).replace('[M-1]', '[M1]')
// console.log(dataTable2[tableMeta.rowIndex]);
// console.log(tableMeta);
console.log(tst);
let indexID = dataTable2[tableMeta.rowIndex][6].formula.findIndex((val) => val.item_formula == tst)
// console.log(indexID);
if (indexID !== -1) {
let valuezz = tableMeta.rowData[data].formula[indexID].value
// baru.push(valuezz)
let valuezz = dataTable2[tableMeta.rowIndex][6].formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
// console.log(valuezz)
// console.log(valuezz);
}
} else {
// console.log(baru);
// console.log(value);
let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
// console.log(indexID)
let data = tableMeta.rowData[6].formula == null? [] : tableMeta.rowData[6].formula
// console.log(data)
let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
if (indexID !== -1) {
// console.log(value.formula[indexID].value)
let valuezz = value.formula[indexID].value
let valuezz = data[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
} else if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
if (tableMeta.columnIndex === 7 || tableMeta.columnIndex === 19) {
let indexID = dataTable2.findIndex((val) => val[22] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][6]
anjay.push(valuezz == "" ? 0 : valuezz)
}
// } else if (tableMeta.columnIndex === 19) {
// let indexID = dataTable2.findIndex((val) => val[22] == tst)
// if (indexID !== -1) {
// let valuezz = dataTable2[indexID][7].value !== undefined ? dataTable2[indexID][7].value : dataTable2[indexID][7]
// anjay.push(valuezz == "" ? 0 : valuezz)
// }
} else {
let data = tableMeta.columnIndex - 1
if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
let indexID = dataTable2.findIndex((val) => val[7] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][data].value !== undefined ? dataTable2[indexID][data].value : dataTable2[indexID][data]
let valuezz = dataTable2[indexID][8]
anjay.push(valuezz == "" ? 0 : valuezz)
}
// console.log(tst, data, tableMeta.rowData[data]);
}
} else {
let indexID = dataTable2.findIndex((val) => val[7] == item)
// console.log(dataTable2[indexID])
if (item == 'X-1') {
anjay.push(-1)
} else if (tambahan) {
if (item == '-' || item == '+' || item == '/' || item == '*') {
opet = item
} else {
anjay.push(opet == ''? Number(item) : Number(String(opet + String(item))))
tambahan = false
opet = ""
}
} else {
if (indexID !== -1) {
let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
let valuezz = dataTable2[indexID][colIdx].value
if (item == dataTable2[tableMeta.rowIndex][7]) {
anjay.push(0)
} else {
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
if (item === '(-1)') {
anjay.push(-1)
}
// console.log(item);
}
}
}
}
}
})
// console.log(tableMeta.rowData[5])
// console.log(splitFormula)
// console.log(baru)
// console.log(anjay)
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 = ""
anjay.map((item, index) => {
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 {
item = item == "" ? 0 : item
if (opt == "tambah") {
total = Number(total) + Number(item)
} else if (opt == "kurang") {
......@@ -267,22 +352,10 @@ export default class CashFlowMR extends Component {
total += Number(item)
}
}
}
})
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(total)
// }
// if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
// // console.log([tableMeta.rowIndex][tableMeta.columnIndex])
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
// } else {
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
// }
dataTable2[tableMeta.rowIndex][6].value = total
return total
}
......@@ -385,7 +458,7 @@ export default class CashFlowMR extends Component {
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)}
value={Number(handleValueFormula(tableMeta, 6)).toFixed(1)}
/>
</span> : null}
</div>
......
......@@ -169,7 +169,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.description,
item.corporate_annual_target.weight == ""? "0%" : item.corporate_annual_target.weight,
parentTrue ? item.corporate_annual_target.uom : item.uom,
parentTrue ? item.corporate_annual_target.kpi_type == "" ? null : item.corporate_annual_target.kpi_type : item.kpi_type == "" ? null : item.kpi_type,
parentTrue ? item.corporate_annual_target.jenis_kpi == "" ? null : item.corporate_annual_target.jenis_kpi : item.jenis_kpi == "" ? null : item.kpi_type,
// parentTrue ? item.corporate_annual_target.kpi_type == "" ? null : { value: item.corporate_annual_target.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
parentTrue ? item.corporate_annual_target.max_ach == "" ? null : titleCase(item.corporate_annual_target.max_ach) : item.max_ach == "" ? null : titleCase(item.max_ach),
// parentTrue ? item.corporate_annual_target.max_ach == "" ? null : { value: titleCase(item.corporate_annual_target.max_ach) } : item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
......@@ -1186,7 +1186,23 @@ export default class CorporateAnnualTargetMR extends Component {
<div style={{ textAlign: 'center' }}>
{tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null :
value
<FormControlLabel
style={{ margin: 0}}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
suffix={"%"}
value={Number(value).toFixed(1)}
disabled={true}
// disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
decimalScale={1}
/>
}
/>
}
</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