TaxPlanningMR.js 115 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
            console.log(response)
rifkaki's avatar
rifkaki committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
            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
141 142 143
        })
    }

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

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

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

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

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

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

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

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

            if (String(i[8]) == "Control (should be nil)") {
rifkaki's avatar
rifkaki committed
489 490 491 492 493
                this.setState({ loading: true })
                console.log(i[9].tbf)
                console.log(this.state.minValue)
                console.log(this.state.maxValue)
                if (Number(i[9].tbf) < Number(this.state.minValue) || Number(i[9].tbf) > Number(this.state.maxValue)) {
rifkaki's avatar
rifkaki committed
494 495 496 497 498 499 500
                    errorContrl = true
                    editAble = true
                } else {
                    errorContrl = false
                    editAble = false
                }
            }
501
        })
rifkaki's avatar
rifkaki committed
502
        // this.setState({ loading: false, buttonError: errorContrl, editable: editAble, saveDraft: false })
rifkaki's avatar
rifkaki committed
503
        console.log(errorContrl)
rifkaki's avatar
rifkaki committed
504
        let i = this.state.dataTable
505
        let payload = {
r.kurnia's avatar
r.kurnia committed
506
            "monthly_report_id": this.props.monthlyReportId,
507 508 509
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
r.kurnia's avatar
r.kurnia committed
510 511 512
            "status": "submitted",
            "months": this.props.month.month_id,
            "tax_planning": data
513
        }
rifkaki's avatar
rifkaki committed
514
        api.create().validateSubmitReportMRTP(payload).then((response) => {
rifkaki's avatar
rifkaki committed
515
            console.log(payload)
rifkaki's avatar
rifkaki committed
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
            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 })
            }
        })
538 539 540 541
    }

    downloadTemplate = async () => {
        let res = await fetch(
rifkaki's avatar
rifkaki committed
542
            `${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}`
543 544 545 546 547 548 549
        )
        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
550
            a.download = 'Template Monthly Report Tax Planning.xlsx';
551 552 553 554 555
            a.click();
        }
    }

    async downloadAllData() {
rifkaki's avatar
rifkaki committed
556 557
        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
558 559
        // console.log(url);
        console.log(urls);
560
        let res = await fetch(
r.kurnia's avatar
r.kurnia committed
561
            this.props.monthlyReportId == null ? url : urls
562 563 564 565 566 567 568
        )
        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
569
            a.download = 'Monthly Report Tax Planning.xlsx';
570 571 572 573 574 575 576 577 578 579 580
            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
581
            let form = dex === 1 ? tableMeta.rowData[6].tbc : dex === 2 ? tableMeta.rowData[6].fcp : dex === 3 ? tableMeta.rowData[6].tbf : tableMeta.rowData[6].tbf
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
            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
613

614 615 616 617 618 619 620 621
            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
622
                            let indexID = dataTable2.findIndex((val) => val[13] == splitform[0])
623 624 625 626 627 628 629 630 631 632 633 634 635 636
                            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
637 638 639
                                let tst = String(item).replace('[M-1]', '[M1]')
                                // let data = tableMeta.columnIndex == 9 ? 20 : tableMeta.columnIndex - 1
                                let data = tableMeta.columnIndex
640 641 642 643 644 645 646 647
                                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
648
                                let data = tableMeta.rowData[12] === null ? [] : tableMeta.rowData[12]
rifkaki's avatar
rifkaki committed
649
                                let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
650
                                if (indexID !== -1) {
r.kurnia's avatar
r.kurnia committed
651
                                    let valuezz = data[indexID].value
652 653 654 655 656
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                            }
                        }
                    } else {
r.kurnia's avatar
r.kurnia committed
657
                        let indexID = dataTable2.findIndex((val) => val[13] == item)
658
                        if (indexID !== -1) {
r.kurnia's avatar
r.kurnia committed
659
                            if (dataTable2[indexID][13] == tableMeta.rowData[13]) {
660 661
                                anjay.push(0)
                            } else {
rifkaki's avatar
rifkaki committed
662
                                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]
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 748 749 750 751 752 753
                                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
754
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc = Number(total).toFixed(1)
755
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
756
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc.value = Number(total).toFixed(1)
757 758 759
                }
            } else if (dex == 2) {
                if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value == undefined) {
Deni Rinaldi's avatar
Deni Rinaldi committed
760
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = Number(total).toFixed(1)
761
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
762
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value = Number(total).toFixed(1)
763
                }
rifkaki's avatar
rifkaki committed
764
            } else if (dex == 3) {
r.kurnia's avatar
r.kurnia committed
765 766 767
                if (tableMeta.rowData[8] == "Corporate Income Tax") {
                    if (total < 0) {
                        total = 0
rifkaki's avatar
rifkaki committed
768
                        dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(2)
r.kurnia's avatar
r.kurnia committed
769 770 771 772
                    } 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
773
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(1)
774
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
775
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf.value = Number(total).toFixed(1)
776
                }
rifkaki's avatar
rifkaki committed
777 778 779 780 781 782
            } 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)
                }
783 784
            }

rifkaki's avatar
rifkaki committed
785
            return tableMeta.rowData[8] == "Corporate Income Tax" ? Number(total).toFixed(2) : Number(total).toFixed(1)
786 787 788 789 790
        }

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

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

            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
850
            } else if (type == 3) {
851
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = total
r.kurnia's avatar
r.kurnia committed
852 853
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
854 855 856 857
            }
            return total
        }

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

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

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

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