Commit 3f12c134 authored by Deni Rinaldi's avatar Deni Rinaldi

subholdingg

parent b45cbae1
...@@ -20,13 +20,14 @@ export default class SubHolding extends Component { ...@@ -20,13 +20,14 @@ export default class SubHolding extends Component {
listPeriode: null, listPeriode: null,
periode: null, periode: null,
reportType: [ reportType: [
{ value: 'DB Balance Sheet', label: 'DB Balance Sheet' }, { value: 1, label: 'DB Balance Sheet' },
{ value: 'DB Profit & Loss', label: 'DB Profit & Loss' }, { value: 2, label: 'DB Profit & Loss' },
{ value: 'DB Balance Sheet Detail', label: 'DB Balance Sheet Detail' }, { value: 3, label: 'DB Balance Sheet Detail' },
{ value: 'DB Ratio', label: 'DB Ratio' }, { value: 4, label: 'DB Ratio' },
], ],
report: null, report: null,
loading: false loading: false,
previewTable: false
} }
} }
...@@ -145,7 +146,8 @@ export default class SubHolding extends Component { ...@@ -145,7 +146,8 @@ export default class SubHolding extends Component {
// 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] }, () => {
this.getDataTable() // this.getDataTable()
this.getSubmission()
// if (this.state.isApprover === true) { // if (this.state.isApprover === true) {
// this.getCompanySubmitted() // this.getCompanySubmitted()
// } else { // } else {
...@@ -157,97 +159,208 @@ export default class SubHolding extends Component { ...@@ -157,97 +159,208 @@ export default class SubHolding extends Component {
}) })
} }
async getDataTable() { getSubmission() {
this.setState({ loading: true })
let payload = { let payload = {
"report_id": 1,
"revision": 0,
"periode": this.state.periode.periode,
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
"submission_id": null "periode": this.state.periode.periode,
"is_approver": true
} }
let response = await api.create().getDetailReportMB(payload) api.create().getSubmission(payload).then(response => {
console.log(response); console.log(response)
let dataTable = [] if (response.data) {
if (response.data) { if (response.data.status === "success") {
let res = response.data.data this.setState({
const handlePushChild = (item) => { submissionID: response.data.data.submission_id,
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) lastRevision: response.data.data.last_revision,
if (indexIDzz === -1) { }, () => {
dataTable.push([ this.getDataTable()
item.type_report_id, })
item.id, } else {
item.parent, this.setState({ submissionID: null, loading: false })
item.formula,
item.level,
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,
Number(item.balance_sheet.january).toFixed(1),
Number(item.balance_sheet.february).toFixed(1),
Number(item.balance_sheet.march).toFixed(1),
Number(item.balance_sheet.april).toFixed(1),
Number(item.balance_sheet.may).toFixed(1),
Number(item.balance_sheet.june).toFixed(1),
Number(item.balance_sheet.july).toFixed(1),
Number(item.balance_sheet.august).toFixed(1),
Number(item.balance_sheet.september).toFixed(1),
Number(item.balance_sheet.october).toFixed(1),
Number(item.balance_sheet.november).toFixed(1),
Number(item.balance_sheet.december).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_more_year).toFixed(1),
item.order,
item.condition_it_should_be,
item.condition_if_wrong
])
} }
if (item.children !== null) { }
if (item.children.length > 0) { })
item.children.map((items, indexs) => { }
handlePushChild(items)
}) getDataTable() {
let payload = {
"report_id": this.state.report.value,
"revision": this.state.lastRevision,
"periode": this.state.periode.periode,
"company_id": this.state.company.company_id,
"submission_id": this.state.submissionID
}
api.create().getDetailReportMB(payload).then(response => {
console.log(response);
let dataTable = []
if (this.state.report.value === 1) {
if (response.data) {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.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.february).toFixed(1),
Number(item.balance_sheet.march).toFixed(1),
Number(item.balance_sheet.april).toFixed(1),
Number(item.balance_sheet.may).toFixed(1),
Number(item.balance_sheet.june).toFixed(1),
Number(item.balance_sheet.july).toFixed(1),
Number(item.balance_sheet.august).toFixed(1),
Number(item.balance_sheet.september).toFixed(1),
Number(item.balance_sheet.october).toFixed(1),
Number(item.balance_sheet.november).toFixed(1),
Number(item.balance_sheet.december).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_more_year).toFixed(1),
item.order,
item.condition_it_should_be,
item.condition_if_wrong
])
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
} }
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
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,
Number(item.balance_sheet.january).toFixed(1),
Number(item.balance_sheet.february).toFixed(1),
Number(item.balance_sheet.march).toFixed(1),
Number(item.balance_sheet.april).toFixed(1),
Number(item.balance_sheet.may).toFixed(1),
Number(item.balance_sheet.june).toFixed(1),
Number(item.balance_sheet.july).toFixed(1),
Number(item.balance_sheet.august).toFixed(1),
Number(item.balance_sheet.september).toFixed(1),
Number(item.balance_sheet.october).toFixed(1),
Number(item.balance_sheet.november).toFixed(1),
Number(item.balance_sheet.december).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_more_year).toFixed(1),
item.order,
item.condition_it_should_be,
item.condition_if_wrong
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
this.setState({ dataTable, previewTable: true, loading: false })
} else {
this.setState({ dataTable: [], previewTable: false, loading: false })
} }
} } else if (this.state.report.value === 2) {
res.map((item, index) => { if (response.data) {
dataTable.push([ let res = response.data.data
item.type_report_id, const handlePushChild = (item) => {
item.id, let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
item.parent, if (indexIDzz === -1) {
item.formula, dataTable.push([
item.level, item.type_report_id,
item.description, item.id,
item.balance_sheet.total_actual_before === null ? "0.0" : item.balance_sheet.total_actual_before === "" ? "0.0" : item.balance_sheet.total_actual_before, item.parent,
Number(item.balance_sheet.january).toFixed(1), item.formula,
Number(item.balance_sheet.february).toFixed(1), item.level,
Number(item.balance_sheet.march).toFixed(1), item.description,
Number(item.balance_sheet.april).toFixed(1), item.profit_loss.notes === "" ? null : item.profit_loss.notes,
Number(item.balance_sheet.may).toFixed(1), item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
Number(item.balance_sheet.june).toFixed(1), item.profit_loss.january,
Number(item.balance_sheet.july).toFixed(1), item.profit_loss.february,
Number(item.balance_sheet.august).toFixed(1), item.profit_loss.march,
Number(item.balance_sheet.september).toFixed(1), item.profit_loss.april,
Number(item.balance_sheet.october).toFixed(1), item.profit_loss.may,
Number(item.balance_sheet.november).toFixed(1), item.profit_loss.june,
Number(item.balance_sheet.december).toFixed(1), item.profit_loss.july,
Number(item.balance_sheet.total_current_year).toFixed(1), item.profit_loss.august,
Number(item.balance_sheet.total_next_year).toFixed(1), item.profit_loss.september,
Number(item.balance_sheet.total_more_year).toFixed(1), item.profit_loss.october,
item.order, item.profit_loss.november,
item.condition_it_should_be, item.profit_loss.december,
item.condition_if_wrong item.profit_loss.total_current_year,
]) item.profit_loss.total_next_year,
if (item.children !== null) { item.profit_loss.total_more_year,
if (item.children.length > 0) { item.order
item.children.map((items, indexs) => { ])
handlePushChild(items) }
}) if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
} }
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
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.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
item.order
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
// console.log(dataTable)
this.setState({ dataTable, previewTable: true, loading: false })
} else {
this.setState({ dataTable: [], previewTable: false, loading: false })
} }
}) } else {
this.setState({ dataTable, loading: false }) this.setState({ dataTable: [], previewTable: false, loading: false })
} else { }
} })
} }
render() { render() {
...@@ -276,9 +389,11 @@ export default class SubHolding extends Component { ...@@ -276,9 +389,11 @@ export default class SubHolding extends Component {
<div style={{ marginTop: 20 }}> <div style={{ marginTop: 20 }}>
<Autocomplete <Autocomplete
options={this.state.reportType} options={this.state.reportType}
getOptionLabel={(option) => titleCase(option.value)} getOptionLabel={(option) => titleCase(option.label)}
id="typereport" id="typereport"
onChange={(event, newInputValue) => this.setState({ report: newInputValue })} onChange={(event, newInputValue) => this.setState({ report: newInputValue }, () => {
this.getSubmission()
})}
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Report Type" margin="normal" style={{ marginTop: 7 }} />} renderInput={(params) => <TextField {...params} label="Report Type" margin="normal" style={{ marginTop: 7 }} />}
...@@ -290,7 +405,9 @@ export default class SubHolding extends Component { ...@@ -290,7 +405,9 @@ export default class SubHolding extends Component {
{...this.state.listCompany} {...this.state.listCompany}
id="company" id="company"
disabled={this.state.intent === 'Home' ? true : false} disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue })} onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.getSubmission()
})}
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />} renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
...@@ -302,12 +419,7 @@ export default class SubHolding extends Component { ...@@ -302,12 +419,7 @@ export default class SubHolding extends Component {
{...this.state.listPeriode} {...this.state.listPeriode}
id="periode" id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
// if (this.state.isApprover === true) { this.getSubmission()
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }
})} })}
disabled={this.state.intent === 'Home' ? true : false} disabled={this.state.intent === 'Home' ? true : false}
disableClearable disableClearable
...@@ -321,12 +433,12 @@ export default class SubHolding extends Component { ...@@ -321,12 +433,12 @@ export default class SubHolding extends Component {
</div> </div>
<div style={{ marginTop: 20 }}> <div style={{ marginTop: 20 }}>
{this.state.loading && loadingComponent} {this.state.loading && loadingComponent}
{!this.state.loading && ( {this.state.previewTable && (
<TableSubHolding <TableSubHolding
width={this.props.width} width={this.props.width}
height={this.props.height} height={this.props.height}
open={this.props.open} open={this.props.open}
type={1} type={this.state.report ? this.state.report.value : 1}
dataTable={this.state.dataTable} dataTable={this.state.dataTable}
periode={this.state.periode ? this.state.periode.periode : null} periode={this.state.periode ? this.state.periode.periode : null}
/> />
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment