Commit 34609fcd authored by Deni Rinaldi's avatar Deni Rinaldi

akhirnya bs bs

parent 6f1d5e77
......@@ -152,16 +152,16 @@ export default class BalanceSheetMR extends Component {
item.balance_sheet.master_budget === "" ? "0" : item.balance_sheet.master_budget,
item.balance_sheet.rolling_budget === "" ? "0" : item.balance_sheet.rolling_budget,
item.balance_sheet.actual === "" ? "0" : item.balance_sheet.actual,
item.balance_sheet.actual_previous_month === null ? "0.0" : item.balance_sheet.actual_previous_month === "" ? "0.0" : item.balance_sheet.actual_previous_month,
item.balance_sheet.actual_previous_month === null ? "100.0" : item.balance_sheet.actual_previous_month === "" ? "100.0" : item.balance_sheet.actual_previous_month,
item.balance_sheet.amount_act_vs_previous_month === "" ? "0" : item.balance_sheet.amount_act_vs_previous_month,
item.balance_sheet.percent_act_vs_previous_month === "" ? "0" : item.balance_sheet.percent_act_vs_previous_month,
item.balance_sheet.amount_act_vs_mb === "" ? "0" : item.balance_sheet.amount_act_vs_mb,
item.balance_sheet.percent_act_vs_mb === "" ? "0" : item.balance_sheet.percent_act_vs_mb,
item.balance_sheet.amount_act_vs_rb === "" ? "0" : item.balance_sheet.amount_act_vs_rb,
item.balance_sheet.percent_act_vs_rb === "" ? "0" : item.balance_sheet.percent_act_vs_rb,
item.balance_sheet.mtd_vs_previous_month === "" ? "-" : item.balance_sheet.mtd_vs_previous_month,
item.balance_sheet.mtd_vs_mb === "" ? "-" : item.balance_sheet.mtd_vs_mb,
item.balance_sheet.mtd_vs_rb === "" ? "-" : item.balance_sheet.mtd_vs_rb,
item.balance_sheet.mtd_vs_previous_month === null ? "" : item.balance_sheet.mtd_vs_previous_month,
item.balance_sheet.mtd_vs_mb === null ? "" : item.balance_sheet.mtd_vs_mb,
item.balance_sheet.mtd_vs_rb === null ? "" : item.balance_sheet.mtd_vs_rb,
item.balance_sheet.actual_formula,
item.order
])
......@@ -186,16 +186,16 @@ export default class BalanceSheetMR extends Component {
item.balance_sheet.master_budget === "" ? "0" : item.balance_sheet.master_budget,
item.balance_sheet.rolling_budget === "" ? "0" : item.balance_sheet.rolling_budget,
item.balance_sheet.actual === "" ? "0" : item.balance_sheet.actual,
item.balance_sheet.actual_previous_month === null ? "0.0" : item.balance_sheet.actual_previous_month === "" ? "0.0" : item.balance_sheet.actual_previous_month,
item.balance_sheet.actual_previous_month === null ? "100.0" : item.balance_sheet.actual_previous_month === "" ? "100.0" : item.balance_sheet.actual_previous_month,
item.balance_sheet.amount_act_vs_previous_month === "" ? "0" : item.balance_sheet.amount_act_vs_previous_month,
item.balance_sheet.percent_act_vs_previous_month === "" ? "0" : item.balance_sheet.percent_act_vs_previous_month,
item.balance_sheet.amount_act_vs_mb === "" ? "0" : item.balance_sheet.amount_act_vs_mb,
item.balance_sheet.percent_act_vs_mb === "" ? "0" : item.balance_sheet.percent_act_vs_mb,
item.balance_sheet.amount_act_vs_rb === "" ? "0" : item.balance_sheet.amount_act_vs_rb,
item.balance_sheet.percent_act_vs_rb === "" ? "0" : item.balance_sheet.percent_act_vs_rb,
item.balance_sheet.mtd_vs_previous_month === "" ? "-" : item.balance_sheet.mtd_vs_previous_month,
item.balance_sheet.mtd_vs_mb === "" ? "-" : item.balance_sheet.mtd_vs_mb,
item.balance_sheet.mtd_vs_rb === "" ? "-" : item.balance_sheet.mtd_vs_rb,
item.balance_sheet.mtd_vs_previous_month === null ? "" : item.balance_sheet.mtd_vs_previous_month,
item.balance_sheet.mtd_vs_mb === null ? "" : item.balance_sheet.mtd_vs_mb,
item.balance_sheet.mtd_vs_rb === null ? "" : item.balance_sheet.mtd_vs_rb,
item.balance_sheet.actual_formula,
item.order
])
......@@ -207,7 +207,7 @@ export default class BalanceSheetMR extends Component {
}
}
})
this.setState({ dataTable, loading: false })
this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
}
console.log(dataTable);
})
......@@ -323,11 +323,11 @@ export default class BalanceSheetMR extends Component {
]
})
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
this.state.dataTable.map(item => {
if (item[22].length > 0) {
// console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(this.state.buttonError)
......@@ -441,8 +441,8 @@ export default class BalanceSheetMR extends Component {
handleValidate() {
let data = []
// console.log(this.state.dataTable)
this.state.dataTable.map(i => {
let err = false
this.state.dataTable.map((i, index) => {
data.push({
"item_report_id": i[1],
"rolling_outlook": i[6],
......@@ -460,40 +460,59 @@ export default class BalanceSheetMR extends Component {
"mtd_vs_mb": i[18],
"mtd_vs_rb": i[19]
})
})
// console.log(JSON.stringify(data))
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": "submitted",
"months": this.props.month.month_id,
"balance_sheet": data
}
api.create().validateSubmitReportMR(payload).then((response) => {
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
} else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
if (i[17] === "" && (Number(i[12]) < this.state.minValue || Number(i[12]) > this.state.maxValue)) {
console.log('msk 1');
err = true
} else if (i[18] === "" && (Number(i[14]) < this.state.minValue || Number(i[14]) > this.state.maxValue)) {
console.log('msk 2');
err = true
} else if (i[19] === "" && (Number(i[16]) < this.state.minValue || Number(i[16]) > this.state.maxValue)) {
console.log('msk 3');
err = true
}
})
}
console.log(JSON.stringify(data));
if (err === true) {
console.log('error');
this.setState({ loading: false, buttonError: true, saveDraft: false })
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
console.log('g error');
this.setState({ loading: false, buttonError: false, saveDraft: false })
}
})
// console.log(JSON.stringify(data))
// let payload = {
// "monthly_report_id": this.props.monthlyReportId,
// "company_id": this.props.company.company_id,
// "periode": this.props.periode,
// "report_id": this.props.report_id,
// "status": "submitted",
// "months": this.props.month.month_id,
// "balance_sheet": data
// }
// api.create().validateSubmitReportMR(payload).then((response) => {
// console.log(response)
// if (response.data) {
// if (response.data.status === "success") {
// if (response.data.data.result) {
// this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
// } else {
// this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
// if (response.data.message.includes("Someone Logged In")) {
// setTimeout(() => {
// localStorage.removeItem(Constant.TOKEN)
// window.location.reload();
// }, 1000);
// }
// })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
// }
// })
}
render() {
......@@ -1278,23 +1297,6 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null :
Number(tableMeta.rowData[12]) <= this.state.minValue || Number(tableMeta.rowData[12]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: 'red', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleVariancePercent(tableMeta, 1, 3)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1302,7 +1304,7 @@ export default class BalanceSheetMR extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
suffix={'%'}
......@@ -1346,7 +1348,6 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null :
Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1354,23 +1355,7 @@ export default class BalanceSheetMR extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: 'red', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleVariancePercent(tableMeta, 2, 5)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
......@@ -1414,7 +1399,6 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null :
Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1422,23 +1406,7 @@ export default class BalanceSheetMR extends Component {
control={
<NumberFormat
thousandSeparator={true}
style={{ color: 'red', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleVariancePercent(tableMeta, 3, 7)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? 'red' : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
......@@ -1499,16 +1467,38 @@ export default class BalanceSheetMR extends Component {
style={{ margin: 0 }}
// value={value}
control={
tableMeta.rowData[17] === "" && (Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue) ?
<LightTooltip title={"MTD Explanation vs Prev Month is Reqiured"} arrow>
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[12]) <= this.state.minValue || Number(tableMeta.rowData[12]) >= this.state.maxValue ? false : true}
disabled={false}
defaultValue={tableMeta.rowData[17]}
inputProps={{
style: {
color: Number(tableMeta.rowData[12]) <= this.state.minValue || Number(tableMeta.rowData[12]) >= this.state.maxValue ? "#5198ea" : 'black',
color: "#5198ea",
textAlign: 'right',
backgroundColor: '#ffac99'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 17)
}}
/>
</LightTooltip>
:
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[17]}
inputProps={{
style: {
color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? "#5198ea" : 'black',
textAlign: 'right'
}
}}
......@@ -1529,16 +1519,38 @@ export default class BalanceSheetMR extends Component {
style={{ margin: 0 }}
// value={value}
control={
tableMeta.rowData[18] === "" && (Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue) ?
<LightTooltip title={"MTD Explanation vs MB is Reqiured"} arrow>
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ? false : true}
disabled={false}
defaultValue={tableMeta.rowData[18]}
inputProps={{
style: {
color: Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ? "#5198ea" : 'black',
color: "#5198ea",
textAlign: 'right',
backgroundColor: '#ffac99'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 18)
}}
/>
</LightTooltip>
:
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[18]}
inputProps={{
style: {
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : 'black',
textAlign: 'right'
}
}}
......@@ -1559,16 +1571,38 @@ export default class BalanceSheetMR extends Component {
style={{ margin: 0 }}
// value={value}
control={
tableMeta.rowData[19] === "" && (Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue) ?
<LightTooltip title={"MTD Explanation vs RB is Reqiured"} arrow>
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ? false : true}
disabled={false}
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ? "#5198ea" : 'black',
color: "#5198ea",
textAlign: 'right',
backgroundColor: '#ffac99'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 19)
}}
/>
</LightTooltip>
:
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? "#5198ea" : 'black',
textAlign: 'right'
}
}}
......@@ -1746,7 +1780,7 @@ export default class BalanceSheetMR extends Component {
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && (
{/* {!this.state.loading && ( */}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
......@@ -1754,7 +1788,7 @@ export default class BalanceSheetMR extends Component {
options={options}
/>
</MuiThemeProvider>
)}
{/* )} */}
</div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
......@@ -1871,7 +1905,7 @@ export default class BalanceSheetMR extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && (
{/* {!this.state.loading && ( */}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
......@@ -1879,7 +1913,7 @@ export default class BalanceSheetMR extends Component {
options={options}
/>
</MuiThemeProvider>
)}
{/* )} */}
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
......
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