Commit 344c5b7e authored by Rifka Kurnia's avatar Rifka Kurnia

Merge branch 'rifka' into 'master'

control should be nil olpa tp

See merge request !1286
parents 5d3c5a08 929fde5a
...@@ -62,10 +62,10 @@ export default class TaxPlanningOLPA extends Component { ...@@ -62,10 +62,10 @@ export default class TaxPlanningOLPA extends Component {
} }
componentDidMount() { componentDidMount() {
this.getItemHierarki() // this.getItemHierarki()
this.getSettingControl()
this.lastUpdate() this.lastUpdate()
this.handleViewOnly() this.handleViewOnly()
console.log(this.props.isApprover)
} }
handleViewOnly() { handleViewOnly() {
...@@ -104,11 +104,44 @@ export default class TaxPlanningOLPA extends Component { ...@@ -104,11 +104,44 @@ export default class TaxPlanningOLPA extends Component {
handleGetFor(type) { handleGetFor(type) {
console.log(type) console.log(type)
this.setState({get_for: type}, () => { this.setState({get_for: type}, () => {
this.getItemHierarki() this.getSettingControl()
this.lastUpdate() 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(){ lastUpdate(){
let payload = { let payload = {
"outlook_pa_id": this.props.outlook_pa_id, "outlook_pa_id": this.props.outlook_pa_id,
...@@ -672,6 +705,8 @@ export default class TaxPlanningOLPA extends Component { ...@@ -672,6 +705,8 @@ export default class TaxPlanningOLPA extends Component {
handleValidate() { handleValidate() {
let data = [] let data = []
let errorContrl = this.state.buttonError
let editAble = this.state.editAble
// console.log(this.state.dataTable) // console.log(this.state.dataTable)
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
// console.log(i[0]) // console.log(i[0])
...@@ -750,6 +785,18 @@ export default class TaxPlanningOLPA extends Component { ...@@ -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)) // console.log(JSON.stringify(data))
let payload = { let payload = {
...@@ -762,10 +809,25 @@ export default class TaxPlanningOLPA extends Component { ...@@ -762,10 +809,25 @@ export default class TaxPlanningOLPA extends Component {
} }
api.create().validateSubmitReportOLPA(payload).then((response) => { api.create().validateSubmitReportOLPA(payload).then((response) => {
console.log(response) console.log(response)
if (response.data.data.result) { if (response.data) {
this.setState({ loading: false, buttonError: false, editable: false }) 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 { } 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 { ...@@ -788,7 +850,7 @@ export default class TaxPlanningOLPA extends Component {
async downloadAllData() { 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 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}` 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( let res = await fetch(
this.props.outlook_pa_id == null ? sub_null : url this.props.outlook_pa_id == null ? sub_null : url
) )
...@@ -904,7 +966,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -904,7 +966,7 @@ export default class TaxPlanningOLPA extends Component {
if (dataTable2[indexID][24] == tableMeta.rowData[24]) { if (dataTable2[indexID][24] == tableMeta.rowData[24]) {
anjay.push(0) anjay.push(0)
} else { } 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 let valuezz = data.value == undefined ? data : data.value
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
} }
...@@ -2777,6 +2839,44 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2777,6 +2839,44 @@ export default class TaxPlanningOLPA extends Component {
</LightTooltip> </LightTooltip>
: :
null 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>
</div> </div>
...@@ -2918,7 +3018,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2918,7 +3018,7 @@ export default class TaxPlanningOLPA extends Component {
</MuiThemeProvider> </MuiThemeProvider>
</div> </div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography> <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>
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1"> <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