Commit d6ee7252 authored by Faisal Hamdi's avatar Faisal Hamdi

Merge branch 'riri' into 'master'

persave-an monthly pl

See merge request !696
parents e457786b 093072c1
...@@ -1069,7 +1069,7 @@ export default class MonthlyReport extends Component { ...@@ -1069,7 +1069,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)}
/> />
......
...@@ -183,25 +183,27 @@ export default class ProfitLossMR extends Component { ...@@ -183,25 +183,27 @@ export default class ProfitLossMR extends Component {
} }
backToMonthlyReport(type) { backToMonthlyReport(type) {
console.log(this.state.dataTable); // console.log(this.state.dataTable);
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,59 +236,45 @@ export default class ProfitLossMR extends Component { ...@@ -234,59 +236,45 @@ 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(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
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
} }
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,25 @@ export default class ProfitLossMR extends Component { ...@@ -854,35 +956,25 @@ 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' }}>
<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, 2)).toFixed(1)}
/>
</span>
: :
<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 +982,7 @@ export default class ProfitLossMR extends Component { ...@@ -890,7 +982,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 +991,23 @@ export default class ProfitLossMR extends Component { ...@@ -899,32 +991,23 @@ 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, 3)).toFixed(1)}
/>
</span> :
<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 +1020,10 @@ export default class ProfitLossMR extends Component { ...@@ -937,20 +1020,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 +1035,7 @@ export default class ProfitLossMR extends Component { ...@@ -962,7 +1035,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 +1044,10 @@ export default class ProfitLossMR extends Component { ...@@ -971,20 +1044,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 +1059,8 @@ export default class ProfitLossMR extends Component { ...@@ -996,7 +1059,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 +1073,10 @@ export default class ProfitLossMR extends Component { ...@@ -1009,20 +1073,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 +1088,7 @@ export default class ProfitLossMR extends Component { ...@@ -1034,7 +1088,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 +1097,10 @@ export default class ProfitLossMR extends Component { ...@@ -1043,20 +1097,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 +1112,8 @@ export default class ProfitLossMR extends Component { ...@@ -1068,7 +1112,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 +1129,36 @@ export default class ProfitLossMR extends Component { ...@@ -1084,6 +1129,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 +1194,8 @@ export default class ProfitLossMR extends Component { ...@@ -1119,7 +1194,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 +1204,7 @@ export default class ProfitLossMR extends Component { ...@@ -1128,7 +1204,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 +1229,8 @@ export default class ProfitLossMR extends Component { ...@@ -1153,7 +1229,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 +1239,7 @@ export default class ProfitLossMR extends Component { ...@@ -1162,7 +1239,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 +1264,8 @@ export default class ProfitLossMR extends Component { ...@@ -1187,7 +1264,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 +1274,7 @@ export default class ProfitLossMR extends Component { ...@@ -1196,7 +1274,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 +1314,6 @@ export default class ProfitLossMR extends Component { ...@@ -1236,48 +1314,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,13 +1322,25 @@ export default class ProfitLossMR extends Component { ...@@ -1286,13 +1322,25 @@ 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 }}>
{this.state.loading && loadingComponent}
<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 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
</div> </div>
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}> <Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Profit Loss</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Profit Loss</Typography>
</div> </div>
...@@ -1313,7 +1361,7 @@ export default class ProfitLossMR extends Component { ...@@ -1313,7 +1361,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 +1389,12 @@ export default class ProfitLossMR extends Component { ...@@ -1341,7 +1389,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 +1415,8 @@ export default class ProfitLossMR extends Component { ...@@ -1362,7 +1415,8 @@ export default class ProfitLossMR extends Component {
</MuiThemeProvider> </MuiThemeProvider>
)} )}
</div> </div>
</div> {/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
(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') ? */}
<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
...@@ -1388,18 +1442,17 @@ export default class ProfitLossMR extends Component { ...@@ -1388,18 +1442,17 @@ export default class ProfitLossMR extends Component {
<button <button
className="button" className="button"
type="button" type="button"
disabled={this.state.buttonError}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
}} }}
onClick={() => { onClick={() => {
this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => { this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false}) this.setState({ loading: false })
// this.handleValidate() // this.handleValidate()
}, 100); }, 100);
}) })
...@@ -1410,26 +1463,23 @@ export default class ProfitLossMR extends Component { ...@@ -1410,26 +1463,23 @@ export default class ProfitLossMR extends Component {
</div> </div>
</button> </button>
<button <button
className="button"
type="button" type="button"
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.editable !== true ? 'pointer' : 'default', cursor: this.state.saveDraft !== true ? 'pointer' : 'default',
borderColor: 'transparent', borderColor: 'transparent',
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 +1487,21 @@ export default class ProfitLossMR extends Component { ...@@ -1437,24 +1487,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 +1509,9 @@ export default class ProfitLossMR extends Component { ...@@ -1462,6 +1509,9 @@ export default class ProfitLossMR extends Component {
</button> </button>
</div> </div>
</div> </div>
{/* : null
} */}
</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