Commit 016f707e authored by Riri Novita's avatar Riri Novita

RO simulasi

parent cf63463e
......@@ -91,6 +91,7 @@ export default class ProfitLossROO extends Component {
}
this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
}
componentDidMount() {
......@@ -478,6 +479,56 @@ export default class ProfitLossROO 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(resp.rows[2]);
let payload = []
let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
orders: i[0] === undefined ? "" : String(i[0]).trim(),
"item_report_id": i[1] === undefined ? 0 : i[1],
"item_report": i[2] === undefined ? "" : String(i[2]).trim(),
"notes": i[3] === undefined ? "" : reg.test(String(i[3])) === false ? "" : String(i[3]).trim(),
"january": i[5] === undefined ? "0" : reg.test(String(fixNumber(Number(i[5]), 1))) === false ? "0" : String(fixNumber(Number(i[5]), 1)).trim(),
"february": i[6] === undefined ? "0" : reg.test(String(fixNumber(Number(i[6]), 1))) === false ? "0" : String(fixNumber(Number(i[6]), 1)).trim(),
"march": i[7] === undefined ? "0" : reg.test(String(fixNumber(Number(i[7]), 1))) === false ? "0" : String(fixNumber(Number(i[7]), 1)).trim(),
"april": i[8] === undefined ? "0" : reg.test(String(fixNumber(Number(i[8]), 1))) === false ? "0" : String(fixNumber(Number(i[8]), 1)).trim(),
"may": i[9] === undefined ? "0" : reg.test(String(fixNumber(Number(i[9]), 1))) === false ? "0" : String(fixNumber(Number(i[9]), 1)).trim(),
"june": i[10] === undefined ? "0" : reg.test(String(fixNumber(Number(i[10]), 1))) === false ? "0" : String(fixNumber(Number(i[10]), 1)).trim(),
"july": i[11] === undefined ? "0" : reg.test(String(fixNumber(Number(i[11]), 1))) === false ? "0" : String(fixNumber(Number(i[11]), 1)).trim(),
"august": i[12] === undefined ? "0" : reg.test(String(fixNumber(Number(i[12]), 1))) === false ? "0" : String(fixNumber(Number(i[12]), 1)).trim(),
"september": i[13] === undefined ? "0" : reg.test(String(fixNumber(Number(i[13]), 1))) === false ? "0" : String(fixNumber(Number(i[13]), 1)).trim(),
"october": i[14] === undefined ? "0" : reg.test(String(fixNumber(Number(i[14]), 1))) === false ? "0" : String(fixNumber(Number(i[14]), 1)).trim(),
"november": i[15] === undefined ? "0" : reg.test(String(fixNumber(Number(i[15]), 1))) === false ? "0" : String(fixNumber(Number(i[15]), 1)).trim(),
"december": i[16] === undefined ? "0" : reg.test(String(fixNumber(Number(i[16]), 1))) === false ? "0" : String(fixNumber(Number(i[16]), 1)).trim(),
})
}
})
console.log("fileHandler payload", payload)
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
quartal: this.props.quarter,
rolling_outlook_id: this.props.rollingOutlookID,
status: 'submitted',
profit_loss: payload
}
console.log("fileHandler body", body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
checkUpload() {
let payload = {
...this.state.payload,
......@@ -540,6 +591,33 @@ export default class ProfitLossROO extends Component {
})
}
uploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
this.setState({ loading: true, dataTable: [] })
console.log(payload)
api.create().checkUploadMBSimulasi(payload).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.refresh('PL', 'simulasiPL')
this.setState({ loading: false })
} 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 })
}
})
}
uploadProfitLossRO(type) {
let data = []
this.state.dataTable.map(i => {
......@@ -2329,6 +2407,22 @@ export default class ProfitLossROO extends Component {
}
</div>
<div style={{ width: '50%' }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<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',
margin: 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.props.isApprover === true || this.state.get_for == 'view' ?
null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
......@@ -2405,6 +2499,7 @@ export default class ProfitLossROO extends Component {
}
</div>
</div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.refresh && (
......@@ -2722,6 +2817,48 @@ export default class ProfitLossROO extends Component {
</div>
)}
{this.state.visibleUploadSimulasi && (
// alert("Coming Soon...")
<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("ROLLING") && String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PROFIT") && String(this.state.judul).includes("LOSS") ?
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 }}>
......
......@@ -606,7 +606,7 @@ export default class RollingOutlook extends Component {
})
}
getRollingOutlookID(type) {
getRollingOutlookID(type, trigger) {
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)
this.getPL(type, trigger)
} else if (type != undefined && type == 'BS') {
let bodyRatioBs = {
"report": 'ratio',
......@@ -1017,7 +1017,7 @@ export default class RollingOutlook extends Component {
}
}
getPL(type) {
getPL(type, trigger) {
let PLID = null
let payloadID = {
"periode": this.state.periode.periode,
......@@ -1128,7 +1128,7 @@ export default class RollingOutlook extends Component {
})
// console.log(dataTable)
this.setState({ dbPL: dataTable }, () => {
this.olahDataPL(this.state.dbPL, type)
this.olahDataPL(this.state.dbPL, type, trigger)
})
} else {
this.setState({ dbPL: [], previewTable: false, previewDownload: false })
......@@ -1367,7 +1367,7 @@ export default class RollingOutlook extends Component {
return total
}
olahDataPL(dbPL, type) {
olahDataPL(dbPL, type, trigger) {
dbPL.map((item, index) => {
if (item[0] == 5 || item[0] == 6 || item[0] == 7) {
item[7].value = this.handleValueFormulaDBPL(index, item[7], item, 7)
......@@ -1387,11 +1387,11 @@ export default class RollingOutlook extends Component {
}
})
this.setState({ dbPL }, () => {
this.payloadPL(type)
this.payloadPL(type, trigger)
})
}
payloadPL(type) {
payloadPL(type, trigger) {
let listPL = []
// console.log(this.state.dbPL)
this.state.dbPL.map((item, index) => {
......@@ -1486,13 +1486,13 @@ export default class RollingOutlook extends Component {
if (type != undefined) {
if (type == 'PL') {
console.log('tarik sis')
this.createDBPL()
this.createDBPL(trigger)
}
}
})
}
createDBPL() {
createDBPL(trigger) {
let payload = {
// "submission_id": this.state.submissionID,
"company_id": this.state.company.company_id,
......@@ -1506,11 +1506,15 @@ export default class RollingOutlook extends Component {
}
console.log(this.state.dbPL)
// console.log(JSON.stringify(payload))
if (trigger === 'simulasiPL') {
} else {
api.create().createDBPLRO(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
}
handleApproveAdmin() {
this.setState({ visibleApproveSuperadmin: true })
......
......@@ -59,7 +59,8 @@ export default class TaxPlanning extends Component {
viewOnly: true,
}
this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this);
this.fileHandler = this.fileHandler.bind(this)
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this)
}
componentDidMount() {
......@@ -475,37 +476,37 @@ export default class TaxPlanning extends Component {
},
april: {
tbc: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[7]).trim()),2)) : String(roundMath(Number(String(i[7]).trim()),1)),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[7]).trim()), 2)) : String(roundMath(Number(String(i[7]).trim()), 1)),
tbf: this.props.quarter === "q2" || this.props.quarter === "q3" ? (i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim()) : (i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim()),
},
may: {
tbc: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[10]).trim()),2)) : String(roundMath(Number(String(i[10]).trim()),1)),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[10]).trim()), 2)) : String(roundMath(Number(String(i[10]).trim()), 1)),
tbf: this.props.quarter === "q2" || this.props.quarter === "q3" ? (i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim()) : (i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim()),
},
june: {
tbc: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[13]).trim()),2)) : String(roundMath(Number(String(i[13]).trim()),1)),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[13]).trim()), 2)) : String(roundMath(Number(String(i[13]).trim()), 1)),
tbf: this.props.quarter === "q2" || this.props.quarter === "q3" ? (i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim()) : (i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim()),
},
july: {
tbc: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim()) : (i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim()),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[10]).trim()),2)) : String(roundMath(Number(String(i[10]).trim()),1))) :
(i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[16]).trim()),2)) : String(roundMath(Number(String(i[16]).trim()),1))),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[10]).trim()), 2)) : String(roundMath(Number(String(i[10]).trim()), 1))) :
(i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[16]).trim()), 2)) : String(roundMath(Number(String(i[16]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim()) :
this.props.quarter === "q2" ? (i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim()) : (i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()),
},
august: {
tbc: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim()) : (i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim()),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[13]).trim()),2)) : String(roundMath(Number(String(i[13]).trim()),1))) :
(i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[19]).trim()),2)) : String(roundMath(Number(String(i[19]).trim()),1))),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[13]).trim()), 2)) : String(roundMath(Number(String(i[13]).trim()), 1))) :
(i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[19]).trim()), 2)) : String(roundMath(Number(String(i[19]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim()) :
this.props.quarter === "q2" ? (i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim()) : i[20] === undefined ? "0" : reg.test(String(i[20])) === false ? "0" : String(i[20]).trim(),
},
september: {
tbc: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim()) : (i[21] === undefined ? "0" : reg.test(String(i[21])) === false ? "0" : String(i[21]).trim()),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[16]).trim()),2)) : String(roundMath(Number(String(i[16]).trim()),1))) :
(i[22] === undefined ? "0" : reg.test(String(i[22])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[22]).trim()),2)) : String(roundMath(Number(String(i[22]).trim()),1))),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[16]).trim()), 2)) : String(roundMath(Number(String(i[16]).trim()), 1))) :
(i[22] === undefined ? "0" : reg.test(String(i[22])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[22]).trim()), 2)) : String(roundMath(Number(String(i[22]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim()) :
this.props.quarter === "q2" ? (i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()) : (i[23] === undefined ? "0" : reg.test(String(i[23])) === false ? "0" : String(i[23]).trim()),
},
......@@ -513,8 +514,8 @@ export default class TaxPlanning extends Component {
tbc: this.props.quarter === "q3" ? (i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim()) :
this.props.quarter === "q2" ? (i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim()) : (i[24] === undefined ? "0" : reg.test(String(i[24])) === false ? "0" : String(i[24]).trim()),
fcp: this.props.quarter === "q3" ? (i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim()) :
this.props.quarter === "q2" ? (i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[19]).trim()),2)) : String(roundMath(Number(String(i[19]).trim()),1))) :
(i[25] === undefined ? "0" : reg.test(String(i[25])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[25]).trim()),2)) : String(roundMath(Number(String(i[25]).trim()),1))),
this.props.quarter === "q2" ? (i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[19]).trim()), 2)) : String(roundMath(Number(String(i[19]).trim()), 1))) :
(i[25] === undefined ? "0" : reg.test(String(i[25])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[25]).trim()), 2)) : String(roundMath(Number(String(i[25]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim()) :
this.props.quarter === "q2" ? (i[20] === undefined ? "0" : reg.test(String(i[20])) === false ? "0" : String(i[20]).trim()) : (i[26] === undefined ? "0" : reg.test(String(i[26])) === false ? "0" : String(i[26]).trim()),
},
......@@ -522,8 +523,8 @@ export default class TaxPlanning extends Component {
tbc: this.props.quarter === "q3" ? (i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim()) :
this.props.quarter === "q2" ? (i[21] === undefined ? "0" : reg.test(String(i[21])) === false ? "0" : String(i[21]).trim()) : (i[27] === undefined ? "0" : reg.test(String(i[27])) === false ? "0" : String(i[27]).trim()),
fcp: this.props.quarter === "q3" ? (i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim()) :
this.props.quarter === "q2" ? (i[22] === undefined ? "0" : reg.test(String(i[22])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[22]).trim()),2)) : String(roundMath(Number(String(i[22]).trim()),1))) :
(i[28] === undefined ? "0" : reg.test(String(i[28])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[28]).trim()),2)) : String(roundMath(Number(String(i[28]).trim()),1))),
this.props.quarter === "q2" ? (i[22] === undefined ? "0" : reg.test(String(i[22])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[22]).trim()), 2)) : String(roundMath(Number(String(i[22]).trim()), 1))) :
(i[28] === undefined ? "0" : reg.test(String(i[28])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[28]).trim()), 2)) : String(roundMath(Number(String(i[28]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()) :
this.props.quarter === "q2" ? (i[23] === undefined ? "0" : reg.test(String(i[23])) === false ? "0" : String(i[23]).trim()) : (i[29] === undefined ? "0" : reg.test(String(i[29])) === false ? "0" : String(i[29]).trim()),
},
......@@ -531,8 +532,126 @@ export default class TaxPlanning extends Component {
tbc: this.props.quarter === "q3" ? (i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim()) :
this.props.quarter === "q2" ? (i[24] === undefined ? "0" : reg.test(String(i[24])) === false ? "0" : String(i[24]).trim()) : (i[30] === undefined ? "0" : reg.test(String(i[30])) === false ? "0" : String(i[30]).trim()),
fcp: this.props.quarter === "q3" ? (i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[19]).trim()) :
this.props.quarter === "q2" ? (i[25] === undefined ? "0" : reg.test(String(i[25])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[25]).trim()),2)) : String(roundMath(Number(String(i[25]).trim()),1))) :
(i[31] === undefined ? "0" : reg.test(String(i[31])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[31]).trim()),2)) : String(roundMath(Number(String(i[31]).trim()),1))),
this.props.quarter === "q2" ? (i[25] === undefined ? "0" : reg.test(String(i[25])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[25]).trim()), 2)) : String(roundMath(Number(String(i[25]).trim()), 1))) :
(i[31] === undefined ? "0" : reg.test(String(i[31])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[31]).trim()), 2)) : String(roundMath(Number(String(i[31]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[20] === undefined ? "0" : reg.test(String(i[20])) === false ? "0" : String(i[20]).trim()) :
this.props.quarter === "q2" ? (i[26] === undefined ? "0" : reg.test(String(i[26])) === false ? "0" : String(i[26]).trim()) : (i[32] === undefined ? "0" : reg.test(String(i[32])) === false ? "0" : String(i[32]).trim()),
},
total_current_year: this.props.quarter === "q3" ? (i[21] === undefined ? "0" : reg.test(String(i[21])) === false ? "0" : String(i[21]).trim()) :
this.props.quarter === "q2" ? (i[27] === undefined ? "" : String(i[27]).trim()) : (i[33] === undefined ? "" : String(i[33]).trim()),
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
rolling_outlook_id: this.props.rollingOutlookID,
quartal: this.props.quarter,
status: this.props.status,
tax_planning: payload
}
console.log(payload)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
}
});
}
fileHandlerSimulasi = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
console.log("masuk upload")
console.log(resp)
if (err) {
console.log(err);
}
else {
let isi = resp.rows.slice(4)
// console.log(resp.rows[2]);
// console.log(resp.rows);
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(),
january: {
// tbc: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
// fcp: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(String(i[3]).trim()).toFixed(1)) : String(Number(String(i[3]).trim()).toFixed(1)),
tbf: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
},
february: {
// tbc: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
// fcp: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(String(i[6]).trim()).toFixed(1)) : String(Number(String(i[6]).trim()).toFixed(1)),
tbf: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
},
march: {
// tbc: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
// fcp: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(String(i[9]).trim()).toFixed(1)) : String(Number(String(i[9]).trim()).toFixed(1)),
tbf: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
},
april: {
tbc: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[7]).trim()), 2)) : String(roundMath(Number(String(i[7]).trim()), 1)),
tbf: this.props.quarter === "q2" || this.props.quarter === "q3" ? (i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim()) : (i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim()),
},
may: {
tbc: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[10]).trim()), 2)) : String(roundMath(Number(String(i[10]).trim()), 1)),
tbf: this.props.quarter === "q2" || this.props.quarter === "q3" ? (i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim()) : (i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim()),
},
june: {
tbc: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
fcp: this.props.quarter === "q2" || this.props.quarter === "q3" ? null : i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[13]).trim()), 2)) : String(roundMath(Number(String(i[13]).trim()), 1)),
tbf: this.props.quarter === "q2" || this.props.quarter === "q3" ? (i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim()) : (i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim()),
},
july: {
tbc: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim()) : (i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim()),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[10]).trim()), 2)) : String(roundMath(Number(String(i[10]).trim()), 1))) :
(i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[16]).trim()), 2)) : String(roundMath(Number(String(i[16]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim()) :
this.props.quarter === "q2" ? (i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim()) : (i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()),
},
august: {
tbc: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim()) : (i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim()),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[13]).trim()), 2)) : String(roundMath(Number(String(i[13]).trim()), 1))) :
(i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[19]).trim()), 2)) : String(roundMath(Number(String(i[19]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim()) :
this.props.quarter === "q2" ? (i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim()) : i[20] === undefined ? "0" : reg.test(String(i[20])) === false ? "0" : String(i[20]).trim(),
},
september: {
tbc: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim()) : (i[21] === undefined ? "0" : reg.test(String(i[21])) === false ? "0" : String(i[21]).trim()),
fcp: this.props.quarter === "q3" ? null : this.props.quarter === "q2" ? (i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[16]).trim()), 2)) : String(roundMath(Number(String(i[16]).trim()), 1))) :
(i[22] === undefined ? "0" : reg.test(String(i[22])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[22]).trim()), 2)) : String(roundMath(Number(String(i[22]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim()) :
this.props.quarter === "q2" ? (i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()) : (i[23] === undefined ? "0" : reg.test(String(i[23])) === false ? "0" : String(i[23]).trim()),
},
october: {
tbc: this.props.quarter === "q3" ? (i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim()) :
this.props.quarter === "q2" ? (i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim()) : (i[24] === undefined ? "0" : reg.test(String(i[24])) === false ? "0" : String(i[24]).trim()),
fcp: this.props.quarter === "q3" ? (i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim()) :
this.props.quarter === "q2" ? (i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[19]).trim()), 2)) : String(roundMath(Number(String(i[19]).trim()), 1))) :
(i[25] === undefined ? "0" : reg.test(String(i[25])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[25]).trim()), 2)) : String(roundMath(Number(String(i[25]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim()) :
this.props.quarter === "q2" ? (i[20] === undefined ? "0" : reg.test(String(i[20])) === false ? "0" : String(i[20]).trim()) : (i[26] === undefined ? "0" : reg.test(String(i[26])) === false ? "0" : String(i[26]).trim()),
},
november: {
tbc: this.props.quarter === "q3" ? (i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim()) :
this.props.quarter === "q2" ? (i[21] === undefined ? "0" : reg.test(String(i[21])) === false ? "0" : String(i[21]).trim()) : (i[27] === undefined ? "0" : reg.test(String(i[27])) === false ? "0" : String(i[27]).trim()),
fcp: this.props.quarter === "q3" ? (i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim()) :
this.props.quarter === "q2" ? (i[22] === undefined ? "0" : reg.test(String(i[22])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[22]).trim()), 2)) : String(roundMath(Number(String(i[22]).trim()), 1))) :
(i[28] === undefined ? "0" : reg.test(String(i[28])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[28]).trim()), 2)) : String(roundMath(Number(String(i[28]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()) :
this.props.quarter === "q2" ? (i[23] === undefined ? "0" : reg.test(String(i[23])) === false ? "0" : String(i[23]).trim()) : (i[29] === undefined ? "0" : reg.test(String(i[29])) === false ? "0" : String(i[29]).trim()),
},
december: {
tbc: this.props.quarter === "q3" ? (i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim()) :
this.props.quarter === "q2" ? (i[24] === undefined ? "0" : reg.test(String(i[24])) === false ? "0" : String(i[24]).trim()) : (i[30] === undefined ? "0" : reg.test(String(i[30])) === false ? "0" : String(i[30]).trim()),
fcp: this.props.quarter === "q3" ? (i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[19]).trim()) :
this.props.quarter === "q2" ? (i[25] === undefined ? "0" : reg.test(String(i[25])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[25]).trim()), 2)) : String(roundMath(Number(String(i[25]).trim()), 1))) :
(i[31] === undefined ? "0" : reg.test(String(i[31])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[31]).trim()), 2)) : String(roundMath(Number(String(i[31]).trim()), 1))),
tbf: this.props.quarter === "q3" ? (i[20] === undefined ? "0" : reg.test(String(i[20])) === false ? "0" : String(i[20]).trim()) :
this.props.quarter === "q2" ? (i[26] === undefined ? "0" : reg.test(String(i[26])) === false ? "0" : String(i[26]).trim()) : (i[32] === undefined ? "0" : reg.test(String(i[32])) === false ? "0" : String(i[32]).trim()),
},
......@@ -624,6 +743,33 @@ export default class TaxPlanning extends Component {
})
}
uploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
this.setState({ loading: true, dataTable: [] })
console.log(payload)
api.create().checkUploadMBSimulasi(payload).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.refresh()
this.setState({ loading: false })
} 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 })
}
})
}
uploadTP(type) {
let data = []
this.state.dataTable.map(i => {
......@@ -747,7 +893,7 @@ export default class TaxPlanning extends Component {
if (String(i[8]) == "Control (should be nil)") {
this.setState({ loading: true })
let n = 0
for ( n = (this.props.quarter == 'q1' ? 12 : (this.props.quarter == 'q2' ? 15 : 18)) ; n <= 20; n++) {
for (n = (this.props.quarter == 'q1' ? 12 : (this.props.quarter == 'q2' ? 15 : 18)); n <= 20; n++) {
if ((Number(i[n].tbf.value) < Number(this.state.minValue) || Number(i[n].tbf.value) > Number(this.state.maxValue))) {
errorContrl = true
editAble = true
......@@ -6001,6 +6147,22 @@ export default class TaxPlanning extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ width: '50%' }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<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',
margin: 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.props.isApprover === true || this.state.get_for == 'view' ?
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download'} data-for="download">
......@@ -6075,6 +6237,7 @@ export default class TaxPlanning extends Component {
}
</div>
</div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent}
......@@ -6090,10 +6253,10 @@ export default class TaxPlanning extends Component {
</div>
{/* <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography> */}
<div style={{display: 'flex'}}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
<div style={{marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10}}>
{this.state.updateBy.reverse().map((item,index) => {
<div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
{this.state.updateBy.reverse().map((item, index) => {
return (
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>{item.latest_update}</Typography>
)
......@@ -6377,6 +6540,45 @@ export default class TaxPlanning extends Component {
</div>
</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>
<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={() => {
"ROLLING OUTLOOK - TAX PLANNING (in IDR mn)"
String(this.state.judul).includes("ROLLING") && String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("TAX") && String(this.state.judul).includes("PLANNING") ?
this.uploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</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