Commit be94de8d authored by d.arizona's avatar d.arizona

deploy

parent 35357351
...@@ -112,6 +112,7 @@ export default class CashFlowMR extends Component { ...@@ -112,6 +112,7 @@ export default class CashFlowMR extends Component {
} }
} }
}) })
console.log(dataTable)
this.setState({ dataTable, loading: false }) this.setState({ dataTable, loading: false })
} }
}) })
...@@ -137,124 +138,208 @@ export default class CashFlowMR extends Component { ...@@ -137,124 +138,208 @@ export default class CashFlowMR extends Component {
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
const handleValueFormula = (value, tableMeta, column, periode, forecast) => { const handleValueFormula = (tableMeta, colIdx) => {
let splitFormula = String(tableMeta.rowData[3]).split('@') // loading = true
// console.log(tableMeta);
// "@44[M-1]#BS"
let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
let baru = [] let baru = []
let anjay = [] let anjay = []
// console.log(splitFormula);
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 re = /^[a-zA-Z0-9]+$/; let subForm = String(item).substr(0, Number(String(item).length) - 1)
let asd = '' // console.log(item);
// console.log(items);
// console.log(subForm);
let re = /^[a-zA-Z0-9_]+$/;
if (item !== "") { if (item !== "") {
if (!re.test(items)) { if (items == ']') {
if (String(item).substr(Number(String(item).length) - 1, 1) === ']') {
baru.push(String(item)) baru.push(String(item))
} else { } else if (!re.test(items)) {
baru.push(String(item).substr(0, Number(String(item).length) - 1)) baru.push(subForm)
baru.push(String(item).substr(Number(String(item).length) - 1, 1)) baru.push(items)
}
} else { } else {
baru.push(String(item)) baru.push(String(item))
} }
} }
}) })
// if (tableMeta.columnIndex == 7) { // console.log(baru);
// console.log(splitFormula) let tambahan = false
// console.log(baru) let opet = ""
// }
// console.log(baru)
baru.map((item, index) => { 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) 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 let tst = '@' + String(item).replace('[M-1]', '[M1]')
forecast.map((items, index) => { // console.log(dataTable2[tableMeta.rowIndex]);
if (items.periode == periode) { // console.log(tableMeta);
forecastt += Number(items.value) console.log(tst);
} let indexID = dataTable2[tableMeta.rowIndex][6].formula.findIndex((val) => val.item_formula == tst)
}) // console.log(indexID);
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 (indexID !== -1) { if (indexID !== -1) {
let valuezz = tableMeta.rowData[data].formula[indexID].value let valuezz = dataTable2[tableMeta.rowIndex][6].formula[indexID].value
// baru.push(valuezz)
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
// console.log(valuezz) // console.log(valuezz);
} }
} else { } else {
// console.log(baru); let data = tableMeta.rowData[6].formula == null? [] : tableMeta.rowData[6].formula
// console.log(value); // console.log(data)
let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode)) let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
// console.log(indexID)
if (indexID !== -1) { if (indexID !== -1) {
// console.log(value.formula[indexID].value) let valuezz = data[indexID].value
let valuezz = value.formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz) 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 { } 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) let indexID = dataTable2.findIndex((val) => val[7] == tst)
if (indexID !== -1) { 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) anjay.push(valuezz == "" ? 0 : valuezz)
} }
// console.log(tst, data, tableMeta.rowData[data]);
}
} else { } else {
let indexID = dataTable2.findIndex((val) => val[7] == item) 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) { 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) anjay.push(valuezz == "" ? 0 : valuezz)
}
} else { } else {
if (item === '(-1)') { if (item === '(-1)') {
anjay.push(-1) anjay.push(-1)
} }
// console.log(item); }
}
} }
} }
} }
}) })
// console.log(tableMeta.rowData[5])
// console.log(splitFormula)
// console.log(baru) // console.log(baru)
// console.log(anjay) // 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 total = 0
let opt = "" 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 == "+") { if (item == "+") {
opt = "tambah" opt = "tambah"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "-") { } else if (item == "-") {
opt = "kurang" opt = "kurang"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "*") { } else if (item == "*") {
opt = "kali" opt = "kali"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "/") { } else if (item == "/") {
opt = "bagi" opt = "bagi"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else { } else {
item = item == "" ? 0 : item
if (opt == "tambah") { if (opt == "tambah") {
total = Number(total) + Number(item) total = Number(total) + Number(item)
} else if (opt == "kurang") { } else if (opt == "kurang") {
...@@ -267,22 +352,10 @@ export default class CashFlowMR extends Component { ...@@ -267,22 +352,10 @@ export default class CashFlowMR extends Component {
total += Number(item) 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) { dataTable2[tableMeta.rowIndex][6].value = total
// // console.log([tableMeta.rowIndex][tableMeta.columnIndex])
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
// } else {
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
// }
return total return total
} }
...@@ -385,7 +458,7 @@ export default class CashFlowMR extends Component { ...@@ -385,7 +458,7 @@ export default class CashFlowMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)} value={Number(handleValueFormula(tableMeta, 6)).toFixed(1)}
/> />
</span> : null} </span> : null}
</div> </div>
......
...@@ -169,7 +169,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -169,7 +169,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.description, item.description,
item.corporate_annual_target.weight == ""? "0%" : item.corporate_annual_target.weight, item.corporate_annual_target.weight == ""? "0%" : item.corporate_annual_target.weight,
parentTrue ? item.corporate_annual_target.uom : item.uom, 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.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 : 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) }, // 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 { ...@@ -1186,7 +1186,23 @@ export default class CorporateAnnualTargetMR extends Component {
<div style={{ textAlign: 'center' }}> <div style={{ textAlign: 'center' }}>
{tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null : 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> </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