Commit dad2004e authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-' into 'master'

+_+

See merge request !723
parents e20c9bd1 74d60c48
...@@ -10,6 +10,7 @@ import { PropagateLoader } from 'react-spinners'; ...@@ -10,6 +10,7 @@ import { PropagateLoader } from 'react-spinners';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import Constant from '../../library/Constant'; import Constant from '../../library/Constant';
import * as R from 'ramda';
const LightTooltip = withStyles((theme) => ({ const LightTooltip = withStyles((theme) => ({
tooltip: { tooltip: {
...@@ -44,13 +45,49 @@ export default class BalanceSheetMR extends Component { ...@@ -44,13 +45,49 @@ export default class BalanceSheetMR extends Component {
this.state = { this.state = {
dataTable: [], dataTable: [],
loading: true, loading: true,
visibleBSMR: true visibleBSMR: true,
valueThreshold: 0,
minValue: 0,
maxValue: 0
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
componentDidMount() { componentDidMount() {
this.getSettingControl()
}
getSettingControl() {
let body = {
group: 'THRESHOLD_VARIANCE',
company_id: this.props.company.company_id,
type: 'BALANCE_SHEET'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
this.setState({
minValue: response.data.data[0] ? response.data.data[0].min_value : -5,
maxValue: response.data.data[0] ? response.data.data[0].max_value : 5,
}, () => {
this.getItemHierarki() this.getItemHierarki()
})
} 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 })
}
})
} }
getItemHierarki() { getItemHierarki() {
...@@ -77,20 +114,20 @@ export default class BalanceSheetMR extends Component { ...@@ -77,20 +114,20 @@ export default class BalanceSheetMR extends Component {
item.formula, item.formula,
item.level, item.level,
item.description, item.description,
item.balance_sheet.rolling_outlook === null ? "1.0" : item.balance_sheet.rolling_outlook === "" ? "1.0" : item.balance_sheet.rolling_outlook, item.balance_sheet.rolling_outlook === null ? "0" : item.balance_sheet.rolling_outlook === "" ? "0" : item.balance_sheet.rolling_outlook,
item.balance_sheet.master_budget === "" ? "2.0" : item.balance_sheet.master_budget, item.balance_sheet.master_budget === "" ? "0" : item.balance_sheet.master_budget,
item.balance_sheet.rolling_budget === "" ? "3.0" : item.balance_sheet.rolling_budget, item.balance_sheet.rolling_budget === "" ? "0" : item.balance_sheet.rolling_budget,
item.balance_sheet.actual === "" ? "4.0" : item.balance_sheet.actual, item.balance_sheet.actual === "" ? "0" : item.balance_sheet.actual,
item.balance_sheet.actual_previous_month === null ? "5.0" : item.balance_sheet.actual_previous_month === "" ? "5.0" : item.balance_sheet.actual_previous_month, item.balance_sheet.actual_previous_month === null ? "0" : item.balance_sheet.actual_previous_month === "" ? "0" : item.balance_sheet.actual_previous_month,
item.balance_sheet.amount_act_vs_previous_month === "" ? "6.0" : item.balance_sheet.amount_act_vs_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 === "" ? "7.0" : item.balance_sheet.percent_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 === "" ? "8.0" : item.balance_sheet.amount_act_vs_mb, item.balance_sheet.amount_act_vs_mb === "" ? "0" : item.balance_sheet.amount_act_vs_mb,
item.balance_sheet.percent_act_vs_mb === "" ? "9.0" : item.balance_sheet.percent_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 === "" ? "10.0" : item.balance_sheet.amount_act_vs_rb, item.balance_sheet.amount_act_vs_rb === "" ? "0" : item.balance_sheet.amount_act_vs_rb,
item.balance_sheet.percent_act_vs_rb === "" ? "11.0" : item.balance_sheet.percent_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 === "" ? "12.0" : item.balance_sheet.mtd_vs_previous_month, item.balance_sheet.mtd_vs_previous_month === "" ? "0" : item.balance_sheet.mtd_vs_previous_month,
item.balance_sheet.mtd_vs_mb === "" ? "13.0" : item.balance_sheet.mtd_vs_mb, item.balance_sheet.mtd_vs_mb === "" ? "0" : item.balance_sheet.mtd_vs_mb,
item.balance_sheet.mtd_vs_rb === "" ? "14.0" : item.balance_sheet.mtd_vs_rb, item.balance_sheet.mtd_vs_rb === "" ? "0" : item.balance_sheet.mtd_vs_rb,
]) ])
} }
if (item.children !== null) { if (item.children !== null) {
...@@ -109,20 +146,20 @@ export default class BalanceSheetMR extends Component { ...@@ -109,20 +146,20 @@ export default class BalanceSheetMR extends Component {
item.formula, item.formula,
item.level, item.level,
item.description, item.description,
item.balance_sheet.rolling_outlook === null ? "1.0" : item.balance_sheet.rolling_outlook === "" ? "1.0" : item.balance_sheet.rolling_outlook, item.balance_sheet.rolling_outlook === null ? "0" : item.balance_sheet.rolling_outlook === "" ? "0" : item.balance_sheet.rolling_outlook,
item.balance_sheet.master_budget === "" ? "2.0" : item.balance_sheet.master_budget, item.balance_sheet.master_budget === "" ? "0" : item.balance_sheet.master_budget,
item.balance_sheet.rolling_budget === "" ? "3.0" : item.balance_sheet.rolling_budget, item.balance_sheet.rolling_budget === "" ? "0" : item.balance_sheet.rolling_budget,
item.balance_sheet.actual === "" ? "4.0" : item.balance_sheet.actual, item.balance_sheet.actual === "" ? "0" : item.balance_sheet.actual,
item.balance_sheet.actual_previous_month === null ? "5.0" : item.balance_sheet.actual_previous_month === "" ? "5.0" : item.balance_sheet.actual_previous_month, item.balance_sheet.actual_previous_month === null ? "0" : item.balance_sheet.actual_previous_month === "" ? "0" : item.balance_sheet.actual_previous_month,
item.balance_sheet.amount_act_vs_previous_month === "" ? "6.0" : item.balance_sheet.amount_act_vs_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 === "" ? "7.0" : item.balance_sheet.percent_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 === "" ? "8.0" : item.balance_sheet.amount_act_vs_mb, item.balance_sheet.amount_act_vs_mb === "" ? "0" : item.balance_sheet.amount_act_vs_mb,
item.balance_sheet.percent_act_vs_mb === "" ? "9.0" : item.balance_sheet.percent_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 === "" ? "10.0" : item.balance_sheet.amount_act_vs_rb, item.balance_sheet.amount_act_vs_rb === "" ? "0" : item.balance_sheet.amount_act_vs_rb,
item.balance_sheet.percent_act_vs_rb === "" ? "11.0" : item.balance_sheet.percent_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 === "" ? "12.0" : item.balance_sheet.mtd_vs_previous_month, item.balance_sheet.mtd_vs_previous_month === "" ? "0" : item.balance_sheet.mtd_vs_previous_month,
item.balance_sheet.mtd_vs_mb === "" ? "13.0" : item.balance_sheet.mtd_vs_mb, item.balance_sheet.mtd_vs_mb === "" ? "0" : item.balance_sheet.mtd_vs_mb,
item.balance_sheet.mtd_vs_rb === "" ? "14.0" : item.balance_sheet.mtd_vs_rb, item.balance_sheet.mtd_vs_rb === "" ? "0" : item.balance_sheet.mtd_vs_rb,
]) ])
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
...@@ -430,11 +467,20 @@ export default class BalanceSheetMR extends Component { ...@@ -430,11 +467,20 @@ export default class BalanceSheetMR extends Component {
// console.log(tableMeta); // console.log(tableMeta);
// } // }
if (dex === 1) { if (dex === 1) {
total = Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10]) total = R.equals((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])), Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
// if (tableMeta.rowData[5] === "Cash and cash equivalent") {
// console.log(total);
// console.log(Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10]));
// console.log(dataTable2[tableMeta.rowIndex]);
// }
} else if (dex === 2) { } else if (dex === 2) {
total = Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7]) total = R.equals((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])), Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
} else if (dex === 3) { } else if (dex === 3) {
total = Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8]) total = R.equals((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])), Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
// console.log(total);
} }
return total return total
} }
...@@ -831,6 +877,23 @@ export default class BalanceSheetMR extends Component { ...@@ -831,6 +877,23 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 120 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : 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 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -882,6 +945,23 @@ export default class BalanceSheetMR extends Component { ...@@ -882,6 +945,23 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 120 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null :
Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= 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, 2, 5)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -933,6 +1013,23 @@ export default class BalanceSheetMR extends Component { ...@@ -933,6 +1013,23 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 120 }}> <div style={{ textAlign: 'right', width: 120 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null :
Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= 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, 3, 7)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -998,6 +1095,26 @@ export default class BalanceSheetMR extends Component { ...@@ -998,6 +1095,26 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null :
Number(tableMeta.rowData[12]) <= this.state.minValue || Number(tableMeta.rowData[12]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[17]}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
value={Number(tableMeta.rowData[17]).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1032,6 +1149,26 @@ export default class BalanceSheetMR extends Component { ...@@ -1032,6 +1149,26 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null :
Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[18]}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
value={Number(tableMeta.rowData[18]).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1066,6 +1203,26 @@ export default class BalanceSheetMR extends Component { ...@@ -1066,6 +1203,26 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null : null :
Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[19]}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
value={Number(tableMeta.rowData[19]).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1167,7 +1324,7 @@ export default class BalanceSheetMR extends Component { ...@@ -1167,7 +1324,7 @@ export default class BalanceSheetMR extends Component {
<Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
</div> </div>
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleBSMR? <Paper style={{ paddingTop: 10 }}> {this.state.visibleBSMR ? <Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
</div> </div>
......
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