Commit 46ef9b54 authored by faisalhamdi's avatar faisalhamdi

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into faisal

parents 1bed2201 ac1c2f8d
......@@ -310,11 +310,11 @@ export default class OutlookPA extends Component {
let data = []
response.data.data.map((item) => {
if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 10)) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
data.push(item)
}
} else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
if ((item >= 2000) && (item == Number(this.state.lastPeriod) + 1 || item < Number(this.state.lastPeriod) + 1)) {
data.push(item)
}
}
......@@ -328,11 +328,11 @@ export default class OutlookPA extends Component {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 10) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : Number(this.state.lastPeriod) + 1)
let index = data.sort((a, b) => a - b).findIndex((val) => val == periode)
// console.log(data)
// console.log(this.state.lastPeriod)
// console.log(periodeData)
// console.log(periode)
// console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
if (this.state.isApprover === true) {
......
......@@ -188,9 +188,9 @@ export default class ProfitLossOLPA extends Component {
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_october,
item.profit_loss.nov_dec,
Number(item.profit_loss.total_current_year).toFixed(1),
Number(item.profit_loss.ytd_october).toFixed(1),
Number(item.profit_loss.nov_dec).toFixed(1),
item.order
])
}
......@@ -224,9 +224,9 @@ export default class ProfitLossOLPA extends Component {
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_october,
item.profit_loss.nov_dec,
Number(item.profit_loss.total_current_year).toFixed(1),
Number(item.profit_loss.ytd_october).toFixed(1),
Number(item.profit_loss.nov_dec).toFixed(1),
item.order
])
if (item.children !== null) {
......@@ -564,6 +564,36 @@ export default class ProfitLossOLPA extends Component {
// console.log(total);
}
const handleTotalFY = (tableMeta) => {
let total = 0
dataTable2[tableMeta.rowIndex].map((item, index) => {
if (index >= 8 && index <= 19) {
let valItem = item == undefined || item == "" ? 0 : item
total += Number(valItem)
}
})
if (tableMeta.rowData[1] === 19865) {
console.log(total);
console.log(dataTable2[tableMeta.rowIndex]);
}
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][20]) / Number(dataTable2[tableMeta.rowIndex - 1][20])
dataTable2[tableMeta.rowIndex][20] = R.equals(value, NaN) ? "0.0" : (R.equals(value, Infinity) ? "0.0" : (value == "-Infinity" ? "0.0" : value))
return R.equals(value, NaN) ? "0.0" : (R.equals(value, Infinity) ? "0.0" : (value == "-Infinity" ? "0.0" : value))
} else if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "total man power") {
let totalTMP = dataTable2[tableMeta.rowIndex][20] = dataTable2[tableMeta.rowIndex][19]
return totalTMP
} else if (indexParent !== -1 && String(dataTable2[indexParent][5]).toLocaleUpperCase() == "GROSS PROFIT MARGIN (% OF REVENUE)") {
return handleFormula(0, tableMeta, 0)
}
else {
dataTable2[tableMeta.rowIndex][20] = total
return total
}
}
const handleTotal = (tableMeta) => {
let total = Number(dataTable2[tableMeta.rowIndex][18]) + Number(dataTable2[tableMeta.rowIndex][19])
dataTable2[tableMeta.rowIndex][22] = total
......@@ -1498,26 +1528,6 @@ export default class ProfitLossOLPA extends Component {
value={Number(handleValue(value, tableMeta)).toFixed(1)}
/>
</span>
// <div style={{ flex: 1 }}>
// <FormControlLabel
// style={{ margin: 0 }}
// value={value}
// control={
// <NumberFormat
// thousandSeparator={true}
// style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// 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) => {
// handleChange(event.target.value, tableMeta)
// // console.log(dataTable2)
// }}
// />
// }
// />
// </div>
:
tableMeta.rowData[0] === 6 ?
<NumberFormat
......@@ -1528,26 +1538,6 @@ export default class ProfitLossOLPA extends Component {
disabled={true}
value={Number(handleFormula(value, tableMeta, 12)).toFixed(1)}
/>
// <div style={{ flex: 1 }}>
// <FormControlLabel
// style={{ margin: 0 }}
// value={value}
// control={
// <NumberFormat
// thousandSeparator={true}
// style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// 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) => {
// handleChange(event.target.value, tableMeta)
// // console.log(dataTable2)
// }}
// />
// }
// />
// </div>
:
tableMeta.rowData[0] === 5 ?
<NumberFormat
......@@ -1558,26 +1548,6 @@ export default class ProfitLossOLPA extends Component {
disabled={true}
value={Number(handleFormula(value, tableMeta, 12)).toFixed(1)}
/>
// <div style={{ flex: 1 }}>
// <FormControlLabel
// style={{ margin: 0 }}
// value={value}
// control={
// <NumberFormat
// thousandSeparator={true}
// style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// 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) => {
// handleChange(event.target.value, tableMeta)
// // console.log(dataTable2)
// }}
// />
// }
// />
// </div>
:
null
}
......@@ -1609,23 +1579,17 @@ export default class ProfitLossOLPA extends Component {
value={Number(value).toFixed(1)}
/>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<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(value).toFixed(1)}
decimalScale={1}
value={Number(handleTotalFY(tableMeta)).toFixed(1)}
/>
}
/>
</div>
</span>
}
</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