Commit fc56110e authored by Faisal Hamdi's avatar Faisal Hamdi

Merge branch 'faisal' into 'master'

Faisal!

See merge request !1411
parents c4ca098d 8667e757
......@@ -333,6 +333,7 @@ const create = (type = "") => {
const getFullApproveMonthly = (body) => api.post('/transaction/monthly_report/get_approved_submit', body)
const getDashboardFinancial = (body) => api.post('/transaction/dashboard/get_dashboard_financial', body)
const getReportCATPA = (body) => api.post('/transaction/cat/performance_appraisal', body)
const getReportCATPQ = (body) => api.post('/transaction/cat/quarterly/get_report_hierarki', body)
//CASH FLOW
const getDetailReportCF = (body) => api.post('/transaction/cash_flow/master_budget/get_report_hierarki', body)
......@@ -740,6 +741,7 @@ const create = (type = "") => {
getFullApproveMonthly,
getDashboardFinancial,
getReportCATPA,
getReportCATPQ,
getHierarkiCronJobMBPL,
getHierarkiCronJobMBCF,
getHierarkiCronJobMBRatio,
......
......@@ -2245,7 +2245,7 @@ export default class SubHolding extends Component {
} else if (this.state.report.value === 8) {
let dbSumaPL = []
let payloadPL = {...payload, report_id: 28, months: this.state.month.month_id, quarter: 0}
let payloadPL = {...payload, report_id: 28, months: this.state.month.month_id}
api.create().getReportPLSummary(payloadPL).then(response => {
console.log(response);
if (response.data) {
......@@ -2255,6 +2255,7 @@ export default class SubHolding extends Component {
const handlePushChild = (item) => {
let indexIDzz = dbSumaPL.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
let month = this.state.month.month_value;
let mtd_actual = item.profit_loss.mtd_actual == ''? 0 : Number(item.profit_loss.mtd_actual)
let mtd_mb = item.profit_loss.mtd_mb == ''? 0 : Number(item.profit_loss.mtd_mb)
let mtd_last_year = item.profit_loss.mtd_last_year == ''? 0 : Number(item.profit_loss.mtd_last_year)
......@@ -2310,31 +2311,34 @@ export default class SubHolding extends Component {
persenYtdLY = ytd_actual / ytd_last_year
}
let q1_actual = item.profit_loss.q1_actual == ''? 0 : Number(item.profit_loss.q1_actual)
let q1_mb = item.profit_loss.q1_mb == ''? 0 : Number(item.profit_loss.q1_mb)
let q1_last_year = item.profit_loss.q1_last_year == ''? 0 : Number(item.profit_loss.q1_last_year)
// let q1_actual = item.profit_loss.q1_actual == ''? 0 : Number(item.profit_loss.q1_actual)
let q_actual = month == "Mar" ? item.profit_loss.q1_actual == ''? 0 : Number(item.profit_loss.q1_actual) : month == "Jun" ? item.profit_loss.q2_actual == ''? 0 : Number(item.profit_loss.q2_actual) : month == "Sep" ? item.profit_loss.q3_actual == ''? 0 : Number(item.profit_loss.q3_actual) : 0
// let q1_mb = item.profit_loss.q1_mb == ''? 0 : Number(item.profit_loss.q1_mb)
let q_mb = month == "Mar" ? item.profit_loss.q1_mb == ''? 0 : Number(item.profit_loss.q1_mb) : month == "Jun" ? item.profit_loss.q2_mb == ''? 0 : Number(item.profit_loss.q2_mb) : month == "Sep" ? item.profit_loss.q3_mb == ''? 0 : Number(item.profit_loss.q3_mb) : 0
// let q1_last_year = item.profit_loss.q1_last_year == ''? 0 : Number(item.profit_loss.q1_last_year)
let q_last_year = month == "Mar" ? item.profit_loss.q1_last_year == ''? 0 : Number(item.profit_loss.q1_last_year) : month == "Jun" ? item.profit_loss.q2_last_year == ''? 0 : Number(item.profit_loss.q2_last_year) : month == "Sep" ? item.profit_loss.q3_last_year == ''? 0 : Number(item.profit_loss.q3_last_year) : 0
let persenQuarterMB = 0
if (q1_mb < 0) {
if (q1_actual >= q1_mb) {
persenQuarterMB = (q1_mb - q1_actual) / q1_mb + 1
if (q_mb < 0) {
if (q_actual >= q_mb) {
persenQuarterMB = (q_mb - q_actual) / q_mb + 1
} else {
persenQuarterMB = (q1_mb - q1_actual) / q1_mb
persenQuarterMB = (q_mb - q_actual) / q_mb
}
}
else {
persenQuarterMB = q1_actual / q1_mb
persenQuarterMB = q_actual / q_mb
}
let persenQuarterLY = 0
if (q1_last_year < 0) {
if (q1_actual >= q1_last_year) {
persenQuarterLY = (q1_last_year - q1_actual) / q1_last_year + 1
if (q_last_year < 0) {
if (q_actual >= q_last_year) {
persenQuarterLY = (q_last_year - q_actual) / q_last_year + 1
} else {
persenQuarterLY = (q1_last_year - q1_actual) / q1_last_year
persenQuarterLY = (q_last_year - q_actual) / q_last_year
}
}
else {
persenQuarterLY = q1_actual / q1_last_year
persenQuarterLY = q_actual / q_last_year
}
let fy_actual = item.profit_loss.fy_actual == ''? 0 : Number(item.profit_loss.fy_actual)
......@@ -2406,11 +2410,13 @@ export default class SubHolding extends Component {
isNaN(persenYtdMB) || persenYtdMB == 'Infinity' || persenYtdMB == '-Infinity'? (item.profit_loss.ytd_mb == '' || item.profit_loss.ytd_mb == 0? -0 : 0) : (item.profit_loss.ytd_mb == '' || item.profit_loss.ytd_mb == 0? persenYtdMB * -100 : persenYtdMB * 100),
item.profit_loss.ytd_last_year,
isNaN(persenYtdLY) || persenYtdLY == 'Infinity' || persenYtdLY == '-Infinity'? (item.profit_loss.ytd_last_year == '' || item.profit_loss.ytd_last_year == 0? -0 : 0) : (item.profit_loss.ytd_last_year == '' || item.profit_loss.ytd_last_year == 0? persenYtdLY * -100 : persenYtdLY * 100),
item.profit_loss.q1_actual,
item.profit_loss.q1_mb,
isNaN(persenQuarterMB) || persenQuarterMB == 'Infinity' || persenQuarterMB == '-Infinity'? (item.profit_loss.q1_mb == '' || item.profit_loss.q1_mb == 0? -0 : 0) : (item.profit_loss.q1_mb == '' || item.profit_loss.q1_mb == 0? persenQuarterMB * -100 : persenQuarterMB * 100),
item.profit_loss.q1_last_year,
isNaN(persenQuarterLY) || persenQuarterLY == 'Infinity' || persenQuarterLY == '-Infinity'? (item.profit_loss.q1_last_year == '' || item.profit_loss.q1_last_year == 0? -0 : 0) : (item.profit_loss.q1_last_year == '' || item.profit_loss.q1_last_year == 0? persenQuarterLY * -100 : persenQuarterLY * 100),
month == "Mar" ? item.profit_loss.q1_actual : month = "Jun" ? item.profit_loss.q2_actual : month = "Sep" ? item.profit_loss.q3_actual : 0,
month == "Mar" ? item.profit_loss.q1_mb : month = "Jun" ? item.profit_loss.q2_mb : month = "Sep" ? item.profit_loss.q3_mb : 0,
isNaN(persenQuarterMB) || persenQuarterMB == 'Infinity' || persenQuarterMB == '-Infinity'? (q_mb == '' || q_mb == 0? -0 : 0) : (q_mb == '' || q_mb == 0? persenQuarterMB * -100 : persenQuarterMB * 100),
// isNaN(persenQuarterMB) || persenQuarterMB == 'Infinity' || persenQuarterMB == '-Infinity'? (item.profit_loss.q1_mb == '' || item.profit_loss.q1_mb == 0? -0 : 0) : (item.profit_loss.q1_mb == '' || item.profit_loss.q1_mb == 0? persenQuarterMB * -100 : persenQuarterMB * 100),
month == "Mar" ? item.profit_loss.q1_last_year : month = "Jun" ? item.profit_loss.q2_last_year : month = "Sep" ? item.profit_loss.q3_last_year : 0,
isNaN(persenQuarterLY) || persenQuarterLY == 'Infinity' || persenQuarterLY == '-Infinity'? (q_last_year == '' || q_last_year == 0? -0 : 0) : (q_last_year == '' || q_last_year == 0? persenQuarterLY * -100 : persenQuarterLY * 100),
// isNaN(persenQuarterLY) || persenQuarterLY == 'Infinity' || persenQuarterLY == '-Infinity'? (item.profit_loss.q1_last_year == '' || item.profit_loss.q1_last_year == 0? -0 : 0) : (item.profit_loss.q1_last_year == '' || item.profit_loss.q1_last_year == 0? persenQuarterLY * -100 : persenQuarterLY * 100),
item.profit_loss.fy_actual,
item.profit_loss.fy_mb,
isNaN(persenFyMB) || persenFyMB == 'Infinity' || persenFyMB == '-Infinity'? (item.profit_loss.fy_mb == '' || item.profit_loss.fy_mb == 0? -0 : 0) : (item.profit_loss.fy_mb == '' || item.profit_loss.fy_mb == 0? persenFyMB * -100 : persenFyMB * 100),
......@@ -2433,6 +2439,7 @@ export default class SubHolding extends Component {
}
}
res.map((item,index) => {
let month = this.state.month.month_value;
let mtd_actual = item.profit_loss.mtd_actual == ''? 0 : Number(item.profit_loss.mtd_actual)
let mtd_mb = item.profit_loss.mtd_mb == ''? 0 : Number(item.profit_loss.mtd_mb)
let mtd_last_year = item.profit_loss.mtd_last_year == ''? 0 : Number(item.profit_loss.mtd_last_year)
......@@ -2488,31 +2495,58 @@ export default class SubHolding extends Component {
persenYtdLY = ytd_actual / ytd_last_year
}
let q1_actual = item.profit_loss.q1_actual == ''? 0 : Number(item.profit_loss.q1_actual)
let q1_mb = item.profit_loss.q1_mb == ''? 0 : Number(item.profit_loss.q1_mb)
let q1_last_year = item.profit_loss.q1_last_year == ''? 0 : Number(item.profit_loss.q1_last_year)
// let q1_actual = item.profit_loss.q1_actual == ''? 0 : Number(item.profit_loss.q1_actual)
// let q1_mb = item.profit_loss.q1_mb == ''? 0 : Number(item.profit_loss.q1_mb)
// let q1_last_year = item.profit_loss.q1_last_year == ''? 0 : Number(item.profit_loss.q1_last_year)
// let persenQuarterMB = 0
// if (q1_mb < 0) {
// if (q1_actual >= q1_mb) {
// persenQuarterMB = (q1_mb - q1_actual) / q1_mb + 1
// } else {
// persenQuarterMB = (q1_mb - q1_actual) / q1_mb
// }
// }
// else {
// persenQuarterMB = q1_actual / q1_mb
// }
// let persenQuarterLY = 0
// if (q1_last_year < 0) {
// if (q1_actual >= q1_last_year) {
// persenQuarterLY = (q1_last_year - q1_actual) / q1_last_year + 1
// } else {
// persenQuarterLY = (q1_last_year - q1_actual) / q1_last_year
// }
// }
// else {
// persenQuarterLY = q1_actual / q1_last_year
// }
let q_actual = month == "Mar" ? item.profit_loss.q1_actual == ''? 0 : Number(item.profit_loss.q1_actual) : month == "Jun" ? item.profit_loss.q2_actual == ''? 0 : Number(item.profit_loss.q2_actual) : month == "Sep" ? item.profit_loss.q3_actual == ''? 0 : Number(item.profit_loss.q3_actual) : 0
let q_mb = month == "Mar" ? item.profit_loss.q1_mb == ''? 0 : Number(item.profit_loss.q1_mb) : month == "Jun" ? item.profit_loss.q2_mb == ''? 0 : Number(item.profit_loss.q2_mb) : month == "Sep" ? item.profit_loss.q3_mb == ''? 0 : Number(item.profit_loss.q3_mb) : 0
let q_last_year = month == "Mar" ? item.profit_loss.q1_last_year == ''? 0 : Number(item.profit_loss.q1_last_year) : month == "Jun" ? item.profit_loss.q2_last_year == ''? 0 : Number(item.profit_loss.q2_last_year) : month == "Sep" ? item.profit_loss.q3_last_year == ''? 0 : Number(item.profit_loss.q3_last_year) : 0
let persenQuarterMB = 0
if (q1_mb < 0) {
if (q1_actual >= q1_mb) {
persenQuarterMB = (q1_mb - q1_actual) / q1_mb + 1
if (q_mb < 0) {
if (q_actual >= q_mb) {
persenQuarterMB = (q_mb - q_actual) / q_mb + 1
} else {
persenQuarterMB = (q1_mb - q1_actual) / q1_mb
persenQuarterMB = (q_mb - q_actual) / q_mb
}
}
else {
persenQuarterMB = q1_actual / q1_mb
persenQuarterMB = q_actual / q_mb
}
let persenQuarterLY = 0
if (q1_last_year < 0) {
if (q1_actual >= q1_last_year) {
persenQuarterLY = (q1_last_year - q1_actual) / q1_last_year + 1
if (q_last_year < 0) {
if (q_actual >= q_last_year) {
persenQuarterLY = (q_last_year - q_actual) / q_last_year + 1
} else {
persenQuarterLY = (q1_last_year - q1_actual) / q1_last_year
persenQuarterLY = (q_last_year - q_actual) / q_last_year
}
}
else {
persenQuarterLY = q1_actual / q1_last_year
persenQuarterLY = q_actual / q_last_year
}
let fy_actual = item.profit_loss.fy_actual == ''? 0 : Number(item.profit_loss.fy_actual)
......@@ -2584,11 +2618,11 @@ export default class SubHolding extends Component {
isNaN(persenYtdMB) || persenYtdMB == 'Infinity' || persenYtdMB == '-Infinity'? (item.profit_loss.ytd_mb == '' || item.profit_loss.ytd_mb == 0? -0 : 0) : (item.profit_loss.ytd_mb == '' || item.profit_loss.ytd_mb == 0? persenYtdMB * -100 : persenYtdMB * 100),
item.profit_loss.ytd_last_year,
isNaN(persenYtdLY) || persenYtdLY == 'Infinity' || persenYtdLY == '-Infinity'? (item.profit_loss.ytd_last_year == '' || item.profit_loss.ytd_last_year == 0? -0 : 0) : (item.profit_loss.ytd_last_year == '' || item.profit_loss.ytd_last_year == 0? persenYtdLY * -100 : persenYtdLY * 100),
item.profit_loss.q1_actual,
item.profit_loss.q1_mb,
isNaN(persenQuarterMB) || persenQuarterMB == 'Infinity' || persenQuarterMB == '-Infinity'? (item.profit_loss.q1_mb == '' || item.profit_loss.q1_mb == 0? -0 : 0) : (item.profit_loss.q1_mb == '' || item.profit_loss.q1_mb == 0? persenQuarterMB * -100 : persenQuarterMB * 100),
item.profit_loss.q1_last_year,
isNaN(persenQuarterLY) || persenQuarterLY == 'Infinity' || persenQuarterLY == '-Infinity'? (item.profit_loss.q1_last_year == '' || item.profit_loss.q1_last_year == 0? -0 : 0) : (item.profit_loss.q1_last_year == '' || item.profit_loss.q1_last_year == 0? persenQuarterLY * -100 : persenQuarterLY * 100),
month == "Mar" ? item.profit_loss.q1_actual : month = "Jun" ? item.profit_loss.q2_actual : month = "Sep" ? item.profit_loss.q3_actual : 0,
month == "Mar" ? item.profit_loss.q1_mb : month = "Jun" ? item.profit_loss.q2_mb : month = "Sep" ? item.profit_loss.q3_mb : 0,
isNaN(persenQuarterMB) || persenQuarterMB == 'Infinity' || persenQuarterMB == '-Infinity'? (q_mb == '' || q_mb == 0? -0 : 0) : (q_mb == '' || q_mb == 0? persenQuarterMB * -100 : persenQuarterMB * 100),
month == "Mar" ? item.profit_loss.q1_last_year : month = "Jun" ? item.profit_loss.q2_last_year : month = "Sep" ? item.profit_loss.q3_last_year : 0,
isNaN(persenQuarterLY) || persenQuarterLY == 'Infinity' || persenQuarterLY == '-Infinity'? (q_last_year == '' || q_last_year == 0? -0 : 0) : (q_last_year == '' || q_last_year == 0? persenQuarterLY * -100 : persenQuarterLY * 100),
item.profit_loss.fy_actual,
item.profit_loss.fy_mb,
isNaN(persenFyMB) || persenFyMB == 'Infinity' || persenFyMB == '-Infinity'? (item.profit_loss.fy_mb == '' || item.profit_loss.fy_mb == 0? -0 : 0) : (item.profit_loss.fy_mb == '' || item.profit_loss.fy_mb == 0? persenFyMB * -100 : persenFyMB * 100),
......@@ -2848,13 +2882,93 @@ export default class SubHolding extends Component {
})
})
} else if (this.state.report.value === 10) {
let dbCatPQ = [
["ABCD", "%", "Rp Bio", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"]
]
this.setState({ dataTable: dbCatPQ, previewTable: true, loading: false, previewDownload: true })
let dbCATPQ = [];
let payloadCATPQ = {...payload, report_id: 17, quarter: this.state.quarter.name}
api.create().getReportCATPQ(payloadCATPQ).then(response => {
console.log(payloadCATPQ);
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
let res = response.data.data
console.log(res);
// const handlePushChild = (item) => {
// let indexIDzz = dbCATPQ.findIndex((val) => val[1] === item.id)
// if (indexIDzz === -1) {
// dbCATPQ.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// item.description,
// item.weight,
// item.uom,
// item.kpi_type,
// item.max_ach,
// item.formula_ytd,
// item.actual_monthly,
// item.target_monthly,
// item.achivement_monthly,
// item.score,
// item.score_x_weight,
// item.order
// ])
// }
// if (item.children !== null) {
// if (item.children.length > 0) {
// item.children.map((items, indexs) => {
// handlePushChild(items)
// })
// }
// }
// }
// res.map((item, index) => {
// dbCATPQ.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// item.description,
// item.weight,
// item.uom,
// item.kpi_type,
// item.max_ach,
// item.formula_ytd,
// item.actual_monthly,
// item.target_monthly,
// item.achivement_monthly,
// item.score,
// item.score_x_weight,
// item.order
// ])
// if (item.children !== null) {
// if (item.children.length > 0) {
// item.children.map((items, indexs) => {
// handlePushChild(items)
// })
// }
// }
// })
// this.setState({ dataTable: dbCATPQ, previewTable: true, loading: false, previewDownload: true })
// console.log(this.state.dataTable)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
} else if (this.state.report.value === 11) {
let dbCATPA = []
let payloadCATPA = {...payload, report_id: 17, months: this.state.month.month_id, get_for: "view"}
let payloadCATPA = {...payload, months: this.state.month.month_id, get_for: "view"}
api.create().getReportCATPA(payloadCATPA).then(response => {
console.log(payloadCATPA);
console.log(response);
......@@ -2876,11 +2990,11 @@ export default class SubHolding extends Component {
item.kpi_type,
item.max_ach,
item.formula_ytd,
item.actual_monthly,
item.target_monthly,
item.achivement_monthly,
item.score,
item.score_x_weight,
item.corporate_annual_target.actual_ytd,
item.corporate_annual_target.target_ytd,
item.corporate_annual_target.achivement_ytd,
item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight,
item.order
])
}
......@@ -2905,11 +3019,11 @@ export default class SubHolding extends Component {
item.kpi_type,
item.max_ach,
item.formula_ytd,
item.actual_monthly,
item.target_monthly,
item.achivement_monthly,
item.score,
item.score_x_weight,
item.corporate_annual_target.actual_ytd,
item.corporate_annual_target.target_ytd,
item.corporate_annual_target.achivement_ytd,
item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight,
item.order
])
if (item.children !== null) {
......
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