Commit a33da690 authored by rifkaki's avatar rifkaki

olpa tp control should be nil

parent a4addf8b
......@@ -62,10 +62,10 @@ export default class TaxPlanningOLPA extends Component {
}
componentDidMount() {
this.getItemHierarki()
// this.getItemHierarki()
this.getSettingControl()
this.lastUpdate()
this.handleViewOnly()
console.log(this.props.isApprover)
}
handleViewOnly() {
......@@ -104,11 +104,44 @@ export default class TaxPlanningOLPA extends Component {
handleGetFor(type) {
console.log(type)
this.setState({get_for: type}, () => {
this.getItemHierarki()
this.getSettingControl()
this.lastUpdate()
})
}
getSettingControl() {
let body = {
group: 'THRESHOLD_CONTROL',
company_id: this.props.company.company_id,
type: 'TAX_PLANNING'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({
minValue: response.data.data[0] ? response.data.data[0].min_value : null,
maxValue: response.data.data[0] ? response.data.data[0].max_value : null,
}, () => {
this.getItemHierarki()
})
} 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 })
}
})
}
lastUpdate(){
let payload = {
"outlook_pa_id": this.props.outlook_pa_id,
......@@ -672,6 +705,8 @@ export default class TaxPlanningOLPA extends Component {
handleValidate() {
let data = []
let errorContrl = this.state.buttonError
let editAble = this.state.editAble
// console.log(this.state.dataTable)
this.state.dataTable.map(i => {
// console.log(i[0])
......@@ -750,6 +785,18 @@ export default class TaxPlanningOLPA extends Component {
}
})
if (String(i[8]) == "Control (should be nil)") {
this.setState({ loading: true })
if ((Number(i[19].tbf) < Number(this.state.minValue) || Number(i[19].tbf) > Number(this.state.maxValue)) || (Number(i[20].tbf) < Number(this.state.minValue) || Number(i[20].tbf) > Number(this.state.maxValue)) || (Number(i[21]) < Number(this.state.minValue) || Number(i[21]) > Number(this.state.maxValue))) {
errorContrl = true
editAble = true
}
else {
errorContrl = false
editAble = false
}
}
})
// console.log(JSON.stringify(data))
let payload = {
......@@ -762,10 +809,25 @@ export default class TaxPlanningOLPA extends Component {
}
api.create().validateSubmitReportOLPA(payload).then((response) => {
console.log(response)
if (response.data.data.result) {
this.setState({ loading: false, buttonError: false, editable: false })
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result && errorContrl === false && editAble === 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({ loading: false, buttonError: true, editable: true })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
......@@ -788,7 +850,7 @@ export default class TaxPlanningOLPA extends Component {
async downloadAllData() {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/outlook_pa/export_outlook_pa?outlook_pa_id=${this.props.outlook_pa_id}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
let sub_null = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/outlook_pa/export_outlook_pa?outlook_pa_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
// console.log(url);
console.log(url);
let res = await fetch(
this.props.outlook_pa_id == null ? sub_null : url
)
......@@ -904,7 +966,7 @@ export default class TaxPlanningOLPA extends Component {
if (dataTable2[indexID][24] == tableMeta.rowData[24]) {
anjay.push(0)
} else {
let data = dex == 1 ? dataTable2[indexID][tableMeta.columnIndex].tbc : dex == 2 ? dataTable2[indexID][tableMeta.columnIndex].fcp : dataTable2[indexID][tableMeta.columnIndex].tbf
let data = dex == 1 ? dataTable2[indexID][tableMeta.columnIndex].tbc : dex == 2 ? dataTable2[indexID][tableMeta.columnIndex].fcp : dex == 3 ? dataTable2[indexID][tableMeta.columnIndex].tbf : dataTable2[indexID][tableMeta.columnIndex]
let valuezz = data.value == undefined ? data : data.value
anjay.push(valuezz == "" ? 0 : valuezz)
}
......@@ -2777,6 +2839,44 @@ export default class TaxPlanningOLPA extends Component {
</LightTooltip>
:
null
// tableMeta.rowData[3] === 7 ?
// (Number(handleValueFormula(value, tableMeta, 7)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) <= Number(this.state.maxValue)) ?
// <NumberFormat
// thousandSeparator={true}
// style={{
// fontSize: 12,
// textAlign: 'right',
// borderColor: 'transparent',
// margin: 0,
// width: 96,
// backgroundColor: 'transparent',
// color: 'black'
// }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(handleValueFormula(value, tableMeta, 7)).toFixed(1)}
// /> :
// <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[25].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
// <NumberFormat
// thousandSeparator={true}
// style={{
// fontSize: 12,
// textAlign: 'right',
// borderColor: 'transparent',
// margin: 0,
// width: 96,
// backgroundColor: 'transparent',
// color: 'red'
// }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(handleValueFormula(value, tableMeta, 7)).toFixed(1)}
// />
// </LightTooltip>
// :
// null
}
</div>
</div>
......@@ -2918,7 +3018,7 @@ export default class TaxPlanningOLPA extends Component {
</MuiThemeProvider>
</div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, marginLeft: 20 }}>Notes : {this.state.notesUpdate}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5 }}>Notes : {this.state.notesUpdate}</Typography>
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
......
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