Commit d7030da5 authored by Riri Novita's avatar Riri Novita

benerin formula

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