Commit 2ac0dce5 authored by Riri Novita's avatar Riri Novita

olpa pl

parent 55cea835
...@@ -571,7 +571,7 @@ export default class OutlookPA extends Component { ...@@ -571,7 +571,7 @@ export default class OutlookPA extends Component {
this.setState({ loading: true }) this.setState({ loading: true })
// console.log(JSON.stringify(data)); // console.log(JSON.stringify(data));
api.create('UPLOAD').createReportOLPA(data).then(response => { api.create('UPLOAD').createReportOLPA(data).then(response => {
// console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.getOutlookPAID() this.getOutlookPAID()
......
...@@ -176,21 +176,21 @@ export default class ProfitLossOLPA extends Component { ...@@ -176,21 +176,21 @@ export default class ProfitLossOLPA 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.total_actual_before === null ? "0.0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before, item.profit_loss.total_actual_before === null ? "0.0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january, Number(item.profit_loss.january).toFixed(1),
item.profit_loss.february, Number(item.profit_loss.february).toFixed(1),
item.profit_loss.march, Number(item.profit_loss.march).toFixed(1),
item.profit_loss.april, Number(item.profit_loss.april).toFixed(1),
item.profit_loss.may, Number(item.profit_loss.may).toFixed(1),
item.profit_loss.june, Number(item.profit_loss.june).toFixed(1),
item.profit_loss.july, Number(item.profit_loss.july).toFixed(1),
item.profit_loss.august, Number(item.profit_loss.august).toFixed(1),
item.profit_loss.september, Number(item.profit_loss.september).toFixed(1),
item.profit_loss.october, Number(item.profit_loss.october).toFixed(1),
item.profit_loss.november, Number(item.profit_loss.november).toFixed(1),
item.profit_loss.december, Number(item.profit_loss.december).toFixed(1),
item.profit_loss.total_current_year, item.profit_loss.total_current_year,
item.profit_loss.ytd_oct === undefined ? "0.0" : item.profit_loss.ytd_oct, item.profit_loss.ytd_october,
item.profit_loss.nov_dec === undefined ? "0.0" : item.profit_loss.nov_dec, item.profit_loss.nov_dec,
item.order item.order
]) ])
} }
...@@ -212,21 +212,21 @@ export default class ProfitLossOLPA extends Component { ...@@ -212,21 +212,21 @@ export default class ProfitLossOLPA 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.total_actual_before === null ? "0.0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before, item.profit_loss.total_actual_before === null ? "0.0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january, Number(item.profit_loss.january).toFixed(1),
item.profit_loss.february, Number(item.profit_loss.february).toFixed(1),
item.profit_loss.march, Number(item.profit_loss.march).toFixed(1),
item.profit_loss.april, Number(item.profit_loss.april).toFixed(1),
item.profit_loss.may, Number(item.profit_loss.may).toFixed(1),
item.profit_loss.june, Number(item.profit_loss.june).toFixed(1),
item.profit_loss.july, Number(item.profit_loss.july).toFixed(1),
item.profit_loss.august, Number(item.profit_loss.august).toFixed(1),
item.profit_loss.september, Number(item.profit_loss.september).toFixed(1),
item.profit_loss.october, Number(item.profit_loss.october).toFixed(1),
item.profit_loss.november, Number(item.profit_loss.november).toFixed(1),
item.profit_loss.december, Number(item.profit_loss.december).toFixed(1),
item.profit_loss.total_current_year, item.profit_loss.total_current_year,
item.profit_loss.ytd_oct === undefined ? "0.0" : item.profit_loss.ytd_oct, item.profit_loss.ytd_october,
item.profit_loss.nov_dec === undefined ? "0.0" : item.profit_loss.nov_dec, item.profit_loss.nov_dec,
item.order item.order
]) ])
if (item.children !== null) { if (item.children !== null) {
...@@ -290,7 +290,9 @@ export default class ProfitLossOLPA extends Component { ...@@ -290,7 +290,9 @@ export default class ProfitLossOLPA extends Component {
october: String(Number(i[17]).toFixed(1)), october: String(Number(i[17]).toFixed(1)),
november: String(Number(i[18]).toFixed(1)), november: String(Number(i[18]).toFixed(1)),
december: String(Number(i[19]).toFixed(1)), december: String(Number(i[19]).toFixed(1)),
total_current_year: String(Number(i[20]).toFixed(1)) total_current_year: String(Number(i[20]).toFixed(1)),
ytd_october: String(Number(i[21]).toFixed(1)),
nov_dec: String(Number(i[22]).toFixed(1)),
}) })
}) })
let payload = { let payload = {
...@@ -535,33 +537,32 @@ export default class ProfitLossOLPA extends Component { ...@@ -535,33 +537,32 @@ export default class ProfitLossOLPA extends Component {
let val = String(value).split(",").join("") let val = String(value).split(",").join("")
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
} }
const handleTotal = (tableMeta) => {
const handleNotes = (value, tableMeta) => {
// console.log(value)
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
// console.log(dataTable2[tableMeta.rowIndex]);
}
const handleTotalYTD = (tableMeta) => {
let total = 0 let total = 0
dataTable2[tableMeta.rowIndex].map((item, index) => { dataTable2[tableMeta.rowIndex].map((item, index) => {
if (index >= 7 && index <= 18) { if (index >= 8 && index <= 17) {
let valItem = item == undefined || item == "" ? 0 : item let valItem = item == undefined || item == "" ? 0 : item
total += Number(valItem) total += Number(valItem)
} }
}) })
let indexParent = dataTable2.findIndex((val) => val[1] == tableMeta.rowData[2])
if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "sales price") {
let value = Number(dataTable2[tableMeta.rowIndex - 2][19]) / Number(dataTable2[tableMeta.rowIndex - 1][19])
dataTable2[tableMeta.rowIndex][19] = R.equals(value, NaN) ? "0.0" : value
return R.equals(value, NaN) ? "0.0" : value
} else if (indexParent !== -1 && String(dataTable2[indexParent][5]).toLocaleUpperCase() == "GROSS PROFIT MARGIN (% OF REVENUE)") {
return handleFormula(0, tableMeta, 0)
}
else {
dataTable2[tableMeta.rowIndex][19] = total dataTable2[tableMeta.rowIndex][21] = total
return total return total
}
// console.log(total); // console.log(total);
} }
const handleNotes = (value, tableMeta) => {
// console.log(value) const handleTotal = (tableMeta) => {
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value let total = Number(dataTable2[tableMeta.rowIndex][18]) + Number(dataTable2[tableMeta.rowIndex][19])
// console.log(dataTable2[tableMeta.rowIndex]); dataTable2[tableMeta.rowIndex][22] = total
return total
// console.log(total);
} }
const handleValue = (value, data) => { const handleValue = (value, data) => {
...@@ -1324,6 +1325,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -1324,6 +1325,7 @@ export default class ProfitLossOLPA extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
decimalScale={1}
disabled={this.props.isApprover ? true : ((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') ? false : true)} disabled={this.props.isApprover ? true : ((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') ? false : true)}
value={Number(value).toFixed(1)} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
...@@ -1468,6 +1470,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -1468,6 +1470,7 @@ export default class ProfitLossOLPA extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
decimalScale={1}
disabled={this.props.isApprover ? true : ((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') ? false : true)} disabled={this.props.isApprover ? true : ((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') ? false : true)}
value={Number(value).toFixed(1)} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
...@@ -1646,23 +1649,17 @@ export default class ProfitLossOLPA extends Component { ...@@ -1646,23 +1649,17 @@ export default class ProfitLossOLPA extends Component {
value={Number(value).toFixed(1)} value={Number(value).toFixed(1)}
/> />
: :
<div style={{ flex: 1 }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<FormControlLabel <NumberFormat
style={{ margin: 0 }} thousandSeparator={true}
value={value} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
control={ type="text"
<NumberFormat placeholder=""
thousandSeparator={true} disabled={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} decimalScale={1}
type="text" value={Number(handleTotalYTD(tableMeta)).toFixed(1)}
placeholder=""
disabled={true}
value={Number(value).toFixed(1)}
decimalScale={1}
/>
}
/> />
</div> </span>
} }
</div> </div>
) )
...@@ -1692,23 +1689,17 @@ export default class ProfitLossOLPA extends Component { ...@@ -1692,23 +1689,17 @@ export default class ProfitLossOLPA extends Component {
value={Number(value).toFixed(1)} value={Number(value).toFixed(1)}
/> />
: :
<div style={{ flex: 1 }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<FormControlLabel <NumberFormat
style={{ margin: 0 }} thousandSeparator={true}
value={value} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
control={ type="text"
<NumberFormat placeholder=""
thousandSeparator={true} disabled={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} decimalScale={1}
type="text" value={Number(handleTotal(tableMeta)).toFixed(1)}
placeholder=""
disabled={true}
value={Number(value).toFixed(1)}
decimalScale={1}
/>
}
/> />
</div> </span>
} }
</div> </div>
) )
...@@ -1857,7 +1848,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -1857,7 +1848,7 @@ export default class ProfitLossOLPA extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
</div> </div>
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1" style={{ paddingLeft: 0 }}> <div className="col-1">
<button <button
type="button" type="button"
onClick={() => this.setState({ loading: true }, () => { onClick={() => this.setState({ loading: true }, () => {
......
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