Commit 3531f4d8 authored by d.arizona's avatar d.arizona

apdet

parent 5d67852a
......@@ -47,7 +47,8 @@ class HomePage extends Component {
company: [],
dataDashboardCAT: [],
loading2: false,
loading3: false
loading3: false,
parameterPerfom: []
}
}
......@@ -114,9 +115,7 @@ class HomePage extends Component {
let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
this.setState({ listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[indexMonthMR], listPeriodeCAT: defaultPropsMB, periodeCAT: MB[indexMonthMR] }, () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
this.getDetailUser()
this.getParameterGroupPerfom()
})
}
......@@ -130,7 +129,28 @@ class HomePage extends Component {
let arrayChild = []
item.category.map((items, indexs) => {
if (this.state.company.includes(items.company_id)) {
arrayChild.push({ ...items, current_value: Number(items.current_value).toFixed(2), performanceColor: this.handleBackgroundPerform(Number(items.current_value)) })
let indexPerform = this.state.parameterPerfom.findIndex((val) => val.company_id == items.company_id)
let listPerfomanceDefault = []
if (indexPerform == -1) {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
} else {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => val.company_id == items.company_id)
}
let performanceScore = ''
let perfomanceScoreColor = '#fff'
if (listPerfomanceDefault.length > 0) {
listPerfomanceDefault.map((item, index) => {
// console.log(Number(lastTotal))
// console.log(Number(item.min_value))
// console.log(Number(item.max_value))
if (Number(items.current_value).toFixed(2) >= Number(item.min_value) && Number(items.current_value).toFixed(2) <= Number(item.max_value)) {
// console.log('masuk')
performanceScore = item.description
perfomanceScoreColor = item.value
}
})
}
arrayChild.push({ ...items, current_value: Number(items.current_value).toFixed(2), performanceColor: perfomanceScoreColor })
}
})
if (arrayChild.length > 0 && String(item.item_business).toLocaleLowerCase() != 'holding') {
......@@ -484,6 +504,27 @@ class HomePage extends Component {
return color
}
getParameterGroupPerfom() {
api.create().getParameterByGroupName({
"group_name": "PERFORMANCE_KPI"
}).then((response) => {
console.log(response.data)
if (response.data) {
this.setState({ parameterPerfom: response.data.data } , () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
this.getDetailUser()
})
} else {
this.setState({ parameterPerfom: [] } , () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
this.getDetailUser()
})
}
})
}
render() {
const getDataMonth = (item) => {
let months = item.months
......
......@@ -822,8 +822,13 @@ export default class CorporateAnnualTargetMR extends Component {
}
console.log(Number(Number(total).toFixed(2) / Number(totalWeightz)).toFixed(2))
let listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
let indexPerform = this.state.parameterPerfom.findIndex((val) => val.company_id == this.props.company.company_id)
let listPerfomanceDefault = []
if (indexPerform == -1) {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
} else {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => val.company_id == this.props.company.company_id)
}
let performanceScore = ''
let perfomanceScoreColor = '#fff'
if (listPerfomanceDefault.length > 0) {
......
......@@ -219,7 +219,7 @@ export default class ProfitLossROO extends Component {
let payload = {
"company_id": this.props.company.company_id,
"get_for": this.state.get_for,
"months": 0,
"quartal": this.props.quarter,
"periode": this.props.periode,
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
......@@ -259,7 +259,7 @@ export default class ProfitLossROO extends Component {
item.profit_loss.november === "" ? "0" : item.profit_loss.november,
item.profit_loss.december === "" ? "0" : item.profit_loss.december,
item.profit_loss.current_year_total === "" ? "0" : item.profit_loss.current_year_total,
item.profit_loss.actual_formula === "" ? "0" : item.profit_loss.actual_formula,
"",
item.order,
])
}
......@@ -294,7 +294,7 @@ export default class ProfitLossROO extends Component {
item.profit_loss.november === "" ? "0" : item.profit_loss.november,
item.profit_loss.december === "" ? "0" : item.profit_loss.december,
item.profit_loss.current_year_total === "" ? "0" : item.profit_loss.current_year_total,
item.profit_loss.actual_formula === "" ? "0" : item.profit_loss.actual_formula,
"",
item.order,
])
if (item.children !== null) {
......@@ -327,37 +327,37 @@ export default class ProfitLossROO extends Component {
}
downloadTemplate = async () => {
alert('Coming Soon ...')
// let res = await fetch(
// `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/profit_loss/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
// )
// res = await res.blob()
// // console.log(res)
// if (res.size > 0) {
// let url = window.URL.createObjectURL(res);
// let a = document.createElement('a');
// a.href = url;
// a.download = 'Template Monthly Report Profit Loss.xlsx';
// a.click();
// }
// alert('Coming Soon ...')
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/profit_loss/rolling_outlook/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&quartal=${this.props.quarter}`
)
res = await res.blob()
// console.log(res)
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Template Rolling Outlook Profit Loss.xlsx';
a.click();
}
}
async downloadAllData() {
alert('Coming Soon ...')
// let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/profit_loss/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
// console.log(url);
// let res = await fetch(
// `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/profit_loss/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId === null ? "" : this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
// )
// res = await res.blob()
// this.setState({ loading: false })
// if (res.size > 0) {
// let url = window.URL.createObjectURL(res);
// let a = document.createElement('a');
// a.href = url;
// a.download = 'Monthly Report Profit Loss.xlsx';
// a.click();
// }
// alert('Coming Soon ...')
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/profit_loss/rolling_outlook/export_rolling_outlook?rolling_outlook_id=${this.props.rollingOutlookID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&quartal=${this.props.quarter}`
console.log(url);
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/profit_loss/rolling_outlook/export_rolling_outlook?rolling_outlook_id=${this.props.rollingOutlookID === null ? "" : this.props.rollingOutlookID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&quartal=${this.props.quarter}`
)
res = await res.blob()
this.setState({ loading: false })
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Rolling Outlook Profit Loss.xlsx';
a.click();
}
}
backToRollingOutlook(type) {
......@@ -367,20 +367,21 @@ export default class ProfitLossROO extends Component {
this.state.dataTable.map(i => {
data.push({
"item_report_id": i[1],
"total_december_last_year": String(Number(i[6]).toFixed(1)),
"january": String(Number(i[7]).toFixed(1)),
"february": String(Number(i[8]).toFixed(1)),
"march": String(Number(i[9]).toFixed(1)),
"april": String(Number(i[10]).toFixed(1)),
"may": String(Number(i[11]).toFixed(1)),
"june": String(Number(i[12]).toFixed(1)),
"july": String(Number(i[13]).toFixed(1)),
"august": String(Number(i[14]).toFixed(1)),
"september": String(Number(i[15]).toFixed(1)),
"october": String(Number(i[16]).toFixed(1)),
"november": String(Number(i[17]).toFixed(1)),
"december": String(Number(i[18]).toFixed(1)),
"total_december_year": String(Number(i[19]).toFixed(1))
"notes": String(i[6]),
"last_year_total": String(Number(i[7]).toFixed(1)),
"january": String(Number(i[8]).toFixed(1)),
"february": String(Number(i[9]).toFixed(1)),
"march": String(Number(i[10]).toFixed(1)),
"april": String(Number(i[11]).toFixed(1)),
"may": String(Number(i[12]).toFixed(1)),
"june": String(Number(i[13]).toFixed(1)),
"july": String(Number(i[14]).toFixed(1)),
"august": String(Number(i[15]).toFixed(1)),
"september": String(Number(i[16]).toFixed(1)),
"october": String(Number(i[17]).toFixed(1)),
"november": String(Number(i[18]).toFixed(1)),
"december": String(Number(i[19]).toFixed(1)),
"current_year_total": String(Number(i[20]).toFixed(1)),
})
})
let payload = {
......@@ -388,7 +389,7 @@ export default class ProfitLossROO extends Component {
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"months": 0,
"quartal": this.props.quarter,
"status": type,
"balance_sheet": data
}
......@@ -398,13 +399,8 @@ export default class ProfitLossROO extends Component {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
if (type == 'submitted') {
// this.props.saveToMonthlyReport('PL')
this.props.onClickClose()
} else {
// this.props.saveToMonthlyReport()
this.props.onClickClose()
}
this.props.refresh()
this.props.onClickClose()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleTekTekTek: 0 }, () => {
document.body.style.overflow = 'unset';
......@@ -766,6 +762,17 @@ export default class ProfitLossROO extends Component {
}
const handleTotal = (val, tableMeta) => {
let total = 0
tableMeta.rowData.map((item,index) => {
if (index >= 8 && index <= 19) {
total += Number(item)
}
})
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(1)
return total
}
let columns = [
{
name: "",
......@@ -940,11 +947,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={true}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1038,11 +1045,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={true}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1136,11 +1143,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={true}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1234,11 +1241,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={true}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1332,11 +1339,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: this.props.quarter == 'q1'? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={this.props.quarter == 'q1'? true : false}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1430,11 +1437,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: this.props.quarter == 'q1'? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={this.props.quarter == 'q1'? true : false}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1528,11 +1535,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: this.props.quarter == 'q1'? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={this.props.quarter == 'q1'? true : false}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1626,11 +1633,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2'? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2'? true : false}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1724,11 +1731,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2'? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2'? true : false}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -1822,11 +1829,11 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2'? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2'? true : false}
value={Number(val).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
......@@ -2214,12 +2221,12 @@ export default class ProfitLossROO extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={false}
value={Number(val).toFixed(1)}
disabled={true}
value={Number(handleTotal(val, tableMeta)).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
......
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