Commit 19e73c89 authored by EKSAD's avatar EKSAD

profit loss

parent 8dac516a
......@@ -656,12 +656,15 @@ export default class BudgetTahunan extends Component {
)}
{this.state.visiblePL && (
<ProfitLoss
open={this.props.open}
report_id={this.state.report_id}
height={this.props.height}
width={this.props.width}
company={this.state.company}
revision={this.state.revisionTable}
periode={this.state.periode.periode}
submissionID={this.state.submissionID}
saveToMasterBudget={this.saveToMasterBudget.bind(this)}
onClickClose={() => this.setState({ visiblePL: false, visibleBudgetTahunan: true })}
/>
......
......@@ -5,6 +5,9 @@ import NumberFormat from 'react-number-format';
import api from '../../api';
import AddIcon from '@material-ui/icons/Add';
import { values } from 'ramda';
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());
......@@ -48,11 +51,13 @@ export default class ProfitLoss extends Component {
}
getItemHierarki() {
this.setState({ loading: true })
let payload = {
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID
}
api.create().getDetailReportMB(payload).then(response => {
console.log(response);
......@@ -68,6 +73,7 @@ export default class ProfitLoss extends Component {
item.formula,
item.level,
item.description,
item.profit_loss.notes,
item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
......@@ -95,6 +101,7 @@ export default class ProfitLoss extends Component {
i.formula,
i.level,
i.description,
i.profit_loss.notes,
i.profit_loss.total_actual_before,
i.profit_loss.january,
i.profit_loss.february,
......@@ -121,6 +128,7 @@ export default class ProfitLoss extends Component {
val.formula,
val.level,
val.description,
val.profit_loss.notes,
val.profit_loss.total_actual_before,
val.profit_loss.january,
val.profit_loss.february,
......@@ -147,6 +155,7 @@ export default class ProfitLoss extends Component {
items.formula,
items.level,
items.description,
items.profit_loss.notes,
items.profit_loss.total_actual_before,
items.profit_loss.january,
items.profit_loss.february,
......@@ -173,6 +182,7 @@ export default class ProfitLoss extends Component {
itemss.formula,
itemss.level,
itemss.description,
itemss.profit_loss.notes,
itemss.profit_loss.total_actual_before,
itemss.profit_loss.january,
itemss.profit_loss.february,
......@@ -199,6 +209,7 @@ export default class ProfitLoss extends Component {
item1.formula,
item1.level,
item1.description,
item1.profit_loss.notes,
item1.profit_loss.total_actual_before,
item1.profit_loss.january,
item1.profit_loss.february,
......@@ -225,6 +236,7 @@ export default class ProfitLoss extends Component {
item2.formula,
item2.level,
item2.description,
item2.profit_loss.notes,
item2.profit_loss.total_actual_before,
item2.profit_loss.january,
item2.profit_loss.february,
......@@ -251,6 +263,7 @@ export default class ProfitLoss extends Component {
item3.formula,
item3.level,
item3.description,
item3.profit_loss.notes,
item3.profit_loss.total_actual_before,
item3.profit_loss.january,
item3.profit_loss.february,
......@@ -277,6 +290,7 @@ export default class ProfitLoss extends Component {
item4.formula,
item4.level,
item4.description,
item4.profit_loss.notes,
item4.profit_loss.total_actual_before,
item4.profit_loss.january,
item4.profit_loss.february,
......@@ -303,6 +317,7 @@ export default class ProfitLoss extends Component {
item5.formula,
item5.level,
item5.description,
item5.profit_loss.notes,
item5.profit_loss.total_actual_before,
item5.profit_loss.january,
item5.profit_loss.february,
......@@ -329,6 +344,7 @@ export default class ProfitLoss extends Component {
item6.formula,
item6.level,
item6.description,
item6.profit_loss.notes,
item6.profit_loss.total_actual_before,
item6.profit_loss.january,
item6.profit_loss.february,
......@@ -354,6 +370,7 @@ export default class ProfitLoss extends Component {
item6.formula,
item6.level,
item6.description,
item6.profit_loss.notes,
item6.profit_loss.total_actual_before,
item6.profit_loss.january,
item6.profit_loss.february,
......@@ -381,6 +398,7 @@ export default class ProfitLoss extends Component {
item5.formula,
item5.level,
item5.description,
item5.profit_loss.notes,
item5.profit_loss.total_actual_before,
item5.profit_loss.january,
item5.profit_loss.february,
......@@ -408,6 +426,7 @@ export default class ProfitLoss extends Component {
item4.formula,
item4.level,
item4.description,
item4.profit_loss.notes,
item4.profit_loss.total_actual_before,
item4.profit_loss.january,
item4.profit_loss.february,
......@@ -435,6 +454,7 @@ export default class ProfitLoss extends Component {
item3.formula,
item3.level,
item3.description,
item3.profit_loss.notes,
item3.profit_loss.total_actual_before,
item3.profit_loss.january,
item3.profit_loss.february,
......@@ -462,6 +482,7 @@ export default class ProfitLoss extends Component {
item2.formula,
item2.level,
item2.description,
item2.profit_loss.notes,
item2.profit_loss.total_actual_before,
item2.profit_loss.january,
item2.profit_loss.february,
......@@ -489,6 +510,7 @@ export default class ProfitLoss extends Component {
item1.formula,
item1.level,
item1.description,
item1.profit_loss.notes,
item1.profit_loss.total_actual_before,
item1.profit_loss.january,
item1.profit_loss.february,
......@@ -516,6 +538,7 @@ export default class ProfitLoss extends Component {
itemss.formula,
itemss.level,
itemss.description,
itemss.profit_loss.notes,
itemss.profit_loss.total_actual_before,
itemss.profit_loss.january,
itemss.profit_loss.february,
......@@ -543,6 +566,7 @@ export default class ProfitLoss extends Component {
items.formula,
items.level,
items.description,
items.profit_loss.notes,
items.profit_loss.total_actual_before,
items.profit_loss.january,
items.profit_loss.february,
......@@ -570,6 +594,7 @@ export default class ProfitLoss extends Component {
val.formula,
val.level,
val.description,
val.profit_loss.notes,
val.profit_loss.total_actual_before,
val.profit_loss.january,
val.profit_loss.february,
......@@ -597,6 +622,7 @@ export default class ProfitLoss extends Component {
i.formula,
i.level,
i.description,
i.profit_loss.notes,
i.profit_loss.total_actual_before,
i.profit_loss.january,
i.profit_loss.february,
......@@ -623,6 +649,7 @@ export default class ProfitLoss extends Component {
i.formula,
i.level,
i.description,
i.profit_loss.notes,
i.profit_loss.total_actual_before,
i.profit_loss.january,
i.profit_loss.february,
......@@ -650,6 +677,7 @@ export default class ProfitLoss extends Component {
item.formula,
item.level,
item.description,
item.profit_loss.notes,
item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
......@@ -670,8 +698,10 @@ export default class ProfitLoss extends Component {
}
})
console.log(dataTable);
this.setState({ dataTable })
this.setState({ dataTable, loading: false })
}
} else {
this.setState({ loading: false })
}
})
}
......@@ -708,6 +738,45 @@ export default class ProfitLoss extends Component {
// }, () => console.log(this.state.dataTable))
}
backToMasterBudget(type) {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
notes: String(i[6]),
total_actual_before: String(i[7]),
january: String(i[8]),
february: String(i[9]),
march: String(i[10]),
april: String(i[11]),
may: String(i[12]),
june: String(i[13]),
july: String(i[14]),
august: String(i[15]),
september: String(i[16]),
october: String(i[17]),
november: String(i[18]),
december: String(i[19]),
total_current_year: String(i[20]),
total_next_year: String(i[21]),
total_more_year: String(i[22])
})
})
let payload = {
"submission_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"profit_loss": data
}
console.log(data);
this.props.saveToMasterBudget(payload)
this.props.onClickClose()
}
render() {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => {
......@@ -771,7 +840,7 @@ export default class ProfitLoss extends Component {
setCellProps: () => ({ style }),
customBodyRender: (val, tableMeta) => {
return (
<div style={{ width: 300}}>
<div style={{ width: 300 }}>
{tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
......@@ -784,7 +853,43 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "31-Dec-2020 OL PA",
name: "Notes",
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell>
),
setCellProps: () => ({ style2 }),
customBodyRender: (value, tableMeta, updateValue) => {
return (
<div style={{ textAlign: 'right' }}>
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<Input
disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
/>
</div>
</div>
)
}
}
}, {
name: "31 Dec 2020 Actual",
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -1720,11 +1825,11 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "31-Dec-21 MB",
name: "Current Total",
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
<Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell>
),
setCellProps: () => ({ style2 }),
......@@ -1792,7 +1897,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "31-Dec-22 Forcast",
name: "31 Dec 2022 Total",
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -1864,7 +1969,7 @@ export default class ProfitLoss extends Component {
}
}
}, {
name: "31-Dec-23 Forcast",
name: "31 Dec 2023 Total",
options: {
customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
......@@ -1937,27 +2042,84 @@ export default class ProfitLoss extends Component {
}
}
]
console.log(this.props.width);
const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader
// css={override}
size={20}
color={"#274B80"}
loading={this.state.loading}
/>
</div>
);
return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Pengajuan Budget Tahunan</Typography>
</div>
{this.state.loading && loadingComponent}
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Budget Tahunan - Profit & Loss</Typography>
</div>
<div style={{ padding: 20 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
<div style={{ display: 'flex', justifyContent: 'space-between'}}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ width: '50%'}}>
<div style={{justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
>
<img src={Images.template} />
</button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
>
<img src={Images.upload} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
</div>
</div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) , height: this.props.height - 400 }}>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150), height: this.props.height - 400 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
......@@ -1967,17 +2129,17 @@ export default class ProfitLoss extends Component {
</MuiThemeProvider>
</div>
</div>
<div className="grid grid-2x" style={{ marginTop: 20}}>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button
className="button"
type="button"
onClick={() => this.backToMasterBudget('draft')}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => this.props.onClickClose()}
>
<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>
......@@ -1985,12 +2147,6 @@ export default class ProfitLoss extends Component {
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960', marginRight: 20 }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 20 }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
<button
className="button"
type="button"
......@@ -1998,8 +2154,42 @@ export default class ProfitLoss extends Component {
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => {
this.props.onClickClose()
}}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960', marginRight: 20 }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
type="button"
onClick={() => this.backToMasterBudget('submitted')}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 20 }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => {
this.forceUpdate()
}}
onClick={() => this.forceUpdate()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
......
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