Commit ce348de5 authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

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

parents cfacb929 8880ed33
......@@ -1686,8 +1686,28 @@ export default class BalanceSheet extends Component {
customBodyRender: (value, tableMeta, updateValue) => {
return (
<div style={{ width: 96, textAlign: 'right' }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : tableMeta.rowData[0] === 2 ?
{tableMeta.rowData[0] === 3 ?
<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={Number(value).toFixed(1)}
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}
......@@ -1697,17 +1717,46 @@ export default class BalanceSheet extends Component {
disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span> :
<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={Number(handleTotal(tableMeta)).toFixed(1)}
/>
</span>}
</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={Number(handleFormula(value, tableMeta)).toFixed(1)}
/>
:
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={Number(handleFormula(value, tableMeta)).toFixed(1)}
/>
:
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>
)
}
......@@ -2161,7 +2210,7 @@ export default class BalanceSheet extends Component {
this.uploadBalanceSheet('draft')
}, 100);
})}
style={{ marginRight: 20}}
style={{ 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 as Draft</Typography>
......
......@@ -74,7 +74,9 @@ export default class CorporateAnnualTarget extends Component {
buttonError: true,
// formulaYTDList: null,,
dataDelete: [],
dataReal: []
dataReal: [],
buttonDraft: true,
updateBy: ''
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -82,10 +84,11 @@ export default class CorporateAnnualTarget extends Component {
componentDidMount() {
this.getItemHierarki()
this.getLatestUpdate()
console.log(this.props);
this.getKPIType(
this.getKPIType()
this.getMaxAch()
)
}
getItemHierarki() {
......@@ -118,22 +121,22 @@ export default class CorporateAnnualTarget extends Component {
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,
item.cat.march,
item.cat.april,
item.cat.may,
item.cat.june,
item.cat.july,
item.cat.august,
item.cat.september,
item.cat.october,
item.cat.november,
item.cat.december,
item.cat.total_current_year,
item.cat.total_next_year,
item.cat.total_more_year,
item.cat.total_actual_before == ""? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1),
item.cat.january == ""? item.cat.january : String(item.cat.january).indexOf(".") == -1? Number(item.cat.january) : Number(item.cat.january).toFixed(1),
item.cat.february == ""? item.cat.february : String(item.cat.february).indexOf(".") == -1? Number(item.cat.february) : Number(item.cat.february).toFixed(1),
item.cat.march == ""? item.cat.march : String(item.cat.march).indexOf(".") == -1? Number(item.cat.march) : Number(item.cat.march).toFixed(1),
item.cat.april == ""? item.cat.april : String(item.cat.april).indexOf(".") == -1? Number(item.cat.april) : Number(item.cat.april).toFixed(1),
item.cat.may == ""? item.cat.may : String(item.cat.may).indexOf(".") == -1? Number(item.cat.may) : Number(item.cat.may).toFixed(1),
item.cat.june == ""? item.cat.june : String(item.cat.june).indexOf(".") == -1? Number(item.cat.june) : Number(item.cat.june).toFixed(1),
item.cat.july == ""? item.cat.july : String(item.cat.july).indexOf(".") == -1? Number(item.cat.july) : Number(item.cat.july).toFixed(1),
item.cat.august == ""? item.cat.august : String(item.cat.august).indexOf(".") == -1? Number(item.cat.august) : Number(item.cat.august).toFixed(1),
item.cat.september == ""? item.cat.september : String(item.cat.september).indexOf(".") == -1? Number(item.cat.september) : Number(item.cat.september).toFixed(1),
item.cat.october == ""? item.cat.october : String(item.cat.october).indexOf(".") == -1? Number(item.cat.october) : Number(item.cat.october).toFixed(1),
item.cat.november == ""? item.cat.november : String(item.cat.november).indexOf(".") == -1? Number(item.cat.november) : Number(item.cat.november).toFixed(1),
item.cat.december == ""? item.cat.december : String(item.cat.december).indexOf(".") == -1? Number(item.cat.december) : Number(item.cat.december).toFixed(1),
item.cat.total_current_year == ""? item.cat.total_current_year : String(item.cat.total_current_year).indexOf(".") == -1? Number(item.cat.total_current_year) : Number(item.cat.total_current_year).toFixed(1),
item.cat.total_next_year == ""? item.cat.total_next_year : String(item.cat.total_next_year).indexOf(".") == -1? Number(item.cat.total_next_year) : Number(item.cat.total_next_year).toFixed(1),
item.cat.total_more_year == ""? item.cat.total_more_year : String(item.cat.total_more_year).indexOf(".") == -1? Number(item.cat.total_more_year) : Number(item.cat.total_more_year).toFixed(1),
item.cat.strategic,
item.cat.pic
])
......@@ -160,22 +163,22 @@ export default class CorporateAnnualTarget extends Component {
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,
item.cat.march,
item.cat.april,
item.cat.may,
item.cat.june,
item.cat.july,
item.cat.august,
item.cat.september,
item.cat.october,
item.cat.november,
item.cat.december,
item.cat.total_current_year,
item.cat.total_next_year,
item.cat.total_more_year,
item.cat.total_actual_before == ""? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1),
item.cat.january == ""? item.cat.january : String(item.cat.january).indexOf(".") == -1? Number(item.cat.january) : Number(item.cat.january).toFixed(1),
item.cat.february == ""? item.cat.february : String(item.cat.february).indexOf(".") == -1? Number(item.cat.february) : Number(item.cat.february).toFixed(1),
item.cat.march == ""? item.cat.march : String(item.cat.march).indexOf(".") == -1? Number(item.cat.march) : Number(item.cat.march).toFixed(1),
item.cat.april == ""? item.cat.april : String(item.cat.april).indexOf(".") == -1? Number(item.cat.april) : Number(item.cat.april).toFixed(1),
item.cat.may == ""? item.cat.may : String(item.cat.may).indexOf(".") == -1? Number(item.cat.may) : Number(item.cat.may).toFixed(1),
item.cat.june == ""? item.cat.june : String(item.cat.june).indexOf(".") == -1? Number(item.cat.june) : Number(item.cat.june).toFixed(1),
item.cat.july == ""? item.cat.july : String(item.cat.july).indexOf(".") == -1? Number(item.cat.july) : Number(item.cat.july).toFixed(1),
item.cat.august == ""? item.cat.august : String(item.cat.august).indexOf(".") == -1? Number(item.cat.august) : Number(item.cat.august).toFixed(1),
item.cat.september == ""? item.cat.september : String(item.cat.september).indexOf(".") == -1? Number(item.cat.september) : Number(item.cat.september).toFixed(1),
item.cat.october == ""? item.cat.october : String(item.cat.october).indexOf(".") == -1? Number(item.cat.october) : Number(item.cat.october).toFixed(1),
item.cat.november == ""? item.cat.november : String(item.cat.november).indexOf(".") == -1? Number(item.cat.november) : Number(item.cat.november).toFixed(1),
item.cat.december == ""? item.cat.december : String(item.cat.december).indexOf(".") == -1? Number(item.cat.december) : Number(item.cat.december).toFixed(1),
item.cat.total_current_year == ""? item.cat.total_current_year : String(item.cat.total_current_year).indexOf(".") == -1? Number(item.cat.total_current_year) : Number(item.cat.total_current_year).toFixed(1),
item.cat.total_next_year == ""? item.cat.total_next_year : String(item.cat.total_next_year).indexOf(".") == -1? Number(item.cat.total_next_year) : Number(item.cat.total_next_year).toFixed(1),
item.cat.total_more_year == ""? item.cat.total_more_year : String(item.cat.total_more_year).indexOf(".") == -1? Number(item.cat.total_more_year) : Number(item.cat.total_more_year).toFixed(1),
item.cat.strategic,
item.cat.pic
])
......@@ -221,7 +224,7 @@ export default class CorporateAnnualTarget extends Component {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'CAT.xlsx';
a.download = 'Master Budget CAT.xlsx';
a.click();
}
}
......@@ -241,12 +244,12 @@ export default class CorporateAnnualTarget extends Component {
isi.map((i, index) => {
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_id: i[0] === undefined ? "" : reg.test(String(i[0])) === false ? "" : 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(),
formula: i[5] === undefined ? "" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
weight: i[2] === undefined ? "" : reg.test(String(i[2])) === false ? "" : String(i[2]).trim(),
uom: i[3] === undefined ? "" : reg.test(String(i[3])) === false ? "" : String(i[3]).trim(),
kpi_type: i[4] === undefined ? "" : reg.test(String(i[4])) === false ? "" : String(i[4]).trim(),
formula: i[5] === undefined ? "" : reg.test(String(i[5])) === false ? "" : String(i[5]).trim(),
total_actual_before: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
january: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
february: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
......@@ -263,8 +266,8 @@ export default class CorporateAnnualTarget extends Component {
total_current_year: i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[19]).trim(),
total_next_year: i[20] === undefined ? "0" : reg.test(String(i[20])) === false ? "0" : String(i[20]).trim(),
total_more_year: i[21] === undefined ? "0" : reg.test(String(i[21])) === false ? "0" : String(i[21]).trim(),
strategic: i[22] === undefined ? "0" : reg.test(String(i[22])) === false ? "0" : String(i[22]).trim(),
pic: i[23] === undefined ? "0" : reg.test(String(i[23])) === false ? "0" : String(i[23]).trim()
strategic: i[22] === undefined ? "" : reg.test(String(i[22])) === false ? "" : String(i[22]).trim(),
pic: i[23] === undefined ? "" : reg.test(String(i[23])) === false ? "" : String(i[23]).trim()
})
}
})
......@@ -297,27 +300,27 @@ export default class CorporateAnnualTarget extends Component {
item.level,
"",
item.item_report,
item.weight,
item.type_report_id == 1? `${Number(item.weight) * 100}%` : 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.kpi_type == "" || item.kpi_type == null? null : {value: item.kpi_type},
item.max_ach == "" || item.max_ach == null? null : {value: item.max_ach},
item.formula == "" || item.formula == null? null : {value: item.formula},
item.total_actual_before == ""? item.total_actual_before : String(item.total_actual_before).indexOf(".") == -1? Number(item.total_actual_before) : Number(item.total_actual_before).toFixed(1),
item.january == ""? item.january : String(item.january).indexOf(".") == -1? Number(item.january) : Number(item.january).toFixed(1),
item.february == ""? item.february : String(item.february).indexOf(".") == -1? Number(item.february) : Number(item.february).toFixed(1),
item.march == ""? item.march : String(item.march).indexOf(".") == -1? Number(item.march) : Number(item.march).toFixed(1),
item.april == ""? item.april : String(item.april).indexOf(".") == -1? Number(item.april) : Number(item.april).toFixed(1),
item.may == ""? item.may : String(item.may).indexOf(".") == -1? Number(item.may) : Number(item.may).toFixed(1),
item.june == ""? item.june : String(item.june).indexOf(".") == -1? Number(item.june) : Number(item.june).toFixed(1),
item.july == ""? item.july : String(item.july).indexOf(".") == -1? Number(item.july) : Number(item.july).toFixed(1),
item.august == ""? item.august : String(item.august).indexOf(".") == -1? Number(item.august) : Number(item.august).toFixed(1),
item.september == ""? item.september : String(item.september).indexOf(".") == -1? Number(item.september) : Number(item.september).toFixed(1),
item.october == ""? item.october : String(item.october).indexOf(".") == -1? Number(item.october) : Number(item.october).toFixed(1),
item.november == ""? item.november : String(item.november).indexOf(".") == -1? Number(item.november) : Number(item.november).toFixed(1),
item.december == ""? item.december : String(item.december).indexOf(".") == -1? Number(item.december) : Number(item.december).toFixed(1),
item.total_current_year == ""? item.total_current_year : String(item.total_current_year).indexOf(".") == -1? Number(item.total_current_year) : Number(item.total_current_year).toFixed(1),
item.total_next_year == ""? item.total_next_year : String(item.total_next_year).indexOf(".") == -1? Number(item.total_next_year) : Number(item.total_next_year).toFixed(1),
item.total_more_year == ""? item.total_more_year : String(item.total_more_year).indexOf(".") == -1? Number(item.total_more_year) : Number(item.total_more_year).toFixed(1),
item.strategic,
item.pic,
item.error
......@@ -339,7 +342,7 @@ export default class CorporateAnnualTarget extends Component {
})
}
uploadCAT() {
uploadCAT(type) {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
......@@ -377,10 +380,11 @@ export default class CorporateAnnualTarget extends Component {
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID,
// "status": "submitted",
"status": type,
"cat": data
}
console.log(data);
console.log(JSON.stringify(body))
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
console.log(response);
if (response.data) {
......@@ -626,6 +630,25 @@ export default class CorporateAnnualTarget extends Component {
})
}
getLatestUpdate() {
let payload = {
"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
}
api.create().getLastestUpdateMB(payload).then(response => {
if (response.data) {
if (response.data.status === "success") {
this.setState({
updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update
})
}
}
})
}
render() {
let dataTable2 = this.state.dataTable
let dataDelete = this.state.dataDelete
......@@ -809,7 +832,7 @@ export default class CorporateAnnualTarget extends Component {
name: "",
options: {
filter: false,
display: this.state.visibleCAT,
// display: this.state.visibleCAT,
customHeadRender: (columnMeta) => (
<TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#dbdbdb'}}>
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
......@@ -896,40 +919,36 @@ export default class CorporateAnnualTarget extends Component {
<div style={{ width: 300 }}>
{tableMeta.rowData[22] ?
tableMeta.rowData[22].length > 0 ?
tableMeta.rowData[22][0].field === 'item' ?
tableMeta.rowData[4] == 0 ?
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
</a>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</a>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<LightTooltip title={"Report Items Not Registered"} arrow>
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</LightTooltip>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
tableMeta.rowData[1] == null?
<div style={{ paddingLeft: 20}}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
tableMeta.rowData[1] == null?
<div style={{ paddingLeft: 20}}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
}
<ReactTooltip border={true} id="account" place="bottom" type="light" effect="solid" />
</div>
)
}
......@@ -1140,7 +1159,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "2020",
name: `${Number(this.props.periode) - 1}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -1164,6 +1183,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1179,7 +1199,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Jan 2021",
name: `Jan ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1203,6 +1223,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1218,7 +1239,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Feb 2021",
name: `Feb ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1242,6 +1263,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1257,7 +1279,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Mar 2021",
name: `Mar ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1281,6 +1303,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1296,7 +1319,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Apr 2021",
name: `Apr ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1320,6 +1343,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1335,7 +1359,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "May 2021",
name: `May ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1359,6 +1383,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1374,7 +1399,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Jun 2021",
name: `Jun ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1398,6 +1423,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1413,7 +1439,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Jul 2021",
name: `Jul ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1437,6 +1463,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1452,7 +1479,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Aug 2021",
name: `Aug ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1476,6 +1503,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1491,7 +1519,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Sep 2021",
name: `Sep ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1514,6 +1542,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
decimalScale={1}
value={value}
onBlur={(event) => {
// updateValue(event.target.value)
......@@ -1530,7 +1559,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Oct 2021",
name: `Oct ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1554,6 +1583,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1569,7 +1599,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Nop 2021",
name: `Nop ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1593,6 +1623,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1608,7 +1639,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "Dec 2021",
name: `Dec ${this.props.periode}`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1632,6 +1663,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1647,7 +1679,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "2021 Total",
name: `${this.props.periode} Total`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1669,6 +1701,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
disabled={true}
// onBlur={(event) => {
// // updateValue(event.target.value)
......@@ -1684,7 +1717,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "2022 Total",
name: `${Number(this.props.periode) + 1} Total`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1708,6 +1741,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1723,7 +1757,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
}, {
name: "2023 Total",
name: `${Number(this.props.periode) + 2} Total`,
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
......@@ -1747,6 +1781,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
value={value}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1855,7 +1890,7 @@ export default class CorporateAnnualTarget extends Component {
return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Pengajuan Budget Tahunan</Typography>
<Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
</div>
{/* {this.state.loading && loadingComponent} */}
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
......@@ -1866,7 +1901,7 @@ export default class CorporateAnnualTarget extends Component {
<div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleCAT? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Corporate Annual Target</Typography>
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget Submission - Corporate Annual Target</Typography>
</div>
<div style={{ padding: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
......@@ -1938,6 +1973,7 @@ export default class CorporateAnnualTarget extends Component {
/>
</MuiThemeProvider>
</div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
</div>
<div className="grid grid-2x">
<div className="col-1">
......@@ -1949,10 +1985,14 @@ export default class CorporateAnnualTarget extends Component {
cursor: 'pointer',
borderColor: 'transparent',
}}
onClick={() => this.backToMasterBudget('draft')}
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100)})}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div>
......@@ -1967,14 +2007,16 @@ export default class CorporateAnnualTarget extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
onClick={() =>
this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false}, () => {
setTimeout(() => {
this.handleValidate()
}, 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>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
......@@ -1987,16 +2029,12 @@ export default class CorporateAnnualTarget extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true, dataTable: dataTable2}, () => {
setTimeout(() => {
this.handleValidate()
}, 100);
})
disabled={this.state.buttonDraft}
onClick={() => { this.backToMasterBudget('draft')
}}
>
<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 as Draft</Typography>
</div>
</button>
<button
......@@ -2013,7 +2051,7 @@ export default class CorporateAnnualTarget extends Component {
}}
>
<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' }}>Save & Complete</Typography>
</div>
</button>
</div>
......@@ -2030,66 +2068,89 @@ export default class CorporateAnnualTarget extends Component {
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
</MuiThemeProvider>
</div>
)}
</div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button
type="button"
onClick={() => this.setState({ loading: true, visibleCAT: 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' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.buttonError}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
<div className="grid grid-2x">
<div className="col-1">
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
onClick={() =>
this.setState({ loading: true, visibleCAT: true }, () => {
setTimeout(() => {
this.getItemHierarki()
}, 100)
})}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
type="button"
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
}, 100)
})
}
style={{ marginRight: 20 }}
>
<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' }}>Calculate</Typography>
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.buttonError}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
this.uploadCAT("draft")
}, 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.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadCAT()
}, 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' }}>Save</Typography>
</div>
</button>
})}
>
<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 as Draft</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadCAT("submitted")
}, 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' }}>Save & Complete</Typography>
</div>
</button>
</div>
</div>
</div>
</Paper>}
......
......@@ -46,7 +46,8 @@ export default class FixedAssetsMovement extends Component {
disabledSave: true,
editable: false,
buttonError: false,
judulColumn: null
judulColumn: null,
updateBy: '-'
}
this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this);
......@@ -54,9 +55,29 @@ export default class FixedAssetsMovement extends Component {
componentDidMount() {
this.getItemHierarki()
this.getLatestUpdate()
console.log(this.props);
}
getLatestUpdate() {
let payload = {
"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
}
api.create().getLastestUpdateMB(payload).then(response => {
if (response.data) {
if (response.data.status === "success") {
this.setState({
updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update
})
}
}
})
}
getItemHierarki() {
this.setState({ loading: true })
let payload = {
......@@ -180,22 +201,22 @@ export default class FixedAssetsMovement extends Component {
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])
total_actual_before: String(Number(i[6]).toFixed(1)),
january: String(Number(i[7]).toFixed(1)),
february: String(Number(i[8]).toFixed(1)),
march: String(Number(i[9]).toFixed(1)),
april: String(Number(i[10]).toFixed(1)),
may: String(Number(i[11]).toFixed(1)),
june: String(Number(i[12]).toFixed(1)),
july: String(Number(i[13]).toFixed(1)),
august: String(Number(i[14]).toFixed(1)),
september: String(Number(i[15]).toFixed(1)),
october: String(Number(i[16]).toFixed(1)),
november: String(Number(i[17]).toFixed(1)),
december: String(Number(i[18]).toFixed(1)),
total_current_year: String(Number(i[19]).toFixed(1)),
total_next_year: String(Number(i[20]).toFixed(1)),
total_more_year: String(Number(i[21]).toFixed(1))
})
})
......@@ -207,7 +228,7 @@ export default class FixedAssetsMovement extends Component {
"status": type,
"fixed_asset_movement": data
}
console.log(data);
// console.log(data);
this.props.saveToMasterBudget(payload)
this.props.onClickClose()
}
......@@ -222,7 +243,7 @@ export default class FixedAssetsMovement extends Component {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Template Fixed Assets Movement.xlsx';
a.download = 'Template Master Budget Fixed Assets Movement.xlsx';
a.click();
}
}
......@@ -264,10 +285,12 @@ export default class FixedAssetsMovement extends Component {
}
})
let body = {
submission_id: this.props.submissionID,
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
fixed_asset_movement: payload
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
......@@ -370,7 +393,8 @@ export default class FixedAssetsMovement extends Component {
}
async downloadAllData() {
console.log(this.props)
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
console.log(url);
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
)
......@@ -380,45 +404,45 @@ export default class FixedAssetsMovement extends Component {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Fixed Assets Movement.xlsx';
a.download = 'Master Budget Fixed Assets Movement.xlsx';
a.click();
}
}
handleValidate() {
let data = []
// console.log(this.state.dataTable)
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])
january: i[0] === 3 && i[7] === "" ? "0" : String(i[7]),
february: i[0] === 3 && i[8] === "" ? "0" : String(i[8]),
march: i[0] === 3 && i[9] === "" ? "0" : String(i[9]),
april: i[0] === 3 && i[10] === "" ? "0" : String(i[10]),
may: i[0] === 3 && i[11] === "" ? "0" : String(i[11]),
june: i[0] === 3 && i[12] === "" ? "0" : String(i[12]),
july: i[0] === 3 && i[13] === "" ? "0" : String(i[13]),
august: i[0] === 3 && i[14] === "" ? "0" : String(i[14]),
september: i[0] === 3 && i[15] === "" ? "0" : String(i[15]),
october: i[0] === 3 && i[16] === "" ? "0" : String(i[16]),
november: i[0] === 3 && i[17] === "" ? "0" : String(i[17]),
december: i[0] === 3 && i[18] === "" ? "0" : String(i[18]),
total_current_year: i[0] === 3 && i[19] === "" ? "0" : String(i[19]),
total_next_year: i[0] === 3 && i[20] === "" ? "0" : String(i[20]),
total_more_year: i[0] === 3 && i[21] === "" ? "0" : String(i[21])
})
})
// 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,
fixed_asset_movement: data,
status: "submitted"
"submission_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"fixed_asset_movement": data,
"status": "submitted"
}
console.log(payload)
// console.log(payload)
api.create().validateSubmitReport(payload).then((response) => {
console.log(response)
if (response.data.data.result) {
......@@ -609,7 +633,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={value}
value={Number(value).toFixed(1)}
/>
}
/>
......@@ -642,7 +666,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
......@@ -659,7 +683,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -730,7 +754,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -748,7 +772,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -819,7 +843,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -837,7 +861,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -908,7 +932,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -926,7 +950,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -997,7 +1021,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1015,7 +1039,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1086,7 +1110,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1104,7 +1128,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1175,7 +1199,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1193,7 +1217,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1264,7 +1288,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1282,7 +1306,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1353,7 +1377,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1371,7 +1395,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1442,7 +1466,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1460,7 +1484,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1531,7 +1555,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1549,7 +1573,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1620,7 +1644,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1638,7 +1662,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1707,7 +1731,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span> :
<span style={{ fontSize: 12, textAlign: 'right' }}>
......@@ -1717,7 +1741,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleTotal(tableMeta)}
value={Number(handleTotal(tableMeta)).toFixed(1)}
/>
</span>}
</div>
......@@ -1747,7 +1771,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1765,7 +1789,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1836,7 +1860,7 @@ export default class FixedAssetsMovement extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1854,7 +1878,7 @@ export default class FixedAssetsMovement extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1918,19 +1942,19 @@ export default class FixedAssetsMovement extends Component {
return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Pengajuan Budget Tahunan</Typography>
<Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
</div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.loading && loadingComponent}
{/* {this.state.loading && loadingComponent} */}
<div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleFixedAssetsMovement === true ?
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Budget Tahunan - Fixed Assets Movement</Typography>
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Fixed Assets Movement</Typography>
</div>
<div style={{ padding: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
......@@ -1993,43 +2017,19 @@ export default class FixedAssetsMovement extends Component {
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
</MuiThemeProvider>
</div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button
type="button"
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',
borderColor: 'transparent',
outline: 'none'
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%'}}>
<button
className="button"
type="button"
......@@ -2046,10 +2046,12 @@ export default class FixedAssetsMovement extends Component {
}, 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 style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%'}}>
<button
className="button"
type="button"
......@@ -2073,6 +2075,32 @@ export default class FixedAssetsMovement extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
className="button"
type="button"
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',
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 as Draft</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
......@@ -2110,13 +2138,14 @@ export default class FixedAssetsMovement extends Component {
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
</MuiThemeProvider>
</div>
)}
</div>
......
......@@ -3,8 +3,6 @@ import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormCon
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
import api from '../../api';
import AddIcon from '@material-ui/icons/Add';
import { values, type } from 'ramda';
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
......@@ -46,7 +44,8 @@ export default class ProfitLoss extends Component {
disabledSave: true,
editable: false,
buttonError: false,
judulColumn: null
judulColumn: null,
updateBy: '-'
}
this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this);
......@@ -54,9 +53,29 @@ export default class ProfitLoss extends Component {
componentDidMount() {
this.getItemHierarki()
this.getLatestUpdate()
console.log(this.props);
}
getLatestUpdate() {
let payload = {
"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
}
api.create().getLastestUpdateMB(payload).then(response => {
if (response.data) {
if (response.data.status === "success") {
this.setState({
updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update
})
}
}
})
}
getItemHierarki() {
this.setState({ loading: true, judulColumn: null })
let payload = {
......@@ -71,7 +90,6 @@ export default class ProfitLoss extends Component {
let dataTable = []
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) {
......@@ -184,22 +202,22 @@ export default class ProfitLoss extends Component {
data.push({
item_report_id: i[1],
notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
total_actual_before: String(i[7]),
january: String(i[8]),
february: String(i[9]),
march: String(i[10]),
april: String(i[11]),
may: String(i[12]),
june: String(i[13]),
july: String(i[14]),
august: String(i[15]),
september: String(i[16]),
october: String(i[17]),
november: String(i[18]),
december: String(i[19]),
total_current_year: String(i[20]),
total_next_year: String(i[21]),
total_more_year: String(i[22])
total_actual_before: String(Number(i[7]).toFixed(1)),
january: String(Number(i[8]).toFixed(1)),
february: String(Number(i[9]).toFixed(1)),
march: String(Number(i[10]).toFixed(1)),
april: String(Number(i[11]).toFixed(1)),
may: String(Number(i[12]).toFixed(1)),
june: String(Number(i[13]).toFixed(1)),
july: String(Number(i[14]).toFixed(1)),
august: String(Number(i[15]).toFixed(1)),
september: String(Number(i[16]).toFixed(1)),
october: String(Number(i[17]).toFixed(1)),
november: String(Number(i[18]).toFixed(1)),
december: String(Number(i[19]).toFixed(1)),
total_current_year: String(Number(i[20]).toFixed(1)),
total_next_year: String(Number(i[21]).toFixed(1)),
total_more_year: String(Number(i[22]).toFixed(1))
})
})
let payload = {
......@@ -210,7 +228,7 @@ export default class ProfitLoss extends Component {
"status": type,
"profit_loss": data
}
console.log(data);
// console.log(data);
this.props.saveToMasterBudget(payload)
this.props.onClickClose()
}
......@@ -225,7 +243,7 @@ export default class ProfitLoss extends Component {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Template Profit Loss.xlsx';
a.download = 'Template Master Budget Profit & Loss.xlsx';
a.click();
}
}
......@@ -321,35 +339,35 @@ export default class ProfitLoss extends Component {
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(dataTable)
// console.log(this.state.buttonError)
})
}
}
})
}
uploadProfitLoss() {
uploadProfitLoss(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
notes: String(i[6]),
total_actual_before: String(i[7]),
january: String(i[8]),
february: String(i[9]),
march: String(i[10]),
april: String(i[11]),
may: String(i[12]),
june: String(i[13]),
july: String(i[14]),
august: String(i[15]),
september: String(i[16]),
october: String(i[17]),
november: String(i[18]),
december: String(i[19]),
total_current_year: String(i[20]),
total_next_year: String(i[21]),
total_more_year: String(i[22])
total_actual_before: String(Number(i[7]).toFixed(1)),
january: String(Number(i[8]).toFixed(1)),
february: String(Number(i[9]).toFixed(1)),
march: String(Number(i[10]).toFixed(1)),
april: String(Number(i[11]).toFixed(1)),
may: String(Number(i[12]).toFixed(1)),
june: String(Number(i[13]).toFixed(1)),
july: String(Number(i[14]).toFixed(1)),
august: String(Number(i[15]).toFixed(1)),
september: String(Number(i[16]).toFixed(1)),
october: String(Number(i[17]).toFixed(1)),
november: String(Number(i[18]).toFixed(1)),
december: String(Number(i[19]).toFixed(1)),
total_current_year: String(Number(i[20]).toFixed(1)),
total_next_year: String(Number(i[21]).toFixed(1)),
total_more_year: String(Number(i[22]).toFixed(1)),
})
})
let body = {
......@@ -357,10 +375,10 @@ export default class ProfitLoss extends Component {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
profit_loss: data
profit_loss: data,
status: type
}
console.log(data);
// console.log(JSON.stringify(body));
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
console.log(response);
if (response.data) {
......@@ -371,15 +389,17 @@ export default class ProfitLoss extends Component {
alert(response.data.status)
}
} else {
alert(response.problem)
this.setState({loading: false})
this.props.onClickClose()
this.props.getReport()
alert(response.problem)
// this.props.onClickClose()
// this.props.getReport()
}
})
}
async downloadAllData() {
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
console.log(url);
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
)
......@@ -389,33 +409,34 @@ export default class ProfitLoss extends Component {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Profit Loss.xlsx';
a.download = 'Master Budget Profit & Loss.xlsx';
a.click();
}
}
handleValidate() {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
total_actual_before: String(i[7]),
january: String(i[8]),
february: String(i[9]),
march: String(i[10]),
april: String(i[11]),
may: String(i[12]),
june: String(i[13]),
july: String(i[14]),
august: String(i[15]),
september: String(i[16]),
october: String(i[17]),
november: String(i[18]),
december: String(i[19]),
total_current_year: String(i[20]),
total_next_year: String(i[21]),
total_more_year: String(i[22])
january: i[0] === 3 && i[8] === "" ? "0" : String(i[8]),
february: i[0] === 3 && i[9] === "" ? "0" : String(i[9]),
march: i[0] === 3 && i[10] === "" ? "0" : String(i[10]),
april: i[0] === 3 && i[11] === "" ? "0" : String(i[11]),
may: i[0] === 3 && i[12] === "" ? "0" : String(i[12]),
june: i[0] === 3 && i[13] === "" ? "0" : String(i[13]),
july: i[0] === 3 && i[14] === "" ? "0" : String(i[14]),
august: i[0] === 3 && i[15] === "" ? "0" : String(i[15]),
september: i[0] === 3 && i[16] === "" ? "0" : String(i[16]),
october: i[0] === 3 && i[17] === "" ? "0" : String(i[17]),
november: i[0] === 3 && i[18] === "" ? "0" : String(i[18]),
december: i[0] === 3 && i[19] === "" ? "0" : String(i[19]),
total_current_year: i[0] === 3 && i[20] === "" ? "0" : String(i[20]),
total_next_year: i[0] === 3 && i[21] === "" ? "0" : String(i[21]),
total_more_year: i[0] === 3 && i[22] === "" ? "0" : String(i[22])
})
})
let payload = {
......@@ -423,9 +444,10 @@ export default class ProfitLoss extends Component {
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"profit_loss": data
"profit_loss": data,
"status": "submitted"
}
console.log(payload)
api.create().validateSubmitReport(payload).then((response) => {
console.log(response)
if (response.data.data.result) {
......@@ -436,11 +458,14 @@ export default class ProfitLoss extends Component {
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
let dataTable2 = this.state.dataTable
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 {
......@@ -464,8 +489,15 @@ export default class ProfitLoss extends Component {
total += Number(valItem)
}
})
dataTable2[tableMeta.rowIndex][20] = total
return total
if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "sales price" ) {
dataTable2[tableMeta.rowIndex][20] = Number(dataTable2[tableMeta.rowIndex - 2][20]) / Number(dataTable2[tableMeta.rowIndex - 1][20])
let value = Number(dataTable2[tableMeta.rowIndex - 2][20]) / Number(dataTable2[tableMeta.rowIndex - 1][20])
return value
} else {
dataTable2[tableMeta.rowIndex][20] = total
return total
}
// console.log(total);
}
const handleNotes = (value, tableMeta) => {
......@@ -656,7 +688,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={value}
value={Number(value).toFixed(1)}
/>
}
/>
......@@ -689,7 +721,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
......@@ -706,7 +738,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -777,7 +809,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -795,7 +827,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -866,7 +898,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -884,7 +916,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -955,7 +987,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -973,7 +1005,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1044,7 +1076,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1062,7 +1094,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1133,7 +1165,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1151,7 +1183,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1222,7 +1254,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1240,7 +1272,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1311,7 +1343,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1329,7 +1361,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1400,7 +1432,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1418,7 +1450,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1489,7 +1521,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1507,7 +1539,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1578,7 +1610,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1596,7 +1628,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1667,7 +1699,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1685,7 +1717,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1754,7 +1786,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span> :
<span style={{ fontSize: 12, textAlign: 'right' }}>
......@@ -1764,7 +1796,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleTotal(tableMeta)}
value={Number(handleTotal(tableMeta)).toFixed(1)}
/>
</span>}
</div>
......@@ -1794,7 +1826,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1812,7 +1844,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1883,7 +1915,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1901,7 +1933,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={handleValue(tableMeta)}
value={Number(handleValue(tableMeta)).toFixed(1)}
/>
</span>
:
......@@ -1971,25 +2003,25 @@ export default class ProfitLoss extends Component {
return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Pengajuan Budget Tahunan</Typography>
<Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
</div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.loading && loadingComponent}
{/* {this.state.loading && loadingComponent} */}
<div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleProfitLoss === true ?
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Budget Tahunan - Profit & Loss </Typography>
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Profit & Loss </Typography>
</div>
<div style={{ padding: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ width: '50%' }}>
......@@ -2046,30 +2078,26 @@ export default class ProfitLoss extends Component {
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
</MuiThemeProvider>
</div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button
type="button"
onClick={() => this.state.editable === true ?
this.setState({ loading: true }, () => {
setTimeout(() => {
this.backToMasterBudget('draft')
}, 100);
}) :
this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
......@@ -2078,7 +2106,7 @@ export default class ProfitLoss extends Component {
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div>
......@@ -2093,14 +2121,16 @@ export default class ProfitLoss extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.handleValidate()
}, 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>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
......@@ -2113,24 +2143,34 @@ export default class ProfitLoss extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true}, () => {
onClick={() => this.state.editable === true ?
this.setState({ loading: true }, () => {
setTimeout(() => {
this.handleValidate()
this.backToMasterBudget('draft')
}, 100);
})
}}
}) :
this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 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>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() => this.state.buttonError?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
: this.backToMasterBudget('submitted')}
disabled={this.state.buttonError}
onClick={() => {
this.state.buttonError ?
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning', loading: false })
}, 100);
})
: this.backToMasterBudget('submitted')
}}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
......@@ -2139,7 +2179,7 @@ export default class ProfitLoss extends Component {
}}
>
<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' }}>Save & Complate</Typography>
</div>
</button>
</div>
......@@ -2151,71 +2191,91 @@ export default class ProfitLoss extends Component {
<div style={{ padding: 25 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
<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) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
</MuiThemeProvider>
</div>
)}
</div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button
type="button"
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' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.buttonError}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button
type="button"
onClick={() => this.setState({ loading: true, visibleProfitLoss: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
this.getItemHierarki()
}, 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.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadProfitLoss()
}, 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' }}>Save</Typography>
</div>
</button>
})}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
className="button"
type="button"
// disabled={this.state.buttonError}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
}, 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' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadProfitLoss('draft')
}, 100);
})}
style={{ 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 as Draft</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadProfitLoss('submitted')
}, 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' }}>Save & Complete</Typography>
</div>
</button>
</div>
</div>
</div>
</Paper>}
......
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