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)}
/> />
......
...@@ -121,20 +121,20 @@ export default class ProfitLossMR extends Component { ...@@ -121,20 +121,20 @@ export default class ProfitLossMR extends Component {
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 ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook,
item.profit_loss.master_budget === null ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget, item.profit_loss.master_budget === null ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget,
item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget, item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual, item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual,
item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual, item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month, item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month, item.profit_loss.amount_act_vs_previous_month === null ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month, item.profit_loss.percent_act_vs_previous_month === null ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb, item.profit_loss.amount_act_vs_mb === null ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
item.profit_loss.percent_act_vs_mb === null ? "0.0" : item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_act_vs_mb, item.profit_loss.percent_act_vs_mb === null ? "0.0" : item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_act_vs_mb,
item.profit_loss.amount_act_vs_rb === null ? "0.0" : item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb, item.profit_loss.amount_act_vs_rb === null ? "0.0" : item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb,
item.profit_loss.percent_act_vs_rb === null ? "0.0" : item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_act_vs_rb, item.profit_loss.percent_act_vs_rb === null ? "0.0" : item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_act_vs_rb,
item.profit_loss.mtd_vs_previous_month === null ? "0.0" : item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month, item.profit_loss.mtd_vs_previous_month === null ? "0.0" : item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month,
item.profit_loss.mtd_vs_mb === null ? "0.0" : item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb, item.profit_loss.mtd_vs_mb === null ? "0.0" : item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb,
item.profit_loss.mtd_vs_rb === null ? "0.0" : item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb, item.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) {
...@@ -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])) } else {
// console.log(b); dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
}
return prevAmount }
}
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)}
/> />
} }
/> />
...@@ -594,40 +646,40 @@ export default class ProfitLossMR extends Component { ...@@ -594,40 +646,40 @@ export default class ProfitLossMR extends Component {
value={Number(handleValue(tableMeta, 1)).toFixed(1)} value={Number(handleValue(tableMeta, 1)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={tableMeta.rowData[9]} 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=""
disabled={true} disabled={true}
value={Number(handleFormula(value, tableMeta, 1, 1)).toFixed(1)} value={Number(handleFormula(value, tableMeta, 1)).toFixed(1)}
/> />
} }
/> />
</div> </div>
: :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={tableMeta.rowData[9]} 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=""
disabled={true} disabled={true}
value={tableMeta.rowData[9]} value={tableMeta.rowData[9]}
/> />
} }
/> />
</div> </div>
} }
</div> </div>
</div> </div>
...@@ -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,81 +956,62 @@ export default class ProfitLossMR extends Component { ...@@ -854,81 +956,62 @@ 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' }}> <div style={{ flex: 1 }}>
<NumberFormat <FormControlLabel
thousandSeparator={true} style={{ margin: 0 }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} value={val}
type="text" control={
placeholder="" <NumberFormat
disabled={true} thousandSeparator={true}
value={Number(handleValue(tableMeta, 2)).toFixed(1)} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
/> type="text"
</span> placeholder=""
: disabled={true}
<div style={{ flex: 1 }}> value={Number(handleVariance(tableMeta, 1, 0)).toFixed(1)}
<FormControlLabel />
style={{ margin: 0 }} }
value={Number(tableMeta.rowData[13]).toFixed(1)} />
control={ </div>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handlePrevAmount(tableMeta) ).toFixed(1)}
/>
}
/>
</div>
} }
</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' }}> <div style={{ flex: 1 }}>
<NumberFormat <FormControlLabel
thousandSeparator={true} style={{ margin: 0 }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} value={val}
type="text" control={
placeholder="" <NumberFormat
disabled={true} thousandSeparator={true}
value={Number(handleValue(tableMeta, 3)).toFixed(1)} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
/> type="text"
</span> : placeholder=""
<div style={{ flex: 1 }}> suffix={'%'}
<FormControlLabel disabled={true}
style={{ margin: 0 }} value={Number(handleVariancePercent(tableMeta, 1, 1)).toFixed(2)}
value={Number(tableMeta.rowData[14]).toFixed(1)} />
control={ }
<NumberFormat />
thousandSeparator={true} </div>
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[14]).toFixed(1)}
/>
}
/>
</div>
} }
</div> </div>
</div> </div>
...@@ -937,70 +1020,51 @@ export default class ProfitLossMR extends Component { ...@@ -937,70 +1020,51 @@ 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' }}> <div style={{ flex: 1 }}>
<NumberFormat <FormControlLabel
thousandSeparator={true} style={{ margin: 0 }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} value={val}
type="text" control={
placeholder="" <NumberFormat
disabled={true} thousandSeparator={true}
value={Number(handleValue(tableMeta, 4)).toFixed(1)} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
/> type="text"
</span> : placeholder=""
<div style={{ flex: 1 }}> disabled={true}
<FormControlLabel value={Number(handleVariance(tableMeta, 2, 2)).toFixed(1)}
style={{ margin: 0 }} />
value={val} }
control={ />
<NumberFormat </div>
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[15]).toFixed(1)}
/>
}
/>
</div>
} }
</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' }}> <div style={{ flex: 1 }}>
<NumberFormat <FormControlLabel
thousandSeparator={true} style={{ margin: 0 }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} value={val}
type="text" control={
placeholder="" <NumberFormat
disabled={true} thousandSeparator={true}
value={Number(handleValue(tableMeta, 5)).toFixed(1)} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
/> type="text"
</span> : placeholder=""
<div style={{ flex: 1 }}> disabled={true}
<FormControlLabel suffix={'%'}
style={{ margin: 0 }} value={Number(handleVariancePercent(tableMeta, 2, 3)).toFixed(2)}
value={val} />
control={ }
<NumberFormat />
thousandSeparator={true} </div>
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[16]).toFixed(1)}
/>
}
/>
</div>
} }
</div> </div>
</div> </div>
...@@ -1009,70 +1073,51 @@ export default class ProfitLossMR extends Component { ...@@ -1009,70 +1073,51 @@ 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' }}> <div style={{ flex: 1 }}>
<NumberFormat <FormControlLabel
thousandSeparator={true} style={{ margin: 0 }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} value={val}
type="text" control={
placeholder="" <NumberFormat
disabled={true} thousandSeparator={true}
value={Number(handleValue(tableMeta, 6)).toFixed(1)} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
/> type="text"
</span> : placeholder=""
<div style={{ flex: 1 }}> disabled={true}
<FormControlLabel value={Number(handleVariance(tableMeta, 3, 4)).toFixed(1)}
style={{ margin: 0 }} />
value={val} }
control={ />
<NumberFormat </div>
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[17]).toFixed(1)}
/>
}
/>
</div>
} }
</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' }}> <div style={{ flex: 1 }}>
<NumberFormat <FormControlLabel
thousandSeparator={true} style={{ margin: 0 }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} value={val}
type="text" control={
placeholder="" <NumberFormat
disabled={true} thousandSeparator={true}
value={Number(handleValue(tableMeta, 7)).toFixed(1)} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
/> type="text"
</span> : placeholder=""
<div style={{ flex: 1 }}> disabled={true}
<FormControlLabel suffix={'%'}
style={{ margin: 0 }} value={Number(handleVariancePercent(tableMeta, 3, 5)).toFixed(2)}
value={val} />
control={ }
<NumberFormat />
thousandSeparator={true} </div>
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[18]).toFixed(1)}
/>
}
/>
</div>
} }
</div> </div>
</div> </div>
...@@ -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,8 +1415,9 @@ export default class ProfitLossMR extends Component { ...@@ -1362,8 +1415,9 @@ export default class ProfitLossMR extends Component {
</MuiThemeProvider> </MuiThemeProvider>
)} )}
</div> </div>
</div> {/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
<div className="grid grid-2x" style={{ marginTop: 20 }}> (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="col-1"> <div className="col-1">
<button <button
type="button" type="button"
...@@ -1385,82 +1439,78 @@ export default class ProfitLossMR extends Component { ...@@ -1385,82 +1439,78 @@ export default class ProfitLossMR extends Component {
</button> </button>
</div> </div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}> <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button <button
className="button" className="button"
type="button" type="button"
disabled={this.state.buttonError} style={{
style={{ backgroundColor: 'transparent',
backgroundColor: 'transparent', cursor: 'pointer',
cursor: this.state.buttonError === true ? 'default' : 'pointer', borderColor: 'transparent',
borderColor: 'transparent', outline: 'none',
outline: 'none', marginRight: 20
marginRight: 20 }}
}} onClick={() => {
onClick={() => { this.setState({ loading: true }, () => {
this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => { setTimeout(() => {
setTimeout(() => { this.setState({ loading: false })
this.setState({ loading: false}) // this.handleValidate()
// this.handleValidate() }, 100);
}, 100); })
}) }}
}} >
> <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography> </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' }}>
// ) <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
// } </div>
> </button>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <button
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography> type="button"
</div> // disabled={this.state.buttonError}
</button> onClick={() =>
<button this.state.buttonError ?
type="button" this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
style={{ :
backgroundColor: 'transparent', this.state.handleTekTekTek == 1 ? null :
cursor: this.state.editable !== true ? 'pointer' : 'default', this.setState({ handleTekTekTek: 1 }, () => {
borderColor: 'transparent', this.backToMonthlyReport('submitted')
outline: 'none', })}
}} style={{
// onClick={() => backgroundColor: 'transparent',
// this.state.editable === true ? cursor: this.state.buttonError === true ? 'default' : 'pointer',
// null : borderColor: 'transparent',
// this.setState({ loading: true }, () => outline: 'none',
// this.state.handleTekTekTek == 1 ? null : }}
// this.setState({ handleTekTekTek: 1 }, () => { >
// setTimeout(() => { <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
// this.uploadProfitLoss('submitted') <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
// }, 100); </div>
// }) </button>
// ) </div>
// } </div>
> {/* : null
<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>
</div>
</button>
</div>
</div> </div>
</Paper> </Paper>
</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