Commit fa1e4e00 authored by Riri Novita's avatar Riri Novita

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

create LOV

See merge request !2188
parents ef19eb71 30103bc0
...@@ -553,6 +553,8 @@ const create = (type = "") => { ...@@ -553,6 +553,8 @@ const create = (type = "") => {
const getTypeOfInvestment = () => api.get('setting_type/get_all_setting_type_by_investment') 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 validateSaveLOV = (body) => api.post('transaction/lov/monthly_report/validate_save', body)
const validateSaveLOCF = (body) => api.post('transaction/locf/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 // Superadmin Approve
...@@ -958,7 +960,9 @@ const create = (type = "") => { ...@@ -958,7 +960,9 @@ const create = (type = "") => {
uploadSimulasiROOI, uploadSimulasiROOI,
getTypeOfInvestment, getTypeOfInvestment,
validateSaveLOCF, validateSaveLOCF,
validateSaveLOV validateSaveLOV,
uploadMonthlyReportLOV,
createMonthlyReportLOV
} }
} }
......
...@@ -161,10 +161,10 @@ export default class ListOfCreditFacilities extends Component { ...@@ -161,10 +161,10 @@ export default class ListOfCreditFacilities extends Component {
switch (params) { switch (params) {
case "LOV": case "LOV":
console.log(data); console.log(data);
this.setState({ dataTableLOV: data, diffLOV: array[16], perBSLOV: array[18], tambahLOV: type, visibleParent: visibleView == undefined ? true : visibleView}) this.setState({ dataTableLOV: data, diffLOV: array[16], perBSLOV: array[18], tambahLOV: type, visibleParent: visibleView == undefined ? true : visibleView })
break; break;
case "LOCF": case "LOCF":
this.setState({ dataTableLOCF: data, diffLOCF: array[46], perBSLOCF: array[48], tambah: type, visibleParent: visibleView == undefined ? true : visibleView}) this.setState({ dataTableLOCF: data, diffLOCF: array[46], perBSLOCF: array[48], tambah: type, visibleParent: visibleView == undefined ? true : visibleView })
break break
default: default:
break; break;
...@@ -276,19 +276,193 @@ export default class ListOfCreditFacilities extends Component { ...@@ -276,19 +276,193 @@ export default class ListOfCreditFacilities extends Component {
}) })
} }
// 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) { backToMonthlyReportLOCF(type) {
// this.setState({ loading: true }) console.log('masoook LOCF');
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 dataTable2 = this.state.dataTablelocf == undefined || this.state.tambah == 'tambah' || this.state.tambah == 'upload' ? this.state.dataTableLOCF : this.state.dataTablelocf
let data = [] let data = []
let error = false let error = false
this.deleteReport() // this.deleteReport()
this.state.dataTable.map(i => { console.log(dataTable2);
console.log(i); dataTable2.map(i => {
if (i[0] == 3) { if (i[0] == 3) {
if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "") { if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "") {
error = true error = true
} }
if (i[7].value == 'Others' && i[18] == '') { if (i[7].value == 'Others' && i[18] == '') {
error = true error = true
} }
...@@ -301,8 +475,9 @@ export default class ListOfCreditFacilities extends Component { ...@@ -301,8 +475,9 @@ export default class ListOfCreditFacilities extends Component {
"bank_name": i[6] == null ? [6] : i[6].value, "bank_name": i[6] == null ? [6] : i[6].value,
"type_of_credit": i[7] == null ? i[7] : i[7].value, "type_of_credit": i[7] == null ? i[7] : i[7].value,
"remarks": i[8], "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], // "loan_maturity_date": i[9],
"loan_maturity_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
// "loan_maturity_date": i[9] !== undefined || i[9] !== "null" || i[9] !== null? (String(tgl[2]).length <= 2? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])) : "",
"interest": i[10] == "" ? "0.00" : i[10], "interest": i[10] == "" ? "0.00" : i[10],
"currency": i[11], "currency": i[11],
"loan_plafond_amount_ori": Number(i[12]) == "" ? "0.0" : Number(i[12]), "loan_plafond_amount_ori": Number(i[12]) == "" ? "0.0" : Number(i[12]),
...@@ -348,8 +523,9 @@ export default class ListOfCreditFacilities extends Component { ...@@ -348,8 +523,9 @@ export default class ListOfCreditFacilities extends Component {
"bank_name": i[6] == null ? [6] : i[6].value, "bank_name": i[6] == null ? [6] : i[6].value,
"type_of_credit": i[7] == null ? i[7] : i[7].value, "type_of_credit": i[7] == null ? i[7] : i[7].value,
"remarks": i[8], "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], // "loan_maturity_date": i[9],
"loan_maturity_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
// "loan_maturity_date": i[9] !== undefined || i[9] !== "null" || i[9] !== null? (String(tgl[2]).length <= 2? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])) : "",
"interest": i[10] == "" ? "0.00" : i[10], "interest": i[10] == "" ? "0.00" : i[10],
"currency": i[11], "currency": i[11],
"loan_plafond_amount_ori": fixNumber(Number(i[12]), 1) == "" ? "0.0" : fixNumber(Number(i[12]), 1), "loan_plafond_amount_ori": fixNumber(Number(i[12]), 1) == "" ? "0.0" : fixNumber(Number(i[12]), 1),
...@@ -392,7 +568,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -392,7 +568,7 @@ export default class ListOfCreditFacilities extends Component {
} }
}) })
let payload = { let body = {
"monthly_report_id": this.props.monthlyReportId, "monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
"periode": this.props.periode, "periode": this.props.periode,
...@@ -401,51 +577,146 @@ export default class ListOfCreditFacilities extends Component { ...@@ -401,51 +577,146 @@ export default class ListOfCreditFacilities extends Component {
"months": this.props.month.month_id, "months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id, "currency_id": this.props.defaultCurrency.id,
"locf": data, "locf": data,
"per_bs": this.state.perBSLOCF, "per_bs": this.state.perBS,
"diff": this.state.diff, "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 })
})
}
} }
console.log(payload) 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
}
// if (error && type == 'submitted') { if (i[8] == '' && i[7]?.value == 'Time deposit' || i[7]?.value == 'N/A') {
// this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 }) error = true
// } else { }
// api.create('UPLOAD').createMonthlyReportLOCF(payload).then(response => { let tgl = String(i[9]).split('-')
// console.log(response); let checkUndifined = tgl.findIndex((val) => val == undefined)
// if (response.data) { if (this.props.defaultCurrency.id == 2) {
// if (response.data.status === "success") { data.push({
// this.props.saveToMonthlyReport('LOCF') "item_report_id": i[1],
// } else { "company_name": i[5],
// if (response.data?.message == "Please Set Up Rate Currency First") { "institution_name": i[6],
// this.setState({ visibleAlertSave: true }) "type_of_investment": i[7] == null ? i[7] : i[7].value,
// } else { "remarks": i[8],
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { "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])),
// document.body.style.overflow = 'unset'; "tenor": i[10],
// if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) { "expected_return": i[11] == "" ? "0.00" : i[11],
// setTimeout(() => { "currency": i[12] == null ? i[12] : i[12].value,
// localStorage.removeItem(Constant.TOKEN) "investment_amount_ori": Number(i[13]) == "" ? "0.0" : Number(i[13]),
// window.location.reload(); "investment_amount_cur": Number(i[14]) == "" ? "0.0" : Number(i[14]),
// }, 1000); "notes": i[15],
// } })
// this.props.saveToMonthlyReport() } else {
// }) data.push({
// } "item_report_id": i[1],
// } "company_name": i[5],
// // else { "institution_name": i[6],
// // this.setState({ loading: false }, () => { "type_of_investment": i[7] == null ? i[7] : i[7].value,
// // this.props.saveToMonthlyReport() "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],
// } else { "expected_return": i[11] == "" ? "0.00" : i[11],
// this.setState({ loading: false }, () => { "currency": i[12] == null ? i[12] : i[12].value,
// // this.getSubmission() "investment_amount_ori": Number(i[13]) == "" ? "0.0" : Number(i[13]),
// document.body.style.overflow = 'unset'; "investment_amount_cur": Number(i[14]) == "" ? "0.0" : Number(i[14]),
// }) "notes": i[15],
// } })
// this.setState({ handleDoubleClick: 0 }) }
// })
// } }
})
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').createMonthlyReportLOV(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})
} 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 })
})
}
} }
handleCalculateLOCF = () => { handleCalculateLOCF = () => {
...@@ -732,7 +1003,6 @@ export default class ListOfCreditFacilities extends Component { ...@@ -732,7 +1003,6 @@ export default class ListOfCreditFacilities extends Component {
} }
handleCalculateLOV = () => { handleCalculateLOV = () => {
console.log(this.state.visibleParent);
this.setState({ loading: true }) this.setState({ loading: true })
let dataTable2 = this.state.dataTablelov == undefined || this.state.tambahLOV == 'tambah' || this.state.tambahLOV == 'upload' ? this.state.dataTableLOV : 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 data = []
...@@ -898,7 +1168,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -898,7 +1168,7 @@ export default class ListOfCreditFacilities extends Component {
} }
uploadLOCF(type) { uploadLOCF(type) {
console.log('masooook'); 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 dataTable2 = this.state.dataTablelocf == undefined || this.state.tambah == 'tambah' || this.state.tambah == 'upload' ? this.state.dataTableLOCF : this.state.dataTablelocf
let data = [] let data = []
let error = false let error = false
...@@ -1029,41 +1299,146 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1029,41 +1299,146 @@ export default class ListOfCreditFacilities extends Component {
"total_loan": this.state.perBS "total_loan": this.state.perBS
} }
console.log(body); console.log(body);
// if (error && type == 'submitted') { if (error && type == 'submitted') {
// this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 }) this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
// } else { } else {
// api.create('UPLOAD').uploadMonthlyReportLOCF(body).then(response => { api.create('UPLOAD').uploadMonthlyReportLOCF(body).then(response => {
// console.log(response); console.log(response);
// if (response.data) { if (response.data) {
// if (response.ok) { if (response.ok) {
// if (response.data.status === "success") { if (response.data.status === "success") {
this.uploadLOV(type)
// this.props.saveToMonthlyReport('LOCF') // this.props.saveToMonthlyReport('LOCF')
// // 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") {
// this.setState({ visibleAlertSave: true }) this.setState({ visibleAlertSave: true })
// } else { } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { 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")) { if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
// setTimeout(() => { setTimeout(() => {
// localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
// window.location.reload(); window.location.reload();
// }, 1000); }, 1000);
// } }
// }) })
// } }
// // alert(response.data.status) // alert(response.data.status)
// } }
// } else { } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
// } }
// } else { } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
// } }
// this.setState({ handleDoubleClick: 0 }) this.setState({ handleDoubleClick: 0 })
// }) })
// } }
}
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() { render() {
...@@ -1222,7 +1597,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1222,7 +1597,7 @@ export default class ListOfCreditFacilities extends Component {
this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete' }) this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete' })
: :
this.state.handleDoubleClick == 1 ? null : this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => { this.setState({ handleDoubleClick: 1, loadingChild: true }, () => {
setTimeout(() => { setTimeout(() => {
this.backToMonthlyReportLOCF('draft') this.backToMonthlyReportLOCF('draft')
}, 100); }, 100);
...@@ -1248,7 +1623,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1248,7 +1623,7 @@ export default class ListOfCreditFacilities extends Component {
this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete / Diff must be 0' }) this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete / Diff must be 0' })
: :
this.state.handleDoubleClick == 1 ? null : this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => { this.setState({ handleDoubleClick: 1, loadingChild: true }, () => {
setTimeout(() => { setTimeout(() => {
this.backToMonthlyReportLOCF('submitted') this.backToMonthlyReportLOCF('submitted')
}, 100); }, 100);
...@@ -1320,12 +1695,11 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1320,12 +1695,11 @@ export default class ListOfCreditFacilities extends Component {
<div className="col-1"> <div className="col-1">
<button <button
type="button" type="button"
onClick={() => { onClick={() => this.setState({ loading: true }, () => {
this.getBankData() setTimeout(() => {
this.getTypeOfCredit() this.props.onClickClose()
this.getSubmission() }, 100);
} })}
}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
...@@ -1351,7 +1725,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1351,7 +1725,7 @@ export default class ListOfCreditFacilities extends Component {
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
}} }}
onClick={() => this.setState({ totalOutStand: totalLoan, saveTambahan: false }, () => { onClick={() => this.setState({ totalOutStand: totalLoan, saveTambahan: false, loadingChild: true }, () => {
this.handleCalculateLOCF() this.handleCalculateLOCF()
})} })}
> >
...@@ -1367,7 +1741,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1367,7 +1741,7 @@ export default class ListOfCreditFacilities extends Component {
this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete' }) this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete' })
: :
this.state.handleDoubleClick == 1 ? null : this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => { this.setState({ handleDoubleClick: 1, loadingChild: true }, () => {
setTimeout(() => { setTimeout(() => {
this.uploadLOCF('draft') this.uploadLOCF('draft')
}, 100); }, 100);
...@@ -1393,7 +1767,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1393,7 +1767,7 @@ export default class ListOfCreditFacilities extends Component {
this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete / Diff must be 0' }) this.setState({ snekbar: true, snekbarMsg: 'Data Incomplete / Diff must be 0' })
: :
this.state.handleDoubleClick == 1 ? null : this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => { this.setState({ handleDoubleClick: 1, loadingChild: true }, () => {
setTimeout(() => { setTimeout(() => {
this.uploadLOCF('submitted') this.uploadLOCF('submitted')
}, 100); }, 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