Commit da6b4f59 authored by Rifka Kurnia's avatar Rifka Kurnia

Merge branch 'rifka' into 'master'

Rifka

See merge request !1081
parents 3f56b6b7 cba56b9c
...@@ -264,6 +264,7 @@ const create = (type = "") => { ...@@ -264,6 +264,7 @@ const create = (type = "") => {
const getReportFRLastMR = (body) => api.post('/transaction/summary_ratio/monthly_report_last_year/get_report_hierarki', body) const getReportFRLastMR = (body) => api.post('/transaction/summary_ratio/monthly_report_last_year/get_report_hierarki', body)
const getReportBSSuma = (body) => api.post('/transaction/summary_balance_sheet/summary/get_report_hierarki', body) const getReportBSSuma = (body) => api.post('/transaction/summary_balance_sheet/summary/get_report_hierarki', body)
const getDashboardCAT = (body) => api.post('/dashboard/cat', body) const getDashboardCAT = (body) => api.post('/dashboard/cat', body)
const getHierarkiReportHistorical = (body) => api.post('/transaction/historical/get_historical_hierarki', body)
//CASH FLOW //CASH FLOW
const getDetailReportCF = (body) => api.post('/transaction/cash_flow/master_budget/get_report_hierarki', body) const getDetailReportCF = (body) => api.post('/transaction/cash_flow/master_budget/get_report_hierarki', body)
...@@ -635,7 +636,8 @@ const create = (type = "") => { ...@@ -635,7 +636,8 @@ const create = (type = "") => {
getHierarkiCreateReportPLMR, getHierarkiCreateReportPLMR,
createReportPLMB, createReportPLMB,
createReportPLMR, createReportPLMR,
getPLID getPLID,
getHierarkiReportHistorical
} }
} }
......
...@@ -1351,11 +1351,33 @@ export default class SubHolding extends Component { ...@@ -1351,11 +1351,33 @@ export default class SubHolding extends Component {
let quarter_actual = item.cash_flow.quarter_actual == '' ? 0 : item.cash_flow.quarter_actual let quarter_actual = item.cash_flow.quarter_actual == '' ? 0 : item.cash_flow.quarter_actual
let quarter = item.cash_flow.quarter == '' ? 0 : item.cash_flow.quarter let quarter = item.cash_flow.quarter == '' ? 0 : item.cash_flow.quarter
let persenQuarter = Number(quarter_actual / quarter) // let persenQuarter = Number(quarter_actual / quarter)
let persenQuarter = 0
if (quarter < 0) {
if (quarter_actual >= quarter) {
persenQuarter = (quarter - quarter_actual) / quarter + 1
} else {
persenQuarter = (quarter - quarter_actual) / quarter
}
}
else {
persenQuarter = quarter_actual / quarter
}
let fy_actual = item.cash_flow.fy_actual == '' ? 0 : item.cash_flow.fy_actual let fy_actual = item.cash_flow.fy_actual == '' ? 0 : item.cash_flow.fy_actual
let fy = item.cash_flow.fy == '' ? 0 : item.cash_flow.fy let fy = item.cash_flow.fy == '' ? 0 : item.cash_flow.fy
let persenFy = Number(fy_actual / fy) // let persenFy = Number(fy_actual / fy)
let persenFy = 0
if (fy < 0) {
if (fy_actual >= fy) {
persenFy = (fy - fy_actual) / fy + 1
} else {
persenFy = (fy - fy_actual) / fy
}
}
else {
persenFy = fy_actual / fy
}
dbSumaCF.push([ dbSumaCF.push([
item.id, item.id,
......
...@@ -8,6 +8,7 @@ import TableSummaryTriputra from './TableSummaryTriputra' ...@@ -8,6 +8,7 @@ import TableSummaryTriputra from './TableSummaryTriputra'
import { PropagateLoader } from 'react-spinners' import { PropagateLoader } from 'react-spinners'
import ReactTooltip from 'react-tooltip' import ReactTooltip from 'react-tooltip'
import Images from '../../assets/Images' import Images from '../../assets/Images'
import { format } from 'date-fns';
export default class SummaryOfTriputra extends Component { export default class SummaryOfTriputra extends Component {
constructor(props) { constructor(props) {
...@@ -29,7 +30,8 @@ export default class SummaryOfTriputra extends Component { ...@@ -29,7 +30,8 @@ export default class SummaryOfTriputra extends Component {
], ],
report: null, report: null,
loading: false, loading: false,
previewTable: false previewTable: false,
listMonths: null,
} }
} }
...@@ -38,8 +40,10 @@ export default class SummaryOfTriputra extends Component { ...@@ -38,8 +40,10 @@ export default class SummaryOfTriputra extends Component {
} }
componentDidMount() { componentDidMount() {
this.getDetailUser() // this.getDetailUser()
this.setState({ report: this.state.reportType[0], loading: true }) this.setState({ report: this.state.reportType[0], loading: true })
this.getPeriode()
// this.getMonth()
} }
getDetailUser() { getDetailUser() {
...@@ -117,20 +121,21 @@ export default class SummaryOfTriputra extends Component { ...@@ -117,20 +121,21 @@ export default class SummaryOfTriputra extends Component {
getPeriode() { getPeriode() {
api.create().getPeriodeTransaction().then(response => { api.create().getPeriodeTransaction().then(response => {
let currentYear = new Date().getFullYear() let currentYear = new Date().getFullYear()
// console.log(currentYear) console.log(currentYear)
console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
let data = [] let data = []
response.data.data.map((item) => { response.data.data.map((item) => {
if (this.state.isApprover) { // if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) { if (item >= 2000 && item <= (Number(currentYear))) {
data.push(item)
}
} else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
data.push(item) data.push(item)
} }
} // } else {
// if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
// data.push(item)
// }
// }
}) })
let periodeData = data.map((item) => { let periodeData = data.map((item) => {
return { return {
...@@ -141,15 +146,17 @@ export default class SummaryOfTriputra extends Component { ...@@ -141,15 +146,17 @@ export default class SummaryOfTriputra extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, getOptionLabel: (option) => option.periode,
}; };
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod) // let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
let periode = String(Number(currentYear))
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode) let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// console.log(data) // console.log(data)
// console.log(this.state.latestPeriode) // console.log(this.state.latestPeriode)
// console.log(periodeData) // console.log(periodeData)
// console.log(index) console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => { this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index], loading: false }, () => {
// this.getDataTable() // this.getDataTable()
this.getSubmission() this.getMonth()
// this.getSubmission()
// if (this.state.isApprover === true) { // if (this.state.isApprover === true) {
// this.getCompanySubmitted() // this.getCompanySubmitted()
// } else { // } else {
...@@ -161,6 +168,40 @@ export default class SummaryOfTriputra extends Component { ...@@ -161,6 +168,40 @@ export default class SummaryOfTriputra extends Component {
}) })
} }
getMonth() {
api.create().getMonthTransaction().then(response => {
let dateNow = new Date
let month = format(dateNow, 'MMMM')
console.log(month)
console.log(response)
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
let monthData = data.map((item) => {
return {
month_id: item.month_id,
month_name: item.month_name
}
})
let defaultProps = {
options: monthData,
getOptionLabel: (option) => option.month_name,
};
// let index = data.sort((a, b) => a - b).findIndex((val) => val == bulan)
// this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] })
let index = data.findIndex((val) => val.month_name == month)
console.log(index)
console.log(monthData)
this.setState({ listMonths: defaultProps, month: index == -1 ? monthData[0].month_name : monthData[index].month_name }, () => {
this.getDataTable()
})
console.log(this.state.month)
}
}
})
}
getReportType() { getReportType() {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
...@@ -222,184 +263,188 @@ export default class SummaryOfTriputra extends Component { ...@@ -222,184 +263,188 @@ export default class SummaryOfTriputra extends Component {
} }
getDataTable() { getDataTable() {
let payload = { // let payload = {
"report_id": this.state.report.value, // "report_id": this.state.report.value,
"revision": this.state.lastRevision, // "revision": this.state.lastRevision,
// "periode": this.state.periode.periode,
// "company_id": this.state.company.company_id,
// "submission_id": this.state.submissionID
// }
let newPayload = {
"periode": this.state.periode.periode, "periode": this.state.periode.periode,
"company_id": this.state.company.company_id, "report_type":"historical"
"submission_id": this.state.submissionID
} }
if (this.state.report.value === 1) { if (this.state.report.value === 1) {
api.create().getDetailReportMB(payload).then(response => { // api.create().getDetailReportMB(payload).then(response => {
// console.log(response); // // console.log(response);
// console.log(payload) // // console.log(payload)
let dataTable = [] let dataTable = []
if (response.data) { // if (response.data) {
let res = response.data.data // let res = response.data.data
const handlePushChild = (item) => { // const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) // let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) { // if (indexIDzz === -1) {
dataTable.push([ // dataTable.push([
item.type_report_id, // item.type_report_id,
item.id, // item.id,
item.parent, // item.parent,
item.formula, // item.formula,
item.level, // item.level,
item.description, // item.description,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before, // item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january, // item.profit_loss.january,
item.profit_loss.february, // item.profit_loss.february,
item.profit_loss.march, // item.profit_loss.march,
item.profit_loss.april, // item.profit_loss.april,
item.profit_loss.may, // item.profit_loss.may,
item.profit_loss.june, // item.profit_loss.june,
item.profit_loss.july, // item.profit_loss.july,
item.profit_loss.august, // item.profit_loss.august,
item.profit_loss.september, // item.profit_loss.september,
item.profit_loss.october, // item.profit_loss.october,
item.profit_loss.november, // item.profit_loss.november,
item.profit_loss.december, // item.profit_loss.december,
item.profit_loss.total_current_year, // item.profit_loss.total_current_year,
item.profit_loss.total_next_year, // item.profit_loss.total_next_year,
item.profit_loss.total_more_year, // item.profit_loss.total_more_year,
item.order // item.order
]) // ])
} // }
if (item.children !== null) { // if (item.children !== null) {
if (item.children.length > 0) { // if (item.children.length > 0) {
item.children.map((items, indexs) => { // item.children.map((items, indexs) => {
handlePushChild(items) // handlePushChild(items)
}) // })
} // }
} // }
} // }
res.map((item, index) => { // res.map((item, index) => {
dataTable.push([ // dataTable.push([
item.type_report_id, // item.type_report_id,
item.id, // item.id,
item.parent, // item.parent,
item.formula, // item.formula,
item.level, // item.level,
item.description, // item.description,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before, // item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january, // item.profit_loss.january,
item.profit_loss.february, // item.profit_loss.february,
item.profit_loss.march, // item.profit_loss.march,
item.profit_loss.april, // item.profit_loss.april,
item.profit_loss.may, // item.profit_loss.may,
item.profit_loss.june, // item.profit_loss.june,
item.profit_loss.july, // item.profit_loss.july,
item.profit_loss.august, // item.profit_loss.august,
item.profit_loss.september, // item.profit_loss.september,
item.profit_loss.october, // item.profit_loss.october,
item.profit_loss.november, // item.profit_loss.november,
item.profit_loss.december, // item.profit_loss.december,
item.profit_loss.total_current_year, // item.profit_loss.total_current_year,
item.profit_loss.total_next_year, // item.profit_loss.total_next_year,
item.profit_loss.total_more_year, // item.profit_loss.total_more_year,
item.order // item.order
]) // ])
if (item.children !== null) { // if (item.children !== null) {
if (item.children.length > 0) { // if (item.children.length > 0) {
item.children.map((items, indexs) => { // item.children.map((items, indexs) => {
handlePushChild(items) // handlePushChild(items)
}) // })
} // }
} // }
}) // })
// console.log(dataTable) // // console.log(dataTable)
this.setState({ dataTable, previewTable: true, loading: false, previewDownload: true }) this.setState({ dataTable, previewTable: true, loading: false, previewDownload: true })
} else { // } else {
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false }) // this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
} // }
}) // })
} else if (this.state.report.value === 2) { } else if (this.state.report.value === 2) {
api.create().getDetailReportMB(payload).then(response => { // api.create().getDetailReportMB(payload).then(response => {
console.log(payload); // console.log(payload);
console.log(response); // console.log(response);
let dataTable = [] let dataTable = []
if (response.data) { // if (response.data) {
let res = response.data.data // let res = response.data.data
const handlePushChild = (item) => { // const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) // let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) { // if (indexIDzz === -1) {
dataTable.push([ // dataTable.push([
item.type_report_id, // item.type_report_id,
item.id, // item.id,
item.parent, // item.parent,
item.formula, // item.formula,
item.level, // item.level,
item.description, // item.description,
item.balance_sheet.total_actual_before === null ? "0.0" : item.balance_sheet.total_actual_before === "" ? "0.0" : item.balance_sheet.total_actual_before, // item.balance_sheet.total_actual_before === null ? "0.0" : item.balance_sheet.total_actual_before === "" ? "0.0" : item.balance_sheet.total_actual_before,
Number(item.balance_sheet.january).toFixed(1), // Number(item.balance_sheet.january).toFixed(1),
Number(item.balance_sheet.february).toFixed(1), // Number(item.balance_sheet.february).toFixed(1),
Number(item.balance_sheet.march).toFixed(1), // Number(item.balance_sheet.march).toFixed(1),
Number(item.balance_sheet.april).toFixed(1), // Number(item.balance_sheet.april).toFixed(1),
Number(item.balance_sheet.may).toFixed(1), // Number(item.balance_sheet.may).toFixed(1),
Number(item.balance_sheet.june).toFixed(1), // Number(item.balance_sheet.june).toFixed(1),
Number(item.balance_sheet.july).toFixed(1), // Number(item.balance_sheet.july).toFixed(1),
Number(item.balance_sheet.august).toFixed(1), // Number(item.balance_sheet.august).toFixed(1),
Number(item.balance_sheet.september).toFixed(1), // Number(item.balance_sheet.september).toFixed(1),
Number(item.balance_sheet.october).toFixed(1), // Number(item.balance_sheet.october).toFixed(1),
Number(item.balance_sheet.november).toFixed(1), // Number(item.balance_sheet.november).toFixed(1),
Number(item.balance_sheet.december).toFixed(1), // Number(item.balance_sheet.december).toFixed(1),
Number(item.balance_sheet.total_current_year).toFixed(1), // Number(item.balance_sheet.total_current_year).toFixed(1),
Number(item.balance_sheet.total_next_year).toFixed(1), // Number(item.balance_sheet.total_next_year).toFixed(1),
Number(item.balance_sheet.total_more_year).toFixed(1), // Number(item.balance_sheet.total_more_year).toFixed(1),
item.order, // item.order,
item.condition_it_should_be, // item.condition_it_should_be,
item.condition_if_wrong // item.condition_if_wrong
]) // ])
} // }
if (item.children !== null) { // if (item.children !== null) {
if (item.children.length > 0) { // if (item.children.length > 0) {
item.children.map((items, indexs) => { // item.children.map((items, indexs) => {
handlePushChild(items) // handlePushChild(items)
}) // })
} // }
} // }
} // }
res.map((item, index) => { // res.map((item, index) => {
dataTable.push([ // dataTable.push([
item.type_report_id, // item.type_report_id,
item.id, // item.id,
item.parent, // item.parent,
item.formula, // item.formula,
item.level, // item.level,
item.description, // item.description,
item.balance_sheet.total_actual_before === null ? "0.0" : item.balance_sheet.total_actual_before === "" ? "0.0" : item.balance_sheet.total_actual_before, // item.balance_sheet.total_actual_before === null ? "0.0" : item.balance_sheet.total_actual_before === "" ? "0.0" : item.balance_sheet.total_actual_before,
Number(item.balance_sheet.january).toFixed(1), // Number(item.balance_sheet.january).toFixed(1),
Number(item.balance_sheet.february).toFixed(1), // Number(item.balance_sheet.february).toFixed(1),
Number(item.balance_sheet.march).toFixed(1), // Number(item.balance_sheet.march).toFixed(1),
Number(item.balance_sheet.april).toFixed(1), // Number(item.balance_sheet.april).toFixed(1),
Number(item.balance_sheet.may).toFixed(1), // Number(item.balance_sheet.may).toFixed(1),
Number(item.balance_sheet.june).toFixed(1), // Number(item.balance_sheet.june).toFixed(1),
Number(item.balance_sheet.july).toFixed(1), // Number(item.balance_sheet.july).toFixed(1),
Number(item.balance_sheet.august).toFixed(1), // Number(item.balance_sheet.august).toFixed(1),
Number(item.balance_sheet.september).toFixed(1), // Number(item.balance_sheet.september).toFixed(1),
Number(item.balance_sheet.october).toFixed(1), // Number(item.balance_sheet.october).toFixed(1),
Number(item.balance_sheet.november).toFixed(1), // Number(item.balance_sheet.november).toFixed(1),
Number(item.balance_sheet.december).toFixed(1), // Number(item.balance_sheet.december).toFixed(1),
Number(item.balance_sheet.total_current_year).toFixed(1), // Number(item.balance_sheet.total_current_year).toFixed(1),
Number(item.balance_sheet.total_next_year).toFixed(1), // Number(item.balance_sheet.total_next_year).toFixed(1),
Number(item.balance_sheet.total_more_year).toFixed(1), // Number(item.balance_sheet.total_more_year).toFixed(1),
item.order, // item.order,
item.condition_it_should_be, // item.condition_it_should_be,
item.condition_if_wrong // item.condition_if_wrong
]) // ])
if (item.children !== null) { // if (item.children !== null) {
if (item.children.length > 0) { // if (item.children.length > 0) {
item.children.map((items, indexs) => { // item.children.map((items, indexs) => {
handlePushChild(items) // handlePushChild(items)
}) // })
} // }
} // }
}) // })
this.setState({ dataTable, previewTable: true, loading: false, previewDownload: true }) this.setState({ dataTable, previewTable: true, loading: false, previewDownload: true })
} else { // } else {
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false }) // this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
} // }
}) // })
} else if (this.state.report.value === 3) { } else if (this.state.report.value === 3) {
// api.create().getReportHierarkiPL(payload).then(response => { // api.create().getReportHierarkiPL(payload).then(response => {
// // console.log(response); // // console.log(response);
...@@ -488,9 +533,9 @@ export default class SummaryOfTriputra extends Component { ...@@ -488,9 +533,9 @@ export default class SummaryOfTriputra extends Component {
// } // }
// }) // })
} else if (this.state.report.value === 4) { } else if (this.state.report.value === 4) {
// api.create().getReportHierarkiFR(payload).then(response => { api.create().getHierarkiReportHistorical(newPayload).then(response => {
// console.log(payload); console.log(newPayload);
// console.log(response); console.log(response);
let dataTable = [] let dataTable = []
// if (response.data) { // if (response.data) {
// let res = response.data.data // let res = response.data.data
...@@ -573,7 +618,7 @@ export default class SummaryOfTriputra extends Component { ...@@ -573,7 +618,7 @@ export default class SummaryOfTriputra extends Component {
// } else { // } else {
// this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false }) // this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
// } // }
// }) })
} }
} }
...@@ -675,7 +720,8 @@ export default class SummaryOfTriputra extends Component { ...@@ -675,7 +720,8 @@ export default class SummaryOfTriputra extends Component {
getOptionLabel={(option) => titleCase(option.label)} getOptionLabel={(option) => titleCase(option.label)}
id="typereport" id="typereport"
onChange={(event, newInputValue) => this.setState({ report: newInputValue, loading: true, previewTable: false }, () => { onChange={(event, newInputValue) => this.setState({ report: newInputValue, loading: true, previewTable: false }, () => {
this.getSubmission() // this.getSubmission()
this.getDataTable()
})} })}
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
...@@ -688,7 +734,8 @@ export default class SummaryOfTriputra extends Component { ...@@ -688,7 +734,8 @@ export default class SummaryOfTriputra extends Component {
{...this.state.listPeriode} {...this.state.listPeriode}
id="periode" id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true, previewTable: false }, () => { onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true, previewTable: false }, () => {
this.getSubmission() // this.getSubmission()
this.getDataTable()
})} })}
disabled={this.state.intent === 'Home' ? true : false} disabled={this.state.intent === 'Home' ? true : false}
disableClearable disableClearable
...@@ -699,6 +746,20 @@ export default class SummaryOfTriputra extends Component { ...@@ -699,6 +746,20 @@ export default class SummaryOfTriputra extends Component {
value={this.state.periode} value={this.state.periode}
/> />
</div> </div>
<div style={{ marginTop: 15 }}>
<Autocomplete
{...this.state.listMonths}
// getOptionLabel={(option) => titleCase(option.label)}
id="months"
onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true, previewTable: false }, () => {
this.getDataTable()
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Months" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.month}
/>
</div>
</div> </div>
<div> <div>
<div style={{ display: 'flex', justifyContent: 'space-between', padding: '0px 20px 10px 20px' }}> <div style={{ display: 'flex', justifyContent: 'space-between', padding: '0px 20px 10px 20px' }}>
......
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