Commit dc52ad61 authored by Riri Novita's avatar Riri Novita

apdet

parent 189ed559
......@@ -241,11 +241,13 @@ const create = (type = "") => {
const getReportPLDetailMB = (body) => api.post('/transaction/db_profit_loss_detail/master_budget/get_report_hierarki', body)
const getReportPLDetailMR = (body) => api.post('/transaction/db_profit_loss_detail/monthly_report/get_report_hierarki', body)
const getReportPL = (body) => api.post('/transaction/db_profit_loss/get_report_hierarki', body)
const getReportFR = (body) => api.post('/transaction/db_ratio/get_report_hierarki', body)
const getHierarkiCreateReportPLMB = (body) => api.post('/transaction/db_profit_loss/master_budget/get_report_hierarki', body)
const getHierarkiCreateReportPLMR = (body) => api.post('/transaction/db_profit_loss/monthly_report/get_report_hierarki', body)
const createReportPLMB = (body) => api.post('/transaction/db_profit_loss/master_budget/create_submission_report', body)
const createReportPLMR = (body) => api.post('/transaction/db_profit_loss/monthly_report/create_monthly_report', body)
const getPLID = (body) => api.post('/transaction/db_profit_loss/get_profit_loss_id', body)
const getFRID = (body) => api.post('/transaction/db_ratio/get_ratio_id', body)
// const getReportPLMB = (body) => api.post('/transaction/db_profit_loss/get_report_hierarki', body)
// const getReportPLMB = (body) => api.post('/transaction/db_profit_loss/get_report_hierarki', body)
const getReportPLMR = (body) => api.post('/transaction/db_profit_loss/monthly_report/get_report_hierarki', body)
......@@ -634,11 +636,13 @@ const create = (type = "") => {
getReportBSSuma,
getDashboardCAT,
getReportPL,
getReportFR,
getHierarkiCreateReportPLMB,
getHierarkiCreateReportPLMR,
createReportPLMB,
createReportPLMR,
getPLID,
getFRID,
getHierarkiReportHistorical,
getHierarkiReportMTD,
getHierarkiReportYtd
......
......@@ -626,11 +626,12 @@ export default class SubHolding extends Component {
"periode": this.state.periode.periode,
"company_id": this.state.company.company_id
}
console.log(payloadID);
// console.log(payloadID);
api.create().getPLID(payloadID).then(response => {
console.log(response);
if (response) {
PLID = response.data.data == null ? null : response.data.data.profit_loss_id
// PLID = response.data.data.profit_loss_id
} else {
PLID = null
}
......@@ -814,130 +815,165 @@ export default class SubHolding extends Component {
})
})
} else if (this.state.report.value === 4) {
api.create().getReportHierarkiFRMB(payload).then(response => {
// console.log(payload);
let FRID = null
let payloadFRID = {
"periode": this.state.periode.periode,
"company_id": this.state.company.company_id
}
api.create().getFRID(payloadFRID).then(response => {
console.log(response);
let dataTable = []
if (response.data) {
if (response.data.status === 'success') {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.uom,
item.ratio.total_actual_before === null ? "0.0" : item.ratio.total_actual_before === "" ? "0.0" : item.ratio.total_actual_before,
Number(item.ratio.january).toFixed(1),
Number(item.ratio.february).toFixed(1),
Number(item.ratio.march).toFixed(1),
Number(item.ratio.april).toFixed(1),
Number(item.ratio.may).toFixed(1),
Number(item.ratio.june).toFixed(1),
Number(item.ratio.july).toFixed(1),
Number(item.ratio.august).toFixed(1),
Number(item.ratio.september).toFixed(1),
Number(item.ratio.october).toFixed(1),
Number(item.ratio.november).toFixed(1),
Number(item.ratio.december).toFixed(1),
Number(item.ratio.total_next_year).toFixed(1),
Number(item.ratio.total_more_year).toFixed(1),
// 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),
// item.order,
// item.condition_it_should_be,
// item.condition_if_wrong,
])
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
if (response) {
FRID = response.data.data == null ? null : response.data.data.ratio_id
} else {
FRID = null
}
this.setState({ FRID }, () => {
let payloads = {...payload, submission_id: this.state.FRID, months: this.state.month.month_id, quarter: 0}
api.create().getReportFR(payloads).then(response => {
console.log(payload);
console.log(response);
let dataTable = []
if (response.data) {
if (response.data.status === 'success') {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.uom,
item.ratio.total_actual_before === null ? "0.0" : item.ratio.total_actual_before === "" ? "0.0" : item.ratio.total_actual_before,
Number(item.ratio.january).toFixed(1),
Number(item.ratio.february).toFixed(1),
Number(item.ratio.march).toFixed(1),
Number(item.ratio.april).toFixed(1),
Number(item.ratio.may).toFixed(1),
Number(item.ratio.june).toFixed(1),
Number(item.ratio.july).toFixed(1),
Number(item.ratio.august).toFixed(1),
Number(item.ratio.september).toFixed(1),
Number(item.ratio.october).toFixed(1),
Number(item.ratio.november).toFixed(1),
Number(item.ratio.december).toFixed(1),
Number(item.ratio.total_next_year).toFixed(1),
Number(item.ratio.total_more_year).toFixed(1),
item.ratio.monthly_january,
item.ratio.monthly_february,
item.ratio.monthly_march,
item.ratio.monthly_april,
item.ratio.monthly_may,
item.ratio.monthly_june,
item.ratio.monthly_july,
item.ratio.monthly_august,
item.ratio.monthly_september,
item.ratio.monthly_october,
item.ratio.monthly_november,
item.ratio.monthly_december,
item.ratio.monthly_january_last_year,
item.ratio.monthly_february_last_year,
item.ratio.monthly_march_last_year,
item.ratio.monthly_april_last_year,
item.ratio.monthly_may_last_year,
item.ratio.monthly_june_last_year,
item.ratio.monthly_july_last_year,
item.ratio.monthly_august_last_year,
item.ratio.monthly_september_last_year,
item.ratio.monthly_october_last_year,
item.ratio.monthly_november_last_year,
item.ratio.monthly_december_last_year,
])
}
}
}
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.oum,
item.ratio.total_actual_before === null ? "0.0" : item.ratio.total_actual_before === "" ? "0.0" : item.ratio.total_actual_before,
Number(item.ratio.january).toFixed(1),
Number(item.ratio.february).toFixed(1),
Number(item.ratio.march).toFixed(1),
Number(item.ratio.april).toFixed(1),
Number(item.ratio.may).toFixed(1),
Number(item.ratio.june).toFixed(1),
Number(item.ratio.july).toFixed(1),
Number(item.ratio.august).toFixed(1),
Number(item.ratio.september).toFixed(1),
Number(item.ratio.october).toFixed(1),
Number(item.ratio.november).toFixed(1),
Number(item.ratio.december).toFixed(1),
Number(item.ratio.total_next_year).toFixed(1),
Number(item.ratio.total_more_year).toFixed(1),
// 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),
// item.order,
// item.condition_it_should_be,
// item.condition_if_wrong
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.oum,
item.ratio.total_actual_before === null ? "0.0" : item.ratio.total_actual_before === "" ? "0.0" : item.ratio.total_actual_before,
Number(item.ratio.january).toFixed(1),
Number(item.ratio.february).toFixed(1),
Number(item.ratio.march).toFixed(1),
Number(item.ratio.april).toFixed(1),
Number(item.ratio.may).toFixed(1),
Number(item.ratio.june).toFixed(1),
Number(item.ratio.july).toFixed(1),
Number(item.ratio.august).toFixed(1),
Number(item.ratio.september).toFixed(1),
Number(item.ratio.october).toFixed(1),
Number(item.ratio.november).toFixed(1),
Number(item.ratio.december).toFixed(1),
Number(item.ratio.total_next_year).toFixed(1),
Number(item.ratio.total_more_year).toFixed(1),
item.ratio.monthly_january,
item.ratio.monthly_february,
item.ratio.monthly_march,
item.ratio.monthly_april,
item.ratio.monthly_may,
item.ratio.monthly_june,
item.ratio.monthly_july,
item.ratio.monthly_august,
item.ratio.monthly_september,
item.ratio.monthly_october,
item.ratio.monthly_november,
item.ratio.monthly_december,
item.ratio.monthly_january_last_year,
item.ratio.monthly_february_last_year,
item.ratio.monthly_march_last_year,
item.ratio.monthly_april_last_year,
item.ratio.monthly_may_last_year,
item.ratio.monthly_june_last_year,
item.ratio.monthly_july_last_year,
item.ratio.monthly_august_last_year,
item.ratio.monthly_september_last_year,
item.ratio.monthly_october_last_year,
item.ratio.monthly_november_last_year,
item.ratio.monthly_december_last_year,
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
this.setState({ dataTable, previewTable: true, loading: false, previewDownload: true })
console.log(this.state.dataTable)
// this.setState({ dataTable }, () => {
// console.log(this.state.dataTable)
// this.getRatioMR(payload)
// })
} 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);
}
})
}
})
this.setState({ dataTable }, () => {
console.log(this.state.dataTable)
this.getRatioMR(payload)
})
} 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 })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
})
})
} else if (this.state.report.value === 5) {
api.create().getReportTP(payload).then(response => {
......@@ -2766,10 +2802,10 @@ export default class SubHolding extends Component {
a.click();
}
} else if (this.state.report.value === 4) {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/db_ratio/export_report?submission_id=${this.state.submissionID === null ? "" : this.state.submissionID}&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.revisionType}`
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/db_ratio/export_report?submission_id=${this.state.FRID === null ? "" : this.state.FRID}&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.revisionType}`
console.log(url);
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/db_ratio/export_report?submission_id=${this.state.submissionID === null ? "" : this.state.submissionID}&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.revisionType}`
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/db_ratio/export_report?submission_id=${this.state.FRID === null ? "" : this.state.FRID}&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.revisionType}`
)
res = await res.blob()
this.setState({ loading: false })
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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