BalanceSheetMR.js 216 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';
Deni Rinaldi's avatar
Deni Rinaldi committed
15

Deni Rinaldi's avatar
Deni Rinaldi committed
16 17 18 19 20 21 22 23 24
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
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
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
44 45 46 47
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
d.arizona's avatar
d.arizona committed
48
            loading: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
49 50 51
            visibleBSMR: true,
            valueThreshold: 0,
            minValue: 0,
Deni Rinaldi's avatar
Deni Rinaldi committed
52
            maxValue: 0,
faisalhamdi's avatar
faisalhamdi committed
53
            updateBy: [],
rifkaki's avatar
rifkaki committed
54 55
            notes: "",
            judulColumn: null,
d.arizona's avatar
d.arizona committed
56
            get_for: "view",
Faisal Hamdi's avatar
Faisal Hamdi committed
57
            viewOnly: true,
58 59 60
            kansas: 0,
            defaultCurrencyUpload: this.props.defaultCurrency,
            visibleAlertSave: false
Deni Rinaldi's avatar
Deni Rinaldi committed
61
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
62
        this.fileHandler = this.fileHandler.bind(this);
Deni Rinaldi's avatar
Deni Rinaldi committed
63
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
64

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

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

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

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

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

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

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

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

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

        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
150 151
                        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
152 153 154 155 156
                    }, () => {
                        this.getItemHierarki()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
157
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
158 159 160 161 162 163 164 165 166 167 168
                            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
169 170
    }

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

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

Deni Rinaldi's avatar
Deni Rinaldi committed
294 295
    downloadTemplate = async () => {
        let res = await fetch(
296
            `${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}`
Deni Rinaldi's avatar
Deni Rinaldi committed
297 298 299 300 301 302 303 304 305 306 307 308 309
        )
        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
310
        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
311 312
        console.log(url);
        let res = await fetch(
rifkaki's avatar
rifkaki committed
313
            `${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
314 315 316 317 318 319 320 321 322 323 324 325
        )
        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
326
    handleGetFor(type) {
Faisal Hamdi's avatar
Faisal Hamdi committed
327
        this.setState({ get_for: type }, () => {
d.arizona's avatar
d.arizona committed
328 329 330 331 332
            this.getSettingControl()
            this.getLatestUpdate()
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            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
348
                            orders: i[0] === undefined ? "" : String(i[0]).trim(),
Deni Rinaldi's avatar
Deni Rinaldi committed
349 350
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
rifkaki's avatar
rifkaki committed
351
                            actual: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
Riri Novita's avatar
Riri Novita committed
352 353 354
                            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
355 356 357 358 359 360 361 362
                        })
                    }
                })
                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
363 364
                    months: this.props.month.month_id,
                    status: 'submitted'
Deni Rinaldi's avatar
Deni Rinaldi committed
365
                }
d.arizona's avatar
d.arizona committed
366
                console.log(body)
rifkaki's avatar
rifkaki committed
367
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
Deni Rinaldi's avatar
Deni Rinaldi committed
368 369 370 371
            }
        });
    }

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

    uploadBalanceSheet(type) {
        let data = []
Faisal Hamdi's avatar
Faisal Hamdi committed
450
        this.setState({ loading: true })
d.arizona's avatar
d.arizona committed
451 452 453
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
d.arizona's avatar
d.arizona committed
454
                item_report: String(i[5]),
d.arizona's avatar
d.arizona committed
455 456 457 458 459 460 461 462 463 464 465
                rolling_outlook: i[0] === 5 || i[0] === 6 ? String(Number(i[6]).toFixed(1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6]).toFixed(1)),
                master_budget: i[0] === 5 || i[0] === 6 ? String(Number(i[7]).toFixed(1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
                rolling_budget: i[0] === 5 || i[0] === 6 ? String(Number(i[8]).toFixed(1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
                actual: i[0] === 5 || i[0] === 6 ? String(Number(i[9]).toFixed(1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
                actual_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[10]).toFixed(1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
                amount_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[11]).toFixed(1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
                percent_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[12]).toFixed(1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
                amount_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[13]).toFixed(1)) : i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
                percent_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[14]).toFixed(1)) : i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
                amount_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[15]).toFixed(1)) : i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
                percent_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[16]).toFixed(1)) : i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)),
Riri Novita's avatar
Riri Novita committed
466 467 468
                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
469 470 471
            })
        })
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
472
            "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
473 474 475
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
476
            "currency_id": this.props.defaultCurrency.id,
d.arizona's avatar
d.arizona committed
477 478 479 480
            "status": type,
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
Riri Novita's avatar
Riri Novita committed
481
        console.log(body);
d.arizona's avatar
d.arizona committed
482
        console.log(JSON.stringify(body));
rifkaki's avatar
rifkaki committed
483
        console.log(body)
d.arizona's avatar
d.arizona committed
484 485 486 487
        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
488
                    // this.props.onClickClose()
d.arizona's avatar
d.arizona committed
489 490
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('BS')
Riri Novita's avatar
Riri Novita committed
491 492 493 494 495 496 497 498 499 500 501
                        // 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
502 503 504
                    } else {
                        this.props.saveToMonthlyReport()
                    }
505
                    this.setState({ loading: false, handleDoubleClick: 0 })
d.arizona's avatar
d.arizona committed
506
                    // this.props.getReport()
d.arizona's avatar
d.arizona committed
507
                } else {
508
                    this.setState({ visibleAlertSave: true, alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
d.arizona's avatar
d.arizona committed
509
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
510 511 512 513 514 515 516 517
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
518
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
d.arizona's avatar
d.arizona committed
519 520 521 522
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
523
    backToMonthlyReport(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
524
        this.setState({ loading: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
525 526 527
        let data = []
        this.state.dataTable.map(i => {
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
528
                "item_report_id": i[1],
d.arizona's avatar
d.arizona committed
529 530 531 532 533 534 535 536
                "rolling_outlook": String(Number(i[6]).toFixed(1)),
                "master_budget": String(Number(i[7]).toFixed(1)),
                "rolling_budget": String(Number(i[8]).toFixed(1)),
                "actual": String(Number(i[9]).toFixed(1)),
                "actual_previous_month": String(Number(i[10]).toFixed(1)),
                "amount_act_vs_previous_month": String(Number(i[11]).toFixed(1)),
                "percent_act_vs_previous_month": String(Number(i[12]).toFixed(1)),
                "amount_act_vs_mb": String(Number(i[13]).toFixed(1)),
Deni Rinaldi's avatar
Deni Rinaldi committed
537
                "percent_act_vs_mb": i[14],
d.arizona's avatar
d.arizona committed
538
                "amount_act_vs_rb": String(Number(i[15]).toFixed(1)),
Deni Rinaldi's avatar
Deni Rinaldi committed
539 540 541 542 543 544 545
                "percent_act_vs_rb": i[16],
                "mtd_vs_previous_month": i[17],
                "mtd_vs_mb": i[18],
                "mtd_vs_rb": i[19]
            })
        })
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
546
            "monthly_report_id": this.props.monthlyReportId,
Deni Rinaldi's avatar
Deni Rinaldi committed
547 548 549
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
550
            "currency_id": this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
551 552 553 554 555
            "status": type,
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
        api.create('UPLOAD').createMonthlyReportBS(payload).then(response => {
rifkaki's avatar
rifkaki committed
556
            console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
557
            console.log(response);
d.arizona's avatar
d.arizona committed
558
            console.log(JSON.stringify(payload))
Deni Rinaldi's avatar
Deni Rinaldi committed
559 560
            if (response.data) {
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
561 562
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('BS')
Riri Novita's avatar
Riri Novita committed
563 564 565 566 567 568 569 570 571 572 573
                        // 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
574 575 576
                    } else {
                        this.props.saveToMonthlyReport()
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
577
                } else {
578
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
Riri Novita's avatar
Riri Novita committed
579
                        document.body.style.overflow = 'unset';
d.arizona's avatar
d.arizona committed
580
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
581 582 583 584 585
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
586 587 588 589
                        this.props.saveToMonthlyReport()
                    })
                }
            } else {
590
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 })
Deni Rinaldi's avatar
Deni Rinaldi committed
591 592 593 594
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
595 596
    handleValidate() {
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
597
        let err = false
d.arizona's avatar
d.arizona committed
598
        let errorContrl = false
rifkaki's avatar
rifkaki committed
599
        let editAble = this.state.editAble
d.arizona's avatar
d.arizona committed
600 601
        let dataTable = this.state.dataTable
        let kansas = this.state.kansas
Faisal Hamdi's avatar
Faisal Hamdi committed
602
        console.log(dataTable[dataTable.length - 1])
d.arizona's avatar
d.arizona committed
603
        dataTable.map((i, index) => {
Faisal Hamdi's avatar
Faisal Hamdi committed
604
            if (i[0] === 3) {
rifkaki's avatar
rifkaki committed
605
                // console.log(i);
d.arizona's avatar
d.arizona committed
606 607 608 609 610
                // 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 
Faisal Hamdi's avatar
Faisal Hamdi committed
611
                if (i[18] === "" && (Number(i[14]).toFixed(1) < this.state.minValue || Number(i[14]).toFixed(1) > this.state.maxValue)) {
d.arizona's avatar
d.arizona committed
612 613
                    console.log('msk 2');
                    err = true
d.arizona's avatar
d.arizona committed
614
                }
d.arizona's avatar
d.arizona committed
615
            }
rifkaki's avatar
rifkaki committed
616 617

            if (String(i[5]) == "Control (should be nil)") {
Faisal Hamdi's avatar
Faisal Hamdi committed
618
                if (Number(i[9]).toFixed(1) < this.state.minValue || Number(i[9]).toFixed(1) > this.state.maxValue) {
d.arizona's avatar
d.arizona committed
619 620 621
                    errorContrl = true
                    editAble = true
                }
rifkaki's avatar
rifkaki committed
622 623
            }

Deni Rinaldi's avatar
Deni Rinaldi committed
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
            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
642
        // console.log(JSON.stringify(data));
d.arizona's avatar
d.arizona committed
643 644 645 646 647 648 649 650 651 652 653 654 655
        // 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
656 657 658 659 660 661 662
        // 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
663

Deni Rinaldi's avatar
Deni Rinaldi committed
664 665 666 667 668 669
        // 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,
670
            "currency_id": this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
671 672 673 674
            "status": "submitted",
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
rifkaki's avatar
rifkaki committed
675
        // console.log(JSON.stringify(payload));
rifkaki's avatar
rifkaki committed
676
        // console.log(this.state.dataTable)
677
        api.create().validateSubmitReportBS(payload).then((response) => {
Riri Novita's avatar
Riri Novita committed
678 679
            console.log(response.data.data.result)
            console.log(err);
rifkaki's avatar
rifkaki committed
680
            console.log(errorContrl);
Deni Rinaldi's avatar
Deni Rinaldi committed
681 682
            if (response.data) {
                if (response.data.status === "success") {
Faisal Hamdi's avatar
Faisal Hamdi committed
683
                    if (response.data.data.result && err === false && errorContrl === false) {
Deni Rinaldi's avatar
Deni Rinaldi committed
684
                        this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
d.arizona's avatar
d.arizona committed
685
                        if (kansas == 0) {
Faisal Hamdi's avatar
Faisal Hamdi committed
686
                            this.setState({ kansas: 1, loading: true }, () => {
d.arizona's avatar
d.arizona committed
687 688 689
                                this.handleValidate()
                            })
                        } else {
Faisal Hamdi's avatar
Faisal Hamdi committed
690
                            this.setState({ kansas: 0 })
d.arizona's avatar
d.arizona committed
691
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
692
                    } else {
d.arizona's avatar
d.arizona committed
693
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
d.arizona's avatar
d.arizona committed
694
                        if (kansas == 0) {
Faisal Hamdi's avatar
Faisal Hamdi committed
695
                            this.setState({ kansas: 1, loading: true }, () => {
d.arizona's avatar
d.arizona committed
696 697 698
                                this.handleValidate()
                            })
                        } else {
Faisal Hamdi's avatar
Faisal Hamdi committed
699
                            this.setState({ kansas: 0 })
d.arizona's avatar
d.arizona committed
700
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
701 702 703
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
704
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
705 706 707 708 709 710 711 712 713 714 715 716 717
                            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
718 719 720 721
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
722
    render() {
Deni Rinaldi's avatar
Deni Rinaldi committed
723
        let dataTable2 = this.state.dataTable
Riri Novita's avatar
Riri Novita committed
724
        const handleText = (value, tableMeta, type) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
725
            dataTable2[tableMeta.rowIndex][type] = value
Riri Novita's avatar
Riri Novita committed
726 727
            // console.log(dataTable2[tableMeta.rowIndex]);
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
728 729 730
        const handleChange = (value, tableMeta, type) => {
            let val = String(value).split(",").join("")
            if (type === "actual") {
Deni Rinaldi's avatar
Deni Rinaldi committed
731
                dataTable2[tableMeta.rowIndex][9] = Number(val).toFixed(1)
d.arizona's avatar
d.arizona committed
732
                console.log(dataTable2);
Deni Rinaldi's avatar
Deni Rinaldi committed
733 734 735 736
            } else {
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
                    // console.log(indexParent)
Deni Rinaldi's avatar
Deni Rinaldi committed
737 738 739
                    dataTable2[tableMeta.rowIndex][9] = Number(val).toFixed(1)
                    let jagain = Number(dataTable2[indexParent][9]).toFixed(1)
                    dataTable2[indexParent][9] = jagain === undefined ? (0 + Number(val)).toFixed(1) : Number(Number(jagain) + Number(val)).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
740 741 742 743 744 745 746
                    // if (tableMeta.rowData[5] === 'Cash & Bank Balance') {
                    //     console.log(value);
                    //     console.log(a);
                    //     console.log(jagain);
                    //     console.log(dataTable2[indexParent]);
                    // }
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
747
                    dataTable2[tableMeta.rowIndex][9] = Number(val).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
748 749
                }
            }
d.arizona's avatar
d.arizona committed
750
            console.log(dataTable2);
Deni Rinaldi's avatar
Deni Rinaldi committed
751 752 753 754 755
        }

        const handleValue = (data, type) => {
            let total = 0
            dataTable2.map((item, index) => {
d.arizona's avatar
d.arizona committed
756
                // if (item[2] !== null) {
Deni Rinaldi's avatar
Deni Rinaldi committed
757 758 759 760 761
                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
762
                // }
Deni Rinaldi's avatar
Deni Rinaldi committed
763

Deni Rinaldi's avatar
Deni Rinaldi committed
764 765
            })
            let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
Deni Rinaldi's avatar
Deni Rinaldi committed
766
            dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
767
            // console.log(indexParent);
Deni Rinaldi's avatar
Deni Rinaldi committed
768 769 770 771 772 773 774
            return total
        }

        const handleVariance = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[10])
Deni Rinaldi's avatar
Deni Rinaldi committed
775
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
776 777
            } else if (dex === 2) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[7])
Deni Rinaldi's avatar
Deni Rinaldi committed
778
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
779 780
            } else if (dex === 3) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[8])
Deni Rinaldi's avatar
Deni Rinaldi committed
781
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
782 783 784 785 786 787 788 789 790 791 792
            }
            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
793
                let selisih = Number(dataTable2[tableMeta.rowIndex][11])
Faisal Hamdi's avatar
Faisal Hamdi committed
794 795
                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)
qorri_di's avatar
qorri_di committed
796 797 798
                    || 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
799

d.arizona's avatar
d.arizona committed
800 801
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = String(selisih).includes('-') ? Number(total * -1).toFixed(1) : Number(total).toFixed(1)

d.arizona's avatar
d.arizona committed
802
                // total = String(selisih).includes('-')  && Number(tableMeta.rowData[9]) < Number(tableMeta.rowData[10])? Number(total * -1).toFixed(1) : Number(total).toFixed(1)
d.arizona's avatar
d.arizona committed
803
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = total
Riri Novita's avatar
Riri Novita committed
804 805 806

                // 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)
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
807 808 809 810 811
                // 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
812
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
813
                let selisih = Number(dataTable2[tableMeta.rowIndex][13])
Faisal Hamdi's avatar
Faisal Hamdi committed
814 815
                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)
qorri_di's avatar
qorri_di committed
816 817 818
                    || 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
819

d.arizona's avatar
d.arizona committed
820
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = String(selisih).includes('-') ? Number(total * -1).toFixed(1) : Number(total).toFixed(1)
d.arizona's avatar
d.arizona committed
821
                // total = String(selisih).includes('-') && Number(tableMeta.rowData[9]) < Number(tableMeta.rowData[7]) ? Number(total * -1).toFixed(1) : Number(total).toFixed(1)
d.arizona's avatar
d.arizona committed
822
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = total
Riri Novita's avatar
Riri Novita committed
823 824
                // 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)
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
825
            } else if (dex === 3) {
Riri Novita's avatar
Riri Novita committed
826
                let selisih = Number(dataTable2[tableMeta.rowIndex][15])
Faisal Hamdi's avatar
Faisal Hamdi committed
827 828
                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)
qorri_di's avatar
qorri_di committed
829 830 831
                    || 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
832

d.arizona's avatar
d.arizona committed
833
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = String(selisih).includes('-') ? Number(total * -1).toFixed(1) : Number(total).toFixed(1)
d.arizona's avatar
d.arizona committed
834
                // total = String(selisih).includes('-') && Number(tableMeta.rowData[9]) < Number(tableMeta.rowData[8])? Number(total * -1).toFixed(1) : Number(total).toFixed(1)
d.arizona's avatar
d.arizona committed
835
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = total
836 837 838
                // 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)
                // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
839
                // console.log(total);
Deni Rinaldi's avatar
Deni Rinaldi committed
840 841
            }
            return total
Deni Rinaldi's avatar
Deni Rinaldi committed
842 843
        }

d.arizona's avatar
d.arizona committed
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872
        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
873
                            // let indexID = dataTable2.findIndex((val) => val[21] == tst)
Faisal Hamdi's avatar
Faisal Hamdi committed
874
                            let data = tableMeta.rowData[20] == null ? [] : tableMeta.rowData[20]
d.arizona's avatar
d.arizona committed
875
                            let indexID = data.findIndex((val) => val.item_formula == String(`${item}`))
d.arizona's avatar
d.arizona committed
876
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
877
                                let valuezz = data[indexID].value
d.arizona's avatar
d.arizona committed
878 879 880
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        } else {
Faisal Hamdi's avatar
Faisal Hamdi committed
881
                            let data = tableMeta.rowData[20] == null ? [] : tableMeta.rowData[20]
d.arizona's avatar
d.arizona committed
882
                            let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
d.arizona's avatar
d.arizona committed
883
                            if (indexID !== -1) {
rifkaki's avatar
rifkaki committed
884
                                // console.log(tableMeta)
d.arizona's avatar
d.arizona committed
885 886 887 888 889 890 891 892 893
                                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
894 895 896 897 898 899
                                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
900 901 902 903 904
                            }
                        } else {
                            let indexID = dataTable2.findIndex((val) => val[21] == item)
                            if (indexID !== -1) {
                                let valuezz = dataTable2[indexID][colIdx]
d.arizona's avatar
d.arizona committed
905
                                if (item == dataTable2[tableMeta.rowIndex][21]) {
d.arizona's avatar
d.arizona committed
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 931 932 933 934 935 936 937 938 939 940 941 942 943
                                    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
944
            let optPrev = ""
d.arizona's avatar
d.arizona committed
945 946 947
            anjay2.map((item, index) => {
                if (Array.isArray(item)) {
                    prio = true
d.arizona's avatar
d.arizona committed
948
                    optPrev = opt
d.arizona's avatar
d.arizona committed
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 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
                    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
990 991 992 993 994 995 996 997 998 999 1000
                            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
1001 1002 1003 1004 1005 1006 1007
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "-") {
                        opt = "kurang"
                        if (prio) {
d.arizona's avatar
d.arizona committed
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018
                            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
1019 1020 1021 1022 1023 1024 1025
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "*") {
                        opt = "kali"
                        if (prio) {
d.arizona's avatar
d.arizona committed
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
                            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
1037 1038 1039 1040 1041 1042 1043
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "/") {
                        opt = "bagi"
                        if (prio) {
d.arizona's avatar
d.arizona committed
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
                            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
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
                            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
1082 1083 1084 1085 1086
            // console.log(splitFormula)
            // console.log(baru)
            // console.log(anjay)
            // console.log(anjay2)
            // console.log(total)
d.arizona's avatar
d.arizona committed
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099
            // //         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
1100
        let columns = [
Deni Rinaldi's avatar
Deni Rinaldi committed
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
            {
                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
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142
            {
                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
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160
                                {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
1161 1162 1163 1164 1165
                            </div>
                        )
                    }
                }
            },
Deni Rinaldi's avatar
Deni Rinaldi committed
1166
            {
Deni Rinaldi's avatar
Deni Rinaldi committed
1167
                name: `Rolling Outlook (FY${this.props.periode})`,
Deni Rinaldi's avatar
Deni Rinaldi committed
1168
                options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
1169
                    customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1170
                        <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
1171 1172 1173
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1174 1175 1176 1177 1178
                    setCellProps: () => ({
                        style: {
                            paddingRight: 0
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
1179 1180
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1181
                            <div style={{ textAlign: 'right' }}>
rifkaki's avatar
rifkaki committed
1182
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1183
                                    null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1184
                                    this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1185 1186 1187 1188 1189 1190 1191 1192
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
                                            value={Number(val).toFixed(1)}
                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
                                        :
                                        <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(val).toFixed(1)}
                                                    />
                                                }
                                            />
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1210
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1211 1212 1213 1214 1215 1216 1217 1218 1219
                            </div>
                        )
                    }
                }
            },
            {
                name: `Month To Date (MTD)`,
                options: {
                    customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1220
                        <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
1221
                            {/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1222 1223 1224 1225 1226
                                <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
1227 1228
                                    <span>{"Master Budget (MB)"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1229
                                <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
1230 1231
                                    <span>{"Rolling Budget (RB)"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1232
                                <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
1233 1234 1235 1236
                                    <span>{"Actual"}</span>
                                </div>
                            </div>
                        </th>
Deni Rinaldi's avatar
Deni Rinaldi committed
1237
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1238 1239 1240 1241 1242 1243
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
1244
                    customBodyRender: (val, tableMeta, updateValue) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1245
                        // console.log(tableMeta);
Deni Rinaldi's avatar
Deni Rinaldi committed
1246 1247 1248 1249 1250
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
rifkaki's avatar
rifkaki committed
1251
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1252
                                                null :
d.arizona's avatar
d.arizona committed
1253
                                                // this.state.get_for == 'view'?
Faisal Hamdi's avatar
Faisal Hamdi committed
1254 1255 1256 1257 1258 1259 1260 1261
                                                <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)}
                                                />
d.arizona's avatar
d.arizona committed
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290
                                                // :
                                                // 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
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342
                                                // 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
1343
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1344 1345 1346 1347
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
rifkaki's avatar
rifkaki committed
1348
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1349
                                                null :
d.arizona's avatar
d.arizona committed
1350
                                                // this.state.get_for == 'view'?
Faisal Hamdi's avatar
Faisal Hamdi committed
1351 1352 1353 1354 1355 1356 1357 1358
                                                <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)}
                                                />
d.arizona's avatar
d.arizona committed
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
                                                // :
                                                // 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
1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439
                                                // 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
1440
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1441 1442 1443 1444
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1445
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1446
                                                null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1447
                                                this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1448 1449 1450 1451 1452 1453 1454 1455
                                                    <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[9]).toFixed(1)}
                                                    />
Faisal Hamdi's avatar
Faisal Hamdi committed
1456 1457
                                                    :
                                                    tableMeta.rowData[0] === 3 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1458 1459 1460 1461 1462 1463 1464
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
Faisal Hamdi's avatar
Faisal Hamdi committed
1465
                                                                        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
1466 1467
                                                                        type="text"
                                                                        placeholder=""
Faisal Hamdi's avatar
Faisal Hamdi committed
1468 1469
                                                                        disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
                                                                        value={Number(tableMeta.rowData[9]).toFixed(1)}
d.arizona's avatar
d.arizona committed
1470 1471 1472
                                                                        onBlur={(event) => {
                                                                            handleChange(event.target.value, tableMeta)
                                                                        }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1473 1474 1475
                                                                    />
                                                                }
                                                            />
Deni Rinaldi's avatar
Deni Rinaldi committed
1476
                                                        </div> :
Faisal Hamdi's avatar
Faisal Hamdi committed
1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494
                                                        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}
                                                                            value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "r/e (cummulative)" && this.props.periode == 2021 && this.props.month.month_id == 1 ? Number(tableMeta.rowData[9]).toFixed(1) : Number(handleValueFormula(tableMeta, 9)).toFixed(1)}
                                                                            onBlur={(event) => {
                                                                                handleChange(event.target.value, tableMeta)
                                                                            }}
                                                                        />
                                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1495
                                                                />
Faisal Hamdi's avatar
Faisal Hamdi committed
1496 1497 1498
                                                            </div> :
                                                            tableMeta.rowData[0] === 2 ?
                                                                <span style={{ fontSize: 12, textAlign: 'right' }}>
rifkaki's avatar
rifkaki committed
1499 1500
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
Faisal Hamdi's avatar
Faisal Hamdi committed
1501
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
rifkaki's avatar
rifkaki committed
1502 1503 1504
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
Faisal Hamdi's avatar
Faisal Hamdi committed
1505 1506 1507 1508 1509
                                                                        value={Number(handleValue(tableMeta, 2)).toFixed(1)}
                                                                    />
                                                                </span> :
                                                                tableMeta.rowData[0] === 7 ?
                                                                    (Number(handleValueFormula(tableMeta, 9)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(tableMeta, 9)).toFixed(1) <= Number(this.state.maxValue)) ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1510 1511
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
rifkaki's avatar
rifkaki committed
1512 1513 1514 1515 1516 1517
                                                                            style={{
                                                                                fontSize: 12,
                                                                                textAlign: 'right',
                                                                                borderColor: 'transparent',
                                                                                margin: 0,
                                                                                width: 96,
Faisal Hamdi's avatar
Faisal Hamdi committed
1518
                                                                                backgroundColor: 'transparent'
rifkaki's avatar
rifkaki committed
1519
                                                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1520 1521 1522
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
rifkaki's avatar
rifkaki committed
1523
                                                                            value={Number(handleValueFormula(tableMeta, 9)).toFixed(1)}
Faisal Hamdi's avatar
Faisal Hamdi committed
1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542
                                                                        /> :
                                                                        <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)).toFixed(1)}
                                                                            />
                                                                        </LightTooltip>
rifkaki's avatar
rifkaki committed
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559
                                                                    :
                                                                    <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[9]).toFixed(1)}
                                                                                />
                                                                            }
                                                                        />
                                                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1560
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
            {
                name: "Actual Previous Month",
                options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
1572
                    customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1573
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1574 1575 1576
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1577 1578 1579 1580 1581
                    setCellProps: () => ({
                        style: {
                            paddingRight: 0
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
1582 1583
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1584
                            <div style={{ textAlign: 'right' }}>
rifkaki's avatar
rifkaki committed
1585
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1586
                                    null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1587
                                    this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1588 1589 1590 1591 1592 1593 1594 1595
                                        <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[10]).toFixed(1)}
                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659
                                        :
                                        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, 2)).toFixed(1)}
                                                />
                                            </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}
                                                            value={Number(tableMeta.rowData[10]).toFixed(1)}
                                                        />
                                                    }
                                                />
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1660
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1661 1662 1663 1664 1665 1666 1667 1668 1669 1670
                            </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
1671
                            <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
1672
                            <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1673 1674
                                <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
1675 1676 1677
                                        <span>{"Act vs Previous Month"}</span>
                                    </div>
                                    <div className="grid grid-2x">
Deni Rinaldi's avatar
Deni Rinaldi committed
1678
                                        <div className="column-1" style={{ borderRight: '1px #fff solid', backgroundColor: '#37b5e6' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1679 1680
                                            <span>{"Amount"}</span>
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1681
                                        <div className="column-2" style={{ borderLeft: '1px #fff solid', backgroundColor: '#37b5e6' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1682 1683 1684 1685
                                            <span>{"%"}</span>
                                        </div>
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1686
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698
                                    <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
1699
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714
                                    <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
1715 1716 1717
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
Deni Rinaldi's avatar
Deni Rinaldi committed
1718
                            paddingRight: 10
Deni Rinaldi's avatar
Deni Rinaldi committed
1719 1720
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
1721
                    customBodyRender: (val, tableMeta, updateValue) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1722
                        // console.log(tableMeta);
Deni Rinaldi's avatar
Deni Rinaldi committed
1723 1724 1725
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
1726
                                    <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
1727
                                        <div className="grid grid-2x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
1728
                                            <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
1729
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
1730
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1731
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1732
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1733 1734 1735 1736 1737 1738 1739 1740
                                                            <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[11]).toFixed(1)}
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793
                                                            :
                                                            // 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}
                                                                            value={Number(handleVariance(tableMeta, 1, 2)).toFixed(1)}
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1794
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1795 1796
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1797
                                            <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
1798
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
1799
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1800
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1801
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1802 1803 1804 1805 1806
                                                            <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
1807
                                                                suffix={'%'}
Riri Novita's avatar
Riri Novita committed
1808 1809 1810
                                                                disabled={true}
                                                                value={Number(tableMeta.rowData[12]).toFixed(1)}
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864
                                                            // :
                                                            // 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}
                                                                            value={Number(handleVariancePercent(tableMeta, 1, 3)).toFixed(1)}
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1865
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1866 1867 1868 1869
                                                </div>
                                            </div>
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1870
                                    <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
1871
                                        <div className="grid grid-2x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
1872
                                            <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
1873
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
1874
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1875
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1876
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1877 1878 1879 1880 1881 1882 1883 1884
                                                            <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[13]).toFixed(1)}
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937
                                                            // :
                                                            // 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}
                                                                            value={Number(handleVariance(tableMeta, 2, 4)).toFixed(1)}
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1938
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1939 1940
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1941
                                            <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
1942
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
1943
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1944
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
1945
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
1946 1947 1948 1949 1950
                                                            <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
1951
                                                                suffix={'%'}
Riri Novita's avatar
Riri Novita committed
1952 1953 1954
                                                                disabled={true}
                                                                value={Number(tableMeta.rowData[14]).toFixed(1)}
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
                                                            :
                                                            // 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={'%'}
                                                                            value={Number(handleVariancePercent(tableMeta, 2, 5)).toFixed(1)}
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2009
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2010 2011 2012 2013
                                                </div>
                                            </div>
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2014
                                    <div className="column-3">
Deni Rinaldi's avatar
Deni Rinaldi committed
2015
                                        <div className="grid grid-2x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
2016
                                            <div className="column-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
2017
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
2018
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2019
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2020
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
2021 2022 2023 2024 2025 2026 2027 2028
                                                            <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[15]).toFixed(1)}
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081
                                                            :
                                                            // 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}
                                                                            value={Number(handleVariance(tableMeta, 3, 6)).toFixed(1)}
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2082
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2083 2084
                                                </div>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2085
                                            <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
2086
                                                <div style={{ textAlign: 'right', width: 120 }}>
rifkaki's avatar
rifkaki committed
2087
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2088
                                                        null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2089
                                                        this.state.get_for == 'view' ?
Riri Novita's avatar
Riri Novita committed
2090 2091 2092 2093
                                                            <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
2094
                                                                suffix={'%'}
Riri Novita's avatar
Riri Novita committed
2095 2096 2097 2098
                                                                placeholder=""
                                                                disabled={true}
                                                                value={Number(tableMeta.rowData[16]).toFixed(1)}
                                                            />
Faisal Hamdi's avatar
Faisal Hamdi committed
2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152
                                                            :
                                                            // 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={'%'}
                                                                            value={Number(handleVariancePercent(tableMeta, 3, 7)).toFixed(1)}
                                                                        />
                                                                    }
                                                                />
                                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2153
                                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2154 2155 2156 2157 2158 2159 2160 2161 2162 2163
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
Deni Rinaldi's avatar
Deni Rinaldi committed
2164 2165 2166 2167 2168 2169 2170 2171
            {
                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
2172
                            <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
2173
                            <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2174
                                <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
2175 2176
                                    <span>{"vs Prev Month"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2177
                                <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
2178 2179
                                    <span>{"vs MB"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2180
                                <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
2181 2182 2183 2184 2185
                                    <span>{"vs RB"}</span>
                                </div>
                            </div>
                        </th>
                    ),
Deni Rinaldi's avatar
Deni Rinaldi committed
2186 2187 2188 2189 2190 2191
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
2192 2193 2194 2195 2196 2197
                    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
2198
                                            <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2199
                                                {tableMeta.rowData[0] !== 3 ?
Faisal Hamdi's avatar
Faisal Hamdi committed
2200 2201
                                                    null :
                                                    (this.state.get_for == 'view' ?
d.arizona's avatar
d.arizona committed
2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212
                                                        <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
2213
                                                                    color: 'black',
d.arizona's avatar
d.arizona committed
2214 2215 2216 2217
                                                                    textAlign: 'left'
                                                                }
                                                            }}
                                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
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
                                                        :
                                                        <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
2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282
                                                                // 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
2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303
                                                                <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: {
                                                                            color: Number(tableMeta.rowData[12]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[12]).toFixed(1) > this.state.maxValue ? "#5198ea" : '#5198ea',
                                                                            textAlign: 'left'
                                                                        }
                                                                    }}
                                                                    onBlur={(event) => {
                                                                        handleText(event.target.value, tableMeta, 17)
                                                                    }}
                                                                />
                                                            }
                                                        />)}
Riri Novita's avatar
Riri Novita committed
2304
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2305 2306 2307 2308
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
2309
                                            <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2310
                                                {tableMeta.rowData[0] !== 3 ? null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2311
                                                    (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[18]}
                                                            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
                                                        :
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            // value={value}
                                                            control={
                                                                tableMeta.rowData[18] === "" && (Number(tableMeta.rowData[14]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[14]).toFixed(1) > this.state.maxValue) ?
                                                                    <LightTooltip title={"MTD Explanation vs MB is Reqiured"} arrow>
rifkaki's avatar
rifkaki committed
2335 2336
                                                                        <Input
                                                                            disableUnderline={true}
Faisal Hamdi's avatar
Faisal Hamdi committed
2337
                                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', minHeight: 30, padding: 0 }}
rifkaki's avatar
rifkaki committed
2338 2339
                                                                            type="text"
                                                                            placeholder=""
Faisal Hamdi's avatar
Faisal Hamdi committed
2340 2341 2342
                                                                            multiline={true}
                                                                            // disabled={false}
                                                                            disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
rifkaki's avatar
rifkaki committed
2343 2344 2345
                                                                            defaultValue={tableMeta.rowData[18]}
                                                                            inputProps={{
                                                                                style: {
Faisal Hamdi's avatar
Faisal Hamdi committed
2346 2347 2348 2349 2350
                                                                                    color: "#5198ea",
                                                                                    textAlign: 'left',
                                                                                    backgroundColor: '#ffac99',
                                                                                    minHeight: 30,
                                                                                    padding: 0
rifkaki's avatar
rifkaki committed
2351 2352 2353 2354 2355 2356
                                                                                }
                                                                            }}
                                                                            onBlur={(event) => {
                                                                                handleText(event.target.value, tableMeta, 18)
                                                                            }}
                                                                        />
Faisal Hamdi's avatar
Faisal Hamdi 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 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415
                                                                    </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: {
                                                                                color: Number(tableMeta.rowData[14]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[14]).toFixed(1) > this.state.maxValue ? "#5198ea" : '#5198ea',
                                                                                textAlign: 'left'
                                                                            }
                                                                        }}
                                                                        onBlur={(event) => {
                                                                            handleText(event.target.value, tableMeta, 18)
                                                                        }}
                                                                    />
                                                            }
                                                        />)}
Riri Novita's avatar
Riri Novita committed
2416
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2417 2418 2419 2420
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
2421
                                            <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2422
                                                {tableMeta.rowData[0] !== 3 ? null :
Faisal Hamdi's avatar
Faisal Hamdi committed
2423
                                                    (this.state.get_for == 'view' ?
d.arizona's avatar
d.arizona committed
2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434
                                                        <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
2435
                                                                    color: 'black',
d.arizona's avatar
d.arizona committed
2436 2437 2438 2439
                                                                    textAlign: 'left'
                                                                }
                                                            }}
                                                        />
Faisal Hamdi's avatar
Faisal Hamdi committed
2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468
                                                        :
                                                        <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
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
                                                                // 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
2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525
                                                                <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: {
                                                                            color: Number(tableMeta.rowData[16]).toFixed(1) < this.state.minValue || Number(tableMeta.rowData[16]).toFixed(1) > this.state.maxValue ? "#5198ea" : '#5198ea',
                                                                            textAlign: 'left'
                                                                        }
                                                                    }}
                                                                    onBlur={(event) => {
                                                                        handleText(event.target.value, tableMeta, 19)
                                                                    }}
                                                                />
                                                            }
                                                        />)}
Riri Novita's avatar
Riri Novita committed
2526
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2527 2528 2529 2530 2531 2532 2533
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 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
            }, {
                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
2578 2579 2580 2581 2582 2583
                }
            },
            {
                name: "",
                options: {
                    display: false
Deni Rinaldi's avatar
Deni Rinaldi committed
2584 2585
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
2586
        ]
Deni Rinaldi's avatar
Deni Rinaldi committed
2587

Deni Rinaldi's avatar
Deni Rinaldi committed
2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598
        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
2599 2600
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2601
                {this.state.loading && loadingComponent}
Deni Rinaldi's avatar
Deni Rinaldi committed
2602 2603 2604
                <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
2605 2606 2607 2608 2609
                <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
2610
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2611
                    {this.state.visibleBSMR ? <Paper style={{ paddingTop: 10 }}>
qorri_di's avatar
qorri_di committed
2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 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
                        <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>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</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
2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693
                                                <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
2694
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
qorri_di's avatar
qorri_di committed
2695 2696
                                        </div>
                                    }
qorri_di's avatar
qorri_di committed
2697
                                </div>
qorri_di's avatar
qorri_di committed
2698
                            </div>
qorri_di's avatar
qorri_di committed
2699

qorri_di's avatar
qorri_di committed
2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710
                            <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>
                                )}
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2711

qorri_di's avatar
qorri_di committed
2712 2713 2714 2715 2716 2717 2718 2719 2720 2721
                            <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
2722

qorri_di's avatar
qorri_di committed
2723
                                    }
faisalhamdi's avatar
faisalhamdi committed
2724
                                </div>
qorri_di's avatar
qorri_di committed
2725 2726
                            </div>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2727

qorri_di's avatar
qorri_di committed
2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738
                            <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>
Riri Novita's avatar
Riri Novita committed
2739
                            </div>
qorri_di's avatar
qorri_di committed
2740 2741 2742 2743 2744 2745 2746 2747 2748
                            <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>

                        </div>
                        {/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
Deni Rinaldi's avatar
Deni Rinaldi committed
2749
                                (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') ? */}
qorri_di's avatar
qorri_di committed
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 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841
                        <div className="grid grid-2x" style={{ padding: 20 }}>
                            <div className="col-1" style={{ paddingLeft: 0 }}>
                                <button
                                    type="button"
                                    onClick={() => this.setState({ loading: true }, () => {
                                        setTimeout(() => {
                                            this.props.onClickClose()
                                        }, 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>
                            {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
Deni Rinaldi's avatar
Deni Rinaldi committed
2842
                                        type="button"
qorri_di's avatar
qorri_di committed
2843 2844 2845 2846 2847 2848 2849 2850 2851
                                        // 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')
                                                    })}
Deni Rinaldi's avatar
Deni Rinaldi committed
2852 2853
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2854
                                            cursor: 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2855 2856 2857 2858
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
qorri_di's avatar
qorri_di committed
2859 2860
                                        <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>
Deni Rinaldi's avatar
Deni Rinaldi committed
2861
                                        </div>
qorri_di's avatar
qorri_di committed
2862
                                    </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
2863
                                </div>
qorri_di's avatar
qorri_di committed
2864 2865 2866
                            }
                        </div>
                        {/* : null
Deni Rinaldi's avatar
Deni Rinaldi committed
2867
                            } */}
qorri_di's avatar
qorri_di committed
2868
                    </Paper> :
Deni Rinaldi's avatar
Deni Rinaldi committed
2869 2870 2871
                        <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
2872
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2873 2874 2875
                            <div style={{ padding: 20 }}>
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
2876
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2877
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
d.arizona's avatar
d.arizona committed
2878
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2879
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
rifkaki's avatar
rifkaki committed
2880
                                    {this.state.dataLoaded && !this.state.loading && (
Deni Rinaldi's avatar
Deni Rinaldi committed
2881 2882 2883 2884 2885 2886 2887
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
Faisal Hamdi's avatar
Faisal Hamdi committed
2888
                                    )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2889
                                </div>
d.arizona's avatar
d.arizona committed
2890
                            </div>
Faisal Hamdi's avatar
Faisal Hamdi committed
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
                            <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
2925
                                                setTimeout(() => {
Faisal Hamdi's avatar
Faisal Hamdi committed
2926
                                                    this.handleValidate()
d.arizona's avatar
d.arizona committed
2927
                                                }, 100);
Faisal Hamdi's avatar
Faisal Hamdi committed
2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948
                                            })
                                        }}
                                    >
                                        <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' })
                                                :
2949 2950
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
Faisal Hamdi's avatar
Faisal Hamdi committed
2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965
                                                        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' })
                                                :
2966 2967
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
Faisal Hamdi's avatar
Faisal Hamdi committed
2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980
                                                        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
2981
                                </div>
Faisal Hamdi's avatar
Faisal Hamdi committed
2982
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2983
                        </Paper>
d.arizona's avatar
d.arizona committed
2984
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2985
                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004
                {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>
3005 3006 3007 3008 3009 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 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058
                            <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>
                            <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div>
                        </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
                                        }}
                                        onClick={() => this.setState({ visibleAlertSave: false })}
                                    >
                                        <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
3059 3060 3061
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
3062 3063 3064 3065
            </div>
        )
    }
}