Commit f847a4c7 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-' into 'master'

apivalidate

See merge request !780
parents 87326875 80c96750
......@@ -283,6 +283,7 @@ const create = (type = "") => {
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 uploadMonthlyReportOI = (body) => api.post('transaction/monthly_report_oi/import_monthly_report', body)
const validateSubmitReportMR = (body) => api.post('transaction/monthly_report/validate_save', body)
// MonthlyPL
const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body)
......@@ -508,7 +509,8 @@ const create = (type = "") => {
uploadMonthlyReportFAM,
uploadMonthlyReportTP,
uploadMonthlyReportOI,
getHierarkiMontlyReportCF
getHierarkiMontlyReportCF,
validateSubmitReportMR
}
}
......
......@@ -439,6 +439,63 @@ export default class BalanceSheetMR extends Component {
})
}
handleValidate() {
let data = []
// console.log(this.state.dataTable)
this.state.dataTable.map(i => {
data.push({
"item_report_id": i[1],
"rolling_outlook": i[6],
"master_budget": i[7],
"rolling_budget": i[8],
"actual": i[9],
"actual_previous_month": i[10],
"amount_act_vs_previous_month": i[11],
"percent_act_vs_previous_month": i[12],
"amount_act_vs_mb": i[13],
"percent_act_vs_mb": i[14],
"amount_act_vs_rb": i[15],
"percent_act_vs_rb": i[16],
"mtd_vs_previous_month": i[17],
"mtd_vs_mb": i[18],
"mtd_vs_rb": i[19]
})
})
// console.log(JSON.stringify(data))
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": "submitted",
"months": this.props.month.month_id,
"balance_sheet": data
}
api.create().validateSubmitReportMR(payload).then((response) => {
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result) {
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")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
render() {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta, type) => {
......@@ -1811,8 +1868,7 @@ export default class BalanceSheetMR extends Component {
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false })
// this.handleValidate()
this.handleValidate()
}, 100);
})
}}
......@@ -1846,7 +1902,7 @@ export default class BalanceSheetMR extends Component {
</button>
<button
type="button"
// disabled={this.state.buttonError}
disabled={this.state.buttonError}
onClick={() =>
this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
......@@ -1928,8 +1984,7 @@ export default class BalanceSheetMR extends Component {
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false })
// this.handleValidate()
this.handleValidate()
}, 100);
})
}}
......@@ -1963,7 +2018,7 @@ export default class BalanceSheetMR extends Component {
</button>
<button
type="button"
// disabled={this.state.buttonError}
disabled={this.state.buttonError}
onClick={() =>
this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
......
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