Commit 9f6e5df8 authored by Riri Novita's avatar Riri Novita

upload oi

parent 0770580a
...@@ -279,6 +279,7 @@ const create = (type = "") => { ...@@ -279,6 +279,7 @@ const create = (type = "") => {
const uploadMonthlyReportBS = (body) => api.post('transaction/monthly_report_bs/import_monthly_report', body) const uploadMonthlyReportBS = (body) => api.post('transaction/monthly_report_bs/import_monthly_report', body)
const uploadMonthlyReportFAM = (body) => api.post('transaction/monthly_report/fam/import_monthly_report', body) const uploadMonthlyReportFAM = (body) => api.post('transaction/monthly_report/fam/import_monthly_report', body)
const uploadMonthlyReportTP = (body) => api.post('transaction/monthly_report_tp/import_monthly_report', body) const uploadMonthlyReportTP = (body) => api.post('transaction/monthly_report_tp/import_monthly_report', body)
const uploadMonthlyReportOI = (body) => api.post('transaction/monthly_report_oi/import_monthly_report', body)
// MonthlyPL // MonthlyPL
const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body) const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body)
...@@ -500,6 +501,7 @@ const create = (type = "") => { ...@@ -500,6 +501,7 @@ const create = (type = "") => {
uploadMonthlyReportBS, uploadMonthlyReportBS,
uploadMonthlyReportFAM, uploadMonthlyReportFAM,
uploadMonthlyReportTP, uploadMonthlyReportTP,
uploadMonthlyReportOI,
getHierarkiMontlyReportCF getHierarkiMontlyReportCF
} }
} }
......
...@@ -285,37 +285,83 @@ export default class OperatingIndicatorMR extends Component { ...@@ -285,37 +285,83 @@ export default class OperatingIndicatorMR extends Component {
let total = 0 let total = 0
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
console.log(item); console.log(item);
// if (item.type_report_id != null) { if (item.type_report_id != null) {
// total += 1 total += 1
// } }
// return [ return [
// item.type_report_id, item.type_report_id,
// item.item_report_id, item.item_report_id,
// item.parent, item.parent,
// item.formula, item.formula,
// item.level, item.level,
// item.item_report, item.item_report,
// item.uom, item.uom,
// item.rolling_outlook, item.rolling_outlook,
// item.master_budget, item.master_budget,
// item.rolling_budget, item.rolling_budget,
// item.actual, item.actual,
// item.amount_act_vs_mb, item.amount_act_vs_mb,
// item.percent_act_vs_mb, item.percent_act_vs_mb,
// item.amount_act_vs_rb, item.amount_act_vs_rb,
// item.percent_act_vs_rb, item.percent_act_vs_rb,
// item.mtd_vs_mb, item.mtd_vs_mb,
// item.mtd_vs_rb, item.mtd_vs_rb,
// item.order, item.order,
// item.error item.error
// ] ]
}) })
// this.setState({ dataTable, dataLoaded: true, loading: false, templateNull : total > 0 ? true : false }) this.setState({ dataTable, dataLoaded: true, loading: false, templateNull : total > 0 ? true : false })
} }
} }
}) })
} }
uploadOI(type) {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
uom: String(i[6]),
rolling_outlook: String(Number(i[7]).toFixed(1)),
master_budget: String(Number(i[8]).toFixed(1)),
rolling_budget: String(Number(i[9]).toFixed(1)),
actual: String(Number(i[10]).toFixed(1)),
amount_act_vs_mb: String(Number(i[11]).toFixed(1)),
percent_act_vs_mb: String(Number(i[12]).toFixed(1)),
amount_act_vs_rb: String(Number(i[13]).toFixed(1)),
percent_act_vs_rb: String(Number(i[14]).toFixed(1)),
mtd_vs_mb: String(Number(i[15]).toFixed(1)),
mtd_vs_rb: String(Number(i[16]).toFixed(1)),
})
})
let body = {
company_id: this.props.data.company.company_id,
operating_indicator_id: this.props.data.operatingIndID,
periode: this.props.data.periode,
report_id: this.props.data.report_id,
status: type,
months: this.props.data.report_id === 22 ? 1 : 23 ? 2 : 24 ? 3 : 25 ? 4 : 27 ? 5 : 28 ? 6 : 29 ? 7 : 31 ? 8 : 32 ? 9 : 33 ? 10 : 35 ? 11 : 36 ? 12 : null,
monthly_report: data
}
console.log(data);
// // console.log(JSON.stringify(body))
api.create('UPLOAD').uploadMonthlyReportOI(body).then(response => {
// // console.log(response);
this.setState({ loading: false })
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
} else {
alert(response.data.status)
}
} else {
alert(response.problem)
}
})
}
closeAlert() { closeAlert() {
this.setState({ alert: false }) this.setState({ alert: false })
} }
...@@ -1401,7 +1447,7 @@ export default class OperatingIndicatorMR extends Component { ...@@ -1401,7 +1447,7 @@ export default class OperatingIndicatorMR extends Component {
onClick={() => onClick={() =>
this.setState({ loading: true, visibleOI: true }, () => { this.setState({ loading: true, visibleOI: true }, () => {
setTimeout(() => { setTimeout(() => {
this.getDataDetail() this.getItemHierarki()
}, 100) }, 100)
})} })}
> >
......
...@@ -1716,6 +1716,7 @@ export default class ProfitLossMR extends Component { ...@@ -1716,6 +1716,7 @@ export default class ProfitLossMR extends Component {
</MuiThemeProvider> </MuiThemeProvider>
)} )}
</div> </div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
{/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null : {/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? */} (this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? */}
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
......
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