Commit 801ef202 authored by Riri Novita's avatar Riri Novita

Merge branch 'ENV-DEV' of http://103.44.149.204/d.arizona/tia-dev into dev/riri

parents 1e3c2649 fa1e4e00
......@@ -553,6 +553,8 @@ const create = (type = "") => {
const getTypeOfInvestment = () => api.get('setting_type/get_all_setting_type_by_investment')
const validateSaveLOV = (body) => api.post('transaction/lov/monthly_report/validate_save', body)
const validateSaveLOCF = (body) => api.post('transaction/locf/monthly_report/validate_save', body)
const uploadMonthlyReportLOV = (body) => api.post('transaction/lov/monthly_report/import_monthly_report', body)
const createMonthlyReportLOV = (body) => api.post('transaction/lov/monthly_report/create_monthly_report', body)
// Superadmin Approve
......@@ -958,7 +960,9 @@ const create = (type = "") => {
uploadSimulasiROOI,
getTypeOfInvestment,
validateSaveLOCF,
validateSaveLOV
validateSaveLOV,
uploadMonthlyReportLOV,
createMonthlyReportLOV
}
}
......
......@@ -555,8 +555,8 @@ export default class LOCF extends Component {
let lastArray = dataTable[dataTable.length - 1]
this.setState({ dataTable, diff: lastArray[46], perBS: lastArray[47], dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => {
console.log(lastArray);
this.props.sendToParent(dataTable, lastArray , 'LOCF', 'upload')
console.log(this.state.visibleLOCFMR);
this.props.sendToParent(dataTable, lastArray , 'LOCF', 'upload', this.state.visibleLOCFMR)
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, typeAlert: 'warning', loading: false }, () => {
......@@ -3592,7 +3592,7 @@ export default class LOCF extends Component {
<Typography style={{ fontSize: '12px', color: '#4b4b4b' }}>Diff</Typography>
</div>
<div style={{ borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
<Typography style={{ fontSize: '14px', color: Number(this.state.diff) > 0 ? 'red' : '#4b4b4b' }}><NumberFormat value={this.state.diff} displayType={'text'} thousandSeparator={true} prefix={''} /></Typography>
<Typography style={{ fontSize: '14px', color: Number(this.state.diff) > '0.0' || Number(this.state.diff) < '0.0' ? 'red' : '#4b4b4b' }}><NumberFormat value={this.state.diff} displayType={'text'} thousandSeparator={true} prefix={''} /></Typography>
</div>
</div>
</div>
......
......@@ -475,9 +475,8 @@ export default class LOV extends Component {
})
console.log(dataTable)
let lastArray = dataTable[dataTable.length - 1]
console.log(lastArray);
this.setState({ dataTable, diff: lastArray[16], perBS: lastArray[18], loading: false, visibleLOVMR: true }, () => {
this.props.sendToParent(dataTable, lastArray, 'LOV', 'upload')
this.setState({ dataTable, diff: lastArray[16], perBS: lastArray[18], dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => {
this.props.sendToParent(dataTable, lastArray, 'LOV', 'upload', this.state.visibleLOVMR)
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, typeAlert: 'warning', loading: false }, () => {
......@@ -660,7 +659,7 @@ export default class LOV extends Component {
// }
getListCurrency() {
this.setState({ dataLoaded: false })
// this.setState({ dataLoaded: false })
api.create().getDataCurrency().then(response => {
console.log(response)
if (response.data) {
......@@ -995,18 +994,17 @@ export default class LOV extends Component {
let prevData = dataTable2[index - 1] == undefined ? null : dataTable2[index - 1][6]
let currentData = dataTable2[index][6]
let nextData = dataTable2[index + 1] == undefined ? null : dataTable2[index + 1][6]
console.log(nextData);
if (nextData == null) {
dataTable2.splice(index, 1)
} else if (nextData.value.includes('Total')) {
} else if (nextData.includes('Total')) {
if (prevData !== null && currentData == null) {
dataTable2.splice(index, 1)
} else if (prevData !== null && prevData.value == currentData.value) {
} else if (prevData !== null && prevData == currentData) {
dataTable2.splice(index, 1)
} else if (dataTable2.length > 3) {
if (prevData == null) {
if (nextData.value.includes('Grand')) {
if (nextData.includes('Grand')) {
dataTable2.splice(index, 1)
} else {
dataTable2.splice(index, 2)
......@@ -1016,7 +1014,7 @@ export default class LOV extends Component {
}
} else if (dataTable2.length == 3) {
if (prevData == null) {
if (nextData.value.includes('Grand')) {
if (nextData.includes('Grand')) {
dataTable2.splice(index, 1)
} else {
dataTable2.splice(index, 3)
......@@ -1832,6 +1830,7 @@ export default class LOV extends Component {
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent}
{this.state.dataLoaded && !this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<div>cuuuk</div>
<MUIDataTable
data={dataTable2}
columns={columns}
......@@ -1840,54 +1839,6 @@ export default class LOV extends Component {
</MuiThemeProvider>}
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1" style={{ paddingLeft: 0 }}>
<button
type="button"
onClick={() => this.setState({ loading: true, visiblePLMR: true }, () => {
setTimeout(() => {
this.getItemHierarkiLOV()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
// this.setState({ loading: false })
this.handleValidate()
}, 100);
})
}}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15, marginTop: 5 }}>
<div>
<div style={{ display: 'flex' }}>
......@@ -1948,25 +1899,25 @@ export default class LOV extends Component {
</div>
{/* <div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5}}>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography>
</div>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.totalOutStand)}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography>
</div>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.perBS)}</Typography>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15}}>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Diff</Typography>
</div>
<div style={{borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{(formatSeparator(this.state.diff))}</Typography>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15}}>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Diff</Typography>
</div>
<div style={{borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{(formatSeparator(this.state.diff))}</Typography>
</div>
</div> */}
</div>
</div> */}
</div>
}
......
......@@ -120,9 +120,11 @@ export default class ListOfCreditFacilities extends Component {
perBSLOV: 0,
snekbar: false,
snekbarMsg: '',
visibleLOCFMR: true,
visibleParent: true,
buttonError: false,
saveDraft: true,
saveComp: true,
saveCompLOV: true,
get_for: 'view',
updateBy: [],
notes: "",
......@@ -153,14 +155,16 @@ export default class ListOfCreditFacilities extends Component {
})
}
dataTableForChild(data, array, params, type) {
dataTableForChild(data, array, params, type, visibleView) {
console.log(visibleView);
console.log(type);
switch (params) {
case "LOV":
console.log(data);
this.setState({ dataTableLOV: data, diffLOV: array[16], perBSLOV: array[18], tambahLOV: type })
this.setState({ dataTableLOV: data, diffLOV: array[16], perBSLOV: array[18], tambahLOV: type, visibleParent: visibleView == undefined ? true : visibleView })
break;
case "LOCF":
this.setState({ dataTableLOCF: data, diffLOCF: array[46], perBSLOCF: array[48], tambah: type })
this.setState({ dataTableLOCF: data, diffLOCF: array[46], perBSLOCF: array[48], tambah: type, visibleParent: visibleView == undefined ? true : visibleView })
break
default:
break;
......@@ -266,24 +270,199 @@ export default class ListOfCreditFacilities extends Component {
})
} else {
this.setState({ submissionID: null, loading: false, visibleLOCFMR: true })
this.setState({ submissionID: null, loading: false })
}
}
})
}
// backToMonthlyReportLOCF(type) {
// // this.setState({ loading: true })
// console.log('kok kesiniii');
// let dataTable2 = this.state.dataTablelocf == undefined || this.state.tambah == 'tambah' || this.state.tambah == 'upload' ? this.state.dataTableLOCF : this.state.dataTablelocf
// let data = []
// let error = false
// this.deleteReport()
// dataTable.map(i => {
// console.log(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)
// if (this.props.defaultCurrency.id == 2) {
// 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] == 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],
// "interest": i[10] == "" ? "0.00" : i[10],
// "currency": i[11],
// "loan_plafond_amount_ori": Number(i[12]) == "" ? "0.0" : Number(i[12]),
// "loan_plafond_amount_idr": Number(i[13]) == "" ? "0.0" : Number(i[13]),
// "out_loan_ki_amount_ori": Number(i[14]) == "" ? "0.0" : Number(i[14]),
// "out_loan_ki_amount_idr": Number(i[15]) == "" ? "0.0" : Number(i[15]),
// "out_loan_kmk_amount_ori": Number(i[16]) == "" ? "0.0" : Number(i[16]),
// "out_loan_kmk_amount_idr": Number(i[17]) == "" ? "0.0" : Number(i[17]),
// // "mtd_vs_previous_month": i[18],
// "out_loan_other_type": i[18],
// "out_loan_other_amount_ori": Number(i[19]) == "" ? "0.0" : Number(i[19]),
// "out_loan_other_amount_idr": Number(i[20]) == "" ? "0.0" : Number(i[20]),
// "total_out_loan_ori": Number(i[21]) == "" ? "0.0" : Number(i[21]),
// "total_out_loan_idr": Number(i[22]) == "" ? "0.0" : Number(i[22]),
// "remaining_plafond_ori": Number(i[23]) == "" ? "0.0" : Number(i[23]),
// "remaining_plafond_idr": Number(i[24]) == "" ? "0.0" : Number(i[24]),
// "current_ratio_financial": Number(i[25]) == "" ? "0.00" : Number(i[25]),
// "current_ratio_current": Number(i[26]) == "" ? "0.00" : Number(i[26]),
// "der_financial": Number(i[27]) == "" ? "0.00" : Number(i[27]),
// "der_current": Number(i[28]) == "" ? "0.00" : Number(i[28]),
// "debt_to_ebitda_financial": Number(i[29]) == "" ? "0.00" : Number(i[29]),
// "debt_to_ebitda_current": Number(i[30]) == "" ? "0.00" : Number(i[30]),
// "ebitda_to_interest_financial": Number(i[31]) == "" ? "0.00" : Number(i[31]),
// "ebitda_to_interest_current": Number(i[32]) == "" ? "0.00" : Number(i[32]),
// "other_ratio1_ratio_name": i[33],
// "other_ratio1_financial": Number(i[34]) == "" ? "0.00" : Number(i[34]),
// "other_ratio1_current": Number(i[35]) == "" ? "0.00" : Number(i[35]),
// "other_ratio2_ratio_name": i[36],
// "other_ratio2_financial": Number(i[37]) == "" ? "0.00" : Number(i[37]),
// "other_ratio2_current": Number(i[38]) == "" ? "0.00" : Number(i[38]),
// "other_ratio3_ratio_name": i[39],
// "other_ratio3_financial": Number(i[40]) == "" ? "0.00" : Number(i[40]),
// "other_ratio3_current": Number(i[41]) == "" ? "0.00" : Number(i[41]),
// "other_ratio4_ratio_name": i[42],
// "other_ratio4_financial": Number(i[43]) == "" ? "0.00" : Number(i[43]),
// "other_ratio4_current": Number(i[44]) == "" ? "0.00" : Number(i[44]),
// "notes": i[45],
// })
// } else {
// 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] == 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],
// "interest": i[10] == "" ? "0.00" : i[10],
// "currency": i[11],
// "loan_plafond_amount_ori": fixNumber(Number(i[12]), 1) == "" ? "0.0" : fixNumber(Number(i[12]), 1),
// "loan_plafond_amount_idr": fixNumber(Number(i[13]), 1) == "" ? "0.0" : fixNumber(Number(i[13]), 1),
// "out_loan_ki_amount_ori": fixNumber(Number(i[14]), 1) == "" ? "0.0" : fixNumber(Number(i[14]), 1),
// "out_loan_ki_amount_idr": fixNumber(Number(i[15]), 1) == "" ? "0.0" : fixNumber(Number(i[15]), 1),
// "out_loan_kmk_amount_ori": fixNumber(Number(i[16]), 1) == "" ? "0.0" : fixNumber(Number(i[16]), 1),
// "out_loan_kmk_amount_idr": fixNumber(Number(i[17]), 1) == "" ? "0.0" : fixNumber(Number(i[17]), 1),
// // "mtd_vs_previous_month": i[18],
// "out_loan_other_type": i[18],
// "out_loan_other_amount_ori": fixNumber(Number(i[19]), 1) == "" ? "0.0" : fixNumber(Number(i[19]), 1),
// "out_loan_other_amount_idr": fixNumber(Number(i[20]), 1) == "" ? "0.0" : fixNumber(Number(i[20]), 1),
// "total_out_loan_ori": fixNumber(Number(i[21]), 1) == "" ? "0.0" : fixNumber(Number(i[21]), 1),
// "total_out_loan_idr": fixNumber(Number(i[22]), 1) == "" ? "0.0" : fixNumber(Number(i[22]), 1),
// "remaining_plafond_ori": fixNumber(Number(i[23]), 1) == "" ? "0.0" : fixNumber(Number(i[23]), 1),
// "remaining_plafond_idr": fixNumber(Number(i[24]), 1) == "" ? "0.0" : fixNumber(Number(i[24]), 1),
// "current_ratio_financial": fixNumber(Number(i[25]), 2) == "" ? "0.00" : fixNumber(Number(i[25]), 2),
// "current_ratio_current": fixNumber(Number(i[26]), 2) == "" ? "0.00" : fixNumber(Number(i[26]), 2),
// "der_financial": fixNumber(Number(i[27]), 2) == "" ? "0.00" : fixNumber(Number(i[27]), 2),
// "der_current": fixNumber(Number(i[28]), 2) == "" ? "0.00" : fixNumber(Number(i[28]), 2),
// "debt_to_ebitda_financial": fixNumber(Number(i[29]), 2) == "" ? "0.00" : fixNumber(Number(i[29]), 2),
// "debt_to_ebitda_current": fixNumber(Number(i[30]), 2) == "" ? "0.00" : fixNumber(Number(i[30]), 2),
// "ebitda_to_interest_financial": fixNumber(Number(i[31]), 2) == "" ? "0.00" : fixNumber(Number(i[31]), 2),
// "ebitda_to_interest_current": fixNumber(Number(i[32]), 2) == "" ? "0.00" : fixNumber(Number(i[32]), 2),
// "other_ratio1_ratio_name": i[33],
// "other_ratio1_financial": fixNumber(Number(i[34]), 2) == "" ? "0.00" : fixNumber(Number(i[34]), 2),
// "other_ratio1_current": fixNumber(Number(i[35]), 2) == "" ? "0.00" : fixNumber(Number(i[35]), 2),
// "other_ratio2_ratio_name": i[36],
// "other_ratio2_financial": fixNumber(Number(i[37]), 2) == "" ? "0.00" : fixNumber(Number(i[37]), 2),
// "other_ratio2_current": fixNumber(Number(i[38]), 2) == "" ? "0.00" : fixNumber(Number(i[38]), 2),
// "other_ratio3_ratio_name": i[39],
// "other_ratio3_financial": fixNumber(Number(i[40]), 2) == "" ? "0.00" : fixNumber(Number(i[40]), 2),
// "other_ratio3_current": fixNumber(Number(i[41]), 2) == "" ? "0.00" : fixNumber(Number(i[41]), 2),
// "other_ratio4_ratio_name": i[42],
// "other_ratio4_financial": fixNumber(Number(i[43]), 2) == "" ? "0.00" : fixNumber(Number(i[43]), 2),
// "other_ratio4_current": fixNumber(Number(i[44]), 2) == "" ? "0.00" : fixNumber(Number(i[44]), 2),
// "notes": i[45],
// })
// }
// }
// })
// let payload = {
// "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.perBSLOCF,
// "diff": this.state.diff,
// "total_loan": this.state.perBSLOCF
// }
// console.log(payload)
// // if (error && type == 'submitted') {
// // this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
// // } else {
// // api.create('UPLOAD').createMonthlyReportLOCF(payload).then(response => {
// // console.log(response);
// // if (response.data) {
// // if (response.data.status === "success") {
// // this.props.saveToMonthlyReport('LOCF')
// // } else {
// // if (response.data?.message == "Please Set Up Rate Currency First") {
// // this.setState({ visibleAlertSave: true })
// // } else {
// // this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
// // document.body.style.overflow = 'unset';
// // if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
// // setTimeout(() => {
// // localStorage.removeItem(Constant.TOKEN)
// // window.location.reload();
// // }, 1000);
// // }
// // this.props.saveToMonthlyReport()
// // })
// // }
// // }
// // // else {
// // // this.setState({ loading: false }, () => {
// // // this.props.saveToMonthlyReport()
// // // })
// // // }
// // } else {
// // this.setState({ loading: false }, () => {
// // // this.getSubmission()
// // document.body.style.overflow = 'unset';
// // })
// // }
// // this.setState({ handleDoubleClick: 0 })
// // })
// // }
// }
backToMonthlyReportLOCF(type) {
// this.setState({ loading: true })
console.log('masoook LOCF');
let dataTable2 = this.state.dataTablelocf == undefined || this.state.tambah == 'tambah' || this.state.tambah == 'upload' ? this.state.dataTableLOCF : this.state.dataTablelocf
let data = []
let error = false
this.deleteReport()
this.state.dataTable.map(i => {
console.log(i);
// this.deleteReport()
console.log(dataTable2);
dataTable2.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
}
......@@ -296,8 +475,9 @@ export default class ListOfCreditFacilities extends Component {
"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],
// "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]) == "" ? "0.0" : Number(i[12]),
......@@ -343,8 +523,9 @@ export default class ListOfCreditFacilities extends Component {
"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],
// "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": fixNumber(Number(i[12]), 1) == "" ? "0.0" : fixNumber(Number(i[12]), 1),
......@@ -387,7 +568,7 @@ export default class ListOfCreditFacilities extends Component {
}
})
let payload = {
let body = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
......@@ -396,47 +577,142 @@ export default class ListOfCreditFacilities extends Component {
"months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id,
"locf": data,
"per_bs": this.state.perBSLOCF,
"per_bs": this.state.perBS,
"diff": this.state.diff,
"total_loan": this.state.perBSLOCF
"total_loan": this.state.perBS
}
console.log(body);
if (error && type == 'submitted') {
this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
} else {
api.create('UPLOAD').createMonthlyReportLOCF(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.backToMonthlyReportLOV(type)
} else {
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} 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);
}
})
}
// alert(response.data.status)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
}
this.setState({ handleDoubleClick: 0 })
})
}
}
backToMonthlyReportLOV(type) {
console.log('masoook LOV');
let dataTable2 = this.state.dataTablelov == undefined || this.state.tambahLOV == 'tambah' || this.state.tambahLOV == 'upload' ? this.state.dataTableLOV : this.state.dataTablelov
let data = []
let error = false
// this.deleteReport()
console.log(dataTable2);
dataTable2.map(i => {
if (i[0] == 3) {
if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "" || i[12] == "") {
error = true
}
console.log(JSON.stringify(payload))
if (i[8] == '' && i[7]?.value == 'Time deposit' || i[7]?.value == 'N/A') {
error = true
}
let tgl = String(i[9]).split('-')
let checkUndifined = tgl.findIndex((val) => val == undefined)
if (this.props.defaultCurrency.id == 2) {
data.push({
"item_report_id": i[1],
"company_name": i[5],
"institution_name": i[6],
"type_of_investment": i[7] == null ? i[7] : i[7].value,
"remarks": i[8],
"placement_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
"tenor": i[10],
"expected_return": i[11] == "" ? "0.00" : i[11],
"currency": i[12] == null ? i[12] : i[12].value,
"investment_amount_ori": Number(i[13]) == "" ? "0.0" : Number(i[13]),
"investment_amount_cur": Number(i[14]) == "" ? "0.0" : Number(i[14]),
"notes": i[15],
})
} else {
data.push({
"item_report_id": i[1],
"company_name": i[5],
"institution_name": i[6],
"type_of_investment": i[7] == null ? i[7] : i[7].value,
"remarks": i[8],
"placement_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
"tenor": i[10],
"expected_return": i[11] == "" ? "0.00" : i[11],
"currency": i[12] == null ? i[12] : i[12].value,
"investment_amount_ori": Number(i[13]) == "" ? "0.0" : Number(i[13]),
"investment_amount_cur": Number(i[14]) == "" ? "0.0" : Number(i[14]),
"notes": i[15],
})
}
}
})
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,
"lov": data,
"per_bs": this.state.perBS,
"diff": this.state.diff,
"total_loan": this.state.perBS
}
console.log(body);
if (error && type == 'submitted') {
this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
} else {
api.create('UPLOAD').createMonthlyReportLOCF(payload).then(response => {
api.create('UPLOAD').createMonthlyReportLOV(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport('LOCF')
} else {
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
if (response.ok) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport('LOCF')
this.setState({ loadingChild : false})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.props.saveToMonthlyReport()
})
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} 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);
}
})
}
// alert(response.data.status)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
}
// else {
// this.setState({ loading: false }, () => {
// this.props.saveToMonthlyReport()
// })
// }
} else {
this.setState({ loading: false }, () => {
// this.getSubmission()
document.body.style.overflow = 'unset';
})
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
}
this.setState({ handleDoubleClick: 0 })
})
......@@ -448,9 +724,11 @@ export default class ListOfCreditFacilities extends Component {
let dataTable2 = this.state.dataTablelocf == undefined || this.state.tambah == 'tambah' || this.state.tambah == 'upload' ? this.state.dataTableLOCF : this.state.dataTablelocf
let data = []
let error = false
console.log(dataTable2);
let bankNameEmpty = false
dataTable2.map(i => {
console.log(i[12]);
if (i[6] == null) {
bankNameEmpty = true
}
if (i[0] == 3) {
if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "") {
error = true
......@@ -701,9 +979,22 @@ export default class ListOfCreditFacilities extends Component {
}
}
})
console.log(error);
let lastArrayLOCF = dataTablelocf[res.length - 1]
this.setState({ dataTablelocf, diffLOCF: lastArrayLOCF[46], perBSLOCF: lastArrayLOCF[48], visibleLOCFMR: true, loading: false }, () => {
if (bankNameEmpty) {
if (this.state.get_for == 'view') {
this.setState({ saveDraft: false, saveComp: true })
} else {
this.setState({ saveDraft: false, saveComp: true })
}
} else {
if (this.state.get_for == 'view') {
console.log("view");
} else {
this.setState({ saveDraft: false, saveComp: lastArrayLOCF[46] == 0 || lastArrayLOCF[46] == '0.0' || lastArrayLOCF[46] == "-0.0" ? false : true })
}
}
this.setState({ dataTablelocf, diffLOCF: lastArrayLOCF[46], perBSLOCF: lastArrayLOCF[48], loading: false }, () => {
this.handleCalculateLOV()
})
}
......@@ -713,12 +1004,15 @@ export default class ListOfCreditFacilities extends Component {
handleCalculateLOV = () => {
this.setState({ loading: true })
console.log(this.state.dataTablelov);
console.log(this.state.dataTableLOV);
let dataTable2 = this.state.dataTablelov == undefined || this.state.tambahLOV == 'tambah' || this.state.tambahLOV == 'upload' ? this.state.dataTableLOV : this.state.dataTablelov
let data = []
let error = false
let bankNameEmpty = false
console.log(dataTable2);
dataTable2.map(i => {
if (i[6] == null) {
bankNameEmpty = true
}
if (i[0] == 3) {
if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "" || i[12] == "") {
error = true
......@@ -849,9 +1143,21 @@ export default class ListOfCreditFacilities extends Component {
}
}
})
console.log(dataTablelov);
let lastArrayLOV = dataTablelov[res.length - 1]
this.setState({ dataTablelov, diffLOV: lastArrayLOV[16], perBSLOV: lastArrayLOV[18], loading: false, visibleLOCFMR: true, loadingChild: false }, () => {
if (bankNameEmpty) {
if (this.state.get_for == 'view') {
this.setState({ saveDraft: false, saveCompLOV: true })
} else {
this.setState({ saveDraft: false, saveCompLOV: true })
}
} else {
if (this.state.get_for == 'view') {
console.log("view");
} else {
this.setState({ saveDraft: false, saveCompLOV: lastArrayLOV[16] == 0 || lastArrayLOV[16] == '0.0' || lastArrayLOV[16] == "-0.0" ? false : true })
}
}
this.setState({ dataTablelov, diffLOV: lastArrayLOV[16], perBSLOV: lastArrayLOV[18], loading: false, loadingChild: false }, () => {
// this.handleCalculateLOV()
})
} else {
......@@ -862,12 +1168,13 @@ export default class ListOfCreditFacilities extends Component {
}
uploadLOCF(type) {
console.log("masoook");
console.log('masoook LOCF');
let dataTable2 = this.state.dataTablelocf == undefined || this.state.tambah == 'tambah' || this.state.tambah == 'upload' ? this.state.dataTableLOCF : this.state.dataTablelocf
let data = []
let error = false
this.deleteReport()
this.state.dataTable2.map(i => {
// this.deleteReport()
console.log(dataTable2);
dataTable2.map(i => {
if (i[0] == 3) {
if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "") {
error = true
......@@ -992,55 +1299,154 @@ export default class ListOfCreditFacilities extends Component {
"total_loan": this.state.perBS
}
console.log(body);
// if (error && type == 'submitted') {
// this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
// } else {
// api.create('UPLOAD').uploadMonthlyReportLOCF(body).then(response => {
// console.log(response);
// if (response.data) {
// if (response.ok) {
// if (response.data.status === "success") {
// this.props.saveToMonthlyReport('LOCF')
// // this.props.onClickClose()
// // this.props.getReport()
// } else {
// if (response.data?.message == "Please Set Up Rate Currency First") {
// this.setState({ visibleAlertSave: true })
// } 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);
// }
// })
// }
// // alert(response.data.status)
// }
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
// }
// this.setState({ handleDoubleClick: 0 })
// })
// }
if (error && type == 'submitted') {
this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
} else {
api.create('UPLOAD').uploadMonthlyReportLOCF(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.uploadLOV(type)
// this.props.saveToMonthlyReport('LOCF')
// this.props.onClickClose()
// this.props.getReport()
} else {
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} 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);
}
})
}
// alert(response.data.status)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
}
this.setState({ handleDoubleClick: 0 })
})
}
}
// handleCalculateLOV = () => {
// let dataTable2 = this.state.dataTableLOV
// console.log(dataTable2);
// }
uploadLOV(type) {
console.log('masoook LOV');
let dataTable2 = this.state.dataTablelov == undefined || this.state.tambahLOV == 'tambah' || this.state.tambahLOV == 'upload' ? this.state.dataTableLOV : this.state.dataTablelov
let data = []
let error = false
// this.deleteReport()
console.log(dataTable2);
dataTable2.map(i => {
if (i[0] == 3) {
if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "" || i[12] == "") {
error = true
}
if (i[8] == '' && i[7]?.value == 'Time deposit' || i[7]?.value == 'N/A') {
error = true
}
let tgl = String(i[9]).split('-')
let checkUndifined = tgl.findIndex((val) => val == undefined)
if (this.props.defaultCurrency.id == 2) {
data.push({
"item_report_id": i[1],
"company_name": i[5],
"institution_name": i[6],
"type_of_investment": i[7] == null ? i[7] : i[7].value,
"remarks": i[8],
"placement_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
"tenor": i[10],
"expected_return": i[11] == "" ? "0.00" : i[11],
"currency": i[12] == null ? i[12] : i[12].value,
"investment_amount_ori": Number(i[13]) == "" ? "0.0" : Number(i[13]),
"investment_amount_cur": Number(i[14]) == "" ? "0.0" : Number(i[14]),
"notes": i[15],
})
} else {
data.push({
"item_report_id": i[1],
"company_name": i[5],
"institution_name": i[6],
"type_of_investment": i[7] == null ? i[7] : i[7].value,
"remarks": i[8],
"placement_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
"tenor": i[10],
"expected_return": i[11] == "" ? "0.00" : i[11],
"currency": i[12] == null ? i[12] : i[12].value,
"investment_amount_ori": Number(i[13]) == "" ? "0.0" : Number(i[13]),
"investment_amount_cur": Number(i[14]) == "" ? "0.0" : Number(i[14]),
"notes": i[15],
})
}
}
})
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,
"lov": data,
"per_bs": this.state.perBS,
"diff": this.state.diff,
"total_loan": this.state.perBS
}
console.log(body);
if (error && type == 'submitted') {
this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
} else {
api.create('UPLOAD').uploadMonthlyReportLOV(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport('LOCF')
this.setState({ loadingChild : false})
// this.props.onClickClose()
// this.props.getReport()
} else {
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} 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);
}
})
}
// alert(response.data.status)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
}
this.setState({ handleDoubleClick: 0 })
})
}
}
render() {
let dataTable2 = this.state.dataTable
let loading = this.state.loading
let totalLoan = 0
const loadingComponent = (
<div style={{ position: 'fixed', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
......@@ -1070,7 +1476,7 @@ export default class ListOfCreditFacilities extends Component {
<Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
</div>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleLOCFMR ?
{this.state.visibleParent ?
< Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<Snackbar open={this.state.snekbar} autoHideDuration={3000} onClose={handleClose}>
<Alert onClose={handleClose} severity="error">
......@@ -1191,7 +1597,7 @@ export default class ListOfCreditFacilities extends Component {
this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete' })
:
this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.setState({ handleDoubleClick: 1, loadingChild: true }, () => {
setTimeout(() => {
this.backToMonthlyReportLOCF('draft')
}, 100);
......@@ -1213,11 +1619,11 @@ export default class ListOfCreditFacilities extends Component {
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.state.saveComp || this.state.saveTambahan ?
this.state.saveComp || this.state.saveCompLOV || this.state.saveTambahan ?
this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete / Diff must be 0' })
:
this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.setState({ handleDoubleClick: 1, loadingChild: true }, () => {
setTimeout(() => {
this.backToMonthlyReportLOCF('submitted')
}, 100);
......@@ -1264,6 +1670,7 @@ export default class ListOfCreditFacilities extends Component {
width={this.props.width}
sendToParent={this.dataTableForChild.bind(this)}
dataTablelocf={this.state.dataTablelocf}
loadingChild={this.state.loadingChild}
/>
<hr />
<LOV
......@@ -1281,19 +1688,18 @@ export default class ListOfCreditFacilities extends Component {
height={this.props.height}
width={this.props.width}
sendToParent={this.dataTableForChild.bind(this)}
sendDataTable={this.olahDataTable.bind(this)}
dataTablelov={this.state.dataTablelov}
loadingChild={this.state.loadingChild}
/>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button
type="button"
onClick={() => {
this.getBankData()
this.getTypeOfCredit()
this.getSubmission()
}
}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
......@@ -1319,7 +1725,7 @@ export default class ListOfCreditFacilities extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ totalOutStand: totalLoan, saveTambahan: false }, () => {
onClick={() => this.setState({ totalOutStand: totalLoan, saveTambahan: false, loadingChild: true }, () => {
this.handleCalculateLOCF()
})}
>
......@@ -1335,7 +1741,7 @@ export default class ListOfCreditFacilities extends Component {
this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete' })
:
this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.setState({ handleDoubleClick: 1, loadingChild: true }, () => {
setTimeout(() => {
this.uploadLOCF('draft')
}, 100);
......@@ -1357,11 +1763,11 @@ export default class ListOfCreditFacilities extends Component {
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.state.saveComp || this.state.saveTambahan ?
this.state.saveComp || this.state.saveCompLOV || this.state.saveTambahan ?
this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete / Diff must be 0' })
:
this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.setState({ handleDoubleClick: 1, loadingChild: true }, () => {
setTimeout(() => {
this.uploadLOCF('submitted')
}, 100);
......
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