Commit 586a877b authored by Faisal Hamdi's avatar Faisal Hamdi

Merge branch 'faisal' into 'master'

update fam

See merge request !995
parents 647efe9e b475c848
......@@ -311,6 +311,7 @@ const create = (type = "") => {
const checkUploadMonthlyReportLOCF = (body) => api.post('transaction/locf/monthly_report/check_import', body)
const uploadMonthlyReportLOCF = (body) => api.post('transaction/locf/monthly_report/import_monthly_report', body)
const validateSubmitReportOI = (body) => api.post('transaction/operating_indicator/monthly_report/validate_save', body)
const validateSubmitReportFAM = (body) => api.post('transaction/fam/monthly_report/validate_save', body)
const getListUserSubcoMB = (periode) => api.get(`transaction/get_dashboard_sub_co/master_budget/${periode}`)
const getListUserSubcoMR = (months,periode) => api.get(`transaction/get_dashboard_sub_co/monthly_report/${periode}/${months}`)
......@@ -566,7 +567,8 @@ const create = (type = "") => {
approvalMonthly,
createPeriodeRevisionMonthly,
getListUserSubcoMB,
getListUserSubcoMR
getListUserSubcoMR,
validateSubmitReportFAM
}
}
......
......@@ -49,6 +49,8 @@ export default class FixedAssetsMovementMR extends Component {
updateBy: '-',
notesUpdate: '-',
get_for: 'view',
saveDraft: true,
buttonError: true,
viewOnly: true
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -205,10 +207,10 @@ export default class FixedAssetsMovementMR extends Component {
}
})
console.log(dataTable);
this.setState({ dataTable, loading: false, refresh: false }, () => {
this.setState({ dataTable, loading: false, refresh: false, buttonError: true, saveDraft: true }, () => {
this.setState({ loading: true, refresh: true })
setTimeout(() => {
this.setState({ loading: false, refresh: false })
this.setState({ loading: false, refresh: false, buttonError: true, saveDraft: true })
}, 200);
})
......@@ -223,7 +225,7 @@ export default class FixedAssetsMovementMR extends Component {
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, refresh: false })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, refresh: false, buttonError: true, saveDraft: true })
}
})
}
......@@ -322,8 +324,8 @@ export default class FixedAssetsMovementMR extends Component {
item.error
]
})
// console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, refresh: false }, () => {
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: true, editable: true, refresh: false }, () => {
this.state.dataTable.map(item => {
if (item[15].length > 0) {
console.log('masuk')
......@@ -434,6 +436,61 @@ export default class FixedAssetsMovementMR extends Component {
})
}
handleValidate() {
let data = []
let err = false
this.state.dataTable.map((i, index) => {
data.push({
"item_report_id": i[1],
"mtd_mb": i[6],
"mtd_rb": i[7],
"mtd_actual": i[8],
"act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(i[9]),
"act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(i[10]),
"act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(i[11]),
"act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(i[12])
})
})
// 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,
"fixed_asset_movement": data
}
// console.log(JSON.stringify(payload));
api.create().validateSubmitReportFAM(payload).then((response) => {
console.log(response.data.data.result)
console.log(err);
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result && err === 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")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
closeAlert() {
this.setState({ alert: false })
}
......@@ -703,8 +760,8 @@ export default class FixedAssetsMovementMR extends Component {
}
// console.log(dex)
// console.log(Number(tableMeta.columnIndex) + Number(type))
console.log(total);
console.log(dataTable2);
// console.log(total);
// console.log(dataTable2);
return total
}
......@@ -1409,8 +1466,8 @@ export default class FixedAssetsMovementMR extends Component {
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false })
// this.handleValidate()
// this.setState({ loading: false })
this.handleValidate()
}, 100);
})
}}
......@@ -1527,8 +1584,8 @@ export default class FixedAssetsMovementMR extends Component {
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false })
// this.handleValidate()
// this.setState({ loading: false })
this.handleValidate()
}, 100);
})
}}
......@@ -1563,7 +1620,7 @@ export default class FixedAssetsMovementMR 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: 'error' })
......
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