TaxPlanningMR.js 117 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
            visibleTP: true,
            disabledSave: true,
            editable: false,
            judulColumn: null,
faisalhamdi's avatar
faisalhamdi committed
51
            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
            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 }, () => {
d.arizona's avatar
d.arizona committed
130
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
rifkaki's avatar
rifkaki committed
131 132 133 134 135 136 137 138 139 140
                            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({
faisalhamdi's avatar
faisalhamdi committed
158
                        updateBy: response.data.data.detail === null ? [] : response.data.data.detail,
rifkaki's avatar
rifkaki committed
159
                        notesUpdate: response.data.data.notes_update === null ? "" : response.data.data.notes_update
160
                    })
Riri Novita's avatar
Riri Novita committed
161 162
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
163
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
164 165 166 167 168 169
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
170 171 172 173 174 175 176 177
                }
            }
        })
    }

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

    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
298
    backToMonthlyReport(type) {
299 300 301
        let data = []
        this.state.dataTable.map(i => {
            data.push({
r.kurnia's avatar
r.kurnia committed
302
                item_report_id: i[4],
Deni Rinaldi's avatar
Deni Rinaldi committed
303
                trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
r.kurnia's avatar
r.kurnia committed
304 305 306 307
                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))
308 309 310
            })
        })
        let payload = {
r.kurnia's avatar
r.kurnia committed
311
            "monthly_report_id": this.props.monthlyReportId,
312 313 314 315
            "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
316
            "months": this.props.month.month_id,
317 318
            "tax_planning": data
        }
r.kurnia's avatar
r.kurnia committed
319

320
        api.create('UPLOAD').createMonthlyReportTP(payload).then(response => {
r.kurnia's avatar
r.kurnia committed
321 322
            console.log(payload);
            console.log(response);
r.kurnia's avatar
r.kurnia committed
323 324
            if (response.data) {
                if (response.data.status === "success") {
325
                    this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
326
                } else {
r.kurnia's avatar
r.kurnia committed
327
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
r.kurnia's avatar
r.kurnia committed
328
                        document.body.style.overflow = 'unset';
d.arizona's avatar
d.arizona committed
329
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
r.kurnia's avatar
r.kurnia committed
330 331 332 333 334
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
335
                        this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
336
                    })
r.kurnia's avatar
r.kurnia committed
337
                }
r.kurnia's avatar
r.kurnia committed
338
            } else {
339
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
r.kurnia's avatar
r.kurnia committed
340 341
            }
        })
342 343 344 345 346 347 348 349 350 351
    }

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

    checkUpload() {
387
        api.create().checkUploadMonthlyReportTP(this.state.payload).then(response => {
388
            // console.log(JSON.stringify(this.state.payload));
389 390
            console.log(this.state.payload)
            console.log(response)
391 392 393 394 395 396
            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
397 398 399
                            Number(item.type_report_id.tbc),
                            Number(item.type_report_id.fcp),
                            Number(item.type_report_id.tbf),
400 401
                            item.item_report_id,
                            item.parent,
r.kurnia's avatar
r.kurnia committed
402
                            { tbc: item.formula.tbc, fcp: item.formula.fcp, tbf: item.formula.tbf },
403 404 405
                            item.level,
                            item.item_report,
                            {
r.kurnia's avatar
r.kurnia committed
406
                                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
407 408
                                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),
409
                            },
rifkaki's avatar
rifkaki committed
410
                            0,
r.kurnia's avatar
r.kurnia committed
411
                            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
412
                            item.actual_formula,
r.kurnia's avatar
r.kurnia committed
413 414 415
                            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
416
                            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),
417 418 419 420 421
                            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
422
                            if (item[17].length > 0) {
423 424 425 426
                                // console.log('masuk')
                                this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true })
                            }
                        })
r.kurnia's avatar
r.kurnia committed
427
                        // console.log(this.state.dataTable);
428
                    })
Riri Novita's avatar
Riri Novita committed
429 430
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
431
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
432 433 434 435 436 437
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
438 439 440 441 442 443 444 445 446 447
                }
            }
        })
    }

    uploadTP(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[4],
r.kurnia's avatar
r.kurnia committed
448
                trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
r.kurnia's avatar
r.kurnia committed
449 450 451 452
                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))
453 454 455
            })
        })
        let body = {
r.kurnia's avatar
r.kurnia committed
456 457 458 459 460 461 462
            "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
463 464
        }
        // console.log(data);
r.kurnia's avatar
r.kurnia committed
465
        api.create('UPLOAD').uploadMonthlyReportTP(body).then(response => {
r.kurnia's avatar
r.kurnia committed
466 467
            // console.log(body);
            // console.log(JSON.stringify(body));
rifkaki's avatar
rifkaki committed
468
            console.log(response);
469 470
            if (response.data) {
                if (response.data.status === "success") {
r.kurnia's avatar
r.kurnia committed
471
                    this.props.saveToMonthlyReport()
472
                } else {
r.kurnia's avatar
r.kurnia committed
473
                    this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
474
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
r.kurnia's avatar
r.kurnia committed
475 476 477 478 479
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
r.kurnia's avatar
r.kurnia committed
480
                        this.props.saveToMonthlyReport()
r.kurnia's avatar
r.kurnia committed
481 482
                    })
                    // alert(response.data.status)
483 484
                }
            } else {
r.kurnia's avatar
r.kurnia committed
485
                this.setState({ loading: false, alert: true, messageAlert: response.problem, tipeAlert: 'error' })
486 487 488 489
            }
        })
    }

rifkaki's avatar
rifkaki committed
490
    handleValidate(dataTable2) {
491
        let data = []
rifkaki's avatar
rifkaki committed
492 493
        let errorContrl = this.state.buttonError
        let editAble = this.state.editAble
rifkaki's avatar
rifkaki committed
494 495 496
        console.log(this.state.dataTable)
        console.log(dataTable2)
        dataTable2.map(i => {
497
            data.push({
r.kurnia's avatar
r.kurnia committed
498 499 500 501 502 503
                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))
504
            })
rifkaki's avatar
rifkaki committed
505 506

            if (String(i[8]) == "Control (should be nil)") {
rifkaki's avatar
rifkaki committed
507 508 509 510 511
                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
512 513 514 515 516 517 518
                    errorContrl = true
                    editAble = true
                } else {
                    errorContrl = false
                    editAble = false
                }
            }
519
        })
rifkaki's avatar
rifkaki committed
520
        // this.setState({ loading: false, buttonError: errorContrl, editable: editAble, saveDraft: false })
rifkaki's avatar
rifkaki committed
521
        console.log(errorContrl)
rifkaki's avatar
rifkaki committed
522
        let i = this.state.dataTable
523
        let payload = {
r.kurnia's avatar
r.kurnia committed
524
            "monthly_report_id": this.props.monthlyReportId,
525 526 527
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
r.kurnia's avatar
r.kurnia committed
528 529 530
            "status": "submitted",
            "months": this.props.month.month_id,
            "tax_planning": data
531
        }
rifkaki's avatar
rifkaki committed
532
        api.create().validateSubmitReportMRTP(payload).then((response) => {
rifkaki's avatar
rifkaki committed
533
            console.log(payload)
rifkaki's avatar
rifkaki committed
534 535 536 537 538 539 540 541 542 543
            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 }, () => {
d.arizona's avatar
d.arizona committed
544
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
rifkaki's avatar
rifkaki committed
545 546 547 548 549 550 551 552 553 554 555
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
556 557 558 559
    }

    downloadTemplate = async () => {
        let res = await fetch(
rifkaki's avatar
rifkaki committed
560
            `${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}`
561 562 563 564 565 566 567
        )
        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
568
            a.download = 'Template Monthly Report Tax Planning.xlsx';
569 570 571 572 573
            a.click();
        }
    }

    async downloadAllData() {
rifkaki's avatar
rifkaki committed
574 575
        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
576 577
        // console.log(url);
        console.log(urls);
578
        let res = await fetch(
r.kurnia's avatar
r.kurnia committed
579
            this.props.monthlyReportId == null ? url : urls
580 581 582 583 584 585 586
        )
        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
587
            a.download = 'Monthly Report Tax Planning.xlsx';
588 589 590 591 592 593 594 595 596 597 598
            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
599
            let form = dex === 1 ? tableMeta.rowData[6].tbc : dex === 2 ? tableMeta.rowData[6].fcp : dex === 3 ? tableMeta.rowData[6].tbf : tableMeta.rowData[6].tbf
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
            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
631

632 633 634 635 636 637 638 639
            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
640
                            let indexID = dataTable2.findIndex((val) => val[13] == splitform[0])
641 642 643 644 645 646 647 648 649 650 651 652 653 654
                            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
655 656 657
                                let tst = String(item).replace('[M-1]', '[M1]')
                                // let data = tableMeta.columnIndex == 9 ? 20 : tableMeta.columnIndex - 1
                                let data = tableMeta.columnIndex
658 659 660 661 662 663 664 665
                                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
666
                                let data = tableMeta.rowData[12] === null ? [] : tableMeta.rowData[12]
rifkaki's avatar
rifkaki committed
667
                                let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
668
                                if (indexID !== -1) {
r.kurnia's avatar
r.kurnia committed
669
                                    let valuezz = data[indexID].value
670 671 672 673 674
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                            }
                        }
                    } else {
r.kurnia's avatar
r.kurnia committed
675
                        let indexID = dataTable2.findIndex((val) => val[13] == item)
676
                        if (indexID !== -1) {
r.kurnia's avatar
r.kurnia committed
677
                            if (dataTable2[indexID][13] == tableMeta.rowData[13]) {
678 679
                                anjay.push(0)
                            } else {
rifkaki's avatar
rifkaki committed
680
                                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]
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 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771
                                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
772
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc = Number(total).toFixed(1)
773
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
774
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc.value = Number(total).toFixed(1)
775 776 777
                }
            } else if (dex == 2) {
                if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value == undefined) {
Deni Rinaldi's avatar
Deni Rinaldi committed
778
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = Number(total).toFixed(1)
779
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
780
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp.value = Number(total).toFixed(1)
781
                }
rifkaki's avatar
rifkaki committed
782
            } else if (dex == 3) {
r.kurnia's avatar
r.kurnia committed
783 784 785
                if (tableMeta.rowData[8] == "Corporate Income Tax") {
                    if (total < 0) {
                        total = 0
rifkaki's avatar
rifkaki committed
786
                        dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(2)
r.kurnia's avatar
r.kurnia committed
787 788 789 790
                    } 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
791
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(total).toFixed(1)
792
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
793
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf.value = Number(total).toFixed(1)
794
                }
rifkaki's avatar
rifkaki committed
795 796 797 798 799 800
            } 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)
                }
801 802
            }

rifkaki's avatar
rifkaki committed
803
            return tableMeta.rowData[8] == "Corporate Income Tax" ? Number(total).toFixed(2) : Number(total).toFixed(1)
804 805 806 807 808
        }

        const handleChange = (value, tableMeta, indexChilds) => {
            let val = String(value).split(",").join("")
            // let data = this.state.dataTable2
r.kurnia's avatar
r.kurnia committed
809
            let indexParent = dataTable2.findIndex((val) => val[4] === dataTable2[tableMeta.rowIndex][5])
810 811 812 813 814 815 816 817 818
            // 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
819
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbc = Number(val)
820 821
                }
                else if (indexChilds == 1) {
rifkaki's avatar
rifkaki committed
822
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].fcp = Number(val)
823 824
                }
                else if (indexChilds == 2) {
rifkaki's avatar
rifkaki committed
825
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = Number(val)
826 827
                }
            }
rifkaki's avatar
rifkaki committed
828
            console.log(dataTable2)
829
        }
rifkaki's avatar
rifkaki committed
830
        const handleTotal = (value, tableMeta, dex) => {
rifkaki's avatar
rifkaki committed
831
            // console.log(tableMeta)
rifkaki's avatar
rifkaki committed
832
            let total = 0
833
            dataTable2[tableMeta.rowIndex].map((item, index) => {
r.kurnia's avatar
r.kurnia committed
834
                if (index == 9) {
rifkaki's avatar
rifkaki committed
835 836
                    let valItemTBF = item.tbf == undefined || item.tbf == "" || item.tbf == "undefined" ? 0.0 : item.tbf
                    total = Number(tableMeta.rowData[16]) + Number(valItemTBF)
837 838 839
                }
            })
            
rifkaki's avatar
rifkaki committed
840
            dataTable2[tableMeta.rowIndex][10] = Number(total)
rifkaki's avatar
rifkaki committed
841
            return total
842 843 844 845 846
        }

        const handleParent = (tableMeta, type) => {
            let total = 0
            dataTable2.map((item, index) => {
r.kurnia's avatar
r.kurnia committed
847
                if (item[5] == tableMeta.rowData[4]) {
848 849 850 851 852 853
                    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
854 855 856 857 858
                            (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)
                            )
859 860 861 862 863 864 865 866 867
                        )
                    )
                }
            })

            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
868
            } else if (type == 3) {
869
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].tbf = total
r.kurnia's avatar
r.kurnia committed
870 871
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
872 873 874 875
            }
            return total
        }

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

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

1470
        const loadingComponent = (
1471
            <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)' }}>
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483
                <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 }}>
1484
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report Submission</Typography>
1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
                </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' }} >
1496
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Tax Planning</Typography>
1497 1498 1499 1500
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
1501
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
rifkaki's avatar
rifkaki committed
1502
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()}, {this.props.periode} (rev.{this.props.revision})</Typography>
1503 1504 1505
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
d.arizona's avatar
d.arizona committed
1506
                                        {this.props.isApprover === true || this.state.get_for == 'view'?
r.kurnia's avatar
r.kurnia committed
1507
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
1508 1509 1510 1511 1512 1513 1514 1515
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
r.kurnia's avatar
r.kurnia committed
1516 1517 1518 1519 1520 1521
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
1522 1523 1524 1525 1526
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
r.kurnia's avatar
r.kurnia committed
1527
                                            </div> :
1528
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
r.kurnia's avatar
r.kurnia committed
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 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575
                                                <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" />
1576
                                            </div>
r.kurnia's avatar
r.kurnia committed
1577
                                        }
1578
                                    </div>
r.kurnia's avatar
r.kurnia committed
1579
                                </div>      
1580 1581 1582

                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {this.state.loading && loadingComponent}
r.kurnia's avatar
r.kurnia committed
1583
                                        {!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
r.kurnia's avatar
r.kurnia committed
1584 1585 1586 1587 1588
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
r.kurnia's avatar
r.kurnia committed
1589
                                        </MuiThemeProvider>}
r.kurnia's avatar
r.kurnia committed
1590
                                    {/* )} */}
1591
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605
                                <div style={{display: 'flex'}}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10}}>
                                        {
                                            this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>

                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1606
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5 }}>Notes : {this.state.notesUpdate}</Typography>
1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623
                            </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
1624
                                        <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
1625
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
1626 1627 1628
                                        </div>
                                    </button>
                                </div>
r.kurnia's avatar
r.kurnia committed
1629 1630
                                {/* {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
1631 1632 1633 1634
                                {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
1635
                                        {this.state.get_for == 'view' && this.state.viewOnly && <button
d.arizona's avatar
d.arizona committed
1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655
                                            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
1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667
                                            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
1668
                                                        setTimeout(() => {
r.kurnia's avatar
r.kurnia committed
1669
                                                            // this.setState({ loading: false, buttonError: false, editable: true })
rifkaki's avatar
rifkaki committed
1670
                                                            this.handleValidate(dataTable2)
r.kurnia's avatar
r.kurnia committed
1671 1672
                                                        }, 100);
                                                    })
r.kurnia's avatar
r.kurnia committed
1673 1674 1675 1676 1677 1678
                                                }
                                            }
                                        >
                                            <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
1679 1680
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
r.kurnia's avatar
r.kurnia committed
1681 1682 1683 1684
                                            className="button"
                                            type="button"
                                            onClick={() => 
                                                this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1685 1686 1687 1688 1689 1690 1691 1692
                                                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
1693 1694 1695
                                            }
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1696
                                                cursor: 'pointer',
r.kurnia's avatar
r.kurnia committed
1697 1698 1699 1700 1701 1702 1703 1704
                                                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
1705 1706
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
r.kurnia's avatar
r.kurnia committed
1707 1708 1709 1710
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            onClick={() => 
                                                this.state.buttonError ?
Riri Novita's avatar
Riri Novita committed
1711
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
r.kurnia's avatar
r.kurnia committed
1712 1713
                                                    :
                                                    this.state.handleTekTekTek == 1 ? null :
r.kurnia's avatar
r.kurnia committed
1714 1715 1716 1717 1718
                                                        this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                            setTimeout(() => {
                                                                this.backToMonthlyReport('submitted')
                                                            }, 100);
                                                        })
r.kurnia's avatar
r.kurnia committed
1719 1720 1721
                                            }
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1722
                                                cursor: 'pointer',
r.kurnia's avatar
r.kurnia committed
1723 1724 1725 1726
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
                                        >
rifkaki's avatar
rifkaki committed
1727
                                            <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
1728 1729
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
d.arizona's avatar
d.arizona committed
1730
                                        </button>}
r.kurnia's avatar
r.kurnia committed
1731
                                    </div>
r.kurnia's avatar
r.kurnia committed
1732
                                }
1733 1734 1735 1736 1737 1738 1739 1740
                            </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
1741
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()}, {this.props.periode} (rev.{this.props.revision})</Typography>
1742 1743 1744 1745 1746
                                        <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
1747
                                            {!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
1748 1749 1750 1751 1752
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
d.arizona's avatar
d.arizona committed
1753
                                            </MuiThemeProvider>}
1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765
                                        </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
1766
                                            style={{ marginRight: 20, marginLeft: 10 }}
1767 1768
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
r.kurnia's avatar
r.kurnia committed
1769
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787
                                            </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
1788
                                                        this.handleValidate(dataTable2)
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801
                                                    }, 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
1802
                                                cursor: 'pointer',
1803 1804 1805 1806 1807
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1808
                                                this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825
                                                :
                                                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
1826
                                                cursor: 'pointer',
1827 1828 1829 1830
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                            onClick={() => this.state.editable === true ?
Riri Novita's avatar
Riri Novita committed
1831
                                                this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
1832 1833 1834 1835 1836 1837 1838 1839
                                                :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.uploadTP('submitted')
                                                        }, 100);
                                                    })}
                                        >
rifkaki's avatar
rifkaki committed
1840
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 10 }}>
1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878
                                                <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
1879
                                    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") ?
1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
            </div>
        );
    }
}