import React, { Component } from 'react'; import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input } from '@material-ui/core'; import MUIDataTable from 'mui-datatables'; import NumberFormat from 'react-number-format'; import Images from '../../assets/Images'; import ReactTooltip from 'react-tooltip'; import api from '../../api'; var ct = require("../../library/CustomTable"); const getMuiTheme = () => createMuiTheme(ct.customTable()); const options = ct.customOptionsFixedColumn(); const style = { position: "sticky", left: 0, background: "white", zIndex: 101, }; const style2 = { position: "sticky", left: 420, background: "white", zIndex: 101 }; export default class TaxPlanning extends Component { constructor(props) { super(props) this.state = { dataTable: [ // ["TOTAL ASSETS", "11,247,249", "10,702,196"], // ["TOTAL CURRENT ASSETS", "2,647,647", "2,058,898"], // ["Cash & Cash Equivalent", "1,464,571", "729,743"], // ["Cash & Bank Balance", "938,707", "265,584"], // ["Time & Call Deposit", "525,864", "464,159"], // ["BI Deposit", "", ""], // ["Marketable Securities", "150,250", "154,500"], // ["Notes Receivable", "", ""], // ["Accounts Receivable", "172,031", "97,112"], // ["Trade Receivables - Third Party", "142,668", "77,480"], ] } } componentDidMount() { this.getItemHierarki() console.log(this.props); } getItemHierarki() { let payload = { "report_id": this.props.report_id, "company_id": this.props.company.company_id } api.create().getItemReportHierarki(payload).then(response => { console.log(response); if (response.data) { if (response.data.status === "success") { let dataTable = [] response.data.data.map((item, index) => { if (item.children && item.children.length > 0) { dataTable.push([ item.type_report_id, item.id, item.parent, item.level, item.description ]) item.children.map(i => { if (i.children) { if (i.children.length > 0) { dataTable.push([ i.type_report_id, i.id, i.parent, i.level, i.description ]) i.children.map(val => { dataTable.push([ val.type_report_id, val.id, val.parent, val.level, val.description ]) }) } else { dataTable.push([ i.type_report_id, i.id, i.parent, i.level, i.description ]) } } else { dataTable.push([ i.type_report_id, i.id, i.parent, i.level, i.description ]) } }) } else { dataTable.push([ item.type_report_id, item.id, item.parent, item.level, item.description ]) } }) console.log(dataTable); this.setState({ dataTable }) } } }) } handleValue(data) { let total = 0 this.state.dataTable.map((item, index) => { if (data.rowData[1] == item[2]) { total = item[data.columnIndex] == undefined ? (total + 0) : (total + item[data.columnIndex]) } }) let indexParent = this.state.dataTable.findIndex((val) => val[1] == this.state.dataTable[data.rowIndex][2]) let a = this.state.dataTable[data.rowIndex][data.columnIndex] = total // console.log(indexParent); return a } handleChange(value, tableMeta) { let val = String(value).split(",").join("") let data = this.state.dataTable let indexParent = data.findIndex((val) => val[1] == data[tableMeta.rowIndex][2]) if (indexParent > 0) { let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) let jagain = data[indexParent][tableMeta.columnIndex] a = data[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val)) } else { data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) } this.forceUpdate() // console.log(this.state.dataTable) // this.setState({ // data: a, // }, () => console.log(this.state.dataTable)) } render() { const columns = [{ name: "", options: { display: false } },{ name: "", options: { display: false } },{ name: "", options: { display: false } },{ name: "", options: { display: false } },{ name: "Account", options: { customHeadRender: (columnMeta) => ( {columnMeta.name} ), setCellProps: () => ({ style }), customBodyRender: (val, tableMeta) => { return (
{tableMeta.rowData[3] == 0 ? {String(val).toUpperCase()} : tableMeta.rowData[3] === 1? {val} : {val} }
) } } // }, { // name: "31 Dec 2020 Actual", // options: { // customHeadRender: (columnMeta) => ( // // {columnMeta.name} // // ), // setCellProps: () => ({ // style: { // position: "sticky", // left: 420, // background: "white", // zIndex: 101 // } // }) // } }, { name: "January 2021", options: { customHeadRender: (columnMeta) => ( {columnMeta.name} ), customBodyRender: (value, tableMeta, updateValue) => { console.log(tableMeta) return (
{tableMeta.rowData[0] === 4 ?
{ // console.log(event.target) updateValue(event.target.value) this.handleChange(event.target.value, tableMeta) }} /> } />
: tableMeta.rowData[0] === 2 ? : tableMeta.rowData[0] === 1 ? - : validasi }
) } } }, { name: "February 2021", options: { filter: false, customHeadRender: (columnMeta) => (
{columnMeta.name}
{"Trial Balance (Commercial) MTD"}
{"Fiscal Correction Positive /(Negative)"}
{"Trial Balance (Fiscal) MTD"}
), customBodyRender: (value, tableMeta, updateValue) => { return (
{99}
{tableMeta.rowData[0] === 4 ?
{ // console.log(event.target) updateValue(event.target.value) this.handleChange(event.target.value, tableMeta) }} /> } />
: tableMeta.rowData[0] === 2 ? : tableMeta.rowData[0] === 1 ? - : validasi }
{99}
); } } }, { name: "March 2021", options: { filter: false, customHeadRender: (columnMeta) => (
{columnMeta.name}
{"Trial Balance (Commercial) MTD"}
{"Fiscal Correction Positive /(Negative)"}
{"Trial Balance (Fiscal) MTD"}
), customBodyRender: (val) => { return (
{val}
{val}
{val}
); } } }, { name: "April 2021", options: { customHeadRender: (columnMeta) => ( {columnMeta.name} ), customBodyRender: (val) => { return (
{val}
) } } }, { name: "May 2021", options: { customHeadRender: (columnMeta) => ( {columnMeta.name} ), customBodyRender: (val) => { return (
{val}
) } } }, { name: "June 2021", options: { customHeadRender: (columnMeta) => ( {columnMeta.name} ), customBodyRender: (val) => { return (
{val}
) } } }, { name: "31 Dec 2021 Total", options: { customHeadRender: (columnMeta) => ( {columnMeta.name} ), customBodyRender: (val) => { return (
{val}
) } } }, { name: "31 Dec 2022 Total", options: { customHeadRender: (columnMeta) => ( {columnMeta.name} ), customBodyRender: (val) => { return (
{val}
) } } }, { name: "31 Dec 2023 Total", options: { customHeadRender: (columnMeta) => ( {columnMeta.name} ), customBodyRender: (val) => { return (
{val}
) } } } ] return (
Master Budget - Tax Planning
{/* */}
{this.props.company.company_name} Company Periode : 2021 in IDR mn
this.props.onClickClose()} style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', cursor: 'pointer' }}> Back
this.props.onClickClose()} style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960', cursor: 'pointer', marginRight: 20 }}> Cancel
Save
//
//
// Budget Tahunan - Tax Planning //
//
// {/* //
// Budget Tahunan //
*/} //
//
// PT. XYZ // Periode : 2021 // in IDR mn //
//
// // // //
//
// {/*
*/} //
//
); } }