Commit 929fde5a authored by rifkaki's avatar rifkaki

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

parents a33da690 5d3c5a08
......@@ -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 = {
......@@ -325,7 +327,7 @@ export default class ProfitLossOLPA extends Component {
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
// console.log(resp)
console.log(resp)
if (err) {
console.log(err);
}
......@@ -353,7 +355,9 @@ export default class ProfitLossOLPA extends Component {
october: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
november: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
december: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
total_current_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim()
total_current_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
ytd_october: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim(),
nov_dec: i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim()
})
}
})
......@@ -399,13 +403,15 @@ export default class ProfitLossOLPA extends Component {
item.november,
item.december,
item.total_current_year,
item.ytd_october,
item.nov_dec,
item.orders,
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.state.dataTable.map(item => {
if (item[21].length > 0) {
if (item[23].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
......@@ -436,7 +442,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 body = {
......@@ -535,33 +543,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 +1331,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 +1476,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 +1655,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 +1695,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>
)
......@@ -1729,6 +1726,16 @@ export default class ProfitLossOLPA extends Component {
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}
]
......@@ -1857,7 +1864,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