Commit b8206735 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'riri' into 'master'

apdet judul

See merge request !342
parents 3d807c6e 2e7cd8e1
......@@ -4,7 +4,7 @@ import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
import api from '../../api';
import AddIcon from '@material-ui/icons/Add';
import { values } from 'ramda';
import { values, type } from 'ramda';
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
......@@ -44,7 +44,8 @@ export default class ProfitLoss extends Component {
visibleProfitLoss: true,
disabledSave: true,
editable: false,
buttonError: false
buttonError: false,
judulColumn: null
}
this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this);
......@@ -56,7 +57,7 @@ export default class ProfitLoss extends Component {
}
getItemHierarki() {
this.setState({ loading: true })
this.setState({ loading: true, judulColumn: null })
let payload = {
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
......@@ -67,6 +68,7 @@ export default class ProfitLoss extends Component {
api.create().getDetailReportMB(payload).then(response => {
console.log(response);
let dataTable = []
if (response.data) {
let res = response.data.data
console.log(res)
const handlePushChild = (item) => {
......@@ -80,7 +82,7 @@ export default class ProfitLoss extends Component {
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
......@@ -115,7 +117,7 @@ export default class ProfitLoss extends Component {
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
......@@ -141,6 +143,9 @@ export default class ProfitLoss extends Component {
}
})
this.setState({ dataTable, loading: false, buttonError: true })
} else {
this.setState({ dataTable, loading: false, buttonError: true })
}
})
}
......@@ -233,16 +238,16 @@ export default class ProfitLoss extends Component {
}
else {
let isi = resp.rows.slice(3)
console.log(isi);
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({
item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(),
notes: i[2] === undefined ? "" : String(i[2]).trim(),
total_actual_before: i[3] === undefined ? "0" : String(i[3]).trim(),
total_actual_before: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
january: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
february: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
march: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
......@@ -267,8 +272,8 @@ export default class ProfitLoss extends Component {
report_id: this.props.report_id,
profit_loss: payload
}
console.log(payload)
this.setState({ payload: body, judul: resp.rows[1][0] })
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
}
});
}
......@@ -308,12 +313,15 @@ export default class ProfitLoss extends Component {
item.error
]
})
// console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
if (this.state.dataTable[23].length > 0) {
this.state.dataTable.map(item => {
if (item[23].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(dataTable)
})
}
}
})
......@@ -383,9 +391,12 @@ export default class ProfitLoss 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)
......@@ -396,6 +407,7 @@ export default class ProfitLoss extends Component {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
}
}
}
const handleNotes = (value, tableMeta) => {
console.log(value)
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
......@@ -484,7 +496,7 @@ export default class ProfitLoss extends Component {
display: false
}
}, {
name: "Account",
name: this.state.judulColumn !== null ? this.state.judulColumn[1] : "Account",
options: {
customHeadRender: (columnMeta) => (
<TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300 }}>
......@@ -522,7 +534,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Notes",
name: this.state.judulColumn !== null ? this.state.judulColumn[2] : "Notes",
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -559,7 +571,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "31 Dec 2020 Actual",
name: this.state.judulColumn !== null ? this.state.judulColumn[3] : `31 Dec ${Number(this.props.periode) - 1} Actual`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -570,7 +582,9 @@ export default class ProfitLoss 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 }}
......@@ -578,77 +592,22 @@ export default class ProfitLoss extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
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)}
// />
null
:
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)}
// />
null
:
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: "Jan 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[4] : `Jan ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -736,7 +695,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Feb 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[5] : `Feb ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -825,7 +784,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Mar 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[6] : `Mar ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -914,7 +873,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Apr 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[7] : `Apr ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1003,7 +962,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "May 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[8] : `May ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1092,7 +1051,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Jun 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[9] : `Jun ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1181,7 +1140,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Jul 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[10] : `Jul ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1270,7 +1229,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Aug 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[11] : `Aug ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1359,7 +1318,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Sep 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[12] : `Sep ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1448,7 +1407,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Oct 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[13] : `Oct ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1537,7 +1496,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Nov 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[14] : `Nov ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1626,7 +1585,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Dec 2021",
name: this.state.judulColumn !== null ? this.state.judulColumn[15] : `Dec ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1715,7 +1674,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "Current Total",
name: this.state.judulColumn !== null ? this.state.judulColumn[16] : "Current Total",
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -1804,7 +1763,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "31 Dec 2022 Total",
name: this.state.judulColumn !== null ? this.state.judulColumn[17] : `31 Dec ${Number(this.props.periode) + 1} Total`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -1893,7 +1852,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "31 Dec 2022 Total",
name: this.state.judulColumn !== null ? this.state.judulColumn[18] : `31 Dec ${Number(this.props.periode) + 2} Total`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -2086,7 +2045,17 @@ export default class ProfitLoss extends Component {
<div className="col-1">
<button
type="button"
onClick={() => this.state.editable === true ? this.backToMasterBudget('draft') : this.props.onClickClose()}
onClick={() => this.state.editable === true ?
this.setState({ loading: true }, () => {
setTimeout(() => {
this.backToMasterBudget('draft')
}, 100);
}) :
this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
......@@ -2110,9 +2079,11 @@ export default class ProfitLoss extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => {
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}}
}, 100);
})}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
......@@ -2168,7 +2139,7 @@ export default class ProfitLoss extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150), height: this.props.height - 400 }}>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
......@@ -2182,7 +2153,11 @@ export default class ProfitLoss extends Component {
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button
type="button"
onClick={() => this.setState({ visibleProfitLoss: true }, () => this.getItemHierarki())}
onClick={() => this.setState({ loading: true, visibleProfitLoss: true }, () => {
setTimeout(() => {
this.getItemHierarki()
}, 100);
})}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
......@@ -2192,6 +2167,7 @@ export default class ProfitLoss extends Component {
<button
className="button"
type="button"
disabled={this.state.buttonError}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
......@@ -2213,7 +2189,7 @@ export default class ProfitLoss extends Component {
</button>
<button
type="button"
// disabled={this.state.buttonError}
disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadProfitLoss()
......
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