Commit d012efdf authored by Riri Novita's avatar Riri Novita

Rollback RO, OLPA & OI

parent b4f4c049
......@@ -76,7 +76,6 @@ export default class OperatingIndicatorMR extends Component {
visibleAlertSave: false
}
this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
}
componentDidMount() {
......@@ -428,46 +427,6 @@ export default class OperatingIndicatorMR extends Component {
});
}
fileHandlerSimulasi = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
console.log(resp)
if (err) {
// // console.log(err);
}
else {
let isi = resp.rows.slice(3)
// // console.log(isi);
let payload = []
let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
order: i[0] === undefined ? "" : String(i[0]).trim(),
item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
uom: i[3] === undefined ? "" : String(i[3]).trim(),
actual: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
mtd_vs_mb: i[5] === undefined ? "" : String(i[5]).trim(),
mtd_vs_rb: i[6] === undefined ? "" : String(i[6]).trim(),
})
}
})
let body = {
company_id: this.props.data.company.company_id,
periode: this.props.data.periode,
report_id: this.props.data.report_id,
months: this.props.months,
status: 'submitted',
monthly_report: payload
}
console.log(body)
console.log(JSON.stringify(body));
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
checkUpload() {
let payload = {
...this.state.payload,
......@@ -538,32 +497,6 @@ export default class OperatingIndicatorMR extends Component {
})
}
uploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
this.setState({ loading: true, dataTable: [] })
console.log(payload)
api.create().uploadSimulasiMROI(payload).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false })
}
})
}
uploadOI(type) {
let data = []
// console.log(this.state.dataTable)
......@@ -1767,21 +1700,6 @@ export default class OperatingIndicatorMR extends Component {
</div>
<div style={{ width: '50%' }}>
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload Simulasi'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginRight: 5
}}
onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })}
>
<img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
{this.state.get_for == 'edit' && (this.props.permission.create || this.props.permission.edit) && <a data-tip={'Download Template'} data-for="template">
<button
style={{
......@@ -2137,47 +2055,6 @@ export default class OperatingIndicatorMR extends Component {
</div>
)}
{this.state.visibleUploadSimulasi && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File Simulasi</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUploadSimulasi: false })}
>
<img src={Images.close} />
</button>
</div>
</div>
<div style={{ padding: '25px 30px' }}>
<UploadFile
type={this.state.uploadStatusSimulasi}
percentage={this.state.percentageSimulasi}
result={this.state.resultSimulasi}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandlerSimulasi(dt)
this.setState({ uploadStatusSimulasi: 'idle', percentageSimulasi: '0' })
}}
onUpload={() => {
String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") && String(this.state.judul).includes("OPERATING") && String(this.state.judul).includes("INDICATOR") ?
this.uploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</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>
)}
{this.state.visibleAlertSave && (
<div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
This diff is collapsed.
......@@ -339,10 +339,10 @@ export default class CashFlow extends Component {
})
console.log(listCF)
this.createCashFlow(listCF, trigger)
this.createCashFlow(listCF)
}
createCashFlow(dbcf, trigger) {
createCashFlow(dbcf) {
let payload = {
"outlook_pa_id": this.props.outlook_pa_id,
"company_id": this.props.company.company_id,
......@@ -355,71 +355,37 @@ export default class CashFlow extends Component {
}
console.log(dbcf)
console.log(JSON.stringify(payload))
if (trigger === 'simulasi') {
api.create().createSimulasiOLPACF(payload).then(response => {
console.log(payload);
console.log(response);
// console.log(JSON.stringify(payload))
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.props.onClickClose()
this.props.getReport()
})
}
// else {
// this.setState({ loading: false, handleDoubleClick: 0 }, () => {
// this.props.onClickClose()
// this.props.getReport()
// })
// }
api.create().createCFOLPA(payload).then(response => {
console.log(payload);
console.log(response);
// console.log(JSON.stringify(payload))
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
} else {
this.setState({ loading: false, handleDoubleClick: 0 })
}
})
} else {
api.create().createCFOLPA(payload).then(response => {
console.log(payload);
console.log(response);
// console.log(JSON.stringify(payload))
if (response.data) {
if (response.data.status === "success") {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.props.onClickClose()
this.props.getReport()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.props.onClickClose()
this.props.getReport()
})
}
// else {
// this.setState({ loading: false, handleDoubleClick: 0 }, () => {
// this.props.onClickClose()
// this.props.getReport()
// })
// }
} else {
this.setState({ loading: false, handleDoubleClick: 0 })
})
}
})
}
// else {
// this.setState({ loading: false, handleDoubleClick: 0 }, () => {
// this.props.onClickClose()
// this.props.getReport()
// })
// }
} else {
this.setState({ loading: false, handleDoubleClick: 0 })
}
})
this.props.onClickClose()
this.props.getReport()
}
......@@ -1831,7 +1797,7 @@ export default class CashFlow extends Component {
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[18]).toFixed(1)}
// value={Number(tableMeta.rowData[18]).toFixed(1)}
value={this.props.PLBSFAMSubmitted ? Number(tableMeta.rowData[18]).toFixed(1) : Number(handleTotal(tableMeta)).toFixed(1)}
/>
</span>
......@@ -2267,29 +2233,6 @@ export default class CashFlow extends Component {
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
// this.state.buttonError ?
// this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
// :
this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1 }, () => {
this.olahDataCashFlow(dataTable2, 'simulasi')
})}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 15
}}
>
<div style={{ backgroundColor: '#cd5c5c', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data Simulasi</Typography>
</div>
</button>
{this.state.viewOnly &&
<button
type="button"
......
......@@ -578,8 +578,7 @@ export default class OutlookPA extends Component {
})
}
getOutlookPAID(type, trigger) {
getOutlookPAID(type) {
this.setState({ loading: true })
let payload = {
"company_id": this.state.company.company_id,
......@@ -620,7 +619,7 @@ export default class OutlookPA extends Component {
this.getLatestPeriodSubmit()
if (type != undefined && type == 'PL') {
// this.getCashFlow(type)
this.getPL(type, trigger)
this.getPL(type)
} else if (type != undefined && type == 'BS') {
let bodyRatioOLPA = {
"report": 'ratio',
......@@ -1006,7 +1005,7 @@ export default class OutlookPA extends Component {
}
getPL(type, trigger) {
getPL(type) {
let PLID = null
let payloadID = {
"periode": this.state.periode.periode,
......@@ -1116,7 +1115,7 @@ export default class OutlookPA extends Component {
})
// console.log(dataTable)
this.setState({ dbPL: dataTable }, () => {
this.olahDataPL(this.state.dbPL, type, trigger)
this.olahDataPL(this.state.dbPL, type)
})
} else {
this.setState({ dbPL: [], previewTable: false, previewDownload: false })
......@@ -1355,7 +1354,7 @@ export default class OutlookPA extends Component {
return total
}
olahDataPL(dbPL, type, trigger) {
olahDataPL(dbPL, type) {
dbPL.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormulaDBPL(index, item[7], item, 7)
......@@ -1375,11 +1374,11 @@ export default class OutlookPA extends Component {
}
})
this.setState({ dbPL }, () => {
this.payloadPL(type, trigger)
this.payloadPL(type)
})
}
payloadPL(type, trigger) {
payloadPL(type) {
let listPL = []
// console.log(this.state.dbPL)
this.state.dbPL.map((item, index) => {
......@@ -1474,13 +1473,13 @@ export default class OutlookPA extends Component {
if (type != undefined) {
if (type == 'PL') {
console.log('tarik sis')
this.createDBPL(trigger)
this.createDBPL()
}
}
})
}
createDBPL(trigger) {
createDBPL() {
let payload = {
// "submission_id": this.state.submissionID,
"company_id": this.state.company.company_id,
......@@ -1493,17 +1492,10 @@ export default class OutlookPA extends Component {
}
console.log(this.state.dbPL)
// console.log(JSON.stringify(payload))
if (trigger === 'simulasiPL') {
api.create().createDBPLOLPASimulasi(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else {
api.create().createDBPLOLPA(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
api.create().createDBPLOLPA(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
handleApproveAdmin() {
......
This diff is collapsed.
This diff is collapsed.
......@@ -342,7 +342,7 @@ export default class CashFlow extends Component {
this.createCashFlow(listCF, trigger)
}
createCashFlow(dbcf, trigger) {
createCashFlow(dbcf) {
let payload = {
"rolling_outlook_id": this.props.rollingOutlookID,
"company_id": this.props.company.company_id,
......@@ -355,73 +355,41 @@ export default class CashFlow extends Component {
}
console.log(dbcf)
console.log(JSON.stringify(payload))
if (trigger === 'simulasi') {
api.create().createRollingOutlookCFSimulasi(payload).then(response => {
console.log(payload);
console.log(response);
// console.log(JSON.stringify(payload))
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.refresh()
} else {
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true, loading: false })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.props.onClickClose()
this.props.refresh()
})
}
}
api.create().createRollingOutlookCF(payload).then(response => {
console.log(payload);
console.log(response);
// console.log(JSON.stringify(payload))
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.refresh()
} else {
this.setState({ loading: false, handleDoubleClick: 0 })
}
})
} else {
api.create().createRollingOutlookCF(payload).then(response => {
console.log(payload);
console.log(response);
// console.log(JSON.stringify(payload))
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.refresh()
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true, loading: false })
} else {
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true, loading: false })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.props.onClickClose()
this.props.refresh()
})
}
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.props.onClickClose()
this.props.refresh()
})
}
// else {
// this.setState({ loading: false, handleDoubleClick: 0 }, () => {
// this.props.onClickClose()
// this.props.refresh()
// })
// }
} else {
this.setState({ loading: false, handleDoubleClick: 0 })
}
})
}
// else {
// this.setState({ loading: false, handleDoubleClick: 0 }, () => {
// this.props.onClickClose()
// this.props.refresh()
// })
// }
} else {
this.setState({ loading: false, handleDoubleClick: 0 })
}
})
this.props.onClickClose()
this.props.refresh()
}
......@@ -2250,29 +2218,6 @@ export default class CashFlow extends Component {
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
// this.state.buttonError ?
// this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
// :
this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1 }, () => {
this.olahDataCashFlow(dataTable2, 'simulasi')
})}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 15
}}
>
<div style={{ backgroundColor: '#cd5c5c', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data Simulasi</Typography>
</div>
</button>
{this.state.viewOnly &&
<button
type="button"
......
......@@ -606,7 +606,7 @@ export default class RollingOutlook extends Component {
})
}
getRollingOutlookID(type, trigger) {
getRollingOutlookID(type) {
this.setState({ loading: true })
let payload = {
"company_id": this.state.company.company_id,
......@@ -653,7 +653,7 @@ export default class RollingOutlook extends Component {
this.getLatestPeriodSubmit()
if (type != undefined && type == 'PL') {
// this.getCashFlow(type)
this.getPL(type, trigger)
this.getPL(type)
} else if (type != undefined && type == 'BS') {
let bodyRatioBs = {
"report": 'ratio',
......@@ -663,17 +663,10 @@ export default class RollingOutlook extends Component {
"quartal": this.state.quarter.value,
"currency_id": this.state.defaultCurrency.id
}
if (trigger === "simulasiPL") {
api.create().triggerRatioROSimulasi(bodyRatioBs).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else {
api.create().triggerRatioRO(bodyRatioBs).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
api.create().triggerRatioRO(bodyRatioBs).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else {
this.setState({ loading: false })
}
......@@ -1024,7 +1017,7 @@ export default class RollingOutlook extends Component {
}
}
getPL(type, trigger) {
getPL(type) {
let PLID = null
let payloadID = {
"periode": this.state.periode.periode,
......@@ -1135,7 +1128,7 @@ export default class RollingOutlook extends Component {
})
// console.log(dataTable)
this.setState({ dbPL: dataTable }, () => {
this.olahDataPL(this.state.dbPL, type, trigger)
this.olahDataPL(this.state.dbPL, type)
})
} else {
this.setState({ dbPL: [], previewTable: false, previewDownload: false })
......@@ -1374,7 +1367,7 @@ export default class RollingOutlook extends Component {
return total
}
olahDataPL(dbPL, type, trigger) {
olahDataPL(dbPL, type) {
dbPL.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormulaDBPL(index, item[7], item, 7)
......@@ -1394,11 +1387,11 @@ export default class RollingOutlook extends Component {
}
})
this.setState({ dbPL }, () => {
this.payloadPL(type, trigger)
this.payloadPL(type)
})
}
payloadPL(type, trigger) {
payloadPL(type) {
let listPL = []
// console.log(this.state.dbPL)
this.state.dbPL.map((item, index) => {
......@@ -1493,13 +1486,13 @@ export default class RollingOutlook extends Component {
if (type != undefined) {
if (type == 'PL') {
console.log('tarik sis')
this.createDBPL(trigger)
this.createDBPL()
}
}
})
}
createDBPL(trigger) {
createDBPL() {
let payload = {
// "submission_id": this.state.submissionID,
"company_id": this.state.company.company_id,
......@@ -1513,17 +1506,10 @@ export default class RollingOutlook extends Component {
}
console.log(this.state.dbPL)
// console.log(JSON.stringify(payload))
if (trigger === 'simulasiPL') {
api.create().createDBPLROSimulasi(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else {
api.create().createDBPLRO(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
api.create().createDBPLRO(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
handleApproveAdmin() {
......
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