Commit cb98c5b4 authored by Riri Novita's avatar Riri Novita

Rollback Code MR Simulasi

parent fe5af8aa
......@@ -58,16 +58,14 @@ export default class BalanceSheetMR extends Component {
kansas: 0,
defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false,
visibleButtonUpload: false
}
this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
}
componentDidMount() {
this.getSettingControl()
this.getLatestUpdate()
// this.handleViewOnly()
this.handleViewOnly()
}
handleViewOnly() {
......@@ -371,45 +369,6 @@ export default class BalanceSheetMR 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 ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
actual: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
mtd_vs_previous_month: i[4] === undefined ? "" : 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.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
balance_sheet: payload,
months: this.props.month.month_id,
status: 'submitted'
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
checkUpload() {
let payload = {
...this.state.payload,
......@@ -486,135 +445,6 @@ export default class BalanceSheetMR extends Component {
})
}
checkUploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
api.create().checkUploadMonthlyReportBS(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleBSMR: false, loading: true, visibleButtonUpload: true })
let err = false
let dataTable = response.data.data.map((item, index) => {
if (item.type_report_id === 3) {
if (item.mtd_vs_mb == "" && Number(item.percent_act_vs_mb).toFixed(1) < this.state.minValue || Number(item.percent_act_vs_mb).toFixed(1) > this.state.maxValue) {
err = true
}
}
return [
item.type_report_id,
item.item_report_id,
item.parent,
item.formula,
item.level,
item.item_report,
item.rolling_outlook === null ? "" : item.rolling_outlook === "" ? "" : item.rolling_outlook,
item.master_budget === "" ? "" : item.master_budget,
item.rolling_budget === "" ? "" : item.rolling_budget,
item.actual === "" ? "" : item.actual,
item.actual_previous_month === null ? "0.0" : item.actual_previous_month === "" ? "0.0" : item.actual_previous_month,
item.amount_act_vs_previous_month === "" ? "0.0" : item.amount_act_vs_previous_month,
item.percent_act_vs_previous_month === "" ? "0.0" : item.percent_act_vs_previous_month,
item.amount_act_vs_mb === "" ? "0.0" : item.amount_act_vs_mb,
item.percent_act_vs_mb === "" ? "0.0" : item.percent_act_vs_mb,
item.amount_act_vs_rb === "" ? "0.0" : item.amount_act_vs_rb,
item.percent_act_vs_rb === "" ? "0.0" : item.percent_act_vs_rb,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
item.mtd_vs_previous_month === null ? "" : item.mtd_vs_previous_month === undefined ? "" : item.mtd_vs_previous_month,
item.mtd_vs_mb === null ? "" : item.mtd_vs_mb === undefined ? "" : item.mtd_vs_mb,
item.mtd_vs_rb === null ? "" : item.mtd_vs_rb === undefined ? "" : item.mtd_vs_rb,
item.actual_formula,
item.order,
item.condition_it_should_be,
item.condition_if_wrong,
item.error
]
})
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: true, isUpload: true }, () => {
this.state.dataTable.map(item => {
if (item[24].length > 0) {
// console.log('masuk')
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(this.state.buttonError)
})
} 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.setState({ loading: true })
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
item_report: String(i[5]),
rolling_outlook: i[0] === 5 || i[0] === 6 ? String(Number(i[6]).toFixed(1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6]).toFixed(1)),
master_budget: i[0] === 5 || i[0] === 6 ? String(Number(i[7]).toFixed(1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
rolling_budget: i[0] === 5 || i[0] === 6 ? String(Number(i[8]).toFixed(1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
actual: i[0] === 5 || i[0] === 6 ? String(Number(i[9]).toFixed(1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
actual_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[10]).toFixed(1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
amount_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[11]).toFixed(1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
percent_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[12]).toFixed(1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
amount_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[13]).toFixed(1)) : i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
percent_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[14]).toFixed(1)) : i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
amount_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[15]).toFixed(1)) : i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
percent_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[16]).toFixed(1)) : i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)),
mtd_vs_previous_month: String(i[17]),
mtd_vs_mb: String(i[18]),
mtd_vs_rb: String(i[19])
})
})
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.props.defaultCurrency.id,
"status": type,
"months": this.props.month.month_id,
"balance_sheet": data
}
this.setState({ loading: true, dataTable: [] })
console.log(body)
api.create().uploadSimulasiMRBS(body).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport('BS', 'simulasiBS')
} 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 })
}
})
}
uploadBalanceSheet(type) {
let data = []
this.setState({ loading: true })
......@@ -2819,20 +2649,6 @@ export default class BalanceSheetMR extends Component {
// </div>
:
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<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" />
<a data-tip={'Download Template'} data-for="template">
<button
style={{
......@@ -3216,72 +3032,6 @@ export default class BalanceSheetMR 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("BALANCE") && String(this.state.judul).includes("SHEET") ?
this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</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>
)}
{this.state.visibleAlertSave && (
<div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
......@@ -214,7 +214,7 @@ export default class CashFlowMR extends Component {
}
}
payloadCF(dataTable2, trigger) {
payloadCF(dataTable2) {
let listCF = []
console.log(dataTable2)
dataTable2.map((item, index) => {
......@@ -232,10 +232,10 @@ export default class CashFlowMR extends Component {
// }
})
this.createCashFlow(listCF, trigger)
this.createCashFlow(listCF)
}
createCashFlow(listCF, trigger) {
createCashFlow(listCF) {
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
......@@ -246,7 +246,7 @@ export default class CashFlowMR extends Component {
"currency_id": this.props.defaultCurrency.id,
"cash_flow": listCF
}
this.props.createCashFlow(payload, trigger)
this.props.createCashFlow(payload)
}
render() {
......@@ -766,29 +766,6 @@ export default class CashFlowMR 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.payloadCF(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"
......
......@@ -79,10 +79,8 @@ export default class CorporateAnnualTargetMR extends Component {
perfomanceScoreColor: '#fff',
defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false,
visibleButtonUpload: false
}
this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
}
componentDidMount() {
......@@ -92,7 +90,7 @@ export default class CorporateAnnualTargetMR extends Component {
this.getMaxAch()
this.getParameterGroup()
this.getParameterGroupPerfom()
// this.handleViewOnly()
this.handleViewOnly()
}
handleGetFor(type) {
......@@ -411,45 +409,6 @@ export default class CorporateAnnualTargetMR extends Component {
});
}
fileHandlerSimulasi = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, 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({
item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
weight: i[3] === undefined ? "" : (String(i[3])) === false ? "0" : String(i[3]).trim(),
uom: i[4] === undefined ? "" : (String(i[4])) === false ? "0" : String(i[4]).trim(),
jenis_kpi: i[5] === undefined ? "" : (String(i[5])) === false ? "0" : String(i[5]).trim(),
max_ach: i[6] === undefined ? "" : (String(i[6])) === false ? "0" : String(i[6]).trim(),
actual_monthly: i[7] === undefined ? "0.0" : (String(i[7])) === false ? "0" : String(i[7]).trim(),
notes: i[8] === undefined ? "" : (String(i[8])) === false ? "0" : String(i[8]).trim(),
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
months: this.props.month.month_id,
corporate_annual_target: payload,
status: "submitted"
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
checkUpload() {
this.setState({ loading: true })
let payload = {
......@@ -512,120 +471,6 @@ export default class CorporateAnnualTargetMR extends Component {
})
}
checkUploadSimulasi() {
this.setState({ loading: true })
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
api.create().checkUploadMonthlyReportCAT(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(this.state.payload)
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleCATMR: false, 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.parent == null ? (String(item.weight).includes("%") ? Number(String(item.weight).trim().substr(0, String(item.weight).trim().length - 1)) : Number(item.weight) * 100) : (String(item.weight).includes("%") ? String(item.weight).trim().substr(0, String(item.weight).trim().length - 1) : item.weight),
item.uom,
item.jenis_kpi,
item.max_ach,
item.formula_ytd,
item.actual_monthly,
item.target_monthly,
item.achivement_monthly,
item.score,
item.score_x_weight,
item.notes,
item.actual_formula === null ? [] : item.actual_formula,
item.order,
item.error
]
})
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.handleCalculate(dataTable)
this.state.dataTable.map(item => {
if (item[16].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
})
console.log(this.state.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: String(i[5]),
weight: String(i[6]),
uom: String(i[7]),
jenis_kpi: i[8] == null ? "" : i[8],
max_ach: i[9] == null ? "" : i[9],
formula_ytd: i[10] == null ? "" : i[10],
actual_monthly: String(Number(i[11]).toFixed(1)),
target_monthly: String(Number(i[12]).toFixed(1)),
achivement_monthly: String(Number(i[13]).toFixed(1)),
score: String(Number(i[14]).toFixed(0)),
score_x_weight: String(Number(i[15]).toFixed(2)),
notes: String(i[16])
})
})
let body = {
// "monthly_report_id": this.props.monthlyReportId,
"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,
"currency_id": this.props.defaultCurrency.id,
"corporate_annual_target": data,
"total_score": this.state.totalScore,
"performance": this.state.perfomanceScore
}
this.setState({ loading: true, dataTable: [] })
console.log(body)
api.create().uploadSimulasiMRCAT(body).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.onClickClose()
} 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 })
}
})
}
uploadCATMR(type) {
let data = []
this.state.dataTable.map(i => {
......@@ -2144,20 +1989,6 @@ export default class CorporateAnnualTargetMR extends Component {
</div>
<div style={{ width: '50%' }}>
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
{this.state.get_for == 'edit' && <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.state.get_for == 'edit' && <a data-tip={'Download Template'} data-for="template">
<button
style={{
......@@ -2584,72 +2415,6 @@ export default class CorporateAnnualTargetMR 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("PERFORMANCE") && String(this.state.judul).includes("CAT") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</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>
)}
{this.state.visibleAlertSave && (
<div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
......@@ -54,16 +54,14 @@ export default class FixedAssetsMovementMR extends Component {
viewOnly: true,
defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false,
visibleButtonUpload: false
}
this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
}
componentDidMount() {
this.getItemHierarki()
this.getLatestUpdate()
// this.handleViewOnly()
this.handleViewOnly()
}
handleGetFor(type) {
......@@ -301,40 +299,6 @@ export default class FixedAssetsMovementMR extends Component {
});
}
fileHandlerSimulasi = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
if (err) {
console.log(err);
}
else {
let isi = resp.rows.slice(3)
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 ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
mtd_actual: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
months: this.props.month.month_id,
fixed_asset_movement: payload,
status: 'submitted'
}
// console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
checkUpload() {
let payload = {
...this.state.payload,
......@@ -394,110 +358,6 @@ export default class FixedAssetsMovementMR extends Component {
})
}
checkUploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
api.create().checkUploadMonthlyReportFAM(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
// console.log(this.state.payload)
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleFAMMR: false, refresh: 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.mtd_mb,
item.mtd_rb,
item.mtd_actual,
item.act_vs_mb_amount,
item.act_vs_mb_percent,
item.act_vs_rb_amount,
item.act_vs_rb_percent,
item.actual_formula,
item.order,
item.error
]
})
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: true, editable: true, refresh: false }, () => {
this.state.dataTable.map(item => {
if (item[15].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true, loading: true, refresh: true })
setTimeout(() => {
this.setState({ loading: false, refresh: false })
}, 200);
}
})
// console.log(this.state.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: String(i[5]),
mtd_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[6]).toFixed(1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6]).toFixed(1)),
mtd_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[7]).toFixed(1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
mtd_actual: i[0] === 5 || i[0] === 6 ? String(Number(i[8]).toFixed(1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
act_vs_mb_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[9]).toFixed(1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
act_vs_mb_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[10]).toFixed(1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
act_vs_rb_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[11]).toFixed(1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
act_vs_rb_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[12]).toFixed(1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
})
})
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.props.defaultCurrency.id,
"status": type,
"months": this.props.month.month_id,
"fixed_asset_movement": data
}
this.setState({ loading: true, dataTable: [] })
console.log(body)
api.create().uploadSimulasiMRFAM(body).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport('FAM')
} 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 })
}
})
}
uploadFAMMR(type) {
let data = []
this.state.dataTable.map(i => {
......@@ -1526,20 +1386,6 @@ export default class FixedAssetsMovementMR extends Component {
// </div>
:
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<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" />
<a data-tip={'Download Template'} data-for="template">
<button
style={{
......@@ -1904,72 +1750,6 @@ export default class FixedAssetsMovementMR 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.fileHandler(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("FIXED") && String(this.state.judul).includes("ASSETS") && String(this.state.judul).includes("MOVEMENT") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</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>
)}
{this.state.visibleAlertSave && (
<div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
......@@ -122,10 +122,8 @@ export default class ListOfCreditFacilities extends Component {
saveTambahan: true,
defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false,
visibleButtonUpload: false
}
this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
}
componentDidMount() {
......@@ -134,7 +132,7 @@ export default class ListOfCreditFacilities extends Component {
this.getTypeOfCredit()
this.getSubmission()
this.getLatestUpdate()
// this.handleViewOnly()
this.handleViewOnly()
}
handleGetFor(type) {
......@@ -511,83 +509,6 @@ export default class ListOfCreditFacilities 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) {
let tgl = String(i[5]).split('-')
console.log(i[5])
console.log(tgl)
payload.push({
"item_report_id": i[1],
"borrower_comp_name": this.props.company.company_name,
"bank_name": i[2],
"type_of_credit": i[3],
"remarks": i[4],
"loan_maturity_date": i[5] !== undefined ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : null,
"interest": i[6],
"currency": i[7],
"loan_plafond_amount_ori": i[8] !== undefined ? Number(i[8]).toFixed(1) : i[8],
"loan_plafond_amount_idr": i[9] !== undefined ? Number(i[9]).toFixed(1) : i[9],
"out_loan_ki_amount_ori": i[10] !== undefined ? Number(i[10]).toFixed(1) : i[10],
"out_loan_ki_amount_idr": i[11] !== undefined ? Number(i[11]).toFixed(1) : i[11],
"out_loan_kmk_amount_ori": i[12] !== undefined ? Number(i[12]).toFixed(1) : i[12],
"out_loan_kmk_amount_idr": i[13] !== undefined ? Number(i[13]).toFixed(1) : i[13],
"out_loan_other_type": i[14],
"out_loan_other_amount_ori": i[15] !== undefined ? Number(i[15]).toFixed(1) : i[15],
"out_loan_other_amount_idr": i[16] !== undefined ? Number(i[16]).toFixed(1) : i[16],
// "total_out_loan_ori": i[18],
// "total_out_loan_idr": i[19],
// "remaining_plafond_ori": i[20],
// "remaining_plafond_idr": i[21],
"current_ratio_financial": i[17],
"der_financial": i[18],
"debt_to_ebitda_financial": i[19],
"ebitda_to_interest_financial": i[20],
"other_ratio1_ratio_name": i[21],
"other_ratio1_financial": i[22],
"other_ratio1_current": i[23],
"other_ratio2_ratio_name": i[24],
"other_ratio2_financial": i[25],
"other_ratio2_current": i[26],
"other_ratio3_ratio_name": i[27],
"other_ratio3_financial": i[28],
"other_ratio3_current": i[29],
"other_ratio4_ratio_name": i[30],
"other_ratio4_financial": i[31],
"other_ratio4_current": i[32],
"notes": i[33],
})
}
})
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": 'submitted',
"months": this.props.month.month_id,
"locf": payload,
"per_bs": this.state.perBS,
"diff": this.state.diff,
"total_loan": this.state.perBS
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
deleteReport() {
let payload = { "item_report_id": this.state.dataDelete, "periode": this.props.periode, "months": this.props.month.month_id }
......@@ -761,265 +682,6 @@ export default class ListOfCreditFacilities extends Component {
})
}
checkUploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
let dataDelete = []
api.create().getIdDeleteFromExcelLOCF(payload).then((response) => {
console.log(response)
// if (response.data) {
// // // // // // console.log(response.data)
// let idDelete = response.data.data.item_report_id
// if (idDelete.length > 0) {
// idDelete.map((item, index) => {
// dataDelete.push(item)
// })
// this.setState({ dataDelete })
// }
// }
})
api.create().checkUploadMonthlyReportLOCF(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleLOCFMR: false, totalOutStand: 0, diff: 0, visibleButtonUpload: true })
let dataTable = []
response.data.data.map((item, index) => {
if (index == response.data.data.length - 1) {
dataTable.push([
3,
item.item_report_id,
item.parent,
item.formula,
item.level,
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 ? "" : item.remarks === "" ? "" : item.remarks,
item.loan_maturity_date === null || item.loan_maturity_date === "" ? null : item.loan_maturity_date,
item.interest === null || item.interest === "" ? "0.00" : item.interest,
item.currency === null || item.currency === "" ? "" : item.currency,
item.loan_plafond_amount_ori == null ? "" : 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,
item.type_of_credit == "Investment Loan" ? item.out_loan_ki_amount_ori : "0.0",
item.type_of_credit == "Investment Loan" ? (item.out_loan_ki_amount_idr === null ? "0.0" : item.out_loan_ki_amount_idr === "" ? "0.0" : item.out_loan_ki_amount_idr) : "0.0",
item.type_of_credit == "Revolving Loan (KMK)" ? item.out_loan_kmk_amount_ori : "0.0",
item.type_of_credit == "Revolving Loan (KMK)" ? (item.out_loan_kmk_amount_idr === null ? "0.0" : item.out_loan_kmk_amount_idr === "" ? "0.0" : item.out_loan_kmk_amount_idr) : "0.0",
item.type_of_credit == "Others" ? item.out_loan_other_type : "",
item.type_of_credit == "Others" ? item.out_loan_other_amount_ori : "0.0",
item.type_of_credit == "Others" ? (item.out_loan_other_amount_idr === null ? "0.0" : item.out_loan_other_amount_idr === "" ? "0.0" : item.out_loan_other_amount_idr) : "0.0",
item.total_out_loan_ori === null ? "0.0" : item.total_out_loan_ori === "" ? "0.0" : item.total_out_loan_ori,
item.total_out_loan_idr === null ? "0.0" : item.total_out_loan_idr === "" ? "0.0" : item.total_out_loan_idr,
item.remaining_plafond_ori === null ? "0.0" : item.remaining_plafond_ori === "" ? "0.0" : item.remaining_plafond_ori,
item.remaining_plafond_idr === null ? "0.0" : item.remaining_plafond_idr === "" ? "0.0" : item.remaining_plafond_idr,
item.current_ratio_financial == null ? "" : item.current_ratio_financial,
item.current_ratio_current === null ? "0.0" : item.current_ratio_current === "" ? "0.0" : item.current_ratio_current,
item.der_financial == null ? "" : item.der_financial,
item.der_current === null ? "0.0" : item.der_current === "" ? "0.0" : item.der_current,
item.debt_to_ebitda_financial == null ? "" : item.debt_to_ebitda_financial,
item.debt_to_ebitda_current === null ? "0.0" : item.debt_to_ebitda_current === "" ? "0.0" : item.debt_to_ebitda_current,
item.ebitda_to_interest_financial == null ? "" : 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 == null ? "" : item.other_ratio1_ratio_name,
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 == null ? "" : item.other_ratio2_ratio_name,
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 == null ? "" : item.other_ratio3_ratio_name,
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 == null ? "" : item.other_ratio4_ratio_name,
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,
],
[9, "", "", "", "", "", { value: "Grand Total" }, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999],
)
} else {
dataTable.push([
3,
item.item_report_id,
item.parent,
item.formula,
item.level,
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 ? "" : item.remarks === "" ? "" : item.remarks,
item.loan_maturity_date === null || item.loan_maturity_date === "" ? null : item.loan_maturity_date,
item.interest === null || item.interest === "" ? "0.00" : item.interest,
item.currency === null || item.currency === "" ? "" : item.currency,
item.loan_plafond_amount_ori == null ? "" : 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,
item.type_of_credit == "Investment Loan" ? item.out_loan_ki_amount_ori : "0.0",
item.type_of_credit == "Investment Loan" ? (item.out_loan_ki_amount_idr === null ? "0.0" : item.out_loan_ki_amount_idr === "" ? "0.0" : item.out_loan_ki_amount_idr) : "0.0",
item.type_of_credit == "Revolving Loan (KMK)" ? item.out_loan_kmk_amount_ori : "0.0",
item.type_of_credit == "Revolving Loan (KMK)" ? (item.out_loan_kmk_amount_idr === null ? "0.0" : item.out_loan_kmk_amount_idr === "" ? "0.0" : item.out_loan_kmk_amount_idr) : "0.0",
item.type_of_credit == "Others" ? item.out_loan_other_type : "",
item.type_of_credit == "Others" ? item.out_loan_other_amount_ori : "0.0",
item.type_of_credit == "Others" ? (item.out_loan_other_amount_idr === null ? "0.0" : item.out_loan_other_amount_idr === "" ? "0.0" : item.out_loan_other_amount_idr) : "0.0",
item.total_out_loan_ori === null ? "0.0" : item.total_out_loan_ori === "" ? "0.0" : item.total_out_loan_ori,
item.total_out_loan_idr === null ? "0.0" : item.total_out_loan_idr === "" ? "0.0" : item.total_out_loan_idr,
item.remaining_plafond_ori === null ? "0.0" : item.remaining_plafond_ori === "" ? "0.0" : item.remaining_plafond_ori,
item.remaining_plafond_idr === null ? "0.0" : item.remaining_plafond_idr === "" ? "0.0" : item.remaining_plafond_idr,
item.current_ratio_financial == null ? "" : item.current_ratio_financial,
item.current_ratio_current === null ? "0.0" : item.current_ratio_current === "" ? "0.0" : item.current_ratio_current,
item.der_financial == null ? "" : item.der_financial,
item.der_current === null ? "0.0" : item.der_current === "" ? "0.0" : item.der_current,
item.debt_to_ebitda_financial == null ? "" : item.debt_to_ebitda_financial,
item.debt_to_ebitda_current === null ? "0.0" : item.debt_to_ebitda_current === "" ? "0.0" : item.debt_to_ebitda_current,
item.ebitda_to_interest_financial == null ? "" : 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 == null ? "" : item.other_ratio1_ratio_name,
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 == null ? "" : item.other_ratio2_ratio_name,
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 == null ? "" : item.other_ratio3_ratio_name,
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 == null ? "" : item.other_ratio4_ratio_name,
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,
])
}
// if (item.children !== null) {
// if (item.children.length > 0) {
// item.children.map((items, indexs) => {
// handlePushChild(items)
// })
// }
// }
})
// console.log(dataTable);
if (dataTable.length == 0) {
dataTable.push(
[3, "", "", "", "", this.props.company.company_name, null, null, "", null, "0.00", "", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "", 0],
[9, "", "", "", "", "", { value: "Grand Total" }, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999],
)
}
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => {
this.handleCalculate()
this.state.dataTable.map(item => {
if (item[23].length > 0) {
// console.log('masuk')
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(this.state.buttonError)
})
// console.log(dataTable);
}
}
})
}
uploadSimulasi(type) {
let data = []
let error = false
this.deleteReport()
this.state.dataTable.map(i => {
if (i[0] == 3) {
if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "") {
error = true
}
if (i[7].value == 'Others' && i[18] == '') {
error = true
}
let tgl = String(i[9]).split('-')
let checkUndifined = tgl.findIndex((val) => val == undefined)
data.push({
"item_report_id": i[1],
"borrower_comp_name": i[5],
"bank_name": i[6] == null ? [6] : i[6].value,
"type_of_credit": i[7] == null ? i[7] : i[7].value,
"remarks": i[8],
// "loan_maturity_date": i[9],
"loan_maturity_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
// "loan_maturity_date": i[9] !== undefined || i[9] !== "null" || i[9] !== null? (String(tgl[2]).length <= 2? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])) : "",
"interest": i[10] == "" ? "0.00" : i[10],
"currency": i[11],
"loan_plafond_amount_ori": Number(i[12]).toFixed(1) == "" ? "0.0" : Number(i[12]).toFixed(1),
"loan_plafond_amount_idr": Number(i[13]).toFixed(1) == "" ? "0.0" : Number(i[13]).toFixed(1),
"out_loan_ki_amount_ori": Number(i[14]).toFixed(1) == "" ? "0.0" : Number(i[14]).toFixed(1),
"out_loan_ki_amount_idr": Number(i[15]).toFixed(1) == "" ? "0.0" : Number(i[15]).toFixed(1),
"out_loan_kmk_amount_ori": Number(i[16]).toFixed(1) == "" ? "0.0" : Number(i[16]).toFixed(1),
"out_loan_kmk_amount_idr": Number(i[17]).toFixed(1) == "" ? "0.0" : Number(i[17]).toFixed(1),
// "mtd_vs_previous_month": i[18],
"out_loan_other_type": i[18],
"out_loan_other_amount_ori": Number(i[19]).toFixed(1) == "" ? "0.0" : Number(i[19]).toFixed(1),
"out_loan_other_amount_idr": Number(i[20]).toFixed(1) == "" ? "0.0" : Number(i[20]).toFixed(1),
"total_out_loan_ori": Number(i[21]).toFixed(1) == "" ? "0.0" : Number(i[21]).toFixed(1),
"total_out_loan_idr": Number(i[22]).toFixed(1) == "" ? "0.0" : Number(i[22]).toFixed(1),
"remaining_plafond_ori": Number(i[23]).toFixed(1) == "" ? "0.0" : Number(i[23]).toFixed(1),
"remaining_plafond_idr": Number(i[24]).toFixed(1) == "" ? "0.0" : Number(i[24]).toFixed(1),
"current_ratio_financial": Number(i[25]).toFixed(2) == "" ? "0.00" : Number(i[25]).toFixed(2),
"current_ratio_current": Number(i[26]).toFixed(2) == "" ? "0.00" : Number(i[26]).toFixed(2),
"der_financial": Number(i[27]).toFixed(2) == "" ? "0.00" : Number(i[27]).toFixed(2),
"der_current": Number(i[28]).toFixed(2) == "" ? "0.00" : Number(i[28]).toFixed(2),
"debt_to_ebitda_financial": Number(i[29]).toFixed(2) == "" ? "0.00" : Number(i[29]).toFixed(2),
"debt_to_ebitda_current": Number(i[30]).toFixed(2) == "" ? "0.00" : Number(i[30]).toFixed(2),
"ebitda_to_interest_financial": Number(i[31]).toFixed(2) == "" ? "0.00" : Number(i[31]).toFixed(2),
"ebitda_to_interest_current": Number(i[32]).toFixed(2) == "" ? "0.00" : Number(i[32]).toFixed(2),
"other_ratio1_ratio_name": i[33],
"other_ratio1_financial": Number(i[34]).toFixed(2) == "" ? "0.00" : Number(i[34]).toFixed(2),
"other_ratio1_current": Number(i[35]).toFixed(2) == "" ? "0.00" : Number(i[35]).toFixed(2),
"other_ratio2_ratio_name": i[36],
"other_ratio2_financial": Number(i[37]).toFixed(2) == "" ? "0.00" : Number(i[37]).toFixed(2),
"other_ratio2_current": Number(i[38]).toFixed(2) == "" ? "0.00" : Number(i[38]).toFixed(2),
"other_ratio3_ratio_name": i[39],
"other_ratio3_financial": Number(i[40]).toFixed(2) == "" ? "0.00" : Number(i[40]).toFixed(2),
"other_ratio3_current": Number(i[41]).toFixed(2) == "" ? "0.00" : Number(i[41]).toFixed(2),
"other_ratio4_ratio_name": i[42],
"other_ratio4_financial": Number(i[43]).toFixed(2) == "" ? "0.00" : Number(i[43]).toFixed(2),
"other_ratio4_current": Number(i[44]).toFixed(2) == "" ? "0.00" : Number(i[44]).toFixed(2),
"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,
"currency_id": this.props.defaultCurrency.id,
"locf": data,
"per_bs": this.state.perBS,
"diff": this.state.diff,
"total_loan": this.state.perBS
}
this.setState({ loading: true, dataTable: [] })
console.log(body)
api.create().uploadSimulasiMRLOCF(body).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport('LOCF', "simulasiLOCF")
} 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 })
}
})
}
uploadLOCF(type) {
let data = []
let error = false
......@@ -4173,26 +3835,6 @@ export default class ListOfCreditFacilities 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" />
{(this.state.get_for == 'edit' &&
<div>
<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" />
</div>
)}
{(this.state.get_for == 'edit' &&
<div>
<a data-tip={'Download Template'} data-for="template">
......@@ -4717,72 +4359,6 @@ export default class ListOfCreditFacilities 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({ uploadStatus: 'idle', percentage: '0' })
}}
onUpload={() => {
String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("LIST") && String(this.state.judul).includes("CREDIT") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
this.checkUploadSimulasi() :
this.setState({ snekbar: true, snekbarMsg: 'Invalid Template', tipeAlert: 'warning' })
}}
/>
</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>
)}
{this.state.visibleAlertSave && (
<div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
......@@ -685,7 +685,7 @@ export default class MonthlyReport extends Component {
})
}
getMonthlyReportID(type, trigger) {
getMonthlyReportID(type) {
this.setState({ selectReport: [], isCheckAll: false }, () => {
let payload = {
"company_id": this.state.company.company_id,
......@@ -730,7 +730,7 @@ export default class MonthlyReport extends Component {
}
// this.getPL(type)
if (type != undefined && type == 'PL') {
this.getPL(type, trigger)
this.getPL(type)
} else if (type != undefined && type == 'LOCF') {
let bodyRatioLocf = {
"report": 'ratio',
......@@ -740,17 +740,10 @@ export default class MonthlyReport extends Component {
"months": this.state.month.month_id,
"currency_id": this.state.defaultCurrency.id
}
if (trigger == "simulasiLOCF") {
api.create().triggerHistoricalRatioSimulasi(bodyRatioLocf).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else {
api.create().triggerHistoricalRatio(bodyRatioLocf).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
api.create().triggerHistoricalRatio(bodyRatioLocf).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else if (type != undefined && type == 'BS') {
let bodyRatioBs = {
"report": 'ratio',
......@@ -760,17 +753,10 @@ export default class MonthlyReport extends Component {
"months": this.state.month.month_id,
"currency_id": this.state.defaultCurrency.id
}
if (trigger === 'simulasiBS') {
api.create().triggerRatioFromLOCFSimulasi(bodyRatioBs).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else {
api.create().triggerRatioFromLOCF(bodyRatioBs).then((res) => {
console.log(res)
this.setState({ loading: false })
})
}
api.create().triggerRatioFromLOCF(bodyRatioBs).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else {
this.setState({ loading: false })
}
......@@ -856,8 +842,7 @@ export default class MonthlyReport extends Component {
})
}
saveToMonthlyReport(type, trigger) {
console.log(trigger);
saveToMonthlyReport(type) {
this.setState({
visibleMonthlyReport: true,
loading: true,
......@@ -870,7 +855,7 @@ export default class MonthlyReport extends Component {
visibleLOCF: false,
visibleOI: false,
}, () => {
this.getMonthlyReportID(type, trigger)
this.getMonthlyReportID(type)
})
}
......@@ -1543,22 +1528,15 @@ export default class MonthlyReport extends Component {
})
}
createCashFlow(payload, trigger) {
createCashFlow(payload) {
console.log(JSON.stringify(payload))
if (trigger === "simulasi") {
api.create().uploadSimulasiMRCF(payload).then((res) => {
this.saveToMonthlyReport()
console.log(res)
})
} else {
api.create().createMonthlyReportCF(payload).then((res) => {
this.saveToMonthlyReport()
console.log(res)
})
}
api.create().createMonthlyReportCF(payload).then((res) => {
this.saveToMonthlyReport()
console.log(res)
})
}
getPL(type, trigger) {
getPL(type) {
let PLID = null
let payloadID = {
"periode": this.state.periode.periode,
......@@ -1683,7 +1661,7 @@ export default class MonthlyReport extends Component {
console.log(JSON.stringify(dataTable))
console.log(dataTable)
this.setState({ dbPL: dataTable }, () => {
this.olahDataPL(this.state.dbPL, type, trigger)
this.olahDataPL(this.state.dbPL, type)
})
} else {
this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -1919,7 +1897,7 @@ export default class MonthlyReport extends Component {
}
olahDataPL(dbPL, type, trigger) {
olahDataPL(dbPL, type) {
dbPL.map((item, index) => {
if (item[0] == 5 || item[0] == 6) {
item[6].value = this.handleValueFormulaDBPLMR(item[6], item, 6)
......@@ -1928,11 +1906,11 @@ export default class MonthlyReport extends Component {
})
// console.log(dbPL)
this.setState({ dbPL }, () => {
this.payloadPL(type, trigger)
this.payloadPL(type)
})
}
payloadPL(type, trigger) {
payloadPL(type) {
let listPL = []
this.state.dbPL.map((item, index) => {
// if (item[6].value == "" || item[6].value == 0 || item[6].value == "0.0") {
......@@ -1961,14 +1939,14 @@ export default class MonthlyReport extends Component {
// console.log(this.state.dbPL)
// this.setState({ loading: false })
console.log('tarik sis')
this.createPL(trigger)
this.createPL()
}
}
})
}
createPL(trigger) {
console.log(trigger);
createPL() {
console.log();
let payload = {
// "monthly_report_id": this.state.monthlyReportId,
"company_id": this.state.company.company_id,
......@@ -1981,32 +1959,25 @@ export default class MonthlyReport extends Component {
"profit_loss_mr": this.state.dbPL,
"currency_id": this.state.defaultCurrency.id
}
if (trigger === "simulasiPL") {
api.create().createSimulasiReportPLMR(payload).then((res) => {
console.log(res)
this.setState({ loading: false })
})
} else {
api.create().createReportPLMR(payload).then((res) => {
console.log(res)
// console.log(this.state.dbPL)
this.setState({ loading: false })
// if (response.data) {
// if (response.data.status === "success") {
// this.props.saveToMonthlyReport()
// } else {
// this.setState({ loading: false }, () => {
// this.props.saveToMonthlyReport()
// })
// }
// } else {
// this.setState({ loading: false }, () => {
// // this.getSubmission()
// document.body.style.overflow = 'unset';
// })
// }
})
}
api.create().createReportPLMR(payload).then((res) => {
console.log(res)
// console.log(this.state.dbPL)
this.setState({ loading: false })
// if (response.data) {
// if (response.data.status === "success") {
// this.props.saveToMonthlyReport()
// } else {
// this.setState({ loading: false }, () => {
// this.props.saveToMonthlyReport()
// })
// }
// } else {
// this.setState({ loading: false }, () => {
// // this.getSubmission()
// document.body.style.overflow = 'unset';
// })
// }
})
}
getFR(type) {
......
......@@ -95,19 +95,17 @@ export default class ProfitLossMR extends Component {
viewOnly: true,
get_for: 'view',
defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false,
visibleButtonUpload: false
visibleAlertSave: false
}
this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
}
componentDidMount() {
// this.getItemHierarki()
this.getLatestUpdate()
this.getSettingControl()
// this.handleViewOnly()
this.handleViewOnly()
}
handleViewOnly() {
......@@ -483,46 +481,6 @@ export default class ProfitLossMR 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 ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
notes: 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(),
mtd_vs_previous_month: i[7] === undefined ? "" : String(i[7]).trim(),
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
months: this.props.month.month_id,
status: 'submitted',
profit_loss: payload
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
}
});
}
checkUpload() {
let payload = {
...this.state.payload,
......@@ -594,131 +552,6 @@ export default class ProfitLossMR extends Component {
})
}
checkUploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
console.log(this.props.monthlyReportId);
api.create().checkUploadMonthlyReportPL(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visiblePLMR: 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 == null || item.notes == "null" ? "" : item.notes,
item.rolling_outlook === null ? "" : item.rolling_outlook === "" ? "" : item.rolling_outlook,
item.master_budget === "" ? "" : item.master_budget,
item.rolling_budget === "" ? "" : item.rolling_budget,
item.actual === "" ? "" : Number(item.actual).toFixed(1),
0,
item.actual_previous_month === null ? "" : item.actual_previous_month === "" ? "" : item.actual_previous_month,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
item.amount_act_vs_previous_month,
item.percent_act_vs_previous_month,
item.amount_act_vs_mb,
item.percent_act_vs_mb,
item.amount_act_vs_rb,
item.percent_act_vs_rb,
item.mtd_vs_mb,
item.mtd_vs_rb,
item.mtd_vs_previous_month,
item.orders,
item.ytd_actual === null ? "" : item.ytd_actual === "" ? "" : item.ytd_actual,
item.error
]
})
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(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],
notes: String(i[6]),
rolling_outlook: String(Number(i[7]).toFixed(1)),
master_budget: String(Number(i[8]).toFixed(1)),
rolling_budget: String(Number(i[9]).toFixed(1)),
actual: String(Number(i[10]).toFixed(1)),
ytd_actual: String(Number(i[11]).toFixed(1)),
actual_previous_month: String(Number(i[12]).toFixed(1)),
amount_act_vs_previous_month: String(Number(i[13]).toFixed(1)),
percent_act_vs_previous_month: i[14],
amount_act_vs_mb: String(Number(i[15]).toFixed(1)),
percent_act_vs_mb: i[16],
amount_act_vs_rb: String(Number(i[17]).toFixed(1)),
percent_act_vs_rb: i[18],
mtd_vs_mb: String(i[19]),
mtd_vs_rb: String(i[20]),
mtd_vs_previous_month: String(i[21]),
})
})
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,
"months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id,
"status": type,
"profit_loss": data
}
console.log(body);
api.create().uploadSimulasiMRPL(body).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport('PL', 'simulasiPL')
this.props.onClickClose()
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 })
}
})
}
uploadProfitLossMR(type) {
let data = []
this.state.dataTable.map(i => {
......@@ -2246,20 +2079,6 @@ export default class ProfitLossMR extends Component {
null
:
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<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" />
<a data-tip={'Download Template'} data-for="template">
<button
style={{
......@@ -2646,72 +2465,6 @@ export default class ProfitLossMR 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("PROFIT") && String(this.state.judul).includes("LOSS") ?
this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</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>
)}
{this.state.visibleAlertSave && (
<div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
......@@ -59,18 +59,16 @@ export default class TaxPlanningMR extends Component {
viewOnly: true,
defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false,
visibleButtonUpload: false
}
this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
}
componentDidMount() {
this.getSettingControl()
// this.getItemHierarki()
this.getLatestUpdate()
// this.handleViewOnly()
this.handleViewOnly()
}
handleViewOnly() {
......@@ -390,48 +388,6 @@ export default class TaxPlanningMR 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]);
// 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_name: i[2] === undefined ? "" : String(i[2]).trim(),
trial_balance_commercial: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[3]).trim()), 2)) : String(roundMath(Number(String(i[3]).trim()), 1)),
fiscal_correction: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[4]).trim()), 2)) : String(roundMath(Number(String(i[4]).trim()), 1)),
trial_balance_fiscal: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[2]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(roundMath(Number(String(i[5]).trim()), 2)) : String(roundMath(Number(String(i[5]).trim()), 1)),
trial_balance_fiscal_actual: "",
trial_balance_fiscal_mb: "",
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
months: this.props.month.month_id,
tax_planning: payload,
status: "submitted"
}
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
// console.log(this.state.judulColumn)
// console.log(this.state.judul)
}
});
}
checkUpload() {
let payload = {
...this.state.payload,
......@@ -493,108 +449,6 @@ export default class TaxPlanningMR extends Component {
})
}
checkUploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
api.create().checkUploadMonthlyReportTP(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(this.state.payload)
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleTP: false, loading: true, visibleButtonUpload: true })
let dataTable = response.data.data.map((item, index) => {
return [
0,
Number(item.type_report_id.tbc),
Number(item.type_report_id.fcp),
Number(item.type_report_id.tbf),
item.item_report_id,
item.parent,
{ tbc: item.formula.tbc, fcp: item.formula.fcp, tbf: item.formula.tbf },
item.level,
item.item_report,
{
tbc: item.trial_balance_commercial === null ? "0.0" : item.trial_balance_commercial === "" ? "0.0" : item.trial_balance_commercial,
fcp: item.fiscal_correction === null ? "0.0" : item.fiscal_correction === "" ? "0.0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.fiscal_correction).toFixed(2) : Number(item.fiscal_correction).toFixed(1),
tbf: item.trial_balance_fiscal === null ? "0.0" : item.trial_balance_fiscal === "" ? "0.0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.trial_balance_fiscal).toFixed(2) : Number(item.trial_balance_fiscal).toFixed(1),
},
0,
item.trial_balance_fiscal_mb === null ? "0.0" : item.trial_balance_fiscal_mb === "" ? "0.0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.trial_balance_fiscal_mb).toFixed(2) : Number(item.trial_balance_fiscal_mb).toFixed(1),
item.actual_formula,
item.orders,
{ tbc: item.condition_it_should_be.tbc, fcp: item.condition_it_should_be.fcp, tbf: item.condition_it_should_be.tbf },
{ tbc: item.condition_if_wrong.tbc, fcp: item.condition_if_wrong.fcp, tbf: item.condition_if_wrong.tbf },
item.trial_balance_fiscal_actual === null ? "0.0" : item.trial_balance_fiscal_actual === "" ? "0.0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.trial_balance_fiscal_actual).toFixed(2) : Number(item.trial_balance_fiscal_actual).toFixed(1),
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, saveDraft: true }, () => {
this.state.dataTable.map(item => {
if (item[17].length > 0) {
// console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true })
}
})
// console.log(this.state.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[4],
trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
fiscal_correction: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].fcp).toFixed(2)) : String(Number(i[9].fcp).toFixed(1)),
trial_balance_fiscal: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].tbf).toFixed(2)) : String(Number(i[9].tbf).toFixed(1)),
trial_balance_fiscal_actual: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[10]).toFixed(2)) : String(Number(i[10]).toFixed(1)),
trial_balance_fiscal_mb: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[11]).toFixed(2)) : String(Number(i[11]).toFixed(1))
})
})
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,
"currency_id": this.props.defaultCurrency.id,
"tax_planning": data
}
console.log(body)
api.create().uploadSimulasiMRTP(body).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport()
} 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 => {
......@@ -1691,20 +1545,6 @@ export default class TaxPlanningMR extends Component {
// </div>
:
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<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" />
<a data-tip={'Download Template'} data-for="template">
<button
style={{
......@@ -2071,72 +1911,6 @@ export default class TaxPlanningMR 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("TAX") && String(this.state.judul).includes("PLANNING") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</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>
)}
{this.state.visibleAlertSave && (
<div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
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