TaxPlanningMR.js 106 KB
Newer Older
1
import React, { Component } from 'react';
r.kurnia's avatar
r.kurnia committed
2
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, Tooltip, withStyles, Snackbar } from '@material-ui/core';
3 4 5 6 7 8 9 10 11 12
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
import api from '../../api';
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
import { Alert } from '@material-ui/lab';
import * as R from 'ramda';
r.kurnia's avatar
r.kurnia committed
13
import Constant from '../../library/Constant';
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);

var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());

const options = ct.customOptionsFixedColumn();
const style = {
    position: "sticky",
    left: 0,
    zIndex: 101,
    background: "white",
};
const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100,
    top: 0
};

Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
41
export default class TaxPlanningMR extends Component {
42 43 44 45
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
r.kurnia's avatar
r.kurnia committed
46
            loading: true,
47 48 49 50 51
            visibleTP: true,
            disabledSave: true,
            editable: false,
            judulColumn: null,
            updateBy: '-',
r.kurnia's avatar
r.kurnia committed
52
            notesUpdate: '-',
53 54
            buttonDraft: true,
            handleTekTekTek: 0,
r.kurnia's avatar
r.kurnia committed
55
            saveDraft: true,
r.kurnia's avatar
r.kurnia committed
56
            buttonError: true
57 58 59 60 61 62

        }
        this.fileHandler = this.fileHandler.bind(this);
    }

    componentDidMount() {
r.kurnia's avatar
r.kurnia committed
63 64
        this.getSettingControl()
        // this.getItemHierarki()
r.kurnia's avatar
r.kurnia committed
65
        this.getLatestUpdate()
66 67
    }

r.kurnia's avatar
r.kurnia committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    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);
            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()
            })
        })
    }

86 87
    getLatestUpdate() {
        let payload = {
r.kurnia's avatar
r.kurnia committed
88 89 90 91 92 93
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "monthly_report_id": this.props.monthlyReportId,
            "months": this.props.month.month_id
94
        }
r.kurnia's avatar
r.kurnia committed
95
        api.create().getLastestUpdateMR(payload).then(response => {
r.kurnia's avatar
r.kurnia committed
96
            console.log(response)
97 98 99
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
r.kurnia's avatar
r.kurnia committed
100 101
                        updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update,
                        notesUpdate: response.data.data.notes_update === null ? '-' : response.data.data.notes_update
102 103 104 105 106 107 108 109 110
                    })
                }
            }
        })
    }

    getItemHierarki() {
        this.setState({ loading: true, judulColumn: null })
        let payload = {
r.kurnia's avatar
r.kurnia committed
111 112 113 114 115
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "monthly_report_id": this.props.monthlyReportId,
r.kurnia's avatar
r.kurnia committed
116
            "months": this.props.month.month_id
117
        }
r.kurnia's avatar
r.kurnia committed
118
        api.create().getHierarkiMontlyReportTP(payload).then(response => {
r.kurnia's avatar
r.kurnia committed
119
            console.log(response);
rifkaki's avatar
rifkaki committed
120
            console.log(payload);
121 122
            let dataTable = []
            if (response.data) {
r.kurnia's avatar
r.kurnia committed
123 124 125 126 127 128 129
                if (response.data.status == 'success') {
                    let res = response.data.data
                    const handlePushChild = (item) => {
                        let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                        if (indexIDzz === -1) {
                            dataTable.push([
                                item.type_report_id,
r.kurnia's avatar
r.kurnia committed
130 131 132
                                item.type_report_tax.value_tbc.type_report_id,
                                item.type_report_tax.value_fc.type_report_id,
                                item.type_report_tax.value_tbf.type_report_id,
r.kurnia's avatar
r.kurnia committed
133 134
                                item.id,
                                item.parent,
r.kurnia's avatar
r.kurnia committed
135
                                { tbc: item.formula_tax.value_tbc, fcp: item.formula_tax.value_fc, tbf: item.formula_tax.value_tbf },
r.kurnia's avatar
r.kurnia committed
136 137
                                item.level,
                                item.description,
r.kurnia's avatar
r.kurnia committed
138 139 140 141 142
                                {
                                    tbc: item.tax_planning.trial_balance_commercial === null ? "0.0" : item.tax_planning.trial_balance_commercial === "" ? "0.0" : item.tax_planning.trial_balance_commercial,
                                    fcp: item.tax_planning.fiscal_correction === null ? "0.0" : item.tax_planning.fiscal_correction === "" ? "0.0" : item.tax_planning.fiscal_correction,
                                    tbf: item.tax_planning.trial_balance_fiscal === null ? "0.0" : item.tax_planning.trial_balance_fiscal === "" ? "0.0" : item.tax_planning.trial_balance_fiscal,
                                },
rifkaki's avatar
rifkaki committed
143
                                0,
r.kurnia's avatar
r.kurnia committed
144
                                item.tax_planning.trial_balance_fiscal_mb === null ? "0.0" : item.tax_planning.trial_balance_fiscal_mb === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_mb,
r.kurnia's avatar
r.kurnia committed
145
                                item.tax_planning.actual_formula,
r.kurnia's avatar
r.kurnia committed
146
                                item.order,
r.kurnia's avatar
r.kurnia committed
147 148
                                { tbc: item.condition_it_should_be_tax.value_tbc, fcp: item.condition_it_should_be_tax.value_fc, tbf: item.condition_it_should_be_tax.value_tbf },
                                { tbc: item.condition_if_wrong_tax.value_tbc, fcp: item.condition_if_wrong_tax.value_fc, tbf: item.condition_if_wrong_tax.value_tbf },
rifkaki's avatar
rifkaki committed
149 150
                                item.tax_planning.trial_balance_fiscal_actual === null ? "0.0" : item.tax_planning.trial_balance_fiscal_actual === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_actual,

r.kurnia's avatar
r.kurnia committed
151 152 153 154 155 156 157 158 159 160 161
                            ])
                        }
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
                        }
                    }
                    res.map((item, index) => {
162 163
                        dataTable.push([
                            item.type_report_id,
r.kurnia's avatar
r.kurnia committed
164 165 166
                            item.type_report_tax.value_tbc.type_report_id,
                            item.type_report_tax.value_fc.type_report_id,
                            item.type_report_tax.value_tbf.type_report_id,
167 168
                            item.id,
                            item.parent,
r.kurnia's avatar
r.kurnia committed
169
                            { tbc: item.formula_tax.value_tbc, fcp: item.formula_tax.value_fc, tbf: item.formula_tax.value_tbf },
170 171
                            item.level,
                            item.description,
r.kurnia's avatar
r.kurnia committed
172 173 174 175 176
                            {
                                tbc: item.tax_planning.trial_balance_commercial === null ? "0.0" : item.tax_planning.trial_balance_commercial === "" ? "0.0" : item.tax_planning.trial_balance_commercial,
                                fcp: item.tax_planning.fiscal_correction === null ? "0.0" : item.tax_planning.fiscal_correction === "" ? "0.0" : item.tax_planning.fiscal_correction,
                                tbf: item.tax_planning.trial_balance_fiscal === null ? "0.0" : item.tax_planning.trial_balance_fiscal === "" ? "0.0" : item.tax_planning.trial_balance_fiscal,
                            },
rifkaki's avatar
rifkaki committed
177
                            0,
r.kurnia's avatar
r.kurnia committed
178
                            item.tax_planning.trial_balance_fiscal_mb === null ? "0.0" : item.tax_planning.trial_balance_fiscal_mb === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_mb,
r.kurnia's avatar
r.kurnia committed
179
                            item.tax_planning.actual_formula,
180
                            item.order,
r.kurnia's avatar
r.kurnia committed
181 182
                            { tbc: item.condition_it_should_be_tax.value_tbc, fcp: item.condition_it_should_be_tax.value_fc, tbf: item.condition_it_should_be_tax.value_tbf },
                            { tbc: item.condition_if_wrong_tax.value_tbc, fcp: item.condition_if_wrong_tax.value_fc, tbf: item.condition_if_wrong_tax.value_tbf },
rifkaki's avatar
rifkaki committed
183
                            item.tax_planning.trial_balance_fiscal_actual === null ? "0.0" : item.tax_planning.trial_balance_fiscal_actual === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_actual,
184
                        ])
r.kurnia's avatar
r.kurnia committed
185 186 187 188 189 190
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
191
                        }
r.kurnia's avatar
r.kurnia committed
192
                    })
r.kurnia's avatar
r.kurnia committed
193
                    this.setState({ dataTable, loading: false, editable: true })
r.kurnia's avatar
r.kurnia committed
194 195 196 197 198 199 200
                } else {
                    this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
201
                        }
r.kurnia's avatar
r.kurnia committed
202 203
                    })
                }
204
            } else {
r.kurnia's avatar
r.kurnia committed
205
                this.setState({ dataTable, loading: false, editable: true })
206
            }
r.kurnia's avatar
r.kurnia committed
207
            console.log(this.state.dataTable)
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
        })
    }

    handleChange(value, tableMeta) {
        let val = String(value).split(",").join("")
        let data = this.state.dataTable
        let indexParent = data.findIndex((val) => val[4] === data[tableMeta.rowIndex][5])
        if (indexParent > 0) {
            // console.log(indexParent)
            let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
            let jagain = data[indexParent][tableMeta.columnIndex]
            a = data[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
        } else {
            data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
        }
        // this.forceUpdate()
        // console.log(this.state.dataTable)
        // this.setState({
        //     data: a,
        // }, () => console.log(this.state.dataTable))
    }

r.kurnia's avatar
r.kurnia committed
230
    backToMonthlyReport(type) {
231 232 233
        let data = []
        this.state.dataTable.map(i => {
            data.push({
r.kurnia's avatar
r.kurnia committed
234
                item_report_id: i[4],
Deni Rinaldi's avatar
Deni Rinaldi committed
235
                trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
r.kurnia's avatar
r.kurnia committed
236 237 238 239
                fiscal_correction: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].fcp).toFixed(2)) : String(Number(i[9].fcp).toFixed(1)),
                trial_balance_fiscal: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].tbf).toFixed(2)) : String(Number(i[9].tbf).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))
240 241 242
            })
        })
        let payload = {
r.kurnia's avatar
r.kurnia committed
243
            "monthly_report_id": this.props.monthlyReportId,
244 245 246 247
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
r.kurnia's avatar
r.kurnia committed
248
            "months": this.props.month.month_id,
249 250
            "tax_planning": data
        }
r.kurnia's avatar
r.kurnia committed
251

252
        api.create('UPLOAD').createMonthlyReportTP(payload).then(response => {
r.kurnia's avatar
r.kurnia committed
253 254
            console.log(payload);
            console.log(response);
r.kurnia's avatar
r.kurnia committed
255 256
            if (response.data) {
                if (response.data.status === "success") {
257
                    this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
258
                } else {
r.kurnia's avatar
r.kurnia committed
259
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
r.kurnia's avatar
r.kurnia committed
260 261 262 263 264 265 266
                        document.body.style.overflow = 'unset';
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
267
                        this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
268
                    })
r.kurnia's avatar
r.kurnia committed
269
                }
r.kurnia's avatar
r.kurnia committed
270
            } else {
271
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
r.kurnia's avatar
r.kurnia committed
272 273
            }
        })
274 275 276 277 278 279 280 281 282 283
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                // console.log(err);
            }
            else {
r.kurnia's avatar
r.kurnia committed
284
                let isi = resp.rows.slice(3)
285 286 287 288 289 290 291
                // console.log(resp.rows[2]);
                // console.log(resp.rows);
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
r.kurnia's avatar
r.kurnia committed
292 293 294
                            order: i[0] === undefined ? "" : String(i[0]).trim(),
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report_name: i[2] === undefined ? "" : String(i[2]).trim(),
rifkaki's avatar
rifkaki committed
295 296 297
                            trial_balance_commercial: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(String(i[3]).trim()).toFixed(2)) :String(Number(String(i[3]).trim()).toFixed(1)),
                            fiscal_correction: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(String(i[4]).trim()).toFixed(2)) :String(Number(String(i[4]).trim()).toFixed(1)),
                            trial_balance_fiscal: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(String(i[5]).trim()).toFixed(2)) :String(Number(String(i[5]).trim()).toFixed(1)),
r.kurnia's avatar
r.kurnia committed
298 299
                            trial_balance_fiscal_actual: "",
                            trial_balance_fiscal_mb: "",
300 301 302 303 304 305 306
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
307
                    months: this.props.month.month_id,
308 309
                    tax_planning: payload
                }
rifkaki's avatar
rifkaki committed
310 311 312
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
                console.log(this.state.judulColumn)
                console.log(this.state.judul)
313 314 315 316 317
            }
        });
    }

    checkUpload() {
318
        api.create().checkUploadMonthlyReportTP(this.state.payload).then(response => {
319
            // console.log(JSON.stringify(this.state.payload));
r.kurnia's avatar
r.kurnia committed
320
            // console.log(this.state.payload)
r.kurnia's avatar
r.kurnia committed
321
            // console.log(response)
322 323 324 325 326 327
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, visibleTP: false, loading: true })
                    let dataTable = response.data.data.map((item, index) => {
                        return [
                            0,
r.kurnia's avatar
r.kurnia committed
328 329 330
                            Number(item.type_report_id.tbc),
                            Number(item.type_report_id.fcp),
                            Number(item.type_report_id.tbf),
331 332
                            item.item_report_id,
                            item.parent,
r.kurnia's avatar
r.kurnia committed
333
                            { tbc: item.formula.tbc, fcp: item.formula.fcp, tbf: item.formula.tbf },
334 335 336
                            item.level,
                            item.item_report,
                            {
r.kurnia's avatar
r.kurnia committed
337
                                tbc: item.trial_balance_commercial === null ? "0.0" : item.trial_balance_commercial === "" ? "0.0" : item.trial_balance_commercial,
r.kurnia's avatar
r.kurnia committed
338 339
                                fcp: item.fiscal_correction === null ? "0.0" : item.fiscal_correction === "" ? "0.0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.fiscal_correction).toFixed(2) : Number(item.fiscal_correction).toFixed(1),
                                tbf: item.trial_balance_fiscal === null ? "0.0" : item.trial_balance_fiscal === "" ? "0.0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.trial_balance_fiscal).toFixed(2) : Number(item.trial_balance_fiscal).toFixed(1),
340
                            },
rifkaki's avatar
rifkaki committed
341
                            0,
r.kurnia's avatar
r.kurnia committed
342
                            item.trial_balance_fiscal_mb === null ? "0.0" : item.trial_balance_fiscal_mb === "" ? "0.0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.trial_balance_fiscal_mb).toFixed(2) : Number(item.trial_balance_fiscal_mb).toFixed(1),
r.kurnia's avatar
r.kurnia committed
343
                            item.actual_formula,
r.kurnia's avatar
r.kurnia committed
344 345 346
                            item.orders,
                            { tbc: item.condition_it_should_be.tbc, fcp: item.condition_it_should_be.fcp, tbf: item.condition_it_should_be.tbf },
                            { tbc: item.condition_if_wrong.tbc, fcp: item.condition_if_wrong.fcp, tbf: item.condition_if_wrong.tbf },
rifkaki's avatar
rifkaki committed
347
                            item.trial_balance_fiscal_actual === null ? "0.0" : item.trial_balance_fiscal_actual === "" ? "0.0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.trial_balance_fiscal_actual).toFixed(2) : Number(item.trial_balance_fiscal_actual).toFixed(1),
348 349 350 351 352
                            item.error
                        ]
                    })
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, saveDraft: true }, () => {
                        this.state.dataTable.map(item => {
rifkaki's avatar
rifkaki committed
353
                            if (item[17].length > 0) {
354 355 356 357
                                // console.log('masuk')
                                this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true })
                            }
                        })
r.kurnia's avatar
r.kurnia committed
358
                        // console.log(this.state.dataTable);
359 360 361 362 363 364 365 366 367 368 369
                    })
                }
            }
        })
    }

    uploadTP(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[4],
r.kurnia's avatar
r.kurnia committed
370
                trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
r.kurnia's avatar
r.kurnia committed
371 372 373 374
                fiscal_correction: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].fcp).toFixed(2)) : String(Number(i[9].fcp).toFixed(1)),
                trial_balance_fiscal: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].tbf).toFixed(2)) : String(Number(i[9].tbf).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))
375 376 377
            })
        })
        let body = {
r.kurnia's avatar
r.kurnia committed
378 379 380 381 382 383 384
            "monthly_report_id": this.props.monthlyReportId,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
            "months": this.props.month.month_id,
            "tax_planning": data
385 386
        }
        // console.log(data);
r.kurnia's avatar
r.kurnia committed
387
        api.create('UPLOAD').uploadMonthlyReportTP(body).then(response => {
r.kurnia's avatar
r.kurnia committed
388 389
            // console.log(body);
            // console.log(JSON.stringify(body));
r.kurnia's avatar
r.kurnia committed
390
            // console.log(response);
391 392
            if (response.data) {
                if (response.data.status === "success") {
r.kurnia's avatar
r.kurnia committed
393
                    this.props.saveToMonthlyReport()
394
                } else {
r.kurnia's avatar
r.kurnia committed
395 396 397 398 399 400 401
                    this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
r.kurnia's avatar
r.kurnia committed
402
                        this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
403 404
                    })
                    // alert(response.data.status)
405 406
                }
            } else {
r.kurnia's avatar
r.kurnia committed
407
                this.setState({ loading: false, alert: true, messageAlert: response.problem, tipeAlert: 'error' })
408 409 410 411 412 413 414 415 416
            }
        })
    }

    handleValidate() {
        let data = []
        // console.log(this.state.dataTable)
        this.state.dataTable.map(i => {
            data.push({
r.kurnia's avatar
r.kurnia committed
417 418 419 420 421 422
                item_report_id: i[4],
                trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
                fiscal_correction: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].fcp).toFixed(2)) : String(Number(i[9].fcp).toFixed(1)),
                trial_balance_fiscal: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].tbf).toFixed(2)) : String(Number(i[9].tbf).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))
423 424 425
            })
        })
        let payload = {
r.kurnia's avatar
r.kurnia committed
426
            "monthly_report_id": this.props.monthlyReportId,
427 428 429
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
r.kurnia's avatar
r.kurnia committed
430 431 432
            "status": "submitted",
            "months": this.props.month.month_id,
            "tax_planning": data
433
        }
r.kurnia's avatar
r.kurnia committed
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
        api.create().validateSubmitReportMRTP(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 })
            }
        })
457 458 459 460
    }

    downloadTemplate = async () => {
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
461
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/monthly_report_tp/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
462 463 464 465 466 467 468
        )
        res = await res.blob()
        // console.log(res)
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
r.kurnia's avatar
r.kurnia committed
469
            a.download = 'Template Monthly Report Tax Planning.xlsx';
470 471 472 473 474
            a.click();
        }
    }

    async downloadAllData() {
faisalhamdi's avatar
faisalhamdi committed
475 476
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/monthly_report_tp/export_monthly_report?monthly_report_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
        let urls = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/monthly_report_tp/export_monthly_report?monthly_report_id=${this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
r.kurnia's avatar
r.kurnia committed
477 478
        // console.log(url);
        console.log(urls);
479
        let res = await fetch(
r.kurnia's avatar
r.kurnia committed
480
            this.props.monthlyReportId == null ? url : urls
481 482 483 484 485 486 487
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
r.kurnia's avatar
r.kurnia committed
488
            a.download = 'Monthly Report Tax Planning.xlsx';
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
            a.click();
        }
    }

    closeAlert() {
        this.setState({ alert: false })
    }

    render() {
        let dataTable2 = this.state.dataTable
        const handleValueFormula = (value, tableMeta, dex, xntd, forecast, periode) => {
            let form = dex === 1 ? tableMeta.rowData[6].tbc : dex === 2 ? tableMeta.rowData[6].fcp : tableMeta.rowData[6].tbf
            let splitFormula = String(form).split('@')
            let baru = []
            let anjay = []
            splitFormula.map((item, index) => {
                let items = String(item).substr(Number(String(item).length) - 1, 1)
                let re = /^[a-zA-Z0-9_]+$/;
                let asd = ''
                if (item !== "") {
                    if (!re.test(items)) {
                        baru.push(String(item).substr(0, Number(String(item).length) - 1))
                        baru.push(String(item).substr(Number(String(item).length) - 1, 1))
                    } else {
                        baru.push(String(item))
                    }
                }
            })
            
            if (tableMeta.rowData[8] == "Under payment  /(Over Payment ) Income Tax Art.  29" || forecast !== undefined) {
                let opgab = []
                baru.map((item, index) => {
                    if( item.length > 1 && (item.includes("+") || item.includes("-") || item.includes("*") || item.includes("/"))){
                        opgab.push(String(item).substr(0, Number(String(item).length) - 1))
                        opgab.push(String(item).substr(Number(String(item).length) - 1, 1))
                    } else {
                        opgab.push(item)
                    }
                })
                if(opgab.length > 0){
                    baru = opgab
                }
            }
rifkaki's avatar
rifkaki committed
532

533 534 535 536 537 538 539 540
            let totalShldBeNil = 0
            baru.map((item, index) => {
                if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
                    anjay.push(item)
                } else {
                    if (String(item).includes('#')) {
                        let splitform = String(item).split('#')
                        if (splitform[1] == 'TP1' || splitform[1] == 'TP2' || splitform[1] == 'TP3') {
r.kurnia's avatar
r.kurnia committed
541
                            let indexID = dataTable2.findIndex((val) => val[13] == splitform[0])
542 543 544 545 546 547 548 549 550 551 552 553 554 555
                            if (indexID !== -1) {
                                let data = splitform[1] == 'TP1' ? dataTable2[indexID][tableMeta.columnIndex].tbc : splitform[1] == 'TP2' ? dataTable2[indexID][tableMeta.columnIndex].fcp : dataTable2[indexID][tableMeta.columnIndex].tbf
                                let valuezz = data.value == undefined ? data : data.value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        } else {
                            if (forecast !== undefined) {
                                forecast.map((item,index) => {
                                    if (periode == item.periode) {
                                        totalShldBeNil += Number(item.value)
                                    }
                                })
                                anjay.push(totalShldBeNil)
                            } else if (String(item).includes('[M-1]')) {
r.kurnia's avatar
r.kurnia committed
556 557 558
                                let tst = String(item).replace('[M-1]', '[M1]')
                                // let data = tableMeta.columnIndex == 9 ? 20 : tableMeta.columnIndex - 1
                                let data = tableMeta.columnIndex
559 560 561 562 563 564 565 566
                                let dataSub = dex == 1 ? tableMeta.rowData[data].tbc : dex == 2 ? tableMeta.rowData[data].fcp : tableMeta.rowData[data].tbf
                                let period = data == 20 ? Number(this.props.periode) - 1 : this.props.periode
                                let indexID = dataSub.formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
                                if (indexID !== -1) {
                                    let valuezz = tableMeta.rowData[data].formula[indexID].value
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                            } else {
r.kurnia's avatar
r.kurnia committed
567
                                let data = tableMeta.rowData[12]
rifkaki's avatar
rifkaki committed
568
                                let indexID = data.findIndex((val) => val.item_formula == String(`${item}`) && val.periode == Number(this.props.periode))
569
                                if (indexID !== -1) {
r.kurnia's avatar
r.kurnia committed
570
                                    let valuezz = data[indexID].value
571 572 573 574 575
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                            }
                        }
                    } else {
r.kurnia's avatar
r.kurnia committed
576
                        let indexID = dataTable2.findIndex((val) => val[13] == item)
577
                        if (indexID !== -1) {
r.kurnia's avatar
r.kurnia committed
578
                            if (dataTable2[indexID][13] == tableMeta.rowData[13]) {
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
                                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 valuezz = data.value == undefined ? data : data.value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }

                        }
                    }
                }
            })

            let total = 0
            let total2 = 0
            let opt = ""
            let opt2 = ""
            let prio = false
            let simpen2 = ""
            anjay.map((item, index) => {
                if (item == "+") {
                    if (prio) {
                        opt2 = "tambah"
                    } else {
                        opt = "tambah"
                    }
                } else if (item == "-") {
                    if (prio) {
                        opt2 = "kurang"
                    } else {
                        opt = "kurang"
                    }
                } else if (item == "*") {
                    if (prio) {
                        opt2 = "kali"
                    } else {
                        opt = "kali"
                    }
                } else if (item == "/") {
                    if (prio) {
                        opt2 = "bagi"
                    } else {
                        opt = "bagi"
                    }
                } else if (item == "(") {
                    prio = true
                    simpen2 = "active"
                } else if (item == ")") {
                    prio = false
                }
                else {
                    if (prio) {
                        if (opt2 == "tambah") {
                            total2 = Number(total2) + Number(item)
                        } else if (opt2 == "kurang") {
                            total2 = Number(total2) - Number(item)
                        } else if (opt2 == "kali") {
                            total2 = Number(total2) * Number(item)
                        } else if (opt2 == "bagi") {
                            total2 = Number(total2) / Number(item) == NaN ? 0 : Number(total2) / Number(item)
                        } else {
                            total2 += Number(item)
                        }
                    } else {
                        if (opt == "tambah") {
                            total = Number(total) + Number(item)
                        } else if (opt == "kurang") {
                            total = Number(total) - Number(item)
                        } else if (opt == "kali") {
                            total = Number(total) * Number(item)
                        } else if (opt == "bagi") {
                            total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
                        } else {
                            total += Number(item)
                        }
                    }
                }
            })

            if(simpen2 == "active") {
                if (opt == "tambah") {
                    total = Number(total) + Number(total2)
                } else if (opt == "kurang") {
                    total = Number(total) - Number(total2)
                } else if (opt == "kali") {
                    total = Number(total) * Number(total2)
                } else if (opt == "bagi") {
                    total = Number(total) / Number(total2) == NaN ? 0 : Number(total) / Number(total2)
                }
            }

            total = R.equals(total, NaN) ? "0.0" : total

            if (dex == 1) {
                if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc.value == undefined) {
Deni Rinaldi's avatar
Deni Rinaldi committed
673
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc = Number(total).toFixed(1)
674
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
675
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc.value = Number(total).toFixed(1)
676 677 678
                }
            } else if (dex == 2) {
                if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value == undefined) {
Deni Rinaldi's avatar
Deni Rinaldi committed
679
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = Number(total).toFixed(1)
680
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
681
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value = Number(total).toFixed(1)
682 683
                }
            } else {
r.kurnia's avatar
r.kurnia committed
684 685 686 687 688 689 690 691
                if (tableMeta.rowData[8] == "Corporate Income Tax") {
                    if (total < 0) {
                        total = 0
                        dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(1)
                    } else {
                        dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(2)
                    }
                } else if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf.value == undefined) {
Deni Rinaldi's avatar
Deni Rinaldi committed
692
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(1)
693
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
694
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf.value = Number(total).toFixed(1)
695 696 697
                }
            }

Deni Rinaldi's avatar
Deni Rinaldi committed
698
            return Number(total).toFixed(1)
699 700 701
        }

        const handleChange = (value, tableMeta, indexChilds) => {
r.kurnia's avatar
r.kurnia committed
702
            console.log(dataTable2)
703 704
            let val = String(value).split(",").join("")
            // let data = this.state.dataTable2
r.kurnia's avatar
r.kurnia committed
705
            let indexParent = dataTable2.findIndex((val) => val[4] === dataTable2[tableMeta.rowIndex][5])
706 707 708 709 710 711 712 713 714
            // ini buat input untuk perhitungan parent nya
            if (indexParent > 0) {
                if (indexChilds == 1) {
                    let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = Number(val)
                    let jagain = dataTable2[indexParent][tableMeta.columnIndex].fcp
                    a = dataTable2[indexParent][tableMeta.columnIndex].fcp = jagain === undefined ? (0 + Number(val)) : (Number(jagain) + Number(val))
                }
            } else {
                if (indexChilds == 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
715
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc = Number(val).toFixed(1)
716 717
                }
                else if (indexChilds == 1) {
Deni Rinaldi's avatar
Deni Rinaldi committed
718
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = Number(val).toFixed(1)
719 720
                }
                else if (indexChilds == 2) {
Deni Rinaldi's avatar
Deni Rinaldi committed
721
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(val).toFixed(1)
722 723 724
                }
            }
        }
rifkaki's avatar
rifkaki committed
725
        const handleTotal = (value, tableMeta, dex) => {
rifkaki's avatar
rifkaki committed
726
            // console.log(tableMeta)
rifkaki's avatar
rifkaki committed
727
            let total = 0
r.kurnia's avatar
r.kurnia committed
728

729
            dataTable2[tableMeta.rowIndex].map((item, index) => {
r.kurnia's avatar
r.kurnia committed
730
                if (index == 9) {
r.kurnia's avatar
r.kurnia committed
731
                    let valItemFCP = item.fcp == undefined || item.fcp == "" || item.fcp == "undefined" ? 0.0 : item.fcp
rifkaki's avatar
rifkaki committed
732
                    total = Number(tableMeta.rowData[16]) + Number(valItemFCP)
733 734 735
                }
            })
            
rifkaki's avatar
rifkaki committed
736 737
            dataTable2[tableMeta.rowIndex][10] = Number(total).toFixed(1)
            return total
738 739 740 741 742
        }

        const handleParent = (tableMeta, type) => {
            let total = 0
            dataTable2.map((item, index) => {
r.kurnia's avatar
r.kurnia committed
743
                if (item[5] == tableMeta.rowData[4]) {
744 745 746 747 748 749
                    total += Number(type == 1 ?
                        item[tableMeta.columnIndex].tbc.value == undefined ? Number(item[tableMeta.columnIndex].tbc == "" || item[tableMeta.columnIndex].tbc == "0.0" ? 0 : item[tableMeta.columnIndex].tbc) : Number(item[tableMeta.columnIndex].tbc.value == "" || item[tableMeta.columnIndex].tbc.value == "0.0" ? 0 : item[tableMeta.columnIndex].tbc.value)
                        :
                        (type == 2 ?
                            item[tableMeta.columnIndex].fcp.value == undefined ? Number(item[tableMeta.columnIndex].fcp == "" || item[tableMeta.columnIndex].fcp == "0.0" ? 0 : item[tableMeta.columnIndex].fcp) : Number(item[tableMeta.columnIndex].fcp.value == "" || item[tableMeta.columnIndex].fcp.value == "0.0" ? 0 : item[tableMeta.columnIndex].fcp.value)
                            :
r.kurnia's avatar
r.kurnia committed
750 751 752 753 754
                            (type == 3 ?
                                item[tableMeta.columnIndex].tbf.value == undefined ? Number(item[tableMeta.columnIndex].tbf == "" || item[tableMeta.columnIndex].tbf == "0.0" ? 0 : item[tableMeta.columnIndex].tbf) : Number(item[tableMeta.columnIndex].tbf.value == "" || item[tableMeta.columnIndex].tbf.value == "0.0" ? 0 : item[tableMeta.columnIndex].tbf.value)
                                :
                                item[tableMeta.columnIndex].value == undefined ? Number(item[tableMeta.columnIndex] == "" || item[tableMeta.columnIndex] == "0.0" ? 0 : item[tableMeta.columnIndex]) : Number(item[tableMeta.columnIndex].value == "" || item[tableMeta.columnIndex].value == "0.0" ? 0 : item[tableMeta.columnIndex].value)
                            )
755 756 757 758 759 760 761 762 763
                        )
                    )
                }
            })

            if (type == 1) {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc = total
            } else if (type == 2) {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = total
r.kurnia's avatar
r.kurnia committed
764
            } else if (type == 3) {
765
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = total
r.kurnia's avatar
r.kurnia committed
766 767
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
768 769 770 771
            }
            return total
        }

r.kurnia's avatar
r.kurnia committed
772 773
        const columns = [
        {
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
r.kurnia's avatar
r.kurnia committed
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
813 814 815 816 817 818 819 820 821 822 823 824
        }, {
            name: "Account",
            options: {
                customHeadRender: (columnMeta) => (
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300 }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style }),
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ width: 300 }}>
r.kurnia's avatar
r.kurnia committed
825
                            {tableMeta.rowData[0] === null ?
r.kurnia's avatar
r.kurnia committed
826
                                tableMeta.rowData[7] == 0 ?
r.kurnia's avatar
r.kurnia committed
827 828 829
                                    <LightTooltip title={"Report Items Not Registered"} arrow>
                                        <span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(val).toUpperCase()}</span>
                                    </LightTooltip> :
r.kurnia's avatar
r.kurnia committed
830
                                    <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[7]) }}>
831 832 833 834 835
                                        <LightTooltip title={"Report Items Not Registered"} arrow>
                                            <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                        </LightTooltip>
                                    </div>
                                :
r.kurnia's avatar
r.kurnia committed
836
                                tableMeta.rowData[7] == 0 ?
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866
                                    <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                    :
                                    <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[7]) }}>
                                        <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                    </div>
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `MTD`,
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ borderBottom: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
                        <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                            <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                <span>{"Trial Balance (Commercial) MTD"}</span>
                            </div>
                            <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                <span>{"Fiscal Correction Positive /(Negative)"}</span>
                            </div>
                            <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                <span>{"Trial Balance (Fiscal) MTD"}</span>
                            </div>
                        </div>
                    </th>
                ),
                setCellProps: () => ({ style2 }),
r.kurnia's avatar
r.kurnia committed
867
                customBodyRender: (value, tableMeta, updateValue) => {
868 869 870 871
                    return (
                        <div>
                            <div className="grid grid-3x content-center">
                                <div className="col-1">
r.kurnia's avatar
r.kurnia committed
872
                                    <div style={{ textAlign: 'right', width: 90 }}>
r.kurnia's avatar
r.kurnia committed
873
                                        {tableMeta.rowData[1] === 4 || tableMeta.rowData[1] === 1 ?
r.kurnia's avatar
r.kurnia committed
874
                                            null :
r.kurnia's avatar
r.kurnia committed
875
                                            tableMeta.rowData[1] === 2 ?
r.kurnia's avatar
r.kurnia committed
876 877 878 879 880 881 882
                                                <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
883
                                                        value={Number(handleParent(tableMeta, 1)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
884 885 886
                                                    />
                                                </span>
                                                :
r.kurnia's avatar
r.kurnia committed
887 888 889 890 891 892 893 894 895
                                                tableMeta.rowData[1] === 3 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value.tbc}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    decimalSeparator={"."}
r.kurnia's avatar
r.kurnia committed
896
                                                                    style={{ color: this.props.isApprover ? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
897 898
                                                                    type="text"
                                                                    placeholder="input"
r.kurnia's avatar
r.kurnia committed
899
                                                                    disabled={this.props.isApprover}
Deni Rinaldi's avatar
Deni Rinaldi committed
900
                                                                    value={Number(value.tbc).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
901 902 903 904 905 906
                                                                    onBlur={(event) => {
                                                                        handleChange(event.target.value, tableMeta, 0)
                                                                        // console.log(dataTable2)
                                                                    }}
                                                                />
                                                            }
r.kurnia's avatar
r.kurnia committed
907
                                                        />
r.kurnia's avatar
r.kurnia committed
908
                                                    </div> 
r.kurnia's avatar
r.kurnia committed
909
                                                    :
r.kurnia's avatar
r.kurnia committed
910
                                                    tableMeta.rowData[1] === 5 || tableMeta.rowData[1] === 6 ?
r.kurnia's avatar
r.kurnia committed
911 912 913
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
r.kurnia's avatar
r.kurnia committed
914
                                                                value={value.tbc}
r.kurnia's avatar
r.kurnia committed
915 916 917 918 919 920 921
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
r.kurnia's avatar
r.kurnia committed
922
                                                                        value={Number(handleValueFormula(value, tableMeta, 1)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
923 924 925 926 927
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                                        :
r.kurnia's avatar
r.kurnia committed
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944
                                                        null
                                        }
                                    </div>
                                </div>
                                <div className="col-2">
                                    <div style={{ textAlign: 'right', width: 90 }}>
                                        {tableMeta.rowData[2] === 4 || tableMeta.rowData[2] === 1 ?
                                            null 
                                            :
                                            tableMeta.rowData[2] === 2 ?
                                                <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
945
                                                        value={Number(handleParent(tableMeta, 2)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
946 947 948 949 950 951 952 953 954 955 956 957 958 959
                                                    />
                                                </span>
                                                :
                                                tableMeta.rowData[2] === 3 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value.fcp}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder="input"
r.kurnia's avatar
r.kurnia committed
960
                                                                    value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp).toFixed(2) : Number(value.fcp).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
961 962 963 964 965 966 967 968 969 970
                                                                    onBlur={(event) => {
                                                                        handleChange(event.target.value, tableMeta, 1)
                                                                        // console.log(dataTable2)
                                                                    }}
                                                                />
                                                            }
                                                        />
                                                    </div>
                                                    :
                                                    tableMeta.rowData[2] === 5 || tableMeta.rowData[2] === 6 ?
r.kurnia's avatar
r.kurnia committed
971 972 973
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
r.kurnia's avatar
r.kurnia committed
974
                                                                value={value.tbc}
r.kurnia's avatar
r.kurnia committed
975 976 977
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
r.kurnia's avatar
r.kurnia committed
978
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
979
                                                                        type="text"
r.kurnia's avatar
r.kurnia committed
980 981
                                                                        placeholder=""
                                                                        disabled={true}
r.kurnia's avatar
r.kurnia committed
982
                                                                        value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
983 984 985 986
                                                                    />
                                                                }
                                                            />
                                                        </div>
r.kurnia's avatar
r.kurnia committed
987 988
                                                        :
                                                        null
r.kurnia's avatar
r.kurnia committed
989 990 991
                                        }
                                    </div>
                                </div>
992
                                <div className="col-3">
r.kurnia's avatar
r.kurnia committed
993
                                    <div style={{ textAlign: 'right', width: 90 }}>
r.kurnia's avatar
r.kurnia committed
994
                                        {tableMeta.rowData[3] === 4 || tableMeta.rowData[3] === 1 ? 
r.kurnia's avatar
r.kurnia committed
995
                                            null :
r.kurnia's avatar
r.kurnia committed
996
                                            tableMeta.rowData[3] === 2 ?
r.kurnia's avatar
r.kurnia committed
997
                                                <span style={{ fontSize: 12, textAlign: 'right' }}>
r.kurnia's avatar
r.kurnia committed
998 999
                                                    <NumberFormat
                                                        thousandSeparator={true}
r.kurnia's avatar
r.kurnia committed
1000
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
1001 1002 1003
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1004
                                                        value={Number(handleParent(tableMeta, 3)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1005 1006 1007
                                                    />
                                                </span>
                                                :
r.kurnia's avatar
r.kurnia committed
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018
                                                tableMeta.rowData[3] === 3 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value.tbf}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder="input"
r.kurnia's avatar
r.kurnia committed
1019
                                                                    value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.tbf).toFixed(2) : Number(value.tbf).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1020 1021 1022 1023 1024 1025 1026
                                                                    onBlur={(event) => {
                                                                        handleChange(event.target.value, tableMeta, 2)
                                                                        // console.log(dataTable2)
                                                                    }}
                                                                />
                                                            }
                                                        />
r.kurnia's avatar
r.kurnia committed
1027
                                                    </div>
r.kurnia's avatar
r.kurnia committed
1028
                                                    :
r.kurnia's avatar
r.kurnia committed
1029 1030 1031 1032 1033 1034 1035 1036 1037
                                                    // tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 ?
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(handleTotal(tableMeta, 6)).toFixed(1)}
                                                    //     />
r.kurnia's avatar
r.kurnia committed
1038
                                                    tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 ?
r.kurnia's avatar
r.kurnia committed
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value.tbc}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
r.kurnia's avatar
r.kurnia committed
1050
                                                                    value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(handleValueFormula(value, tableMeta, 3)).toFixed(2) : Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1051 1052
                                                                />
                                                            }
r.kurnia's avatar
r.kurnia committed
1053
                                                        />
r.kurnia's avatar
r.kurnia committed
1054 1055
                                                    </div>
                                                    :
r.kurnia's avatar
r.kurnia committed
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
                                                    tableMeta.rowData[3] === 7 ?
                                                        (Number(handleValueFormula(value, tableMeta, 3)).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, 3)).toFixed(1)}
                                                            /> :
r.kurnia's avatar
r.kurnia committed
1074
                                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[14].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})` } arrow>
r.kurnia's avatar
r.kurnia committed
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
                                                                <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, 3)).toFixed(1)}
                                                                />
                                                            </LightTooltip>
r.kurnia's avatar
r.kurnia committed
1092 1093
                                                            :
                                                            null
1094 1095 1096 1097 1098 1099 1100 1101 1102
                                        }
                                    </div>
                                </div>
                            </div>
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1103
            name: `Trial Balance (Fiscal) Actual YTD`,
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, paddingTop: 8 }}>{columnMeta.name}</div>
                        {/* <div className="" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky", paddingBottom: 20 }}>
                            <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                <span>{"Trial Balance (Fiscal) Actual MTD"}</span>
                            </div>
                        </div> */}
                    </th>
                ),
                setCellProps: () => ({ style2 }),
r.kurnia's avatar
r.kurnia committed
1116
                customBodyRender: (value, tableMeta, updateValue) => {
1117
                    return (
r.kurnia's avatar
r.kurnia committed
1118
                        <div style={{ textAlign: 'right', width: 90 }}>
r.kurnia's avatar
r.kurnia committed
1119
                            {tableMeta.rowData[3] === 4 || tableMeta.rowData[3] === 1 ?
r.kurnia's avatar
r.kurnia committed
1120 1121
                                null 
                                :
r.kurnia's avatar
r.kurnia committed
1122
                                tableMeta.rowData[3] === 2 ?
r.kurnia's avatar
r.kurnia committed
1123 1124 1125 1126 1127 1128 1129
                                    <span style={{ fontSize: 12, textAlign: 'right' }}>
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1130
                                            value={Number(handleParent(tableMeta, 4)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1131 1132 1133
                                        />
                                    </span>
                                    :
rifkaki's avatar
rifkaki committed
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154
                                    tableMeta.rowData[3] === 7 ?
                                        // (Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) <= Number(this.state.maxValue)) ?
                                        (Number(value).toFixed(1) >= Number(this.state.minValue) && Number(value).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, 3)).toFixed(1)}
                                                value={Number(value).toFixed(1)}
                                            /> :
                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[14].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
r.kurnia's avatar
r.kurnia committed
1155 1156 1157 1158 1159 1160 1161 1162 1163
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{
                                                        fontSize: 12,
                                                        textAlign: 'right',
                                                        borderColor: 'transparent',
                                                        margin: 0,
                                                        width: 96,
                                                        backgroundColor: 'transparent',
rifkaki's avatar
rifkaki committed
1164
                                                        color: 'red'
r.kurnia's avatar
r.kurnia committed
1165 1166 1167 1168
                                                    }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
rifkaki's avatar
rifkaki committed
1169
                                                    // value={Number(handleValueFormula(value, tableMeta, 4)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1170
                                                    value={Number(value).toFixed(1)}
rifkaki's avatar
rifkaki committed
1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189
                                                />
                                            </LightTooltip>
                                            :
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            disabled={true}
                                                            value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(handleTotal(value, tableMeta, 4)).toFixed(2) : Number(handleTotal(value, tableMeta, 4)).toFixed(1)}
                                                        />
                                                    }
                                                />
                                            </div>
r.kurnia's avatar
r.kurnia committed
1190

r.kurnia's avatar
r.kurnia committed
1191
                            }
1192 1193 1194 1195 1196
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1197
            name: `Trial Balance (Fiscal) MB YTD`,
1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, paddingTop: 8 }}>{columnMeta.name}</div>
                        {/* <div className="" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky", paddingBottom: 20 }}>
                            <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                <span>{"Trial Balance (Fiscal) Actual MTD"}</span>
                            </div>
                        </div> */}
                    </th>
                ),
                setCellProps: () => ({ style2 }),
r.kurnia's avatar
r.kurnia committed
1210
                customBodyRender: (value, tableMeta, updateValue) => {
1211
                    return (
r.kurnia's avatar
r.kurnia committed
1212
                        <div style={{ textAlign: 'right', width: 90 }}>
r.kurnia's avatar
r.kurnia committed
1213
                            {tableMeta.rowData[3] === 4 || tableMeta.rowData[3] === 1 ?
r.kurnia's avatar
r.kurnia committed
1214 1215
                                null 
                                :
r.kurnia's avatar
r.kurnia committed
1216
                                tableMeta.rowData[3] === 2 ?
r.kurnia's avatar
r.kurnia committed
1217 1218 1219 1220 1221 1222 1223
                                    <span style={{ fontSize: 12, textAlign: 'right' }}>
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1224
                                            value={Number(handleParent(tableMeta, 4)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1225 1226 1227
                                        />
                                    </span>
                                    :
rifkaki's avatar
rifkaki committed
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248
                                    tableMeta.rowData[3] === 7 ? 
                                        // (Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) <= Number(this.state.maxValue)) ?
                                        (Number(value).toFixed(1) >= Number(this.state.minValue) && Number(value).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, 3)).toFixed(1)}
                                                value={Number(value).toFixed(1)}
                                            /> :
                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[14].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
r.kurnia's avatar
r.kurnia committed
1249 1250 1251 1252 1253 1254 1255 1256 1257
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{
                                                        fontSize: 12,
                                                        textAlign: 'right',
                                                        borderColor: 'transparent',
                                                        margin: 0,
                                                        width: 96,
                                                        backgroundColor: 'transparent',
rifkaki's avatar
rifkaki committed
1258
                                                        color: 'red'
r.kurnia's avatar
r.kurnia committed
1259 1260 1261 1262
                                                    }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
rifkaki's avatar
rifkaki committed
1263
                                                    // value={Number(handleValueFormula(value, tableMeta, 4)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1264
                                                    value={Number(value).toFixed(1)}
rifkaki's avatar
rifkaki committed
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278
                                                />
                                            </LightTooltip>
                                            :
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            disabled={true}
rifkaki's avatar
rifkaki committed
1279
                                                            value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value).toFixed(2) : Number(value).toFixed(1)}
rifkaki's avatar
rifkaki committed
1280 1281 1282 1283
                                                        />
                                                    }
                                                />
                                            </div>
r.kurnia's avatar
r.kurnia committed
1284
                            }
1285 1286 1287 1288
                        </div>
                    )
                }
            }
rifkaki's avatar
rifkaki committed
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301
        },  
        {
            name: "",
            options: {
                display: false
            }
        },
        {
            name: "",
            options: {
                display: false
            }
        },
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320
        {
            name: "",
            options: {
                display: false
            }
        },
        {
            name: "",
            options: {
                display: false
            }
        },
        {
            name: "",
            options: {
                display: false
            }
        },
        ]
1321

1322
        const loadingComponent = (
1323
            <div style={{ position: 'fixed', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );

        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
1336
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report Submission</Typography>
1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347
                </div>
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
                {/* {this.state.loading && loadingComponent} */}
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
                    {this.state.visibleTP === true ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
1348
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Tax Planning</Typography>
1349 1350 1351 1352
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
1353 1354
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
1355 1356 1357
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
r.kurnia's avatar
r.kurnia committed
1358 1359
                                        {this.props.isApprover === true ?
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
1360 1361 1362 1363 1364 1365 1366 1367
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
r.kurnia's avatar
r.kurnia committed
1368 1369 1370 1371 1372 1373
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
1374 1375 1376 1377 1378
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
r.kurnia's avatar
r.kurnia committed
1379
                                            </div> :
1380
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
r.kurnia's avatar
r.kurnia committed
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427
                                                <a data-tip={'Download Template'} data-for="template">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.downloadTemplate()}
                                                    >
                                                        <img src={Images.template} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                                <a data-tip={'Upload'} data-for="upload">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.setState({ visibleUpload: true })}
                                                    >
                                                        <img src={Images.upload} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
1428
                                            </div>
r.kurnia's avatar
r.kurnia committed
1429
                                        }
1430
                                    </div>
r.kurnia's avatar
r.kurnia committed
1431
                                </div>      
1432 1433 1434

                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {this.state.loading && loadingComponent}
r.kurnia's avatar
r.kurnia committed
1435 1436 1437 1438 1439 1440 1441 1442
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    {/* )} */}
1443
                                </div>
r.kurnia's avatar
r.kurnia committed
1444
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20, marginLeft: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
r.kurnia's avatar
r.kurnia committed
1445
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, marginLeft: 20 }}>Notes : {this.state.notesUpdate}</Typography>
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462
                            </div>
                            <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                <div className="col-1">
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none'
                                        }}
                                    >
rifkaki's avatar
rifkaki committed
1463
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginLeft: 10 }}>
r.kurnia's avatar
r.kurnia committed
1464
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
1465 1466 1467
                                        </div>
                                    </button>
                                </div>
r.kurnia's avatar
r.kurnia committed
1468 1469
                                {/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
                                    (this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? */}
r.kurnia's avatar
r.kurnia committed
1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486
                                {this.props.isApprover === true ?
                                    <div className="col-2">
                                    </div> :
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => 
                                                {
                                                    this.setState({ loading: true, buttonDraft: false }, () => {
r.kurnia's avatar
r.kurnia committed
1487
                                                        setTimeout(() => {
r.kurnia's avatar
r.kurnia committed
1488 1489
                                                            // this.setState({ loading: false, buttonError: false, editable: true })
                                                            this.handleValidate()
r.kurnia's avatar
r.kurnia committed
1490 1491
                                                        }, 100);
                                                    })
r.kurnia's avatar
r.kurnia committed
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531
                                                }
                                            }
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
                                        </button>
                                        <button
                                            className="button"
                                            type="button"
                                            onClick={() => 
                                                this.state.saveDraft === true ?
                                                    null :
                                                    this.state.handleTekTekTek == 1 ? null :
                                                        this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                            setTimeout(() => {
                                                                this.backToMonthlyReport('draft')
                                                            }, 100);
                                                        })
                                            }
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.saveDraft !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                            </div>
                                        </button>
                                        <button
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            onClick={() => 
                                                this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                    :
                                                    this.state.handleTekTekTek == 1 ? null :
r.kurnia's avatar
r.kurnia committed
1532 1533 1534 1535 1536
                                                        this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                            setTimeout(() => {
                                                                this.backToMonthlyReport('submitted')
                                                            }, 100);
                                                        })
r.kurnia's avatar
r.kurnia committed
1537 1538 1539
                                            }
                                            style={{
                                                backgroundColor: 'transparent',
r.kurnia's avatar
r.kurnia committed
1540
                                                cursor: this.state.buttonError === true  ? 'default' : 'pointer',
r.kurnia's avatar
r.kurnia committed
1541 1542 1543 1544
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
                                        >
rifkaki's avatar
rifkaki committed
1545
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 10 }}>
r.kurnia's avatar
r.kurnia committed
1546 1547 1548 1549
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
                                        </button>
                                    </div>
r.kurnia's avatar
r.kurnia committed
1550
                                }
1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583
                            </div>
                        </Paper>
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div>
                                <div style={{ padding: 25 }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    {this.state.dataLoaded && (
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                            {this.state.loading && loadingComponent}
                                            <MuiThemeProvider theme={getMuiTheme()}>
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
                                            </MuiThemeProvider>
                                        </div>
                                    )}
                                </div>
                                <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                    <div className="col-1">
                                        <button
                                            type="button"
                                            onClick={() => this.setState({ loading: true, visibleTP: true }, () => {
                                                setTimeout(() => {
                                                    this.getItemHierarki()
                                                }, 100);
                                            })}
rifkaki's avatar
rifkaki committed
1584
                                            style={{ marginRight: 20, marginLeft: 10 }}
1585 1586
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
r.kurnia's avatar
r.kurnia committed
1587
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657
                                            </div>
                                        </button>
                                    </div>
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                // this.forceUpdate()
                                                this.setState({ loading: true, buttonDraft: false }, () => {
                                                    setTimeout(() => {
                                                        this.handleValidate()
                                                    }, 100);
                                                })
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
                                        </button>
                                        <button
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.saveDraft !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => this.state.saveDraft === true ?
                                                null
                                                :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.uploadTP('draft')
                                                        }, 100);
                                                    })}
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                            </div>
                                        </button>
                                        <button
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                            onClick={() => this.state.editable === true ?
                                                null
                                                :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.uploadTP('submitted')
                                                        }, 100);
                                                    })}
                                        >
rifkaki's avatar
rifkaki committed
1658
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 10 }}>
1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </Paper>
                    }
                </div>
                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                    </div>
                                </div>
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
                                acceptedFiles={["xlsx"]}
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
                                onUpload={() => {
rifkaki's avatar
rifkaki committed
1697
                                    String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("TAX") && String(this.state.judul).includes("PLANNING") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
            </div>
        );
    }
}