Commit ff2e3146 authored by Riri Novita's avatar Riri Novita

Merge branch 'dev/riri' into 'ENV-DEV'

Button Upload Simulasi MR

See merge request !1888
parents c0e2fc41 b0955a3b
...@@ -54,6 +54,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -54,6 +54,7 @@ export default class FixedAssetsMovement extends Component {
} }
this.handleValue = this.handleValue.bind(this) 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() { componentDidMount() {
...@@ -338,6 +339,55 @@ export default class FixedAssetsMovement extends Component { ...@@ -338,6 +339,55 @@ export default class FixedAssetsMovement 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({
item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(),
total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
march: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
april: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
may: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
june: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
july: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
august: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
september: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
october: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
november: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
december: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
total_current_year: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
total_next_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
total_more_year: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
fixed_asset_movement: payload,
status: 'submitted'
}
// // console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
}
});
}
checkUpload() { checkUpload() {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
...@@ -408,6 +458,45 @@ export default class FixedAssetsMovement extends Component { ...@@ -408,6 +458,45 @@ export default class FixedAssetsMovement extends Component {
}) })
} }
uploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
this.setState({ loading: true, dataTable: [] })
// let dataDelete = this.state.dataDelete
// api.create().getIdDeleteFromExcel(payload).then((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 })
// }
// }
// })
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.getReport('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 })
}
})
}
uploadFAM(type) { uploadFAM(type) {
console.log("masuk ga?"); console.log("masuk ga?");
let data = [] let data = []
...@@ -2643,6 +2732,22 @@ export default class FixedAssetsMovement extends Component { ...@@ -2643,6 +2732,22 @@ export default class FixedAssetsMovement extends Component {
} }
</div> </div>
<div style={{ width: '50%' }}> <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.state.dataTable.length == 0 ? null : this.props.isApprover == true ? {this.state.dataTable.length == 0 ? null : this.props.isApprover == true ?
null null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
...@@ -2727,6 +2832,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -2727,6 +2832,7 @@ export default class FixedAssetsMovement extends Component {
} }
</div> </div>
</div> </div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent} {this.state.loading && loadingComponent}
...@@ -3016,6 +3122,48 @@ export default class FixedAssetsMovement extends Component { ...@@ -3016,6 +3122,48 @@ export default class FixedAssetsMovement 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>
<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.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("FIXED") && String(this.state.judul).includes("ASSETS") && String(this.state.judul).includes("MOVEMENT") ?
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 && ( {this.state.visibleAlertSave && (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}> <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
...@@ -60,6 +60,7 @@ export default class BalanceSheetMR extends Component { ...@@ -60,6 +60,7 @@ export default class BalanceSheetMR extends Component {
visibleAlertSave: false visibleAlertSave: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
} }
componentDidMount() { componentDidMount() {
...@@ -369,6 +370,45 @@ export default class BalanceSheetMR extends Component { ...@@ -369,6 +370,45 @@ 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() { checkUpload() {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
...@@ -445,6 +485,31 @@ export default class BalanceSheetMR extends Component { ...@@ -445,6 +485,31 @@ export default class BalanceSheetMR 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.saveToMonthlyReport('BS')
} 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) { uploadBalanceSheet(type) {
let data = [] let data = []
this.setState({ loading: true }) this.setState({ loading: true })
...@@ -2624,6 +2689,22 @@ export default class BalanceSheetMR extends Component { ...@@ -2624,6 +2689,22 @@ export default class BalanceSheetMR extends Component {
} }
</div> </div>
<div style={{ width: '50%' }}> <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' ? {this.props.isApprover === true || this.state.get_for == 'view' ?
null null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
...@@ -2700,6 +2781,7 @@ export default class BalanceSheetMR extends Component { ...@@ -2700,6 +2781,7 @@ export default class BalanceSheetMR extends Component {
} }
</div> </div>
</div> </div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && ( {!this.state.loading && (
...@@ -3032,6 +3114,47 @@ export default class BalanceSheetMR extends Component { ...@@ -3032,6 +3114,47 @@ export default class BalanceSheetMR 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>
<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.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 && ( {this.state.visibleAlertSave && (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}> <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
...@@ -81,6 +81,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -81,6 +81,7 @@ export default class CorporateAnnualTargetMR extends Component {
visibleAlertSave: false visibleAlertSave: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
} }
componentDidMount() { componentDidMount() {
...@@ -409,6 +410,45 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -409,6 +410,45 @@ 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() { checkUpload() {
this.setState({ loading: true }) this.setState({ loading: true })
let payload = { let payload = {
...@@ -471,6 +511,31 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -471,6 +511,31 @@ export default class CorporateAnnualTargetMR 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()
} 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) { uploadCATMR(type) {
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
...@@ -1989,6 +2054,21 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1989,6 +2054,21 @@ export default class CorporateAnnualTargetMR extends Component {
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload Simulasi'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
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"> {this.state.get_for == 'edit' && <a data-tip={'Download Template'} data-for="template">
<button <button
style={{ style={{
...@@ -2415,6 +2495,47 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -2415,6 +2495,47 @@ export default class CorporateAnnualTargetMR 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>
<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.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 && ( {this.state.visibleAlertSave && (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}> <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
...@@ -56,6 +56,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -56,6 +56,7 @@ export default class FixedAssetsMovementMR extends Component {
visibleAlertSave: false visibleAlertSave: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
} }
componentDidMount() { componentDidMount() {
...@@ -299,6 +300,40 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -299,6 +300,40 @@ 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() { checkUpload() {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
...@@ -358,6 +393,31 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -358,6 +393,31 @@ export default class FixedAssetsMovementMR 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.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) { uploadFAMMR(type) {
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
...@@ -1361,6 +1421,22 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1361,6 +1421,22 @@ export default class FixedAssetsMovementMR extends Component {
} }
</div> </div>
<div style={{ width: '50%' }}> <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' ? {this.props.isApprover === true || this.state.get_for == 'view' ?
null null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
...@@ -1437,6 +1513,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1437,6 +1513,7 @@ export default class FixedAssetsMovementMR extends Component {
} }
</div> </div>
</div> </div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.refresh && ( {!this.state.refresh && (
...@@ -1750,6 +1827,47 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1750,6 +1827,47 @@ export default class FixedAssetsMovementMR 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>
<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.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 && ( {this.state.visibleAlertSave && (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}> <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
...@@ -123,6 +123,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -123,6 +123,7 @@ export default class ListOfCreditFacilities extends Component {
visibleAlertSave: false visibleAlertSave: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
} }
componentDidMount() { componentDidMount() {
...@@ -508,6 +509,84 @@ export default class ListOfCreditFacilities extends Component { ...@@ -508,6 +509,84 @@ 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],
"loan_plafond_amount_idr": i[9],
"out_loan_ki_amount_ori": i[10],
"out_loan_ki_amount_idr": i[11],
"out_loan_kmk_amount_ori": i[12],
"out_loan_kmk_amount_idr": i[13],
"out_loan_other_type": i[14],
"out_loan_other_amount_ori": i[15],
"out_loan_other_amount_idr": 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() { deleteReport() {
let payload = { "item_report_id": this.state.dataDelete, "periode": this.props.periode, "months": this.props.month.month_id } let payload = { "item_report_id": this.state.dataDelete, "periode": this.props.periode, "months": this.props.month.month_id }
...@@ -680,6 +759,31 @@ export default class ListOfCreditFacilities extends Component { ...@@ -680,6 +759,31 @@ export default class ListOfCreditFacilities 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.saveToMonthlyReport('LOCF')
} 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) { uploadLOCF(type) {
let data = [] let data = []
let error = false let error = false
...@@ -3833,6 +3937,21 @@ export default class ListOfCreditFacilities extends Component { ...@@ -3833,6 +3937,21 @@ export default class ListOfCreditFacilities extends Component {
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload Simulasi'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
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' && {(this.state.get_for == 'edit' &&
<div> <div>
<a data-tip={'Download Template'} data-for="template"> <a data-tip={'Download Template'} data-for="template">
...@@ -4357,6 +4476,47 @@ export default class ListOfCreditFacilities extends Component { ...@@ -4357,6 +4476,47 @@ export default class ListOfCreditFacilities 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>
<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.uploadSimulasi() :
this.setState({ snekbar: true, snekbarMsg: '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 && ( {this.state.visibleAlertSave && (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}> <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 { ...@@ -685,7 +685,7 @@ export default class MonthlyReport extends Component {
}) })
} }
getMonthlyReportID(type) { getMonthlyReportID(type, trigger) {
this.setState({ selectReport: [], isCheckAll: false }, () => { this.setState({ selectReport: [], isCheckAll: false }, () => {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
...@@ -730,7 +730,7 @@ export default class MonthlyReport extends Component { ...@@ -730,7 +730,7 @@ export default class MonthlyReport extends Component {
} }
// this.getPL(type) // this.getPL(type)
if (type != undefined && type == 'PL') { if (type != undefined && type == 'PL') {
this.getPL(type) this.getPL(type, trigger)
} else if (type != undefined && type == 'LOCF') { } else if (type != undefined && type == 'LOCF') {
let bodyRatioLocf = { let bodyRatioLocf = {
"report": 'ratio', "report": 'ratio',
...@@ -842,7 +842,8 @@ export default class MonthlyReport extends Component { ...@@ -842,7 +842,8 @@ export default class MonthlyReport extends Component {
}) })
} }
saveToMonthlyReport(type) { saveToMonthlyReport(type, trigger) {
console.log(trigger);
this.setState({ this.setState({
visibleMonthlyReport: true, visibleMonthlyReport: true,
loading: true, loading: true,
...@@ -855,7 +856,7 @@ export default class MonthlyReport extends Component { ...@@ -855,7 +856,7 @@ export default class MonthlyReport extends Component {
visibleLOCF: false, visibleLOCF: false,
visibleOI: false, visibleOI: false,
}, () => { }, () => {
this.getMonthlyReportID(type) this.getMonthlyReportID(type, trigger)
}) })
} }
...@@ -1536,7 +1537,7 @@ export default class MonthlyReport extends Component { ...@@ -1536,7 +1537,7 @@ export default class MonthlyReport extends Component {
}) })
} }
getPL(type) { getPL(type, trigger) {
let PLID = null let PLID = null
let payloadID = { let payloadID = {
"periode": this.state.periode.periode, "periode": this.state.periode.periode,
...@@ -1661,7 +1662,7 @@ export default class MonthlyReport extends Component { ...@@ -1661,7 +1662,7 @@ export default class MonthlyReport extends Component {
console.log(JSON.stringify(dataTable)) console.log(JSON.stringify(dataTable))
console.log(dataTable) console.log(dataTable)
this.setState({ dbPL: dataTable }, () => { this.setState({ dbPL: dataTable }, () => {
this.olahDataPL(this.state.dbPL, type) this.olahDataPL(this.state.dbPL, type, trigger)
}) })
} else { } else {
this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -1897,7 +1898,7 @@ export default class MonthlyReport extends Component { ...@@ -1897,7 +1898,7 @@ export default class MonthlyReport extends Component {
} }
olahDataPL(dbPL, type) { olahDataPL(dbPL, type, trigger) {
dbPL.map((item, index) => { dbPL.map((item, index) => {
if (item[0] == 5 || item[0] == 6) { if (item[0] == 5 || item[0] == 6) {
item[6].value = this.handleValueFormulaDBPLMR(item[6], item, 6) item[6].value = this.handleValueFormulaDBPLMR(item[6], item, 6)
...@@ -1906,11 +1907,11 @@ export default class MonthlyReport extends Component { ...@@ -1906,11 +1907,11 @@ export default class MonthlyReport extends Component {
}) })
// console.log(dbPL) // console.log(dbPL)
this.setState({ dbPL }, () => { this.setState({ dbPL }, () => {
this.payloadPL(type) this.payloadPL(type, trigger)
}) })
} }
payloadPL(type) { payloadPL(type, trigger) {
let listPL = [] let listPL = []
this.state.dbPL.map((item, index) => { this.state.dbPL.map((item, index) => {
// if (item[6].value == "" || item[6].value == 0 || item[6].value == "0.0") { // if (item[6].value == "" || item[6].value == 0 || item[6].value == "0.0") {
...@@ -1939,13 +1940,14 @@ export default class MonthlyReport extends Component { ...@@ -1939,13 +1940,14 @@ export default class MonthlyReport extends Component {
// console.log(this.state.dbPL) // console.log(this.state.dbPL)
// this.setState({ loading: false }) // this.setState({ loading: false })
console.log('tarik sis') console.log('tarik sis')
this.createPL() this.createPL(trigger)
} }
} }
}) })
} }
createPL() { createPL(trigger) {
console.log(trigger);
let payload = { let payload = {
// "monthly_report_id": this.state.monthlyReportId, // "monthly_report_id": this.state.monthlyReportId,
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
......
...@@ -99,6 +99,7 @@ export default class ProfitLossMR extends Component { ...@@ -99,6 +99,7 @@ export default class ProfitLossMR extends Component {
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
} }
componentDidMount() { componentDidMount() {
...@@ -481,6 +482,46 @@ export default class ProfitLossMR extends Component { ...@@ -481,6 +482,46 @@ 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() { checkUpload() {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
...@@ -552,6 +593,33 @@ export default class ProfitLossMR extends Component { ...@@ -552,6 +593,33 @@ export default class ProfitLossMR 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.saveToMonthlyReport('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 })
}
})
}
uploadProfitLossMR(type) { uploadProfitLossMR(type) {
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
...@@ -596,7 +664,7 @@ export default class ProfitLossMR extends Component { ...@@ -596,7 +664,7 @@ export default class ProfitLossMR extends Component {
} else { } else {
this.props.saveToMonthlyReport() this.props.saveToMonthlyReport()
} }
// this.props.onClickClose() this.props.onClickClose()
// this.props.getReport() // this.props.getReport()
} else { } else {
if (response.data?.message == "Please Set Up Rate Currency First") { if (response.data?.message == "Please Set Up Rate Currency First") {
...@@ -2054,6 +2122,22 @@ export default class ProfitLossMR extends Component { ...@@ -2054,6 +2122,22 @@ export default class ProfitLossMR extends Component {
} }
</div> </div>
<div style={{ width: '50%' }}> <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' ? {this.props.isApprover === true || this.state.get_for == 'view' ?
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
// <a data-tip={'Download'} data-for="download"> // <a data-tip={'Download'} data-for="download">
...@@ -2130,6 +2214,7 @@ export default class ProfitLossMR extends Component { ...@@ -2130,6 +2214,7 @@ export default class ProfitLossMR extends Component {
} }
</div> </div>
</div> </div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.refresh && ( {!this.state.refresh && (
...@@ -2465,6 +2550,47 @@ export default class ProfitLossMR extends Component { ...@@ -2465,6 +2550,47 @@ export default class ProfitLossMR 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>
<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.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 && ( {this.state.visibleAlertSave && (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}> <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
......
...@@ -62,6 +62,7 @@ export default class TaxPlanningMR extends Component { ...@@ -62,6 +62,7 @@ export default class TaxPlanningMR extends Component {
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
} }
componentDidMount() { componentDidMount() {
...@@ -388,6 +389,48 @@ export default class TaxPlanningMR extends Component { ...@@ -388,6 +389,48 @@ 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() { checkUpload() {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
...@@ -449,6 +492,31 @@ export default class TaxPlanningMR extends Component { ...@@ -449,6 +492,31 @@ export default class TaxPlanningMR 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.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) { uploadTP(type) {
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
...@@ -1520,6 +1588,22 @@ export default class TaxPlanningMR extends Component { ...@@ -1520,6 +1588,22 @@ export default class TaxPlanningMR extends Component {
} }
</div> </div>
<div style={{ width: '50%' }}> <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' ? {this.props.isApprover === true || this.state.get_for == 'view' ?
null null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
...@@ -1596,6 +1680,7 @@ export default class TaxPlanningMR extends Component { ...@@ -1596,6 +1680,7 @@ export default class TaxPlanningMR extends Component {
} }
</div> </div>
</div> </div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent} {this.state.loading && loadingComponent}
...@@ -1911,6 +1996,47 @@ export default class TaxPlanningMR extends Component { ...@@ -1911,6 +1996,47 @@ export default class TaxPlanningMR 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>
<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.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 && ( {this.state.visibleAlertSave && (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}> <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