Commit 587ceebe authored by Riri Novita's avatar Riri Novita

update formula

parent a5fbba06
...@@ -1068,7 +1068,7 @@ export default class MonthlyReport extends Component { ...@@ -1068,7 +1068,7 @@ export default class MonthlyReport extends Component {
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
month={this.state.month} month={this.state.month}
// saveToMasterBudget={this.saveToMasterBudget.bind(this)} saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
onClickClose={() => this.setState({ visiblePL: false, visibleMonthlyReport: true })} onClickClose={() => this.setState({ visiblePL: false, visibleMonthlyReport: true })}
// getReport={this.getCompanyActive.bind(this)} // getReport={this.getCompanyActive.bind(this)}
/> />
......
...@@ -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 ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook, 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 ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget, 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 ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_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 ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual, item.profit_loss.actual === null ? "4.0" : item.profit_loss.actual === "" ? "4.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.ytd_actual === null ? "5.0" : item.profit_loss.ytd_actual === "" ? "5.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.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 ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_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 ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_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 ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb, 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 ? "0.0" : item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_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 ? "0.0" : item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb, 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 ? "0.0" : item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_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 ? "0.0" : item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month, 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 ? "0.0" : item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb, 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 ? "0.0" : item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb, item.profit_loss.mtd_vs_rb === null ? "15.0" : item.profit_loss.mtd_vs_rb === "" ? "15.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 ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook, 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 ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget, 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 ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_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 ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual, item.profit_loss.actual === null ? "4.0" : item.profit_loss.actual === "" ? "4.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.ytd_actual === null ? "5.0" : item.profit_loss.ytd_actual === "" ? "5.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.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 ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_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 ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_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 ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb, 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 ? "0.0" : item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_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 ? "0.0" : item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb, 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 ? "0.0" : item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_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 ? "0.0" : item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month, 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 ? "0.0" : item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb, 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 ? "0.0" : item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb, item.profit_loss.mtd_vs_rb === null ? "15.0" : item.profit_loss.mtd_vs_rb === "" ? "15.0" : item.profit_loss.mtd_vs_rb,
item.order, item.order,
]) ])
if (item.children !== null) { if (item.children !== null) {
...@@ -187,21 +187,23 @@ export default class ProfitLossMR extends Component { ...@@ -187,21 +187,23 @@ export default class ProfitLossMR extends Component {
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
"item_report_id": i[2], "item_report_id": i[1],
"rolling_outlook": i[6], "notes": i[6],
"master_budget": i[7], "rolling_outlook": i[7],
"rolling_budget": i[8], "master_budget": i[8],
"actual": i[9], "rolling_budget": i[9],
"actual_previous_month": i[10], "actual": i[10],
"amount_act_vs_previous_month": i[11], "ytd_actual": i[11],
"percent_act_vs_previous_month": i[12], "actual_previous_month": i[12],
"amount_act_vs_mb": i[13], "amount_act_vs_previous_month": i[13],
"percent_act_vs_mb": i[14], "percent_act_vs_previous_month": i[14],
"amount_act_vs_rb": i[15], "amount_act_vs_mb": i[15],
"percent_act_vs_rb": i[16], "percent_act_vs_mb": i[16],
"mtd_vs_previous_month": i[17], "amount_act_vs_rb": i[17],
"mtd_vs_mb": i[18], "percent_act_vs_rb": i[18],
"mtd_vs_rb": i[19] "mtd_vs_previous_month": i[19],
"mtd_vs_mb": i[20],
"mtd_vs_rb": i[21]
}) })
}) })
let payload = { let payload = {
...@@ -211,7 +213,7 @@ export default class ProfitLossMR extends Component { ...@@ -211,7 +213,7 @@ export default class ProfitLossMR extends Component {
"report_id": this.props.report_id, "report_id": this.props.report_id,
"status": type, "status": type,
"months": this.props.month.month_id, "months": this.props.month.month_id,
"balance_sheet": data "profit_loss": data
} }
api.create('UPLOAD').createMonthlyReportPL(payload).then(response => { api.create('UPLOAD').createMonthlyReportPL(payload).then(response => {
console.log(response); console.log(response);
...@@ -234,40 +236,25 @@ export default class ProfitLossMR extends Component { ...@@ -234,40 +236,25 @@ export default class ProfitLossMR extends Component {
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
const handleNotes = (value, tableMeta) => { const handleNotes = (value, tableMeta) => {
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
// console.log(dataTable2[tableMeta.rowIndex]); // console.log(dataTable2[tableMeta.rowIndex]);
} }
const handleChange = (value, tableMeta, indexChilds) => { const handleChange = (value, tableMeta, type) => {
console.log(dataTable2)
// console.log(tableMeta)
let val = String(value).split(",").join("") let val = String(value).split(",").join("")
dataTable2[tableMeta.rowIndex][10] = Number(val) if (type === "actual") {
} dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
const handlePrevAmount = ( tableMeta) =>{ } else {
let prevAmount = 0 let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
dataTable2[tableMeta.rowIndex].map((item, index) => { if (indexParent > 0) {
dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
prevAmount = Number(dataTable2[tableMeta.rowIndex][10]) - Number(dataTable2[tableMeta.rowIndex][12]) let jagain = Number(dataTable2[indexParent][10]).toFixed(1)
}) dataTable2[indexParent][10] = jagain === undefined ? (0 + Number(val)).toFixed(1) : Number(Number(jagain) + Number(val)).toFixed(1)
dataTable2[tableMeta.rowIndex][13] = Number(prevAmount).toFixed(1)
// console.log(Number(dataTable2[tableMeta.rowIndex][10]))
// console.log(b);
return prevAmount } else {
dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
}
} }
const handlePrevPercent = ( tableMeta) =>{
let b = 0
dataTable2[tableMeta.rowIndex].map((item, index) => {
b = Number(dataTable2[tableMeta.rowIndex][10]) - Number(dataTable2[tableMeta.rowIndex][12])
})
dataTable2[tableMeta.rowIndex][13] = Number(b).toFixed(1)
// console.log(Number(dataTable2[tableMeta.rowIndex][10]))
// console.log(b);
return b
} }
const handleValue = (data, type) => { const handleValue = (data, type) => {
let total = 0 let total = 0
...@@ -282,11 +269,12 @@ export default class ProfitLossMR extends Component { ...@@ -282,11 +269,12 @@ export default class ProfitLossMR extends Component {
// console.log(indexParent); // console.log(indexParent);
return a return a
} }
const handleFormula = (data, tableMeta, month, type) => { const handleFormula = (data, tableMeta, type) => {
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 tambahan = false let tambahan = false
let opet = "" let opet = ""
arrayFormula.map((item, indexs) => { arrayFormula.map((item, indexs) => {
if (item == 'X') { if (item == 'X') {
tambahan = true tambahan = true
...@@ -329,20 +317,65 @@ export default class ProfitLossMR extends Component { ...@@ -329,20 +317,65 @@ export default class ProfitLossMR extends Component {
} else if (opt == "kurang") { } else if (opt == "kurang") {
total = Number(total) - Number(item) total = Number(total) - Number(item)
} else if (opt == "kali") { } else if (opt == "kali") {
if (tableMeta.rowData[22] === 3) {
console.log(arrayFormula);
console.log(array);
console.log(total);
console.log(item);
}
total = Number(total) * Number(item) total = Number(total) * Number(item)
// if (tableMeta.rowData[22] === 3) {
// console.log(dataTable2[tableMeta.rowIndex]);
// console.log(total);
// console.log(item);
// console.log(arrayJumlah);
// }
} else if (opt == "bagi") { } else if (opt == "bagi") {
total = R.equals((Number(total) / Number(item)), NaN) ? '0' : Number(total) / Number(item) total = R.equals((Number(total) / Number(item)), NaN) ? '0' : Number(total) / Number(item)
} else { } else {
total += item total += Number(item)
} }
} }
}) })
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total) let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total)
return a return a
} }
const handleVariance = (tableMeta, dex, type) => {
let total = 0
if (dex === 1) {
total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[12])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
} else if (dex === 2) {
total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[8])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
} else if (dex === 3) {
total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[9])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
}
return total
}
const handleVariancePercent = (tableMeta, dex, type) => {
let total = 0
if (dex === 1) {
total = Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][12])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(2)
} else if (dex === 2) {
total = Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(2)
} else if (dex === 3) {
total = Number(dataTable2[tableMeta.rowIndex][17]) / Number(dataTable2[tableMeta.rowIndex][9])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(2)
}
return total
}
let columns = [ let columns = [
{ {
name: "", name: "",
...@@ -470,7 +503,26 @@ export default class ProfitLossMR extends Component { ...@@ -470,7 +503,26 @@ export default class ProfitLossMR extends Component {
return ( return (
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 4 ?
null : 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=""
disabled={true}
value={Number(handleFormula(val, tableMeta, 0)).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -554,7 +606,7 @@ export default class ProfitLossMR extends Component { ...@@ -554,7 +606,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleFormula(value, tableMeta, 1, 0)).toFixed(1)} value={Number(handleFormula(value, tableMeta, 0)).toFixed(1)}
/> />
} }
/> />
...@@ -606,7 +658,7 @@ export default class ProfitLossMR extends Component { ...@@ -606,7 +658,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleFormula(value, tableMeta, 1, 1)).toFixed(1)} value={Number(handleFormula(value, tableMeta, 1)).toFixed(1)}
/> />
} }
/> />
...@@ -678,7 +730,7 @@ export default class ProfitLossMR extends Component { ...@@ -678,7 +730,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleFormula(value, tableMeta, 1, 2)).toFixed(1)} value={Number(handleFormula(value, tableMeta, 2)).toFixed(1)}
/> />
} }
/> />
...@@ -708,6 +760,18 @@ export default class ProfitLossMR extends Component { ...@@ -708,6 +760,18 @@ export default class ProfitLossMR extends Component {
} }
} }
}, },
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{ {
name: "YTD Actual", name: "YTD Actual",
options: { options: {
...@@ -730,9 +794,28 @@ export default class ProfitLossMR extends Component { ...@@ -730,9 +794,28 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta, 2)).toFixed(1)} value={Number(handleValue(tableMeta, 0)).toFixed(1)}
/> />
</span> : </span>
:
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=""
disabled={true}
value={Number(handleFormula(val, tableMeta, 0)).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -777,9 +860,28 @@ export default class ProfitLossMR extends Component { ...@@ -777,9 +860,28 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta, 2)).toFixed(1)} value={Number(handleValue(tableMeta, 0)).toFixed(1)}
/> />
</span> : </span>
:
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=""
disabled={true}
value={Number(handleFormula(val, tableMeta, 0)).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -854,35 +956,44 @@ export default class ProfitLossMR extends Component { ...@@ -854,35 +956,44 @@ export default class ProfitLossMR extends Component {
setCellProps: () => ({ setCellProps: () => ({
style: { style: {
paddingLeft: 0, paddingLeft: 0,
paddingRight: 0 paddingRight: 10
} }
}), }),
customBodyRender: (val, tableMeta, updateValue) => { customBodyRender: (val, tableMeta, updateValue) => {
// console.log(tableMeta);
return ( return (
<div> <div>
<div className="grid grid-3x content-center"> <div className="grid grid-3x content-center">
<div className="column-1"> <div className="column-1">
<div className="grid grid-2x content-center"> <div className="grid grid-2x content-center">
<div className="column-1"> <div className="column-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
tableMeta.rowData[0] === 2 ? :
<span style={{ fontSize: 12, textAlign: 'right' }}> tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[9]}
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"
suffix={'%'}
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta, 2)).toFixed(1)} value={Number(handleFormula(val, tableMeta, 0)).toFixed(1)}
/> />
</span> }
/>
</div>
: :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={Number(tableMeta.rowData[13]).toFixed(1)} value={val}
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
...@@ -890,7 +1001,7 @@ export default class ProfitLossMR extends Component { ...@@ -890,7 +1001,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handlePrevAmount(tableMeta) ).toFixed(1)} value={Number(handleVariance(tableMeta, 1, 0)).toFixed(1)}
/> />
} }
/> />
...@@ -899,32 +1010,42 @@ export default class ProfitLossMR extends Component { ...@@ -899,32 +1010,42 @@ export default class ProfitLossMR extends Component {
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
tableMeta.rowData[0] === 2 ? :
<span style={{ fontSize: 12, textAlign: 'right' }}> tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[9]}
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={'%'}
disabled={true} disabled={true}
value={Number(handleValue(tableMeta, 3)).toFixed(1)} value={Number(handleFormula(val, tableMeta, 1)).toFixed(1)}
/> />
</span> : }
/>
</div>
:
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={Number(tableMeta.rowData[14]).toFixed(1)} 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=""
suffix={'%'}
disabled={true} disabled={true}
value={Number(tableMeta.rowData[14]).toFixed(1)} value={Number(handleVariancePercent(tableMeta, 1, 1)).toFixed(2)}
/> />
} }
/> />
...@@ -937,20 +1058,10 @@ export default class ProfitLossMR extends Component { ...@@ -937,20 +1058,10 @@ export default class ProfitLossMR extends Component {
<div className="column-2"> <div className="column-2">
<div className="grid grid-2x content-center"> <div className="grid grid-2x content-center">
<div className="column-1"> <div className="column-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
tableMeta.rowData[0] === 2 ? :
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 4)).toFixed(1)}
/>
</span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -962,7 +1073,7 @@ export default class ProfitLossMR extends Component { ...@@ -962,7 +1073,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(tableMeta.rowData[15]).toFixed(1)} value={Number(handleVariance(tableMeta, 2, 2)).toFixed(1)}
/> />
} }
/> />
...@@ -971,20 +1082,10 @@ export default class ProfitLossMR extends Component { ...@@ -971,20 +1082,10 @@ export default class ProfitLossMR extends Component {
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
tableMeta.rowData[0] === 2 ? :
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 5)).toFixed(1)}
/>
</span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -996,7 +1097,8 @@ export default class ProfitLossMR extends Component { ...@@ -996,7 +1097,8 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(tableMeta.rowData[16]).toFixed(1)} suffix={'%'}
value={Number(handleVariancePercent(tableMeta, 2, 3)).toFixed(2)}
/> />
} }
/> />
...@@ -1009,20 +1111,10 @@ export default class ProfitLossMR extends Component { ...@@ -1009,20 +1111,10 @@ export default class ProfitLossMR extends Component {
<div className="column-3"> <div className="column-3">
<div className="grid grid-2x content-center"> <div className="grid grid-2x content-center">
<div className="column-1"> <div className="column-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
tableMeta.rowData[0] === 2 ? :
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 6)).toFixed(1)}
/>
</span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -1034,7 +1126,7 @@ export default class ProfitLossMR extends Component { ...@@ -1034,7 +1126,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(tableMeta.rowData[17]).toFixed(1)} value={Number(handleVariance(tableMeta, 3, 4)).toFixed(1)}
/> />
} }
/> />
...@@ -1043,20 +1135,10 @@ export default class ProfitLossMR extends Component { ...@@ -1043,20 +1135,10 @@ export default class ProfitLossMR extends Component {
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
tableMeta.rowData[0] === 2 ? :
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 7)).toFixed(1)}
/>
</span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -1068,7 +1150,8 @@ export default class ProfitLossMR extends Component { ...@@ -1068,7 +1150,8 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(tableMeta.rowData[18]).toFixed(1)} suffix={'%'}
value={Number(handleVariancePercent(tableMeta, 3, 5)).toFixed(2)}
/> />
} }
/> />
...@@ -1084,6 +1167,36 @@ export default class ProfitLossMR extends Component { ...@@ -1084,6 +1167,36 @@ export default class ProfitLossMR extends Component {
} }
} }
}, },
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{ {
name: `MTD Explanation`, name: `MTD Explanation`,
options: { options: {
...@@ -1119,7 +1232,8 @@ export default class ProfitLossMR extends Component { ...@@ -1119,7 +1232,8 @@ export default class ProfitLossMR extends Component {
<div className="col-1"> <div className="col-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
:
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1128,7 +1242,7 @@ export default class ProfitLossMR extends Component { ...@@ -1128,7 +1242,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta, 7)).toFixed(1)} value={Number(handleValue(tableMeta, 0)).toFixed(1)}
/> />
</span> : </span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
...@@ -1153,7 +1267,8 @@ export default class ProfitLossMR extends Component { ...@@ -1153,7 +1267,8 @@ export default class ProfitLossMR extends Component {
<div className="col-2"> <div className="col-2">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
:
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1162,7 +1277,7 @@ export default class ProfitLossMR extends Component { ...@@ -1162,7 +1277,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta, 8)).toFixed(1)} value={Number(handleValue(tableMeta, 1)).toFixed(1)}
/> />
</span> : </span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
...@@ -1187,7 +1302,8 @@ export default class ProfitLossMR extends Component { ...@@ -1187,7 +1302,8 @@ export default class ProfitLossMR extends Component {
<div className="col-3"> <div className="col-3">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null
:
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1196,7 +1312,7 @@ export default class ProfitLossMR extends Component { ...@@ -1196,7 +1312,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta, 9)).toFixed(1)} value={Number(handleValue(tableMeta, 2)).toFixed(1)}
/> />
</span> : </span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
...@@ -1236,48 +1352,6 @@ export default class ProfitLossMR extends Component { ...@@ -1236,48 +1352,6 @@ export default class ProfitLossMR extends Component {
display: false display: false
} }
}, },
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
{ {
name: "", name: "",
options: { options: {
...@@ -1286,6 +1360,17 @@ export default class ProfitLossMR extends Component { ...@@ -1286,6 +1360,17 @@ export default class ProfitLossMR extends Component {
} }
] ]
const loadingComponent = (
<div style={{ position: 'fixed', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader
// css={override}
size={20}
color={"#274B80"}
loading={this.state.loading}
/>
</div>
);
return ( return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}> <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
...@@ -1313,7 +1398,7 @@ export default class ProfitLossMR extends Component { ...@@ -1313,7 +1398,7 @@ export default class ProfitLossMR extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => null} onClick={() => this.downloadTemplate()}
> >
<img src={Images.template} /> <img src={Images.template} />
</button> </button>
...@@ -1341,7 +1426,12 @@ export default class ProfitLossMR extends Component { ...@@ -1341,7 +1426,12 @@ export default class ProfitLossMR extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => null} onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
}, 100);
})}
> >
<img src={Images.download} /> <img src={Images.download} />
</button> </button>
...@@ -1362,7 +1452,6 @@ export default class ProfitLossMR extends Component { ...@@ -1362,7 +1452,6 @@ export default class ProfitLossMR extends Component {
</MuiThemeProvider> </MuiThemeProvider>
)} )}
</div> </div>
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1"> <div className="col-1">
<button <button
...@@ -1418,18 +1507,14 @@ export default class ProfitLossMR extends Component { ...@@ -1418,18 +1507,14 @@ export default class ProfitLossMR extends Component {
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
}} }}
// onClick={() => onClick={() =>
// this.state.editable === true ? this.state.saveDraft === true ?
// null : null :
// this.setState({ loading: true }, () => this.state.handleTekTekTek == 1 ? null :
// this.state.handleTekTekTek == 1 ? null : this.setState({ handleTekTekTek: 1 }, () => {
// this.setState({ handleTekTekTek: 1 }, () => { this.backToMonthlyReport('draft')
// setTimeout(() => { })
// this.uploadProfitLoss('draft') }
// }, 100);
// })
// )
// }
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
...@@ -1437,24 +1522,21 @@ export default class ProfitLossMR extends Component { ...@@ -1437,24 +1522,21 @@ export default class ProfitLossMR extends Component {
</button> </button>
<button <button
type="button" type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
:
this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => {
this.backToMonthlyReport('submitted')
})}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.editable !== true ? 'pointer' : 'default', cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
}} }}
// onClick={() =>
// this.state.editable === true ?
// null :
// this.setState({ loading: true }, () =>
// this.state.handleTekTekTek == 1 ? null :
// this.setState({ handleTekTekTek: 1 }, () => {
// setTimeout(() => {
// this.uploadProfitLoss('submitted')
// }, 100);
// })
// )
// }
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
...@@ -1462,6 +1544,7 @@ export default class ProfitLossMR extends Component { ...@@ -1462,6 +1544,7 @@ export default class ProfitLossMR extends Component {
</button> </button>
</div> </div>
</div> </div>
</div>
</Paper> </Paper>
</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