LOVMR.js 115 KB
Newer Older
Riri Novita's avatar
Riri Novita committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
import React, { Component } from 'react';
import { createMuiTheme, FormControlLabel, MuiThemeProvider, Paper, TableCell, Tooltip, Typography, withStyles, Input, ThemeProvider, TextareaAutosize } from '@material-ui/core'
import MUIDataTable from 'mui-datatables';
import Images from '../../assets/Images';
import api from '../../api';
import NumberFormat from 'react-number-format';
import Constant from '../../library/Constant';
import { titleCase } from '../../library/Utils';
import { Autocomplete } from '@material-ui/lab';
import { PropagateLoader } from 'react-spinners';
import ReactTooltip from 'react-tooltip';
import { DatePicker } from '@material-ui/pickers';
import { format } from 'date-fns';
import { BorderStyle } from '@material-ui/icons';
import { includes } from 'ramda';
import Snackbar from '@material-ui/core/Snackbar';
import MuiAlert from '@material-ui/lab/Alert';
import { makeStyles } from '@material-ui/core/styles';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
import { fixNumber, roundMath } from "../../library/Utils";

function Alert(props) {
    return <MuiAlert elevation={6} variant="filled" {...props} />;
}

const useStyles = makeStyles((theme) => ({
    root: {
        width: '100%',
        '& > * + *': {
            marginTop: theme.spacing(2),
        },
    },
}));

const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);
Riri Novita's avatar
Riri Novita committed
44 45 46 47 48 49 50 51 52 53

const LightTooltipError = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(255, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);

Riri Novita's avatar
Riri Novita committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());
const options = ct.customOptionsFixedColumn();

const style = {
    position: "sticky",
    left: 0,
    background: "white",
    zIndex: 101,
};

const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100,
    top: 0
};

const theme = createMuiTheme({
    overrides: {
        // Style sheet name ⚛️
        MuiInputBase: {
            input: {
                color: '#5198ea',
                marginTop: -10,
                textAlign: 'center'
            }
        }
    },
});

const theme2 = createMuiTheme({
    overrides: {
        // Style sheet name ⚛️
        MuiInputBase: {
            input: {
                color: '#5198ea',
                textAlign: 'center'
            }
        }
    },
});

const theme3 = createMuiTheme({
    overrides: {
        // Style sheet name ⚛️
        MuiInputBase: {
            input: {
                color: '#black',
                textAlign: 'center'
            }
        }
    },
});

export default class LOV extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
            typeOfInvestmentList: [],
            currencyList: [],
            loading: false,
            dataTableRatio: [],
            currentDate: format(new Date(), 'yyyy-MM-dd'),
            totalOutStand: 0,
            diff: 0,
            perBS: 0,
            snekbar: false,
            snekbarMsg: '',
Riri Novita's avatar
Riri Novita committed
124
            visibleLOVMR: true,
Riri Novita's avatar
Riri Novita committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
            saveDraft: true,
            saveComp: true,
            get_for: 'view',
            updateBy: [],
            notes: "",
            viewOnly: true,
            dataDelete: [],
            saveTambahan: true,
            defaultCurrencyUpload: this.props.defaultCurrency,
            visibleAlertSave: false,
        }
        this.fileHandler = this.fileHandler.bind(this);
    }

    componentDidMount() {
Riri Novita's avatar
Riri Novita committed
140
        // this.getPerBS()
Riri Novita's avatar
Riri Novita committed
141 142 143 144 145 146 147 148 149
        this.getTypeOfInvesment()
        this.getListCurrency()
        this.getSubmission()
        this.getLatestUpdate()
        this.handleViewOnly()
    }

    componentDidUpdate(prevProps) {
        if (this.props.get_for !== prevProps.get_for) {
Riri Novita's avatar
Riri Novita committed
150
            // this.getPerBS()
Riri Novita's avatar
Riri Novita committed
151 152 153 154 155 156
            this.getTypeOfInvesment()
            this.getListCurrency()
            this.getSubmission()
            this.getLatestUpdate()
            this.handleViewOnly()
        }
Riri Novita's avatar
Riri Novita committed
157
        if (this.props.dataTablelov !== prevProps.dataTablelov) {
Riri Novita's avatar
Riri Novita committed
158
            let array = this.props.dataTablelov
Riri Novita's avatar
Riri Novita committed
159 160
            let datas = array[array.length - 1]
            console.log(datas);
Riri Novita's avatar
Riri Novita committed
161
            this.setState({ dataTable: this.props.dataTablelov, diff: datas[16], loanTotal: datas[17], perBS: datas[18] })
Riri Novita's avatar
Riri Novita committed
162 163
        }
        if (this.props.loadingChild !== prevProps.loadingChild) {
164
            this.setState({ loading: this.props.loadingChild })
Riri Novita's avatar
Riri Novita committed
165
        }
Riri Novita's avatar
Riri Novita committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
    }

    handleGetFor(type) {
        this.setState({ get_for: type }, () => {
            this.getPerBS()
            this.getTypeOfInvesment()
            this.getListCurrency()
            this.getSubmission()
            this.getLatestUpdate()
        })
    }

    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
        let checkPrevRev = false

        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }

        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
        }

        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }

        if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
            checkStatus = true
        } else {
            checkStatus = false
        }

        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
        // this.setState({viewOnly: true})
    }

    getItemHierarkiLOV() {
        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,
            "currency_id": this.props.defaultCurrency.id,
            "get_for": this.props.get_for
        }
        console.log(payload);
        api.create().getHierarkiMontlyReportInvesment(payload).then(response => {
            console.log(response);
            let dataTable = []
            if (response.data) {
                let res = response.data.data
Riri Novita's avatar
Riri Novita committed
229 230
                const handlePushChild = (item) => {
                    let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
Riri Novita's avatar
Riri Novita committed
231
                    let tgl = String(item.lov.placement_date).split('-')
Riri Novita's avatar
Riri Novita committed
232
                    if (indexIDzz === -1) {
Riri Novita's avatar
Riri Novita committed
233 234 235 236 237 238
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
Riri Novita's avatar
Riri Novita committed
239
                            String(item.lov.institution_name).includes('Total') ? null : item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.company_name,
Riri Novita's avatar
Riri Novita committed
240 241 242 243 244
                            item.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_name,
                            item.lov.type_of_investment === null ? null : item.lov.type_of_investment === "" ? null : { value: item.lov.type_of_investment },
                            item.lov.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
                            item.lov.placement_date == null || item.lov.placement_date == "" ? null : (item.lov.placement_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.lov.placement_date) : null),
                            item.lov.tenor === null || item.lov.tenor === "" ? "" : item.lov.tenor,
Riri Novita's avatar
Riri Novita committed
245
                            item.lov.expected_return === null || item.lov.expected_return === "" || item.lov.expected_return === "0.0" ? "0.00" : item.lov.expected_return,
Riri Novita's avatar
Riri Novita committed
246 247
                            // item.lov.currency === null ? null : item.lov.currency === "" ? null : { value: item.lov.currency },
                            item.lov.currency === null || item.lov.currency === "" ? "" : item.lov.currency,
Riri Novita's avatar
Riri Novita committed
248 249 250
                            item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
                            item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
                            item.lov.notes,
Riri Novita's avatar
Riri Novita committed
251 252 253
                            item.diff,
                            item.total_loan,
                            item.per_bs
Riri Novita's avatar
Riri Novita committed
254
                            // index
Riri Novita's avatar
Riri Novita committed
255 256
                        ])
                    }
Riri Novita's avatar
Riri Novita committed
257 258 259 260 261 262 263
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
Riri Novita's avatar
Riri Novita committed
264
                }
Riri Novita's avatar
Riri Novita committed
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
                res.map((item, index) => {
                    let tgl = String(item.lov.placement_date).split('-')
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        String(item.lov.institution_name).includes('Total') ? null : item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.company_name,
                        item.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_name,
                        item.lov.type_of_investment === null ? null : item.lov.type_of_investment === "" ? null : { value: item.lov.type_of_investment },
                        item.lov.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
                        item.lov.placement_date == null || item.lov.placement_date == "" ? null : (item.lov.placement_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.lov.placement_date) : null),
                        item.lov.tenor === null || item.lov.tenor === "" ? "" : item.lov.tenor,
                        item.lov.expected_return === null || item.lov.expected_return === "" ? "0.0" : item.lov.expected_return,
Riri Novita's avatar
Riri Novita committed
280 281
                        // item.lov.currency === null ? null : item.lov.currency === "" ? null : { value: item.lov.currency },
                        item.lov.currency === null || item.lov.currency === "" ? "" : item.lov.currency,
Riri Novita's avatar
Riri Novita committed
282 283 284
                        item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
                        item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
                        item.lov.notes,
Riri Novita's avatar
Riri Novita committed
285 286 287
                        item.diff,
                        item.total_loan,
                        item.per_bs
Riri Novita's avatar
Riri Novita committed
288 289 290 291 292 293 294 295 296 297
                        // index
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
Riri Novita's avatar
Riri Novita committed
298
                console.log(dataTable)
Riri Novita's avatar
Riri Novita committed
299 300
                let lastArray = dataTable[res.length - 1]
                console.log(lastArray);
Riri Novita's avatar
Riri Novita committed
301
                this.setState({ dataTable, diff: lastArray[16], loanTotal: lastArray[17], perBS: lastArray[18], loading: false, visibleLOVMR: true }, () => {
Riri Novita's avatar
Riri Novita committed
302
                    this.props.sendToParent(dataTable, lastArray, 'LOV')
Riri Novita's avatar
Riri Novita committed
303 304


Riri Novita's avatar
Riri Novita committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
                })
            }
        })
    }

    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
        }
        // console.log(payload)
        api.create().getLastestUpdateMR(payload).then(response => {
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        updateBy: response.data.data.detail === null ? [] : response.data.data.detail,
                        notes: response.data.data.notes_update === null ? "" : response.data.data.notes_update
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, typeAlert: '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);
                        }
                    })
                }
            } else {
                // console.log('brrrrrrrr')
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp.rows[0][0])
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                // console.log(isi);
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        let tgl = String(i[6]).split('-')
359
                        // console.log(tgl);
Riri Novita's avatar
Riri Novita committed
360 361 362 363 364 365 366 367 368 369 370
                        payload.push({
                            "item_report_id": i[1],
                            "company_name": this.props.company.company_name,
                            "institution_name": i[3],
                            "type_of_investment": i[4],
                            "remarks": i[5],
                            "placement_date": i[6] !== undefined ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : null,
                            "tenor": i[7],
                            "expected_return": i[8],
                            "currency": i[9],
                            "investment_amount_ori": i[10] !== undefined ? Number(i[10]) : i[10],
371
                            "investment_amount_cur": i[11] !== undefined ? Number(i[11]) : i[11],
Riri Novita's avatar
Riri Novita committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385
                            "notes": i[12],
                        })
                    }
                })
                let body = {
                    "monthly_report_id": this.props.monthlyReportId,
                    "company_id": this.props.company.company_id,
                    "periode": this.props.periode,
                    "report_id": this.props.report_id,
                    "status": 'submitted',
                    "months": this.props.month.month_id,
                    "lov": payload,
                    "per_bs": this.state.perBS,
                    "diff": this.state.diff,
Riri Novita's avatar
Riri Novita committed
386
                    "total_loan": this.state.loanTotal
Riri Novita's avatar
Riri Novita committed
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
                }
                console.log(body)
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
            }
        });
    }


    deleteReport() {
        let payload = { "item_report_id": this.state.dataDelete, "periode": this.props.periode, "months": this.props.month.month_id }

        if (this.state.dataDelete.length > 0) {
            api.create().deleteAllItemReportLOCF(payload).then((response) => {
                console.log(response)
            })
        }
    }

    checkUpload() {
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        console.log(payload);
        let dataDelete = []
        api.create().getIdDeleteFromExcelLOV(payload).then((response) => {
            console.log(response)
        })

        api.create().checkUploadMonthlyReportLOV(payload).then(response => {
            console.log(response)
418
            let dataTable = []
Riri Novita's avatar
Riri Novita committed
419
            if (response.data) {
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, loading: true, visibleLOVMR: false })
                    let res = response.data.data
                    const handlePushChild = (item) => {
                        let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                        let tgl = String(item.lov.placement_date).split('-')
                        if (indexIDzz === -1) {
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                String(item.lov.institution_name).includes('Total') ? null : item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.company_name,
                                item.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_name,
                                item.lov.type_of_investment === null ? null : item.lov.type_of_investment === "" ? null : { value: item.lov.type_of_investment },
                                item.lov.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
                                item.lov.placement_date == null || item.lov.placement_date == "" ? null : (item.lov.placement_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.lov.placement_date) : null),
                                item.lov.tenor === null || item.lov.tenor === "" ? "" : item.lov.tenor,
                                item.lov.expected_return === null || item.lov.expected_return === "" ? "0.0" : item.lov.expected_return,
Riri Novita's avatar
Riri Novita committed
440 441
                                // item.lov.currency === null ? null : item.lov.currency === "" ? null : { value: item.lov.currency },
                                item.lov.currency === null || item.lov.currency === "" ? "" : item.lov.currency,
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
                                item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
                                item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
                                item.lov.notes,
                                item.diff,
                                item.total_loan,
                                item.per_bs
                                // index
                            ])
                        }
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
                        }
                    }
                    res.map((item, index) => {
                        let tgl = String(item.lov.placement_date).split('-')
Riri Novita's avatar
Riri Novita committed
461 462 463 464 465 466 467 468 469 470 471 472 473
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            String(item.lov.institution_name).includes('Total') ? null : item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.company_name,
                            item.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_name,
                            item.lov.type_of_investment === null ? null : item.lov.type_of_investment === "" ? null : { value: item.lov.type_of_investment },
                            item.lov.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
                            item.lov.placement_date == null || item.lov.placement_date == "" ? null : (item.lov.placement_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.lov.placement_date) : null),
                            item.lov.tenor === null || item.lov.tenor === "" ? "" : item.lov.tenor,
                            item.lov.expected_return === null || item.lov.expected_return === "" ? "0.0" : item.lov.expected_return,
Riri Novita's avatar
Riri Novita committed
474 475
                            // item.lov.currency === null ? null : item.lov.currency === "" ? null : { value: item.lov.currency },
                            item.lov.currency === null || item.lov.currency === "" ? "" : item.lov.currency,
Riri Novita's avatar
Riri Novita committed
476 477 478 479 480 481 482 483
                            item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
                            item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
                            item.lov.notes,
                            item.diff,
                            item.total_loan,
                            item.per_bs
                            // index
                        ])
484 485 486 487 488 489
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
Riri Novita's avatar
Riri Novita committed
490
                        }
491 492 493
                    })
                    console.log(dataTable)
                    let lastArray = dataTable[dataTable.length - 1]
Riri Novita's avatar
Riri Novita committed
494
                    this.setState({ dataTable, diff: lastArray[16], loanTotal: lastArray[17], perBS: lastArray[18], dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => {
Riri Novita's avatar
Riri Novita committed
495
                        this.props.sendToParent(dataTable, lastArray, 'LOV', 'upload', this.state.visibleLOVMR)
Riri Novita's avatar
Riri Novita committed
496
                    })
Riri Novita's avatar
Riri Novita committed
497
                    console.log(this.state.visibleLOVMR);
Riri Novita's avatar
Riri Novita committed
498
                } else {
499 500 501 502 503 504 505
                    this.setState({ alert: true, messageAlert: response.data.message, typeAlert: '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);
                        }
Riri Novita's avatar
Riri Novita committed
506 507 508 509 510 511
                    })
                }
            }
        })
    }

512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
    // uploadLOCF(type) {
    //     let data = []
    //     let error = false
    //     this.deleteReport()
    //     this.state.dataTable.map(i => {
    //         if (i[0] == 3) {
    //             if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "") {
    //                 error = true
    //             }

    //             if (i[7].value == 'Others' && i[18] == '') {
    //                 error = true
    //             }
    //             let tgl = String(i[9]).split('-')
    //             let checkUndifined = tgl.findIndex((val) => val == undefined)
    //             if (this.props.defaultCurrency.id == 2) {
    //                 data.push({
    //                     "item_report_id": i[1],
    //                     "borrower_comp_name": i[5],
    //                     "bank_name": i[6] == null ? [6] : i[6].value,
    //                     "type_of_credit": i[7] == null ? i[7] : i[7].value,
    //                     "remarks": i[8],
    //                     // "loan_maturity_date": i[9],
    //                     "loan_maturity_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
    //                     // "loan_maturity_date":  i[9] !== undefined || i[9] !== "null" || i[9] !== null? (String(tgl[2]).length <= 2? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])) : "",
    //                     "interest": i[10] == "" ? "0.00" : i[10],
    //                     "currency": i[11],
    //                     "loan_plafond_amount_ori": Number(i[12]) == "" ? "0.0" : Number(i[12]),
    //                     "loan_plafond_amount_idr": Number(i[13]) == "" ? "0.0" : Number(i[13]),
    //                     "out_loan_ki_amount_ori": Number(i[14]) == "" ? "0.0" : Number(i[14]),
    //                     "out_loan_ki_amount_idr": Number(i[15]) == "" ? "0.0" : Number(i[15]),
    //                     "out_loan_kmk_amount_ori": Number(i[16]) == "" ? "0.0" : Number(i[16]),
    //                     "out_loan_kmk_amount_idr": Number(i[17]) == "" ? "0.0" : Number(i[17]),
    //                     // "mtd_vs_previous_month": i[18],
    //                     "out_loan_other_type": i[18],
    //                     "out_loan_other_amount_ori": Number(i[19]) == "" ? "0.0" : Number(i[19]),
    //                     "out_loan_other_amount_idr": Number(i[20]) == "" ? "0.0" : Number(i[20]),
    //                     "total_out_loan_ori": Number(i[21]) == "" ? "0.0" : Number(i[21]),
    //                     "total_out_loan_idr": Number(i[22]) == "" ? "0.0" : Number(i[22]),
    //                     "remaining_plafond_ori": Number(i[23]) == "" ? "0.0" : Number(i[23]),
    //                     "remaining_plafond_idr": Number(i[24]) == "" ? "0.0" : Number(i[24]),
    //                     "current_ratio_financial": Number(i[25]) == "" ? "0.00" : Number(i[25]),
    //                     "current_ratio_current": Number(i[26]) == "" ? "0.00" : Number(i[26]),
    //                     "der_financial": Number(i[27]) == "" ? "0.00" : Number(i[27]),
    //                     "der_current": Number(i[28]) == "" ? "0.00" : Number(i[28]),
    //                     "debt_to_ebitda_financial": Number(i[29]) == "" ? "0.00" : Number(i[29]),
    //                     "debt_to_ebitda_current": Number(i[30]) == "" ? "0.00" : Number(i[30]),
    //                     "ebitda_to_interest_financial": Number(i[31]) == "" ? "0.00" : Number(i[31]),
    //                     "ebitda_to_interest_current": Number(i[32]) == "" ? "0.00" : Number(i[32]),
    //                     "other_ratio1_ratio_name": i[33],
    //                     "other_ratio1_financial": Number(i[34]) == "" ? "0.00" : Number(i[34]),
    //                     "other_ratio1_current": Number(i[35]) == "" ? "0.00" : Number(i[35]),
    //                     "other_ratio2_ratio_name": i[36],
    //                     "other_ratio2_financial": Number(i[37]) == "" ? "0.00" : Number(i[37]),
    //                     "other_ratio2_current": Number(i[38]) == "" ? "0.00" : Number(i[38]),
    //                     "other_ratio3_ratio_name": i[39],
    //                     "other_ratio3_financial": Number(i[40]) == "" ? "0.00" : Number(i[40]),
    //                     "other_ratio3_current": Number(i[41]) == "" ? "0.00" : Number(i[41]),
    //                     "other_ratio4_ratio_name": i[42],
    //                     "other_ratio4_financial": Number(i[43]) == "" ? "0.00" : Number(i[43]),
    //                     "other_ratio4_current": Number(i[44]) == "" ? "0.00" : Number(i[44]),
    //                     "notes": i[45],
    //                 })
    //             } else {
    //                 data.push({
    //                     "item_report_id": i[1],
    //                     "borrower_comp_name": i[5],
    //                     "bank_name": i[6] == null ? [6] : i[6].value,
    //                     "type_of_credit": i[7] == null ? i[7] : i[7].value,
    //                     "remarks": i[8],
    //                     // "loan_maturity_date": i[9],
    //                     "loan_maturity_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
    //                     // "loan_maturity_date":  i[9] !== undefined || i[9] !== "null" || i[9] !== null? (String(tgl[2]).length <= 2? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])) : "",
    //                     "interest": i[10] == "" ? "0.00" : i[10],
    //                     "currency": i[11],
    //                     "loan_plafond_amount_ori": fixNumber(Number(i[12]), 1) == "" ? "0.0" : fixNumber(Number(i[12]), 1),
    //                     "loan_plafond_amount_idr": fixNumber(Number(i[13]), 1) == "" ? "0.0" : fixNumber(Number(i[13]), 1),
    //                     "out_loan_ki_amount_ori": fixNumber(Number(i[14]), 1) == "" ? "0.0" : fixNumber(Number(i[14]), 1),
    //                     "out_loan_ki_amount_idr": fixNumber(Number(i[15]), 1) == "" ? "0.0" : fixNumber(Number(i[15]), 1),
    //                     "out_loan_kmk_amount_ori": fixNumber(Number(i[16]), 1) == "" ? "0.0" : fixNumber(Number(i[16]), 1),
    //                     "out_loan_kmk_amount_idr": fixNumber(Number(i[17]), 1) == "" ? "0.0" : fixNumber(Number(i[17]), 1),
    //                     // "mtd_vs_previous_month": i[18],
    //                     "out_loan_other_type": i[18],
    //                     "out_loan_other_amount_ori": fixNumber(Number(i[19]), 1) == "" ? "0.0" : fixNumber(Number(i[19]), 1),
    //                     "out_loan_other_amount_idr": fixNumber(Number(i[20]), 1) == "" ? "0.0" : fixNumber(Number(i[20]), 1),
    //                     "total_out_loan_ori": fixNumber(Number(i[21]), 1) == "" ? "0.0" : fixNumber(Number(i[21]), 1),
    //                     "total_out_loan_idr": fixNumber(Number(i[22]), 1) == "" ? "0.0" : fixNumber(Number(i[22]), 1),
    //                     "remaining_plafond_ori": fixNumber(Number(i[23]), 1) == "" ? "0.0" : fixNumber(Number(i[23]), 1),
    //                     "remaining_plafond_idr": fixNumber(Number(i[24]), 1) == "" ? "0.0" : fixNumber(Number(i[24]), 1),
    //                     "current_ratio_financial": fixNumber(Number(i[25]), 2) == "" ? "0.00" : fixNumber(Number(i[25]), 2),
    //                     "current_ratio_current": fixNumber(Number(i[26]), 2) == "" ? "0.00" : fixNumber(Number(i[26]), 2),
    //                     "der_financial": fixNumber(Number(i[27]), 2) == "" ? "0.00" : fixNumber(Number(i[27]), 2),
    //                     "der_current": fixNumber(Number(i[28]), 2) == "" ? "0.00" : fixNumber(Number(i[28]), 2),
    //                     "debt_to_ebitda_financial": fixNumber(Number(i[29]), 2) == "" ? "0.00" : fixNumber(Number(i[29]), 2),
    //                     "debt_to_ebitda_current": fixNumber(Number(i[30]), 2) == "" ? "0.00" : fixNumber(Number(i[30]), 2),
    //                     "ebitda_to_interest_financial": fixNumber(Number(i[31]), 2) == "" ? "0.00" : fixNumber(Number(i[31]), 2),
    //                     "ebitda_to_interest_current": fixNumber(Number(i[32]), 2) == "" ? "0.00" : fixNumber(Number(i[32]), 2),
    //                     "other_ratio1_ratio_name": i[33],
    //                     "other_ratio1_financial": fixNumber(Number(i[34]), 2) == "" ? "0.00" : fixNumber(Number(i[34]), 2),
    //                     "other_ratio1_current": fixNumber(Number(i[35]), 2) == "" ? "0.00" : fixNumber(Number(i[35]), 2),
    //                     "other_ratio2_ratio_name": i[36],
    //                     "other_ratio2_financial": fixNumber(Number(i[37]), 2) == "" ? "0.00" : fixNumber(Number(i[37]), 2),
    //                     "other_ratio2_current": fixNumber(Number(i[38]), 2) == "" ? "0.00" : fixNumber(Number(i[38]), 2),
    //                     "other_ratio3_ratio_name": i[39],
    //                     "other_ratio3_financial": fixNumber(Number(i[40]), 2) == "" ? "0.00" : fixNumber(Number(i[40]), 2),
    //                     "other_ratio3_current": fixNumber(Number(i[41]), 2) == "" ? "0.00" : fixNumber(Number(i[41]), 2),
    //                     "other_ratio4_ratio_name": i[42],
    //                     "other_ratio4_financial": fixNumber(Number(i[43]), 2) == "" ? "0.00" : fixNumber(Number(i[43]), 2),
    //                     "other_ratio4_current": fixNumber(Number(i[44]), 2) == "" ? "0.00" : fixNumber(Number(i[44]), 2),
    //                     "notes": i[45],
    //                 })
    //             }

    //         }
    //     })
    //     let body = {
    //         "monthly_report_id": this.props.monthlyReportId,
    //         "company_id": this.props.company.company_id,
    //         "periode": this.props.periode,
    //         "report_id": this.props.report_id,
    //         "status": type,
    //         "months": this.props.month.month_id,
    //         "currency_id": this.props.defaultCurrency.id,
    //         "locf": data,
    //         "per_bs": this.state.perBS,
    //         "diff": this.state.diff,
    //         "total_loan": this.state.perBS
    //     }
    //     console.log(JSON.stringify(body));
    //     if (error && type == 'submitted') {
    //         this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
    //     } else {
    //         api.create('UPLOAD').uploadMonthlyReportLOCF(body).then(response => {
    //             console.log(response);
    //             if (response.data) {
    //                 if (response.ok) {
    //                     if (response.data.status === "success") {
    //                         this.props.saveToMonthlyReport('LOCF')
    //                         // this.props.onClickClose()
    //                         // this.props.getReport()
    //                     } else {
    //                         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 }, () => {
    //                                 if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
    //                                     setTimeout(() => {
    //                                         localStorage.removeItem(Constant.TOKEN)
    //                                         window.location.reload();
    //                                     }, 1000);
    //                                 }
    //                             })
    //                         }
    //                         // alert(response.data.status)
    //                     }
    //                 } else {
    //                     this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
    //                 }
    //             } else {
    //                 this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
    //             }
    //             this.setState({ handleDoubleClick: 0 })
    //         })
    //     }
    // }

Riri Novita's avatar
Riri Novita committed
678
    getListCurrency() {
Riri Novita's avatar
Riri Novita committed
679
        // this.setState({ dataLoaded: false })
Riri Novita's avatar
Riri Novita committed
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721
        api.create().getDataCurrency().then(response => {
            console.log(response)
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let inpuCurrency = []

                        data.map((item) => {
                            inpuCurrency.push({
                                value: `${item.currency_name}`
                            })
                        })
                        let defaultProps = {
                            options: inpuCurrency,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
                        // // // console.log(defaultProps)
                        this.setState({ currencyList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

    getTypeOfInvesment() {
        let body = {
            group: 'INVESTMENT',
            company_id: this.props.company.company_id,
Riri Novita's avatar
Riri Novita committed
722
            type: 'TYPE_OF_INVESTMENT',
Riri Novita's avatar
Riri Novita committed
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
            currency_id: this.props.defaultCurrency.id,
        }
        this.setState({ dataLoaded: false })
        api.create().getAllSettingByType(body).then(response => {
            console.log(response)
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        // // // console.log(data)
                        let inpuTypeOfInvestment = []

                        data.map((item) => {
                            inpuTypeOfInvestment.push({
                                value: `${item.value}`
                            })
                        })
                        console.log(data);
                        let defaultProps = {
                            options: inpuTypeOfInvestment,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
                        // // // console.log(defaultProps)
                        this.setState({ typeOfInvestmentList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

    downloadTemplate = async () => {
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
768
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/lov/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}`
Riri Novita's avatar
Riri Novita committed
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
        )
        res = await res.blob()
        // console.log(this.props.report_id)
        // console.log(this.props.company.company_id)
        // console.log(this.props.periode)
        // console.log(this.props.month.month_id)
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Template Monthly Report List of Investment.xlsx';
            a.click();
        }
    }

    async downloadAllData() {
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/monthly_report/export_monthly_report?monthly_report_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
        let urls = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/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}`
        // console.log(url);
        // console.log(urls);
        let res = await fetch(
            this.props.monthlyReportId == null ? url : urls
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Monthly Report List of Credit Facilities.xlsx';
            a.click();
        }
    }

    getSubmission() {
        this.setState({ loading: true })
        let payload = {
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "is_approver": true
        }
        api.create().getSubmission(payload).then(response => {
            // console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        submissionID: response.data.data.submission_id,
                        lastRevision: response.data.data.last_revision,
                    }, () => {
                        this.getItemHierarkiLOV()
                    })
                } else {
                    this.setState({ submissionID: null, loading: false })
                }
            }
        })
    }


    render() {
        let dataTable2 = this.state.dataTable
        let loading = this.state.loading
        let dataTampungBank = []
        let indexNyasar = false
        let totalLoan = 0

        // const formatSeparator = (num) => {
        //    return String(num).replace(/(?<!\..*)(\d)(?=(?:\d{3})+(?:\.|$))/g, '$1,')

        // return num
        // }

        const handleAction = (typeReport, tableMeta, typeButton) => {
            if (typeReport == 3) {
                if (dataTable2.length == 2) {
                    if (typeButton == 'add') {
                        return true
                    } else {
                        return false
                    }
                } else {
                    return true
                }
            } else {
                return false
            }
        }

        const handleChange = (value, tableMeta, column, typeChange, typeDrop) => {
Riri Novita's avatar
Riri Novita committed
858
            console.log(column, value);
Riri Novita's avatar
Riri Novita committed
859 860 861 862 863 864 865 866
            let val = ''
            if (typeChange == 'date') {
                dataTable2[tableMeta.rowIndex][column] = format(value, 'yyyy-MM-dd')
                this.setState({ loading: true }, () => {
                    this.setState({ loading: false })
                })
            } else {
                dataTable2[tableMeta.rowIndex][column] = value
Riri Novita's avatar
Riri Novita committed
867 868 869 870 871
                if (column != 6 && column != 7 && column != 8 && column != 10 && column != 12 && column != 15) {
                    val = String(value).split(",").join("")
                    val = this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 2) : Number(val)
                } else {
                    val = String(value).split(",").join("")
Riri Novita's avatar
Riri Novita committed
872

Riri Novita's avatar
Riri Novita committed
873
                }
Riri Novita's avatar
Riri Novita committed
874

Riri Novita's avatar
Riri Novita committed
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900
                if (value.value !== undefined) {
                    this.setState({ loading: true })
                    if (value.value == 'Government bonds') {
                        this.setState({ loading: false })
                    } else if (value.value == 'Stocks') {
                        this.setState({ loading: false })
                    } else if (value.value == 'Mutual funds') {
                        this.setState({ loading: false })
                    } else if (value.value == 'Investment in associate') {
                        this.setState({ loading: false })
                    } else if (value.value == 'Investment in joint venture') {
                        this.setState({ loading: false })
                    } else if (value.value == 'Investment in subsidiary') {
                        this.setState({ loading: false })
                    } else if (value.value == 'Time deposit') {
                        this.setState({ loading: false })
                    } else if (value.value == 'Corporate bonds') {
                        this.setState({ loading: false })
                    } else if (value.value == 'Others') {
                        this.setState({ loading: false })
                    } else if (value.value == 'N/A') {
                        this.setState({ loading: false })
                    }
                    this.setState({ loading: false })
                    dataTable2[tableMeta.rowIndex][column] = value
                } else {
Riri Novita's avatar
Riri Novita committed
901
                    dataTable2[tableMeta.rowIndex][column] = val
Riri Novita's avatar
Riri Novita committed
902
                }
Riri Novita's avatar
Riri Novita committed
903
            }
Riri Novita's avatar
Riri Novita committed
904 905 906
            console.log(dataTable2[tableMeta.rowIndex][column]);
            console.log(value)
            console.log(String(value).split(",").join(""))
Riri Novita's avatar
Riri Novita committed
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980
        }

        const handleValueDropDown = (value, type, tableMeta) => {
            let data = type == 'typeOfInvestmentList' ? this.state.typeOfInvestmentList.options : this.state.currencyList.options
            let index = 0
            if (type == 'typeOfInvestmentList' && dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] != null && dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] != "") {
                indexNyasar = true
            }
            if (value == null) {
                index = -1
            } else {
                if (type == 'currencyList') {
                    index = data.findIndex((val) => String(val.currency_name) == String(value.currency_name))
                } else {
                    index = data.findIndex((val) => String(val.value) == String(value.value))
                }
            }
            if (index == -1) {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = null
                return null
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
                return value
            }
            // console.log(value);
        }

        const handleFormulaHardcode = (value, tableMeta, column) => {
            let valuez = 0
            if (tableMeta.rowData[0] == 8) {
                dataTable2.map((item, index) => {
                    if (item[6].value.includes(String(tableMeta.rowData[6].value).substr(6, tableMeta.rowData[6].length)) && item[0] != 8) {
                        valuez += Number(item[column])
                    }
                })
            } else {
                dataTable2.map((item, index) => {
                    if (item[0] == 8) {
                        valuez += Number(item[column])
                    }
                })
            }
            dataTable2[tableMeta.rowIndex][column] = valuez
            return valuez
        }

        const handleTambah = (data, rowIndex) => {
            // // console.log(dataTable2)
            let newData = []
            let indexxx = 0
            console.log(dataTable2);
            dataTable2.map((item, index) => {
                indexxx = index
                if (item[6] == "Grand Total") {
                    item[16] = 999999
                } else {
                    item[16] = indexxx
                }
                newData.push(item)
                if (index == rowIndex) {
                    indexxx = index + 1
                    newData.push([
                        3,
                        "",
                        "",
                        "",
                        "",
                        this.props.company.company_name,
                        "",
                        null,
                        "",
                        null,
                        "",
                        "",
Riri Novita's avatar
Riri Novita committed
981
                        "",
Riri Novita's avatar
Riri Novita committed
982 983 984 985 986 987 988 989 990
                        "0",
                        "",
                        "",
                        indexxx],
                    )

                }
            })
            dataTable2 = newData.sort((a, b) => a[16] - b[16])
Riri Novita's avatar
Riri Novita committed
991
            let lastArray = dataTable2[dataTable2.length - 1]
Riri Novita's avatar
Riri Novita committed
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004
            if (this.state.visibleLOVMR == false) {
                if (this.props.dataTablelov) {
                    if (this.props.dataTablelov.length !== dataTable2.length) {
                        this.setState({ updateData: true })
                    }
                }
            } else {
                if (this.props.dataTablelov) {
                    if (this.props.dataTablelov.length !== dataTable2.length) {
                        this.setState({ updateData: true })
                    }
                }
            }
Riri Novita's avatar
Riri Novita committed
1005 1006 1007
            this.setState({ dataTable: dataTable2 }, () => {
                setTimeout(() => {
                    this.setState({ loading: false })
Riri Novita's avatar
Riri Novita committed
1008
                    this.props.sendToParent(dataTable2, lastArray, 'LOV', 'tambah', this.state.visibleLOVMR, this.state.updateData)
Riri Novita's avatar
Riri Novita committed
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
                }, 500)
            })
        }

        const handleDelete = (index) => {
            let dataDelete = this.state.dataDelete
            let berapaInput = 0
            dataTable2.map((items, indexs) => {
                if (items[0] == 3) {
                    berapaInput += 1
                }
            })

            dataDelete.push(dataTable2[index][1])

            let prevData = dataTable2[index - 1] == undefined ? null : dataTable2[index - 1][6]
            let currentData = dataTable2[index][6]
            let nextData = dataTable2[index + 1] == undefined ? null : dataTable2[index + 1][6]

            if (nextData == null) {
                dataTable2.splice(index, 1)
Riri Novita's avatar
Riri Novita committed
1030
            } else if (nextData.includes('Total')) {
Riri Novita's avatar
Riri Novita committed
1031 1032
                if (prevData !== null && currentData == null) {
                    dataTable2.splice(index, 1)
Riri Novita's avatar
Riri Novita committed
1033
                } else if (prevData !== null && prevData == currentData) {
Riri Novita's avatar
Riri Novita committed
1034 1035 1036
                    dataTable2.splice(index, 1)
                } else if (dataTable2.length > 3) {
                    if (prevData == null) {
Riri Novita's avatar
Riri Novita committed
1037
                        if (nextData.includes('Grand')) {
Riri Novita's avatar
Riri Novita committed
1038 1039 1040 1041 1042 1043 1044 1045 1046
                            dataTable2.splice(index, 1)
                        } else {
                            dataTable2.splice(index, 2)
                        }
                    } else {
                        dataTable2.splice(index, 2)
                    }
                } else if (dataTable2.length == 3) {
                    if (prevData == null) {
Riri Novita's avatar
Riri Novita committed
1047
                        if (nextData.includes('Grand')) {
Riri Novita's avatar
Riri Novita committed
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
                            dataTable2.splice(index, 1)
                        } else {
                            dataTable2.splice(index, 3)
                            dataTable2.push(
                                [3, "", "", "", "", this.props.company.company_name, "", null, "", null, "0.0", "0.0", "", "", "", "", 0],
                                [9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999],
                            )
                        }
                    } else {
                        dataTable2.splice(index, 1)
                    }
                }
            } else {
                dataTable2.splice(index, 1)
            }

            this.setState({ dataTable: dataTable2, dataDelete }, () => {
                setTimeout(() => {
                    console.log(this.state.dataDelete)
                    this.setState({ loading: false })
                }, 100)
            })
        }

Riri Novita's avatar
Riri Novita committed
1072
        let columns = [
Riri Novita's avatar
Riri Novita committed
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
            {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    filter: false,
                    display: this.props.get_for == 'view' ? false : true,
                    customHeadRender: (columnMeta) => (
                        <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 99, backgroundColor: '#dbdbdb' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ display: 'flex' }}>
                                {handleAction(tableMeta.rowData[0], tableMeta, 'add') && <span>
                                    <LightTooltip title={'Add'} arrow>
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                            }}
                                            // onClick={() => // // console.log(tableMeta.rowData[1])}
                                            onClick={() => {
                                                this.setState({ loading: true })
                                                handleTambah(tableMeta.rowData[1], tableMeta.rowIndex)
                                            }}
                                        >
                                            <img src={Images.add} />
                                        </button>
                                    </LightTooltip>
                                </span>}
                                {handleAction(tableMeta.rowData[0], tableMeta, 'delete') && <span>
                                    <LightTooltip title={'Delete'} arrow>
                                        <button
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                marginLeft: 5
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true })
                                                handleDelete(tableMeta.rowIndex)
                                            }}
                                        >
                                            <img src={Images.delete} style={{ width: 37, height: 37 }} />
                                        </button>
                                    </LightTooltip>
                                </span>}
                            </div >
                        );
                    }
                }
            }, {
Riri Novita's avatar
Riri Novita committed
1148
                name: "Company",
Riri Novita's avatar
Riri Novita committed
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'center', width: 90 }}>
                                {tableMeta.rowData[0] === 4 ?
                                    null :
                                    val
                                }
                            </div>
                        )
                    }
                }
            }, {
                name: "Institution Name",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
Riri Novita's avatar
Riri Novita committed
1178
                            <div style={{ display: 'flex', justifyContent: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1179
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] == 8 ?
Riri Novita's avatar
Riri Novita committed
1180 1181
                                    <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{val.value}</Typography>
                                    :
Riri Novita's avatar
Riri Novita committed
1182 1183 1184 1185 1186 1187 1188
                                    tableMeta.rowData[0] == 9 ?
                                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{val}</Typography>
                                        :
                                        <div style={{ padding: 0, margin: 0 }}>
                                            <textarea disabled={this.props.get_for == 'view'} style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: tableMeta.rowData[6] == '' && this.props.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" defaultValue={tableMeta.rowData[6]}
                                                onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} />
                                        </div>
Riri Novita's avatar
Riri Novita committed
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243
                                }
                            </div>
                        )
                    }
                }
            }, {
                name: "Type Of Investment",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right', width: 90 }}>
                                {tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 || tableMeta.rowData[0] === 4 ?
                                    null :
                                    <Autocomplete
                                        {...this.state.typeOfInvestmentList}
                                        id="typeOfInvestmentList"
                                        onChange={(event, newInputValue) => handleChange(newInputValue, tableMeta, tableMeta.columnIndex)}
                                        debug
                                        value={handleValueDropDown(val, 'typeOfInvestmentList', tableMeta)}
                                        disableClearable
                                        disabled={this.props.get_for == 'view'}
                                        // disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
                                        style={{ padding: 0, margin: 0 }}
                                        renderInput={(params) =>
                                            <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
                                                <textarea style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: tableMeta.rowData[7] == null && this.props.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" {...params.inputProps} />
                                            </div>
                                        }
                                    />
                                }
                            </div>
                        )
                    }
                }
            }, {
                name: "Remarks",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'left', width: 90 }}>
                                {tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
                                    null :
                                    <div style={{ padding: 0, margin: 0 }}>
Riri Novita's avatar
Riri Novita committed
1244
                                        <textarea disabled={this.props.get_for == 'view'} style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: this.props.get_for == 'view' ? 'white' : tableMeta.rowData[8] !== '' ? 'white' : tableMeta.rowData[7] == null ? '#ffac99' : (tableMeta.rowData[8] == '' && tableMeta.rowData[7].value == 'Time deposit' || tableMeta.rowData[7].value == 'N/A') ? 'white' : '#ffac99' }} type="text" defaultValue={tableMeta.rowData[8]}
Riri Novita's avatar
Riri Novita committed
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320
                                            onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} />
                                    </div>
                                }

                            </div>
                        )
                    }
                }
            }, {
                name: "Placement Date",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right', width: 90 }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] == 8 || tableMeta.rowData[0] == 9 ?
                                    null :
                                    <DatePicker
                                        margin="normal"
                                        id="loanMatureDate"
                                        // label="Valid To"
                                        format="dd-MM-yyyy"
                                        value={val}
                                        disabled={this.props.get_for == 'view'}
                                        onChange={(e) => handleChange(e, tableMeta, tableMeta.columnIndex, 'date')}
                                        // minDate={this.state.startDate}
                                        KeyboardButtonProps={{
                                            'aria-label': 'change date',
                                        }}
                                        inputProps={{
                                            style: {
                                                marginTop: -20,
                                                textAlign: 'center',
                                                fontSize: 11,
                                                height: 20,
                                                paddingBottom: 11,
                                                fontFamily: 'Nunito Sans, sans-serif',
                                                color: this.props.get_for == 'view' ? "black" : '#5198ea',
                                                backgroundColor: (tableMeta.rowData[9] == null || tableMeta.rowData[9] == '') && this.props.get_for == 'edit' ? '#ffac99' : 'white'
                                            }
                                        }}
                                        InputLabelProps={{
                                            style: {
                                                fontSize: 11,
                                                color: '#5198ea',
                                                fontFamily: 'Nunito Sans, sans-serif',
                                            }
                                        }}

                                        style={{ padding: 0, margin: 0, width: '100%' }}
                                    />
                                }
                            </div>
                        )
                    }
                }
            }, {
                name: "Tenor",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'left', width: 90 }}>
                                {tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
                                    null :
                                    <div style={{ padding: 0, margin: 0 }}>
Riri Novita's avatar
Riri Novita committed
1321 1322 1323 1324 1325 1326
                                        {/* {tableMeta.rowData[10] == '' || tableMeta.rowData[10] == 0.0 || tableMeta.rowData[10] == 0 && this.props.get_for == 'edit' ?
                                            <LightTooltipError title={"Data belum sesuai"} arrow>
                                                <textarea disabled={this.props.get_for == 'view'} style={{ fontSize: 12, borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: tableMeta.rowData[10] == '' || tableMeta.rowData[10] == 0.0 || tableMeta.rowData[10] == 0 && this.props.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" defaultValue={tableMeta.rowData[10]}
                                                    onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} />
                                            </LightTooltipError>
                                            : */}
Riri Novita's avatar
Riri Novita committed
1327
                                        <textarea disabled={this.props.get_for == 'view'} style={{ fontSize: 12, borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: (this.props.get_for == 'edit' && tableMeta.rowData[10] == '' )|| (this.props.get_for == 'edit' && tableMeta.rowData[10] == 0.0) || (this.props.get_for == 'edit' && tableMeta.rowData[10] == 0) ? '#ffac99' : 'white' }} type="text" defaultValue={tableMeta.rowData[10]}
Riri Novita's avatar
Riri Novita committed
1328
                                            onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} />
Riri Novita's avatar
Riri Novita committed
1329
                                        {/* } */}
Riri Novita's avatar
Riri Novita committed
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
                                    </div>
                                }

                            </div>
                        )
                    }
                }
            }, {
                name: "Expected Return/Interest (%)",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (value, tableMeta, updateValue) => {
                        return (
                            <div style={{ display: 'flex' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] == 8 || tableMeta.rowData[0] == 9 ?
                                    null :
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
Riri Novita's avatar
Riri Novita committed
1357
                                                style={{ color: this.props.get_for == 'view' ? "black" : "#5198ea", fontSize: 13, textAlign: 'center', paddingBottom: 18, borderColor: 'transparent', margin: 0, width: 96, backgroundColor: (this.props.get_for == 'edit' && tableMeta.rowData[11] == 0.00) || (this.props.get_for == 'edit' && tableMeta.rowData[11] == '') ? '#ffac99' : 'transparent' }}
Riri Novita's avatar
Riri Novita committed
1358 1359
                                                type="text"
                                                placeholder=""
Riri Novita's avatar
Riri Novita committed
1360
                                                decimalScale={this.props.defaultCurrency.id == 1 ? 2 : 16}
Riri Novita's avatar
Riri Novita committed
1361 1362
                                                disabled={this.props.get_for == 'view'}
                                                value={fixNumber(Number(tableMeta.rowData[11]), 2) == "0.0" ? "0.00" : fixNumber(Number(tableMeta.rowData[11]), 2)}
Riri Novita's avatar
Riri Novita committed
1363
                                                onBlur={(event) => {
Riri Novita's avatar
Riri Novita committed
1364
                                                    handleChange(event.target.value, tableMeta, 11)
Riri Novita's avatar
Riri Novita committed
1365
                                                }}
Riri Novita's avatar
Riri Novita committed
1366

Riri Novita's avatar
Riri Novita committed
1367 1368 1369 1370 1371 1372 1373 1374
                                            />
                                        }
                                    />
                                }
                            </div>
                        )
                    }
                }
Riri Novita's avatar
Riri Novita committed
1375
            },
Riri Novita's avatar
Riri Novita committed
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411
            // {
            //     name: "Currency",
            //     options: {
            //         customHeadRender: (columnMeta) => (
            //             <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
            //                 <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
            //             </TableCell>
            //         ),
            //         setCellProps: () => ({ style2 }),
            //         customBodyRender: (val, tableMeta, updateValue) => {
            //             return (
            //                 <div style={{ textAlign: 'right', width: 90 }}>
            //                     {tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 || tableMeta.rowData[0] === 4 ?
            //                         null :
            //                         <Autocomplete
            //                             {...this.state.currencyList}
            //                             id="currencyList"
            //                             onChange={(event, newInputValue) => handleChange(newInputValue, tableMeta, tableMeta.columnIndex)}
            //                             debug
            //                             value={handleValueDropDown(val, 'currencyList', tableMeta)}
            //                             disableClearable
            //                             disabled={this.props.get_for == 'view'}
            //                             style={{ padding: 0, margin: 0 }}
            //                             renderInput={(params) =>
            //                                 <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
            //                                     <textarea style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: tableMeta.rowData[12] == null && this.props.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" {...params.inputProps} />
            //                                 </div>
            //                             }
            //                         />
            //                     }
            //                 </div>
            //             )
            //         }
            //     }
            // }, 
            {
Riri Novita's avatar
Riri Novita committed
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421
                name: "Currency",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
Riri Novita's avatar
Riri Novita committed
1422 1423
                            <div style={{ display: 'flex' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] == 8 || tableMeta.rowData[0] == 9 ?
Riri Novita's avatar
Riri Novita committed
1424
                                    null :
Riri Novita's avatar
Riri Novita committed
1425
                                    <div style={{ padding: 0, margin: 0 }}>
Riri Novita's avatar
Riri Novita committed
1426
                                        <textarea maxLength={3} disabled={this.props.get_for == 'view'} style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: tableMeta.rowData[12] == '' && this.props.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" defaultValue={tableMeta.rowData[12]}
Riri Novita's avatar
Riri Novita committed
1427 1428
                                            onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} />
                                    </div>
Riri Novita's avatar
Riri Novita committed
1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446
                                }
                            </div>
                        )
                    }
                }
            }, {
                name: `Investment Amount (Original Currency)`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div className="col-1">
                                <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
1447
                                    {tableMeta.rowData[0] === 4 ?
Riri Novita's avatar
Riri Novita committed
1448
                                        null :
Riri Novita's avatar
Riri Novita committed
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
                                        tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={val}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "black", fontSize: 12, paddingBottom: 18, textAlign: 'right', fontWeight: 'bold', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            disabled={true}
                                                            decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[13]), 1) : Number(tableMeta.rowData[13]) == 0 ? "0.0" : Number(tableMeta.rowData[13])}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={val}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: this.props.get_for == 'view' ? "black" : "#5198ea", fontSize: 12, paddingBottom: 18, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
                                                            disabled={this.props.get_for == 'view'}
                                                            value={this.props.defaultCurrency.id == 1 ? (fixNumber(Number(tableMeta.rowData[13]), 1) == 0.0 ? "0.0" : fixNumber(Number(tableMeta.rowData[13]), 1)) : (Number(tableMeta.rowData[13]) == 0.0 ? "0.0" : Number(tableMeta.rowData[13]))}
                                                            onBlur={(event) => {
Riri Novita's avatar
Riri Novita committed
1482
                                                                handleChange(event.target.value, tableMeta, 13)
Riri Novita's avatar
Riri Novita committed
1483 1484 1485 1486 1487 1488
                                                            }}

                                                        />
                                                    }
                                                />
                                            </div>
Riri Novita's avatar
Riri Novita committed
1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523
                                    }
                                </div>
                            </div>
                        )
                    }
                }
            }, {
                name: `Investment Amount (Reporting Currency)`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div className="col-1">
                                <div style={{ textAlign: 'right', width: 90 }}>
                                    {tableMeta.rowData[0] === 4 ?
                                        null :
                                        tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={val}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "black", fontSize: 12, paddingBottom: 18, textAlign: 'right', fontWeight: 'bold', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            disabled={true}
                                                            decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
                                                            // value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14)), 1) : Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14)) == 0 ? "0.0" : Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14))}
Riri Novita's avatar
Riri Novita committed
1524
                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[14]), 1) : Number(tableMeta.rowData[14]) == 0 ? "0.0" : Number(tableMeta.rowData[14])}
Riri Novita's avatar
Riri Novita committed
1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={val}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: this.props.get_for == 'view' ? "black" : "#5198ea", fontSize: 12, paddingBottom: 18, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
                                                            disabled={this.props.get_for == 'view'}
                                                            value={this.props.defaultCurrency.id == 1 ? (fixNumber(Number(tableMeta.rowData[14]), 1) == 0.0 ? "0.0" : fixNumber(Number(tableMeta.rowData[14]), 1)) : (Number(tableMeta.rowData[14]) == 0.0 ? "0.0" : Number(tableMeta.rowData[14]))}
                                                            onBlur={(event) => {
                                                                handleChange(event.target.value, tableMeta, 14)
                                                            }}

                                                        />
                                                    }
                                                />
                                            </div>
                                    }
                                </div>
                            </div>
                        )
                    }
                }
            }, {
                name: "Notes",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, height: 42, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'left', width: 90 }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
                                    null :
                                    <div style={{ padding: 0, margin: 0 }}>
                                        <textarea disabled={this.props.get_for == 'view'} style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: 'transparent' }} type="text" defaultValue={tableMeta.rowData[15]}
                                            onBlur={(event) => handleChange(event.target.value, tableMeta, 45)} />
                                    </div>
                                    // <FormControlLabel
                                    //     style={{ margin: 0 }}
                                    //     control={
                                    //         <ThemeProvider theme={theme}>
                                    //             <Input
                                    //                 disableUnderline={true}
                                    //                 style={{ color: this.props.get_for == 'view'? "black" : "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 75, backgroundColor: 'transparent' }}
                                    //                 type="text"
                                    //                 placeholder=""
                                    //                 multiline={true}
                                    //                 defaultValue={tableMeta.rowData[45]}
                                    //                 disabled={this.props.get_for == 'view'}
                                    //                 onBlur={(event) => {
                                    //                     handleChange(event.target.value, tableMeta, 45)
                                    //                 }}
                                    //             />
                                    //         </ThemeProvider>
                                    //     }
                                    // />
                                }
                            </div>
                        )
                    }
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }
        ]

        const loadingComponent = (
            <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)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );

        const handleClose = (event, reason) => {
            if (reason === 'clickaway') {
                return;
            }

            this.setState({
                snekbar: false,
                snekbarMsg: ''
            })
        };

        return (
            <div>
Riri Novita's avatar
Riri Novita committed
1631
                {this.state.visibleLOVMR ?
Riri Novita's avatar
Riri Novita committed
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718
                    <div style={{ padding: 20 }}>
                        <Snackbar open={this.state.snekbar} autoHideDuration={6000} onClose={handleClose}>
                            <Alert onClose={handleClose} severity="error">
                                {this.state.snekbarMsg}
                            </Alert>
                        </Snackbar>
                        <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                            <div>
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', fontWeight: 'bold' }}>List Of Investment</Typography>
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
                                {this.props.defaultCurrency.id === 1 ?
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    :
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                }
                            </div>
                            <div style={{ width: '50%' }}>
                                <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                    {(this.props.get_for == 'edit' &&
                                        <div>
                                            <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" />
                                        </div>
                                    )}
                                    {(this.props.get_for == 'edit' &&
                                        <div>
                                            <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" />
                                        </div>
                                    )}
                                    {/* <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>
                        </div>

                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                            {this.state.loading && loadingComponent}
                            {!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
                                <MUIDataTable
                                    data={dataTable2}
Riri Novita's avatar
Riri Novita committed
1719
                                    columns={columns}
Riri Novita's avatar
Riri Novita committed
1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744
                                    options={options}
                                />
                            </MuiThemeProvider>}
                            {this.props.get_for == 'view' && this.state.viewOnly && <div style={{ color: '#000', marginTop: 10, fontSize: 12 }}>(*) There may be discrepancies in amount due to rounding</div>}
                        </div>

                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15, marginTop: 5 }}>
                            <div>
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.props.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
                                        {
                                            this.props.updateBy.length > 0 ? this.props.updateBy.reverse().map((item, index) => {
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>

                                        }
                                    </div>
                                </div>
                            </div>
                            <div style={{ display: 'flex', flexDirection: 'row' }}>
                                <div style={{ padding: 5 }}>
Riri Novita's avatar
Riri Novita committed
1745
                                    <Typography style={{ fontSize: '12px', color: '#4b4b4b' }}>Total Investment</Typography>
Riri Novita's avatar
Riri Novita committed
1746 1747 1748 1749 1750 1751 1752 1753
                                </div>
                                <div style={{ border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
                                    <Typography style={{ fontSize: '14px', color: '#4b4b4b' }}><NumberFormat value={this.state.perBS} displayType={'text'} thousandSeparator={true} prefix={''} /></Typography>
                                </div>
                            </div>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <div>
Riri Novita's avatar
Riri Novita committed
1754
                                {/* <Typography style={{ fontSize: '12px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.props.notes}</Typography> */}
Riri Novita's avatar
Riri Novita committed
1755 1756 1757 1758 1759 1760
                            </div>
                            <div style={{ display: 'flex', flexDirection: 'row' }}>
                                <div style={{ padding: 5 }}>
                                    <Typography style={{ fontSize: '12px', color: '#4b4b4b' }}>Diff</Typography>
                                </div>
                                <div style={{ borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
Riri Novita's avatar
Riri Novita committed
1761
                                    <Typography style={{ fontSize: '14px', color: Number(this.state.diff) > '0.0' || Number(this.state.diff) < '0.0' ? 'red' : '#4b4b4b' }}><NumberFormat value={this.state.diff == 0 ? "0.0" : this.state.diff} displayType={'text'} thousandSeparator={true} prefix={''} /></Typography>
Riri Novita's avatar
Riri Novita committed
1762 1763 1764
                                </div>
                            </div>
                        </div>
Riri Novita's avatar
Riri Novita committed
1765
                        {/* <div style={{ display: 'flex', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
Riri Novita's avatar
Riri Novita committed
1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, fontWeight: 'bold', textDecorationLine: 'underline' }}>Keterangan:</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>1. Current ratio = Current Assets / Current Liabilities</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>2. DER = Interest Bearing Debt / Total Equity (dimana Interest Bearing Debt = Short term loan + Current maturities of long term debt + Long term loan + Due to affiliated companies + Due to shareholder)</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>3. Debt to EBITDA = Interest Bearing Debt / EBITDA (dimana Interest Bearing Debt = Short term loan + Current maturities of long term debt + Long term loan + Due to affiliated companies + Due to shareholder</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginLeft: 10 }}>& EBITDA = Income from operations 2 (EBIT 2) + depreciation)</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>4. EBITDA to Interest (ISCR) = EBITDA / Interest Expenses (dimana EBITDA = Income from operations 2 (EBIT 2) + depreciation)</Typography>
Riri Novita's avatar
Riri Novita committed
1782
                        </div> */}
Riri Novita's avatar
Riri Novita committed
1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822

                        {/* <div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5}}>
                     <div style={{display: 'flex', flexDirection: 'row'}}>
                         <div style={{padding: 5}}>
                             <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography>
                         </div>
                         <div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
                             <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.totalOutStand)}</Typography>
                         </div>
                     </div>
                 </div>
                 <div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15}}>
                     <div style={{display: 'flex', flexDirection: 'row'}}>
                         <div style={{padding: 5}}>
                             <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Diff</Typography>
                         </div>
                         <div style={{borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
                             <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.diff)}</Typography>
                         </div>
                     </div>
                 </div> */}
                    </div>
                    :
                    <div style={{ padding: 20 }}>
                        <div>
                            <Typography style={{ fontSize: '12px', color: '#4b4b4b', fontWeight: 'bold' }}>List Of Investment</Typography>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
                            {this.props.defaultCurrency.id === 1 ?
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                :
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                            }
                        </div>

                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                            {this.state.loading && loadingComponent}
                            {this.state.dataLoaded && !this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
                                <MUIDataTable
                                    data={dataTable2}
Riri Novita's avatar
Riri Novita committed
1823
                                    columns={columns}
Riri Novita's avatar
Riri Novita committed
1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863
                                    options={options}
                                />
                            </MuiThemeProvider>}
                        </div>

                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15, marginTop: 5 }}>
                            <div>
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.props.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
                                        {
                                            this.props.updateBy.length > 0 ? this.props.updateBy.reverse().map((item, index) => {
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>

                                        }
                                    </div>
                                </div>
                            </div>
                            <div style={{ display: 'flex', flexDirection: 'row' }}>
                                <div style={{ padding: 5 }}>
                                    <Typography style={{ fontSize: '12px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography>
                                </div>
                                <div style={{ border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
                                    <Typography style={{ fontSize: '14px', color: '#4b4b4b' }}><NumberFormat value={this.state.perBS} displayType={'text'} thousandSeparator={true} prefix={''} /></Typography>
                                </div>
                            </div>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <div>
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.props.notes}</Typography>
                            </div>
                            <div style={{ display: 'flex', flexDirection: 'row' }}>
                                <div style={{ padding: 5 }}>
                                    <Typography style={{ fontSize: '12px', color: '#4b4b4b' }}>Diff</Typography>
                                </div>
                                <div style={{ borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
Riri Novita's avatar
Riri Novita committed
1864
                                    <Typography style={{ fontSize: '14px', color: Number(this.state.diff) > '0.0' || Number(this.state.diff) < '0.0' ? 'red' : '#4b4b4b' }}><NumberFormat value={this.state.diff} displayType={'text'} thousandSeparator={true} prefix={''} /></Typography>
Riri Novita's avatar
Riri Novita committed
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888
                                </div>
                            </div>
                        </div>

                        <div style={{ display: 'flex', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, fontWeight: 'bold', textDecorationLine: 'underline' }}>Keterangan:</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>1. Current ratio = Current Assets / Current Liabilities</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>2. DER = Interest Bearing Debt / Total Equity (dimana Interest Bearing Debt = Short term loan + Current maturities of long term debt + Long term loan + Due to affiliated companies + Due to shareholder)</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>3. Debt to EBITDA = Interest Bearing Debt / EBITDA (dimana Interest Bearing Debt = Short term loan + Current maturities of long term debt + Long term loan + Due to affiliated companies + Due to shareholder</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginLeft: 10 }}>& EBITDA = Income from operations 2 (EBIT 2) + depreciation)</Typography>
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>4. EBITDA to Interest (ISCR) = EBITDA / Interest Expenses (dimana EBITDA = Income from operations 2 (EBIT 2) + depreciation)</Typography>
                        </div>

                        {/* <div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5}}>
Riri Novita's avatar
Riri Novita committed
1889 1890 1891 1892 1893 1894
                            <div style={{display: 'flex', flexDirection: 'row'}}>
                                <div style={{padding: 5}}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography>
                                </div>
                                <div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.perBS)}</Typography>
Riri Novita's avatar
Riri Novita committed
1895 1896
                                </div>
                            </div>
Riri Novita's avatar
Riri Novita committed
1897 1898 1899 1900 1901 1902 1903 1904
                        </div>
                        <div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15}}>
                            <div style={{display: 'flex', flexDirection: 'row'}}>
                                <div style={{padding: 5}}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Diff</Typography>
                                </div>
                                <div style={{borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{(formatSeparator(this.state.diff))}</Typography>
Riri Novita's avatar
Riri Novita committed
1905
                                </div>
Riri Novita's avatar
Riri Novita committed
1906 1907
                            </div>
                        </div> */}
Riri Novita's avatar
Riri Novita committed
1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954
                    </div>
                }

                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File List Of Investment</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>
                            <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("LIST") && String(this.state.judul).includes("INVESTMENT") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
                                            this.checkUpload() :
                                            this.setState({ snekbar: true, snekbarMsg: 'Invalid Template', tipeAlert: 'warning' })
                                    }}
                                />
                            </div>
                            <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>
                        </div>
                    </div>
                )}
            </div>
        )
    }

1955
}