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

Merge branch 'didam' into 'master'

apdet

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