Commit 76f099bd authored by Riri Novita's avatar Riri Novita

simulasi RO PL

parent 56ded309
...@@ -87,7 +87,8 @@ export default class ProfitLossROO extends Component { ...@@ -87,7 +87,8 @@ export default class ProfitLossROO extends Component {
viewOnly: true, viewOnly: true,
get_for: 'view', get_for: 'view',
defaultCurrencyUpload: this.props.defaultCurrency, defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false visibleAlertSave: false,
visibleButtonUpload: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -591,14 +592,106 @@ export default class ProfitLossROO extends Component { ...@@ -591,14 +592,106 @@ export default class ProfitLossROO extends Component {
}) })
} }
uploadSimulasi() { checkUploadSimulasi() {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id currency_id: this.state.defaultCurrencyUpload?.id
} }
api.create().checkImportRollingOutlookPL(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log("checkUpload Response", response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visiblePLRO: false, loading: true, visibleButtonUpload: true })
let dataTable = response.data.data.map((item, index) => {
return [
item.type_report_id,
item.item_report_id,
item.parent,
item.formula,
item.level,
item.item_report,
item.notes,
item.last_year_total === "" ? "0" : item.last_year_total,
item.january === "" ? "0" : item.january,
item.february === "" ? "0" : item.february,
item.march === "" ? "0" : item.march,
item.april === "" ? "0" : item.april,
item.may === "" ? "0" : item.may,
item.june === "" ? "0" : item.june,
item.july === "" ? "0" : item.july,
item.august === "" ? "0" : item.august,
item.september === "" ? "0" : item.september,
item.october === "" ? "0" : item.october,
item.november === "" ? "0" : item.november,
item.december === "" ? "0" : item.december,
item.current_year_total === "" ? "0" : item.current_year_total,
"",
item.order,
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
this.state.dataTable.map(item => {
// if (item[24].length > 0) {
// // console.log('masuk')
// this.setState({ buttonError: true, errorPreview: true })
// }
})
// console.log(this.state.buttonError)
})
console.log("checkUpload DataTable", dataTable);
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
}
})
}
uploadSimulasi(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
"item_report_id": i[1],
"item_report": i[5],
"notes": String(i[6]),
"last_year_total": String(Number(i[7]).toFixed(1)),
"january": String(Number(i[8]).toFixed(1)),
"february": String(Number(i[9]).toFixed(1)),
"march": String(Number(i[10]).toFixed(1)),
"april": String(Number(i[11]).toFixed(1)),
"may": String(Number(i[12]).toFixed(1)),
"june": String(Number(i[13]).toFixed(1)),
"july": String(Number(i[14]).toFixed(1)),
"august": String(Number(i[15]).toFixed(1)),
"september": String(Number(i[16]).toFixed(1)),
"october": String(Number(i[17]).toFixed(1)),
"november": String(Number(i[18]).toFixed(1)),
"december": String(Number(i[19]).toFixed(1)),
"current_year_total": String(Number(i[20]).toFixed(1)),
})
})
console.log("uploadProfitLossRO Data", data)
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,
"currency_id": this.state.defaultCurrencyUpload?.id,
"quartal": this.props.quarter,
"rolling_outlook_id": this.props.rollingOutlookID,
"status": type,
"profit_loss": data
}
this.setState({ loading: true, dataTable: [] }) this.setState({ loading: true, dataTable: [] })
console.log(payload) console.log(body)
api.create().uploadSimulasiROPL(payload).then(response => { api.create().uploadSimulasiROPL(body).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -2407,78 +2500,76 @@ export default class ProfitLossROO extends Component { ...@@ -2407,78 +2500,76 @@ export default class ProfitLossROO extends Component {
} }
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}> {this.props.isApprover === true || this.state.get_for == 'view' ?
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" /> null
<a data-tip={'Upload Simulasi'} data-for="upload"> // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button // <a data-tip={'Download'} data-for="download">
style={{ // <button
backgroundColor: 'transparent', // style={{
cursor: 'pointer', // backgroundColor: 'transparent',
borderColor: 'transparent', // cursor: 'pointer',
margin: 15 // borderColor: 'transparent',
}} // margin: 5
onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })} // }}
> // onClick={() =>
<img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} /> // this.setState({ loading: true }, () => {
</button> // setTimeout(() => {
</a> // this.downloadAllData()
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" /> // }, 100);
{this.props.isApprover === true || this.state.get_for == 'view' ? // })}
null // >
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> // <img src={Images.download} />
// <a data-tip={'Download'} data-for="download"> // </button>
// <button // </a>
// style={{ // <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
// backgroundColor: 'transparent', // </div>
// cursor: 'pointer', :
// borderColor: 'transparent', <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
// margin: 5 <a data-tip={'Upload Simulasi'} data-for="upload">
// }} <button
// onClick={() => style={{
// this.setState({ loading: true }, () => { backgroundColor: 'transparent',
// setTimeout(() => { cursor: 'pointer',
// this.downloadAllData() borderColor: 'transparent',
// }, 100); margin: 5
// })} }}
// > onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })}
// <img src={Images.download} /> >
// </button> <img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} />
// </a> </button>
// <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> </a>
// </div> <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
: <a data-tip={'Download Template'} data-for="template">
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <button
<a data-tip={'Download Template'} data-for="template"> style={{
<button backgroundColor: 'transparent',
style={{ cursor: 'pointer',
backgroundColor: 'transparent', borderColor: 'transparent',
cursor: 'pointer', margin: 5
borderColor: 'transparent', }}
margin: 5 onClick={() => this.setState({ loading: true }, () => {
}} this.downloadTemplate()
onClick={() => this.setState({ loading: true }, () => { })}
this.downloadTemplate() >
})} <img src={Images.template} />
> </button>
<img src={Images.template} /> </a>
</button> <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
</a> <a data-tip={'Upload'} data-for="upload">
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" /> <button
<a data-tip={'Upload'} data-for="upload"> style={{
<button backgroundColor: 'transparent',
style={{ cursor: 'pointer',
backgroundColor: 'transparent', borderColor: 'transparent',
cursor: 'pointer', margin: 5
borderColor: 'transparent', }}
margin: 5 onClick={() => this.setState({ visibleUpload: true })}
}} >
onClick={() => this.setState({ visibleUpload: true })} <img src={Images.upload} />
> </button>
<img src={Images.upload} /> </a>
</button> <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
</a> {/* <a data-tip={'Download'} data-for="download">
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -2494,10 +2585,9 @@ export default class ProfitLossROO extends Component { ...@@ -2494,10 +2585,9 @@ export default class ProfitLossROO extends Component {
<img src={Images.download} /> <img src={Images.download} />
</button> </button>
</a> </a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
</div> </div>
} }
</div>
</div> </div>
</div> </div>
...@@ -2849,12 +2939,37 @@ export default class ProfitLossROO extends Component { ...@@ -2849,12 +2939,37 @@ export default class ProfitLossROO extends Component {
}} }}
onUpload={() => { onUpload={() => {
String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("ROLLING") && String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PROFIT") && String(this.state.judul).includes("LOSS") ? String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("ROLLING") && String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PROFIT") && String(this.state.judul).includes("LOSS") ?
this.uploadSimulasi() : this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}} }}
/> />
</div> </div>
<div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.uploadSimulasi('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' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data</Typography>
</div>
</button>
</div>
</div>
}
{/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */}
</div> </div>
</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