BalanceSheetMR.js 232 KB
Newer Older
Riri Novita's avatar
Riri Novita committed
1
import { createMuiTheme, FormControlLabel, Input, Snackbar, MuiThemeProvider, Paper, TableCell, Tooltip, Typography, withStyles } from '@material-ui/core'
Deni Rinaldi's avatar
Deni Rinaldi committed
2 3 4 5
import MUIDataTable from 'mui-datatables';
import React, { Component } from 'react'
import ReactTooltip from 'react-tooltip';
import Images from '../../assets/Images';
Deni Rinaldi's avatar
Deni Rinaldi committed
6
import api from '../../api';
Deni Rinaldi's avatar
Deni Rinaldi committed
7 8 9
import NumberFormat from 'react-number-format';
import { type } from 'ramda';
import { PropagateLoader } from 'react-spinners';
Deni Rinaldi's avatar
Deni Rinaldi committed
10 11
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
d.arizona's avatar
d.arizona committed
12
import Constant from '../../library/Constant';
Deni Rinaldi's avatar
Deni Rinaldi committed
13
import * as R from 'ramda';
Riri Novita's avatar
Riri Novita committed
14
import { Alert } from '@material-ui/lab';
15
import { fixNumber, roundMath } from '../../library/Utils';
Deni Rinaldi's avatar
Deni Rinaldi committed
16

Deni Rinaldi's avatar
Deni Rinaldi committed
17 18 19 20 21 22 23 24 25
const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);

Deni Rinaldi's avatar
Deni Rinaldi committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
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
};

export default class BalanceSheetMR extends Component {
Deni Rinaldi's avatar
Deni Rinaldi committed
45 46 47 48
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
d.arizona's avatar
d.arizona committed
49
            loading: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
50 51 52
            visibleBSMR: true,
            valueThreshold: 0,
            minValue: 0,
Deni Rinaldi's avatar
Deni Rinaldi committed
53
            maxValue: 0,
faisalhamdi's avatar
faisalhamdi committed
54
            updateBy: [],
rifkaki's avatar
rifkaki committed
55 56
            notes: "",
            judulColumn: null,
d.arizona's avatar
d.arizona committed
57
            get_for: "view",
Faisal Hamdi's avatar
Faisal Hamdi committed
58
            viewOnly: true,
59 60
            kansas: 0,
            defaultCurrencyUpload: this.props.defaultCurrency,
Riri Novita's avatar
Riri Novita committed
61
            visibleAlertSave: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
62
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
63
        this.fileHandler = this.fileHandler.bind(this);
Deni Rinaldi's avatar
Deni Rinaldi committed
64
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
65

Deni Rinaldi's avatar
Deni Rinaldi committed
66
    componentDidMount() {
Deni Rinaldi's avatar
Deni Rinaldi committed
67
        this.getSettingControl()
Deni Rinaldi's avatar
Deni Rinaldi committed
68
        this.getLatestUpdate()
Riri Novita's avatar
Riri Novita committed
69
        this.handleViewOnly()
Riri Novita's avatar
Riri Novita committed
70 71 72 73 74 75
    }

    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
d.arizona's avatar
d.arizona committed
76
        let checkPrevRev = false
Riri Novita's avatar
Riri Novita committed
77 78 79 80 81 82

        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }
Faisal Hamdi's avatar
Faisal Hamdi committed
83

Riri Novita's avatar
Riri Novita committed
84 85 86 87
        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
Faisal Hamdi's avatar
Faisal Hamdi committed
88 89
        }

d.arizona's avatar
d.arizona committed
90 91 92 93 94
        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }
Faisal Hamdi's avatar
Faisal Hamdi committed
95

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

Faisal Hamdi's avatar
Faisal Hamdi committed
102
        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
d.arizona's avatar
d.arizona committed
103
        // this.setState({viewOnly: true})
Deni Rinaldi's avatar
Deni Rinaldi committed
104 105 106 107 108 109 110 111 112 113 114
    }

    getLatestUpdate() {
        let payload = {
            "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
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
115 116
        api.create().getLastestUpdateMR(payload).then(response => {
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
117 118 119
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
faisalhamdi's avatar
faisalhamdi committed
120
                        updateBy: response.data.data.detail === null ? [] : response.data.data.detail,
Deni Rinaldi's avatar
Deni Rinaldi committed
121
                        notes: response.data.data.notes_update === null ? "" : response.data.data.notes_update
Deni Rinaldi's avatar
Deni Rinaldi committed
122 123 124
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
125
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
126 127 128 129 130 131 132 133 134 135 136
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
137 138 139 140
    }

    getSettingControl() {
        let body = {
d.arizona's avatar
d.arizona committed
141
            group: 'THRESHOLD_VARIANCE',
Deni Rinaldi's avatar
Deni Rinaldi committed
142
            company_id: this.props.company.company_id,
Riri Novita's avatar
Riri Novita committed
143 144
            type: 'BALANCE_SHEET',
            currency_id: this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
145 146 147 148 149 150 151
        }

        api.create().getAllSettingByType(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
152 153
                        minValue: response.data.data[0] ? Number(response.data.data[0].min_value) : -5,
                        maxValue: response.data.data[0] ? Number(response.data.data[0].max_value) : 5,
Deni Rinaldi's avatar
Deni Rinaldi committed
154 155 156 157 158
                    }, () => {
                        this.getItemHierarki()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
159
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
160 161 162 163 164 165 166 167 168 169 170
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
171 172
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
173
    getItemHierarki() {
Deni Rinaldi's avatar
Deni Rinaldi committed
174
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
175
            "report_id": this.props.report_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
176 177 178
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
179
            "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
180
            "months": this.props.month.month_id,
181
            "currency_id": this.props.defaultCurrency.id,
Faisal Hamdi's avatar
Faisal Hamdi committed
182
            "get_for": this.state.get_for
Deni Rinaldi's avatar
Deni Rinaldi committed
183
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
184
        api.create().getHierarkiMontlyReportBS(payload).then(response => {
rifkaki's avatar
rifkaki committed
185
            console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
186
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
187
            let dataTable = []
d.arizona's avatar
d.arizona committed
188 189
            let err = false

Deni Rinaldi's avatar
Deni Rinaldi committed
190 191 192 193
            if (response.data) {
                let res = response.data.data
                const handlePushChild = (item) => {
                    let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
Faisal Hamdi's avatar
Faisal Hamdi committed
194
                    if (item.type_report_id === 3) {
d.arizona's avatar
d.arizona committed
195 196 197
                        // if (item.balance_sheet.mtd_vs_previous_month == "" &&  Number(item.balance_sheet.percent_act_vs_previous_month) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_previous_month) > this.state.maxValue) {
                        //     err = true
                        // } 
198
                        if (item.balance_sheet.mtd_vs_mb == "" && this.props.defaultCurrency.id == 1 ? fixNumber(Number(item.balance_sheet.percent_act_vs_mb), 1) : Number(item.balance_sheet.percent_act_vs_mb) < this.state.minValue || this.props.defaultCurrency.id == 1 ? fixNumber(Number(item.balance_sheet.percent_act_vs_mb), 1) : Number(item.balance_sheet.percent_act_vs_mb) > this.state.maxValue) {
d.arizona's avatar
d.arizona committed
199 200
                            err = true
                        }
d.arizona's avatar
d.arizona committed
201 202 203
                        // if (item.balance_sheet.mtd_vs_rb == "" &&  Number(item.balance_sheet.percent_act_vs_rb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_rb) > this.state.maxValue) {
                        //     err = true
                        // }
d.arizona's avatar
d.arizona committed
204
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
205 206 207 208 209 210 211 212
                    if (indexIDzz === -1) {
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.description,
Deni Rinaldi's avatar
Deni Rinaldi committed
213 214 215 216
                            item.balance_sheet.rolling_outlook === null ? "0" : item.balance_sheet.rolling_outlook === "" ? "0" : item.balance_sheet.rolling_outlook,
                            item.balance_sheet.master_budget === "" ? "0" : item.balance_sheet.master_budget,
                            item.balance_sheet.rolling_budget === "" ? "0" : item.balance_sheet.rolling_budget,
                            item.balance_sheet.actual === "" ? "0" : item.balance_sheet.actual,
Deni Rinaldi's avatar
Deni Rinaldi committed
217
                            item.balance_sheet.actual_previous_month === null ? "0.0" : item.balance_sheet.actual_previous_month === "" ? "0.0" : item.balance_sheet.actual_previous_month,
Deni Rinaldi's avatar
Deni Rinaldi committed
218 219 220 221 222 223
                            item.balance_sheet.amount_act_vs_previous_month === "" ? "0" : item.balance_sheet.amount_act_vs_previous_month,
                            item.balance_sheet.percent_act_vs_previous_month === "" ? "0" : item.balance_sheet.percent_act_vs_previous_month,
                            item.balance_sheet.amount_act_vs_mb === "" ? "0" : item.balance_sheet.amount_act_vs_mb,
                            item.balance_sheet.percent_act_vs_mb === "" ? "0" : item.balance_sheet.percent_act_vs_mb,
                            item.balance_sheet.amount_act_vs_rb === "" ? "0" : item.balance_sheet.amount_act_vs_rb,
                            item.balance_sheet.percent_act_vs_rb === "" ? "0" : item.balance_sheet.percent_act_vs_rb,
Deni Rinaldi's avatar
Deni Rinaldi committed
224 225 226
                            item.balance_sheet.mtd_vs_previous_month === null ? "" : item.balance_sheet.mtd_vs_previous_month,
                            item.balance_sheet.mtd_vs_mb === null ? "" : item.balance_sheet.mtd_vs_mb,
                            item.balance_sheet.mtd_vs_rb === null ? "" : item.balance_sheet.mtd_vs_rb,
d.arizona's avatar
d.arizona committed
227
                            item.balance_sheet.actual_formula,
rifkaki's avatar
rifkaki committed
228 229 230
                            item.order,
                            item.condition_it_should_be,
                            item.condition_if_wrong
Deni Rinaldi's avatar
Deni Rinaldi committed
231 232 233 234 235 236 237 238 239 240
                        ])
                    }
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                }
241
                console.log(res);
Deni Rinaldi's avatar
Deni Rinaldi committed
242
                res.map((item, index) => {
Faisal Hamdi's avatar
Faisal Hamdi committed
243
                    if (item.type_report_id === 3) {
d.arizona's avatar
d.arizona committed
244 245 246
                        // if (item.balance_sheet.mtd_vs_previous_month == "" &&  Number(item.balance_sheet.percent_act_vs_previous_month) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_previous_month) > this.state.maxValue) {
                        //     err = true
                        // } 
247
                        if (item.balance_sheet.mtd_vs_mb == "" && this.props.defaultCurrency.id == 1 ? fixNumber(Number(item.balance_sheet.percent_act_vs_mb), 1) : Number(item.balance_sheet.percent_act_vs_mb) < this.state.minValue || this.props.defaultCurrency.id == 1 ? fixNumber(Number(item.balance_sheet.percent_act_vs_mb), 1) : Number(item.balance_sheet.percent_act_vs_mb) > this.state.maxValue) {
d.arizona's avatar
d.arizona committed
248 249
                            err = true
                        }
d.arizona's avatar
d.arizona committed
250 251 252
                        // if (item.balance_sheet.mtd_vs_rb == "" &&  Number(item.balance_sheet.percent_act_vs_rb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_rb) > this.state.maxValue) {
                        //     err = true
                        // }
d.arizona's avatar
d.arizona committed
253
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
254 255 256 257 258 259 260
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
Deni Rinaldi's avatar
Deni Rinaldi committed
261 262 263 264
                        item.balance_sheet.rolling_outlook === null ? "0" : item.balance_sheet.rolling_outlook === "" ? "0" : item.balance_sheet.rolling_outlook,
                        item.balance_sheet.master_budget === "" ? "0" : item.balance_sheet.master_budget,
                        item.balance_sheet.rolling_budget === "" ? "0" : item.balance_sheet.rolling_budget,
                        item.balance_sheet.actual === "" ? "0" : item.balance_sheet.actual,
Deni Rinaldi's avatar
Deni Rinaldi committed
265
                        item.balance_sheet.actual_previous_month === null ? "0.0" : item.balance_sheet.actual_previous_month === "" ? "0.0" : item.balance_sheet.actual_previous_month,
Deni Rinaldi's avatar
Deni Rinaldi committed
266 267 268 269 270 271
                        item.balance_sheet.amount_act_vs_previous_month === "" ? "0" : item.balance_sheet.amount_act_vs_previous_month,
                        item.balance_sheet.percent_act_vs_previous_month === "" ? "0" : item.balance_sheet.percent_act_vs_previous_month,
                        item.balance_sheet.amount_act_vs_mb === "" ? "0" : item.balance_sheet.amount_act_vs_mb,
                        item.balance_sheet.percent_act_vs_mb === "" ? "0" : item.balance_sheet.percent_act_vs_mb,
                        item.balance_sheet.amount_act_vs_rb === "" ? "0" : item.balance_sheet.amount_act_vs_rb,
                        item.balance_sheet.percent_act_vs_rb === "" ? "0" : item.balance_sheet.percent_act_vs_rb,
Deni Rinaldi's avatar
Deni Rinaldi committed
272 273 274
                        item.balance_sheet.mtd_vs_previous_month === null ? "" : item.balance_sheet.mtd_vs_previous_month,
                        item.balance_sheet.mtd_vs_mb === null ? "" : item.balance_sheet.mtd_vs_mb,
                        item.balance_sheet.mtd_vs_rb === null ? "" : item.balance_sheet.mtd_vs_rb,
d.arizona's avatar
d.arizona committed
275
                        item.balance_sheet.actual_formula,
rifkaki's avatar
rifkaki committed
276 277 278
                        item.order,
                        item.condition_it_should_be,
                        item.condition_if_wrong
Deni Rinaldi's avatar
Deni Rinaldi committed
279 280 281 282 283 284 285 286 287
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
d.arizona's avatar
d.arizona committed
288 289 290
                if (err === true) {
                    this.setState({ bebas: true })
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
291
                this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
292
            }
Riri Novita's avatar
Riri Novita committed
293
            console.log(dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
294 295 296
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
297 298
    downloadTemplate = async () => {
        let res = await fetch(
299
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}&&currency_id=${this.props.defaultCurrency.id}`
Deni Rinaldi's avatar
Deni Rinaldi committed
300 301 302 303 304 305 306 307 308 309 310 311 312
        )
        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;
            a.download = 'Template Monthly Report Balance Sheet.xlsx';
            a.click();
        }
    }

    async downloadAllData() {
rifkaki's avatar
rifkaki committed
313
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/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}`
Deni Rinaldi's avatar
Deni Rinaldi committed
314 315
        console.log(url);
        let res = await fetch(
rifkaki's avatar
rifkaki committed
316
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId === null ? "" : 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}`
Deni Rinaldi's avatar
Deni Rinaldi committed
317 318 319 320 321 322 323 324 325 326 327 328
        )
        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;
            a.download = 'Monthly Report Balance Sheet.xlsx';
            a.click();
        }
    }

d.arizona's avatar
d.arizona committed
329
    handleGetFor(type) {
Faisal Hamdi's avatar
Faisal Hamdi committed
330
        this.setState({ get_for: type }, () => {
d.arizona's avatar
d.arizona committed
331 332 333 334 335
            this.getSettingControl()
            this.getLatestUpdate()
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
336 337 338
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
339
            console.log(resp)
Deni Rinaldi's avatar
Deni Rinaldi committed
340 341 342 343 344 345 346 347 348 349 350
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                // console.log(resp.rows[2]);
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
d.arizona's avatar
d.arizona committed
351
                            orders: i[0] === undefined ? "" : String(i[0]).trim(),
Deni Rinaldi's avatar
Deni Rinaldi committed
352 353
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
rifkaki's avatar
rifkaki committed
354
                            actual: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
Riri Novita's avatar
Riri Novita committed
355 356 357
                            mtd_vs_previous_month: i[4] === undefined ? "" : String(i[4]).trim(),
                            mtd_vs_mb: i[5] === undefined ? "" : String(i[5]).trim(),
                            mtd_vs_rb: i[6] === undefined ? "" : String(i[6]).trim(),
Deni Rinaldi's avatar
Deni Rinaldi committed
358 359 360 361 362 363 364 365
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    balance_sheet: payload,
d.arizona's avatar
d.arizona committed
366 367
                    months: this.props.month.month_id,
                    status: 'submitted'
Deni Rinaldi's avatar
Deni Rinaldi committed
368
                }
d.arizona's avatar
d.arizona committed
369
                console.log(body)
rifkaki's avatar
rifkaki committed
370
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
Deni Rinaldi's avatar
Deni Rinaldi committed
371 372 373 374
            }
        });
    }

d.arizona's avatar
d.arizona committed
375
    checkUpload() {
376 377 378 379 380
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        api.create().checkUploadMonthlyReportBS(payload).then(response => {
d.arizona's avatar
d.arizona committed
381 382 383 384 385
            // console.log(JSON.stringify(this.state.payload));
            console.log(response)
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, visibleBSMR: false, loading: true })
d.arizona's avatar
d.arizona committed
386
                    let err = false
d.arizona's avatar
d.arizona committed
387
                    let dataTable = response.data.data.map((item, index) => {
Faisal Hamdi's avatar
Faisal Hamdi committed
388
                        if (item.type_report_id === 3) {
389
                            if (item.mtd_vs_mb == "" && this.props.defaultCurrency.id == 1 ? fixNumber(Number(item.percent_act_vs_mb), 1) : Number(item.percent_act_vs_mb) < this.state.minValue || this.props.defaultCurrency.id == 1 ? fixNumber(Number(item.percent_act_vs_mb), 1) : Number(item.percent_act_vs_mb) > this.state.maxValue) {
d.arizona's avatar
d.arizona committed
390 391 392
                                err = true
                            }
                        }
d.arizona's avatar
d.arizona committed
393 394 395 396 397 398 399 400 401 402 403
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.item_report,
                            item.rolling_outlook === null ? "" : item.rolling_outlook === "" ? "" : item.rolling_outlook,
                            item.master_budget === "" ? "" : item.master_budget,
                            item.rolling_budget === "" ? "" : item.rolling_budget,
                            item.actual === "" ? "" : item.actual,
d.arizona's avatar
d.arizona committed
404 405 406 407 408 409 410 411 412 413 414 415 416
                            item.actual_previous_month === null ? "0.0" : item.actual_previous_month === "" ? "0.0" : item.actual_previous_month,
                            item.amount_act_vs_previous_month === "" ? "0.0" : item.amount_act_vs_previous_month,
                            item.percent_act_vs_previous_month === "" ? "0.0" : item.percent_act_vs_previous_month,
                            item.amount_act_vs_mb === "" ? "0.0" : item.amount_act_vs_mb,
                            item.percent_act_vs_mb === "" ? "0.0" : item.percent_act_vs_mb,
                            item.amount_act_vs_rb === "" ? "0.0" : item.amount_act_vs_rb,
                            item.percent_act_vs_rb === "" ? "0.0" : item.percent_act_vs_rb,
                            // 0,
                            // 0,
                            // 0,
                            // 0,
                            // 0,
                            // 0,
rifkaki's avatar
rifkaki committed
417 418 419
                            item.mtd_vs_previous_month === null ? "" : item.mtd_vs_previous_month === undefined ? "" : item.mtd_vs_previous_month,
                            item.mtd_vs_mb === null ? "" : item.mtd_vs_mb === undefined ? "" : item.mtd_vs_mb,
                            item.mtd_vs_rb === null ? "" : item.mtd_vs_rb === undefined ? "" : item.mtd_vs_rb,
d.arizona's avatar
d.arizona committed
420
                            item.actual_formula,
Deni Rinaldi's avatar
Deni Rinaldi committed
421
                            item.order,
rifkaki's avatar
rifkaki committed
422 423
                            item.condition_it_should_be,
                            item.condition_if_wrong,
d.arizona's avatar
d.arizona committed
424 425 426 427
                            item.error
                        ]
                    })
                    console.log(dataTable)
Deni Rinaldi's avatar
Deni Rinaldi committed
428
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: true, isUpload: true }, () => {
d.arizona's avatar
d.arizona committed
429
                        this.state.dataTable.map(item => {
rifkaki's avatar
rifkaki committed
430
                            if (item[24].length > 0) {
d.arizona's avatar
d.arizona committed
431
                                // console.log('masuk')
Deni Rinaldi's avatar
Deni Rinaldi committed
432
                                this.setState({ buttonError: true, errorPreview: true })
d.arizona's avatar
d.arizona committed
433 434 435 436
                            }
                        })
                        // console.log(this.state.buttonError)
                    })
Riri Novita's avatar
Riri Novita committed
437 438
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
439
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
440 441 442 443 444 445
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
d.arizona's avatar
d.arizona committed
446 447 448 449 450 451 452
                }
            }
        })
    }

    uploadBalanceSheet(type) {
        let data = []
Faisal Hamdi's avatar
Faisal Hamdi committed
453
        this.setState({ loading: true })
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    item_report: String(i[5]),
                    rolling_outlook: i[0] === 5 || i[0] === 6 ? String(Number(i[6])) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6])),
                    master_budget: i[0] === 5 || i[0] === 6 ? String(Number(i[7])) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7])),
                    rolling_budget: i[0] === 5 || i[0] === 6 ? String(Number(i[8])) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8])),
                    actual: i[0] === 5 || i[0] === 6 ? String(Number(i[9])) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9])),
                    actual_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[10])) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10])),
                    amount_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[11])) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11])),
                    percent_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[12])) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12])),
                    amount_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[13])) : i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13])),
                    percent_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[14])) : i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14])),
                    amount_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[15])) : i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15])),
                    percent_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[16])) : i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16])),
                    mtd_vs_previous_month: String(i[17]),
                    mtd_vs_mb: String(i[18]),
                    mtd_vs_rb: String(i[19])
                })
d.arizona's avatar
d.arizona committed
474
            })
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    item_report: String(i[5]),
                    rolling_outlook: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[6]), 1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(fixNumber(Number(i[6]), 1)),
                    master_budget: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[7]), 1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(fixNumber(Number(i[7]), 1)),
                    rolling_budget: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[8]), 1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(fixNumber(Number(i[8]), 1)),
                    actual: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[9]), 1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(fixNumber(Number(i[9]), 1)),
                    actual_previous_month: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[10]), 1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(fixNumber(Number(i[10]), 1)),
                    amount_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[11]), 1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(fixNumber(Number(i[11]), 1)),
                    percent_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[12]), 1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(fixNumber(Number(i[12]), 1)),
                    amount_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[13]), 1)) : i[0] === 3 && i[13] === "" ? "0.0" : String(fixNumber(Number(i[13]), 1)),
                    percent_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[14]), 1)) : i[0] === 3 && i[14] === "" ? "0.0" : String(fixNumber(Number(i[14]), 1)),
                    amount_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[15]), 1)) : i[0] === 3 && i[15] === "" ? "0.0" : String(fixNumber(Number(i[15]), 1)),
                    percent_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[16]), 1)) : i[0] === 3 && i[16] === "" ? "0.0" : String(fixNumber(Number(i[16]), 1)),
                    mtd_vs_previous_month: String(i[17]),
                    mtd_vs_mb: String(i[18]),
                    mtd_vs_rb: String(i[19])
                })
            })
        }

d.arizona's avatar
d.arizona committed
498
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
499
            "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
500 501 502
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
503
            "currency_id": this.props.defaultCurrency.id,
d.arizona's avatar
d.arizona committed
504 505 506 507
            "status": type,
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
Riri Novita's avatar
Riri Novita committed
508
        console.log(body);
d.arizona's avatar
d.arizona committed
509
        console.log(JSON.stringify(body));
rifkaki's avatar
rifkaki committed
510
        console.log(body)
d.arizona's avatar
d.arizona committed
511 512 513 514
        api.create('UPLOAD').uploadMonthlyReportBS(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
515
                    // this.props.onClickClose()
d.arizona's avatar
d.arizona committed
516
                    if (type == 'submitted') {
Riri Novita's avatar
Riri Novita committed
517
                        this.props.saveToMonthlyReport('BS')
Riri Novita's avatar
Riri Novita committed
518 519 520 521 522 523 524 525 526 527 528
                        // let bodyRatioBs = {
                        //     "report": 'ratio',
                        //     "monthlyReportId": this.props.monthlyReportId,
                        //     "periode": this.props.periode,
                        //     "companyId": this.props.company.company_id,
                        //     "months": this.props.month.month_id
                        // }
                        // api.create().triggerRatioFromLOCF(bodyRatioBs).then((res) => {
                        //     console.log(res)
                        //     this.setState({ loading: false })
                        // })
d.arizona's avatar
d.arizona committed
529 530 531
                    } else {
                        this.props.saveToMonthlyReport()
                    }
532
                    this.setState({ loading: false, handleDoubleClick: 0 })
d.arizona's avatar
d.arizona committed
533
                    // this.props.getReport()
d.arizona's avatar
d.arizona committed
534
                } else {
535 536 537 538 539 540 541 542 543 544 545 546
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ visibleAlertSave: true, alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
d.arizona's avatar
d.arizona committed
547 548
                }
            } else {
549
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
d.arizona's avatar
d.arizona committed
550 551 552 553
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
554
    backToMonthlyReport(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
555
        this.setState({ loading: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
556
        let data = []
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    "item_report_id": i[1],
                    "rolling_outlook": String(Number(i[6])),
                    "master_budget": String(Number(i[7])),
                    "rolling_budget": String(Number(i[8])),
                    "actual": String(Number(i[9])),
                    "actual_previous_month": String(Number(i[10])),
                    "amount_act_vs_previous_month": String(Number(i[11])),
                    "percent_act_vs_previous_month": String(Number(i[12])),
                    "amount_act_vs_mb": String(Number(i[13])),
                    "percent_act_vs_mb": i[14],
                    "amount_act_vs_rb": String(Number(i[15])),
                    "percent_act_vs_rb": i[16],
                    "mtd_vs_previous_month": i[17],
                    "mtd_vs_mb": i[18],
                    "mtd_vs_rb": i[19]
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
576
            })
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    "item_report_id": i[1],
                    "rolling_outlook": String(fixNumber(Number(i[6]), 1)),
                    "master_budget": String(fixNumber(Number(i[7]), 1)),
                    "rolling_budget": String(fixNumber(Number(i[8]), 1)),
                    "actual": String(fixNumber(Number(i[9]), 1)),
                    "actual_previous_month": String(fixNumber(Number(i[10]), 1)),
                    "amount_act_vs_previous_month": String(fixNumber(Number(i[11]), 1)),
                    "percent_act_vs_previous_month": String(fixNumber(Number(i[12]), 1)),
                    "amount_act_vs_mb": String(fixNumber(Number(i[13]), 1)),
                    "percent_act_vs_mb": i[14],
                    "amount_act_vs_rb": String(fixNumber(Number(i[15]), 1)),
                    "percent_act_vs_rb": i[16],
                    "mtd_vs_previous_month": i[17],
                    "mtd_vs_mb": i[18],
                    "mtd_vs_rb": i[19]
                })
            })
        }

Deni Rinaldi's avatar
Deni Rinaldi committed
599
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
600
            "monthly_report_id": this.props.monthlyReportId,
Deni Rinaldi's avatar
Deni Rinaldi committed
601 602 603
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
604
            "currency_id": this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
605 606 607 608 609
            "status": type,
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
        api.create('UPLOAD').createMonthlyReportBS(payload).then(response => {
rifkaki's avatar
rifkaki committed
610
            console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
611
            console.log(response);
d.arizona's avatar
d.arizona committed
612
            console.log(JSON.stringify(payload))
Deni Rinaldi's avatar
Deni Rinaldi committed
613 614
            if (response.data) {
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
615 616
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('BS')
Riri Novita's avatar
Riri Novita committed
617 618 619 620 621 622 623 624 625 626 627
                        // let bodyRatioBs = {
                        //     "report": 'ratio',
                        //     "monthlyReportId": this.props.monthlyReportId,
                        //     "periode": this.props.periode,
                        //     "companyId": this.props.company.company_id,
                        //     "months": this.props.month.month_id
                        // }
                        // api.create().triggerRatioFromLOCF(bodyRatioBs).then((res) => {
                        //     console.log(res)
                        //     this.setState({ loading: false })
                        // })
d.arizona's avatar
d.arizona committed
628 629 630
                    } else {
                        this.props.saveToMonthlyReport()
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
631
                } else {
632 633 634 635 636 637 638 639 640 641 642 643 644 645
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
                            document.body.style.overflow = 'unset';
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                            this.props.saveToMonthlyReport()
                        })
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
646 647
                }
            } else {
648
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 })
Deni Rinaldi's avatar
Deni Rinaldi committed
649 650 651 652
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
653 654
    handleValidate() {
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
655
        let err = false
d.arizona's avatar
d.arizona committed
656
        let errorContrl = false
rifkaki's avatar
rifkaki committed
657
        let editAble = this.state.editAble
d.arizona's avatar
d.arizona committed
658 659
        let dataTable = this.state.dataTable
        let kansas = this.state.kansas
Faisal Hamdi's avatar
Faisal Hamdi committed
660
        console.log(dataTable[dataTable.length - 1])
d.arizona's avatar
d.arizona committed
661
        dataTable.map((i, index) => {
Faisal Hamdi's avatar
Faisal Hamdi committed
662
            if (i[0] === 3) {
rifkaki's avatar
rifkaki committed
663
                // console.log(i);
d.arizona's avatar
d.arizona committed
664 665 666 667 668
                // if ( i[17] === "" && (Number(i[12]) < this.state.minValue || Number(i[12]) > this.state.maxValue)) {
                //     console.log('msk 1');
                //     // console.log(i);
                //     err = true
                // } else 
Riri Novita's avatar
Riri Novita committed
669
                if (i[18] === "" && (fixNumber(Number(i[14]), 1) < this.state.minValue || fixNumber(Number(i[14]), 1) > this.state.maxValue)) {
d.arizona's avatar
d.arizona committed
670 671
                    console.log('msk 2');
                    err = true
d.arizona's avatar
d.arizona committed
672
                }
d.arizona's avatar
d.arizona committed
673
            }
rifkaki's avatar
rifkaki committed
674 675

            if (String(i[5]) == "Control (should be nil)") {
Riri Novita's avatar
Riri Novita committed
676
                if (fixNumber(Number(i[9]), 1) < this.state.minValue || fixNumber(Number(i[9]), 1) > this.state.maxValue) {
d.arizona's avatar
d.arizona committed
677 678 679
                    errorContrl = true
                    editAble = true
                }
rifkaki's avatar
rifkaki committed
680 681
            }

Deni Rinaldi's avatar
Deni Rinaldi committed
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
            data.push({
                "item_report_id": i[1],
                "rolling_outlook": i[6],
                "master_budget": i[7],
                "rolling_budget": i[8],
                "actual": i[9],
                "actual_previous_month": i[10],
                "amount_act_vs_previous_month": i[11],
                "percent_act_vs_previous_month": i[12],
                "amount_act_vs_mb": i[13],
                "percent_act_vs_mb": i[14],
                "amount_act_vs_rb": i[15],
                "percent_act_vs_rb": i[16],
                "mtd_vs_previous_month": i[17],
                "mtd_vs_mb": i[18],
                "mtd_vs_rb": i[19]
            })
        })
rifkaki's avatar
rifkaki committed
700
        // console.log(JSON.stringify(data));
d.arizona's avatar
d.arizona committed
701 702 703 704 705 706 707 708 709 710 711 712 713
        // data.map(i => {
        //     if (i.mtd_vs_previous_month === "" && (Number(i.percent_act_vs_previous_month) < this.state.minValue || Number(i.percent_act_vs_previous_month) > this.state.maxValue)) {
        //         console.log('msk 1');
        //         console.log(i);
        //         err = true
        //     } else if (i.mtd_vs_mb === "" && (Number(i.percent_act_vs_mb) < this.state.minValue || Number(i.percent_act_vs_mb) > this.state.maxValue)) {
        //         console.log('msk 2');
        //         err = true
        //     } else if (i.mtd_vs_rb === "" && (Number(i.percent_act_vs_rb) < this.state.minValue || Number(i.percent_act_vs_rb) > this.state.maxValue)) {
        //         console.log('msk 3');
        //         err = true
        //     }
        // })
Deni Rinaldi's avatar
Deni Rinaldi committed
714 715 716 717 718 719 720
        // if (err === true) {
        //     console.log('error');
        //     this.setState({ loading: false, buttonError: true, saveDraft: false })
        // } else {
        //     console.log('g error');
        //     this.setState({ loading: false, buttonError: false, saveDraft: false })
        // }
Deni Rinaldi's avatar
Deni Rinaldi committed
721

Deni Rinaldi's avatar
Deni Rinaldi committed
722 723 724 725 726 727
        // console.log(JSON.stringify(data))
        let payload = {
            "monthly_report_id": this.props.monthlyReportId,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
728
            "currency_id": this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
729 730 731 732
            "status": "submitted",
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
rifkaki's avatar
rifkaki committed
733
        // console.log(JSON.stringify(payload));
rifkaki's avatar
rifkaki committed
734
        // console.log(this.state.dataTable)
735
        api.create().validateSubmitReportBS(payload).then((response) => {
Riri Novita's avatar
Riri Novita committed
736 737
            console.log(response.data.data.result)
            console.log(err);
rifkaki's avatar
rifkaki committed
738
            console.log(errorContrl);
Deni Rinaldi's avatar
Deni Rinaldi committed
739 740
            if (response.data) {
                if (response.data.status === "success") {
Faisal Hamdi's avatar
Faisal Hamdi committed
741
                    if (response.data.data.result && err === false && errorContrl === false) {
Deni Rinaldi's avatar
Deni Rinaldi committed
742
                        this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
d.arizona's avatar
d.arizona committed
743
                        if (kansas == 0) {
Faisal Hamdi's avatar
Faisal Hamdi committed
744
                            this.setState({ kansas: 1, loading: true }, () => {
d.arizona's avatar
d.arizona committed
745 746 747
                                this.handleValidate()
                            })
                        } else {
Faisal Hamdi's avatar
Faisal Hamdi committed
748
                            this.setState({ kansas: 0 })
d.arizona's avatar
d.arizona committed
749
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
750
                    } else {
d.arizona's avatar
d.arizona committed
751
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
d.arizona's avatar
d.arizona committed
752
                        if (kansas == 0) {
Faisal Hamdi's avatar
Faisal Hamdi committed
753
                            this.setState({ kansas: 1, loading: true }, () => {
d.arizona's avatar
d.arizona committed
754 755 756
                                this.handleValidate()
                            })
                        } else {
Faisal Hamdi's avatar
Faisal Hamdi committed
757
                            this.setState({ kansas: 0 })
d.arizona's avatar
d.arizona committed
758
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
759 760 761
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
762
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
763 764 765 766 767 768 769 770 771 772 773 774 775
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
776 777 778 779
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
780
    render() {
Deni Rinaldi's avatar
Deni Rinaldi committed
781
        let dataTable2 = this.state.dataTable
Riri Novita's avatar
Riri Novita committed
782
        const handleText = (value, tableMeta, type) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
783
            dataTable2[tableMeta.rowIndex][type] = value
Riri Novita's avatar
Riri Novita committed
784 785
            // console.log(dataTable2[tableMeta.rowIndex]);
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
786 787 788
        const handleChange = (value, tableMeta, type) => {
            let val = String(value).split(",").join("")
            if (type === "actual") {
789
                dataTable2[tableMeta.rowIndex][9] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 1) : Number(val)
d.arizona's avatar
d.arizona committed
790
                console.log(dataTable2);
Deni Rinaldi's avatar
Deni Rinaldi committed
791 792 793 794
            } else {
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
                    // console.log(indexParent)
795 796 797
                    dataTable2[tableMeta.rowIndex][9] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 1) : Number(val)
                    let jagain = this.props.defaultCurrency.id == 1 ? fixNumber(Number(dataTable2[indexParent][9]), 1) : Number(dataTable2[indexParent][9])
                    dataTable2[indexParent][9] = this.props.defaultCurrency.id == 1 ? (jagain === undefined ? (0 + fixNumber(Number(val)), 1) : fixNumber(Number(Number(jagain) + Number(val)))) : (jagain === undefined ? (0 + Number(val)) : Number(Number(jagain) + Number(val)))
Deni Rinaldi's avatar
Deni Rinaldi committed
798 799 800 801 802 803 804
                    // if (tableMeta.rowData[5] === 'Cash & Bank Balance') {
                    //     console.log(value);
                    //     console.log(a);
                    //     console.log(jagain);
                    //     console.log(dataTable2[indexParent]);
                    // }
                } else {
805
                    dataTable2[tableMeta.rowIndex][9] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 1) : Number(val)
Deni Rinaldi's avatar
Deni Rinaldi committed
806 807
                }
            }
d.arizona's avatar
d.arizona committed
808
            console.log(dataTable2);
Deni Rinaldi's avatar
Deni Rinaldi committed
809 810 811 812 813
        }

        const handleValue = (data, type) => {
            let total = 0
            dataTable2.map((item, index) => {
d.arizona's avatar
d.arizona committed
814
                // if (item[2] !== null) {
Deni Rinaldi's avatar
Deni Rinaldi committed
815 816 817 818 819
                if (data.rowData[1] === item[2]) {
                    // console.log(item[data.columnIndex + type])
                    let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type])
                    total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal
                }
d.arizona's avatar
d.arizona committed
820
                // }
Deni Rinaldi's avatar
Deni Rinaldi committed
821

Deni Rinaldi's avatar
Deni Rinaldi committed
822 823
            })
            let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
824
            dataTable2[data.rowIndex][data.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
825
            // console.log(indexParent);
Deni Rinaldi's avatar
Deni Rinaldi committed
826 827 828 829 830 831 832
            return total
        }

        const handleVariance = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[10])
833
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
834 835
            } else if (dex === 2) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[7])
836
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
837 838
            } else if (dex === 3) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[8])
839
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
840 841 842 843 844 845 846 847 848 849 850
            }
            return total
        }

        const handleVariancePercent = (tableMeta, dex, type) => {
            let total = 0
            // if (tableMeta.rowData[5] === "Cash and cash equivalent") {
            //     console.log(dataTable2);
            //     console.log(tableMeta);
            // }
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
851
                let selisih = Number(dataTable2[tableMeta.rowIndex][11])
Faisal Hamdi's avatar
Faisal Hamdi committed
852 853
                let prevMonth = Number(String(dataTable2[tableMeta.rowIndex][10]).includes('-') ? Number(dataTable2[tableMeta.rowIndex][10]) * -1 : dataTable2[tableMeta.rowIndex][10])
                total = R.equals(selisih / prevMonth, 0)
854 855 856
                || R.equals(selisih / prevMonth, NaN)
                || R.equals(selisih / prevMonth, Infinity)
                || R.equals(selisih / prevMonth, -Infinity) ? 0 : (selisih / prevMonth) * 100
Riri Novita's avatar
Riri Novita committed
857

858
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = String(selisih).includes('-') ? Number(total * -1).toFixed(1) : this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
d.arizona's avatar
d.arizona committed
859

860
                // total = String(selisih).includes('-')  && Number(tableMeta.rowData[9]) < Number(tableMeta.rowData[10])? Number(total * -1).toFixed(1) : this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
d.arizona's avatar
d.arizona committed
861
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = total
Riri Novita's avatar
Riri Novita committed
862 863

                // total = R.equals(Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])) * 100), NaN) ? '0' : R.equals(Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])) * 100), Infinity) ? '0' : Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])) * 100 == "-Infinity" ? '0' : (Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])) * 100)
864
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
865 866 867 868 869
                // if (tableMeta.rowData[5] === "Cash and cash equivalent") {
                // console.log(total);
                // console.log(Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10]));
                //     console.log(dataTable2[tableMeta.rowIndex]);
                // }
Deni Rinaldi's avatar
Deni Rinaldi committed
870
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
871
                let selisih = Number(dataTable2[tableMeta.rowIndex][13])
Faisal Hamdi's avatar
Faisal Hamdi committed
872 873
                let prevMonth = Number(String(dataTable2[tableMeta.rowIndex][7]).includes('-') ? Number(dataTable2[tableMeta.rowIndex][7]) * -1 : dataTable2[tableMeta.rowIndex][7])
                total = R.equals(selisih / prevMonth, 0)
874 875 876
                || R.equals(selisih / prevMonth, NaN)
                || R.equals(selisih / prevMonth, Infinity)
                || R.equals(selisih / prevMonth, -Infinity) ? 0 : (selisih / prevMonth) * 100
Riri Novita's avatar
Riri Novita committed
877

878 879
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = String(selisih).includes('-') ? Number(total * -1).toFixed(1) : this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
                // total = String(selisih).includes('-') && Number(tableMeta.rowData[9]) < Number(tableMeta.rowData[7]) ? Number(total * -1).toFixed(1) : this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
d.arizona's avatar
d.arizona committed
880
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = total
Riri Novita's avatar
Riri Novita committed
881
                // total = R.equals(Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])) * 100), NaN) ? '0' : R.equals(Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])) * 100), Infinity) ? '0' : Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])) * 100 == "-Infinity" ? '0' : (Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])) * 100)
882
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
883
            } else if (dex === 3) {
Riri Novita's avatar
Riri Novita committed
884
                let selisih = Number(dataTable2[tableMeta.rowIndex][15])
Faisal Hamdi's avatar
Faisal Hamdi committed
885 886
                let prevMonth = Number(String(dataTable2[tableMeta.rowIndex][8]).includes('-') ? Number(dataTable2[tableMeta.rowIndex][8]) * -1 : dataTable2[tableMeta.rowIndex][8])
                total = R.equals(selisih / prevMonth, 0)
887 888 889
                || R.equals(selisih / prevMonth, NaN)
                || R.equals(selisih / prevMonth, Infinity)
                || R.equals(selisih / prevMonth, -Infinity) ? 0 : (selisih / prevMonth) * 100
Riri Novita's avatar
Riri Novita committed
890

891 892
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = String(selisih).includes('-') ? Number(total * -1).toFixed(1) : this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
                // total = String(selisih).includes('-') && Number(tableMeta.rowData[9]) < Number(tableMeta.rowData[8])? Number(total * -1).toFixed(1) : this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
d.arizona's avatar
d.arizona committed
893
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = total
894 895
                // total = R.equals((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])), Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])
                // total = R.equals(Number((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100), NaN) ? '0' : R.equals(Number((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100), Infinity) ? '0' : Number((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100 == "-Infinity" ? '0' : (Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100)
896
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ?  fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
897
                // console.log(total);
Deni Rinaldi's avatar
Deni Rinaldi committed
898 899
            }
            return total
Deni Rinaldi's avatar
Deni Rinaldi committed
900 901
        }

d.arizona's avatar
d.arizona committed
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930
        const handleValueFormula = (tableMeta, colIdx) => {
            // loading = true
            let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
            let baru = []
            let anjay = []

            splitFormula.map((item, index) => {
                let items = String(item).substr(Number(String(item).length) - 1, 1)
                let subForm = String(item).substr(0, Number(String(item).length) - 1)
                let re = /^[a-zA-Z0-9_]+$/;
                if (item !== "") {
                    if (items == ']') {
                        baru.push(String(item))
                    } else if (!re.test(items)) {
                        baru.push(subForm)
                        baru.push(items)
                    } else {
                        baru.push(String(item))
                    }
                }
            })

            baru.map((item, index) => {
                if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
                    anjay.push(item)
                } else {
                    if (String(item).includes('#')) {
                        if (String(item).includes('[M-1]')) {
                            let tst = String(item).replace('[M-1]', '')
d.arizona's avatar
d.arizona committed
931
                            // let indexID = dataTable2.findIndex((val) => val[21] == tst)
Faisal Hamdi's avatar
Faisal Hamdi committed
932
                            let data = tableMeta.rowData[20] == null ? [] : tableMeta.rowData[20]
d.arizona's avatar
d.arizona committed
933
                            let indexID = data.findIndex((val) => val.item_formula == String(`${item}`))
d.arizona's avatar
d.arizona committed
934
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
935
                                let valuezz = data[indexID].value
d.arizona's avatar
d.arizona committed
936 937 938
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        } else {
Faisal Hamdi's avatar
Faisal Hamdi committed
939
                            let data = tableMeta.rowData[20] == null ? [] : tableMeta.rowData[20]
d.arizona's avatar
d.arizona committed
940
                            let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
d.arizona's avatar
d.arizona committed
941
                            if (indexID !== -1) {
rifkaki's avatar
rifkaki committed
942
                                // console.log(tableMeta)
d.arizona's avatar
d.arizona committed
943 944 945 946 947 948 949 950 951
                                let valuezz = data[indexID].value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        }
                    } else {
                        if (String(item).includes('[M-1]')) {
                            let tst = String(item).replace('[M-1]', '')
                            let indexID = dataTable2.findIndex((val) => val[21] == tst)
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
952 953 954 955 956 957
                                let valuezz = dataTable2[indexID][10]
                                if (item == dataTable2[tableMeta.rowIndex][21]) {
                                    anjay.push(0)
                                } else {
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
d.arizona's avatar
d.arizona committed
958 959 960 961 962
                            }
                        } else {
                            let indexID = dataTable2.findIndex((val) => val[21] == item)
                            if (indexID !== -1) {
                                let valuezz = dataTable2[indexID][colIdx]
d.arizona's avatar
d.arizona committed
963
                                if (item == dataTable2[tableMeta.rowIndex][21]) {
d.arizona's avatar
d.arizona committed
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
                                    anjay.push(0)
                                } else {
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                            } else {
                                if (item === '(-1)') {
                                    anjay.push(-1)
                                }
                            }
                        }
                    }
                }
            })

            let anjay2 = []
            let kurung = false
            let item1 = []
            anjay.map((item, index) => {
                if (item == "(") {
                    kurung = true
                } else if (item == ")") {
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
                } else {
                    if (kurung) {
                        item1.push(item)
                    } else {
                        anjay2.push(item)
                    }
                }
            })

            let total = 0
            let opt = ""
            let totalPrio = 0
            let optPrio = ""
            let prio = false
d.arizona's avatar
d.arizona committed
1002
            let optPrev = ""
d.arizona's avatar
d.arizona committed
1003 1004 1005
            anjay2.map((item, index) => {
                if (Array.isArray(item)) {
                    prio = true
d.arizona's avatar
d.arizona committed
1006
                    optPrev = opt
d.arizona's avatar
d.arizona committed
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
                    item.map((items, indexs) => {
                        if (items == "+") {
                            optPrio = "tambah"
                        } else if (items == "-") {
                            optPrio = "kurang"
                        } else if (items == "*") {
                            optPrio = "kali"
                        } else if (items == "/") {
                            optPrio = "bagi"
                        } else {
                            if (optPrio == "tambah") {
                                totalPrio = Number(totalPrio) + Number(items)
                            } else if (optPrio == "kurang") {
                                totalPrio = Number(totalPrio) - Number(items)
                            } else if (optPrio == "kali") {
                                totalPrio = Number(totalPrio) * Number(items)
                            } else if (optPrio == "bagi") {
                                totalPrio = Number(totalPrio) / Number(items) == NaN ? 0 : Number(totalPrio) / Number(items)
                            } else {
                                totalPrio += Number(items)
                            }
                        }
                    })

                    if (index == anjay2.length - 1) {
                        if (opt == "tambah") {
                            total = Number(total) + Number(totalPrio)
                        } else if (opt == "kurang") {
                            total = Number(total) - Number(totalPrio)
                        } else if (opt == "kali") {
                            total = Number(total) * Number(totalPrio)
                        } else if (opt == "bagi") {
                            total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                        } else {
                            total += Number(totalPrio)
                        }
                    }
                } else {
                    if (item == "+") {
                        opt = "tambah"
                        if (prio) {
d.arizona's avatar
d.arizona committed
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
                            if (optPrev == "tambah") {
                                total = Number(total) + Number(totalPrio)
                            } else if (optPrev == "kurang") {
                                total = Number(total) - Number(totalPrio)
                            } else if (optPrev == "kali") {
                                total = Number(total) * Number(totalPrio)
                            } else if (optPrev == "bagi") {
                                total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                            } else {
                                total += Number(totalPrio)
                            }
d.arizona's avatar
d.arizona committed
1059 1060 1061 1062 1063 1064 1065
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "-") {
                        opt = "kurang"
                        if (prio) {
d.arizona's avatar
d.arizona committed
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
                            if (optPrev == "tambah") {
                                total = Number(total) + Number(totalPrio)
                            } else if (optPrev == "kurang") {
                                total = Number(total) - Number(totalPrio)
                            } else if (optPrev == "kali") {
                                total = Number(total) * Number(totalPrio)
                            } else if (optPrev == "bagi") {
                                total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                            } else {
                                total += Number(totalPrio)
                            }
d.arizona's avatar
d.arizona committed
1077 1078 1079 1080 1081 1082 1083
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "*") {
                        opt = "kali"
                        if (prio) {
d.arizona's avatar
d.arizona committed
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094
                            if (optPrev == "tambah") {
                                total = Number(total) + Number(totalPrio)
                            } else if (optPrev == "kurang") {
                                total = Number(total) - Number(totalPrio)
                            } else if (optPrev == "kali") {
                                total = Number(total) * Number(totalPrio)
                            } else if (optPrev == "bagi") {
                                total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                            } else {
                                total += Number(totalPrio)
                            }
d.arizona's avatar
d.arizona committed
1095 1096 1097 1098 1099 1100 1101
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "/") {
                        opt = "bagi"
                        if (prio) {
d.arizona's avatar
d.arizona committed
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
                            if (optPrev == "tambah") {
                                total = Number(total) + Number(totalPrio)
                            } else if (optPrev == "kurang") {
                                total = Number(total) - Number(totalPrio)
                            } else if (optPrev == "kali") {
                                total = Number(total) * Number(totalPrio)
                            } else if (optPrev == "bagi") {
                                total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                            } else {
                                total += Number(totalPrio)
                            }
d.arizona's avatar
d.arizona committed
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } 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)
                        }
                    }
                }
            })

            total = R.equals(total, NaN) ? "0.0" : total
            // // // total = R.equals(total, NaN) ? "0.0" : total
            // // // console.log(dataTable2[tableMeta.rowIndex][22])
            // // // console.log(tableMeta.rowData[5])
            // // if (tableMeta.rowData[5] == "1.5 Other non-current assets") {
            // // if (forecast !== undefined) {
            // //     if (String(tableMeta.rowData[5]) == "Depreciation & amortisation") {
Deni Rinaldi's avatar
Deni Rinaldi committed
1140 1141 1142 1143 1144
            // console.log(splitFormula)
            // console.log(baru)
            // console.log(anjay)
            // console.log(anjay2)
            // console.log(total)
d.arizona's avatar
d.arizona committed
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
            // //         console.log(dataTable2[tableMeta.rowIndex])
            // //     }
            // // }

            // if (dataTable2[tableMeta.rowIndex][colIdx].value == undefined) {
            dataTable2[tableMeta.rowIndex][colIdx] = total
            // } else {
            //     dataTable2[tableMeta.rowIndex][column].value = total
            // }
            // loading = false
            return total
        }

Deni Rinaldi's avatar
Deni Rinaldi committed
1158
        let columns = [
Deni Rinaldi's avatar
Deni Rinaldi committed
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
Deni Rinaldi's avatar
Deni Rinaldi committed
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200
            {
                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 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218
                                {tableMeta.rowData[0] === null ?
                                    tableMeta.rowData[4] == 0 ?
                                        <LightTooltip title={"Report Items Not Registered"} arrow>
                                            <span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(val).toUpperCase()}</span>
                                        </LightTooltip> :
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                            <LightTooltip title={"Report Items Not Registered"} arrow>
                                                <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </LightTooltip>
                                        </div>
                                    :
                                    tableMeta.rowData[4] == 0 ?
                                        <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                        :
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                            <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                        </div>
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1219 1220 1221 1222 1223
                            </div>
                        )
                    }
                }
            },
Deni Rinaldi's avatar
Deni Rinaldi committed
1224
            {
Deni Rinaldi's avatar
Deni Rinaldi committed
1225
                name: `Rolling Outlook (FY${this.props.periode})`,
Deni Rinaldi's avatar
Deni Rinaldi committed
1226
                options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
1227
                    customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1228
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#07a7d0', width: 96, borderLeft: '1px #fff solid', borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1229 1230 1231
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1232 1233 1234 1235 1236
                    setCellProps: () => ({
                        style: {
                            paddingRight: 0
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
1237 1238
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1239
                            <div style={{ textAlign: 'right' }}>
rifkaki's avatar
rifkaki committed
1240
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1241
                                    null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1242
                                    this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1243 1244 1245 1246 1247 1248
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
1249
                                            value={fixNumber(Number(val), 1) == 0 ? "0.0" : fixNumber(Number(val), 1)}
Riri Novita's avatar
Riri Novita committed
1250
                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
                                        :
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={val}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1263
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 1) : Number(val) == 0 ? "0.0" : Number(val)}
Faisal Hamdi's avatar
Faisal Hamdi committed
1264 1265 1266 1267
                                                    />
                                                }
                                            />
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1268
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1269 1270 1271 1272 1273 1274 1275 1276 1277
                            </div>
                        )
                    }
                }
            },
            {
                name: `Month To Date (MTD)`,
                options: {
                    customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1278
                        <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)", padding: 0 }} >
Deni Rinaldi's avatar
Deni Rinaldi committed
1279
                            {/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1280 1281 1282 1283 1284
                                <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                            </TableCell> */}
                            <div style={{ borderBottom: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 40 }}>{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, borderRight: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1285 1286
                                    <span>{"Master Budget (MB)"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1287
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1288 1289
                                    <span>{"Rolling Budget (RB)"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1290
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1291 1292 1293 1294
                                    <span>{"Actual"}</span>
                                </div>
                            </div>
                        </th>
Deni Rinaldi's avatar
Deni Rinaldi committed
1295
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1296 1297 1298 1299 1300 1301
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
1302
                    customBodyRender: (val, tableMeta, updateValue) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1303
                        // console.log(tableMeta);
Deni Rinaldi's avatar
Deni Rinaldi committed
1304 1305 1306 1307 1308
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
rifkaki's avatar
rifkaki committed
1309
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1310
                                                null :
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327
                                                this.state.get_for == 'view'?
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[7]), 1) : Number(tableMeta.rowData[7]) == 0 ? "0.0" :  fixNumber(Number(tableMeta.rowData[7]))}
                                                    />:
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[7]), 1) : Number(tableMeta.rowData[7]) == 0 ? "0.0" : Number(tableMeta.rowData[7])}
                                                    />
d.arizona's avatar
d.arizona committed
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
                                                // :
                                                // tableMeta.rowData[0] === 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}
                                                //             value={Number(handleValue(tableMeta, 0)).toFixed(1)}
                                                //         />
                                                //     </span> :
                                                //     tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
                                                //         <div style={{ flex: 1 }}>
                                                //             <FormControlLabel
                                                //                 style={{ margin: 0 }}
                                                //                 value={val}
                                                //                 control={
                                                //                     <NumberFormat
                                                //                         thousandSeparator={true}
                                                //                         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                //                         type="text"
                                                //                         placeholder=""
                                                //                         disabled={true}
                                                //                         value={Number(handleValueFormula(tableMeta, 7)).toFixed(1)}
                                                //                     />
                                                //                 }
                                                //             />
                                                //         </div> :
Faisal Hamdi's avatar
Faisal Hamdi committed
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408
                                                // tableMeta.rowData[0] === 7 ?
                                                //     (Number(handleValueFormula(tableMeta, 7)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 7)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                //         <NumberFormat
                                                //             thousandSeparator={true}
                                                //             style={{
                                                //                 fontSize: 12,
                                                //                 textAlign: 'right',
                                                //                 borderColor: 'transparent',
                                                //                 margin: 0,
                                                //                 width: 96,
                                                //                 backgroundColor: 'transparent'
                                                //             }}
                                                //             type="text"
                                                //             placeholder=""
                                                //             disabled={true}
                                                //             value={Number(handleValueFormula(tableMeta, 7)).toFixed(1)}
                                                //         /> :
                                                //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 7)).toFixed(1)}
                                                //             />
                                                //         </LightTooltip>
                                                //         :
                                                // <div style={{ flex: 1 }}>
                                                //     <FormControlLabel
                                                //         style={{ margin: 0 }}
                                                //         value={val}
                                                //         control={
                                                //             <NumberFormat
                                                //                 thousandSeparator={true}
                                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                //                 type="text"
                                                //                 placeholder=""
                                                //                 disabled={true}
                                                //                 value={Number(tableMeta.rowData[7]).toFixed(1)}
                                                //             />
                                                //         }
                                                //     />
                                                // </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1409
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1410 1411 1412 1413
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
rifkaki's avatar
rifkaki committed
1414
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1415
                                                null :
1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432
                                                this.state.get_for == 'view'?
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[8]), 1) : Number(tableMeta.rowData[8]) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[8]))}
                                                    />:
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[8]), 1) : Number(tableMeta.rowData[8]) == 0 ? "0.0" : Number(tableMeta.rowData[8])}
                                                    />
d.arizona's avatar
d.arizona committed
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461
                                                // :
                                                // tableMeta.rowData[0] === 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}
                                                //             value={Number(handleValue(tableMeta, 1)).toFixed(1)}
                                                //         />
                                                //     </span> :
                                                //     tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
                                                //         <div style={{ flex: 1 }}>
                                                //             <FormControlLabel
                                                //                 style={{ margin: 0 }}
                                                //                 value={val}
                                                //                 control={
                                                //                     <NumberFormat
                                                //                         thousandSeparator={true}
                                                //                         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                //                         type="text"
                                                //                         placeholder=""
                                                //                         disabled={true}
                                                //                         value={Number(handleValueFormula(tableMeta, 8)).toFixed(1)}
                                                //                     />
                                                //                 }
                                                //             />
                                                //         </div> :
Faisal Hamdi's avatar
Faisal Hamdi committed
1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513
                                                // tableMeta.rowData[0] === 7 ?
                                                //     (Number(handleValueFormula(tableMeta, 8)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 8)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                //         <NumberFormat
                                                //             thousandSeparator={true}
                                                //             style={{
                                                //                 fontSize: 12,
                                                //                 textAlign: 'right',
                                                //                 borderColor: 'transparent',
                                                //                 margin: 0,
                                                //                 width: 96,
                                                //                 backgroundColor: 'transparent'
                                                //             }}
                                                //             type="text"
                                                //             placeholder=""
                                                //             disabled={true}
                                                //             value={Number(handleValueFormula(tableMeta, 8)).toFixed(1)}
                                                //         /> :
                                                //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 8)).toFixed(1)}
                                                //             />
                                                //         </LightTooltip>
                                                //         :
                                                // <div style={{ flex: 1 }}>
                                                //     <FormControlLabel
                                                //         style={{ margin: 0 }}
                                                //         value={val}
                                                //         control={
                                                //             <NumberFormat
                                                //                 thousandSeparator={true}
                                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                //                 type="text"
                                                //                 placeholder=""
                                                //                 disabled={true}
                                                //                 value={Number(tableMeta.rowData[8]).toFixed(1)}
                                                //             />
                                                //         }
                                                //     />
                                                // </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1514
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1515 1516 1517 1518
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1519
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1520
                                                null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1521
                                                this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1522 1523 1524 1525 1526 1527
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1528
                                                        value={fixNumber(Number(tableMeta.rowData[9]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[9]), 1)}
Riri Novita's avatar
Riri Novita committed
1529
                                                    />
Faisal Hamdi's avatar
Faisal Hamdi committed
1530 1531
                                                    :
                                                    tableMeta.rowData[0] === 3 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1532 1533 1534 1535 1536 1537 1538
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
Faisal Hamdi's avatar
Faisal Hamdi committed
1539
                                                                        style={{ color: this.props.isApprover || this.state.get_for == 'view' ? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1540 1541
                                                                        type="text"
                                                                        placeholder=""
Faisal Hamdi's avatar
Faisal Hamdi committed
1542
                                                                        disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
Riri Novita's avatar
Riri Novita committed
1543
                                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[9]), 1) : Number(tableMeta.rowData[9]) == 0 ? "0.0" : Number(tableMeta.rowData[9])}
d.arizona's avatar
d.arizona committed
1544 1545 1546
                                                                        onBlur={(event) => {
                                                                            handleChange(event.target.value, tableMeta)
                                                                        }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1547 1548 1549
                                                                    />
                                                                }
                                                            />
Deni Rinaldi's avatar
Deni Rinaldi committed
1550
                                                        </div> :
Faisal Hamdi's avatar
Faisal Hamdi committed
1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562
                                                        tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ color: String(tableMeta.rowData[5]).toLocaleLowerCase() == "r/e (cummulative)" && this.props.periode == 2021 && this.props.month.month_id == 1 ? "#5198ea" : "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={String(tableMeta.rowData[5]).toLocaleLowerCase() == "r/e (cummulative)" && this.props.periode == 2021 && this.props.month.month_id == 1 ? false : true}
Riri Novita's avatar
Riri Novita committed
1563
                                                                            value={this.props.defaultCurrency.id == 1 ? (String(tableMeta.rowData[5]).toLocaleLowerCase() == "r/e (cummulative)" && this.props.periode == 2021 && this.props.month.month_id == 1 ? fixNumber(Number(tableMeta.rowData[9]), 1) : fixNumber(Number(handleValueFormula(tableMeta, 9)), 1)) : (String(tableMeta.rowData[5]).toLocaleLowerCase() == "r/e (cummulative)" && this.props.periode == 2021 && this.props.month.month_id == 1 ? (Number(tableMeta.rowData[9]) == 0 ? "0.0" : Number(tableMeta.rowData[9])) : (Number(handleValueFormula(tableMeta, 9)) == 0 ? "0.0" : Number(handleValueFormula(tableMeta, 9))))}
Faisal Hamdi's avatar
Faisal Hamdi committed
1564 1565 1566 1567 1568
                                                                            onBlur={(event) => {
                                                                                handleChange(event.target.value, tableMeta)
                                                                            }}
                                                                        />
                                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1569
                                                                />
Faisal Hamdi's avatar
Faisal Hamdi committed
1570 1571 1572
                                                            </div> :
                                                            tableMeta.rowData[0] === 2 ?
                                                                <span style={{ fontSize: 12, textAlign: 'right' }}>
rifkaki's avatar
rifkaki committed
1573 1574
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
Faisal Hamdi's avatar
Faisal Hamdi committed
1575
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
rifkaki's avatar
rifkaki committed
1576 1577 1578
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1579
                                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(tableMeta, 2)), 1) : Number(handleValue(tableMeta, 2)) == 0 ? "0.0" : Number(handleValue(tableMeta, 2))}
Faisal Hamdi's avatar
Faisal Hamdi committed
1580 1581 1582
                                                                    />
                                                                </span> :
                                                                tableMeta.rowData[0] === 7 ?
Riri Novita's avatar
Riri Novita committed
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619
                                                                    this.props.defaultCurrency.id == 1 ?
                                                                        (fixNumber(Number(handleValueFormula(tableMeta, 9)), 1) >= Number(this.state.minValue) && fixNumber(Number(handleValueFormula(tableMeta, 9)), 1) <= Number(this.state.maxValue)) ?
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{
                                                                                    fontSize: 12,
                                                                                    textAlign: 'right',
                                                                                    borderColor: 'transparent',
                                                                                    margin: 0,
                                                                                    width: 96,
                                                                                    backgroundColor: 'transparent'
                                                                                }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
                                                                                value={fixNumber(Number(handleValueFormula(tableMeta, 9)), 1)}
                                                                            /> :
                                                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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={fixNumber(Number(handleValueFormula(tableMeta, 9)), 1)}
                                                                                />
                                                                            </LightTooltip>
                                                                        :
                                                                        (Number(handleValueFormula(tableMeta, 9)) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 9)) <= Number(this.state.maxValue)) ?
Faisal Hamdi's avatar
Faisal Hamdi committed
1620 1621 1622 1623 1624 1625 1626 1627
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{
                                                                                    fontSize: 12,
                                                                                    textAlign: 'right',
                                                                                    borderColor: 'transparent',
                                                                                    margin: 0,
                                                                                    width: 96,
Riri Novita's avatar
Riri Novita committed
1628
                                                                                    backgroundColor: 'transparent'
Faisal Hamdi's avatar
Faisal Hamdi committed
1629 1630 1631 1632
                                                                                }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652
                                                                                value={Number(handleValueFormula(tableMeta, 9)) == 0 ? "0.0" : Number(handleValueFormula(tableMeta, 9))}
                                                                            /> :
                                                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 9)) == 0 ? "0.0" : Number(handleValueFormula(tableMeta, 9))}
                                                                                />
                                                                            </LightTooltip>
rifkaki's avatar
rifkaki committed
1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664
                                                                    :
                                                                    <div style={{ flex: 1 }}>
                                                                        <FormControlLabel
                                                                            style={{ margin: 0 }}
                                                                            value={val}
                                                                            control={
                                                                                <NumberFormat
                                                                                    thousandSeparator={true}
                                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                                    type="text"
                                                                                    placeholder=""
                                                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1665
                                                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[9]), 1) : Number(tableMeta.rowData[9]) == 0 ? "0.0" : Number(tableMeta.rowData[9])}
rifkaki's avatar
rifkaki committed
1666 1667 1668 1669
                                                                                />
                                                                            }
                                                                        />
                                                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1670
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
            {
                name: "Actual Previous Month",
                options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
1682
                    customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1683
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1684 1685 1686
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1687 1688 1689 1690 1691
                    setCellProps: () => ({
                        style: {
                            paddingRight: 0
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
1692 1693
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1694
                            <div style={{ textAlign: 'right' }}>
rifkaki's avatar
rifkaki committed
1695
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1696
                                    null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1697
                                    this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1698 1699 1700 1701 1702 1703
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
1704
                                            value={fixNumber(Number(tableMeta.rowData[10]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[10]), 1)}
Riri Novita's avatar
Riri Novita committed
1705
                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
1706 1707 1708 1709 1710 1711 1712 1713 1714
                                        :
                                        tableMeta.rowData[0] === 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}
Riri Novita's avatar
Riri Novita committed
1715
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(tableMeta, 2)), 1) : Number(handleValue(tableMeta, 2)) == 0 ? "0.0" : Number(handleValue(tableMeta, 2))}
Faisal Hamdi's avatar
Faisal Hamdi committed
1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
                                                />
                                            </span> :
                                            // tableMeta.rowData[0] === 7 ?
                                            //     (Number(handleValueFormula(tableMeta, 10)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 10)).toFixed(1) <= Number(this.state.maxValue)) ?
                                            //         <NumberFormat
                                            //             thousandSeparator={true}
                                            //             style={{
                                            //                 fontSize: 12,
                                            //                 textAlign: 'right',
                                            //                 borderColor: 'transparent',
                                            //                 margin: 0,
                                            //                 width: 96,
                                            //                 backgroundColor: 'transparent'
                                            //             }}
                                            //             type="text"
                                            //             placeholder=""
                                            //             disabled={true}
                                            //             value={Number(handleValueFormula(tableMeta, 10)).toFixed(1)}
                                            //         /> :
                                            //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 10)).toFixed(1)}
                                            //             />
                                            //         </LightTooltip>
                                            //         :
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={val}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
1765
                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[10]), 1) : Number(tableMeta.rowData[10]) == 0 ? "0.0" : Number(tableMeta.rowData[10])}
Faisal Hamdi's avatar
Faisal Hamdi committed
1766 1767 1768 1769
                                                        />
                                                    }
                                                />
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1770
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1771 1772 1773 1774 1775 1776 1777 1778 1779 1780
                            </div>
                        )
                    }
                }
            },
            {
                name: `Variance`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
Deni Rinaldi's avatar
Deni Rinaldi committed
1781
                            <div style={{ borderBottom: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 40 }}>{columnMeta.name}</div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1782
                            <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1783 1784
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#37b5e6' }}>
                                    <div style={{ borderBottom: '1px #fff solid', backgroundColor: '#37b5e6' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1785 1786 1787
                                        <span>{"Act vs Previous Month"}</span>
                                    </div>
                                    <div className="grid grid-2x">
Deni Rinaldi's avatar
Deni Rinaldi committed
1788
                                        <div className="column-1" style={{ borderRight: '1px #fff solid', backgroundColor: '#37b5e6' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1789 1790
                                            <span>{"Amount"}</span>
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1791
                                        <div className="column-2" style={{ borderLeft: '1px #fff solid', backgroundColor: '#37b5e6' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1792 1793 1794 1795
                                            <span>{"%"}</span>
                                        </div>
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1796
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808
                                    <div style={{ borderBottom: '1px #fff solid' }}>
                                        <span>{"Act vs MB"}</span>
                                    </div>
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid' }}>
                                            <span>{"Amount"}</span>
                                        </div>
                                        <div className="column-2" style={{ borderLeft: '1px #fff solid' }}>
                                            <span>{"%"}</span>
                                        </div>
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1809
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824
                                    <div style={{ borderBottom: '1px #fff solid' }}>
                                        <span>{"Act vs RB"}</span>
                                    </div>
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid' }}>
                                            <span>{"Amount"}</span>
                                        </div>
                                        <div className="column-2" style={{ borderLeft: '1px #fff solid' }}>
                                            <span>{"%"}</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </th>
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1825 1826 1827
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
Deni Rinaldi's avatar
Deni Rinaldi committed
1828
                            paddingRight: 10
Deni Rinaldi's avatar
Deni Rinaldi committed
1829 1830
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
1831
                    customBodyRender: (val, tableMeta, updateValue) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1832
                        // console.log(tableMeta);
Deni Rinaldi's avatar
Deni Rinaldi committed
1833 1834 1835
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
1836
                                    <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
1837
                                        <div className="grid grid-2x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
1838
                                            <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
1839
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
1840
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1841
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1842
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1843 1844 1845 1846 1847 1848
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
1849
                                                                value={fixNumber(Number(tableMeta.rowData[11]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[11]), 1)}
Riri Novita's avatar
Riri Novita committed
1850
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
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 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898
                                                            :
                                                            // tableMeta.rowData[0] === 7 ?
                                                            //     (Number(handleValueFormula(tableMeta, 11)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 11)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            //         <NumberFormat
                                                            //             thousandSeparator={true}
                                                            //             style={{
                                                            //                 fontSize: 12,
                                                            //                 textAlign: 'right',
                                                            //                 borderColor: 'transparent',
                                                            //                 margin: 0,
                                                            //                 width: 96,
                                                            //                 backgroundColor: 'transparent'
                                                            //             }}
                                                            //             type="text"
                                                            //             placeholder=""
                                                            //             disabled={true}
                                                            //             value={Number(handleValueFormula(tableMeta, 11)).toFixed(1)}
                                                            //         /> :
                                                            //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 11)).toFixed(1)}
                                                            //             />
                                                            //         </LightTooltip>
                                                            //         :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
1899
                                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleVariance(tableMeta, 1, 2)), 1) : Number(handleVariance(tableMeta, 1, 2)) == 0 ? "0.0" : Number(handleVariance(tableMeta, 1, 2))}
Faisal Hamdi's avatar
Faisal Hamdi committed
1900 1901 1902 1903
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1904
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1905 1906
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1907
                                            <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
1908
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
1909
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1910
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1911
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1912 1913 1914 1915 1916
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
d.arizona's avatar
d.arizona committed
1917
                                                                suffix={'%'}
Riri Novita's avatar
Riri Novita committed
1918
                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
1919
                                                                value={fixNumber(Number(tableMeta.rowData[12]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[12]), 1)}
Riri Novita's avatar
Riri Novita committed
1920
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969
                                                            // :
                                                            // tableMeta.rowData[0] === 7 ?
                                                            //     (Number(handleValueFormula(tableMeta, 12)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 12)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            //         <NumberFormat
                                                            //             thousandSeparator={true}
                                                            //             style={{
                                                            //                 fontSize: 12,
                                                            //                 textAlign: 'right',
                                                            //                 borderColor: 'transparent',
                                                            //                 margin: 0,
                                                            //                 width: 96,
                                                            //                 backgroundColor: 'transparent'
                                                            //             }}
                                                            //             type="text"
                                                            //             placeholder=""
                                                            //             disabled={true}
                                                            //             value={Number(handleValueFormula(tableMeta, 12)).toFixed(1)}
                                                            //         /> :
                                                            //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 12)).toFixed(1)}
                                                            //             />
                                                            //         </LightTooltip>
                                                            :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ color: Number(tableMeta.rowData[12]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[12]).toFixed(1) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            suffix={'%'}
                                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
1970
                                                                            value={fixNumber(Number(handleVariancePercent(tableMeta, 1, 3)), 1) == 0 ? "0.0" : fixNumber(Number(handleVariancePercent(tableMeta, 1, 3)), 1)}
Faisal Hamdi's avatar
Faisal Hamdi committed
1971 1972 1973 1974
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1975
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1976 1977 1978 1979
                                                </div>
                                            </div>
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1980
                                    <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
1981
                                        <div className="grid grid-2x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
1982
                                            <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
1983
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
1984
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1985
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1986
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1987 1988 1989 1990 1991 1992
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
1993
                                                                value={fixNumber(Number(tableMeta.rowData[13]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[13]), 1)}
Riri Novita's avatar
Riri Novita committed
1994
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042
                                                            // :
                                                            // tableMeta.rowData[0] === 7 ?
                                                            //     (Number(handleValueFormula(tableMeta, 13)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 13)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            //         <NumberFormat
                                                            //             thousandSeparator={true}
                                                            //             style={{
                                                            //                 fontSize: 12,
                                                            //                 textAlign: 'right',
                                                            //                 borderColor: 'transparent',
                                                            //                 margin: 0,
                                                            //                 width: 96,
                                                            //                 backgroundColor: 'transparent'
                                                            //             }}
                                                            //             type="text"
                                                            //             placeholder=""
                                                            //             disabled={true}
                                                            //             value={Number(handleValueFormula(tableMeta, 13)).toFixed(1)}
                                                            //         /> :
                                                            //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 13)).toFixed(1)}
                                                            //             />
                                                            //         </LightTooltip>
                                                            :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
2043
                                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleVariance(tableMeta, 2, 4)), 1) : Number(handleVariance(tableMeta, 2, 4)) == 0 ? "0.0" : Number(handleVariance(tableMeta, 2, 4))}
Faisal Hamdi's avatar
Faisal Hamdi committed
2044 2045 2046 2047
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2048
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2049 2050
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2051
                                            <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
2052
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
2053
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2054
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2055
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
2056 2057 2058 2059 2060
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
d.arizona's avatar
d.arizona committed
2061
                                                                suffix={'%'}
Riri Novita's avatar
Riri Novita committed
2062
                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
2063
                                                                value={fixNumber(Number(tableMeta.rowData[14]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[14]), 1)}
Riri Novita's avatar
Riri Novita committed
2064
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113
                                                            :
                                                            // tableMeta.rowData[0] === 7 ?
                                                            //     (Number(handleValueFormula(tableMeta, 14)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 14)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            //         <NumberFormat
                                                            //             thousandSeparator={true}
                                                            //             style={{
                                                            //                 fontSize: 12,
                                                            //                 textAlign: 'right',
                                                            //                 borderColor: 'transparent',
                                                            //                 margin: 0,
                                                            //                 width: 96,
                                                            //                 backgroundColor: 'transparent'
                                                            //             }}
                                                            //             type="text"
                                                            //             placeholder=""
                                                            //             disabled={true}
                                                            //             value={Number(handleValueFormula(tableMeta, 14)).toFixed(1)}
                                                            //         /> :
                                                            //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 14)).toFixed(1)}
                                                            //             />
                                                            //         </LightTooltip>
                                                            //         :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ color: Number(tableMeta.rowData[14]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[14]).toFixed(1) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            suffix={'%'}
Riri Novita's avatar
Riri Novita committed
2114
                                                                            value={fixNumber(Number(handleVariancePercent(tableMeta, 2, 5)), 1) == 0 ? "0.0" : fixNumber(Number(handleVariancePercent(tableMeta, 2, 5)), 1)}
Faisal Hamdi's avatar
Faisal Hamdi committed
2115 2116 2117 2118
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2119
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2120 2121 2122 2123
                                                </div>
                                            </div>
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2124
                                    <div className="column-3">
Deni Rinaldi's avatar
Deni Rinaldi committed
2125
                                        <div className="grid grid-2x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
2126
                                            <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
2127
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
2128
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2129
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2130
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
2131 2132 2133 2134 2135 2136
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
2137
                                                                value={fixNumber(Number(tableMeta.rowData[15]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[15]), 1)}
Riri Novita's avatar
Riri Novita committed
2138
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186
                                                            :
                                                            // tableMeta.rowData[0] === 7 ?
                                                            //     (Number(handleValueFormula(tableMeta, 15)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 15)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            //         <NumberFormat
                                                            //             thousandSeparator={true}
                                                            //             style={{
                                                            //                 fontSize: 12,
                                                            //                 textAlign: 'right',
                                                            //                 borderColor: 'transparent',
                                                            //                 margin: 0,
                                                            //                 width: 96,
                                                            //                 backgroundColor: 'transparent'
                                                            //             }}
                                                            //             type="text"
                                                            //             placeholder=""
                                                            //             disabled={true}
                                                            //             value={Number(handleValueFormula(tableMeta, 15)).toFixed(1)}
                                                            //         /> :
                                                            //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 15)).toFixed(1)}
                                                            //             />
                                                            //         </LightTooltip>
                                                            //         :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
2187
                                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleVariance(tableMeta, 3, 6)), 1) : Number(handleVariance(tableMeta, 3, 6)) == 0 ? "0.0" : Number(handleVariance(tableMeta, 3, 6))}
Faisal Hamdi's avatar
Faisal Hamdi committed
2188 2189 2190 2191
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2192
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2193 2194
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2195
                                            <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
2196
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
2197
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2198
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2199
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
2200 2201 2202 2203
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
d.arizona's avatar
d.arizona committed
2204
                                                                suffix={'%'}
Riri Novita's avatar
Riri Novita committed
2205 2206
                                                                placeholder=""
                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
2207
                                                                value={fixNumber(Number(tableMeta.rowData[16]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[16]), 1)}
Riri Novita's avatar
Riri Novita committed
2208
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257
                                                            :
                                                            // tableMeta.rowData[0] === 7 ?
                                                            //     (Number(handleValueFormula(tableMeta, 16)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 16)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            //         <NumberFormat
                                                            //             thousandSeparator={true}
                                                            //             style={{
                                                            //                 fontSize: 12,
                                                            //                 textAlign: 'right',
                                                            //                 borderColor: 'transparent',
                                                            //                 margin: 0,
                                                            //                 width: 96,
                                                            //                 backgroundColor: 'transparent'
                                                            //             }}
                                                            //             type="text"
                                                            //             placeholder=""
                                                            //             disabled={true}
                                                            //             value={Number(handleValueFormula(tableMeta, 16)).toFixed(1)}
                                                            //         /> :
                                                            //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 16)).toFixed(1)}
                                                            //             />
                                                            //         </LightTooltip>
                                                            //         :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ color: Number(tableMeta.rowData[16]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[16]).toFixed(1) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            suffix={'%'}
Riri Novita's avatar
Riri Novita committed
2258
                                                                            value={fixNumber(Number(handleVariancePercent(tableMeta, 3, 7)), 1) == 0 ? "0.0" : fixNumber(Number(handleVariancePercent(tableMeta, 3, 7)), 1)}
Faisal Hamdi's avatar
Faisal Hamdi committed
2259 2260 2261 2262
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2263
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
Deni Rinaldi's avatar
Deni Rinaldi committed
2274 2275 2276 2277 2278 2279 2280 2281
            {
                name: `MTD Explanation`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)", padding: 0 }} >
                            {/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
                                <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                            </TableCell> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
2282
                            <div style={{ borderBottom: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 40 }}>{columnMeta.name}</div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2283
                            <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2284
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2285 2286
                                    <span>{"vs Prev Month"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2287
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2288 2289
                                    <span>{"vs MB"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2290
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2291 2292 2293 2294 2295
                                    <span>{"vs RB"}</span>
                                </div>
                            </div>
                        </th>
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
2296 2297 2298 2299 2300 2301
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
2302 2303 2304 2305 2306 2307
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
2308
                                            <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2309
                                                {tableMeta.rowData[0] !== 3 ?
Faisal Hamdi's avatar
Faisal Hamdi committed
2310 2311
                                                    null :
                                                    (this.state.get_for == 'view' ?
d.arizona's avatar
d.arizona committed
2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322
                                                        <Input
                                                            disableUnderline={true}
                                                            style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            // disabled={Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? false : true}
                                                            disabled={true}
                                                            multiline={true}
                                                            defaultValue={tableMeta.rowData[17]}
                                                            inputProps={{
                                                                style: {
Faisal Hamdi's avatar
Faisal Hamdi committed
2323
                                                                    color: 'black',
d.arizona's avatar
d.arizona committed
2324 2325 2326 2327
                                                                    textAlign: 'left'
                                                                }
                                                            }}
                                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356
                                                        :
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            // value={value}
                                                            control={
                                                                // tableMeta.rowData[17] === "" && (Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue) ?
                                                                //     <LightTooltip title={"MTD Explanation vs Prev Month is Reqiured"} arrow>
                                                                //         <Input
                                                                //             disableUnderline={true}
                                                                //             style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                //             type="text"
                                                                //             placeholder=""
                                                                //             disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                //             // disabled={false}
                                                                //             multiline={true}
                                                                //             defaultValue={tableMeta.rowData[17]}
                                                                //             inputProps={{
                                                                //                 style: {
                                                                //                     color: "#5198ea",
                                                                //                     textAlign: 'left',
                                                                //                     backgroundColor: '#ffac99'
                                                                //                 }
                                                                //             }}
                                                                //             onBlur={(event) => {
                                                                //                 handleText(event.target.value, tableMeta, 17)
                                                                //             }}
                                                                //         />
                                                                //     </LightTooltip>
                                                                //     :
rifkaki's avatar
rifkaki committed
2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392
                                                                // tableMeta.rowData[0] === 7 ?
                                                                //     (Number(handleValueFormula(tableMeta, 17)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 17)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                //         <NumberFormat
                                                                //             thousandSeparator={true}
                                                                //             style={{
                                                                //                 fontSize: 12,
                                                                //                 textAlign: 'right',
                                                                //                 borderColor: 'transparent',
                                                                //                 margin: 0,
                                                                //                 width: 96,
                                                                //                 backgroundColor: 'transparent'
                                                                //             }}
                                                                //             type="text"
                                                                //             placeholder=""
                                                                //             disabled={true}
                                                                //             value={Number(handleValueFormula(tableMeta, 17)).toFixed(1)}
                                                                //         /> :
                                                                //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 17)).toFixed(1)}
                                                                //             />
                                                                //         </LightTooltip>
                                                                //         :
Faisal Hamdi's avatar
Faisal Hamdi committed
2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403
                                                                <Input
                                                                    disableUnderline={true}
                                                                    style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    // disabled={Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? false : true}
                                                                    disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
                                                                    multiline={true}
                                                                    defaultValue={tableMeta.rowData[17]}
                                                                    inputProps={{
                                                                        style: {
Riri Novita's avatar
Riri Novita committed
2404
                                                                            color: fixNumber(Number(tableMeta.rowData[12]), 1) < this.state.minValue || fixNumber(Number(tableMeta.rowData[12]), 1) > this.state.maxValue ? "#5198ea" : '#5198ea',
Faisal Hamdi's avatar
Faisal Hamdi committed
2405 2406 2407 2408 2409 2410 2411 2412 2413
                                                                            textAlign: 'left'
                                                                        }
                                                                    }}
                                                                    onBlur={(event) => {
                                                                        handleText(event.target.value, tableMeta, 17)
                                                                    }}
                                                                />
                                                            }
                                                        />)}
Riri Novita's avatar
Riri Novita committed
2414
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2415 2416 2417 2418
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
2419
                                            <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2420
                                                {tableMeta.rowData[0] !== 3 ? null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2421
                                                    (this.state.get_for == 'view' ?
d.arizona's avatar
d.arizona committed
2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432
                                                        <Input
                                                            disableUnderline={true}
                                                            style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            // disabled={Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? false : true}
                                                            disabled={true}
                                                            multiline={true}
                                                            defaultValue={tableMeta.rowData[18]}
                                                            inputProps={{
                                                                style: {
Faisal Hamdi's avatar
Faisal Hamdi committed
2433
                                                                    color: 'black',
d.arizona's avatar
d.arizona committed
2434 2435 2436 2437
                                                                    textAlign: 'left'
                                                                }
                                                            }}
                                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
2438 2439 2440 2441 2442
                                                        :
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            // value={value}
                                                            control={
Riri Novita's avatar
Riri Novita committed
2443
                                                                tableMeta.rowData[18] === "" && (fixNumber(Number(tableMeta.rowData[14]), 1) < this.state.minValue || fixNumber(Number(tableMeta.rowData[14]), 1) > this.state.maxValue) ?
Faisal Hamdi's avatar
Faisal Hamdi committed
2444
                                                                    <LightTooltip title={"MTD Explanation vs MB is Reqiured"} arrow>
rifkaki's avatar
rifkaki committed
2445 2446
                                                                        <Input
                                                                            disableUnderline={true}
Faisal Hamdi's avatar
Faisal Hamdi committed
2447
                                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', minHeight: 30, padding: 0 }}
rifkaki's avatar
rifkaki committed
2448 2449
                                                                            type="text"
                                                                            placeholder=""
Faisal Hamdi's avatar
Faisal Hamdi committed
2450 2451 2452
                                                                            multiline={true}
                                                                            // disabled={false}
                                                                            disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
rifkaki's avatar
rifkaki committed
2453 2454 2455
                                                                            defaultValue={tableMeta.rowData[18]}
                                                                            inputProps={{
                                                                                style: {
Faisal Hamdi's avatar
Faisal Hamdi committed
2456 2457 2458 2459 2460
                                                                                    color: "#5198ea",
                                                                                    textAlign: 'left',
                                                                                    backgroundColor: '#ffac99',
                                                                                    minHeight: 30,
                                                                                    padding: 0
rifkaki's avatar
rifkaki committed
2461 2462 2463 2464 2465 2466
                                                                                }
                                                                            }}
                                                                            onBlur={(event) => {
                                                                                handleText(event.target.value, tableMeta, 18)
                                                                            }}
                                                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515
                                                                    </LightTooltip>
                                                                    :
                                                                    // tableMeta.rowData[0] === 7 ?
                                                                    //     (Number(handleValueFormula(tableMeta, 18)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 18)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                    //         <NumberFormat
                                                                    //             thousandSeparator={true}
                                                                    //             style={{
                                                                    //                 fontSize: 12,
                                                                    //                 textAlign: 'right',
                                                                    //                 borderColor: 'transparent',
                                                                    //                 margin: 0,
                                                                    //                 width: 96,
                                                                    //                 backgroundColor: 'transparent'
                                                                    //             }}
                                                                    //             type="text"
                                                                    //             placeholder=""
                                                                    //             disabled={true}
                                                                    //             value={Number(handleValueFormula(tableMeta, 18)).toFixed(1)}
                                                                    //         /> :
                                                                    //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 18)).toFixed(1)}
                                                                    //             />
                                                                    //         </LightTooltip>
                                                                    //         :
                                                                    <Input
                                                                        disableUnderline={true}
                                                                        style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        multiline={true}
                                                                        placeholder=""
                                                                        // disabled={Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? false : true}
                                                                        disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
                                                                        defaultValue={tableMeta.rowData[18]}
                                                                        inputProps={{
                                                                            style: {
Riri Novita's avatar
Riri Novita committed
2516
                                                                                color: fixNumber(Number(tableMeta.rowData[14]), 1) < this.state.minValue || fixNumber(Number(tableMeta.rowData[14]), 1) > this.state.maxValue ? "#5198ea" : '#5198ea',
Faisal Hamdi's avatar
Faisal Hamdi committed
2517 2518 2519 2520 2521 2522 2523 2524 2525
                                                                                textAlign: 'left'
                                                                            }
                                                                        }}
                                                                        onBlur={(event) => {
                                                                            handleText(event.target.value, tableMeta, 18)
                                                                        }}
                                                                    />
                                                            }
                                                        />)}
Riri Novita's avatar
Riri Novita committed
2526
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2527 2528 2529 2530
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
2531
                                            <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2532
                                                {tableMeta.rowData[0] !== 3 ? null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2533
                                                    (this.state.get_for == 'view' ?
d.arizona's avatar
d.arizona committed
2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544
                                                        <Input
                                                            disableUnderline={true}
                                                            style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            // disabled={Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? false : true}
                                                            disabled={true}
                                                            multiline={true}
                                                            defaultValue={tableMeta.rowData[19]}
                                                            inputProps={{
                                                                style: {
Faisal Hamdi's avatar
Faisal Hamdi committed
2545
                                                                    color: 'black',
d.arizona's avatar
d.arizona committed
2546 2547 2548 2549
                                                                    textAlign: 'left'
                                                                }
                                                            }}
                                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578
                                                        :
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            // value={value}
                                                            control={
                                                                // tableMeta.rowData[19] === "" && (Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue) ?
                                                                //     <LightTooltip title={"MTD Explanation vs RB is Reqiured"} arrow>
                                                                //         <Input
                                                                //             disableUnderline={true}
                                                                //             style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                //             type="text"
                                                                //             multiline={true}
                                                                //             placeholder=""
                                                                //             // disabled={false}
                                                                //             disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                //             defaultValue={tableMeta.rowData[19]}
                                                                //             inputProps={{
                                                                //                 style: {
                                                                //                     color: "#5198ea",
                                                                //                     textAlign: 'left',
                                                                //                     backgroundColor: '#ffac99'
                                                                //                 }
                                                                //             }}
                                                                //             onBlur={(event) => {
                                                                //                 handleText(event.target.value, tableMeta, 19)
                                                                //             }}
                                                                //         />
                                                                //     </LightTooltip>
                                                                //     :
rifkaki's avatar
rifkaki committed
2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614
                                                                // tableMeta.rowData[0] === 7 ?
                                                                //     (Number(handleValueFormula(tableMeta, 19)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 19)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                //         <NumberFormat
                                                                //             thousandSeparator={true}
                                                                //             style={{
                                                                //                 fontSize: 12,
                                                                //                 textAlign: 'right',
                                                                //                 borderColor: 'transparent',
                                                                //                 margin: 0,
                                                                //                 width: 96,
                                                                //                 backgroundColor: 'transparent'
                                                                //             }}
                                                                //             type="text"
                                                                //             placeholder=""
                                                                //             disabled={true}
                                                                //             value={Number(handleValueFormula(tableMeta, 19)).toFixed(1)}
                                                                //         /> :
                                                                //         <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `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(tableMeta, 19)).toFixed(1)}
                                                                //             />
                                                                //         </LightTooltip>
                                                                //         :
Faisal Hamdi's avatar
Faisal Hamdi committed
2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625
                                                                <Input
                                                                    disableUnderline={true}
                                                                    style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    multiline={true}
                                                                    placeholder=""
                                                                    // disabled={Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? false : true}
                                                                    disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
                                                                    defaultValue={tableMeta.rowData[19]}
                                                                    inputProps={{
                                                                        style: {
Riri Novita's avatar
Riri Novita committed
2626
                                                                            color: fixNumber(Number(tableMeta.rowData[16]), 1) < this.state.minValue || fixNumber(Number(tableMeta.rowData[16]), 1) > this.state.maxValue ? "#5198ea" : '#5198ea',
Faisal Hamdi's avatar
Faisal Hamdi committed
2627 2628 2629 2630 2631 2632 2633 2634 2635
                                                                            textAlign: 'left'
                                                                        }
                                                                    }}
                                                                    onBlur={(event) => {
                                                                        handleText(event.target.value, tableMeta, 19)
                                                                    }}
                                                                />
                                                            }
                                                        />)}
Riri Novita's avatar
Riri Novita committed
2636
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2637 2638 2639 2640 2641 2642 2643
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
d.arizona's avatar
d.arizona committed
2688 2689 2690 2691 2692 2693
                }
            },
            {
                name: "",
                options: {
                    display: false
Deni Rinaldi's avatar
Deni Rinaldi committed
2694 2695
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
2696
        ]
Deni Rinaldi's avatar
Deni Rinaldi committed
2697

Deni Rinaldi's avatar
Deni Rinaldi committed
2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708
        const loadingComponent = (
            <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)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );

Deni Rinaldi's avatar
Deni Rinaldi committed
2709 2710
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2711
                {this.state.loading && loadingComponent}
Deni Rinaldi's avatar
Deni Rinaldi committed
2712 2713 2714
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
                </div>
Riri Novita's avatar
Riri Novita committed
2715 2716 2717 2718 2719
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
Deni Rinaldi's avatar
Deni Rinaldi committed
2720
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2721
                    {this.state.visibleBSMR ? <Paper style={{ paddingTop: 10 }}>
2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
                                        {this.props.defaultCurrency.id === 1 ?
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                            :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                        }
                                    </div>
                                    <div style={{ width: '50%' }}>
                                        {this.props.isApprover === true || this.state.get_for == 'view' ?
                                            null
                                            // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            //     <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" />
                                            // </div>
                                            :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                <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">
Deni Rinaldi's avatar
Deni Rinaldi committed
2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807
                                                <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>
qorri_di's avatar
qorri_di committed
2808
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
2809 2810 2811
                                            </div>
                                        }
                                    </div>
qorri_di's avatar
qorri_di committed
2812 2813
                                </div>

2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {!this.state.loading && (
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
                                    {this.state.get_for == 'view' && this.state.viewOnly && <div style={{ color: '#000', marginTop: 10, fontSize: 12 }}>(*) There may be discrepancies in amount due to rounding</div>}
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2826

2827 2828 2829 2830 2831 2832 2833 2834 2835 2836
                                <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>
faisalhamdi's avatar
faisalhamdi committed
2837

2838 2839
                                        }
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2840
                                </div>
2841
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2842

2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860
                                <div style={{ display: 'flex', maxWidth: '100%', paddingRight: 15 }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, textDecorationLine: 'underline' }}>Notes:</Typography>
                                </div>
                                <div style={{ display: 'flex', maxWidth: '100%', paddingRight: 15 }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, fontWeight: 'bold' }}>Rolling Outlook (Full Year) or Rolling Budget (RB)</Typography>
                                </div>
                                <div style={{ display: 'flex', paddingLeft: 10, justifyContent: 'space-between', maxWidth: '100%', paddingRight: 15 }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>Period Jan-Mar = MB figures</Typography>
                                </div>
                                <div style={{ display: 'flex', paddingLeft: 10, justifyContent: 'space-between', maxWidth: '100%', paddingRight: 15 }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>Period Apr-Jun = OL Q1 figures or MB figures (if OL Q1 not available)</Typography>
                                </div>
                                <div style={{ display: 'flex', paddingLeft: 10, justifyContent: 'space-between', maxWidth: '100%', paddingRight: 15 }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>Period Jul-Sep = OL Q2 figures or OL Q1 (if OL Q2 not available) or MB (if OL Q2 and OL Q1 not available)</Typography>
                                </div>
                                <div style={{ display: 'flex', paddingLeft: 10, justifyContent: 'space-between', maxWidth: '100%', paddingRight: 15 }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>Period Oct-Dec = OL Q3 figures or OL Q2 (if OL Q3 not available) and consecutive to the MB</Typography>
                                </div>
qorri_di's avatar
qorri_di committed
2861 2862

                            </div>
2863 2864 2865 2866 2867
                            {/* {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') ? */}
                            <div className="grid grid-2x" style={{ padding: 20 }}>
                                <div className="col-1" style={{ paddingLeft: 0 }}>
                                    <button
Deni Rinaldi's avatar
Deni Rinaldi committed
2868
                                        type="button"
2869 2870 2871 2872 2873
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
Deni Rinaldi's avatar
Deni Rinaldi committed
2874 2875
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2876
                                            cursor: 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2877 2878 2879 2880
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
2881 2882
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2883
                                        </div>
2884
                                    </button>
Deni Rinaldi's avatar
Deni Rinaldi committed
2885
                                </div>
2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981
                                {this.props.isApprover === true ?
                                    <div className="col-2">
                                    </div> :
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
                                        {this.state.get_for == 'view' && this.state.viewOnly && <button
                                            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
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
                                                    setTimeout(() => {
                                                        this.handleValidate()
                                                    }, 100);
                                                })
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
                                        </button>}
                                        {this.state.get_for === 'edit' && <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
                                                this.state.saveDraft ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    :
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
                                                            this.backToMonthlyReport('draft')
                                                        })
                                            }
                                        >
                                            <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>}
                                        {this.state.get_for === 'edit' && <button
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            onClick={() =>
                                                this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data incomplete !', tipeAlert: 'error' })
                                                    :
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
                                                            this.backToMonthlyReport('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                        >
                                            <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 & Complete</Typography>
                                            </div>
                                        </button>}
                                    </div>
                                }
                            </div>
                            {/* : null
Deni Rinaldi's avatar
Deni Rinaldi committed
2982
                            } */}
2983
                        </Paper> :
Deni Rinaldi's avatar
Deni Rinaldi committed
2984 2985 2986
                        <Paper style={{ paddingTop: 10 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
d.arizona's avatar
d.arizona committed
2987
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2988 2989 2990
                            <div style={{ padding: 20 }}>
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
2991
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
2992 2993 2994 2995 2996
                                    {this.props.defaultCurrency.id === 1 ?
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                        :
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                    }
d.arizona's avatar
d.arizona committed
2997
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2998
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
rifkaki's avatar
rifkaki committed
2999
                                    {this.state.dataLoaded && !this.state.loading && (
Deni Rinaldi's avatar
Deni Rinaldi committed
3000 3001 3002 3003 3004 3005 3006
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
Faisal Hamdi's avatar
Faisal Hamdi committed
3007
                                    )}
Deni Rinaldi's avatar
Deni Rinaldi committed
3008
                                </div>
d.arizona's avatar
d.arizona committed
3009
                            </div>
Faisal Hamdi's avatar
Faisal Hamdi committed
3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043
                            <div className="grid grid-2x" style={{ marginTop: 10, padding: 20 }}>
                                <div className="col-1" style={{ paddingLeft: 0 }}>
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ loading: true, visibleBSMR: true }, () => {
                                            setTimeout(() => {
                                                this.getItemHierarki()
                                            }, 100);
                                        })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none'
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
                                        </div>
                                    </button>
                                </div>
                                <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                        onClick={() => {
                                            this.setState({ loading: true, dataTable: dataTable2 }, () => {
d.arizona's avatar
d.arizona committed
3044
                                                setTimeout(() => {
Faisal Hamdi's avatar
Faisal Hamdi committed
3045
                                                    this.handleValidate()
d.arizona's avatar
d.arizona committed
3046
                                                }, 100);
Faisal Hamdi's avatar
Faisal Hamdi committed
3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067
                                            })
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                            <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                        </div>
                                    </button>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                        onClick={() =>
                                            this.state.saveDraft === true ?
                                                this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                :
3068 3069
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
Faisal Hamdi's avatar
Faisal Hamdi committed
3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084
                                                        this.uploadBalanceSheet('draft')
                                                    })
                                        }
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                        </div>
                                    </button>
                                    <button
                                        type="button"
                                        // disabled={this.state.buttonError}
                                        onClick={() =>
                                            this.state.buttonError ?
                                                this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                :
3085 3086
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
Faisal Hamdi's avatar
Faisal Hamdi committed
3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099
                                                        this.uploadBalanceSheet('submitted')
                                                    })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
                                        <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 & Complete</Typography>
                                        </div>
                                    </button>
d.arizona's avatar
d.arizona committed
3100
                                </div>
Faisal Hamdi's avatar
Faisal Hamdi committed
3101
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3102
                        </Paper>
d.arizona's avatar
d.arizona committed
3103
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
3104
                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123
                {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>
3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140
                            <div style={{ padding: '25px 30px' }}>
                                <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={() => {
                                        String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") && String(this.state.judul).includes("BALANCE") && String(this.state.judul).includes("SHEET") ?
                                            this.checkUpload() :
                                            this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                    }}
                                />
                            </div>
3141
                            <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data in <b>{this.props.defaultCurrency.id == 1 ? "IDR mn" : "thousand USD"}</b></div>
3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169
                        </div>
                    </div>
                )}

                {this.state.visibleAlertSave && (
                    <div className="test app-popup-show">
                        <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
                            <div style={{ margin: 30 }}>
                                <div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
                                    <div style={{ alignSelf: 'center', marginRight: 25 }}>
                                        <img src={Images.warning} />
                                    </div>
                                    <div style={{ justifyContent: 'center', fontSize: 20, color: '#1D2995', marginTop: 10 }}>
                                        <b>Rate Currency USD</b> pada periode yang dipilih <b>belum</b> diatur.<br /> Silahkan menghubungi Superadmin
                                    </div>
                                </div>
                                <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            background: '#F6F7F9',
                                            cursor: 'pointer',
                                            border: '1px solid #3549609e',
                                            outline: 'none',
                                            marginRight: 20,
                                            borderRadius: 9
                                        }}
3170
                                        onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0, loading: false })}
3171 3172 3173 3174 3175 3176 3177
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 9, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
                                            <Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
                                        </div>
                                    </button>
                                </div>
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3178 3179 3180
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
3181 3182 3183
            </div>
        )
    }
Riri Novita's avatar
Riri Novita committed
3184
}