Commit 75598a6b authored by rifkaki's avatar rifkaki

actual last year ratio

parent 55c2f260
......@@ -632,6 +632,13 @@ export default class SubHolding extends Component {
}
getRatioMR(payload) {
let payloadLast = {
"report_id": this.state.report.value,
"revision": this.state.revisionType,
"periode": Number(this.state.periode.periode) - 1,
"company_id": this.state.company.company_id,
"submission_id": this.state.submissionID
}
api.create().getReportHierarkiFRMR(payload).then(response => {
// console.log(payload);
console.log(response);
......@@ -698,7 +705,95 @@ export default class SubHolding extends Component {
})
console.log(dataTable2)
this.setState({ dataTable: dataTable2, previewTable: true, loading: false, previewDownload: true })
// this.setState({ dataTable: dataTable2, previewTable: true, loading: false, previewDownload: true })
this.setState({ dataTable2 }, () => {
console.log(this.state.dataTable2)
this.getRatioLastMR(payloadLast)
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
getRatioLastMR(payloadLast) {
api.create().getReportHierarkiFRMR(payloadLast).then(response => {
console.log(payloadLast);
console.log(response);
let dataTable2 = this.state.dataTable2
let dataTable3 = []
if (response.data) {
if (response.data.status === 'success') {
let res = response.data.data
res.map((item,index) => {
let indexID = dataTable2.findIndex((val) => val[1] == item.id)
if (indexID != -1) {
const handlePushChild = (items) => {
let indexIDzz = dataTable2.findIndex((val) => val[1] === items.id)
// console.log(indexIDzz)
if (indexIDzz != -1) {
dataTable3.push([...dataTable2[indexIDzz],
Number(items.ratio.monthly_january).toFixed(2),
Number(items.ratio.monthly_february).toFixed(2),
Number(items.ratio.monthly_march).toFixed(2),
Number(items.ratio.monthly_april).toFixed(2),
Number(items.ratio.monthly_may).toFixed(2),
Number(items.ratio.monthly_june).toFixed(2),
Number(items.ratio.monthly_july).toFixed(2),
Number(items.ratio.monthly_august).toFixed(2),
Number(items.ratio.monthly_september).toFixed(2),
Number(items.ratio.monthly_october).toFixed(2),
Number(items.ratio.monthly_november).toFixed(2),
Number(items.ratio.monthly_december).toFixed(2),
])
}
if (items.children !== null) {
if (items.children.length > 0) {
items.children.map((itemss, indexss) => {
handlePushChild(itemss)
})
}
}
}
dataTable3.push([...dataTable2[indexID],
Number(item.ratio.monthly_january).toFixed(2),
Number(item.ratio.monthly_february).toFixed(2),
Number(item.ratio.monthly_march).toFixed(2),
Number(item.ratio.monthly_april).toFixed(2),
Number(item.ratio.monthly_may).toFixed(2),
Number(item.ratio.monthly_june).toFixed(2),
Number(item.ratio.monthly_july).toFixed(2),
Number(item.ratio.monthly_august).toFixed(2),
Number(item.ratio.monthly_september).toFixed(2),
Number(item.ratio.monthly_october).toFixed(2),
Number(item.ratio.monthly_november).toFixed(2),
Number(item.ratio.monthly_december).toFixed(2),
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
})
console.log(dataTable3)
this.setState({ dataTable: dataTable3, previewTable: true, loading: false, previewDownload: true })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
......
This diff is collapsed.
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