Commit 8667e757 authored by faisalhamdi's avatar faisalhamdi

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

parents c4748766 c4ca098d
......@@ -364,6 +364,8 @@ const create = (type = "") => {
const createCFOLPA = (body) => api.post ('transaction/cash_flow/outlook_pa/create_outlook_report', body)
const getHierarkiDBPLOLPA = (body) => api.post('transaction/db_profit_loss/outlook_pa/get_report_hierarki', body)
const createDBPLOLPA = (body) => api.post('transaction/db_profit_loss/outlook_pa/create_outlook_report', body)
const getHierarkiDBPLRO = (body) => api.post('transaction/db_profit_loss/rolling_outlook/get_report_hierarki', body)
const createDBPLRO = (body) => api.post('transaction/db_profit_loss/rolling_outlook/create_rolling_outlook', body)
// Monthly
const getMonthlyReport = (body) => api.post('transaction/monthly_report/get_all_report', body)
......@@ -798,7 +800,9 @@ const create = (type = "") => {
getHierarkiCFOLPA,
createCFOLPA,
getHierarkiDBPLOLPA,
createDBPLOLPA
createDBPLOLPA,
getHierarkiDBPLRO,
createDBPLRO
}
}
......
......@@ -71,11 +71,25 @@ class HomePage extends Component {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userData: response.data.data }, () => {
// console.log(this.state.userData)
this.setState({ userData: response.data.data })
// console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
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.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
// api.create().checkApprover().then(response => {
......
......@@ -82,8 +82,24 @@ export default class DashboardCAT extends Component {
this.getCompanyActive()
})
}
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
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.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
// }
// }
})
}
......
......@@ -104,7 +104,21 @@ export default class DashboardFinancial extends React.Component {
this.getCompanyActive()
})
}
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
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.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -132,7 +146,7 @@ export default class DashboardFinancial extends React.Component {
})
let defaultProps = {
options: arrayBaru.sort((a,b) => a.company_name.localeCompare(b.company_name)),
options: arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name)),
getOptionLabel: (option) => titleCase(option.company_name),
};
......
......@@ -75,7 +75,18 @@ export default class SubHolding extends Component {
this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
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'})
}
}
})
......@@ -1084,7 +1095,77 @@ export default class SubHolding extends Component {
item.profit_loss.monthly_last_year_october,
item.profit_loss.monthly_last_year_november,
item.profit_loss.monthly_last_year_december,
item.profit_loss.notes
item.profit_loss.notes,
item.profit_loss.ro_full_year_january,
item.profit_loss.ro_full_year_february,
item.profit_loss.ro_full_year_march,
item.profit_loss.ro_full_year_april,
item.profit_loss.ro_full_year_may,
item.profit_loss.ro_full_year_june,
item.profit_loss.ro_full_year_july,
item.profit_loss.ro_full_year_august,
item.profit_loss.ro_full_year_september,
item.profit_loss.ro_full_year_october,
item.profit_loss.ro_full_year_november,
item.profit_loss.ro_full_year_december,
item.profit_loss.ol_q1_january,
item.profit_loss.ol_q1_february,
item.profit_loss.ol_q1_march,
item.profit_loss.ol_q1_april,
item.profit_loss.ol_q1_may,
item.profit_loss.ol_q1_june,
item.profit_loss.ol_q1_july,
item.profit_loss.ol_q1_august,
item.profit_loss.ol_q1_september,
item.profit_loss.ol_q1_october,
item.profit_loss.ol_q1_november,
item.profit_loss.ol_q1_december,
item.profit_loss.ol_q2_january,
item.profit_loss.ol_q2_february,
item.profit_loss.ol_q2_march,
item.profit_loss.ol_q2_april,
item.profit_loss.ol_q2_may,
item.profit_loss.ol_q2_june,
item.profit_loss.ol_q2_july,
item.profit_loss.ol_q2_august,
item.profit_loss.ol_q2_september,
item.profit_loss.ol_q2_october,
item.profit_loss.ol_q2_november,
item.profit_loss.ol_q2_december,
item.profit_loss.ol_q3_january,
item.profit_loss.ol_q3_february,
item.profit_loss.ol_q3_march,
item.profit_loss.ol_q3_april,
item.profit_loss.ol_q3_may,
item.profit_loss.ol_q3_june,
item.profit_loss.ol_q3_july,
item.profit_loss.ol_q3_august,
item.profit_loss.ol_q3_september,
item.profit_loss.ol_q3_october,
item.profit_loss.ol_q3_november,
item.profit_loss.ol_q3_december,
item.profit_loss.ol_pa_january,
item.profit_loss.ol_pa_february,
item.profit_loss.ol_pa_march,
item.profit_loss.ol_pa_april,
item.profit_loss.ol_pa_may,
item.profit_loss.ol_pa_june,
item.profit_loss.ol_pa_july,
item.profit_loss.ol_pa_august,
item.profit_loss.ol_pa_september,
item.profit_loss.ol_pa_october,
item.profit_loss.ol_pa_november,
item.profit_loss.ol_pa_december,
item.profit_loss.history_current_year,
item.profit_loss.history_last_year,
item.profit_loss.history_last_two_year,
item.profit_loss.history_last_three_year,
item.profit_loss.history_last_four_year,
item.profit_loss.history_last_five_year,
item.profit_loss.history_last_six_year,
item.profit_loss.history_last_seven_year,
item.profit_loss.history_last_eight_year,
item.profit_loss.history_last_nine_year
])
if (item.children !== null) {
......@@ -1148,7 +1229,77 @@ export default class SubHolding extends Component {
item.profit_loss.monthly_last_year_october,
item.profit_loss.monthly_last_year_november,
item.profit_loss.monthly_last_year_december,
item.profit_loss.notes
item.profit_loss.notes,
item.profit_loss.ro_full_year_january,
item.profit_loss.ro_full_year_february,
item.profit_loss.ro_full_year_march,
item.profit_loss.ro_full_year_april,
item.profit_loss.ro_full_year_may,
item.profit_loss.ro_full_year_june,
item.profit_loss.ro_full_year_july,
item.profit_loss.ro_full_year_august,
item.profit_loss.ro_full_year_september,
item.profit_loss.ro_full_year_october,
item.profit_loss.ro_full_year_november,
item.profit_loss.ro_full_year_december,
item.profit_loss.ol_q1_january,
item.profit_loss.ol_q1_february,
item.profit_loss.ol_q1_march,
item.profit_loss.ol_q1_april,
item.profit_loss.ol_q1_may,
item.profit_loss.ol_q1_june,
item.profit_loss.ol_q1_july,
item.profit_loss.ol_q1_august,
item.profit_loss.ol_q1_september,
item.profit_loss.ol_q1_october,
item.profit_loss.ol_q1_november,
item.profit_loss.ol_q1_december,
item.profit_loss.ol_q2_january,
item.profit_loss.ol_q2_february,
item.profit_loss.ol_q2_march,
item.profit_loss.ol_q2_april,
item.profit_loss.ol_q2_may,
item.profit_loss.ol_q2_june,
item.profit_loss.ol_q2_july,
item.profit_loss.ol_q2_august,
item.profit_loss.ol_q2_september,
item.profit_loss.ol_q2_october,
item.profit_loss.ol_q2_november,
item.profit_loss.ol_q2_december,
item.profit_loss.ol_q3_january,
item.profit_loss.ol_q3_february,
item.profit_loss.ol_q3_march,
item.profit_loss.ol_q3_april,
item.profit_loss.ol_q3_may,
item.profit_loss.ol_q3_june,
item.profit_loss.ol_q3_july,
item.profit_loss.ol_q3_august,
item.profit_loss.ol_q3_september,
item.profit_loss.ol_q3_october,
item.profit_loss.ol_q3_november,
item.profit_loss.ol_q3_december,
item.profit_loss.ol_pa_january,
item.profit_loss.ol_pa_february,
item.profit_loss.ol_pa_march,
item.profit_loss.ol_pa_april,
item.profit_loss.ol_pa_may,
item.profit_loss.ol_pa_june,
item.profit_loss.ol_pa_july,
item.profit_loss.ol_pa_august,
item.profit_loss.ol_pa_september,
item.profit_loss.ol_pa_october,
item.profit_loss.ol_pa_november,
item.profit_loss.ol_pa_december,
item.profit_loss.history_current_year,
item.profit_loss.history_last_year,
item.profit_loss.history_last_two_year,
item.profit_loss.history_last_three_year,
item.profit_loss.history_last_four_year,
item.profit_loss.history_last_five_year,
item.profit_loss.history_last_six_year,
item.profit_loss.history_last_seven_year,
item.profit_loss.history_last_eight_year,
item.profit_loss.history_last_nine_year
])
if (item.children !== null) {
if (item.children.length > 0) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -851,9 +851,15 @@ export default class ProfitLossMR extends Component {
}
})
if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "sales price") {
let value = Number(dataTable2[tableMeta.rowIndex - 2][11]) / Number(dataTable2[tableMeta.rowIndex - 1][11])
dataTable2[tableMeta.rowIndex][11] = R.equals(value, NaN) ? "0.0" : (R.equals(value, Infinity) ? "0.0" : (value == "-Infinity" ? "0.0" : value))
return R.equals(value, NaN) ? "0.0" : (R.equals(value, Infinity) ? "0.0" : (value == "-Infinity" ? "0.0" : value))
} else {
dataTable2[tableMeta.rowIndex][11] = Number(total).toFixed(1)
return total
}
}
let columns = [
{
......
......@@ -821,7 +821,7 @@ export default class OutlookPA extends Component {
"revision": Number(this.state.lastRevision),
"periode": this.state.periode.periode,
"company_id": this.state.company.company_id,
"submission_id": this.state.PLID,
"outlook_pa_id": this.state.PLID,
}
api.create().getHierarkiDBPLOLPA(payload).then(response => {
// console.log(response);
......@@ -1282,7 +1282,6 @@ export default class OutlookPA extends Component {
"status": "submitted",
"profit_loss_id": this.state.PLID,
"profit_loss_olpa": this.state.dbPL,
"months": 0,
}
console.log(this.state.dbPL)
// console.log(JSON.stringify(payload))
......
......@@ -206,8 +206,8 @@ export default class TaxPlanningOLPA extends Component {
fcp: item.tax_planning.august.fcp, tbf: item.tax_planning.august.tbf},
{tbc : item.tax_planning.september.tbc, fcp: item.tax_planning.september.fcp, tbf: item.tax_planning.september.tbf},
{tbc : item.tax_planning.october.tbc, fcp: item.tax_planning.october.fcp, tbf: item.tax_planning.october.tbf},
{tbc : item.tax_planning.november.tbc, fcp: item.tax_planning.november.fcp, tbf: item.tax_planning.november.tbf},
{tbc : item.tax_planning.december.tbc, fcp: item.tax_planning.december.fcp, tbf: item.tax_planning.december.tbf},
{ tbc: this.props.status === 'CLOSED' ? Number(item.tax_planning.november.tbc).toFixed(1) : item.type_report_tax.value_tbc.type_report_id == 5 || item.type_report_tax.value_tbc.type_report_id == 6 || item.type_report_tax.value_tbc.type_report_id == 7 ? { value: item.tax_planning.november.tbc, formula: item.tax_planning.november_formula } : item.tax_planning.november.tbc, fcp: this.props.status === 'CLOSED' ? Number(item.tax_planning.november.fcp).toFixed(1) : item.type_report_tax.value_fc.type_report_id == 5 || item.type_report_tax.value_fc.type_report_id == 6 || item.type_report_tax.value_fc.type_report_id == 7 ? { value: item.tax_planning.november.fcp, formula: item.tax_planning.november_formula } : item.tax_planning.november.fcp, tbf: this.props.status === 'CLOSED' ? Number(item.tax_planning.november.tbf).toFixed(1) : item.type_report_tax.value_tbf.type_report_id == 5 || item.type_report_tax.value_tbf.type_report_id == 6 || item.type_report_tax.value_tbf.type_report_id == 7 ? { value: item.tax_planning.november.tbf, formula: item.tax_planning.november_formula } : item.tax_planning.november.tbf },
{ tbc: this.props.status === 'CLOSED' ? Number(item.tax_planning.december.tbc).toFixed(1) : item.type_report_tax.value_tbc.type_report_id == 5 || item.type_report_tax.value_tbc.type_report_id == 6 || item.type_report_tax.value_tbc.type_report_id == 7 ? { value: item.tax_planning.december.tbc, formula: item.tax_planning.december_formula } : item.tax_planning.december.tbc, fcp: this.props.status === 'CLOSED' ? Number(item.tax_planning.december.fcp).toFixed(1) : item.type_report_tax.value_fc.type_report_id == 5 || item.type_report_tax.value_fc.type_report_id == 6 || item.type_report_tax.value_fc.type_report_id == 7 ? { value: item.tax_planning.december.fcp, formula: item.tax_planning.december_formula } : item.tax_planning.december.fcp, tbf: this.props.status === 'CLOSED' ? Number(item.tax_planning.december.tbf).toFixed(1) : item.type_report_tax.value_tbf.type_report_id == 5 || item.type_report_tax.value_tbf.type_report_id == 6 || item.type_report_tax.value_tbf.type_report_id == 7 ? { value: item.tax_planning.december.tbf, formula: item.tax_planning.december_formula } : item.tax_planning.december.tbf },
item.tax_planning.total_current_year,
0,
0,
......@@ -247,8 +247,8 @@ export default class TaxPlanningOLPA extends Component {
fcp: item.tax_planning.august.fcp, tbf: item.tax_planning.august.tbf},
{tbc : item.tax_planning.september.tbc, fcp: item.tax_planning.september.fcp, tbf: item.tax_planning.september.tbf},
{tbc : item.tax_planning.october.tbc, fcp: item.tax_planning.october.fcp, tbf: item.tax_planning.october.tbf},
{tbc : item.tax_planning.november.tbc, fcp: item.tax_planning.november.fcp, tbf: item.tax_planning.november.tbf},
{tbc : item.tax_planning.december.tbc, fcp: item.tax_planning.december.fcp, tbf: item.tax_planning.december.tbf},
{ tbc: this.props.status === 'CLOSED' ? Number(item.tax_planning.november.tbc).toFixed(1) : item.type_report_tax.value_tbc.type_report_id == 5 || item.type_report_tax.value_tbc.type_report_id == 6 || item.type_report_tax.value_tbc.type_report_id == 7 ? { value: item.tax_planning.november.tbc, formula: item.tax_planning.november_formula } : item.tax_planning.november.tbc, fcp: this.props.status === 'CLOSED' ? Number(item.tax_planning.november.fcp).toFixed(1) : item.type_report_tax.value_fc.type_report_id == 5 || item.type_report_tax.value_fc.type_report_id == 6 || item.type_report_tax.value_fc.type_report_id == 7 ? { value: item.tax_planning.november.fcp, formula: item.tax_planning.november_formula } : item.tax_planning.november.fcp, tbf: this.props.status === 'CLOSED' ? Number(item.tax_planning.november.tbf).toFixed(1) : item.type_report_tax.value_tbf.type_report_id == 5 || item.type_report_tax.value_tbf.type_report_id == 6 || item.type_report_tax.value_tbf.type_report_id == 7 ? { value: item.tax_planning.november.tbf, formula: item.tax_planning.november_formula } : item.tax_planning.november.tbf },
{ tbc: this.props.status === 'CLOSED' ? Number(item.tax_planning.december.tbc).toFixed(1) : item.type_report_tax.value_tbc.type_report_id == 5 || item.type_report_tax.value_tbc.type_report_id == 6 || item.type_report_tax.value_tbc.type_report_id == 7 ? { value: item.tax_planning.december.tbc, formula: item.tax_planning.december_formula } : item.tax_planning.december.tbc, fcp: this.props.status === 'CLOSED' ? Number(item.tax_planning.december.fcp).toFixed(1) : item.type_report_tax.value_fc.type_report_id == 5 || item.type_report_tax.value_fc.type_report_id == 6 || item.type_report_tax.value_fc.type_report_id == 7 ? { value: item.tax_planning.december.fcp, formula: item.tax_planning.december_formula } : item.tax_planning.december.fcp, tbf: this.props.status === 'CLOSED' ? Number(item.tax_planning.december.tbf).toFixed(1) : item.type_report_tax.value_tbf.type_report_id == 5 || item.type_report_tax.value_tbf.type_report_id == 6 || item.type_report_tax.value_tbf.type_report_id == 7 ? { value: item.tax_planning.december.tbf, formula: item.tax_planning.december_formula } : item.tax_planning.december.tbf },
item.tax_planning.total_current_year,
0,
0,
......@@ -370,14 +370,14 @@ export default class TaxPlanningOLPA extends Component {
tbf: String(Number(i[18].tbf).toFixed(1))
},
november: {
tbc: String(Number(i[19].tbc).toFixed(1)),
fcp: String(Number(i[19].fcp).toFixed(1)),
tbf: String(Number(i[19].tbf).toFixed(1))
tbc: i[1] === 3 && i[19].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[19].tbc.value) : String(i[19].tbc),
fcp: i[2] === 3 && i[19].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[19].fcp.value) : String(i[19].fcp),
tbf: i[3] === 3 && i[19].tbf === "" ? "0" : String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(i[19].tbf) : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[19].tbf.value) : String(i[19].tbf)
},
december: {
tbc: String(Number(i[20].tbc).toFixed(1)),
fcp: String(Number(i[20].fcp).toFixed(1)),
tbf: String(Number(i[20].tbf).toFixed(1))
tbc: i[1] === 3 && i[20].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[20].tbc.value) : String(i[20].tbc),
fcp: i[2] === 3 && i[20].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[20].fcp.value) : String(i[20].fcp),
tbf: i[3] === 3 && i[20].tbf === "" ? "0" : String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(i[20].tbf) : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[20].tbf.value) : String(i[20].tbf)
},
total_current_year: String(Number(i[21]).toFixed(1)),
})
......@@ -504,7 +504,7 @@ export default class TaxPlanningOLPA extends Component {
checkUpload() {
api.create().checkUploadOLPA(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
// console.log(response)
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleTP: false, loading: true })
......@@ -759,26 +759,26 @@ export default class TaxPlanningOLPA extends Component {
tbf: i[3] === 3 && i[18].tbf === "" ? "0" : String(i[18].tbf)
},
november: {
tbc: i[1] === 3 && i[19].tbc === "" ? "0" : String(i[19].tbc),
fcp: i[2] === 3 && i[19].fcp === "" ? "0" : String(i[19].fcp),
tbf: i[3] === 3 && i[19].tbf === "" ? "0" : String(i[19].tbf)
tbc: i[1] === 3 && i[19].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[19].tbc.value) : String(i[19].tbc),
fcp: i[2] === 3 && i[19].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[19].fcp.value) : String(i[19].fcp),
tbf: i[3] === 3 && i[19].tbf === "" ? "0" : String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(i[19].tbf) : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[19].tbf.value) : String(i[19].tbf)
},
december: {
tbc: i[1] === 3 && i[20].tbc === "" ? "0" : String(i[20].tbc),
fcp: i[2] === 3 && i[20].fcp === "" ? "0" : String(i[20].fcp),
tbf: i[3] === 3 && i[20].tbf === "" ? "0" : String(i[20].tbf)
tbc: i[1] === 3 && i[20].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[20].tbc.value) : String(i[20].tbc),
fcp: i[2] === 3 && i[20].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[20].fcp.value) : String(i[20].fcp),
tbf: i[3] === 3 && i[20].tbf === "" ? "0" : String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(i[20].tbf) : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[20].tbf.value) : String(i[20].tbf)
},
total_current_year: i[2] === 3 && i[21] === "" ? "0" : String(i[21]),
total_next_year: {
tbc: i[1] === 3 && i[22].tbc === "" ? "0" : String(i[22].tbc),
fcp: i[2] === 3 && i[22].fcp === "" ? "0" : String(i[22].fcp),
tbf: i[3] === 3 && i[22].tbf === "" ? "0" : String(i[22].tbf)
},
total_more_year: {
tbc: i[1] === 3 && i[23].tbc === "" ? "0" : String(i[23].tbc),
fcp: i[2] === 3 && i[23].fcp === "" ? "0" : String(i[23].fcp),
tbf: i[3] === 3 && i[23].tbf === "" ? "0" : String(i[23].tbf)
}
// total_next_year: {
// tbc: i[1] === 3 && i[22].tbc === "" ? "0" : String(i[22].tbc),
// fcp: i[2] === 3 && i[22].fcp === "" ? "0" : String(i[22].fcp),
// tbf: i[3] === 3 && i[22].tbf === "" ? "0" : String(i[22].tbf)
// },
// total_more_year: {
// tbc: i[1] === 3 && i[23].tbc === "" ? "0" : String(i[23].tbc),
// fcp: i[2] === 3 && i[23].fcp === "" ? "0" : String(i[23].fcp),
// tbf: i[3] === 3 && i[23].tbf === "" ? "0" : String(i[23].tbf)
// }
})
......@@ -795,37 +795,39 @@ export default class TaxPlanningOLPA extends Component {
}
})
// console.log(JSON.stringify(data))
let payload = {
"outlook_pa_id": this.props.outlook_pa_id,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"tax_planning": data,
"status": "submitted"
}
api.create().validateSubmitReportOLPA(payload).then((response) => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result && errorContrl === false && editAble === false ) {
// let payload = {
// "outlook_pa_id": this.props.outlook_pa_id,
// "company_id": this.props.company.company_id,
// "periode": this.props.periode,
// "report_id": this.props.report_id,
// "tax_planning": data,
// "status": "submitted"
// }
// api.create().validateSubmitReportOLPA(payload).then((response) => {
// console.log(payload)
// console.log(response)
// if (response.data) {
// if (response.data.status === "success") {
// if (response.data.data.result && errorContrl === false && editAble === false ) {
if (errorContrl === false && editAble === false ) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
} else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
}
} 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 {
// 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 })
// }
// })
}
downloadTemplate = async () => {
......@@ -870,11 +872,11 @@ export default class TaxPlanningOLPA extends Component {
let dataFormula = []
let id = 0
let double = false
const handleValueFormula = (value, tableMeta, dex, xntd, forecast, periode) => {
// console.log(xntd)
let form = dex === 1 ? tableMeta.rowData[6].tbc : dex === 2 ? tableMeta.rowData[6].fcp : tableMeta.rowData[6].tbf
let splitFormula = String(form).split('@')
// console.log(form)
// console.log(splitFormula)
let baru = []
let anjay = []
splitFormula.map((item, index) => {
......@@ -882,20 +884,24 @@ export default class TaxPlanningOLPA extends Component {
let re = /^[a-zA-Z0-9_]+$/;
let asd = ''
if (item !== "") {
// console.log(item)
// console.log(items)
// re.test(items) ngecek angka
if (!re.test(items)) {
baru.push(String(item).substr(0, Number(String(item).length) - 1))
baru.push(String(item).substr(Number(String(item).length) - 1, 1))
} else {
baru.push(String(item))
}
// console.log(baru)
}
})
// console.log(baru);
// if (forecast !== undefined) {
// console.log(splitFormula)
// }
if (tableMeta.rowData[8] == "Under payment /(Over Payment ) Income Tax Art. 29" || forecast !== undefined) {
// form.replace("(", "")
// form.replace(")", "")
let opgab = []
baru.map((item, index) => {
if (item.length > 1 && (item.includes("+") || item.includes("-") || item.includes("*") || item.includes("/"))) {
......@@ -915,14 +921,17 @@ export default class TaxPlanningOLPA extends Component {
if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
anjay.push(item)
} else {
// console.log(item)
if (String(item).includes('#')) {
let splitform = String(item).split('#')
if (splitform[1] == 'TP1' || splitform[1] == 'TP2' || splitform[1] == 'TP3') {
// console.log(dataTable2)
let indexID = dataTable2.findIndex((val) => val[24] == splitform[0])
if (indexID !== -1) {
// console.log(splitform)
let data = splitform[1] == 'TP1' ? dataTable2[indexID][tableMeta.columnIndex].tbc : splitform[1] == 'TP2' ? dataTable2[indexID][tableMeta.columnIndex].fcp : dataTable2[indexID][tableMeta.columnIndex].tbf
// console.log(data)
// if(value == null){
// console.log(tableMeta);
// }
let valuezz = data.value == undefined ? data : data.value
anjay.push(valuezz == "" ? 0 : valuezz)
}
......@@ -944,17 +953,19 @@ export default class TaxPlanningOLPA extends Component {
let valuezz = tableMeta.rowData[data].formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
// else {
// let data = dex == 1 ? value.tbc : dex == 2 ? value.fcp : value.tbf
// // let data = dex == 1 ? tableMeta.rowData[data].tbc : dex == 2 ? tableMeta.rowData[data].fcp : tableMeta.rowData[data].tbf
// console.log(data);
// let indexID = data.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
// if (indexID !== -1) {
// let valuezz = data.formula[indexID].value
// anjay.push(valuezz == "" ? 0 : valuezz)
// }
} else {
// console.log(value);
// if(value == null){
// console.log(tableMeta);
// }
let data = dex == 1 ? value.tbc : dex == 2 ? value.fcp : value.tbf
// console.log(data);
let indexID = data.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
if (indexID !== -1) {
let valuezz = data.formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
}
} else {
let indexID = dataTable2.findIndex((val) => val[24] == item)
......@@ -962,7 +973,7 @@ export default class TaxPlanningOLPA extends Component {
if (dataTable2[indexID][24] == tableMeta.rowData[24]) {
anjay.push(0)
} else {
let data = dex == 1 ? dataTable2[indexID][tableMeta.columnIndex].tbc : dex == 2 ? dataTable2[indexID][tableMeta.columnIndex].fcp : dex == 3 ? dataTable2[indexID][tableMeta.columnIndex].tbf : dataTable2[indexID][tableMeta.columnIndex]
let data = dex == 1 ? dataTable2[indexID][tableMeta.columnIndex].tbc : dex == 2 ? dataTable2[indexID][tableMeta.columnIndex].fcp : dataTable2[indexID][tableMeta.columnIndex].tbf
let valuezz = data.value == undefined ? data : data.value
anjay.push(valuezz == "" ? 0 : valuezz)
}
......@@ -1076,15 +1087,28 @@ export default class TaxPlanningOLPA extends Component {
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value = Number(total).toFixed(1)
}
} else if (dex == 3) {
if (tableMeta.rowData[8] == "Corporate Income Tax") {
if (total < 0) {
total = 0
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(2)
} else {
if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf.value == undefined) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(2)
}
} else if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf.value == undefined) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(1)
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf.value = Number(total).toFixed(1)
}
} else {
if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(1)
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = Number(total).toFixed(1)
}
}
return Number(total).toFixed(1)
return tableMeta.rowData[8] == "Corporate Income Tax" ? Number(total).toFixed(2) : Number(total).toFixed(1)
}
const handleChange = (value, tableMeta, indexChilds) => {
......@@ -1110,8 +1134,8 @@ export default class TaxPlanningOLPA extends Component {
}
}
}
const handleTotal = (tableMeta, dex) => {
// console.log(tableMeta)
const handleTotal = (tableMeta, dex, periode) => {
let total = 0
let totalfcp = 0
if (String(tableMeta.rowData[8]).toLowerCase() === "fiscal correction positive / (negative) year to date") {
......@@ -1129,17 +1153,21 @@ export default class TaxPlanningOLPA extends Component {
} else {
dataTable2[tableMeta.rowIndex].map((item, index) => {
if (index >= 9 && index <= 20) {
// if (tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 || tableMeta.rowData[3] === 7) {
// let valItem = item.tbf.value == undefined || item.tbf.value == "" || item.tbf.value == "undefined" ? 0.0 : item.tbf.value
// total += Number(valItem)
// } else {
if (String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX") {
let valItem = item.tbf == undefined || item.tbf == "" || item.tbf == "undefined" ? 0.0 : item.tbf
total += Number(valItem)
// }
}
else if (tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 || tableMeta.rowData[3] === 7) {
let valItem = item.tbf.value == undefined || item.tbf.value == "" || item.tbf.value == "undefined" ? 0.0 : item.tbf.value
total += Number(valItem)
} else {
let valItem = item.tbf == undefined || item.tbf == "" || item.tbf == "undefined" ? 0.0 : item.tbf
total += Number(valItem)
}
}
})
}
dataTable2[tableMeta.rowIndex][21] = Number(total)
dataTable2[tableMeta.rowIndex][21] = String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(total).toFixed(2) : Number(total).toFixed(1)
return total
}
......@@ -1971,6 +1999,24 @@ export default class TaxPlanningOLPA extends Component {
null
:
this.state.get_for == 'view'?
tableMeta.rowData[1] === 5 || tableMeta.rowData[1] === 6 || tableMeta.rowData[1] === 7 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.tbc}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.tbc.value).toFixed(2) : Number(value.tbc.value).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2090,6 +2136,24 @@ export default class TaxPlanningOLPA extends Component {
null
:
this.state.get_for == 'view'?
tableMeta.rowData[2] === 5 || tableMeta.rowData[2] === 6 || tableMeta.rowData[2] === 7 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.fcp}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp.value).toFixed(2) : Number(value.fcp.value).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2119,7 +2183,7 @@ export default class TaxPlanningOLPA extends Component {
type="text"
placeholder="input"
// disabled={this.props.isApprover == true ? true : false}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp).toFixed(1) : Number(value.fcp).toFixed(1)}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp).toFixed(2) : Number(value.fcp).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta, 1)
// console.log(dataTable2)
......@@ -2207,6 +2271,24 @@ export default class TaxPlanningOLPA extends Component {
null
:
this.state.get_for == 'view'?
tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 || tableMeta.rowData[3] === 7 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.tbf}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.tbf.value).toFixed(2) : Number(value.tbf.value).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2265,7 +2347,7 @@ export default class TaxPlanningOLPA extends Component {
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(handleValueFormula(value, tableMeta, 3)).toFixed(2) : Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
/>
:
tableMeta.rowData[3] === 5 ?
......@@ -2275,7 +2357,7 @@ export default class TaxPlanningOLPA extends Component {
type="text"
placeholder=""
disabled={false}
value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(handleValueFormula(value, tableMeta, 3)).toFixed(2) : Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
/>
:
tableMeta.rowData[3] === 7 ?
......@@ -2358,6 +2440,24 @@ export default class TaxPlanningOLPA extends Component {
null
:
this.state.get_for == 'view'?
tableMeta.rowData[1] === 5 || tableMeta.rowData[1] === 6 || tableMeta.rowData[1] === 7 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.tbc}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.tbc.value).toFixed(2) : Number(value.tbc.value).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2477,6 +2577,24 @@ export default class TaxPlanningOLPA extends Component {
null
:
this.state.get_for == 'view'?
tableMeta.rowData[2] === 5 || tableMeta.rowData[2] === 6 || tableMeta.rowData[2] === 7 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.fcp}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp.value).toFixed(2) : Number(value.fcp.value).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2506,7 +2624,7 @@ export default class TaxPlanningOLPA extends Component {
type="text"
placeholder="input"
// disabled={this.props.isApprover == true ? true : false}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp).toFixed(1) : Number(value.fcp).toFixed(1)}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp).toFixed(2) : Number(value.fcp).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta, 1)
// console.log(dataTable2)
......@@ -2594,6 +2712,24 @@ export default class TaxPlanningOLPA extends Component {
null
:
this.state.get_for == 'view'?
tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 || tableMeta.rowData[3] === 7 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.tbf}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.tbf.value).toFixed(2) : Number(value.tbf.value).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2652,7 +2788,7 @@ export default class TaxPlanningOLPA extends Component {
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(handleValueFormula(value, tableMeta, 3)).toFixed(2) : Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
/>
:
tableMeta.rowData[3] === 5 ?
......@@ -2662,7 +2798,7 @@ export default class TaxPlanningOLPA extends Component {
type="text"
placeholder=""
disabled={false}
value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(handleValueFormula(value, tableMeta, 3)).toFixed(2) : Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
/>
:
tableMeta.rowData[3] === 7 ?
......@@ -2736,7 +2872,7 @@ export default class TaxPlanningOLPA extends Component {
{tableMeta.rowData[3] === 4 || tableMeta.rowData[3] === 1 ?
null
:
this.state.get_for == 'view'?
this.state.get_for == 'view' ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -2790,7 +2926,7 @@ export default class TaxPlanningOLPA extends Component {
type="text"
placeholder=""
disabled={true}
value={Number(handleTotal(tableMeta, 6)).toFixed(1)}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(handleTotal(tableMeta, 6)).toFixed(2) : Number(handleTotal(tableMeta, 6)).toFixed(1)}
/>
:
tableMeta.rowData[3] === 5 ?
......@@ -2800,39 +2936,29 @@ export default class TaxPlanningOLPA extends Component {
type="text"
placeholder=""
disabled={true}
value={Number(handleTotal(tableMeta, 5)).toFixed(1)}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(handleTotal(tableMeta, 5)).toFixed(2) : Number(handleTotal(tableMeta, 5)).toFixed(1)}
/>
:
// tableMeta.rowData[3] === 1 ?
tableMeta.rowData[3] === 7 ? null
// (Number(handleTotal(tableMeta, 1)) >= Number(this.state.minValue) && Number(handleTotal(tableMeta, 1)) <= Number(this.state.maxValue)) ?
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(handleTotal(tableMeta, 1)).toFixed(1)}
// value={Number(handleTotal(tableMeta, 7)).toFixed(1)}
// /> :
// <LightTooltip title={this.state.minValue === null ? `Value Should be 0` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', color: 'red' }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(handleTotal(tableMeta, 7)).toFixed(1)}
// />
// :
tableMeta.rowData[3] === 7 ?
(Number(handleTotal(tableMeta, 1)) >= Number(this.state.minValue) && Number(handleTotal(tableMeta, 1)) <= Number(this.state.maxValue)) ?
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleTotal(tableMeta, 7)).toFixed(1)}
/> :
<LightTooltip title={this.state.minValue === null ? `Value Should be 0` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', color: 'red' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleTotal(tableMeta, 7)).toFixed(1)}
/>
</LightTooltip>
// </LightTooltip>
:
null
// tableMeta.rowData[3] === 7 ?
......
......@@ -18,6 +18,7 @@ import ProfitLossRO from './RollingOutlook/ProfitLossRO';
import TaxPlanningRO from './RollingOutlook/TaxPlanningRO';
import CorporateAnnualTargetRO from './RollingOutlook/CorporateAnnualTargetRO';
import CashFlowRO from './RollingOutlook/CashFlowRO';
import * as R from 'ramda'
var ct = require("../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
......@@ -519,7 +520,7 @@ export default class RollingOutlook extends Component {
})
}
getRollingOutlookID() {
getRollingOutlookID(type) {
this.setState({ loading: true })
let payload = {
"company_id": this.state.company.company_id,
......@@ -543,6 +544,12 @@ export default class RollingOutlook extends Component {
console.log(this.state.lastStatus);
this.historyApproval()
this.getLatestPeriodSubmit()
if (type != undefined && type == 'PL') {
// this.getCashFlow(type)
this.getPL(type)
} else {
this.setState({ loading: false })
}
// api.create().checkApprover().then(response => {
// console.log(response);
if (this.state.isApprover) {
......@@ -850,6 +857,498 @@ export default class RollingOutlook extends Component {
}
}
getPL(type) {
let PLID = null
let payloadID = {
"periode": this.state.periode.periode,
"company_id": this.state.company.company_id
}
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
} else {
PLID = null
}
this.setState({ PLID }, () => {
let payload = {
"report_id": 28,
"revision": Number(this.state.lastRevision),
"periode": this.state.periode.periode,
"company_id": this.state.company.company_id,
"quartal": this.state.quarter.value,
"rolling_outlook_id": this.state.PLID,
}
api.create().getHierarkiDBPLRO(payload).then(response => {
// console.log(response);
let dataTable = []
if (response.data) {
// let dataTable = []
console.log(response)
let res = response.data.data
const handlePushChild = (item) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_detail_rolling_outlook.total_actual_before === null ? "0" : item.profit_detail_rolling_outlook.total_actual_before === "" ? "0" : item.profit_detail_rolling_outlook.total_actual_before,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.january, formula: item.profit_detail_rolling_outlook.january_formula } : item.profit_detail_rolling_outlook.january,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.february, formula: item.profit_detail_rolling_outlook.february_formula } : item.profit_detail_rolling_outlook.february,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.march, formula: item.profit_detail_rolling_outlook.march_formula } : item.profit_detail_rolling_outlook.march,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.april, formula: item.profit_detail_rolling_outlook.april_formula } : item.profit_detail_rolling_outlook.april,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.may, formula: item.profit_detail_rolling_outlook.may_formula } : item.profit_detail_rolling_outlook.may,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.june, formula: item.profit_detail_rolling_outlook.june_formula } : item.profit_detail_rolling_outlook.june,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.july, formula: item.profit_detail_rolling_outlook.july_formula } : item.profit_detail_rolling_outlook.july,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.august, formula: item.profit_detail_rolling_outlook.august_formula } : item.profit_detail_rolling_outlook.august,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.september, formula: item.profit_detail_rolling_outlook.september_formula } : item.profit_detail_rolling_outlook.september,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.october, formula: item.profit_detail_rolling_outlook.october_formula } : item.profit_detail_rolling_outlook.october,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.november, formula: item.profit_detail_rolling_outlook.november_formula } : item.profit_detail_rolling_outlook.november,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.december, formula: item.profit_detail_rolling_outlook.december_formula } : item.profit_detail_rolling_outlook.december,
item.profit_detail_rolling_outlook.total_current_year,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? 0 : item.profit_detail_rolling_outlook.total_next_year,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? 0 : item.profit_detail_rolling_outlook.total_more_year,
item.order,
item.condition_it_should_be,
item.condition_if_wrong,
item.profit_detail_rolling_outlook.forecast_formula == null ? [] : item.profit_detail_rolling_outlook.forecast_formula,
item.profit_detail_rolling_outlook.notes
])
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.profit_detail_rolling_outlook.total_actual_before === null ? "0" : item.profit_detail_rolling_outlook.total_actual_before === "" ? "0" : item.profit_detail_rolling_outlook.total_actual_before,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.january, formula: item.profit_detail_rolling_outlook.january_formula } : item.profit_detail_rolling_outlook.january,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.february, formula: item.profit_detail_rolling_outlook.february_formula } : item.profit_detail_rolling_outlook.february,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.march, formula: item.profit_detail_rolling_outlook.march_formula } : item.profit_detail_rolling_outlook.march,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.april, formula: item.profit_detail_rolling_outlook.april_formula } : item.profit_detail_rolling_outlook.april,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.may, formula: item.profit_detail_rolling_outlook.may_formula } : item.profit_detail_rolling_outlook.may,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.june, formula: item.profit_detail_rolling_outlook.june_formula } : item.profit_detail_rolling_outlook.june,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.july, formula: item.profit_detail_rolling_outlook.july_formula } : item.profit_detail_rolling_outlook.july,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.august, formula: item.profit_detail_rolling_outlook.august_formula } : item.profit_detail_rolling_outlook.august,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.september, formula: item.profit_detail_rolling_outlook.september_formula } : item.profit_detail_rolling_outlook.september,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.october, formula: item.profit_detail_rolling_outlook.october_formula } : item.profit_detail_rolling_outlook.october,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.november, formula: item.profit_detail_rolling_outlook.november_formula } : item.profit_detail_rolling_outlook.november,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: item.profit_detail_rolling_outlook.december, formula: item.profit_detail_rolling_outlook.december_formula } : item.profit_detail_rolling_outlook.december,
item.profit_detail_rolling_outlook.total_current_year,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? 0 : item.profit_detail_rolling_outlook.total_next_year,
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? 0 : item.profit_detail_rolling_outlook.total_more_year,
item.order,
item.condition_it_should_be,
item.condition_if_wrong,
item.profit_detail_rolling_outlook.forecast_formula == null ? [] : item.profit_detail_rolling_outlook.forecast_formula,
item.profit_detail_rolling_outlook.notes
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
// console.log(dataTable)
this.setState({ dbPL: dataTable }, () => {
this.olahDataPL(this.state.dbPL, type)
})
} else {
this.setState({ dbPL: [], previewTable: false, previewDownload: false })
}
})
})
})
}
handleValueFormulaDBPL = (indexDBCF, value, tableMeta, column, periode, forecast) => {
let splitFormula = String(tableMeta[3]).split(/([()@])/)
// let splitFormula = String(tableMeta.rowData[3]).split('@')
let baru = []
let anjay = []
let dataTable2 = this.state.dbPL
// if (forecast !== undefined) {
// console.log(tableMeta)
// }
splitFormula.map((item, index) => {
let items = String(item).substr(Number(String(item).length) - 1, 1)
let subForm = String(item).substr(0, Number(String(item).length) - 1)
let re = /^[a-zA-Z0-9_]+$/;
let asd = ''
if (item !== "") {
if (!re.test(items)) {
baru.push(subForm)
baru.push(items)
} else {
baru.push(String(item))
}
}
})
baru.map((item, index) => {
if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
anjay.push(item)
} else {
if (String(item).includes('#')) {
if (forecast !== undefined) {
let forecastt = 0
forecast.map((items, index) => {
if (items.periode == periode) {
forecastt += Number(items.value)
}
})
anjay.push(forecastt)
} else {
if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
let data = column == 7 ? 18 : column - 1
let period = data == 18 ? Number(this.state.periode.periode) - 1 : this.state.periode.periode
let indexID = tableMeta[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
if (indexID !== -1) {
let valuezz = tableMeta[data].formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
// console.log(item)
let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.state.periode.periode))
if (indexID !== -1) {
let valuezz = value.formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
}
} else {
let indexID = dataTable2.findIndex((val) => val[22] == item)
if (indexID !== -1) {
// if (forecast !== undefined) {
// console.log(dataTable2[indexID])
// console.log(column)
// console.log(dataTable2[indexID][column])
// }
if (forecast != undefined) {
// console.log(dataTable2[indexID][column])
}
let valuezz = dataTable2[indexID][column].value == undefined ? dataTable2[indexID][column] : dataTable2[indexID][column].value
anjay.push(valuezz == "" ? 0 : valuezz)
} else {
if (item === '(-1)') {
anjay.push(-1)
}
}
}
}
})
let anjay2 = []
let kurung = false
let item1 = []
anjay.map((item, index) => {
if (item == "(") {
kurung = true
} else if (item == ")") {
kurung = false
anjay2.push(item1)
item1 = []
} else {
if (kurung) {
item1.push(item)
} else {
anjay2.push(item)
}
}
})
let total = 0
let opt = ""
let totalPrio = 0
let optPrio = ""
let prio = false
anjay2.map((item, index) => {
if (Array.isArray(item)) {
prio = true
item.map((items, indexs) => {
if (items == "+") {
optPrio = "tambah"
} else if (items == "-") {
optPrio = "kurang"
} else if (items == "*") {
optPrio = "kali"
} else if (items == "/") {
optPrio = "bagi"
} else {
if (optPrio == "tambah") {
totalPrio = Number(totalPrio) + Number(items)
} else if (optPrio == "kurang") {
totalPrio = Number(totalPrio) - Number(items)
} else if (optPrio == "kali") {
totalPrio = Number(totalPrio) * Number(items)
} else if (optPrio == "bagi") {
totalPrio = Number(totalPrio) / Number(items) == NaN ? 0 : Number(totalPrio) / Number(items)
} else {
totalPrio += Number(items)
}
}
})
if (index == anjay2.length - 1) {
if (opt == "tambah") {
total = Number(total) + Number(totalPrio)
} else if (opt == "kurang") {
total = Number(total) - Number(totalPrio)
} else if (opt == "kali") {
total = Number(total) * Number(totalPrio)
} else if (opt == "bagi") {
total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
} else {
total += Number(totalPrio)
}
}
} else {
// console.log(item.length)
if (item == "+") {
opt = "tambah"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "-") {
opt = "kurang"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "*") {
opt = "kali"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "/") {
opt = "bagi"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else {
if (opt == "tambah") {
total = Number(total) + Number(item)
} else if (opt == "kurang") {
total = Number(total) - Number(item)
} else if (opt == "kali") {
total = Number(total) * Number(item)
} else if (opt == "bagi") {
total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
} else {
total += Number(item)
}
}
}
})
if(String(tableMeta[5]) == "Cost of Goods Sold (COGS)" && column == 20) {
console.log(splitFormula)
console.log(baru)
console.log(anjay)
console.log(anjay2)
console.log(total)
}
total = R.equals(total, NaN) ? "0.0" : total
return total
}
handleForecastDBPL = (index, tableMeta, periode, column) => {
let total = 0
let dataTable2 = this.state.dbPL
if (tableMeta[3].includes('#PL')) {
dataTable2[index][25].map((item, index) => {
if (item.periode == periode) {
total += Number(item.value)
}
})
} else {
total = this.handleValueFormulaDBPL(dataTable2[index][column], tableMeta[column], tableMeta, column, periode, dataTable2[index][25])
}
return total
}
olahDataPL(dbPL, type) {
dbPL.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormulaDBPL(index, item[7], item, 7)
item[8].value = this.handleValueFormulaDBPL(index, item[8], item, 8)
item[9].value = this.handleValueFormulaDBPL(index, item[9], item, 9)
item[10].value = this.handleValueFormulaDBPL(index, item[10], item, 10)
item[11].value = this.handleValueFormulaDBPL(index, item[11], item, 11)
item[12].value = this.handleValueFormulaDBPL(index, item[12], item, 12)
item[13].value = this.handleValueFormulaDBPL(index, item[13], item, 13)
item[14].value = this.handleValueFormulaDBPL(index, item[14], item, 14)
item[15].value = this.handleValueFormulaDBPL(index, item[15], item, 15)
item[16].value = this.handleValueFormulaDBPL(index, item[16], item, 16)
item[17].value = this.handleValueFormulaDBPL(index, item[17], item, 17)
item[18].value = this.handleValueFormulaDBPL(index, item[18], item, 18)
item[20] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
item[21] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
}
})
this.setState({ dbPL }, () => {
this.payloadPL(type)
})
}
payloadPL(type) {
let listPL = []
// console.log(this.state.dbPL)
this.state.dbPL.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
// if (item[7].value == "" || item[7].value == 0 || item[7].value == "0.0") {
item[7].value = this.handleValueFormulaDBPL(index, item[7], item, 7)
// }
// if (item[8].value == "" || item[8].value == 0 || item[8].value == "0.0") {
item[8].value = this.handleValueFormulaDBPL(index, item[8], item, 8)
// }
// if (item[9].value == "" || item[9].value == 0 || item[9].value == "0.0") {
item[9].value = this.handleValueFormulaDBPL(index, item[9], item, 9)
// }
// if (item[10].value == "" || item[10].value == 0 || item[10].value == "0.0") {
item[10].value = this.handleValueFormulaDBPL(index, item[10], item, 10)
// }
// if (item[11].value == "" || item[11].value == 0 || item[11].value == "0.0") {
item[11].value = this.handleValueFormulaDBPL(index, item[11], item, 11)
// }
// if (item[12].value == "" || item[12].value == 0 || item[12].value == "0.0") {
item[12].value = this.handleValueFormulaDBPL(index, item[12], item, 12)
// }
// if (item[13].value == "" || item[13].value == 0 || item[13].value == "0.0") {
item[13].value = this.handleValueFormulaDBPL(index, item[13], item, 13)
// }
// if (item[14].value == "" || item[14].value == 0 || item[14].value == "0.0") {
item[14].value = this.handleValueFormulaDBPL(index, item[14], item, 14)
// }
// if (item[15].value == "" || item[15].value == 0 || item[15].value == "0.0") {
item[15].value = this.handleValueFormulaDBPL(index, item[15], item, 15)
// }
// if (item[16].value == "" || item[16].value == 0 || item[16].value == "0.0") {
item[16].value = this.handleValueFormulaDBPL(index, item[16], item, 16)
// }
// if (item[17].value == "" || item[17].value == 0 || item[17].value == "0.0") {
item[17].value = this.handleValueFormulaDBPL(index, item[17], item, 17)
// }
// if (item[18].value == "" || item[18].value == 0 || item[18].value == "0.0") {
item[18].value = this.handleValueFormulaDBPL(index, item[18], item, 18)
// }
// if (item[20] == "" || item[20] == 0 || item[20] == "0.0") {
item[20] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 1}`, 20)
// }
// if (item[21] == "" || item[21] == 0 || item[21] == "0.0") {
item[21] = this.handleForecastDBPL(index, item, `${Number(this.state.periode.periode) + 2}`, 21)
// }
}
listPL.push(
{
"item_report_id": item[1],
"january": String(item[7].value == undefined ? item[7] : Number(item[7].value).toFixed(1)),
"february": String(item[8].value == undefined ? item[8] : Number(item[8].value).toFixed(1)),
"march": String(item[9].value == undefined ? item[9] : Number(item[9].value).toFixed(1)),
"april": String(item[10].value == undefined ? item[10] : Number(item[10].value).toFixed(1)),
"may": String(item[11].value == undefined ? item[11] : Number(item[11].value).toFixed(1)),
"june": String(item[12].value == undefined ? item[12] : Number(item[12].value).toFixed(1)),
"july": String(item[13].value == undefined ? item[13] : Number(item[13].value).toFixed(1)),
"august": String(item[14].value == undefined ? item[14] : Number(item[14].value).toFixed(1)),
"september": String(item[15].value == undefined ? item[15] : Number(item[15].value).toFixed(1)),
"october": String(item[16].value == undefined ? item[16] : Number(item[16].value).toFixed(1)),
"november": String(item[17].value == undefined ? item[17] : Number(item[17].value).toFixed(1)),
"december": String(item[18].value == undefined ? item[18] : Number(item[18].value).toFixed(1)),
"total_current_year": String(item[19]),
"total_next_year": String(item[20] != '' ? Number(item[20]).toFixed(1) : item[20]),
"total_more_year": String(item[21] != '' ? Number(item[21]).toFixed(1) : item[21]),
"notes": String(item[26]),
}
)
})
// console.log(listPL)
this.setState({ dbPL: listPL }, () => {
// if (this.state.submissionID != null) {
// this.createDBPL()
// }
if (type != undefined) {
if (type == 'PL') {
console.log('tarik sis')
this.createDBPL()
}
}
})
}
createDBPL() {
let payload = {
// "submission_id": this.state.submissionID,
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"report_id": 28,
"status": "submitted",
"profit_loss_id": this.state.PLID,
"profit_loss_ro": this.state.dbPL,
"quartal": this.state.quarter.value,
}
console.log(this.state.dbPL)
// console.log(JSON.stringify(payload))
api.create().createDBPLRO(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
render() {
const handleMaxDate = () => {
let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
......
......@@ -405,7 +405,11 @@ export default class ProfitLossROO extends Component {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
if (type == 'submitted') {
this.props.refresh('PL')
} else {
this.props.refresh()
}
this.props.onClickClose()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleTekTekTek: 0 }, () => {
......@@ -573,7 +577,11 @@ export default class ProfitLossROO extends Component {
if (response.ok) {
if (response.data.status === "success") {
this.props.onClickClose()
if (type == 'submitted') {
this.props.refresh('PL')
} else {
this.props.refresh()
}
// this.props.onClickClose()
// this.props.getReport()
} else {
......
......@@ -95,7 +95,18 @@ export default class SummaryOfTriputra extends Component {
// this.getRevision()
// }
})
} 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 })
}
})
}
......@@ -129,7 +140,18 @@ export default class SummaryOfTriputra extends Component {
this.getDataTable()
})
console.log(this.state.month)
} 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 })
}
})
}
......@@ -211,6 +233,7 @@ export default class SummaryOfTriputra extends Component {
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[0] === item.company_id)
......@@ -319,6 +342,16 @@ export default class SummaryOfTriputra extends Component {
})
console.log(dataTable)
this.setState({ dataTable, 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") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
}
......@@ -329,6 +362,7 @@ export default class SummaryOfTriputra extends Component {
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[0] === item.company_id)
......@@ -449,6 +483,16 @@ export default class SummaryOfTriputra extends Component {
})
console.log(dataTable)
this.setState({ dataTable, 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") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
}
......@@ -459,6 +503,7 @@ export default class SummaryOfTriputra extends Component {
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[0] === item.company_id)
......@@ -589,6 +634,16 @@ export default class SummaryOfTriputra extends Component {
})
console.log(dataTable);
this.setState({ dataTable, 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") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
}
......@@ -599,6 +654,7 @@ export default class SummaryOfTriputra extends Component {
console.log(response);
let dataTable = []
if (response.data) {
if (response.data.status === 'success') {
let res = [response.data.data]
console.log(res)
const handlePushChild = (item) => {
......@@ -776,6 +832,16 @@ export default class SummaryOfTriputra extends Component {
})
console.log()
this.setState({ dataTable, 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") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
}
......
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