Commit d7030da5 authored by Riri Novita's avatar Riri Novita

benerin formula

parent c0050637
......@@ -85,21 +85,21 @@ export default class ProfitLossMR extends Component {
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.rolling_outlook === null ? "1.0" : item.profit_loss.rolling_outlook === "" ? "1.0" : item.profit_loss.rolling_outlook,
item.profit_loss.master_budget === null ? "2.0" : item.profit_loss.master_budget === "" ? "2.0" : item.profit_loss.master_budget,
item.profit_loss.rolling_budget === null ? "3.0" : item.profit_loss.rolling_budget === "" ? "3.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "4.0" : item.profit_loss.actual === "" ? "4.0" : item.profit_loss.actual,
item.profit_loss.ytd_actual === null ? "5.0" : item.profit_loss.ytd_actual === "" ? "5.0" : item.profit_loss.ytd_actual,
item.profit_loss.actual_previous_month === null ? "6.0" : item.profit_loss.actual_previous_month === "" ? "6.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "7.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "7.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "8.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "8.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "9.0" : item.profit_loss.amount_act_vs_mb === "" ? "9.0" : item.profit_loss.amount_act_vs_mb,
item.profit_loss.percent_act_vs_mb === null ? "10.0" : item.profit_loss.percent_act_vs_mb === "" ? "10.0" : item.profit_loss.percent_act_vs_mb,
item.profit_loss.amount_act_vs_rb === null ? "11.0" : item.profit_loss.amount_act_vs_rb === "" ? "11.0" : item.profit_loss.amount_act_vs_rb,
item.profit_loss.percent_act_vs_rb === null ? "12.0" : item.profit_loss.percent_act_vs_rb === "" ? "12.0" : item.profit_loss.percent_act_vs_rb,
item.profit_loss.mtd_vs_previous_month === null ? "13.0" : item.profit_loss.mtd_vs_previous_month === "" ? "13.0" : item.profit_loss.mtd_vs_previous_month,
item.profit_loss.mtd_vs_mb === null ? "14.0" : item.profit_loss.mtd_vs_mb === "" ? "14.0" : item.profit_loss.mtd_vs_mb,
item.profit_loss.mtd_vs_rb === null ? "15.0" : item.profit_loss.mtd_vs_rb === "" ? "15.0" : item.profit_loss.mtd_vs_rb,
item.profit_loss.rolling_outlook === null ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook,
item.profit_loss.master_budget === null ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget,
item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual,
item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
item.profit_loss.percent_act_vs_mb === null ? "0.0" : item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_act_vs_mb,
item.profit_loss.amount_act_vs_rb === null ? "0.0" : item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb,
item.profit_loss.percent_act_vs_rb === null ? "0.0" : item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_act_vs_rb,
item.profit_loss.mtd_vs_previous_month === null ? "0.0" : item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month,
item.profit_loss.mtd_vs_mb === null ? "0.0" : item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb,
item.profit_loss.mtd_vs_rb === null ? "0.0" : item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb,
item.order
])
}
......@@ -120,21 +120,21 @@ export default class ProfitLossMR extends Component {
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.rolling_outlook === null ? "1.0" : item.profit_loss.rolling_outlook === "" ? "1.0" : item.profit_loss.rolling_outlook,
item.profit_loss.master_budget === null ? "2.0" : item.profit_loss.master_budget === "" ? "2.0" : item.profit_loss.master_budget,
item.profit_loss.rolling_budget === null ? "3.0" : item.profit_loss.rolling_budget === "" ? "3.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "4.0" : item.profit_loss.actual === "" ? "4.0" : item.profit_loss.actual,
item.profit_loss.ytd_actual === null ? "5.0" : item.profit_loss.ytd_actual === "" ? "5.0" : item.profit_loss.ytd_actual,
item.profit_loss.actual_previous_month === null ? "6.0" : item.profit_loss.actual_previous_month === "" ? "6.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "7.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "7.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "8.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "8.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "9.0" : item.profit_loss.amount_act_vs_mb === "" ? "9.0" : item.profit_loss.amount_act_vs_mb,
item.profit_loss.percent_act_vs_mb === null ? "10.0" : item.profit_loss.percent_act_vs_mb === "" ? "10.0" : item.profit_loss.percent_act_vs_mb,
item.profit_loss.amount_act_vs_rb === null ? "11.0" : item.profit_loss.amount_act_vs_rb === "" ? "11.0" : item.profit_loss.amount_act_vs_rb,
item.profit_loss.percent_act_vs_rb === null ? "12.0" : item.profit_loss.percent_act_vs_rb === "" ? "12.0" : item.profit_loss.percent_act_vs_rb,
item.profit_loss.mtd_vs_previous_month === null ? "13.0" : item.profit_loss.mtd_vs_previous_month === "" ? "13.0" : item.profit_loss.mtd_vs_previous_month,
item.profit_loss.mtd_vs_mb === null ? "14.0" : item.profit_loss.mtd_vs_mb === "" ? "14.0" : item.profit_loss.mtd_vs_mb,
item.profit_loss.mtd_vs_rb === null ? "15.0" : item.profit_loss.mtd_vs_rb === "" ? "15.0" : item.profit_loss.mtd_vs_rb,
item.profit_loss.rolling_outlook === null ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook,
item.profit_loss.master_budget === null ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget,
item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual,
item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
item.profit_loss.percent_act_vs_mb === null ? "0.0" : item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_act_vs_mb,
item.profit_loss.amount_act_vs_rb === null ? "0.0" : item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb,
item.profit_loss.percent_act_vs_rb === null ? "0.0" : item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_act_vs_rb,
item.profit_loss.mtd_vs_previous_month === null ? "0.0" : item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month,
item.profit_loss.mtd_vs_mb === null ? "0.0" : item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb,
item.profit_loss.mtd_vs_rb === null ? "0.0" : item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb,
item.order,
])
if (item.children !== null) {
......@@ -241,6 +241,7 @@ export default class ProfitLossMR extends Component {
// console.log(dataTable2[tableMeta.rowIndex]);
}
const handleChange = (value, tableMeta, type) => {
console.log(dataTable2);
let val = String(value).split(",").join("")
if (type === "actual") {
dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
......@@ -259,13 +260,12 @@ export default class ProfitLossMR extends Component {
const handleValue = (data, type) => {
let total = 0
dataTable2.map((item, index) => {
if (data.rowData[1] === item[2]) {
let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type])
total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal
if (data.rowData[1] == item[2]) {
total = item[data.columnIndex + type] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex + type]))
}
})
let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
let a = dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[data.rowIndex][2])
let a = dataTable2[data.rowIndex][data.columnIndex + type] = Number(total)
// console.log(indexParent);
return a
}
......@@ -318,12 +318,12 @@ export default class ProfitLossMR extends Component {
total = Number(total) - Number(item)
} else if (opt == "kali") {
if (tableMeta.rowData[22] === 3) {
console.log(arrayFormula);
console.log(array);
console.log(total);
console.log(item);
}
// if (tableMeta.rowData[22] === 3) {
// console.log(arrayFormula);
// console.log(array);
// console.log(total);
// console.log(item);
// }
total = Number(total) * Number(item)
// if (tableMeta.rowData[22] === 3) {
// console.log(dataTable2[tableMeta.rowIndex]);
......@@ -971,25 +971,6 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[9]}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
suffix={'%'}
placeholder=""
disabled={true}
value={Number(handleFormula(val, tableMeta, 0)).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1014,25 +995,6 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[9]}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
suffix={'%'}
disabled={true}
value={Number(handleFormula(val, tableMeta, 1)).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......
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