Commit 7010fc8a authored by faisalhamdi's avatar faisalhamdi

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

parents fb9187b4 45c7e72d
......@@ -6,10 +6,15 @@
"dependencies": {
"@date-io/date-fns": "^1.3.13",
"@date-io/moment": "^2.8.0",
"@devexpress/dx-react-chart": "^2.7.3",
"@devexpress/dx-react-chart-material-ui": "^2.7.3",
"@devexpress/dx-react-core": "^2.7.3",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/pickers": "^3.2.10",
"@nivo/bar": "^0.67.0",
"@nivo/core": "^0.67.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
......
......@@ -184,8 +184,8 @@ export default class CorporateAnnualTarget extends Component {
item.description === 'ROIC' ? Number(item.cat.march).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.march == "" ? item.cat.march : String(item.cat.march).indexOf(".") == -1 ? Number(item.cat.march) : Number(item.cat.march).toFixed(1)) : { value: item.cat.march, formula: item.cat.march_formula } : (item.cat.march == "" ? item.cat.march : String(item.cat.march).indexOf(".") == -1 ? Number(item.cat.march) : Number(item.cat.march).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.april).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.april == "" ? item.cat.april : String(item.cat.april).indexOf(".") == -1 ? Number(item.cat.april) : Number(item.cat.april).toFixed(1)) : { value: item.cat.april, formula: item.cat.april_formula } : (item.cat.april == "" ? item.cat.april : String(item.cat.april).indexOf(".") == -1 ? Number(item.cat.april) : Number(item.cat.april).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.may).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.may == "" ? item.cat.may : String(item.cat.may).indexOf(".") == -1 ? Number(item.cat.may) : Number(item.cat.may).toFixed(1)) : { value: item.cat.may, formula: item.cat.may_formula } : (item.cat.may == "" ? item.cat.may : String(item.cat.may).indexOf(".") == -1 ? Number(item.cat.may) : Number(item.cat.may).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.may).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.june == "" ? item.cat.june : String(item.cat.june).indexOf(".") == -1 ? Number(item.cat.june) : Number(item.cat.june).toFixed(1)) : { value: item.cat.june, formula: item.cat.june_formula } : item.description === 'ROIC' ? Number(item.cat.june).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.description === 'ROIC' ? Number(item.cat.may).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.july == "" ? item.cat.july : String(item.cat.july).indexOf(".") == -1 ? Number(item.cat.july) : Number(item.cat.july).toFixed(1)) : { value: item.cat.july, formula: item.cat.july_formula } : item.description === 'ROIC' ? Number(item.cat.july).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.description === 'ROIC' ? Number(item.cat.june).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.june == "" ? item.cat.june : String(item.cat.june).indexOf(".") == -1 ? Number(item.cat.june) : Number(item.cat.june).toFixed(1)) : { value: item.cat.june, formula: item.cat.june_formula } : item.description === 'ROIC' ? Number(item.cat.june).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.description === 'ROIC' ? Number(item.cat.july).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.july == "" ? item.cat.july : String(item.cat.july).indexOf(".") == -1 ? Number(item.cat.july) : Number(item.cat.july).toFixed(1)) : { value: item.cat.july, formula: item.cat.july_formula } : item.description === 'ROIC' ? Number(item.cat.july).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.description === 'ROIC' ? Number(item.cat.august).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.august == "" ? item.cat.august : String(item.cat.august).indexOf(".") == -1 ? Number(item.cat.august) : Number(item.cat.august).toFixed(1)) : { value: item.cat.august, formula: item.cat.august_formula } : (item.cat.august == "" ? item.cat.august : String(item.cat.august).indexOf(".") == -1 ? Number(item.cat.august) : Number(item.cat.august).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.september).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.september == "" ? item.cat.september : String(item.cat.september).indexOf(".") == -1 ? Number(item.cat.september) : Number(item.cat.september).toFixed(1)) : { value: item.cat.september, formula: item.cat.september_formula } : (item.cat.september == "" ? item.cat.september : String(item.cat.september).indexOf(".") == -1 ? Number(item.cat.september) : Number(item.cat.september).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.october).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3? (item.cat.october == "" ? item.cat.october : String(item.cat.october).indexOf(".") == -1 ? Number(item.cat.october) : Number(item.cat.october).toFixed(1)) : { value: item.cat.october, formula: item.cat.october_formula } : (item.cat.october == "" ? item.cat.october : String(item.cat.october).indexOf(".") == -1 ? Number(item.cat.october) : Number(item.cat.october).toFixed(1)),
......@@ -228,8 +228,8 @@ export default class CorporateAnnualTarget extends Component {
item.description === 'ROIC' ? Number(item.cat.march).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.march, formula: item.cat.march_formula } : (item.cat.march == "" ? item.cat.march : String(item.cat.march).indexOf(".") == -1 ? Number(item.cat.march) : Number(item.cat.march).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.april).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.april, formula: item.cat.april_formula } : (item.cat.april == "" ? item.cat.april : String(item.cat.april).indexOf(".") == -1 ? Number(item.cat.april) : Number(item.cat.april).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.may).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.may, formula: item.cat.may_formula } : (item.cat.may == "" ? item.cat.may : String(item.cat.may).indexOf(".") == -1 ? Number(item.cat.may) : Number(item.cat.may).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.may).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.june, formula: item.cat.june_formula } : item.description === 'ROIC' ? Number(item.cat.june).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.description === 'ROIC' ? Number(item.cat.may).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.july, formula: item.cat.july_formula } : item.description === 'ROIC' ? Number(item.cat.july).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.description === 'ROIC' ? Number(item.cat.june).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.june, formula: item.cat.june_formula } : item.description === 'ROIC' ? Number(item.cat.june).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.description === 'ROIC' ? Number(item.cat.july).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.july, formula: item.cat.july_formula } : item.description === 'ROIC' ? Number(item.cat.july).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.description === 'ROIC' ? Number(item.cat.august).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.august, formula: item.cat.august_formula } : (item.cat.august == "" ? item.cat.august : String(item.cat.august).indexOf(".") == -1 ? Number(item.cat.august) : Number(item.cat.august).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.september).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.september, formula: item.cat.september_formula } : (item.cat.september == "" ? item.cat.september : String(item.cat.september).indexOf(".") == -1 ? Number(item.cat.september) : Number(item.cat.september).toFixed(1)),
item.description === 'ROIC' ? Number(item.cat.october).toFixed(1) : item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.october, formula: item.cat.october_formula } : (item.cat.october == "" ? item.cat.october : String(item.cat.october).indexOf(".") == -1 ? Number(item.cat.october) : Number(item.cat.october).toFixed(1)),
......
......@@ -217,6 +217,11 @@ export default function MiniDrawer() {
label: 'CAT Dashboard',
path: 'dashboard-cat',
},
{
img: 'beranda',
label: 'Financial Dashboard',
path: 'dashboard-financial',
},
{
img: 'beranda',
label: 'Summary of Triputra Group',
......
import * as React from 'react';
import Paper from '@material-ui/core/Paper';
import { ResponsiveBar } from '@nivo/bar'
import { Snackbar, TextField, Typography, withStyles } from '@material-ui/core';
import MuiAlert from '@material-ui/lab/Alert';
import { Autocomplete } from '@material-ui/lab';
import { titleCase } from '../../library/Utils';
import api from '../../api';
import Constant from '../../library/Constant';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
// make sure parent container have a defined height when using
// responsive component, otherwise height will be 0 and
// no chart will be rendered.
// website examples showcase many properties,
// you'll often use just a few of them.
// const MyResponsiveBar = ({ data /* see data tab */ }) => (
// )
export default class DashboardFinancial extends React.Component {
constructor(props) {
super(props);
this.state = {
data: [
{
"country": "AD",
"hot dog": 6,
"hot dogColor": "hsl(228, 70%, 50%)",
"burger": 53,
"burgerColor": "hsl(29, 70%, 50%)",
"sandwich": 74,
"sandwichColor": "hsl(148, 70%, 50%)",
"kebab": 132,
"kebabColor": "hsl(54, 70%, 50%)",
"fries": 46,
"friesColor": "hsl(2, 70%, 50%)",
"donut": 146,
"donutColor": "hsl(60, 70%, 50%)"
},
{
"country": "AE",
"hot dog": 167,
"hot dogColor": "hsl(340, 70%, 50%)",
"burger": 133,
"burgerColor": "hsl(160, 70%, 50%)",
"sandwich": 46,
"sandwichColor": "hsl(330, 70%, 50%)",
"kebab": 68,
"kebabColor": "hsl(298, 70%, 50%)",
"fries": 11,
"friesColor": "hsl(89, 70%, 50%)",
"donut": 119,
"donutColor": "hsl(40, 70%, 50%)"
},
{
"country": "AF",
"hot dog": 60,
"hot dogColor": "hsl(188, 70%, 50%)",
"burger": 120,
"burgerColor": "hsl(252, 70%, 50%)",
"sandwich": 138,
"sandwichColor": "hsl(152, 70%, 50%)",
"kebab": 45,
"kebabColor": "hsl(256, 70%, 50%)",
"fries": 132,
"friesColor": "hsl(201, 70%, 50%)",
"donut": 130,
"donutColor": "hsl(191, 70%, 50%)"
},
{
"country": "AG",
"hot dog": 84,
"hot dogColor": "hsl(356, 70%, 50%)",
"burger": 102,
"burgerColor": "hsl(161, 70%, 50%)",
"sandwich": 157,
"sandwichColor": "hsl(177, 70%, 50%)",
"kebab": 65,
"kebabColor": "hsl(74, 70%, 50%)",
"fries": 105,
"friesColor": "hsl(82, 70%, 50%)",
"donut": 90,
"donutColor": "hsl(138, 70%, 50%)"
},
{
"country": "AI",
"hot dog": 144,
"hot dogColor": "hsl(102, 70%, 50%)",
"burger": 62,
"burgerColor": "hsl(308, 70%, 50%)",
"sandwich": 59,
"sandwichColor": "hsl(101, 70%, 50%)",
"kebab": 117,
"kebabColor": "hsl(152, 70%, 50%)",
"fries": 57,
"friesColor": "hsl(297, 70%, 50%)",
"donut": 34,
"donutColor": "hsl(319, 70%, 50%)"
},
{
"country": "AL",
"hot dog": 84,
"hot dogColor": "hsl(288, 70%, 50%)",
"burger": 93,
"burgerColor": "hsl(288, 70%, 50%)",
"sandwich": 23,
"sandwichColor": "hsl(64, 70%, 50%)",
"kebab": 128,
"kebabColor": "hsl(118, 70%, 50%)",
"fries": 199,
"friesColor": "hsl(125, 70%, 50%)",
"donut": 184,
"donutColor": "hsl(334, 70%, 50%)"
},
{
"country": "AM",
"hot dog": 44,
"hot dogColor": "hsl(239, 70%, 50%)",
"burger": 17,
"burgerColor": "hsl(306, 70%, 50%)",
"sandwich": 58,
"sandwichColor": "hsl(317, 70%, 50%)",
"kebab": 51,
"kebabColor": "hsl(148, 70%, 50%)",
"fries": 151,
"friesColor": "hsl(344, 70%, 50%)",
"donut": 174,
"donutColor": "hsl(190, 70%, 50%)"
}
],
};
}
componentDidMount() {
console.log(this.props.height)
}
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive()
})
}
}
}
})
}
getCompanyActive() {
api.create().getPerusahaanActive().then((response) => {
// console.log(response);
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let comID = this.state.rawData ? this.state.rawData.company_id : 0
let companyData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name,
}
})
let arrayBaru = []
this.state.userCompany.map((item, index) => {
let indexID = companyData.findIndex((val) => val.company_id == item)
if (indexID !== -1) {
arrayBaru.push(companyData[indexID])
}
})
let defaultProps = {
options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name),
};
let index = arrayBaru.findIndex((val) => val.company_id == comID)
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
this.getLastPeriod()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
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', listCompany: null, company: null })
}
})
}
getLastPeriod() {
api.create().getLastPeriod(this.state.company.company_id).then(response => {
// console.log(response);
if (response.data.status === "success") {
this.setState({ lastPeriod: response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => {
this.getPeriode()
})
}
})
}
getPeriode() {
api.create().getPeriodeTransaction().then(response => {
let currentYear = new Date().getFullYear()
// console.log(currentYear)
if (response.data) {
if (response.data.status === "success") {
let data = []
response.data.data.map((item) => {
if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
data.push(item)
}
} else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
data.push(item)
}
}
})
let periodeData = data.map((item) => {
return {
periode: item,
}
})
let defaultProps = {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// console.log(data)
// console.log(this.state.latestPeriode)
// console.log(periodeData)
// console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
// this.getDataTable()
// this.getSubmission()
this.getReportType()
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.getRevision()
// }
})
}
}
})
}
getReportType() {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"report_type": "Master Budget",
}
api.create().getReportTypeBody(payload).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
if (this.state.report.value === 2) {
response.data.data.map((item, index) => {
if (item.report_name === 'Balance Sheet') {
this.setState({ revisionType: item.revision }, ()=> {
this.getSubmission()
})
}
})
} else if (this.state.report.value === 1) {
response.data.data.map((item, index) => {
if (item.report_name === 'Profit Loss') {
this.setState({ revisionType: item.revision }, ()=> {
this.getSubmission()
})
}
})
} else {
this.setState({ revisionType: 0 }, ()=> {
this.getSubmission()
})
}
} 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() {
const { data: chartData } = this.state;
return (
<div style={{ flex: 1, backgroundColor: '#f8f8f8' }} ref={this.myRef}>
<div>
<div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Dashboard Financial</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>
<div style={{ padding: 20, width: '100%' }}>
<Paper style={{ paddingTop: 10 , height: this.props.height}}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>FINANCIAL SUMMARY OF TRIPUTRA GROUP</Typography>
</div>
<div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
<div style={{ marginTop: 15 }}>
<Autocomplete
options={this.state.reportType}
getOptionLabel={(option) => titleCase(option.label)}
id="typereport"
onChange={(event, newInputValue) => this.setState({ report: newInputValue, loading: true, previewTable: false }, () => {
this.getReportType()
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Report Type" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.report}
/>
</div>
<div style={{ marginTop: 15 }}>
<Autocomplete
{...this.state.listCompany}
id="company"
disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true, previewTable: false }, () => {
this.getReportType()
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.company}
/>
</div>
<div style={{ marginTop: 15 }}>
<Autocomplete
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true, previewTable: false }, () => {
this.getReportType()
})}
disabled={this.state.intent === 'Home' ? true : false}
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }}
/>}
value={this.state.periode}
/>
</div>
</div>
<div style={{height: Number(0.3 * this.props.height)}}>
<ResponsiveBar
data={chartData}
keys={[ 'hot dog', 'burger', 'sandwich', 'kebab', 'fries', 'donut' ]}
indexBy="country"
margin={{ top: 50, right: 130, bottom: 50, left: 60 }}
padding={0.3}
groupMode="grouped"
valueScale={{ type: 'linear' }}
indexScale={{ type: 'band', round: true }}
colors={{ scheme: 'nivo' }}
defs={[
{
id: 'dots',
type: 'patternDots',
background: 'inherit',
color: '#38bcb2',
size: 4,
padding: 1,
stagger: true
},
{
id: 'lines',
type: 'patternLines',
background: 'inherit',
color: '#eed312',
rotation: -45,
lineWidth: 6,
spacing: 10
}
]}
fill={[
{
match: {
id: 'fries'
},
id: 'dots'
},
{
match: {
id: 'sandwich'
},
id: 'lines'
}
]}
borderColor={{ from: 'color', modifiers: [ [ 'darker', 1.6 ] ] }}
axisTop={null}
axisRight={null}
axisBottom={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: 'country',
legendPosition: 'middle',
legendOffset: 32
}}
axisLeft={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: 'food',
legendPosition: 'middle',
legendOffset: -40
}}
labelSkipWidth={12}
labelSkipHeight={12}
labelTextColor={{ from: 'color', modifiers: [ [ 'darker', 1.6 ] ] }}
legends={[
{
dataFrom: 'keys',
anchor: 'bottom-right',
direction: 'column',
justify: false,
translateX: 25,
translateY: 0,
itemsSpacing: 0,
itemWidth: 20,
itemHeight: 24,
itemDirection: 'left-to-right',
itemOpacity: 0.85,
symbolSize: 17,
effects: [
{
on: 'hover',
style: {
itemOpacity: 1
}
}
]
}
]}
animate={true}
motionStiffness={90}
motionDamping={15}
/>
</div>
</Paper>
</div>
</div>
</div>
);
}
}
......@@ -86,7 +86,9 @@ export default class ListOfCreditFacilities extends Component {
perBS: 0,
snekbar: false,
snekbarMsg: '',
visibleLOCFMR: true
visibleLOCFMR: true,
saveDraft: true,
saveComp: true
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -303,8 +305,8 @@ export default class ListOfCreditFacilities extends Component {
)
}
this.getPerBS()
// console.log(dataTable)
this.setState({ dataTable, loading: false }, () => {
console.log(dataTable)
this.setState({ dataTable, loading: false, visibleLOCFMR: true, totalOutStand: 0, diff: 0 }, () => {
this.handleCalculate()
})
}
......@@ -387,11 +389,11 @@ export default class ListOfCreditFacilities extends Component {
checkUpload() {
api.create().checkUploadMonthlyReportLOCF(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleLOCFMR: false, loading: true })
this.setState({ visibleUpload: false, loading: true, visibleLOCFMR: false, totalOutStand: 0, diff: 0 })
let dataTable = []
response.data.data.map((item, index) => {
if (index == response.data.data.length -1) {
......@@ -401,13 +403,12 @@ export default class ListOfCreditFacilities extends Component {
item.parent,
item.formula,
item.level,
// item.description,
item.borrower_comp_name === null ? "" : item.borrower_comp_name === "" ? "" : item.borrower_comp_name,
item.borrower_comp_name === null ? this.props.company.company_name : item.borrower_comp_name === "" ? this.props.company.company_name : item.borrower_comp_name,
item.bank_name === null ? null : item.bank_name === "" ? null : {value: item.bank_name},
item.type_of_credit === null ? null : item.type_of_credit === "" ? null : {value: item.type_of_credit},
item.remarks === null ? "0.0" : item.remarks === "" ? "0.0" : item.remarks,
item.loan_maturity_date === null ? "0.0" : item.loan_maturity_date === "" ? "0.0" : item.loan_maturity_date,
item.interest === null ? "0.0" : item.interest === "" ? "0.0" : item.interest,
item.remarks === null ? "" : item.remarks === "" ? "" : item.remarks,
item.loan_maturity_date === null ? this.state.currentDate : item.loan_maturity_date === "" ? this.state.currentDate : item.loan_maturity_date,
item.interest === null ? "0" : item.interest === "" ? "0" : item.interest,
item.currency === null ? "0.0" : item.currency === "" ? "0.0" : item.currency,
item.loan_plafond_amount_ori,
item.loan_plafond_amount_idr === null ? "0.0" : item.loan_plafond_amount_idr === "" ? "0.0" : item.loan_plafond_amount_idr,
......@@ -415,7 +416,6 @@ export default class ListOfCreditFacilities extends Component {
item.out_loan_ki_amount_idr === null ? "0.0" : item.out_loan_ki_amount_idr === "" ? "0.0" : item.out_loan_ki_amount_idr,
item.out_loan_kmk_amount_ori,
item.out_loan_kmk_amount_idr === null ? "0.0" : item.out_loan_kmk_amount_idr === "" ? "0.0" : item.out_loan_kmk_amount_idr,
// item.mtd_vs_previous_month === null ? "0.0" : item.mtd_vs_previous_month === "" ? "0.0" : item.mtd_vs_previous_month,
item.out_loan_other_type,
item.out_loan_other_amount_ori,
item.out_loan_other_amount_idr === null ? "0.0" : item.out_loan_other_amount_idr === "" ? "0.0" : item.out_loan_other_amount_idr,
......@@ -432,20 +432,18 @@ export default class ListOfCreditFacilities extends Component {
item.ebitda_to_interest_financial,
item.ebitda_to_interest_current === null ? "0.0" : item.ebitda_to_interest_current === "" ? "0.0" : item.ebitda_to_interest_current,
item.other_ratio1_ratio_name,
item.other_ratio1_financial,
item.other_ratio1_financial === null ? "0.0" : item.other_ratio1_financial === "" ? "0.0" : item.other_ratio1_financial,
item.other_ratio1_current === null ? "0.0" : item.other_ratio1_current === "" ? "0.0" : item.other_ratio1_current,
item.other_ratio2_ratio_name,
item.other_ratio2_financial,
item.other_ratio2_financial === null ? "0.0" : item.other_ratio2_financial === "" ? "0.0" : item.other_ratio2_financial,
item.other_ratio2_current === null ? "0.0" : item.other_ratio2_current === "" ? "0.0" : item.other_ratio2_current,
item.other_ratio3_ratio_name,
item.other_ratio3_financial,
item.other_ratio3_financial === null ? "0.0" : item.other_ratio3_financial === "" ? "0.0" : item.other_ratio3_financial,
item.other_ratio3_current === null ? "0.0" : item.other_ratio3_current === "" ? "0.0" : item.other_ratio3_current,
item.other_ratio4_ratio_name,
item.other_ratio4_financia,,
item.other_ratio4_financial === null ? "0.0" : item.other_ratio4_financial === "" ? "0.0" : item.other_ratio4_financial,
item.other_ratio4_current === null ? "0.0" : item.other_ratio4_current === "" ? "0.0" : item.other_ratio4_current,
item.notes,
// item.per_bs === null ? "0.0" : item.per_bs === "" ? "0.0" : item.per_bs,
// item.diff === null ? "0.0" : item.diff === "" ? "0.0" : item.diff,
],
[9, "", "", "", "", "", {value: "Grand Total"}, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999 ],
)
......@@ -456,13 +454,12 @@ export default class ListOfCreditFacilities extends Component {
item.parent,
item.formula,
item.level,
// item.description,
item.borrower_comp_name === null ? "0.0" : item.borrower_comp_name === "" ? "0.0" : item.borrower_comp_name,
item.borrower_comp_name === null ? this.props.company.company_name : item.borrower_comp_name === "" ? this.props.company.company_name : item.borrower_comp_name,
item.bank_name === null ? null : item.bank_name === "" ? null : {value: item.bank_name},
item.type_of_credit === null ? null : item.type_of_credit === "" ? null : {value: item.type_of_credit},
item.remarks === null ? "0.0" : item.remarks === "" ? "0.0" : item.remarks,
item.loan_maturity_date === null ? "0.0" : item.loan_maturity_date === "" ? "0.0" : item.loan_maturity_date,
item.interest === null ? "0.0" : item.interest === "" ? "0.0" : item.interest,
item.remarks === null ? "" : item.remarks === "" ? "" : item.remarks,
item.loan_maturity_date === null ? this.state.currentDate : item.loan_maturity_date === "" ? this.state.currentDate : item.loan_maturity_date,
item.interest === null ? "0" : item.interest === "" ? "0" : item.interest,
item.currency === null ? "0.0" : item.currency === "" ? "0.0" : item.currency,
item.loan_plafond_amount_ori,
item.loan_plafond_amount_idr === null ? "0.0" : item.loan_plafond_amount_idr === "" ? "0.0" : item.loan_plafond_amount_idr,
......@@ -470,7 +467,6 @@ export default class ListOfCreditFacilities extends Component {
item.out_loan_ki_amount_idr === null ? "0.0" : item.out_loan_ki_amount_idr === "" ? "0.0" : item.out_loan_ki_amount_idr,
item.out_loan_kmk_amount_ori,
item.out_loan_kmk_amount_idr === null ? "0.0" : item.out_loan_kmk_amount_idr === "" ? "0.0" : item.out_loan_kmk_amount_idr,
// item.mtd_vs_previous_month === null ? "0.0" : item.mtd_vs_previous_month === "" ? "0.0" : item.mtd_vs_previous_month,
item.out_loan_other_type,
item.out_loan_other_amount_ori,
item.out_loan_other_amount_idr === null ? "0.0" : item.out_loan_other_amount_idr === "" ? "0.0" : item.out_loan_other_amount_idr,
......@@ -487,20 +483,18 @@ export default class ListOfCreditFacilities extends Component {
item.ebitda_to_interest_financial,
item.ebitda_to_interest_current === null ? "0.0" : item.ebitda_to_interest_current === "" ? "0.0" : item.ebitda_to_interest_current,
item.other_ratio1_ratio_name,
item.other_ratio1_financial,
item.other_ratio1_financial === null ? "0.0" : item.other_ratio1_financial === "" ? "0.0" : item.other_ratio1_financial,
item.other_ratio1_current === null ? "0.0" : item.other_ratio1_current === "" ? "0.0" : item.other_ratio1_current,
item.other_ratio2_ratio_name,
item.other_ratio2_financial,
item.other_ratio2_financial === null ? "0.0" : item.other_ratio2_financial === "" ? "0.0" : item.other_ratio2_financial,
item.other_ratio2_current === null ? "0.0" : item.other_ratio2_current === "" ? "0.0" : item.other_ratio2_current,
item.other_ratio3_ratio_name,
item.other_ratio3_financial,
item.other_ratio3_financial === null ? "0.0" : item.other_ratio3_financial === "" ? "0.0" : item.other_ratio3_financial,
item.other_ratio3_current === null ? "0.0" : item.other_ratio3_current === "" ? "0.0" : item.other_ratio3_current,
item.other_ratio4_ratio_name,
item.other_ratio4_financia,,
item.other_ratio4_financial === null ? "0.0" : item.other_ratio4_financial === "" ? "0.0" : item.other_ratio4_financial,
item.other_ratio4_current === null ? "0.0" : item.other_ratio4_current === "" ? "0.0" : item.other_ratio4_current,
item.notes,
// item.per_bs === null ? "0.0" : item.locf.per_bs === "" ? "0.0" : item.locf.per_bs,
// item.diff === null ? "0.0" : item.locf.diff === "" ? "0.0" : item.locf.diff,
])
}
......@@ -521,6 +515,7 @@ export default class ListOfCreditFacilities extends Component {
}
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
this.handleCalculate()
this.state.dataTable.map(item => {
if (item[23].length > 0) {
// console.log('masuk')
......@@ -537,92 +532,94 @@ export default class ListOfCreditFacilities extends Component {
uploadProfitLossMR(type) {
let data = []
// this.state.dataTable.map(i => {
// data.push({
// "item_report_id": i[1],
// "borrower_comp_name": i[5],
// "bank_name": i[6].value,
// "type_of_credit": i[7].value,
// "remarks": i[8],
// "loan_maturity_date": i[9],
// "interest": i[10],
// "currency": i[11],
// "loan_plafond_amount_ori": i[12],
// "loan_plafond_amount_idr": i[13],
// "out_loan_ki_amount_ori": i[14],
// "out_loan_ki_amount_idr": i[15],
// "out_loan_kmk_amount_ori": i[16],
// "out_loan_kmk_amount_idr": i[17],
// // "mtd_vs_previous_month": i[18],
// "out_loan_other_type": i[18],
// "out_loan_other_amount_ori": i[19],
// "out_loan_other_amount_idr": i[20],
// "total_out_loan_ori": i[21],
// "total_out_loan_idr": i[22],
// "remaining_plafond_ori": i[23],
// "remaining_plafond_idr": i[24],
// "current_ratio_financial": i[25],
// "current_ratio_current": i[26],
// "der_financial": i[27],
// "der_current": i[28],
// "debt_to_ebitda_financial": i[20],
// "debt_to_ebitda_current": i[30],
// "ebitda_to_interest_financial": i[31],
// "ebitda_to_interest_current": i[32],
// "other_ratio1_ratio_name": i[33],
// "other_ratio1_financial": i[34],
// "other_ratio1_current": i[35],
// "other_ratio2_ratio_name": i[36],
// "other_ratio2_financial": i[37],
// "other_ratio2_current": i[38],
// "other_ratio3_ratio_name": i[39],
// "other_ratio3_financial": i[40],
// "other_ratio3_current": i[41],
// "other_ratio4_ratio_name": i[42],
// "other_ratio4_financial": i[43],
// "other_ratio4_current": i[4],
// "notes": i[45],
// })
// })
// let body = {
// "monthly_report_id": this.props.monthlyReportId,
// "company_id": this.props.company.company_id,
// "periode": this.props.periode,
// "report_id": this.props.report_id,
// "status": type,
// "months": this.props.month.month_id,
// "locf": data,
// "per_bs": this.state.perBS,
// "diff": this.state.diff,
// "total_loan" : this.state.totalOutStand
// }
this.state.dataTable.map(i => {
if (i[0] == 3) {
data.push({
"item_report_id": i[1],
"borrower_comp_name": i[5],
"bank_name": i[6].value,
"type_of_credit": i[7].value,
"remarks": i[8],
"loan_maturity_date": i[9],
"interest": i[10],
"currency": i[11],
"loan_plafond_amount_ori": i[12],
"loan_plafond_amount_idr": i[13],
"out_loan_ki_amount_ori": i[14],
"out_loan_ki_amount_idr": i[15],
"out_loan_kmk_amount_ori": i[16],
"out_loan_kmk_amount_idr": i[17],
// "mtd_vs_previous_month": i[18],
"out_loan_other_type": i[18],
"out_loan_other_amount_ori": i[19],
"out_loan_other_amount_idr": i[20],
"total_out_loan_ori": i[21],
"total_out_loan_idr": i[22],
"remaining_plafond_ori": i[23],
"remaining_plafond_idr": i[24],
"current_ratio_financial": i[25],
"current_ratio_current": i[26],
"der_financial": i[27],
"der_current": i[28],
"debt_to_ebitda_financial": i[20],
"debt_to_ebitda_current": i[30],
"ebitda_to_interest_financial": i[31],
"ebitda_to_interest_current": i[32],
"other_ratio1_ratio_name": i[33],
"other_ratio1_financial": i[34],
"other_ratio1_current": i[35],
"other_ratio2_ratio_name": i[36],
"other_ratio2_financial": i[37],
"other_ratio2_current": i[38],
"other_ratio3_ratio_name": i[39],
"other_ratio3_financial": i[40],
"other_ratio3_current": i[41],
"other_ratio4_ratio_name": i[42],
"other_ratio4_financial": i[43],
"other_ratio4_current": i[4],
"notes": i[45],
})
}
})
let body = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"months": this.props.month.month_id,
"locf": data,
"per_bs": this.state.perBS,
"diff": this.state.diff,
"total_loan" : this.state.totalOutStand
}
// console.log(data);
// api.create('UPLOAD').uploadMonthlyReportLOCF(body).then(response => {
// console.log(response);
// if (response.data) {
// if (response.ok) {
// if (response.data.status === "success") {
// this.props.saveToMonthlyReport()
// // this.props.onClickClose()
// // this.props.getReport()
// } 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);
// }
// })
// // alert(response.data.status)
// }
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
// }
// })
api.create('UPLOAD').uploadMonthlyReportLOCF(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport()
// this.props.onClickClose()
// this.props.getReport()
} 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);
}
})
// alert(response.data.status)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
getBankData() {
......@@ -631,6 +628,7 @@ export default class ListOfCreditFacilities extends Component {
company_id: this.props.company.company_id,
type: 'BANK_NAME'
}
this.setState({ dataLoaded: false })
api.create().getAllSettingByType(body).then(response => {
console.log(response)
if (response.data) {
......@@ -1185,14 +1183,14 @@ export default class ListOfCreditFacilities extends Component {
setTimeout(() => {
// console.log(dataCoba)
// console.log(dataGabung)
// console.log(newData)
console.log(newData)
// console.log(dataTampungBank)
// console.log(totalLoan);
// dataTable: newData, totalOutStand: newData[newData.length-1][22]
if (bankNameEmpty) {
this.setState({ loading: false, dataTable: this.state.dataTable, totalOutStand: 0, diff: Number(0 - this.state.perBS) })
this.setState({ loading: false, dataTable: this.state.dataTable, totalOutStand: 0, diff: Number(0 - this.state.perBS), saveDraft: false })
} else {
this.setState({ loading: false, dataTable: newData, totalOutStand: totalLoan, diff: Number(totalLoan - this.state.perBS) })
this.setState({ loading: false, dataTable: newData, totalOutStand: totalLoan, diff: Number(totalLoan - this.state.perBS), saveDraft: false, saveComp: Number(totalLoan - this.state.perBS) == 0? false : true })
}
}, 100);
})
......@@ -1590,7 +1588,7 @@ export default class ListOfCreditFacilities extends Component {
type="text"
placeholder=""
disabled={tableMeta.rowData[0] == 8 || tableMeta.rowData[0] == 9? true : false}
defaultValue={val}
defaultValue={tableMeta.rowData[8]}
onBlur={(event) => {
// // // console.log(event.target.value)
// updateValue(event.target.value)
......@@ -1712,7 +1710,7 @@ export default class ListOfCreditFacilities extends Component {
type="text"
placeholder=""
disabled={false}
defaultValue={val}
defaultValue={tableMeta.rowData[11]}
onBlur={(event) => {
// // // console.log(event.target.value)
// updateValue(event.target.value)
......@@ -3617,7 +3615,7 @@ export default class ListOfCreditFacilities extends Component {
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.state.buttonError ?
this.state.saveComp ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
:
this.state.handleTekTekTek == 1 ? null :
......@@ -3629,7 +3627,7 @@ export default class ListOfCreditFacilities extends Component {
}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
cursor: this.state.saveComp === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
......@@ -3662,13 +3660,13 @@ export default class ListOfCreditFacilities extends Component {
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
{this.state.dataLoaded && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</MuiThemeProvider>}
</div>
<div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5}}>
......@@ -3696,11 +3694,12 @@ export default class ListOfCreditFacilities extends Component {
<div className="col-1">
<button
type="button"
onClick={() => this.setState({ loading: true, visibleLOCFMR: true }, () => {
setTimeout(() => {
this.setState({loading: false})
}, 100);
})}
onClick={() => {
this.getBankData()
this.getTypeOfCredit()
this.getSubmission()
}
}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
......@@ -3741,7 +3740,7 @@ export default class ListOfCreditFacilities extends Component {
this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1, loading: true }, () => {
setTimeout(() => {
this.backToMonthlyReport('draft')
this.uploadProfitLossMR('draft')
}, 100);
})
}
......@@ -3761,19 +3760,19 @@ export default class ListOfCreditFacilities extends Component {
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.state.buttonError ?
this.state.saveComp ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
:
this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1, loading: true }, () => {
setTimeout(() => {
this.backToMonthlyReport('submitted')
this.uploadProfitLossMR('submitted')
}, 100);
})
}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
cursor: this.state.saveComp === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
......
......@@ -59,6 +59,9 @@ export default class OperatingIndicatorMR extends Component {
maxValue: 0,
updateBy: '-',
notesUpdate: '-',
disabledSave: true,
editable: true,
emptyData: false,
templateNull: true
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -136,7 +139,7 @@ export default class OperatingIndicatorMR extends Component {
}
getItemHierarki() {
this.setState({ loading: true })
let payload = {
"operating_indicator_id": this.props.data.operatingIndID,
"report_id": this.props.data.report_id,
......@@ -211,9 +214,13 @@ export default class OperatingIndicatorMR extends Component {
}
}
})
console.log(dataTable);
this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
this.setState({ dataTable, loading: false }, () => {
if (this.state.dataTable.length == 0) {
this.setState({ emptyData: true })
}
})
}
console.log(dataTable);
})
}
......@@ -360,7 +367,7 @@ export default class OperatingIndicatorMR extends Component {
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, templateNull : total > 0 ? true : false })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, templateNull : total > 0 ? true : false })
}
}
})
......@@ -412,12 +419,83 @@ export default class OperatingIndicatorMR extends Component {
})
}
handleValidate() {
let data = []
let err = false
this.state.dataTable.map((i, index) => {
data.push({
"item_report_id": i[1],
"uom": i[6],
"rolling_outlook": i[7],
"master_budget": i[8],
"rolling_budget": i[9],
"actual": i[10],
"amount_act_vs_mb": i[11],
"percent_act_vs_mb": i[12],
"amount_act_vs_rb": i[13],
"percent_act_vs_rb": i[14],
"mtd_vs_mb": i[15],
"mtd_vs_rb": i[16]
})
})
// console.log(JSON.stringify(data));
data.map(i => {
if (i.mtd_vs_mb === "" && (Number(i.percent_act_vs_mb) < this.state.minValue || Number(i.percent_act_vs_mb) > this.state.maxValue)) {
console.log('msk 1');
err = true
} else if (i.mtd_vs_rb === "" && (Number(i.percent_act_vs_rb) < this.state.minValue || Number(i.percent_act_vs_rb) > this.state.maxValue)) {
console.log('msk 2');
err = true
}
})
// console.log(JSON.stringify(data))
let payload = {
"operating_indicator_id": this.props.data.operatingIndID,
"report_id": this.props.data.report_id,
"company_id": this.props.data.company.company_id,
"periode": this.props.data.periode,
"status": "submitted",
"months": this.props.data.report_id === 22 ? 1 : 23 ? 2 : 24 ? 3 : 25 ? 4 : 27 ? 5 : 28 ? 6 : 29 ? 7 : 31 ? 8 : 32 ? 9 : 33 ? 10 : 35 ? 11 : 36 ? 12 : null,
"monthly_report": data
}
// console.log(JSON.stringify(payload));
api.create().validateSubmitReportOI(payload).then((response) => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result && err === false) {
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 })
}
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
let dataTable2 = this.state.dataTable
const handleText = (value, tableMeta, type) => {
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = value
}
const handleValue = (data, type) => {
let total = 0
dataTable2.map((item, index) => {
......@@ -1012,7 +1090,7 @@ export default class OperatingIndicatorMR 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={'%'}
......@@ -1065,7 +1143,7 @@ export default class OperatingIndicatorMR extends Component {
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}
......@@ -1135,113 +1213,101 @@ export default class OperatingIndicatorMR extends Component {
<div className="grid grid-2x content-center">
<div className="col-1">
<div style={{ textAlign: 'right', width: 90 }}>
{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={tableMeta.rowData[15]}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? null :
<FormControlLabel
style={{ margin: 0 }}
// value={value}
control={
tableMeta.rowData[15] === "" && (Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue) ?
<LightTooltipError 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={!this.props.permission.create || !this.props.permission.edit || !this.props.isSubmit}
value={Number(tableMeta.rowData[15]).toFixed(1)}
// disabled={false}
defaultValue={tableMeta.rowData[15]}
inputProps={{
style: {
color: "#5198ea",
textAlign: 'right',
backgroundColor: '#ffac99'
}
}}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
handleText(event.target.value, tableMeta, 0)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 0)).toFixed(1)}
/>
</span>
:
<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' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[15]).toFixed(1)}
/>
}
/>
</div>
</LightTooltipError>
:
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
defaultValue={tableMeta.rowData[15]}
inputProps={{
style: {
color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'right'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 0)
}}
/>
}
/>
}
</div>
</div>
<div className="col-2">
<div style={{ textAlign: 'right', width: 90 }}>
{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 }}
value={tableMeta.rowData[16]}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? null :
<FormControlLabel
style={{ margin: 0 }}
// value={value}
control={
tableMeta.rowData[16] === "" && (Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue) ?
<LightTooltipError 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={false}
defaultValue={tableMeta.rowData[16]}
inputProps={{
style: {
color: "#5198ea",
textAlign: 'right',
backgroundColor: '#ffac99'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 1)
}}
/>
</LightTooltipError>
:
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={!this.props.permission.create || !this.props.permission.edit || !this.props.isSubmit}
value={Number(tableMeta.rowData[16]).toFixed(1)}
defaultValue={tableMeta.rowData[16]}
inputProps={{
style: {
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'right'
}
}}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
handleText(event.target.value, tableMeta, 1)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 0)).toFixed(1)}
/>
</span>
:
<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' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[16]).toFixed(1)}
/>
}
/>
</div>
}
/>
}
</div>
</div>
......@@ -1273,13 +1339,8 @@ export default class OperatingIndicatorMR 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' }}>Monthly Report</Typography>
<Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report 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>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleOI === true ?
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
......@@ -1377,11 +1438,12 @@ export default class OperatingIndicatorMR extends Component {
cursor: 'pointer',
borderColor: 'transparent',
}}
onClick={() => {
this.props.onClickClose()
this.props.getReport()
}
}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
this.props.getReport()
}, 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>
......@@ -1394,6 +1456,7 @@ export default class OperatingIndicatorMR extends Component {
onClick={() =>
this.setState({ loading: true, editable: false }, () => {
setTimeout(() => {
this.handleValidate()
this.setState({ loading: false, buttonError: false })
}, 100);
})
......
......@@ -197,7 +197,7 @@ export default class ProfitLossMR extends Component {
item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual,
item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
item.profit_loss.actual_previous_month === null ? "5.0" : item.profit_loss.actual_previous_month === "" ? "5.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
......@@ -232,7 +232,7 @@ export default class ProfitLossMR extends Component {
item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual,
item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
item.profit_loss.actual_previous_month === null ? "5.0" : item.profit_loss.actual_previous_month === "" ? "5.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
......@@ -1563,52 +1563,53 @@ export default class ProfitLossMR extends Component {
<div style={{ flex: 1 }}>
{tableMeta.rowData[0] === 4 ? null : tableMeta.rowData[0] === 1 ? null : tableMeta.rowData[4] === 0 ? null : tableMeta.rowData[4] === 1 ? null :
<FormControlLabel
style={{ margin: 0 }}
// value={tableMeta.rowData[19]}
control={
tableMeta.rowData[19] === "" && (Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue) ?
<LightTooltipError title={"MTD Explanation vs Prev. Month is Reqiured"} arrow>
style={{ margin: 0 }}
// value={tableMeta.rowData[19]}
control={
tableMeta.rowData[19] === "" && (Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue) ?
<LightTooltipError title={"MTD Explanation vs Prev. Month is Reqiured"} arrow>
<Input
disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
// value={tableMeta.rowData[19]}
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: "#5198ea",
textAlign: 'right',
backgroundColor: '#ffac99'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 0)
}}
/>
</LightTooltipError>
:
<Input
disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
// disabled={Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? false : true}
// value={tableMeta.rowData[19]}
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: "#5198ea",
textAlign: 'right',
backgroundColor: '#ffac99'
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'right'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 0)
}}
/>
</LightTooltipError>
:
<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}
// value={tableMeta.rowData[19]}
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'right'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 0)
}}
/>
}
/>}
}
/>
}
</div>
</div>
</div>
......
......@@ -26,7 +26,6 @@ export default class SummaryOfTriputra extends Component {
{ value: 2, label: 'YTD Report' },
{ value: 3, label: 'CPSM Report' },
{ value: 4, label: 'Historical' },
{ value: 5, label: 'Dashboard Financial' },
],
report: null,
loading: false,
......@@ -233,6 +232,7 @@ export default class SummaryOfTriputra extends Component {
if (this.state.report.value === 1) {
api.create().getDetailReportMB(payload).then(response => {
// console.log(response);
// console.log(payload)
let dataTable = []
if (response.data) {
let res = response.data.data
......
......@@ -10,6 +10,7 @@ import UnitBisnis from '../container/MasterData/UnitBisnis'
import Parameter from '../container/MasterData/Parameter/Parameter'
import ReportItems from '../container/MasterData/ReportItems'
import DashboardCAT from '../container/Laporan/DashboardCAT'
import DashboardFinancial from '../container/Laporan/DashboardFinancial'
import BudgetTahunan from '../container/BudgetTahunan';
import RollingOutlook from '../container/RollingOutlook';
import OperatingIndicator from '../container/OprIndicator/OperatingIndicator'
......@@ -96,6 +97,10 @@ const routes = [
path: "/home/summary-of-triputra",
main: SummaryTriputra
},
{
path: "/home/dashboard-financial",
main: DashboardFinancial
},
{
path: "*",
main: screen404
......
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