Commit a04bd94d authored by Deni Rinaldi's avatar Deni Rinaldi

update balancesheet ter new

parent 8e7966d4
......@@ -80,7 +80,7 @@ export default class BalanceSheet extends Component {
item.formula,
item.level,
item.description,
item.balance_sheet.total_actual_before === null ? "" : item.balance_sheet.total_actual_before,
item.balance_sheet.total_actual_before === null ? "0" : item.balance_sheet.total_actual_before === "" ? "0" : item.balance_sheet.total_actual_before,
item.balance_sheet.january,
item.balance_sheet.february,
item.balance_sheet.march,
......@@ -114,7 +114,7 @@ export default class BalanceSheet extends Component {
item.formula,
item.level,
item.description,
item.balance_sheet.total_actual_before === null ? "" : item.balance_sheet.total_actual_before,
item.balance_sheet.total_actual_before === null ? "0" : item.balance_sheet.total_actual_before === "" ? "0" : item.balance_sheet.total_actual_before,
item.balance_sheet.january,
item.balance_sheet.february,
item.balance_sheet.march,
......@@ -235,7 +235,7 @@ export default class BalanceSheet extends Component {
let isi = resp.rows.slice(3)
console.log(resp.rows[2]);
let payload = []
let reg = /^\d+$/;
let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
......@@ -382,9 +382,12 @@ export default class BalanceSheet extends Component {
render() {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => {
const handleChange = (value, tableMeta, type) => {
let val = String(value).split(",").join("")
// let data = this.state.dataTable2
if (type === "actual") {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
} else {
let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
if (indexParent > 0) {
// console.log(indexParent)
......@@ -395,6 +398,7 @@ export default class BalanceSheet extends Component {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
}
}
}
const handleValue = (data) => {
let total = 0
dataTable2.map((item, index) => {
......@@ -516,7 +520,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[2] : "31 Dec 2020 Actual",
name: this.state.judulColumn !== null ? this.state.judulColumn[2] : `31 Dec ${Number(this.props.periode) - 1} Actual`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -527,83 +531,32 @@ export default class BalanceSheet extends Component {
customBodyRender: (value, tableMeta, updateValue) => {
return (
<div style={{ textAlign: 'right' }}>
{tableMeta.rowData[0] === 3 ?
{tableMeta.rowData[0] === 4 ?
null
:
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
/>
</span>
:
tableMeta.rowData[0] === 4 ?
null
:
tableMeta.rowData[0] === 6 ?
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
value={value}
/>
:
tableMeta.rowData[0] === 5 ?
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={handleFormula(value, tableMeta)}
}
/>
:
tableMeta.rowData[0] === 1 ?
// value === "" ?
// null :
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(value)}
// />
null
:
null
</div>
}
</div>
)
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[3] : "Jan 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[3] : `Jan ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -622,6 +575,7 @@ export default class BalanceSheet extends Component {
control={
<NumberFormat
thousandSeparator={true}
decimalSeparator={"."}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
......@@ -689,7 +643,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[4] : "Feb 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[4] : `Feb ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -776,7 +730,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[5] : "Mar 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[5] : `Mar ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -863,7 +817,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[6] : "Apr 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[6] : `Apr ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -950,7 +904,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[7] : "May 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[7] : `May ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1037,7 +991,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[8] : "Jun 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[8] : `Jun ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1124,7 +1078,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[9] : "Jul 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[9] : `Jul ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1211,7 +1165,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[10] : "Aug 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[10] : `Aug ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1298,7 +1252,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[11] : "Sep 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[11] : `Sep ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1385,7 +1339,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[12] : "Oct 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[12] : `Oct ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1472,7 +1426,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[13] : "Nov 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[13] : `Nov ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1559,7 +1513,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[14] : "Dec 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[14] : `Dec ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1733,7 +1687,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[16] : "31 Dec 2022 Total",
name: this.state.judulColumn !== null ? this.state.judulColumn[16] : `31 Dec ${Number(this.props.periode) + 1} Total`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -1820,7 +1774,7 @@ export default class BalanceSheet extends Component {
}
}
}, {
name: this.state.judulColumn !== null ? this.state.judulColumn[17] : "31 Dec 2023 Total",
name: this.state.judulColumn !== null ? this.state.judulColumn[17] : `31 Dec ${Number(this.props.periode) + 2} Total`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment