TaxPlanningMR.js 114 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: '-',
rifkaki's avatar
rifkaki committed
52
            notesUpdate: "",
53 54
            buttonDraft: true,
            handleTekTekTek: 0,
r.kurnia's avatar
r.kurnia committed
55
            saveDraft: true,
d.arizona's avatar
d.arizona committed
56
            buttonError: true,
rifkaki's avatar
rifkaki committed
57 58
            get_for: "view",
            viewOnly : true
59 60 61 62 63 64

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

    componentDidMount() {
r.kurnia's avatar
r.kurnia committed
65 66
        this.getSettingControl()
        // this.getItemHierarki()
r.kurnia's avatar
r.kurnia committed
67
        this.getLatestUpdate()
rifkaki's avatar
rifkaki committed
68 69 70 71 72 73 74
        this.handleViewOnly()
    }

    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
d.arizona's avatar
d.arizona committed
75
        let checkPrevRev = false
rifkaki's avatar
rifkaki committed
76 77 78 79 80 81 82 83 84 85 86 87 88

        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }
        
        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
        } 
        
d.arizona's avatar
d.arizona committed
89 90 91 92 93 94
        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }

rifkaki's avatar
rifkaki committed
95 96 97 98 99 100
        if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
            checkStatus = true
        } else {
            checkStatus = false
        }

d.arizona's avatar
d.arizona committed
101
        this.setState({viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev})
102 103
    }

d.arizona's avatar
d.arizona committed
104 105 106 107 108 109 110
    handleGetFor(type) {
        this.setState({get_for: type}, () => {
            this.getSettingControl()
            this.getLatestUpdate()
        })
    }

r.kurnia's avatar
r.kurnia committed
111 112 113 114 115 116 117 118
    getSettingControl() {
        let body = {
            group: 'THRESHOLD_CONTROL',
            company_id: this.props.company.company_id,
            type: 'TAX_PLANNING'
        }

        api.create().getAllSettingByType(body).then(response => {
rifkaki's avatar
rifkaki committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({
                        minValue: response.data.data[0] ? response.data.data[0].min_value : null,
                        maxValue: response.data.data[0] ? response.data.data[0].max_value : null,
                    }, () => {
                        this.getItemHierarki()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
r.kurnia's avatar
r.kurnia committed
140 141 142
        })
    }

143 144
    getLatestUpdate() {
        let payload = {
r.kurnia's avatar
r.kurnia committed
145 146 147 148 149 150
            "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
151
        }
r.kurnia's avatar
r.kurnia committed
152
        api.create().getLastestUpdateMR(payload).then(response => {
rifkaki's avatar
rifkaki committed
153
            // console.log(response)
154 155 156
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
r.kurnia's avatar
r.kurnia committed
157
                        updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update,
rifkaki's avatar
rifkaki committed
158
                        notesUpdate: response.data.data.notes_update === null ? "" : response.data.data.notes_update
159 160 161 162 163 164 165 166 167
                    })
                }
            }
        })
    }

    getItemHierarki() {
        this.setState({ loading: true, judulColumn: null })
        let payload = {
r.kurnia's avatar
r.kurnia committed
168 169 170 171 172
            "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,
rifkaki's avatar
rifkaki committed
173
            "months": this.props.month.month_id,
rifkaki's avatar
rifkaki committed
174
            "get_for": this.state.get_for
175
        }
r.kurnia's avatar
r.kurnia committed
176
        api.create().getHierarkiMontlyReportTP(payload).then(response => {
r.kurnia's avatar
r.kurnia committed
177
            console.log(response);
rifkaki's avatar
rifkaki committed
178
            console.log(payload);
179 180
            let dataTable = []
            if (response.data) {
r.kurnia's avatar
r.kurnia committed
181 182 183 184 185 186 187
                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
188 189 190
                                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
191 192
                                item.id,
                                item.parent,
r.kurnia's avatar
r.kurnia committed
193
                                { 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
194 195
                                item.level,
                                item.description,
r.kurnia's avatar
r.kurnia committed
196 197 198 199 200
                                {
                                    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
201
                                0,
r.kurnia's avatar
r.kurnia committed
202
                                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
203
                                item.tax_planning.actual_formula,
r.kurnia's avatar
r.kurnia committed
204
                                item.order,
r.kurnia's avatar
r.kurnia committed
205 206
                                { 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
207 208
                                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
209 210 211 212 213 214 215 216 217 218 219
                            ])
                        }
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
                        }
                    }
                    res.map((item, index) => {
220 221
                        dataTable.push([
                            item.type_report_id,
r.kurnia's avatar
r.kurnia committed
222 223 224
                            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,
225 226
                            item.id,
                            item.parent,
r.kurnia's avatar
r.kurnia committed
227
                            { tbc: item.formula_tax.value_tbc, fcp: item.formula_tax.value_fc, tbf: item.formula_tax.value_tbf },
228 229
                            item.level,
                            item.description,
r.kurnia's avatar
r.kurnia committed
230 231 232 233 234
                            {
                                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
235
                            0,
r.kurnia's avatar
r.kurnia committed
236
                            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
237
                            item.tax_planning.actual_formula,
238
                            item.order,
r.kurnia's avatar
r.kurnia committed
239 240
                            { 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
241
                            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,
242
                        ])
r.kurnia's avatar
r.kurnia committed
243 244 245 246 247 248
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
249
                        }
r.kurnia's avatar
r.kurnia committed
250
                    })
r.kurnia's avatar
r.kurnia committed
251
                    this.setState({ dataTable, loading: false, editable: true })
r.kurnia's avatar
r.kurnia committed
252 253 254 255 256 257 258
                } 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);
259
                        }
r.kurnia's avatar
r.kurnia committed
260 261
                    })
                }
262
            } else {
r.kurnia's avatar
r.kurnia committed
263
                this.setState({ dataTable, loading: false, editable: true })
264
            }
r.kurnia's avatar
r.kurnia committed
265
            console.log(this.state.dataTable)
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
        })
    }

    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
288
    backToMonthlyReport(type) {
289 290 291
        let data = []
        this.state.dataTable.map(i => {
            data.push({
r.kurnia's avatar
r.kurnia committed
292
                item_report_id: i[4],
Deni Rinaldi's avatar
Deni Rinaldi committed
293
                trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
r.kurnia's avatar
r.kurnia committed
294 295 296 297
                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))
298 299 300
            })
        })
        let payload = {
r.kurnia's avatar
r.kurnia committed
301
            "monthly_report_id": this.props.monthlyReportId,
302 303 304 305
            "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
306
            "months": this.props.month.month_id,
307 308
            "tax_planning": data
        }
r.kurnia's avatar
r.kurnia committed
309

310
        api.create('UPLOAD').createMonthlyReportTP(payload).then(response => {
r.kurnia's avatar
r.kurnia committed
311 312
            console.log(payload);
            console.log(response);
r.kurnia's avatar
r.kurnia committed
313 314
            if (response.data) {
                if (response.data.status === "success") {
315
                    this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
316
                } else {
r.kurnia's avatar
r.kurnia committed
317
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
r.kurnia's avatar
r.kurnia committed
318 319 320 321 322 323 324
                        document.body.style.overflow = 'unset';
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
325
                        this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
326
                    })
r.kurnia's avatar
r.kurnia committed
327
                }
r.kurnia's avatar
r.kurnia committed
328
            } else {
329
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
r.kurnia's avatar
r.kurnia committed
330 331
            }
        })
332 333 334 335 336 337 338 339 340 341
    }

    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
342
                let isi = resp.rows.slice(3)
343 344 345 346 347 348 349
                // 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
350 351 352
                            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
353 354 355
                            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
356 357
                            trial_balance_fiscal_actual: "",
                            trial_balance_fiscal_mb: "",
358 359 360 361 362 363 364
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
365
                    months: this.props.month.month_id,
366 367
                    tax_planning: payload,
                    status: "submitted"
368
                }
rifkaki's avatar
rifkaki committed
369
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
rifkaki's avatar
rifkaki committed
370 371
                // console.log(this.state.judulColumn)
                // console.log(this.state.judul)
372 373 374 375 376
            }
        });
    }

    checkUpload() {
377
        api.create().checkUploadMonthlyReportTP(this.state.payload).then(response => {
378
            // console.log(JSON.stringify(this.state.payload));
379 380
            console.log(this.state.payload)
            console.log(response)
381 382 383 384 385 386
            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
387 388 389
                            Number(item.type_report_id.tbc),
                            Number(item.type_report_id.fcp),
                            Number(item.type_report_id.tbf),
390 391
                            item.item_report_id,
                            item.parent,
r.kurnia's avatar
r.kurnia committed
392
                            { tbc: item.formula.tbc, fcp: item.formula.fcp, tbf: item.formula.tbf },
393 394 395
                            item.level,
                            item.item_report,
                            {
r.kurnia's avatar
r.kurnia committed
396
                                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
397 398
                                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),
399
                            },
rifkaki's avatar
rifkaki committed
400
                            0,
r.kurnia's avatar
r.kurnia committed
401
                            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
402
                            item.actual_formula,
r.kurnia's avatar
r.kurnia committed
403 404 405
                            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
406
                            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),
407 408 409 410 411
                            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
412
                            if (item[17].length > 0) {
413 414 415 416
                                // console.log('masuk')
                                this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true })
                            }
                        })
r.kurnia's avatar
r.kurnia committed
417
                        // console.log(this.state.dataTable);
418 419 420 421 422 423 424 425 426 427 428
                    })
                }
            }
        })
    }

    uploadTP(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[4],
r.kurnia's avatar
r.kurnia committed
429
                trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
r.kurnia's avatar
r.kurnia committed
430 431 432 433
                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))
434 435 436
            })
        })
        let body = {
r.kurnia's avatar
r.kurnia committed
437 438 439 440 441 442 443
            "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
444 445
        }
        // console.log(data);
r.kurnia's avatar
r.kurnia committed
446
        api.create('UPLOAD').uploadMonthlyReportTP(body).then(response => {
r.kurnia's avatar
r.kurnia committed
447 448
            // console.log(body);
            // console.log(JSON.stringify(body));
rifkaki's avatar
rifkaki committed
449
            console.log(response);
450 451
            if (response.data) {
                if (response.data.status === "success") {
r.kurnia's avatar
r.kurnia committed
452
                    this.props.saveToMonthlyReport()
453
                } else {
r.kurnia's avatar
r.kurnia committed
454 455 456 457 458 459 460
                    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
461
                        this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
462 463
                    })
                    // alert(response.data.status)
464 465
                }
            } else {
r.kurnia's avatar
r.kurnia committed
466
                this.setState({ loading: false, alert: true, messageAlert: response.problem, tipeAlert: 'error' })
467 468 469 470 471 472
            }
        })
    }

    handleValidate() {
        let data = []
rifkaki's avatar
rifkaki committed
473 474
        let errorContrl = this.state.buttonError
        let editAble = this.state.editAble
475 476 477
        // console.log(this.state.dataTable)
        this.state.dataTable.map(i => {
            data.push({
r.kurnia's avatar
r.kurnia committed
478 479 480 481 482 483
                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))
484
            })
rifkaki's avatar
rifkaki committed
485 486

            if (String(i[8]) == "Control (should be nil)") {
487
                if (i[9].tbf < this.state.minValue || i[9].tbf > this.state.maxValue) {
rifkaki's avatar
rifkaki committed
488 489 490 491 492 493 494
                    errorContrl = true
                    editAble = true
                } else {
                    errorContrl = false
                    editAble = false
                }
            }
495
        })
rifkaki's avatar
rifkaki committed
496
        // this.setState({ loading: false, buttonError: errorContrl, editable: editAble, saveDraft: false })
rifkaki's avatar
rifkaki committed
497 498

        let i = this.state.dataTable
499
        let payload = {
r.kurnia's avatar
r.kurnia committed
500
            "monthly_report_id": this.props.monthlyReportId,
501 502 503
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
r.kurnia's avatar
r.kurnia committed
504 505 506
            "status": "submitted",
            "months": this.props.month.month_id,
            "tax_planning": data
507
        }
rifkaki's avatar
rifkaki committed
508
        api.create().validateSubmitReportMRTP(payload).then((response) => {
rifkaki's avatar
rifkaki committed
509
            console.log(payload)
rifkaki's avatar
rifkaki committed
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    if (response.data.data.result && errorContrl === false && editAble === false ) {
                        this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
                    } else {
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
532 533 534 535
    }

    downloadTemplate = async () => {
        let res = await fetch(
rifkaki's avatar
rifkaki committed
536
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/tax_planning/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
537 538 539 540 541 542 543
        )
        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
544
            a.download = 'Template Monthly Report Tax Planning.xlsx';
545 546 547 548 549
            a.click();
        }
    }

    async downloadAllData() {
rifkaki's avatar
rifkaki committed
550 551
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/tax_planning/monthly_report/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/tax_planning/monthly_report/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
552 553
        // console.log(url);
        console.log(urls);
554
        let res = await fetch(
r.kurnia's avatar
r.kurnia committed
555
            this.props.monthlyReportId == null ? url : urls
556 557 558 559 560 561 562
        )
        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
563
            a.download = 'Monthly Report Tax Planning.xlsx';
564 565 566 567 568 569 570 571 572 573 574
            a.click();
        }
    }

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

    render() {
        let dataTable2 = this.state.dataTable
        const handleValueFormula = (value, tableMeta, dex, xntd, forecast, periode) => {
rifkaki's avatar
rifkaki committed
575
            let form = dex === 1 ? tableMeta.rowData[6].tbc : dex === 2 ? tableMeta.rowData[6].fcp : dex === 3 ? tableMeta.rowData[6].tbf : tableMeta.rowData[6].tbf
576 577 578 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
            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
607

608 609 610 611 612 613 614 615
            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
616
                            let indexID = dataTable2.findIndex((val) => val[13] == splitform[0])
617 618 619 620 621 622 623 624 625 626 627 628 629 630
                            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
631 632 633
                                let tst = String(item).replace('[M-1]', '[M1]')
                                // let data = tableMeta.columnIndex == 9 ? 20 : tableMeta.columnIndex - 1
                                let data = tableMeta.columnIndex
634 635 636 637 638 639 640 641
                                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 {
rifkaki's avatar
rifkaki committed
642
                                let data = tableMeta.rowData[12] === null ? [] : tableMeta.rowData[12]
rifkaki's avatar
rifkaki committed
643
                                let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
644
                                if (indexID !== -1) {
r.kurnia's avatar
r.kurnia committed
645
                                    let valuezz = data[indexID].value
646 647 648 649 650
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                            }
                        }
                    } else {
r.kurnia's avatar
r.kurnia committed
651
                        let indexID = dataTable2.findIndex((val) => val[13] == item)
652
                        if (indexID !== -1) {
r.kurnia's avatar
r.kurnia committed
653
                            if (dataTable2[indexID][13] == tableMeta.rowData[13]) {
654 655
                                anjay.push(0)
                            } else {
rifkaki's avatar
rifkaki committed
656
                                let data = dex == 1 ? dataTable2[indexID][tableMeta.columnIndex].tbc : dex == 2 ? dataTable2[indexID][tableMeta.columnIndex].fcp : dex == 3 ? dataTable2[indexID][tableMeta.columnIndex].tbf : dataTable2[indexID][tableMeta.columnIndex]
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
                                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
748
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc = Number(total).toFixed(1)
749
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
750
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc.value = Number(total).toFixed(1)
751 752 753
                }
            } else if (dex == 2) {
                if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value == undefined) {
Deni Rinaldi's avatar
Deni Rinaldi committed
754
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = Number(total).toFixed(1)
755
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
756
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value = Number(total).toFixed(1)
757
                }
rifkaki's avatar
rifkaki committed
758
            } else if (dex == 3) {
r.kurnia's avatar
r.kurnia committed
759 760 761
                if (tableMeta.rowData[8] == "Corporate Income Tax") {
                    if (total < 0) {
                        total = 0
rifkaki's avatar
rifkaki committed
762
                        dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(2)
r.kurnia's avatar
r.kurnia committed
763 764 765 766
                    } 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
767
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(1)
768
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
769
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf.value = Number(total).toFixed(1)
770
                }
rifkaki's avatar
rifkaki committed
771 772 773 774 775 776
            } else {
                if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(1)
                } else {
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = Number(total).toFixed(1)
                }
777 778
            }

rifkaki's avatar
rifkaki committed
779
            return tableMeta.rowData[8] == "Corporate Income Tax" ? Number(total).toFixed(2) : Number(total).toFixed(1)
780 781 782
        }

        const handleChange = (value, tableMeta, indexChilds) => {
r.kurnia's avatar
r.kurnia committed
783
            console.log(dataTable2)
784 785
            let val = String(value).split(",").join("")
            // let data = this.state.dataTable2
r.kurnia's avatar
r.kurnia committed
786
            let indexParent = dataTable2.findIndex((val) => val[4] === dataTable2[tableMeta.rowIndex][5])
787 788 789 790 791 792 793 794 795
            // 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) {
rifkaki's avatar
rifkaki committed
796
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc = Number(val)
797 798
                }
                else if (indexChilds == 1) {
rifkaki's avatar
rifkaki committed
799
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = Number(val)
800 801
                }
                else if (indexChilds == 2) {
rifkaki's avatar
rifkaki committed
802
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(val)
803 804 805
                }
            }
        }
rifkaki's avatar
rifkaki committed
806
        const handleTotal = (value, tableMeta, dex) => {
rifkaki's avatar
rifkaki committed
807
            // console.log(tableMeta)
rifkaki's avatar
rifkaki committed
808
            let total = 0
809
            dataTable2[tableMeta.rowIndex].map((item, index) => {
r.kurnia's avatar
r.kurnia committed
810
                if (index == 9) {
rifkaki's avatar
rifkaki committed
811 812
                    let valItemTBF = item.tbf == undefined || item.tbf == "" || item.tbf == "undefined" ? 0.0 : item.tbf
                    total = Number(tableMeta.rowData[16]) + Number(valItemTBF)
813 814 815
                }
            })
            
rifkaki's avatar
rifkaki committed
816
            dataTable2[tableMeta.rowIndex][10] = Number(total)
rifkaki's avatar
rifkaki committed
817
            return total
818 819 820 821 822
        }

        const handleParent = (tableMeta, type) => {
            let total = 0
            dataTable2.map((item, index) => {
r.kurnia's avatar
r.kurnia committed
823
                if (item[5] == tableMeta.rowData[4]) {
824 825 826 827 828 829
                    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
830 831 832 833 834
                            (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)
                            )
835 836 837 838 839 840 841 842 843
                        )
                    )
                }
            })

            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
844
            } else if (type == 3) {
845
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = total
r.kurnia's avatar
r.kurnia committed
846 847
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
848 849 850 851
            }
            return total
        }

r.kurnia's avatar
r.kurnia committed
852 853
        const columns = [
        {
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877
            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
878 879 880 881 882 883 884 885 886 887 888 889 890 891 892
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
893 894 895 896 897 898 899 900 901 902 903 904
        }, {
            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
905
                            {tableMeta.rowData[0] === null ?
r.kurnia's avatar
r.kurnia committed
906
                                tableMeta.rowData[7] == 0 ?
r.kurnia's avatar
r.kurnia committed
907 908 909
                                    <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
910
                                    <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[7]) }}>
911 912 913 914 915
                                        <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
916
                                tableMeta.rowData[7] == 0 ?
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946
                                    <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
947
                customBodyRender: (value, tableMeta, updateValue) => {
948 949 950 951
                    return (
                        <div>
                            <div className="grid grid-3x content-center">
                                <div className="col-1">
r.kurnia's avatar
r.kurnia committed
952
                                    <div style={{ textAlign: 'right', width: 90 }}>
r.kurnia's avatar
r.kurnia committed
953
                                        {tableMeta.rowData[1] === 4 || tableMeta.rowData[1] === 1 ?
r.kurnia's avatar
r.kurnia committed
954
                                            null :
d.arizona's avatar
d.arizona committed
955
                                            this.state.get_for == 'view'?
rifkaki's avatar
rifkaki committed
956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971
                                                <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}
                                                                value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.tbc).toFixed(2) : Number(value.tbc).toFixed(1)}
                                                            />
                                                        }
                                                    />
                                                </div>
d.arizona's avatar
d.arizona committed
972
                                            :
r.kurnia's avatar
r.kurnia committed
973
                                            tableMeta.rowData[1] === 2 ?
r.kurnia's avatar
r.kurnia committed
974 975 976 977 978 979 980
                                                <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
981
                                                        value={Number(handleParent(tableMeta, 1)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
982 983 984
                                                    />
                                                </span>
                                                :
r.kurnia's avatar
r.kurnia committed
985 986 987 988 989 990 991 992 993
                                                tableMeta.rowData[1] === 3 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value.tbc}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    decimalSeparator={"."}
d.arizona's avatar
d.arizona committed
994
                                                                    style={{ color: this.props.isApprover || this.state.get_for == 'view' ? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
995 996
                                                                    type="text"
                                                                    placeholder="input"
d.arizona's avatar
d.arizona committed
997
                                                                    disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
Deni Rinaldi's avatar
Deni Rinaldi committed
998
                                                                    value={Number(value.tbc).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
999 1000 1001 1002 1003 1004
                                                                    onBlur={(event) => {
                                                                        handleChange(event.target.value, tableMeta, 0)
                                                                        // console.log(dataTable2)
                                                                    }}
                                                                />
                                                            }
r.kurnia's avatar
r.kurnia committed
1005
                                                        />
r.kurnia's avatar
r.kurnia committed
1006
                                                    </div> 
r.kurnia's avatar
r.kurnia committed
1007
                                                    :
r.kurnia's avatar
r.kurnia committed
1008
                                                    tableMeta.rowData[1] === 5 || tableMeta.rowData[1] === 6 ?
r.kurnia's avatar
r.kurnia committed
1009 1010 1011
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
r.kurnia's avatar
r.kurnia committed
1012
                                                                value={value.tbc}
r.kurnia's avatar
r.kurnia committed
1013 1014 1015 1016 1017 1018 1019
                                                                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
1020
                                                                        value={Number(handleValueFormula(value, tableMeta, 1)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1021 1022 1023 1024 1025
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                                        :
r.kurnia's avatar
r.kurnia committed
1026 1027 1028 1029 1030 1031 1032 1033 1034
                                                        null
                                        }
                                    </div>
                                </div>
                                <div className="col-2">
                                    <div style={{ textAlign: 'right', width: 90 }}>
                                        {tableMeta.rowData[2] === 4 || tableMeta.rowData[2] === 1 ?
                                            null 
                                            :
d.arizona's avatar
d.arizona committed
1035
                                            this.state.get_for == 'view'?
rifkaki's avatar
rifkaki committed
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value.fcp}
                                                        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(value.fcp).toFixed(2) : Number(value.fcp).toFixed(1)}
                                                            />
                                                        }
                                                    />
                                                </div>
d.arizona's avatar
d.arizona committed
1052
                                            :
r.kurnia's avatar
r.kurnia committed
1053 1054 1055 1056 1057 1058 1059 1060
                                            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
1061
                                                        value={Number(handleParent(tableMeta, 2)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
                                                    />
                                                </span>
                                                :
                                                tableMeta.rowData[2] === 3 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value.fcp}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
d.arizona's avatar
d.arizona committed
1073
                                                                    style={{ color: this.props.isApprover || this.state.get_for == 'view'? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
1074
                                                                    type="text"
d.arizona's avatar
d.arizona committed
1075
                                                                    disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
r.kurnia's avatar
r.kurnia committed
1076
                                                                    placeholder="input"
r.kurnia's avatar
r.kurnia committed
1077
                                                                    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
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
                                                                    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
1088 1089 1090
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
r.kurnia's avatar
r.kurnia committed
1091
                                                                value={value.tbc}
r.kurnia's avatar
r.kurnia committed
1092 1093 1094
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
r.kurnia's avatar
r.kurnia committed
1095
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
1096
                                                                        type="text"
r.kurnia's avatar
r.kurnia committed
1097 1098
                                                                        placeholder=""
                                                                        disabled={true}
r.kurnia's avatar
r.kurnia committed
1099
                                                                        value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1100 1101 1102 1103
                                                                    />
                                                                }
                                                            />
                                                        </div>
r.kurnia's avatar
r.kurnia committed
1104 1105
                                                        :
                                                        null
r.kurnia's avatar
r.kurnia committed
1106 1107 1108
                                        }
                                    </div>
                                </div>
1109
                                <div className="col-3">
r.kurnia's avatar
r.kurnia committed
1110
                                    <div style={{ textAlign: 'right', width: 90 }}>
r.kurnia's avatar
r.kurnia committed
1111
                                        {tableMeta.rowData[3] === 4 || tableMeta.rowData[3] === 1 ? 
r.kurnia's avatar
r.kurnia committed
1112
                                            null :
d.arizona's avatar
d.arizona committed
1113
                                            this.state.get_for == 'view'?
rifkaki's avatar
rifkaki committed
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value.tbf}
                                                        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(value.tbf).toFixed(2) : Number(value.tbf).toFixed(1)}
                                                            />
                                                        }
                                                    />
                                                </div>
d.arizona's avatar
d.arizona committed
1130
                                            :
r.kurnia's avatar
r.kurnia committed
1131
                                            tableMeta.rowData[3] === 2 ?
r.kurnia's avatar
r.kurnia committed
1132
                                                <span style={{ fontSize: 12, textAlign: 'right' }}>
r.kurnia's avatar
r.kurnia committed
1133 1134
                                                    <NumberFormat
                                                        thousandSeparator={true}
r.kurnia's avatar
r.kurnia committed
1135
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
1136 1137 1138
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1139
                                                        value={Number(handleParent(tableMeta, 3)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1140 1141 1142
                                                    />
                                                </span>
                                                :
r.kurnia's avatar
r.kurnia committed
1143 1144 1145 1146 1147 1148 1149 1150
                                                tableMeta.rowData[3] === 3 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value.tbf}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
d.arizona's avatar
d.arizona committed
1151
                                                                    style={{ color: this.props.isApprover || this.state.get_for == 'view'? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
1152
                                                                    type="text"
d.arizona's avatar
d.arizona committed
1153
                                                                    disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
r.kurnia's avatar
r.kurnia committed
1154
                                                                    placeholder="input"
r.kurnia's avatar
r.kurnia committed
1155
                                                                    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
1156 1157 1158 1159 1160 1161 1162
                                                                    onBlur={(event) => {
                                                                        handleChange(event.target.value, tableMeta, 2)
                                                                        // console.log(dataTable2)
                                                                    }}
                                                                />
                                                            }
                                                        />
r.kurnia's avatar
r.kurnia committed
1163
                                                    </div>
r.kurnia's avatar
r.kurnia committed
1164 1165
                                                    :
                                                    tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 ?
r.kurnia's avatar
r.kurnia committed
1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
                                                    <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
1177
                                                                    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
1178 1179
                                                                />
                                                            }
r.kurnia's avatar
r.kurnia committed
1180
                                                        />
r.kurnia's avatar
r.kurnia committed
1181 1182
                                                    </div>
                                                    :
r.kurnia's avatar
r.kurnia committed
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200
                                                    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
1201
                                                            <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
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218
                                                                <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
1219 1220
                                                            :
                                                            null
1221 1222 1223 1224 1225 1226 1227 1228 1229
                                        }
                                    </div>
                                </div>
                            </div>
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1230
            name: `Trial Balance (Fiscal) Actual YTD`,
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242
            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
1243
                customBodyRender: (value, tableMeta, updateValue) => {
1244
                    return (
r.kurnia's avatar
r.kurnia committed
1245
                        <div style={{ textAlign: 'right', width: 90 }}>
1246
                            {tableMeta.rowData[3] === 4 || tableMeta.rowData[3] === 1 || tableMeta.rowData[3] === 7?
r.kurnia's avatar
r.kurnia committed
1247 1248
                                null 
                                :
d.arizona's avatar
d.arizona committed
1249
                                this.state.get_for == 'view'?
rifkaki's avatar
rifkaki committed
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
                                    <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}
1261
                                                    value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(tableMeta.rowData[16]).toFixed(2) : Number(tableMeta.rowData[16]).toFixed(1)}
rifkaki's avatar
rifkaki committed
1262 1263 1264 1265
                                                />
                                            }
                                        />
                                    </div>
d.arizona's avatar
d.arizona committed
1266
                                :
r.kurnia's avatar
r.kurnia committed
1267
                                tableMeta.rowData[3] === 2 ?
r.kurnia's avatar
r.kurnia committed
1268 1269 1270 1271 1272 1273 1274
                                    <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
1275
                                            value={Number(handleParent(tableMeta, 4)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1276 1277 1278
                                        />
                                    </span>
                                    :
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318
                                    // tableMeta.rowData[3] === 7 ?
                                    //     (Number(handleValueFormula(value, tableMeta, 4)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(value, tableMeta, 4)).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>
                                    //             <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, 4)).toFixed(1)}
                                    //                 value={Number(value).toFixed(1)}
                                    //             />
                                    //         </LightTooltip>
                                    //         :
rifkaki's avatar
rifkaki committed
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334
                                            <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
1335

r.kurnia's avatar
r.kurnia committed
1336
                            }
1337 1338 1339 1340 1341
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1342
            name: `Trial Balance (Fiscal) MB YTD`,
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354
            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
1355
                customBodyRender: (value, tableMeta, updateValue) => {
1356
                    return (
r.kurnia's avatar
r.kurnia committed
1357
                        <div style={{ textAlign: 'right', width: 90 }}>
rifkaki's avatar
rifkaki committed
1358
                            {tableMeta.rowData[3] === 4 || tableMeta.rowData[3] === 1 || tableMeta.rowData[3] === 7 ? 
r.kurnia's avatar
r.kurnia committed
1359 1360
                                null 
                                :
d.arizona's avatar
d.arizona committed
1361
                                this.state.get_for == 'view'?
rifkaki's avatar
rifkaki committed
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373
                                    // Number(value).toFixed(1) 
                                    <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}
1374
                                                    value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(tableMeta.rowData[11]).toFixed(2) : Number(tableMeta.rowData[11]).toFixed(1)}
rifkaki's avatar
rifkaki committed
1375 1376 1377 1378
                                                />
                                            }
                                        />
                                    </div>
d.arizona's avatar
d.arizona committed
1379
                                :
r.kurnia's avatar
r.kurnia committed
1380
                                tableMeta.rowData[3] === 2 ?
r.kurnia's avatar
r.kurnia committed
1381 1382 1383 1384 1385 1386 1387
                                    <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
1388
                                            value={Number(handleParent(tableMeta, 4)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1389 1390 1391
                                        />
                                    </span>
                                    :
rifkaki's avatar
rifkaki committed
1392 1393 1394 1395 1396
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
r.kurnia's avatar
r.kurnia committed
1397 1398
                                                <NumberFormat
                                                    thousandSeparator={true}
rifkaki's avatar
rifkaki committed
1399
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
r.kurnia's avatar
r.kurnia committed
1400 1401 1402
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
rifkaki's avatar
rifkaki committed
1403
                                                    value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value).toFixed(2) : Number(value).toFixed(1)}
rifkaki's avatar
rifkaki committed
1404
                                                />
rifkaki's avatar
rifkaki committed
1405 1406 1407
                                            }
                                        />
                                    </div>
r.kurnia's avatar
r.kurnia committed
1408
                            }
1409 1410 1411 1412
                        </div>
                    )
                }
            }
rifkaki's avatar
rifkaki committed
1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425
        },  
        {
            name: "",
            options: {
                display: false
            }
        },
        {
            name: "",
            options: {
                display: false
            }
        },
1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444
        {
            name: "",
            options: {
                display: false
            }
        },
        {
            name: "",
            options: {
                display: false
            }
        },
        {
            name: "",
            options: {
                display: false
            }
        },
        ]
1445

1446
        const loadingComponent = (
1447
            <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)' }}>
1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459
                <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 }}>
1460
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report Submission</Typography>
1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471
                </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' }} >
1472
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Tax Planning</Typography>
1473 1474 1475 1476
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
1477
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
rifkaki's avatar
rifkaki committed
1478
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()}, {this.props.periode} (rev.{this.props.revision})</Typography>
1479 1480 1481
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
d.arizona's avatar
d.arizona committed
1482
                                        {this.props.isApprover === true || this.state.get_for == 'view'?
r.kurnia's avatar
r.kurnia committed
1483
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
1484 1485 1486 1487 1488 1489 1490 1491
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
r.kurnia's avatar
r.kurnia committed
1492 1493 1494 1495 1496 1497
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
1498 1499 1500 1501 1502
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
r.kurnia's avatar
r.kurnia committed
1503
                                            </div> :
1504
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
r.kurnia's avatar
r.kurnia committed
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 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551
                                                <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" />
1552
                                            </div>
r.kurnia's avatar
r.kurnia committed
1553
                                        }
1554
                                    </div>
r.kurnia's avatar
r.kurnia committed
1555
                                </div>      
1556 1557 1558

                                <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
1559 1560 1561 1562 1563 1564 1565 1566
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    {/* )} */}
1567
                                </div>
r.kurnia's avatar
r.kurnia committed
1568
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20, marginLeft: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
r.kurnia's avatar
r.kurnia committed
1569
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, marginLeft: 20 }}>Notes : {this.state.notesUpdate}</Typography>
1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586
                            </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
1587
                                        <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
1588
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
1589 1590 1591
                                        </div>
                                    </button>
                                </div>
r.kurnia's avatar
r.kurnia committed
1592 1593
                                {/* {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
1594 1595 1596 1597
                                {this.props.isApprover === true ?
                                    <div className="col-2">
                                    </div> :
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
rifkaki's avatar
rifkaki committed
1598
                                        {this.state.get_for == 'view' && this.state.viewOnly && <button
d.arizona's avatar
d.arizona committed
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({loading: true}, () => {
                                                    this.handleGetFor('edit')
                                                })
                                            }}
                                        >
                                            <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' }}>Edit</Typography>
                                            </div>
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
r.kurnia's avatar
r.kurnia committed
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630
                                            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
1631
                                                        setTimeout(() => {
r.kurnia's avatar
r.kurnia committed
1632 1633
                                                            // this.setState({ loading: false, buttonError: false, editable: true })
                                                            this.handleValidate()
r.kurnia's avatar
r.kurnia committed
1634 1635
                                                        }, 100);
                                                    })
r.kurnia's avatar
r.kurnia committed
1636 1637 1638 1639 1640 1641
                                                }
                                            }
                                        >
                                            <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>
d.arizona's avatar
d.arizona committed
1642 1643
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
r.kurnia's avatar
r.kurnia committed
1644 1645 1646 1647
                                            className="button"
                                            type="button"
                                            onClick={() => 
                                                this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1648 1649 1650 1651 1652 1653 1654 1655
                                                this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' }) 
                                            :
                                            this.state.handleTekTekTek == 1 ? null :
                                                this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                    setTimeout(() => {
                                                        this.backToMonthlyReport('draft')
                                                    }, 100);
                                                })
r.kurnia's avatar
r.kurnia committed
1656 1657 1658
                                            }
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1659
                                                cursor: 'pointer',
r.kurnia's avatar
r.kurnia committed
1660 1661 1662 1663 1664 1665 1666 1667
                                                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>
d.arizona's avatar
d.arizona committed
1668 1669
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
r.kurnia's avatar
r.kurnia committed
1670 1671 1672 1673
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            onClick={() => 
                                                this.state.buttonError ?
Riri Novita's avatar
Riri Novita committed
1674
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
r.kurnia's avatar
r.kurnia committed
1675 1676
                                                    :
                                                    this.state.handleTekTekTek == 1 ? null :
r.kurnia's avatar
r.kurnia committed
1677 1678 1679 1680 1681
                                                        this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                            setTimeout(() => {
                                                                this.backToMonthlyReport('submitted')
                                                            }, 100);
                                                        })
r.kurnia's avatar
r.kurnia committed
1682 1683 1684
                                            }
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1685
                                                cursor: 'pointer',
r.kurnia's avatar
r.kurnia committed
1686 1687 1688 1689
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
                                        >
rifkaki's avatar
rifkaki committed
1690
                                            <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
1691 1692
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
d.arizona's avatar
d.arizona committed
1693
                                        </button>}
r.kurnia's avatar
r.kurnia committed
1694
                                    </div>
r.kurnia's avatar
r.kurnia committed
1695
                                }
1696 1697 1698 1699 1700 1701 1702 1703
                            </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>
rifkaki's avatar
rifkaki committed
1704
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()}, {this.props.periode} (rev.{this.props.revision})</Typography>
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728
                                        <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
1729
                                            style={{ marginRight: 20, marginLeft: 10 }}
1730 1731
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
r.kurnia's avatar
r.kurnia committed
1732
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
                                            </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',
Riri Novita's avatar
Riri Novita committed
1765
                                                cursor: 'pointer',
1766 1767 1768 1769 1770
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1771
                                                this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788
                                                :
                                                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',
Riri Novita's avatar
Riri Novita committed
1789
                                                cursor: 'pointer',
1790 1791 1792 1793
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                            onClick={() => this.state.editable === true ?
Riri Novita's avatar
Riri Novita committed
1794
                                                this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
1795 1796 1797 1798 1799 1800 1801 1802
                                                :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.uploadTP('submitted')
                                                        }, 100);
                                                    })}
                                        >
rifkaki's avatar
rifkaki committed
1803
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 10 }}>
1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841
                                                <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
1842
                                    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") ?
1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
            </div>
        );
    }
}