FixedAssetsMovementMR.js 119 KB
Newer Older
faisalhamdi's avatar
faisalhamdi committed
1
import React, { Component } from 'react';
faisalhamdi's avatar
faisalhamdi committed
2
import { createMuiTheme, FormControlLabel, MuiThemeProvider, Paper, TableCell, Tooltip, Typography, withStyles, Snackbar } from '@material-ui/core';
faisalhamdi's avatar
faisalhamdi committed
3 4
import MUIDataTable from 'mui-datatables';
import api from '../../api';
faisalhamdi's avatar
faisalhamdi committed
5 6
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
faisalhamdi's avatar
faisalhamdi committed
7
import NumberFormat from 'react-number-format';
faisalhamdi's avatar
faisalhamdi committed
8
import { PropagateLoader } from 'react-spinners';
faisalhamdi's avatar
faisalhamdi committed
9 10
import UploadFile from '../../library/Upload';
import { ExcelRenderer } from 'react-excel-renderer';
faisalhamdi's avatar
faisalhamdi committed
11 12 13
import * as R from 'ramda'
import Constant from '../../library/Constant';
import { Alert } from '@material-ui/lab';
14
import { fixNumber, roundMath } from '../../library/Utils';
faisalhamdi's avatar
faisalhamdi committed
15 16 17 18 19 20 21 22 23

const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);
faisalhamdi's avatar
faisalhamdi committed
24 25 26 27 28

var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());

const options = ct.customOptionsFixedColumn();
faisalhamdi's avatar
faisalhamdi committed
29

faisalhamdi's avatar
faisalhamdi committed
30 31 32 33
const style = {
    position: "sticky",
    left: 0,
    background: "white",
faisalhamdi's avatar
faisalhamdi committed
34
    zIndex: 101,
faisalhamdi's avatar
faisalhamdi committed
35 36 37 38
};
const style2 = {
    position: "sticky",
    background: "white",
faisalhamdi's avatar
faisalhamdi committed
39 40
    zIndex: 100,
    top: 0
faisalhamdi's avatar
faisalhamdi committed
41 42 43 44 45 46
};

export default class FixedAssetsMovementMR extends Component {
    constructor(props) {
        super(props)
        this.state = {
faisalhamdi's avatar
faisalhamdi committed
47
            dataTable: [],
faisalhamdi's avatar
faisalhamdi committed
48
            loading: true,
faisalhamdi's avatar
faisalhamdi committed
49
            visibleFAMMR: true,
faisalhamdi's avatar
faisalhamdi committed
50
            updateBy: [],
d.arizona's avatar
d.arizona committed
51
            notesUpdate: '-',
rifkaki's avatar
rifkaki committed
52
            get_for: 'view',
faisalhamdi's avatar
faisalhamdi committed
53 54
            saveDraft: true,
            buttonError: true,
55 56
            viewOnly: true,
            defaultCurrencyUpload: this.props.defaultCurrency,
Riri Novita's avatar
Riri Novita committed
57
            visibleAlertSave: false,
faisalhamdi's avatar
faisalhamdi committed
58
        }
faisalhamdi's avatar
faisalhamdi committed
59
        this.fileHandler = this.fileHandler.bind(this);
faisalhamdi's avatar
faisalhamdi committed
60 61 62 63
    }

    componentDidMount() {
        this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
64
        this.getLatestUpdate()
65
        this.handleViewOnly()
faisalhamdi's avatar
faisalhamdi committed
66 67
    }

d.arizona's avatar
d.arizona committed
68
    handleGetFor(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
69
        this.setState({ get_for: type }, () => {
d.arizona's avatar
d.arizona committed
70 71 72 73 74
            this.getItemHierarki()
            this.getLatestUpdate()
        })
    }

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

        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
86

rifkaki's avatar
rifkaki committed
87 88 89 90
        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
Deni Rinaldi's avatar
Deni Rinaldi committed
91
        }
qorri_di's avatar
qorri_di committed
92

d.arizona's avatar
d.arizona committed
93 94 95 96 97
        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
98

rifkaki's avatar
rifkaki committed
99 100 101 102 103 104
        if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
            checkStatus = true
        } else {
            checkStatus = false
        }

d.arizona's avatar
d.arizona committed
105
        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
rifkaki's avatar
rifkaki committed
106 107
    }

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

faisalhamdi's avatar
faisalhamdi committed
140
    getItemHierarki() {
faisalhamdi's avatar
faisalhamdi committed
141 142 143 144 145
        let payload = {
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
faisalhamdi's avatar
faisalhamdi committed
146
            "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
147
            "months": this.props.month.month_id,
148
            "currency_id": this.props.defaultCurrency.id,
d.arizona's avatar
d.arizona committed
149
            "get_for": this.state.get_for
faisalhamdi's avatar
faisalhamdi committed
150
        }
faisalhamdi's avatar
faisalhamdi committed
151
        api.create().getHierarkiMontlyReportFAM(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
152
            // console.log(payload);
rifkaki's avatar
rifkaki committed
153
            console.log(response);
faisalhamdi's avatar
faisalhamdi committed
154 155
            let dataTable = []
            if (response.data) {
faisalhamdi's avatar
faisalhamdi committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
                if (response.data.status === 'success') {
                    let res = response.data.data
                    const handlePushChild = (item) => {
                        let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                        if (indexIDzz === -1) {
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
                                item.fixed_asset_movement.mtd_mb === "" ? "0.0" : item.fixed_asset_movement.mtd_mb,
                                item.fixed_asset_movement.mtd_rb === "" ? "0.0" : item.fixed_asset_movement.mtd_rb,
                                item.fixed_asset_movement.mtd_actual === "" ? "0.0" : item.fixed_asset_movement.mtd_actual,
                                item.fixed_asset_movement.act_vs_mb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_amount,
                                item.fixed_asset_movement.act_vs_mb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_percent,
                                item.fixed_asset_movement.act_vs_rb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_amount,
                                item.fixed_asset_movement.act_vs_rb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_percent,
faisalhamdi's avatar
faisalhamdi committed
175
                                item.fixed_asset_movement.actual_formula,
faisalhamdi's avatar
faisalhamdi committed
176 177 178 179 180 181 182 183 184 185 186 187
                                item.order
                            ])
                        }
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
                        }
                    }
                    res.map((item, index) => {
faisalhamdi's avatar
faisalhamdi committed
188 189 190 191 192 193 194
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.description,
faisalhamdi's avatar
faisalhamdi committed
195 196 197 198 199 200 201
                            item.fixed_asset_movement.mtd_mb === "" ? "0.0" : item.fixed_asset_movement.mtd_mb,
                            item.fixed_asset_movement.mtd_rb === "" ? "0.0" : item.fixed_asset_movement.mtd_rb,
                            item.fixed_asset_movement.mtd_actual === "" ? "0.0" : item.fixed_asset_movement.mtd_actual,
                            item.fixed_asset_movement.act_vs_mb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_amount,
                            item.fixed_asset_movement.act_vs_mb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_percent,
                            item.fixed_asset_movement.act_vs_rb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_amount,
                            item.fixed_asset_movement.act_vs_rb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_percent,
faisalhamdi's avatar
faisalhamdi committed
202
                            item.fixed_asset_movement.actual_formula,
faisalhamdi's avatar
faisalhamdi committed
203
                            item.order
faisalhamdi's avatar
faisalhamdi committed
204
                        ])
faisalhamdi's avatar
faisalhamdi committed
205 206 207 208 209 210
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
faisalhamdi's avatar
faisalhamdi committed
211
                        }
faisalhamdi's avatar
faisalhamdi committed
212
                    })
rifkaki's avatar
rifkaki committed
213
                    console.log(dataTable);
faisalhamdi's avatar
faisalhamdi committed
214
                    this.setState({ dataTable, loading: false, refresh: false, buttonError: true, saveDraft: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
215
                        this.setState({ loading: true, refresh: true })
d.arizona's avatar
d.arizona committed
216
                        setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
217
                            this.setState({ loading: false, refresh: false, buttonError: true, saveDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
218 219
                        }, 200);

d.arizona's avatar
d.arizona committed
220
                    })
faisalhamdi's avatar
faisalhamdi committed
221 222
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
223
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
224 225 226 227
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
faisalhamdi's avatar
faisalhamdi committed
228
                        }
faisalhamdi's avatar
faisalhamdi committed
229
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
230
                }
faisalhamdi's avatar
faisalhamdi committed
231
            } else {
faisalhamdi's avatar
faisalhamdi committed
232
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, refresh: false, buttonError: true, saveDraft: true })
faisalhamdi's avatar
faisalhamdi committed
233 234 235 236
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
237 238
    downloadTemplate = async () => {
        let res = await fetch(
239
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/fam/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}&&currency_id=${this.props.defaultCurrency.id}`
faisalhamdi's avatar
faisalhamdi committed
240 241 242 243 244 245 246 247 248
        )
        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 Fixed Assets Movement.xlsx'
            a.click();
Deni Rinaldi's avatar
Deni Rinaldi committed
249
        }
faisalhamdi's avatar
faisalhamdi committed
250 251 252
    }

    async downloadAllData() {
faisalhamdi's avatar
faisalhamdi committed
253
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/fam/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}`
faisalhamdi's avatar
faisalhamdi committed
254 255
        console.log(url);
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
256
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/fam/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}`
faisalhamdi's avatar
faisalhamdi committed
257
        )
faisalhamdi's avatar
faisalhamdi committed
258 259
        res = await res.blob()
        this.setState({ loading: false })
faisalhamdi's avatar
faisalhamdi committed
260 261 262 263 264 265 266 267 268
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Monthly Report Fixed Assets Movement.xlsx';
            a.click();
        }
    }

faisalhamdi's avatar
faisalhamdi committed
269 270 271 272 273 274 275 276 277 278 279 280 281
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
faisalhamdi's avatar
faisalhamdi committed
282
                            orders: i[0] === undefined ? "" : String(i[0]).trim(),
faisalhamdi's avatar
faisalhamdi committed
283 284
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
faisalhamdi's avatar
faisalhamdi committed
285
                            mtd_actual: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
faisalhamdi's avatar
faisalhamdi committed
286 287 288 289 290 291 292
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
faisalhamdi's avatar
faisalhamdi committed
293
                    months: this.props.month.month_id,
d.arizona's avatar
d.arizona committed
294 295
                    fixed_asset_movement: payload,
                    status: 'submitted'
faisalhamdi's avatar
faisalhamdi committed
296
                }
faisalhamdi's avatar
faisalhamdi committed
297
                // console.log(body)
rifkaki's avatar
rifkaki committed
298
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
faisalhamdi's avatar
faisalhamdi committed
299 300 301
            }
        });
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
302

faisalhamdi's avatar
faisalhamdi committed
303
    checkUpload() {
304 305 306 307 308
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        api.create().checkUploadMonthlyReportFAM(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
309
            // console.log(JSON.stringify(this.state.payload));
faisalhamdi's avatar
faisalhamdi committed
310
            // console.log(this.state.payload)
d.arizona's avatar
d.arizona committed
311
            console.log(response)
faisalhamdi's avatar
faisalhamdi committed
312 313
            if (response.data) {
                if (response.data.status === 'success') {
faisalhamdi's avatar
faisalhamdi committed
314
                    this.setState({ visibleUpload: false, loading: true, visibleFAMMR: false, refresh: true })
faisalhamdi's avatar
faisalhamdi committed
315 316 317 318 319 320 321 322 323 324 325
                    let dataTable = response.data.data.map((item, index) => {
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.item_report,
                            item.mtd_mb,
                            item.mtd_rb,
                            item.mtd_actual,
faisalhamdi's avatar
faisalhamdi committed
326 327 328 329 330
                            item.act_vs_mb_amount,
                            item.act_vs_mb_percent,
                            item.act_vs_rb_amount,
                            item.act_vs_rb_percent,
                            item.actual_formula,
faisalhamdi's avatar
faisalhamdi committed
331 332 333 334
                            item.order,
                            item.error
                        ]
                    })
faisalhamdi's avatar
faisalhamdi committed
335 336
                    console.log(dataTable)
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: true, editable: true, refresh: false }, () => {
faisalhamdi's avatar
faisalhamdi committed
337
                        this.state.dataTable.map(item => {
d.arizona's avatar
d.arizona committed
338
                            if (item[15].length > 0) {
faisalhamdi's avatar
faisalhamdi committed
339
                                console.log('masuk')
faisalhamdi's avatar
faisalhamdi committed
340 341 342 343
                                this.setState({ buttonError: true, errorPreview: true, editable: true, loading: true, refresh: true })
                                setTimeout(() => {
                                    this.setState({ loading: false, refresh: false })
                                }, 200);
faisalhamdi's avatar
faisalhamdi committed
344 345
                            }
                        })
faisalhamdi's avatar
faisalhamdi committed
346
                        // console.log(this.state.dataTable);
faisalhamdi's avatar
faisalhamdi committed
347
                    })
Riri Novita's avatar
Riri Novita committed
348 349
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
350
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
351 352 353 354 355 356
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
faisalhamdi's avatar
faisalhamdi committed
357 358 359 360 361 362 363
                }
            }
        })
    }

    uploadFAMMR(type) {
        let data = []
364 365 366 367 368 369 370 371 372 373 374 375 376
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    item_report: String(i[5]),
                    mtd_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[6])) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6])),
                    mtd_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[7])) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7])),
                    mtd_actual: i[0] === 5 || i[0] === 6 ? String(Number(i[8])) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8])),
                    act_vs_mb_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[9])) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9])),
                    act_vs_mb_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[10])) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10])),
                    act_vs_rb_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[11])) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11])),
                    act_vs_rb_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[12])) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12])),
                })
faisalhamdi's avatar
faisalhamdi committed
377
            })
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    item_report: String(i[5]),
                    mtd_mb: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[6]), 1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(fixNumber(Number(i[6]), 1)),
                    mtd_rb: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[7]), 1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(fixNumber(Number(i[7]), 1)),
                    mtd_actual: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[8]), 1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(fixNumber(Number(i[8]), 1)),
                    act_vs_mb_amount: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[9]), 1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(fixNumber(Number(i[9]), 1)),
                    act_vs_mb_percent: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[10]), 1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(fixNumber(Number(i[10]), 1)),
                    act_vs_rb_amount: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[11]), 1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(fixNumber(Number(i[11]), 1)),
                    act_vs_rb_percent: i[0] === 5 || i[0] === 6 ? String(fixNumber(Number(i[12]), 1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(fixNumber(Number(i[12]), 1)),
                })
            })
        }

faisalhamdi's avatar
faisalhamdi committed
394
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
395
            "monthly_report_id": this.props.monthlyReportId,
faisalhamdi's avatar
faisalhamdi committed
396 397 398
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
399
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
400 401 402 403 404 405
            "status": type,
            "months": this.props.month.month_id,
            "fixed_asset_movement": data
        }
        console.log(data);
        api.create('UPLOAD').uploadMonthlyReportFAM(body).then(response => {
faisalhamdi's avatar
faisalhamdi committed
406
            // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
407
            if (response.data) {
faisalhamdi's avatar
faisalhamdi committed
408
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
409
                    // this.props.onClickClose()
d.arizona's avatar
d.arizona committed
410 411 412 413 414
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('FAM')
                    } else {
                        this.props.saveToMonthlyReport()
                    }
faisalhamdi's avatar
faisalhamdi committed
415
                    // this.props.getReport()
faisalhamdi's avatar
faisalhamdi committed
416
                } else {
417 418 419 420 421 422 423 424 425 426 427 428
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ visibleAlertSave: true, alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
429
                }
faisalhamdi's avatar
faisalhamdi committed
430 431
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
432 433 434 435
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
436
    backToMonthlyReport(type) {
faisalhamdi's avatar
faisalhamdi committed
437
        this.setState({ loading: true })
faisalhamdi's avatar
faisalhamdi committed
438
        // console.log(this.state.dataTable);
faisalhamdi's avatar
faisalhamdi committed
439
        let data = []
440 441 442 443 444 445 446 447 448 449 450 451
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    "item_report_id": i[1],
                    "mtd_mb": String(Number(i[6])),
                    "mtd_rb": String(Number(i[7])),
                    "mtd_actual": String(Number(i[8])),
                    "act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(Number(i[9])),
                    "act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(Number(i[10])),
                    "act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(Number(i[11])),
                    "act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(Number(i[12]))
                })
faisalhamdi's avatar
faisalhamdi committed
452
            })
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    "item_report_id": i[1],
                    "mtd_mb": String(fixNumber(Number(i[6]), 1)),
                    "mtd_rb": String(fixNumber(Number(i[7]), 1)),
                    "mtd_actual": String(fixNumber(Number(i[8]), 1)),
                    "act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(fixNumber(Number(i[9]), 1)),
                    "act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(fixNumber(Number(i[10]), 1)),
                    "act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(fixNumber(Number(i[11]), 1)),
                    "act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(fixNumber(Number(i[12]), 1))
                })
            })
        }

faisalhamdi's avatar
faisalhamdi committed
468
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
469
            "monthly_report_id": this.props.monthlyReportId,
faisalhamdi's avatar
faisalhamdi committed
470 471 472
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
473
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
474 475 476 477
            "status": type,
            "months": this.props.month.month_id,
            "fixed_asset_movement": data
        }
faisalhamdi's avatar
faisalhamdi committed
478
        // console.log(JSON.stringify(payload));
Deni Rinaldi's avatar
Deni Rinaldi committed
479

faisalhamdi's avatar
faisalhamdi committed
480
        api.create('UPLOAD').createMonthlyReportFAM(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
481
            // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
482 483
            if (response.data) {
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
484 485 486 487 488
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('FAM')
                    } else {
                        this.props.saveToMonthlyReport()
                    }
faisalhamdi's avatar
faisalhamdi committed
489
                } else {
490 491 492 493 494 495 496 497 498 499 500 501 502 503
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                            document.body.style.overflow = 'unset';
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                            this.props.saveToMonthlyReport()
                        })
                    }
qorri_di's avatar
qorri_di committed
504
                }
Riri Novita's avatar
Riri Novita committed
505 506 507 508 509
                // else {
                //     this.setState({ loading: false }, () => {
                //         this.props.saveToMonthlyReport()
                //     })
                // }
faisalhamdi's avatar
faisalhamdi committed
510 511 512 513 514
            } else {
                this.setState({ loading: false }, () => {
                    this.getSubmission()
                    document.body.style.overflow = 'unset';
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
515 516
            }
        })
faisalhamdi's avatar
faisalhamdi committed
517 518
    }

faisalhamdi's avatar
faisalhamdi committed
519 520 521 522
    handleValidate() {
        let data = []
        let err = false
        this.state.dataTable.map((i, index) => {
qorri_di's avatar
qorri_di committed
523

faisalhamdi's avatar
faisalhamdi committed
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
            data.push({
                "item_report_id": i[1],
                "mtd_mb": i[6],
                "mtd_rb": i[7],
                "mtd_actual": i[8],
                "act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(i[9]),
                "act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(i[10]),
                "act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(i[11]),
                "act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(i[12])
            })
        })


        // 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,
543
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
            "status": "submitted",
            "months": this.props.month.month_id,
            "fixed_asset_movement": data
        }
        // console.log(JSON.stringify(payload));
        api.create().validateSubmitReportFAM(payload).then((response) => {
            console.log(response.data.data.result)
            console.log(err);
            if (response.data) {
                if (response.data.status === "success") {
                    if (response.data.data.result && err === false) {
                        this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
                    } else {
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
561
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
562 563 564 565 566 567 568 569 570 571 572 573 574
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
575 576 577 578
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
579
    render() {
faisalhamdi's avatar
faisalhamdi committed
580
        let dataTable2 = this.state.dataTable
faisalhamdi's avatar
faisalhamdi committed
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595

        const handleValueFormula = (tableMeta, colIdx) => {
            // loading = true
            // console.log(tableMeta);
            // "@44[M-1]#BS"
            let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
            let baru = []
            let anjay = []
            // console.log(splitFormula);
            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)
                // console.log(item);
                // console.log(items);
                // console.log(subForm);
Deni Rinaldi's avatar
Deni Rinaldi committed
596

faisalhamdi's avatar
faisalhamdi committed
597 598 599 600 601 602 603 604 605 606
                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))
                    }
faisalhamdi's avatar
faisalhamdi committed
607 608 609
                }
            })

faisalhamdi's avatar
faisalhamdi committed
610
            // console.log(baru);
Riri Novita's avatar
Riri Novita committed
611 612
            let tambahan = false
            let opet = ""
faisalhamdi's avatar
faisalhamdi committed
613
            baru.map((item, index) => {
Riri Novita's avatar
Riri Novita committed
614 615 616
                if (item == 'X') {
                    tambahan = true
                } else if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
faisalhamdi's avatar
faisalhamdi committed
617
                    anjay.push(item)
faisalhamdi's avatar
faisalhamdi committed
618
                } else {
faisalhamdi's avatar
faisalhamdi committed
619 620
                    if (String(item).includes('#')) {
                        if (String(item).includes('[M-1]')) {
Riri Novita's avatar
Riri Novita committed
621
                            let tst = '@' + String(item).replace('[M-1]', '[M1]')
Deni Rinaldi's avatar
Deni Rinaldi committed
622 623
                            // console.log(dataTable2[tableMeta.rowIndex]);
                            // console.log(tableMeta);
Riri Novita's avatar
Riri Novita committed
624
                            console.log(tst);
faisalhamdi's avatar
faisalhamdi committed
625
                            let indexID = dataTable2[tableMeta.rowIndex][13].findIndex((val) => val.item_formula == tst)
Deni Rinaldi's avatar
Deni Rinaldi committed
626
                            // console.log(indexID);
Deni Rinaldi's avatar
Deni Rinaldi committed
627

faisalhamdi's avatar
faisalhamdi committed
628
                            if (indexID !== -1) {
faisalhamdi's avatar
faisalhamdi committed
629
                                let valuezz = dataTable2[tableMeta.rowIndex][13][indexID].value
faisalhamdi's avatar
faisalhamdi committed
630
                                anjay.push(valuezz == "" ? 0 : valuezz)
Deni Rinaldi's avatar
Deni Rinaldi committed
631
                                // console.log(valuezz);
faisalhamdi's avatar
faisalhamdi committed
632
                            }
faisalhamdi's avatar
faisalhamdi committed
633
                        } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
634
                            let data = tableMeta.rowData[13] == null ? [] : tableMeta.rowData[13]
faisalhamdi's avatar
faisalhamdi committed
635 636 637 638 639
                            let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
                            if (indexID !== -1) {
                                let valuezz = data[indexID].value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
faisalhamdi's avatar
faisalhamdi committed
640 641
                        }
                    } else {
faisalhamdi's avatar
faisalhamdi committed
642 643
                        if (String(item).includes('[M-1]')) {
                            let tst = String(item).replace('[M-1]', '')
faisalhamdi's avatar
faisalhamdi committed
644
                            let indexID = dataTable2.findIndex((val) => val[14] == tst)
faisalhamdi's avatar
faisalhamdi committed
645 646 647 648 649
                            if (indexID !== -1) {
                                let valuezz = dataTable2[indexID][8]
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        } else {
faisalhamdi's avatar
faisalhamdi committed
650
                            let indexID = dataTable2.findIndex((val) => val[14] == item)
Riri Novita's avatar
Riri Novita committed
651 652 653 654 655
                            if (item == 'X-1') {
                                anjay.push(-1)
                            } else if (tambahan) {
                                if (item == '-' || item == '+' || item == '/' || item == '*') {
                                    opet = item
faisalhamdi's avatar
faisalhamdi committed
656
                                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
657
                                    anjay.push(opet == '' ? Number(item) : Number(String(opet + String(item))))
Riri Novita's avatar
Riri Novita committed
658 659
                                    tambahan = false
                                    opet = ""
faisalhamdi's avatar
faisalhamdi committed
660 661
                                }
                            } else {
Riri Novita's avatar
Riri Novita committed
662 663 664 665 666 667 668 669 670 671 672
                                if (indexID !== -1) {
                                    let valuezz = dataTable2[indexID][colIdx]
                                    if (item == dataTable2[tableMeta.rowIndex][28]) {
                                        anjay.push(0)
                                    } else {
                                        anjay.push(valuezz == "" ? 0 : valuezz)
                                    }
                                } else {
                                    if (item === '(-1)') {
                                        anjay.push(-1)
                                    }
faisalhamdi's avatar
faisalhamdi committed
673 674
                                }
                            }
faisalhamdi's avatar
faisalhamdi committed
675 676 677 678 679
                        }
                    }
                }
            })

faisalhamdi's avatar
faisalhamdi committed
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698
            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)
                    }
                }
            })

faisalhamdi's avatar
faisalhamdi committed
699
            let total = 0
faisalhamdi's avatar
faisalhamdi committed
700
            let opt = ""
faisalhamdi's avatar
faisalhamdi committed
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
            let totalPrio = 0
            let optPrio = ""
            let prio = false
            anjay2.map((item, index) => {
                if (Array.isArray(item)) {
                    prio = true
                    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)
                            }
                        }
                    })
faisalhamdi's avatar
faisalhamdi committed
730

faisalhamdi's avatar
faisalhamdi committed
731 732 733 734 735 736 737 738 739 740 741 742 743
                    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)
                        }
                    }
faisalhamdi's avatar
faisalhamdi committed
744
                } else {
faisalhamdi's avatar
faisalhamdi committed
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776
                    if (item == "+") {
                        opt = "tambah"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "-") {
                        opt = "kurang"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "*") {
                        opt = "kali"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "/") {
                        opt = "bagi"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
faisalhamdi's avatar
faisalhamdi committed
777
                    } else {
faisalhamdi's avatar
faisalhamdi committed
778 779 780 781 782 783 784 785 786 787 788
                        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)
                        }
faisalhamdi's avatar
faisalhamdi committed
789
                    }
faisalhamdi's avatar
faisalhamdi committed
790 791
                }
            })
faisalhamdi's avatar
faisalhamdi committed
792

faisalhamdi's avatar
faisalhamdi committed
793 794 795 796
            total = R.equals(total, NaN) ? "0.0" : total
            dataTable2[tableMeta.rowIndex][colIdx] = total
            return total
        }
faisalhamdi's avatar
faisalhamdi committed
797

faisalhamdi's avatar
faisalhamdi committed
798
        const handleChange = (value, tableMeta, type) => {
d.arizona's avatar
d.arizona committed
799 800
            let val = String(value).split(",").join("")
            dataTable2[tableMeta.rowIndex][type] = val
d.arizona's avatar
d.arizona committed
801
            // console.log(dataTable2)
faisalhamdi's avatar
faisalhamdi committed
802 803 804
            // console.log(dataTable2[tableMeta.rowIndex][type]);
            // console.log(value);
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
805

faisalhamdi's avatar
faisalhamdi committed
806
        const handleValue = (data, type) => {
qorri_di's avatar
qorri_di committed
807
            // console.log(data, type);            
faisalhamdi's avatar
faisalhamdi committed
808 809 810 811 812 813 814 815
            let total = 0
            dataTable2.map((item, index) => {
                if (data.rowData[1] === item[2]) {
                    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
                }
            })
            let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
816
            let a = dataTable2[data.rowIndex][data.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
faisalhamdi's avatar
faisalhamdi committed
817
            // console.log(indexParent);
faisalhamdi's avatar
faisalhamdi committed
818 819
            return a
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
820

faisalhamdi's avatar
faisalhamdi committed
821
        const handleVariance = (tableMeta, dex, type) => {
Riri Novita's avatar
Riri Novita committed
822
            // console.log(tableMeta);
faisalhamdi's avatar
faisalhamdi committed
823
            let total = 0
faisalhamdi's avatar
faisalhamdi committed
824 825
            // if (dex === 1) {
            //     total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[9]) == NaN? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[9])
826
            //     dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
827 828 829
            // console.log(tableMeta.rowData[8]);
            // console.log(tableMeta.rowData[9]);
            // console.log(total)
faisalhamdi's avatar
faisalhamdi committed
830
            if (dex === 2) {
Deni Rinaldi's avatar
Deni Rinaldi committed
831
                total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[6]) == NaN ? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[6])
832
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
d.arizona's avatar
d.arizona committed
833 834 835
                // console.log(tableMeta.rowData[8]);
                // console.log(tableMeta.rowData[6]);
                // console.log(total)
faisalhamdi's avatar
faisalhamdi committed
836
            } else if (dex === 3) {
Deni Rinaldi's avatar
Deni Rinaldi committed
837
                total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[7]) == NaN ? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[7])
838
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
Riri Novita's avatar
Riri Novita committed
839 840 841
                // console.log(tableMeta.rowData[8]);
                // console.log(tableMeta.rowData[7]);
                // console.log(total)
faisalhamdi's avatar
faisalhamdi committed
842
            }
d.arizona's avatar
d.arizona committed
843 844
            // console.log(dex)
            // console.log(Number(tableMeta.columnIndex) + Number(type))
faisalhamdi's avatar
faisalhamdi committed
845 846
            // console.log(total);
            // console.log(dataTable2);
faisalhamdi's avatar
faisalhamdi committed
847 848 849 850 851
            return total
        }

        const handleVariancePercent = (tableMeta, dex, type) => {
            let total = 0
faisalhamdi's avatar
faisalhamdi committed
852 853 854 855 856 857
            // if (tableMeta.rowData[5] === "Disposal (negative value)") {
            //     console.log(dataTable2);
            //     console.log(tableMeta);
            // }
            // value={Number(handleVariancePercent(tableMeta, 1, 3)).toFixed(1)}
            // dataTable2[5][11]
faisalhamdi's avatar
faisalhamdi committed
858 859
            // if (dex === 1) {
            //     total = R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])
860
            //     dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
861 862 863 864 865
            // 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]);
            // }
faisalhamdi's avatar
faisalhamdi committed
866 867
            if (dex === 2) {
                total = R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])
868
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
faisalhamdi's avatar
faisalhamdi committed
869
            } else if (dex === 3) {
faisalhamdi's avatar
faisalhamdi committed
870
                total = R.equals((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][7])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][7])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][7])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][7])
871
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
faisalhamdi's avatar
faisalhamdi committed
872
                // console.log(total);
faisalhamdi's avatar
faisalhamdi committed
873
            }
d.arizona's avatar
d.arizona committed
874 875
            // console.log(dex)
            // console.log(Number(tableMeta.columnIndex) + Number(type))
d.arizona's avatar
d.arizona committed
876
            return total * 100
faisalhamdi's avatar
faisalhamdi committed
877 878
        }

faisalhamdi's avatar
faisalhamdi committed
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910
        let columns = [
            {
                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
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
                name: "Account",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style }),
                    customBodyRender: (value, tableMeta) => {
                        return (
                            <div style={{ width: 300 }}>
                                {tableMeta.rowData[24] ?
                                    tableMeta.rowData[24].length > 0 ?
                                        <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 ? "" : value}</span>
                                            </LightTooltip>
                                        </div>
                                        :
                                        tableMeta.rowData[4] === 0 ?
                                            <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : value).toUpperCase()}</span>
                                            :
                                            <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : value}</span>
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
936
                                    :
faisalhamdi's avatar
faisalhamdi committed
937 938
                                    tableMeta.rowData[4] === 0 ?
                                        <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : value).toUpperCase()}</span>
faisalhamdi's avatar
faisalhamdi committed
939 940
                                        :
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
faisalhamdi's avatar
faisalhamdi committed
941
                                            <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : value}</span>
faisalhamdi's avatar
faisalhamdi committed
942
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
943 944 945 946
                                }
                            </div>
                        )
                    }
faisalhamdi's avatar
faisalhamdi committed
947
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
948 949 950 951 952 953
            }, {
                name: `Month To Date (MTD)`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <th style={{ ...style2, color: '#fff', backgroundColor: '#1c71b8', 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 }}>
faisalhamdi's avatar
faisalhamdi committed
954 955
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
956 957 958 959 960 961 962 963 964 965 966
                            <div style={{ borderBottom: "1px #fff solid", backgroundColor: '#1c71b8', justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45 }}>{columnMeta.name}</div>
                            <div className="grid grid-3x" style={{ ...style2, color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                    <span>{"Master Budget (MB)"}</span>
                                </div>
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                    <span>{"Rolling Budget (RB)"}</span>
                                </div>
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                    <span>{"Actual"}</span>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
967
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
968 969 970 971 972 973 974 975 976 977 978 979
                        </th>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (value, tableMeta, updateValue) => {
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {
                                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
                                                    null :
Riri Novita's avatar
Riri Novita committed
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
                                                    this.state.get_for == 'view' ?
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={value}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={fixNumber(Number(tableMeta.rowData[6]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[6]), 1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={value}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(tableMeta.rowData[6]) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[6]), 1) : Number(tableMeta.rowData[6])}
                                                                    />
                                                                }
                                                            />
                                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1014 1015
                                            }
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1016
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1017 1018 1019 1020 1021
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {
                                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
                                                    null :
Riri Novita's avatar
Riri Novita committed
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
                                                    this.state.get_for == 'view' ?
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={value}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={fixNumber(Number(tableMeta.rowData[7]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[7]), 1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={value}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1051
                                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[7]), 1) : Number(tableMeta.rowData[7]) == 0 ? "0.0" : Number(tableMeta.rowData[7])}
Riri Novita's avatar
Riri Novita committed
1052 1053 1054 1055
                                                                    />
                                                                }
                                                            />
                                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
                                            }
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 120 }}>
                                            {
                                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
                                                    null :
                                                    this.state.get_for == 'view' ?
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
faisalhamdi's avatar
faisalhamdi committed
1072 1073
                                                                    type="text"
                                                                    placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1074
                                                                    disabled={true}
1075
                                                                    value={Number(tableMeta.rowData[8]) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[8]), 1)}
faisalhamdi's avatar
faisalhamdi committed
1076 1077 1078
                                                                />
                                                            }
                                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
                                                        :
                                                        tableMeta.rowData[0] === 3 ?
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={value}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            // style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            style={{ color: this.props.isApprover || this.state.get_for == 'view' ? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
Riri Novita's avatar
Riri Novita committed
1093
                                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[8]), 1) : Number(tableMeta.rowData[8]) == 0 ? "0.0" : Number(tableMeta.rowData[8])}
Deni Rinaldi's avatar
Deni Rinaldi committed
1094 1095 1096
                                                                            onBlur={(event) => {
                                                                                handleChange(event.target.value, tableMeta, 8)
                                                                            }}
1097
                                                                        // decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
Deni Rinaldi's avatar
Deni Rinaldi committed
1098 1099 1100 1101 1102 1103
                                                                        />
                                                                    }
                                                                />
                                                            </div> :
                                                            tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
                                                                <span style={{ fontSize: 12, textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1104 1105
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
qorri_di's avatar
qorri_di committed
1106
                                                                        style={{ color: String(tableMeta.rowData[5]).toLocaleLowerCase() == "beginning balance" && this.props.periode == 2021 && this.props.month.month_id == 1 ? "#5198ea" : "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
faisalhamdi's avatar
faisalhamdi committed
1107 1108
                                                                        type="text"
                                                                        placeholder=""
qorri_di's avatar
qorri_di committed
1109
                                                                        disabled={String(tableMeta.rowData[5]).toLocaleLowerCase() == "beginning balance" && this.props.periode == 2021 && this.props.month.month_id == 1 ? false : true}
Riri Novita's avatar
Riri Novita committed
1110
                                                                        value={this.props.defaultCurrency.id == 1 ? (String(tableMeta.rowData[5]).toLocaleLowerCase() == "beginning balance" && this.props.periode == 2021 && this.props.month.month_id == 1 ? fixNumber(Number(tableMeta.rowData[8]), 1) : fixNumber(Number(handleValueFormula(tableMeta, 8)), 1)) : (String(tableMeta.rowData[5]).toLocaleLowerCase() == "beginning balance" && this.props.periode == 2021 && this.props.month.month_id == 1 ? (Number(tableMeta.rowData[8]) == 0 ? "0.0" : Number(tableMeta.rowData[8])) : (Number(handleValueFormula(tableMeta, 8)) == 0 ? "0.0" : Number(handleValueFormula(tableMeta, 8))))}
d.arizona's avatar
d.arizona committed
1111 1112 1113
                                                                        onBlur={(event) => {
                                                                            handleChange(event.target.value, tableMeta, 8)
                                                                        }}
1114
                                                                        decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
faisalhamdi's avatar
faisalhamdi committed
1115
                                                                    />
Deni Rinaldi's avatar
Deni Rinaldi committed
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127
                                                                </span> :
                                                                <div style={{ flex: 1 }}>
                                                                    <FormControlLabel
                                                                        style={{ margin: 0 }}
                                                                        value={value}
                                                                        control={
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
1128
                                                                                value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[8]), 1) : Number(tableMeta.rowData[8]) == 0 ? "0.0" : Number(tableMeta.rowData[8])}
Deni Rinaldi's avatar
Deni Rinaldi committed
1129 1130 1131 1132 1133 1134
                                                                            />
                                                                        }
                                                                    />
                                                                </div>
                                            }
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1135 1136 1137
                                    </div>
                                </div>
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1138 1139
                        )
                    }
faisalhamdi's avatar
faisalhamdi committed
1140
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150
            }, {
                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)" }} >
                            <div style={{ borderLeft: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>{columnMeta.name}</div>
                            <div className="grid grid-2x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}>
                                    <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
                                        <span>{"Act vs MB"}</span>
faisalhamdi's avatar
faisalhamdi committed
1151
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1152 1153 1154 1155 1156 1157 1158
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
                                            <span>{"Amount"}</span>
                                        </div>
                                        <div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
                                            <span>{"%"}</span>
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1159 1160
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1161 1162 1163
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}>
                                    <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
                                        <span>{"Act vs RB"}</span>
faisalhamdi's avatar
faisalhamdi committed
1164
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1165 1166 1167 1168 1169 1170 1171
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
                                            <span>{"Amount"}</span>
                                        </div>
                                        <div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
                                            <span>{"%"}</span>
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1172 1173 1174
                                    </div>
                                </div>
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
                        </th>
                    ),
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 10
                        }
                    }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        // console.log(tableMeta);
                        return (
                            <div>
                                <div className="grid grid-2x content-center">
                                    <div className="column-1">
                                        <div className="grid grid-2x content-center">
                                            <div className="column-1">
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null :
                                                        this.state.get_for == 'view' ?
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1205
                                                                        value={fixNumber(Number(tableMeta.rowData[9]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[9]), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220
                                                                    />
                                                                }
                                                            />
                                                            :
                                                            <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}
1221
                                                                            value={Number(tableMeta.rowData[9]) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleVariance(tableMeta, 2, 2)), 1) : Number(handleVariance(tableMeta, 2, 2))}
Deni Rinaldi's avatar
Deni Rinaldi committed
1222 1223
                                                                        />
                                                                    }
faisalhamdi's avatar
faisalhamdi committed
1224
                                                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
1225 1226 1227
                                                            </div>
                                                    }
                                                </div>
faisalhamdi's avatar
faisalhamdi committed
1228
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
                                            <div className="column-2">
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null :
                                                        this.state.get_for == 'view' ?
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        suffix={'%'}
Riri Novita's avatar
Riri Novita committed
1245
                                                                        value={fixNumber(Number(Number(tableMeta.rowData[10])), 1) == 0 ? "0.0" : fixNumber(Number(Number(tableMeta.rowData[10])), 1)}
Riri Novita's avatar
Riri Novita committed
1246
                                                                    // value={Number(tableMeta.rowData[10]) == 0 ? "0.0" : fixNumber(Number(Number(tableMeta.rowData[10]) * 100), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
                                                                    />
                                                                }
                                                            />
                                                            :
                                                            <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}
                                                                            suffix={'%'}
                                                                            // value={0}
Riri Novita's avatar
Riri Novita committed
1264
                                                                            value={fixNumber(Number(handleVariancePercent(tableMeta, 2, 3)), 1) == 0 ? "0.0" : fixNumber(Number(handleVariancePercent(tableMeta, 2, 3)), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1265 1266
                                                                        />
                                                                    }
faisalhamdi's avatar
faisalhamdi committed
1267
                                                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
1268 1269 1270
                                                            </div>
                                                    }
                                                </div>
faisalhamdi's avatar
faisalhamdi committed
1271 1272 1273
                                            </div>
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290
                                    <div className="column-2">
                                        <div className="grid grid-2x content-center">
                                            <div className="column-1">
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null :
                                                        this.state.get_for == 'view' ?
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1291
                                                                        value={fixNumber(Number(tableMeta.rowData[11]), 1) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[11]), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
                                                                    />
                                                                }
                                                            />
                                                            :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
1307
                                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleVariance(tableMeta, 3, 4)), 1) : Number(handleVariance(tableMeta, 3, 4)) == 0 ? "0.0" : Number(handleVariance(tableMeta, 3, 4))}
Deni Rinaldi's avatar
Deni Rinaldi committed
1308 1309
                                                                        />
                                                                    }
faisalhamdi's avatar
faisalhamdi committed
1310
                                                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
1311 1312 1313
                                                            </div>
                                                    }
                                                </div>
faisalhamdi's avatar
faisalhamdi committed
1314
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330
                                            <div className="column-2">
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null :
                                                        this.state.get_for == 'view' ?
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        suffix={'%'}
Riri Novita's avatar
Riri Novita committed
1331
                                                                        value={fixNumber(Number(Number(tableMeta.rowData[12])), 1) == 0 ? "0.0" : fixNumber(Number(Number(tableMeta.rowData[12])), 1)}
Riri Novita's avatar
Riri Novita committed
1332
                                                                        // value={Number(tableMeta.rowData[12]) == 0 ? "0.0" : fixNumber(Number(Number(tableMeta.rowData[12]) * 100), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349
                                                                    />
                                                                }
                                                            />
                                                            :
                                                            <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}
                                                                            suffix={'%'}
                                                                            // value={0}
Riri Novita's avatar
Riri Novita committed
1350
                                                                            value={fixNumber(Number(handleVariancePercent(tableMeta, 3, 5)), 1) == 0 ? "0.0" : fixNumber(Number(handleVariancePercent(tableMeta, 3, 5)), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1351 1352
                                                                        />
                                                                    }
faisalhamdi's avatar
faisalhamdi committed
1353
                                                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
1354 1355 1356
                                                            </div>
                                                    }
                                                </div>
faisalhamdi's avatar
faisalhamdi committed
1357 1358 1359 1360 1361
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1362 1363
                        )
                    }
faisalhamdi's avatar
faisalhamdi committed
1364
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400
            }, {
                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
                }
            }]
faisalhamdi's avatar
faisalhamdi committed
1401

faisalhamdi's avatar
faisalhamdi committed
1402
        const loadingComponent = (
faisalhamdi's avatar
faisalhamdi committed
1403
            <div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
faisalhamdi's avatar
faisalhamdi committed
1404 1405 1406 1407 1408 1409 1410 1411 1412
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );

faisalhamdi's avatar
faisalhamdi committed
1413 1414
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
faisalhamdi's avatar
faisalhamdi committed
1415
                {this.state.loading && loadingComponent}
faisalhamdi's avatar
faisalhamdi committed
1416 1417 1418
                <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>
faisalhamdi's avatar
faisalhamdi committed
1419 1420 1421 1422 1423
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
faisalhamdi's avatar
faisalhamdi committed
1424
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
faisalhamdi's avatar
faisalhamdi committed
1425 1426 1427 1428 1429 1430 1431 1432 1433
                    {this.state.visibleFAMMR ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Fixed Assets Movement</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>
d.arizona's avatar
d.arizona committed
1434
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
1435 1436 1437 1438 1439
                                        {this.props.defaultCurrency.id === 1 ?
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                            :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                        }
faisalhamdi's avatar
faisalhamdi committed
1440 1441
                                    </div>
                                    <div style={{ width: '50%' }}>
Riri Novita's avatar
Riri Novita committed
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
                                        {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">
faisalhamdi's avatar
faisalhamdi committed
1496 1497 1498 1499 1500 1501 1502
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1503
                                                        onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
1504 1505
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1506
                                                                    this.downloadAllData()
faisalhamdi's avatar
faisalhamdi committed
1507 1508 1509 1510 1511 1512
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
qorri_di's avatar
qorri_di committed
1513
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
Riri Novita's avatar
Riri Novita committed
1514 1515
                                            </div>
                                        }
faisalhamdi's avatar
faisalhamdi committed
1516 1517 1518
                                    </div>
                                </div>

faisalhamdi's avatar
faisalhamdi committed
1519
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
faisalhamdi's avatar
faisalhamdi committed
1520
                                    {!this.state.refresh && (
faisalhamdi's avatar
faisalhamdi committed
1521 1522 1523 1524 1525 1526 1527 1528
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
1529
                                    {this.state.get_for == 'view' && this.state.viewOnly && <div style={{ color: '#000', marginTop: 10, fontSize: 12 }}>(*) There may be discrepancies in amount due to rounding</div>}
faisalhamdi's avatar
faisalhamdi committed
1530
                                </div>
qorri_di's avatar
qorri_di committed
1531
                                <div style={{ display: 'flex' }}>
faisalhamdi's avatar
faisalhamdi committed
1532
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
qorri_di's avatar
qorri_di committed
1533
                                    <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
faisalhamdi's avatar
faisalhamdi committed
1534 1535
                                        {
                                            this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
qorri_di's avatar
qorri_di committed
1536 1537 1538 1539
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
qorri_di's avatar
qorri_di committed
1540
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
faisalhamdi's avatar
faisalhamdi committed
1541 1542 1543 1544

                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1545
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5 }}>Notes : {this.state.notesUpdate}</Typography>
faisalhamdi's avatar
faisalhamdi committed
1546
                            </div>
faisalhamdi's avatar
faisalhamdi committed
1547
                            <div className="grid grid-2x" style={{ padding: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
1548
                                <div className="col-1" style={{ paddingLeft: 0 }}>
faisalhamdi's avatar
faisalhamdi committed
1549 1550
                                    <button
                                        type="button"
faisalhamdi's avatar
faisalhamdi committed
1551 1552 1553 1554 1555
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
faisalhamdi's avatar
faisalhamdi committed
1556 1557 1558 1559
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
faisalhamdi's avatar
faisalhamdi committed
1560
                                            outline: 'none'
faisalhamdi's avatar
faisalhamdi committed
1561 1562
                                        }}
                                    >
faisalhamdi's avatar
faisalhamdi committed
1563 1564
                                        <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>
faisalhamdi's avatar
faisalhamdi committed
1565 1566
                                        </div>
                                    </button>
faisalhamdi's avatar
faisalhamdi committed
1567
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1568
                                {this.props.isApprover === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1569
                                    <div className="col-2"></div>
faisalhamdi's avatar
faisalhamdi committed
1570
                                    :
faisalhamdi's avatar
faisalhamdi committed
1571
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
rifkaki's avatar
rifkaki committed
1572
                                        {this.state.get_for == 'view' && this.state.viewOnly && <button
d.arizona's avatar
d.arizona committed
1573 1574 1575 1576 1577 1578
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
faisalhamdi's avatar
faisalhamdi committed
1579
                                                outline: 'none'
d.arizona's avatar
d.arizona committed
1580 1581
                                            }}
                                            onClick={() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1582
                                                this.setState({ loading: true, refresh: true }, () => {
d.arizona's avatar
d.arizona committed
1583
                                                    this.handleGetFor('edit')
Deni Rinaldi's avatar
Deni Rinaldi committed
1584 1585 1586
                                                    // setTimeout(() => {
                                                    //     this.setState({ loading: false })
                                                    // }, 100);
d.arizona's avatar
d.arizona committed
1587 1588 1589 1590 1591 1592 1593 1594
                                                })
                                            }}
                                        >
                                            <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
faisalhamdi's avatar
faisalhamdi committed
1595 1596 1597 1598 1599 1600 1601 1602 1603 1604
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
faisalhamdi's avatar
faisalhamdi committed
1605
                                                this.setState({ loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
1606
                                                    setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
1607 1608
                                                        // this.setState({ loading: false })
                                                        this.handleValidate()
faisalhamdi's avatar
faisalhamdi committed
1609 1610 1611 1612 1613 1614 1615
                                                    }, 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>
d.arizona's avatar
d.arizona committed
1616 1617
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
faisalhamdi's avatar
faisalhamdi committed
1618 1619 1620 1621
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1622
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
1623 1624 1625 1626 1627
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
1628
                                                this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1629
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
1630
                                                    :
1631 1632
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
1633 1634 1635 1636 1637 1638 1639
                                                            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>
d.arizona's avatar
d.arizona committed
1640 1641
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
faisalhamdi's avatar
faisalhamdi committed
1642
                                            type="button"
Riri Novita's avatar
Riri Novita committed
1643
                                            // disabled={this.state.buttonError}
faisalhamdi's avatar
faisalhamdi committed
1644 1645
                                            onClick={() =>
                                                this.state.buttonError ?
Riri Novita's avatar
Riri Novita committed
1646
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
1647
                                                    :
1648 1649
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
1650 1651 1652 1653
                                                            this.backToMonthlyReport('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1654
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
1655 1656 1657 1658 1659 1660 1661
                                                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>
d.arizona's avatar
d.arizona committed
1662
                                        </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1663
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
1664
                                }
faisalhamdi's avatar
faisalhamdi committed
1665 1666 1667 1668 1669 1670 1671
                            </div>
                        </Paper> :
                        <Paper style={{ paddingTop: 10 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Fixed Assets Movement</Typography>
                            </div>
                            <div style={{ padding: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
1672 1673
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
1674
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
1675 1676 1677 1678 1679
                                    {this.props.defaultCurrency.id === 1 ?
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                        :
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                    }
faisalhamdi's avatar
faisalhamdi committed
1680 1681
                                </div>
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
faisalhamdi's avatar
faisalhamdi committed
1682
                                    {!this.state.refresh && (
faisalhamdi's avatar
faisalhamdi committed
1683 1684 1685 1686 1687 1688 1689 1690 1691
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1692
                                <div className="grid grid-2x" style={{ marginTop: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
1693
                                    <div className="col-1" style={{ paddingLeft: 0 }}>
faisalhamdi's avatar
faisalhamdi committed
1694 1695
                                        <button
                                            type="button"
faisalhamdi's avatar
faisalhamdi committed
1696
                                            onClick={() => this.setState({ loading: true, visibleFAMMR: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
1697
                                                setTimeout(() => {
rifkaki's avatar
rifkaki committed
1698
                                                    this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714
                                                }, 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 || this.state.dataTable.length == 0 ? null :
                                        (this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === "draft" || this.props.status === 'submitted') ? */}
faisalhamdi's avatar
faisalhamdi committed
1715
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
1729 1730
                                                        // this.setState({ loading: false })
                                                        this.handleValidate()
faisalhamdi's avatar
faisalhamdi committed
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743
                                                    }, 100);
                                                })
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
                                        </button>
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1744
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
1745 1746 1747 1748 1749
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
1750
                                                this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1751
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
1752
                                                    :
1753 1754
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
1755 1756 1757 1758 1759
                                                            this.uploadFAMMR('draft')
                                                        })
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
1760
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
faisalhamdi's avatar
faisalhamdi committed
1761 1762 1763 1764
                                            </div>
                                        </button>
                                        <button
                                            type="button"
faisalhamdi's avatar
faisalhamdi committed
1765
                                            // disabled={this.state.buttonError}
faisalhamdi's avatar
faisalhamdi committed
1766 1767
                                            onClick={() =>
                                                this.state.buttonError ?
Riri Novita's avatar
Riri Novita committed
1768
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
1769
                                                    :
1770 1771
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
1772 1773 1774 1775
                                                            this.uploadFAMMR('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1776
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
1777 1778 1779 1780 1781
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
1782
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
faisalhamdi's avatar
faisalhamdi committed
1783 1784
                                            </div>
                                        </button>
Deni Rinaldi's avatar
Deni Rinaldi committed
1785
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
1786 1787 1788 1789
                                </div>
                            </div>
                        </Paper>
                    }
faisalhamdi's avatar
faisalhamdi committed
1790
                </div>
faisalhamdi's avatar
faisalhamdi committed
1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809
                {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>
1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826
                            <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("FIXED") && String(this.state.judul).includes("ASSETS") && String(this.state.judul).includes("MOVEMENT") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
                                            this.checkUpload() :
                                            this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                    }}
                                />
                            </div>
1827
                            <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data in <b>{this.props.defaultCurrency.id == 1 ? "IDR mn" : "thousand USD"}</b></div>
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
                        </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
                                        }}
1856
                                        onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0, loading: false })}
1857 1858 1859 1860 1861 1862 1863
                                    >
                                        <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>
faisalhamdi's avatar
faisalhamdi committed
1864 1865 1866
                        </div>
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
1867 1868 1869 1870
            </div>
        )
    }
}