Commit 09b41b04 authored by rifkaki's avatar rifkaki

validate tp bs

parent 5d6e44ba
...@@ -493,6 +493,9 @@ export default class BalanceSheetMR extends Component { ...@@ -493,6 +493,9 @@ export default class BalanceSheetMR extends Component {
handleValidate() { handleValidate() {
let data = [] let data = []
let err = false let err = false
let errorContrl = this.state.buttonError
let editAble = this.state.editAble
console.log(this.state.dataTable)
this.state.dataTable.map((i, index) => { this.state.dataTable.map((i, index) => {
if(i[0] === 3) { if(i[0] === 3) {
// console.log(i); // console.log(i);
...@@ -508,6 +511,19 @@ export default class BalanceSheetMR extends Component { ...@@ -508,6 +511,19 @@ export default class BalanceSheetMR extends Component {
err = true err = true
} }
} }
if (String(i[5]) == "Control (should be nil)") {
i.map((j, indexj) => {
if (indexj >= 6 && indexj <= 16) {
if (Number(j) < this.state.minValue || Number(j) > this.state.maxValue ) {
console.log("masuk error")
errorContrl = true
editAble = true
}
}
})
}
data.push({ data.push({
"item_report_id": i[1], "item_report_id": i[1],
"rolling_outlook": i[6], "rolling_outlook": i[6],
...@@ -559,13 +575,14 @@ export default class BalanceSheetMR extends Component { ...@@ -559,13 +575,14 @@ export default class BalanceSheetMR extends Component {
"balance_sheet": data "balance_sheet": data
} }
// console.log(JSON.stringify(payload)); // console.log(JSON.stringify(payload));
console.log(this.state.dataTable) // console.log(this.state.dataTable)
api.create().validateSubmitReportBS(payload).then((response) => { api.create().validateSubmitReportBS(payload).then((response) => {
console.log(response.data.data.result) console.log(response.data.data.result)
console.log(err); console.log(err);
console.log(errorContrl);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
if (response.data.data.result && err === false) { if (response.data.data.result && err === false && errorContrl === false ) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false }) this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
} else { } else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: true }) this.setState({ loading: false, buttonError: true, editable: true, saveDraft: true })
......
...@@ -420,6 +420,8 @@ export default class TaxPlanningMR extends Component { ...@@ -420,6 +420,8 @@ export default class TaxPlanningMR 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 => {
data.push({ data.push({
...@@ -430,7 +432,20 @@ export default class TaxPlanningMR extends Component { ...@@ -430,7 +432,20 @@ export default class TaxPlanningMR extends Component {
trial_balance_fiscal_actual: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[10]).toFixed(2)) : String(Number(i[10]).toFixed(1)), trial_balance_fiscal_actual: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[10]).toFixed(2)) : String(Number(i[10]).toFixed(1)),
trial_balance_fiscal_mb: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[11]).toFixed(2)) : String(Number(i[11]).toFixed(1)) trial_balance_fiscal_mb: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[11]).toFixed(2)) : String(Number(i[11]).toFixed(1))
}) })
if (String(i[8]) == "Control (should be nil)") {
if (i[9].tbf < this.state.minValue || i[9].tbf > this.state.maxValue || i[10] < this.state.minValue || i[10] > this.state.maxValue) {
errorContrl = true
editAble = true
} else {
errorContrl = false
editAble = false
}
}
}) })
this.setState({ loading: false, buttonError: errorContrl, editable: editAble, saveDraft: false })
let i = this.state.dataTable
let payload = { let payload = {
"monthly_report_id": this.props.monthlyReportId, "monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
...@@ -440,29 +455,29 @@ export default class TaxPlanningMR extends Component { ...@@ -440,29 +455,29 @@ export default class TaxPlanningMR extends Component {
"months": this.props.month.month_id, "months": this.props.month.month_id,
"tax_planning": data "tax_planning": data
} }
api.create().validateSubmitReportMRTP(payload).then((response) => { // api.create().validateSubmitReportMRTP(payload).then((response) => {
console.log(response) // console.log(response)
if (response.data) { // if (response.data) {
if (response.data.status === "success") { // if (response.data.status === "success") {
if (response.data.data.result) { // if (response.data.data.result) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false }) // this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
} else { // } else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false }) // this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
} // }
} else { // } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { // this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) { // if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => { // setTimeout(() => {
localStorage.removeItem(Constant.TOKEN) // localStorage.removeItem(Constant.TOKEN)
window.location.reload(); // window.location.reload();
}, 1000); // }, 1000);
} // }
}) // })
} // }
} else { // } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false }) // this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} // }
}) // })
} }
downloadTemplate = async () => { downloadTemplate = async () => {
......
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