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

olpa pl

parent 55cea835
......@@ -571,7 +571,7 @@ export default class OutlookPA extends Component {
this.setState({ loading: true })
// console.log(JSON.stringify(data));
api.create('UPLOAD').createReportOLPA(data).then(response => {
// console.log(response);
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.getOutlookPAID()
......
......@@ -176,21 +176,21 @@ export default class ProfitLossOLPA extends Component {
item.description,
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.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
Number(item.profit_loss.january).toFixed(1),
Number(item.profit_loss.february).toFixed(1),
Number(item.profit_loss.march).toFixed(1),
Number(item.profit_loss.april).toFixed(1),
Number(item.profit_loss.may).toFixed(1),
Number(item.profit_loss.june).toFixed(1),
Number(item.profit_loss.july).toFixed(1),
Number(item.profit_loss.august).toFixed(1),
Number(item.profit_loss.september).toFixed(1),
Number(item.profit_loss.october).toFixed(1),
Number(item.profit_loss.november).toFixed(1),
Number(item.profit_loss.december).toFixed(1),
item.profit_loss.total_current_year,
item.profit_loss.ytd_oct === undefined ? "0.0" : item.profit_loss.ytd_oct,
item.profit_loss.nov_dec === undefined ? "0.0" : item.profit_loss.nov_dec,
item.profit_loss.ytd_october,
item.profit_loss.nov_dec,
item.order
])
}
......@@ -212,21 +212,21 @@ export default class ProfitLossOLPA extends Component {
item.description,
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.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
Number(item.profit_loss.january).toFixed(1),
Number(item.profit_loss.february).toFixed(1),
Number(item.profit_loss.march).toFixed(1),
Number(item.profit_loss.april).toFixed(1),
Number(item.profit_loss.may).toFixed(1),
Number(item.profit_loss.june).toFixed(1),
Number(item.profit_loss.july).toFixed(1),
Number(item.profit_loss.august).toFixed(1),
Number(item.profit_loss.september).toFixed(1),
Number(item.profit_loss.october).toFixed(1),
Number(item.profit_loss.november).toFixed(1),
Number(item.profit_loss.december).toFixed(1),
item.profit_loss.total_current_year,
item.profit_loss.ytd_oct === undefined ? "0.0" : item.profit_loss.ytd_oct,
item.profit_loss.nov_dec === undefined ? "0.0" : item.profit_loss.nov_dec,
item.profit_loss.ytd_october,
item.profit_loss.nov_dec,
item.order
])
if (item.children !== null) {
......@@ -290,7 +290,9 @@ export default class ProfitLossOLPA extends Component {
october: String(Number(i[17]).toFixed(1)),
november: String(Number(i[18]).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 = {
......@@ -535,33 +537,32 @@ export default class ProfitLossOLPA extends Component {
let val = String(value).split(",").join("")
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
dataTable2[tableMeta.rowIndex].map((item, index) => {
if (index >= 7 && index <= 18) {
if (index >= 8 && index <= 17) {
let valItem = item == undefined || item == "" ? 0 : item
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
return total
}
dataTable2[tableMeta.rowIndex][21] = total
return total
// console.log(total);
}
const handleNotes = (value, tableMeta) => {
// console.log(value)
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
// console.log(dataTable2[tableMeta.rowIndex]);
const handleTotal = (tableMeta) => {
let total = Number(dataTable2[tableMeta.rowIndex][18]) + Number(dataTable2[tableMeta.rowIndex][19])
dataTable2[tableMeta.rowIndex][22] = total
return total
// console.log(total);
}
const handleValue = (value, data) => {
......@@ -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' }}
type="text"
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)}
value={Number(value).toFixed(1)}
onBlur={(event) => {
......@@ -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' }}
type="text"
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)}
value={Number(value).toFixed(1)}
onBlur={(event) => {
......@@ -1646,23 +1649,17 @@ export default class ProfitLossOLPA extends Component {
value={Number(value).toFixed(1)}
/>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(value).toFixed(1)}
decimalScale={1}
/>
}
<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}
decimalScale={1}
value={Number(handleTotalYTD(tableMeta)).toFixed(1)}
/>
</div>
</span>
}
</div>
)
......@@ -1692,23 +1689,17 @@ export default class ProfitLossOLPA extends Component {
value={Number(value).toFixed(1)}
/>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(value).toFixed(1)}
decimalScale={1}
/>
}
<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}
decimalScale={1}
value={Number(handleTotal(tableMeta)).toFixed(1)}
/>
</div>
</span>
}
</div>
)
......@@ -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>
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1" style={{ paddingLeft: 0 }}>
<div className="col-1">
<button
type="button"
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