Commit 2d5a5547 authored by faisalhamdi's avatar faisalhamdi

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into faisal

parents 38fa7b58 94219474
......@@ -168,6 +168,8 @@ const create = (type = "") => {
const getReportParent = (body) => api.post('item_report/get_parent_item_report', body)
const deleteReportItems = (id) => api.post(`item_report/delete_item_report/${id}`)
const getAllSettingByType = (body) => api.post('setting/get_all_setting_by_type', body)
const createAllItemReport = (body) => api.post('item_report/create_all_item_report', body)
const deleteAllItemReport = (body) => api.post('/item_report/delete_all_item_report', body)
//PARAMETER
const getAllParameter = () => api.get('/setting/get_all_setting')
......@@ -335,7 +337,9 @@ const create = (type = "") => {
createOpetaingInd,
uploadMasterBudget,
getAllSettingByType,
getOpetratingIndID
getOpetratingIndID,
createAllItemReport,
deleteAllItemReport
}
}
......
......@@ -24,7 +24,7 @@ const LightTooltip = withStyles((theme) => ({
},
}))(Tooltip);
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const getMuiTheme = () => createMuiTheme(ct.customTable3());
const options = ct.customOptionsFixedColumn();
const style = {
......@@ -59,7 +59,8 @@ export default class CorporateAnnualTarget extends Component {
},
kpiTypeList: [],
maxAchList: [],
visibleCAT: true
visibleCAT: true,
buttonError: false
// formulaYTDList: null,
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -83,10 +84,11 @@ export default class CorporateAnnualTarget extends Component {
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID
}
console.log(JSON.stringify(payload))
api.create().getDetailReportMB(payload).then(response => {
let dataTable = []
console.log(response)
let res = response.data.data
console.log(res)
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
......@@ -100,9 +102,9 @@ export default class CorporateAnnualTarget extends Component {
item.description,
item.cat.weight,
item.cat.uom,
item.cat.kpi_type == "" ? null : item.cat.kpi_type,
item.cat.max_ach == "" ? null : item.cat.max_ach,
item.cat.formula == "" ? null : item.cat.formula,
item.cat.kpi_type == "" ? null : {value: item.cat.kpi_type},
item.cat.max_ach == "" ? null : {value: item.cat.max_ach},
item.cat.formula == "" ? null : {value: item.cat.formula},
item.cat.total_actual_before,
item.cat.january,
item.cat.february,
......@@ -142,9 +144,9 @@ export default class CorporateAnnualTarget extends Component {
item.description,
item.cat.weight,
item.cat.uom,
item.cat.kpi_type == "" ? null : item.cat.kpi_type,
item.cat.max_ach == "" ? null : item.cat.max_ach,
item.cat.formula == "" ? null : item.cat.formula,
item.cat.kpi_type == "" ? null : {value: item.cat.kpi_type},
item.cat.max_ach == "" ? null : {value: item.cat.max_ach},
item.cat.formula == "" ? null : {value: item.cat.formula},
item.cat.total_actual_before,
item.cat.january,
item.cat.february,
......@@ -224,6 +226,7 @@ export default class CorporateAnnualTarget extends Component {
if (i.length > 0) {
payload.push({
item_report_id: i[0] === undefined ? "0" : reg.test(String(i[0])) === false ? "0" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(),
weight: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
uom: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
kpi_type: i[4] === undefined ? "" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
......@@ -267,83 +270,98 @@ export default class CorporateAnnualTarget extends Component {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleCAT: false })
// this.setState({ visibleUpload: false, visibleCAT: false, loading: true })
// let dataTable = response.data.data.map((item, index) => {
// return [
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// "",
// item.description,
// item.weight,
// item.uom,
// item.kpi_type == "" ? null : item.kpi_type,
// item.max_ach == "" ? null : item.max_ach,
// item.formula == "" ? null : item.formula,
// item.total_actual_before,
// item.january,
// item.february,
// item.march,
// item.april,
// item.may,
// item.june,
// item.july,
// item.august,
// item.september,
// item.october,
// item.november,
// item.december,
// item.total_current_year,
// item.total_next_year,
// item.total_more_year,
// item.pic,
// item.error
// ]
// })
// this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
// this.state.dataTable.map(item => {
// if (item[22].length > 0) {
// console.log('masuk')
// this.setState({ buttonError: true, errorPreview: true })
// }
// })
// // console.log(this.state.dataTable);
// })
// this.setState({ visibleUpload: false, visibleCAT: false })
this.setState({ visibleUpload: false, visibleCAT: false, loading: true })
let dataTable = response.data.data.map((item, index) => {
return [
item.type_report_id,
item.item_report_id,
item.parent,
item.formula,
item.level,
"",
item.item_report,
item.weight,
item.uom,
item.kpi_type == "" ? null : item.kpi_type,
item.max_ach == "" ? null : item.max_ach,
item.formula == "" ? null : item.formula,
item.total_actual_before,
item.january,
item.february,
item.march,
item.april,
item.may,
item.june,
item.july,
item.august,
item.september,
item.october,
item.november,
item.december,
item.total_current_year,
item.total_next_year,
item.total_more_year,
item.strategic,
item.pic,
item.error
]
})
console.log(dataTable)
console.log(this.state.buttonError)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
this.state.dataTable.map(item => {
if (item[30].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(this.state.dataTable);
})
}
}
})
}
uploadBalanceSheet() {
uploadCAT() {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
total_actual_before: String(i[6]),
january: String(i[7]),
february: String(i[8]),
march: String(i[9]),
april: String(i[10]),
may: String(i[11]),
june: String(i[12]),
july: String(i[13]),
august: String(i[14]),
september: String(i[15]),
october: String(i[16]),
november: String(i[17]),
december: String(i[18]),
total_current_year: String(i[19]),
total_next_year: String(i[20]),
total_more_year: String(i[21])
"item_report_id": i[0],
"item_report": String(i[6]),
"weight": String(i[7]),
"uom": String(i[8]),
"kpi_type": String(i[9].value) == undefined || String(i[9]) == null ? String(i[9]) : (String(i[9].value) == undefined ? String(i[9].value) : String(i[9].value)),
"max_ach": String(i[10].value) == undefined || String(i[10]) == null ? String(i[10]) : (String(i[10].value) == undefined ? String(i[10].value) : String(i[10].value)),
"formula": String(i[11].value) == undefined || String(i[11]) == null ? String(i[11]) : (String(i[11].value) == undefined ? String(i[11].value) :String(i[11].value)),
"total_actual_before": String(i[12]),
"january": String(i[13]),
"february": String(i[14]),
"march": String(i[15]),
"april": String(i[16]),
"may": String(i[17]),
"june": String(i[18]),
"july": String(i[19]),
"august": String(i[20]),
"september": String(i[21]),
"october": String(i[22]),
"november": String(i[23]),
"december": String(i[24]),
"total_current_year": String(i[25]),
"total_next_year": String(i[26]),
"total_more_year": String(i[27]),
"strategic": String(i[28]),
"pic": String(i[29])
})
})
let body = {
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
// "revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID,
// "status": "submitted",
"cat": data
}
console.log(data);
......@@ -364,39 +382,70 @@ export default class CorporateAnnualTarget extends Component {
backToMasterBudget(type) {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
// console.log(i[9] == null? "" : i[9].value)
data.push({
item_report_id: i[1],
total_actual_before: String(i[6]),
january: String(i[7]),
february: String(i[8]),
march: String(i[9]),
april: String(i[10]),
may: String(i[11]),
june: String(i[12]),
july: String(i[13]),
august: String(i[14]),
september: String(i[15]),
october: String(i[16]),
november: String(i[17]),
december: String(i[18]),
total_current_year: String(i[19]),
total_next_year: String(i[20]),
total_more_year: String(i[21])
"item_report_id": i[1],
"item_report": String(i[6]),
"weight": String(i[7]),
"uom": String(i[8]),
"kpi_type": i[9] == null? "" : i[9].value,
"max_ach": i[10] == null? "" : i[10].value,
"formula": i[11] == null? "" : i[11].value,
"total_actual_before": String(i[12]),
"january": String(i[13]),
"february": String(i[14]),
"march": String(i[15]),
"april": String(i[16]),
"may": String(i[17]),
"june": String(i[18]),
"july": String(i[19]),
"august": String(i[20]),
"september": String(i[21]),
"october": String(i[22]),
"november": String(i[23]),
"december": String(i[24]),
"total_current_year": String(i[25]),
"total_next_year": String(i[26]),
"total_more_year": String(i[27]),
"strategic": String(i[28]),
"pic": String(i[29])
})
})
console.log(JSON.stringify(data))
let payload = {
"submission_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"balance_sheet": data
"cat": data
}
// console.log(data);
this.props.saveToMasterBudget(payload)
this.props.onClickClose()
console.log(JSON.stringify(payload));
this.addNewReport(payload)
}
addNewReport(payloadBro) {
let data = this.state.dataTable.map((item,index) => {
if (item[1] == "") {
return {
"item_name": item[6],
"parent": item[2]
}
}
})
let payload = {
"company_id": 1,
"item_report": data
}
api.create().createAllItemReport(payload).then((response) => {
this.props.saveToMasterBudget(payloadBro)
this.props.onClickClose()
})
}
getKPIType() {
......@@ -486,29 +535,20 @@ export default class CorporateAnnualTarget extends Component {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => {
let val = String(value).split(",").join("")
// let data = this.state.dataTable2
// let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[tableMeta.rowIndex][2])
// if (indexParent > 0) {
// // console.log(indexParent)
// let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// let jagain = dataTable2[indexParent][tableMeta.columnIndex]
// a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
// } else {
let total = 0
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
dataTable2[tableMeta.rowIndex].map((item,index) => {
if (index >= 13 && index <= 24) {
let valItem = item == undefined || item == ""? 0 : item
total += Number(valItem)
}
})
dataTable2[tableMeta.rowIndex][25] = total
console.log(dataTable2[tableMeta.rowIndex])
// }
let total = 0
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
dataTable2[tableMeta.rowIndex].map((item,index) => {
if (index >= 13 && index <= 24) {
let valItem = item == undefined || item == ""? 0 : item
total += Number(valItem)
}
})
dataTable2[tableMeta.rowIndex][25] = total
console.log(dataTable2[tableMeta.rowIndex])
}
const handleChangeDropdown = (value, tableMeta) => {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value.value
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
}
const handleChangePercentage = (value, tableMeta) => {
......@@ -591,12 +631,13 @@ export default class CorporateAnnualTarget extends Component {
}
const handleTambah = (data) => {
console.log(dataTable2)
let newData = []
dataTable2.map((item, index) => {
newData.push(item)
if (item[1] == data) {
newData.push([
item[0],
3,
"",
item[2],
item[3],
......@@ -605,9 +646,9 @@ export default class CorporateAnnualTarget extends Component {
"",
"",
"",
"",
"",
"",
null,
null,
null,
"",
"",
"",
......@@ -645,6 +686,7 @@ export default class CorporateAnnualTarget extends Component {
}, 500)
})
}
const columns = [{
name: "",
options: {
......@@ -674,6 +716,7 @@ export default class CorporateAnnualTarget extends Component {
name: "",
options: {
filter: false,
display: this.state.visibleCAT,
customBodyRender: (val, tableMeta) => {
return (
// handleAction(tableMeta.rowData[2]) &&
......@@ -885,9 +928,10 @@ export default class CorporateAnnualTarget extends Component {
disableClearable
disabled={!handleAction(tableMeta.rowData[2])}
value={val}
style={{padding: 0, margin: 0}}
renderInput={(params) =>
<div ref={params.InputProps.ref}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center'}} type="text" {...params.inputProps} />
<div ref={params.InputProps.ref} style={{padding: 0, margin: 0}}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0}} type="text" {...params.inputProps} />
</div>
}
/>
......@@ -917,10 +961,11 @@ export default class CorporateAnnualTarget extends Component {
debug
disableClearable
value={val}
style={{padding: 0, margin: 0}}
disabled={!handleAction(tableMeta.rowData[2])}
renderInput={(params) =>
<div ref={params.InputProps.ref}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center'}} type="text" {...params.inputProps} />
<div ref={params.InputProps.ref} style={{padding: 0, margin: 0}}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0}} type="text" {...params.inputProps} />
</div>
}
// value={this.state.parent}
......@@ -954,9 +999,10 @@ export default class CorporateAnnualTarget extends Component {
disableClearable
value={val}
disabled={!handleAction(tableMeta.rowData[2])}
style={{padding: 0, margin: 0}}
renderInput={(params) =>
<div ref={params.InputProps.ref}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center'}} type="text" {...params.inputProps} />
<div ref={params.InputProps.ref} style={{padding: 0, margin: 0}}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0}} type="text" {...params.inputProps} />
</div>
}
// value={this.state.parent}
......@@ -1481,10 +1527,11 @@ export default class CorporateAnnualTarget extends Component {
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell>
),
customBodyRender: (val) => {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ width: 96 }}>
{val}
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4?
null : val}
</div>
)
}
......@@ -1715,11 +1762,11 @@ export default class CorporateAnnualTarget extends Component {
margin: 5
}}
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
}, 100);
})}
// this.setState({ loading: true }, () => {
// setTimeout(() => {
this.downloadAllData()}
// }, 100);
// })}
>
<img src={Images.download} />
</button>
......@@ -1758,62 +1805,64 @@ export default class CorporateAnnualTarget extends Component {
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}}
>
<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>
</div>
</button>
<button
type="button"
// disabled={this.state.disabledSave}
onClick={() => this.createData()}
style={{
backgroundColor: 'transparent',
cursor: this.state.disabledSave === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center'}}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, disabledSave: false })
}, 100);
})
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
</div>
}, 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>
</div>
</button>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: false, editable: true })
}, 100);
})
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.backToMasterBudget('submitted')}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
</div>
</div>
</Paper>
:
......@@ -1879,7 +1928,7 @@ export default class CorporateAnnualTarget extends Component {
disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadBalanceSheet()
this.uploadCAT()
}, 100);
})}
>
......
......@@ -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,11 +68,47 @@ export default class ProfitLoss extends Component {
api.create().getDetailReportMB(payload).then(response => {
console.log(response);
let dataTable = []
let res = response.data.data
console.log(res)
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
if (response.data) {
let res = response.data.data
console.log(res)
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
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,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year
])
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
......@@ -80,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,
......@@ -97,50 +134,18 @@ export default class ProfitLoss extends Component {
item.profit_loss.total_next_year,
item.profit_loss.total_more_year
])
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
})
this.setState({ dataTable, loading: false, buttonError: true })
} else {
this.setState({ dataTable, loading: false, buttonError: true })
}
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
this.setState({ dataTable, loading: false, buttonError: true })
})
}
......@@ -177,7 +182,7 @@ export default class ProfitLoss extends Component {
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
notes: String(i[6]),
notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
total_actual_before: String(i[7]),
january: String(i[8]),
february: String(i[9]),
......@@ -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,11 +313,14 @@ 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.setState({ buttonError: true, errorPreview: true })
}
this.state.dataTable.map(item => {
if (item[23].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(dataTable)
})
}
}
......@@ -383,17 +391,29 @@ 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
let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[tableMeta.rowIndex][2])
if (indexParent > 0) {
// console.log(indexParent)
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
let jagain = dataTable2[indexParent][tableMeta.columnIndex]
a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
} else {
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)
// let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// let jagain = dataTable2[indexParent][tableMeta.columnIndex]
// a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (Number(jagain) + Number(val))
// } else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// }
let total = 0
dataTable2[tableMeta.rowIndex].map((item,index) => {
if (index >= 8 && index <= 19) {
let valItem = item == undefined || item == ""? 0 : item
total += Number(valItem)
}
})
dataTable2[tableMeta.rowIndex][20] = total
}
}
const handleNotes = (value, tableMeta) => {
......@@ -484,7 +504,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 +542,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 +579,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 +590,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 +600,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 +703,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 +792,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 +881,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 +970,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 +1059,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 +1148,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 +1237,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 +1326,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 +1415,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 +1504,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 +1593,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 +1682,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 +1771,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 +1860,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 +2053,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 +2087,11 @@ export default class ProfitLoss extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.props.onClickClose()
}}
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 +2147,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 +2161,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 +2175,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 +2197,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()
......
......@@ -1170,7 +1170,7 @@ export default class BalanceSheet extends Component {
</div>
</div>
<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}
......
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