Commit 06b6ce22 authored by Riri Novita's avatar Riri Novita

locf lov

parent 8d012139
...@@ -614,7 +614,9 @@ export default class LOCF extends Component { ...@@ -614,7 +614,9 @@ export default class LOCF extends Component {
} }
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => {
this.handleCalculate() // this.handleCalculate()
let lastArray = dataTable[dataTable.length - 1]
this.props.sendToParent(dataTable, lastArray, 'LOCF')
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[23].length > 0) { if (item[23].length > 0) {
// console.log('masuk') // console.log('masuk')
...@@ -1263,271 +1265,270 @@ export default class LOCF extends Component { ...@@ -1263,271 +1265,270 @@ export default class LOCF extends Component {
} }
handleCalculate = () => { // handleCalculate = () => {
let dataTable2 = this.state.dataTable // let dataTable2 = this.state.dataTable
let data = [] // let data = []
let error = false // let error = false
dataTable2.map(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
} // }
let tgl = String(i[9]).split('-') // let tgl = String(i[9]).split('-')
let checkUndifined = tgl.findIndex((val) => val == undefined) // let checkUndifined = tgl.findIndex((val) => val == undefined)
if (this.props.defaultCurrency.id == 2) { // if (this.props.defaultCurrency.id == 2) {
data.push({ // data.push({
"item_report_id": i[1], // "item_report_id": i[1],
"borrower_comp_name": i[5], // "borrower_comp_name": i[5],
"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] == 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]),
"loan_plafond_amount_idr": Number(i[13]) == "" ? "0.0" : Number(i[13]), // "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_ori": Number(i[14]) == "" ? "0.0" : Number(i[14]),
"out_loan_ki_amount_idr": Number(i[15]) == "" ? "0.0" : Number(i[15]), // "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_ori": Number(i[16]) == "" ? "0.0" : Number(i[16]),
"out_loan_kmk_amount_idr": Number(i[17]) == "" ? "0.0" : Number(i[17]), // "out_loan_kmk_amount_idr": Number(i[17]) == "" ? "0.0" : Number(i[17]),
"out_loan_other_type": 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_ori": Number(i[19]) == "" ? "0.0" : Number(i[19]),
"out_loan_other_amount_idr": Number(i[20]) == "" ? "0.0" : Number(i[20]), // "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_ori": Number(i[21]) == "" ? "0.0" : Number(i[21]),
"total_out_loan_idr": Number(i[22]) == "" ? "0.0" : Number(i[22]), // "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_ori": Number(i[23]) == "" ? "0.0" : Number(i[23]),
"remaining_plafond_idr": Number(i[24]) == "" ? "0.0" : Number(i[24]), // "remaining_plafond_idr": Number(i[24]) == "" ? "0.0" : Number(i[24]),
"current_ratio_financial": Number(i[25]) == "" ? "0.00" : Number(i[25]), // "current_ratio_financial": Number(i[25]) == "" ? "0.00" : Number(i[25]),
"current_ratio_current": Number(i[26]) == "" ? "0.00" : Number(i[26]), // "current_ratio_current": Number(i[26]) == "" ? "0.00" : Number(i[26]),
"der_financial": Number(i[27]) == "" ? "0.00" : Number(i[27]), // "der_financial": Number(i[27]) == "" ? "0.00" : Number(i[27]),
"der_current": Number(i[28]) == "" ? "0.00" : Number(i[28]), // "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_financial": Number(i[29]) == "" ? "0.00" : Number(i[29]),
"debt_to_ebitda_current": Number(i[30]) == "" ? "0.00" : Number(i[30]), // "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_financial": Number(i[31]) == "" ? "0.00" : Number(i[31]),
"ebitda_to_interest_current": Number(i[32]) == "" ? "0.00" : Number(i[32]), // "ebitda_to_interest_current": Number(i[32]) == "" ? "0.00" : Number(i[32]),
"other_ratio1_ratio_name": i[33], // "other_ratio1_ratio_name": i[33],
"other_ratio1_financial": Number(i[34]) == "" ? "0.00" : Number(i[34]), // "other_ratio1_financial": Number(i[34]) == "" ? "0.00" : Number(i[34]),
"other_ratio1_current": Number(i[35]) == "" ? "0.00" : Number(i[35]), // "other_ratio1_current": Number(i[35]) == "" ? "0.00" : Number(i[35]),
"other_ratio2_ratio_name": i[36], // "other_ratio2_ratio_name": i[36],
"other_ratio2_financial": Number(i[37]) == "" ? "0.00" : Number(i[37]), // "other_ratio2_financial": Number(i[37]) == "" ? "0.00" : Number(i[37]),
"other_ratio2_current": Number(i[38]) == "" ? "0.00" : Number(i[38]), // "other_ratio2_current": Number(i[38]) == "" ? "0.00" : Number(i[38]),
"other_ratio3_ratio_name": i[39], // "other_ratio3_ratio_name": i[39],
"other_ratio3_financial": Number(i[40]) == "" ? "0.00" : Number(i[40]), // "other_ratio3_financial": Number(i[40]) == "" ? "0.00" : Number(i[40]),
"other_ratio3_current": Number(i[41]) == "" ? "0.00" : Number(i[41]), // "other_ratio3_current": Number(i[41]) == "" ? "0.00" : Number(i[41]),
"other_ratio4_ratio_name": i[42], // "other_ratio4_ratio_name": i[42],
"other_ratio4_financial": Number(i[43]) == "" ? "0.00" : Number(i[43]), // "other_ratio4_financial": Number(i[43]) == "" ? "0.00" : Number(i[43]),
"other_ratio4_current": Number(i[44]) == "" ? "0.00" : Number(i[44]), // "other_ratio4_current": Number(i[44]) == "" ? "0.00" : Number(i[44]),
"notes": i[45], // "notes": i[45],
}) // })
} else { // } else {
data.push({ // data.push({
"item_report_id": i[1], // "item_report_id": i[1],
"borrower_comp_name": i[5], // "borrower_comp_name": i[5],
"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] == 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),
"loan_plafond_amount_idr": fixNumber(Number(i[13]), 1) == "" ? "0.0" : fixNumber(Number(i[13]), 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_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_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_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), // "out_loan_kmk_amount_idr": fixNumber(Number(i[17]), 1) == "" ? "0.0" : fixNumber(Number(i[17]), 1),
"out_loan_other_type": 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_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), // "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_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), // "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_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), // "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_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), // "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_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), // "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_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), // "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_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), // "ebitda_to_interest_current": fixNumber(Number(i[32]), 2) == "" ? "0.00" : fixNumber(Number(i[32]), 2),
"other_ratio1_ratio_name": i[33], // "other_ratio1_ratio_name": i[33],
"other_ratio1_financial": fixNumber(Number(i[34]), 2) == "" ? "0.00" : fixNumber(Number(i[34]), 2), // "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_ratio1_current": fixNumber(Number(i[35]), 2) == "" ? "0.00" : fixNumber(Number(i[35]), 2),
"other_ratio2_ratio_name": i[36], // "other_ratio2_ratio_name": i[36],
"other_ratio2_financial": fixNumber(Number(i[37]), 2) == "" ? "0.00" : fixNumber(Number(i[37]), 2), // "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_ratio2_current": fixNumber(Number(i[38]), 2) == "" ? "0.00" : fixNumber(Number(i[38]), 2),
"other_ratio3_ratio_name": i[39], // "other_ratio3_ratio_name": i[39],
"other_ratio3_financial": fixNumber(Number(i[40]), 2) == "" ? "0.00" : fixNumber(Number(i[40]), 2), // "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_ratio3_current": fixNumber(Number(i[41]), 2) == "" ? "0.00" : fixNumber(Number(i[41]), 2),
"other_ratio4_ratio_name": i[42], // "other_ratio4_ratio_name": i[42],
"other_ratio4_financial": fixNumber(Number(i[43]), 2) == "" ? "0.00" : fixNumber(Number(i[43]), 2), // "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), // "other_ratio4_current": fixNumber(Number(i[44]), 2) == "" ? "0.00" : fixNumber(Number(i[44]), 2),
"notes": i[45], // "notes": i[45],
}) // })
} // }
} // }
}) // })
let body = { // 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,
"report_id": this.props.report_id, // "report_id": this.props.report_id,
"status": 'submitted', // "status": 'submitted',
"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.perBS, // "per_bs": this.state.perBS,
"diff": this.state.diff, // "diff": this.state.diff,
"total_loan": this.state.perBS // "total_loan": this.state.perBS
} // }
console.log(body); // console.log(body);
api.create().validateSaveLOCF(body).then((response) => { // api.create().validateSaveLOCF(body).then((response) => {
console.log(response); // console.log(response);
let dataTable = [] // let dataTable = []
if (response.data) { // if (response.data) {
let res = response.data.data // let res = response.data.data
const handlePushChild = (item) => { // const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) // let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
let tgl = String(item.locf.loan_maturity_date).split('-') // let tgl = String(item.locf.loan_maturity_date).split('-')
if (indexIDzz === -1) { // if (indexIDzz === -1) {
dataTable.push([ // dataTable.push([
item.type_report_id, // item.type_report_id,
item.id, // item.id,
item.parent, // item.parent,
item.formula, // item.formula,
item.level, // item.level,
String(item.locf.bank_name).includes('Total') ? null : item.locf.borrower_comp_name === null || item.locf.borrower_comp_name === "" ? this.props.company.company_name : item.locf.borrower_comp_name, // String(item.locf.bank_name).includes('Total') ? null : item.locf.borrower_comp_name === null || item.locf.borrower_comp_name === "" ? this.props.company.company_name : item.locf.borrower_comp_name,
item.locf.bank_name === null ? null : item.locf.bank_name === "" ? null : { value: item.locf.bank_name }, // item.locf.bank_name === null ? null : item.locf.bank_name === "" ? null : { value: item.locf.bank_name },
item.locf.type_of_credit === null ? null : item.locf.type_of_credit === "" ? null : { value: item.locf.type_of_credit }, // item.locf.type_of_credit === null ? null : item.locf.type_of_credit === "" ? null : { value: item.locf.type_of_credit },
item.locf.remarks === null || item.locf.remarks === "" ? "" : item.locf.remarks, // item.locf.remarks === null || item.locf.remarks === "" ? "" : item.locf.remarks,
item.locf.loan_maturity_date == null || item.locf.loan_maturity_date == "" ? null : (item.locf.loan_maturity_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.locf.loan_maturity_date) : null), // item.locf.loan_maturity_date == null || item.locf.loan_maturity_date == "" ? null : (item.locf.loan_maturity_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.locf.loan_maturity_date) : null),
item.locf.interest === null || item.locf.interest === "" ? "0.00" : item.locf.interest, // item.locf.interest === null || item.locf.interest === "" ? "0.00" : item.locf.interest,
item.locf.currency === null || item.locf.currency === "" ? "" : item.locf.currency, // item.locf.currency === null || item.locf.currency === "" ? "" : item.locf.currency,
item.locf.loan_plafond_amount_ori, // item.locf.loan_plafond_amount_ori,
item.locf.loan_plafond_amount_idr === null ? "0.0" : item.locf.loan_plafond_amount_idr === "" ? "0.0" : item.locf.loan_plafond_amount_idr, // item.locf.loan_plafond_amount_idr === null ? "0.0" : item.locf.loan_plafond_amount_idr === "" ? "0.0" : item.locf.loan_plafond_amount_idr,
item.locf.out_loan_ki_amount_ori, // item.locf.out_loan_ki_amount_ori,
item.locf.out_loan_ki_amount_idr === null ? "0.0" : item.locf.out_loan_ki_amount_idr === "" ? "0.0" : item.locf.out_loan_ki_amount_idr, // item.locf.out_loan_ki_amount_idr === null ? "0.0" : item.locf.out_loan_ki_amount_idr === "" ? "0.0" : item.locf.out_loan_ki_amount_idr,
item.locf.out_loan_kmk_amount_ori, // item.locf.out_loan_kmk_amount_ori,
item.locf.out_loan_kmk_amount_idr === null ? "0.0" : item.locf.out_loan_kmk_amount_idr === "" ? "0.0" : item.locf.out_loan_kmk_amount_idr, // item.locf.out_loan_kmk_amount_idr === null ? "0.0" : item.locf.out_loan_kmk_amount_idr === "" ? "0.0" : item.locf.out_loan_kmk_amount_idr,
item.locf.out_loan_other_type, // item.locf.out_loan_other_type,
item.locf.out_loan_other_amount_ori, // item.locf.out_loan_other_amount_ori,
item.locf.out_loan_other_amount_idr === null ? "0.0" : item.locf.out_loan_other_amount_idr === "" ? "0.0" : item.locf.out_loan_other_amount_idr, // item.locf.out_loan_other_amount_idr === null ? "0.0" : item.locf.out_loan_other_amount_idr === "" ? "0.0" : item.locf.out_loan_other_amount_idr,
item.locf.total_out_loan_ori === null ? "0.0" : item.locf.total_out_loan_ori === "" ? "0.0" : item.locf.total_out_loan_ori, // item.locf.total_out_loan_ori === null ? "0.0" : item.locf.total_out_loan_ori === "" ? "0.0" : item.locf.total_out_loan_ori,
item.locf.total_out_loan_idr === null ? "0.0" : item.locf.total_out_loan_idr === "" ? "0.0" : item.locf.total_out_loan_idr, // item.locf.total_out_loan_idr === null ? "0.0" : item.locf.total_out_loan_idr === "" ? "0.0" : item.locf.total_out_loan_idr,
item.locf.remaining_plafond_ori === null ? "0.0" : item.locf.remaining_plafond_ori === "" ? "0.0" : item.locf.remaining_plafond_ori, // item.locf.remaining_plafond_ori === null ? "0.0" : item.locf.remaining_plafond_ori === "" ? "0.0" : item.locf.remaining_plafond_ori,
item.locf.remaining_plafond_idr === null ? "0.0" : item.locf.remaining_plafond_idr === "" ? "0.0" : item.locf.remaining_plafond_idr, // item.locf.remaining_plafond_idr === null ? "0.0" : item.locf.remaining_plafond_idr === "" ? "0.0" : item.locf.remaining_plafond_idr,
item.locf.current_ratio_financial, // item.locf.current_ratio_financial,
item.locf.current_ratio_current === null ? "0.0" : item.locf.current_ratio_current === "" ? "0.0" : item.locf.current_ratio_current, // item.locf.current_ratio_current === null ? "0.0" : item.locf.current_ratio_current === "" ? "0.0" : item.locf.current_ratio_current,
item.locf.der_financial, // item.locf.der_financial,
item.locf.der_current === null ? "0.0" : item.locf.der_current === "" ? "0.0" : item.locf.der_current, // item.locf.der_current === null ? "0.0" : item.locf.der_current === "" ? "0.0" : item.locf.der_current,
item.locf.debt_to_ebitda_financial, // item.locf.debt_to_ebitda_financial,
item.locf.debt_to_ebitda_current === null ? "0.0" : item.locf.debt_to_ebitda_current === "" ? "0.0" : item.locf.debt_to_ebitda_current, // item.locf.debt_to_ebitda_current === null ? "0.0" : item.locf.debt_to_ebitda_current === "" ? "0.0" : item.locf.debt_to_ebitda_current,
item.locf.ebitda_to_interest_financial, // item.locf.ebitda_to_interest_financial,
item.locf.ebitda_to_interest_current === null ? "0.0" : item.locf.ebitda_to_interest_current === "" ? "0.0" : item.locf.ebitda_to_interest_current, // item.locf.ebitda_to_interest_current === null ? "0.0" : item.locf.ebitda_to_interest_current === "" ? "0.0" : item.locf.ebitda_to_interest_current,
item.locf.other_ratio1_ratio_name, // item.locf.other_ratio1_ratio_name,
item.locf.other_ratio1_financial, // item.locf.other_ratio1_financial,
item.locf.other_ratio1_current === null ? "0.0" : item.locf.other_ratio1_current === "" ? "0.0" : item.locf.other_ratio1_current, // item.locf.other_ratio1_current === null ? "0.0" : item.locf.other_ratio1_current === "" ? "0.0" : item.locf.other_ratio1_current,
item.locf.other_ratio2_ratio_name, // item.locf.other_ratio2_ratio_name,
item.locf.other_ratio2_financial, // item.locf.other_ratio2_financial,
item.locf.other_ratio2_current === null ? "0.0" : item.locf.other_ratio2_current === "" ? "0.0" : item.locf.other_ratio2_current, // item.locf.other_ratio2_current === null ? "0.0" : item.locf.other_ratio2_current === "" ? "0.0" : item.locf.other_ratio2_current,
item.locf.other_ratio3_ratio_name, // item.locf.other_ratio3_ratio_name,
item.locf.other_ratio3_financial, // item.locf.other_ratio3_financial,
item.locf.other_ratio3_current === null ? "0.0" : item.locf.other_ratio3_current === "" ? "0.0" : item.locf.other_ratio3_current, // item.locf.other_ratio3_current === null ? "0.0" : item.locf.other_ratio3_current === "" ? "0.0" : item.locf.other_ratio3_current,
item.locf.other_ratio4_ratio_name, // item.locf.other_ratio4_ratio_name,
item.locf.other_ratio4_financial, // item.locf.other_ratio4_financial,
item.locf.other_ratio4_current === null ? "0.0" : item.locf.other_ratio4_current === "" ? "0.0" : item.locf.other_ratio4_current, // item.locf.other_ratio4_current === null ? "0.0" : item.locf.other_ratio4_current === "" ? "0.0" : item.locf.other_ratio4_current,
item.locf.notes, // item.locf.notes,
item.diff, // item.diff,
item.total_loan, // item.total_loan,
item.per_bs // item.per_bs
// index // // index
]) // ])
} // }
if (item.children !== null) { // if (item.children !== null) {
if (item.children.length > 0) { // if (item.children.length > 0) {
item.children.map((items, indexs) => { // item.children.map((items, indexs) => {
handlePushChild(items) // handlePushChild(items)
}) // })
} // }
} // }
} // }
res.map((item, index) => { // res.map((item, index) => {
let tgl = String(item.locf.loan_maturity_date).split('-') // let tgl = String(item.locf.loan_maturity_date).split('-')
dataTable.push([ // dataTable.push([
item.type_report_id, // item.type_report_id,
item.id, // item.id,
item.parent, // item.parent,
item.formula, // item.formula,
item.level, // item.level,
String(item.locf.bank_name).includes('Total') ? null : item.locf.borrower_comp_name === null || item.locf.borrower_comp_name === "" ? this.props.company.company_name : item.locf.borrower_comp_name, // String(item.locf.bank_name).includes('Total') ? null : item.locf.borrower_comp_name === null || item.locf.borrower_comp_name === "" ? this.props.company.company_name : item.locf.borrower_comp_name,
item.locf.bank_name === null ? null : item.locf.bank_name === "" ? null : { value: item.locf.bank_name }, // item.locf.bank_name === null ? null : item.locf.bank_name === "" ? null : { value: item.locf.bank_name },
item.locf.type_of_credit === null ? null : item.locf.type_of_credit === "" ? null : { value: item.locf.type_of_credit }, // item.locf.type_of_credit === null ? null : item.locf.type_of_credit === "" ? null : { value: item.locf.type_of_credit },
item.locf.remarks === null || item.locf.remarks === "" ? "" : item.locf.remarks, // item.locf.remarks === null || item.locf.remarks === "" ? "" : item.locf.remarks,
item.locf.loan_maturity_date == null || item.locf.loan_maturity_date == "" ? null : (item.locf.loan_maturity_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.locf.loan_maturity_date) : null), // item.locf.loan_maturity_date == null || item.locf.loan_maturity_date == "" ? null : (item.locf.loan_maturity_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.locf.loan_maturity_date) : null),
item.locf.interest === null || item.locf.interest === "" ? "0.00" : item.locf.interest, // item.locf.interest === null || item.locf.interest === "" ? "0.00" : item.locf.interest,
item.locf.currency === null || item.locf.currency === "" ? "" : item.locf.currency, // item.locf.currency === null || item.locf.currency === "" ? "" : item.locf.currency,
item.locf.loan_plafond_amount_ori, // item.locf.loan_plafond_amount_ori,
item.locf.loan_plafond_amount_idr === null ? "0.0" : item.locf.loan_plafond_amount_idr === "" ? "0.0" : item.locf.loan_plafond_amount_idr, // item.locf.loan_plafond_amount_idr === null ? "0.0" : item.locf.loan_plafond_amount_idr === "" ? "0.0" : item.locf.loan_plafond_amount_idr,
item.locf.out_loan_ki_amount_ori, // item.locf.out_loan_ki_amount_ori,
item.locf.out_loan_ki_amount_idr === null ? "0.0" : item.locf.out_loan_ki_amount_idr === "" ? "0.0" : item.locf.out_loan_ki_amount_idr, // item.locf.out_loan_ki_amount_idr === null ? "0.0" : item.locf.out_loan_ki_amount_idr === "" ? "0.0" : item.locf.out_loan_ki_amount_idr,
item.locf.out_loan_kmk_amount_ori, // item.locf.out_loan_kmk_amount_ori,
item.locf.out_loan_kmk_amount_idr === null ? "0.0" : item.locf.out_loan_kmk_amount_idr === "" ? "0.0" : item.locf.out_loan_kmk_amount_idr, // item.locf.out_loan_kmk_amount_idr === null ? "0.0" : item.locf.out_loan_kmk_amount_idr === "" ? "0.0" : item.locf.out_loan_kmk_amount_idr,
item.locf.out_loan_other_type, // item.locf.out_loan_other_type,
item.locf.out_loan_other_amount_ori, // item.locf.out_loan_other_amount_ori,
item.locf.out_loan_other_amount_idr === null ? "0.0" : item.locf.out_loan_other_amount_idr === "" ? "0.0" : item.locf.out_loan_other_amount_idr, // item.locf.out_loan_other_amount_idr === null ? "0.0" : item.locf.out_loan_other_amount_idr === "" ? "0.0" : item.locf.out_loan_other_amount_idr,
item.locf.total_out_loan_ori === null ? "0.0" : item.locf.total_out_loan_ori === "" ? "0.0" : item.locf.total_out_loan_ori, // item.locf.total_out_loan_ori === null ? "0.0" : item.locf.total_out_loan_ori === "" ? "0.0" : item.locf.total_out_loan_ori,
item.locf.total_out_loan_idr === null ? "0.0" : item.locf.total_out_loan_idr === "" ? "0.0" : item.locf.total_out_loan_idr, // item.locf.total_out_loan_idr === null ? "0.0" : item.locf.total_out_loan_idr === "" ? "0.0" : item.locf.total_out_loan_idr,
item.locf.remaining_plafond_ori === null ? "0.0" : item.locf.remaining_plafond_ori === "" ? "0.0" : item.locf.remaining_plafond_ori, // item.locf.remaining_plafond_ori === null ? "0.0" : item.locf.remaining_plafond_ori === "" ? "0.0" : item.locf.remaining_plafond_ori,
item.locf.remaining_plafond_idr === null ? "0.0" : item.locf.remaining_plafond_idr === "" ? "0.0" : item.locf.remaining_plafond_idr, // item.locf.remaining_plafond_idr === null ? "0.0" : item.locf.remaining_plafond_idr === "" ? "0.0" : item.locf.remaining_plafond_idr,
item.locf.current_ratio_financial, // item.locf.current_ratio_financial,
item.locf.current_ratio_current === null ? "0.0" : item.locf.current_ratio_current === "" ? "0.0" : item.locf.current_ratio_current, // item.locf.current_ratio_current === null ? "0.0" : item.locf.current_ratio_current === "" ? "0.0" : item.locf.current_ratio_current,
item.locf.der_financial, // item.locf.der_financial,
item.locf.der_current === null ? "0.0" : item.locf.der_current === "" ? "0.0" : item.locf.der_current, // item.locf.der_current === null ? "0.0" : item.locf.der_current === "" ? "0.0" : item.locf.der_current,
item.locf.debt_to_ebitda_financial, // item.locf.debt_to_ebitda_financial,
item.locf.debt_to_ebitda_current === null ? "0.0" : item.locf.debt_to_ebitda_current === "" ? "0.0" : item.locf.debt_to_ebitda_current, // item.locf.debt_to_ebitda_current === null ? "0.0" : item.locf.debt_to_ebitda_current === "" ? "0.0" : item.locf.debt_to_ebitda_current,
item.locf.ebitda_to_interest_financial, // item.locf.ebitda_to_interest_financial,
item.locf.ebitda_to_interest_current === null ? "0.0" : item.locf.ebitda_to_interest_current === "" ? "0.0" : item.locf.ebitda_to_interest_current, // item.locf.ebitda_to_interest_current === null ? "0.0" : item.locf.ebitda_to_interest_current === "" ? "0.0" : item.locf.ebitda_to_interest_current,
item.locf.other_ratio1_ratio_name, // item.locf.other_ratio1_ratio_name,
item.locf.other_ratio1_financial, // item.locf.other_ratio1_financial,
item.locf.other_ratio1_current === null ? "0.0" : item.locf.other_ratio1_current === "" ? "0.0" : item.locf.other_ratio1_current, // item.locf.other_ratio1_current === null ? "0.0" : item.locf.other_ratio1_current === "" ? "0.0" : item.locf.other_ratio1_current,
item.locf.other_ratio2_ratio_name, // item.locf.other_ratio2_ratio_name,
item.locf.other_ratio2_financial, // item.locf.other_ratio2_financial,
item.locf.other_ratio2_current === null ? "0.0" : item.locf.other_ratio2_current === "" ? "0.0" : item.locf.other_ratio2_current, // item.locf.other_ratio2_current === null ? "0.0" : item.locf.other_ratio2_current === "" ? "0.0" : item.locf.other_ratio2_current,
item.locf.other_ratio3_ratio_name, // item.locf.other_ratio3_ratio_name,
item.locf.other_ratio3_financial, // item.locf.other_ratio3_financial,
item.locf.other_ratio3_current === null ? "0.0" : item.locf.other_ratio3_current === "" ? "0.0" : item.locf.other_ratio3_current, // item.locf.other_ratio3_current === null ? "0.0" : item.locf.other_ratio3_current === "" ? "0.0" : item.locf.other_ratio3_current,
item.locf.other_ratio4_ratio_name, // item.locf.other_ratio4_ratio_name,
item.locf.other_ratio4_financial, // item.locf.other_ratio4_financial,
item.locf.other_ratio4_current === null ? "0.0" : item.locf.other_ratio4_current === "" ? "0.0" : item.locf.other_ratio4_current, // item.locf.other_ratio4_current === null ? "0.0" : item.locf.other_ratio4_current === "" ? "0.0" : item.locf.other_ratio4_current,
item.locf.notes, // item.locf.notes,
item.diff, // item.diff,
item.total_loan, // item.total_loan,
item.per_bs // item.per_bs
// index // // index
]) // ])
if (item.children !== null) { // if (item.children !== null) {
if (item.children.length > 0) { // if (item.children.length > 0) {
item.children.map((items, indexs) => { // item.children.map((items, indexs) => {
handlePushChild(items) // handlePushChild(items)
}) // })
} // }
} // }
}) // })
console.log(this.props.dataTablelocf) // console.log(this.props.dataTablelocf)
let lastArray = dataTable[res.length - 1] // let lastArray = dataTable[res.length - 1]
this.setState({ dataTable, diff: lastArray[46], perBS: lastArray[48], loading: false, visibleLOCFMR: true }, () => { // this.setState({ dataTable, diff: lastArray[46], perBS: lastArray[48], loading: false, visibleLOCFMR: true }, () => {
// this.props.sendToParent(dataTable, lastArray, 'LOCF') // })
}) // }
}
}) // })
} // }
render() { render() {
...@@ -1561,6 +1562,7 @@ export default class LOCF extends Component { ...@@ -1561,6 +1562,7 @@ export default class LOCF extends Component {
} }
const handleChange = (value, tableMeta, column, typeChange, typeDrop) => { const handleChange = (value, tableMeta, column, typeChange, typeDrop) => {
console.log(column);
let val = '' let val = ''
if (typeChange == 'date') { if (typeChange == 'date') {
dataTable2[tableMeta.rowIndex][column] = format(value, 'yyyy-MM-dd') dataTable2[tableMeta.rowIndex][column] = format(value, 'yyyy-MM-dd')
...@@ -4088,7 +4090,7 @@ export default class LOCF extends Component { ...@@ -4088,7 +4090,7 @@ export default class LOCF extends Component {
</div> </div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}> <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
<div> <div>
<Typography style={{ fontSize: '12px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.props.notes}</Typography> {/* <Typography style={{ fontSize: '12px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.props.notes}</Typography> */}
</div> </div>
<div style={{ display: 'flex', flexDirection: 'row' }}> <div style={{ display: 'flex', flexDirection: 'row' }}>
<div style={{ padding: 5 }}> <div style={{ padding: 5 }}>
......
...@@ -127,7 +127,7 @@ export default class LOV extends Component { ...@@ -127,7 +127,7 @@ export default class LOV extends Component {
} }
componentDidMount() { componentDidMount() {
this.getPerBS() // this.getPerBS()
this.getTypeOfInvesment() this.getTypeOfInvesment()
this.getListCurrency() this.getListCurrency()
this.getSubmission() this.getSubmission()
...@@ -137,7 +137,7 @@ export default class LOV extends Component { ...@@ -137,7 +137,7 @@ export default class LOV extends Component {
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if (this.props.get_for !== prevProps.get_for) { if (this.props.get_for !== prevProps.get_for) {
this.getPerBS() // this.getPerBS()
this.getTypeOfInvesment() this.getTypeOfInvesment()
this.getListCurrency() this.getListCurrency()
this.getSubmission() this.getSubmission()
...@@ -145,7 +145,7 @@ export default class LOV extends Component { ...@@ -145,7 +145,7 @@ export default class LOV extends Component {
this.handleViewOnly() this.handleViewOnly()
} }
if (this.props.dataTablelov !== prevProps.dataTablelov) { if (this.props.dataTablelov !== prevProps.dataTablelov) {
let array = this.props.dataTablelocf let array = this.props.dataTablelov
let datas = array[array.length - 1] let datas = array[array.length - 1]
console.log(datas); console.log(datas);
this.setState({ dataTable: this.props.dataTablelov }) this.setState({ dataTable: this.props.dataTablelov })
...@@ -215,7 +215,6 @@ export default class LOV extends Component { ...@@ -215,7 +215,6 @@ export default class LOV extends Component {
let res = response.data.data let res = response.data.data
const handlePushChild = (item) => { const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
console.log(indexIDzz);
let tgl = String(item.lov.placement_date).split('-') let tgl = String(item.lov.placement_date).split('-')
if (indexIDzz === -1) { if (indexIDzz === -1) {
dataTable.push([ dataTable.push([
...@@ -235,6 +234,9 @@ export default class LOV extends Component { ...@@ -235,6 +234,9 @@ export default class LOV extends Component {
item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori, item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur, item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
item.lov.notes, item.lov.notes,
item.diff,
item.total_loan,
item.per_bs
// index // index
]) ])
} }
...@@ -265,6 +267,9 @@ export default class LOV extends Component { ...@@ -265,6 +267,9 @@ export default class LOV extends Component {
item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori, item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur, item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
item.lov.notes, item.lov.notes,
item.diff,
item.total_loan,
item.per_bs
// index // index
]) ])
if (item.children !== null) { if (item.children !== null) {
...@@ -278,70 +283,10 @@ export default class LOV extends Component { ...@@ -278,70 +283,10 @@ export default class LOV extends Component {
console.log(dataTable) console.log(dataTable)
let lastArray = dataTable[res.length - 1] let lastArray = dataTable[res.length - 1]
console.log(lastArray); console.log(lastArray);
this.setState({ dataTable, loading: false, visibleLOVMR: true }, () => { this.setState({ dataTable, diff: lastArray[16], perBS: lastArray[18], loading: false, visibleLOVMR: true }, () => {
this.props.sendToParent(dataTable, lastArray, 'LOCF') this.props.sendToParent(dataTable, lastArray, 'LOV')
}) })
} }
// if (response.data) {
// let res = response.data.data
// res.map((item, index) => {
// let tgl = String(item.lov.placement_date).split('-')
// let currency = item.lov.currency
// if (index == res.length - 1) {
// dataTable.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.company_name,
// item.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_name,
// item.lov.type_of_investment === null ? null : item.lov.type_of_investment === "" ? null : { value: item.lov.type_of_investment },
// item.lov.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
// item.lov.placement_date == null || item.lov.placement_date == "" ? null : (item.lov.placement_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.lov.placement_date) : null),
// item.lov.tenor === null || item.lov.tenor === "" ? "" : item.lov.tenor,
// item.lov.expected_return === null || item.lov.expected_return === "" ? "0.0" : item.lov.expected_return,
// item.lov.currency === null ? null : item.lov.currency === "" ? null : { value: item.lov.currency },
// item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
// item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
// item.lov.notes,
// index
// ],
// [9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999],
// )
// } else {
// dataTable.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.company_name,
// item.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_name,
// item.lov.type_of_investment === null ? null : item.lov.type_of_investment === "" ? null : { value: item.lov.type_of_investment },
// item.lov.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
// item.lov.placement_date == null || item.lov.placement_date == "" ? null : (item.lov.placement_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.lov.placement_date) : null),
// item.lov.tenor === null || item.lov.tenor === "" ? "" : item.lov.tenor,
// item.lov.expected_return === null || item.lov.expected_return === "" ? "0.0" : item.lov.expected_return,
// item.lov.currency === null ? null : item.lov.currency === "" ? null : { value: item.lov.currency },
// item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
// item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
// item.lov.notes,
// index
// ])
// }
// })
// if (dataTable.length == 0 && this.props.get_for == 'edit') {
// dataTable.push(
// [3, "", "", "", "", this.props.company.company_name, "", null, "", null, "0.0", "0.0", "", "", "", "", 0],
// [9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999],
// )
// }
// console.log(dataTable)
// this.setState({ dataTable, loading: false, visibleLOVMR: true }, () => {
// this.props.sendToParent(dataTable, 'LOV')
// })
// }
}) })
} }
...@@ -452,79 +397,85 @@ export default class LOV extends Component { ...@@ -452,79 +397,85 @@ export default class LOV extends Component {
}) })
api.create().checkUploadMonthlyReportLOV(payload).then(response => { api.create().checkUploadMonthlyReportLOV(payload).then(response => {
let dataTable = []
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { let res = response.data.data
this.setState({ visibleUpload: false, loading: true, visibleLOVMR: false, totalOutStand: 0, diff: 0 }) const handlePushChild = (item) => {
let dataTable = [] let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
let datas = response.data.data let tgl = String(item.lov.placement_date).split('-')
console.log(datas.lov); if (indexIDzz === -1) {
datas.lov.map((item, index) => {
console.log(item);
if (index == datas.lov.length - 1) {
dataTable.push([
3,
item.item_report_id,
"",
"",
"",
item.company_name === null ? this.props.company.company_name : item.company_name === "" ? this.props.company.company_name : item.company_name,
item.institution_name === null ? null : item.institution_name === "" ? null : item.institution_name,
item.type_of_investment === null ? null : item.type_of_investment === "" ? null : { value: item.type_of_investment },
item.remarks === null || item.remarks === "" ? "" : item.remarks,
item.placement_date === null || item.placement_date === "" ? null : item.placement_date,
item.tenor === null || item.tenor === "" ? "" : item.tenor,
item.expected_return === null || item.expected_return === "" ? "0.0" : item.expected_return,
item.currency === null ? null : item.currency === "" ? null : { value: item.currency },
item.investment_amount_ori === null ? "0.0" : item.investment_amount_ori === "" ? "0.0" : item.investment_amount_ori,
item.investment_amount_cur === null ? "0.0" : item.investment_amount_cur === "" ? "0.0" : item.investment_amount_cur,
item.notes,
],
[9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999],
)
} else {
dataTable.push([ dataTable.push([
3, item.type_report_id,
item.item_report_id, item.id,
"", item.parent,
"", item.formula,
"", item.level,
item.company_name === null ? this.props.company.company_name : item.company_name === "" ? this.props.company.company_name : item.company_name, String(item.lov.institution_name).includes('Total') ? null : item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.company_name,
item.institution_name === null ? null : item.institution_name === "" ? null : { value: item.institution_name }, item.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_name,
item.type_of_investment === null ? null : item.type_of_investment === "" ? null : { value: item.type_of_investment }, item.lov.type_of_investment === null ? null : item.lov.type_of_investment === "" ? null : { value: item.lov.type_of_investment },
item.remarks === null || item.remarks === "" ? "" : item.remarks, item.lov.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
item.placement_date === null || item.placement_date === "" ? null : item.placement_date, item.lov.placement_date == null || item.lov.placement_date == "" ? null : (item.lov.placement_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.lov.placement_date) : null),
item.tenor === null || item.tenor === "" ? "" : item.tenor, item.lov.tenor === null || item.lov.tenor === "" ? "" : item.lov.tenor,
item.expected_return === null || item.expected_return === "" ? "0.0" : item.expected_return, item.lov.expected_return === null || item.lov.expected_return === "" ? "0.0" : item.lov.expected_return,
item.currency === null ? null : item.currency === "" ? null : { value: item.currency }, item.lov.currency === null ? null : item.lov.currency === "" ? null : { value: item.lov.currency },
item.investment_amount_ori === null ? "0.0" : item.investment_amount_ori === "" ? "0.0" : item.investment_amount_ori, item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
item.investment_amount_cur === null ? "0.0" : item.investment_amount_cur === "" ? "0.0" : item.investment_amount_cur, item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
item.notes, item.lov.notes,
item.diff,
item.total_loan,
item.per_bs
// index
]) ])
} }
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
}) })
if (dataTable.length == 0) {
dataTable.push(
[3, "", "", "", "", this.props.company.company_name, "", null, "", null, "0.0", "0.0", "", "", "", "", 0],
[9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999],
)
} }
}
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => { }
// this.handleCalculate() res.map((item, index) => {
// this.state.dataTable.map(item => { let tgl = String(item.lov.placement_date).split('-')
// if (item[23].length > 0) { dataTable.push([
// // console.log('masuk') item.type_report_id,
// this.setState({ buttonError: true, errorPreview: true }) item.id,
// } item.parent,
// }) item.formula,
// console.log(this.state.buttonError) item.level,
String(item.lov.institution_name).includes('Total') ? null : item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.company_name,
item.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_name,
item.lov.type_of_investment === null ? null : item.lov.type_of_investment === "" ? null : { value: item.lov.type_of_investment },
item.lov.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
item.lov.placement_date == null || item.lov.placement_date == "" ? null : (item.lov.placement_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.lov.placement_date) : null),
item.lov.tenor === null || item.lov.tenor === "" ? "" : item.lov.tenor,
item.lov.expected_return === null || item.lov.expected_return === "" ? "0.0" : item.lov.expected_return,
item.lov.currency === null ? null : item.lov.currency === "" ? null : { value: item.lov.currency },
item.lov.investment_amount_ori === null ? "0.0" : item.lov.investment_amount_ori === "" ? "0.0" : item.lov.investment_amount_ori,
item.lov.investment_amount_cur === null ? "0.0" : item.lov.investment_amount_cur === "" ? "0.0" : item.lov.investment_amount_cur,
item.lov.notes,
item.diff,
item.total_loan,
item.per_bs
// index
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
}) })
// console.log(dataTable);
} }
} }
}) })
console.log(dataTable)
let lastArray = dataTable[res.length - 1]
console.log(lastArray);
this.setState({ dataTable, diff: lastArray[16], perBS: lastArray[18], loading: false, visibleLOVMR: true }, () => {
this.props.sendToParent(dataTable, lastArray, 'LOV')
})
}
})
} }
uploadLOCF(type) { uploadLOCF(type) {
...@@ -842,36 +793,36 @@ export default class LOV extends Component { ...@@ -842,36 +793,36 @@ export default class LOV extends Component {
}) })
} }
getPerBS() { // getPerBS() {
let payload = { // let payload = {
"report_id": this.props.report_id, // "report_id": this.props.report_id,
"revision": Number(this.props.revision), // "revision": Number(this.props.revision),
"periode": this.props.periode, // "periode": this.props.periode,
"company_id": this.props.company.company_id, // "company_id": this.props.company.company_id,
"monthly_report_id": this.props.monthlyReportId, // "monthly_report_id": this.props.monthlyReportId,
"months": this.props.month.month_id, // "months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id, // "currency_id": this.props.defaultCurrency.id,
"get_for": this.props.get_for // "get_for": this.props.get_for
} // }
api.create().getPerBSiMontlyReportLOV(payload).then((response) => { // api.create().getPerBSiMontlyReportLOV(payload).then((response) => {
console.log(response) // console.log(response)
if (this.props.get_for == 'view') { // if (this.props.get_for == 'view') {
this.setState({ perBS: "0.0" }) // this.setState({ perBS: "0.0" })
} else { // } else {
if (response.data) { // if (response.data) {
if (response.data.status == "success") { // if (response.data.status == "success") {
this.setState({ // this.setState({
perBS: this.props.defaultCurrency.id == 1 ? (response.data.data.per_bs == null || response.data.data.per_bs == '' ? fixNumber(Number(0), 1) : fixNumber(Number(response.data.data.per_bs), 1)) : (response.data.data.per_bs == null || response.data.data.per_bs == '' ? Number(0) : Number(response.data.data.per_bs)), // perBS: this.props.defaultCurrency.id == 1 ? (response.data.data.per_bs == null || response.data.data.per_bs == '' ? fixNumber(Number(0), 1) : fixNumber(Number(response.data.data.per_bs), 1)) : (response.data.data.per_bs == null || response.data.data.per_bs == '' ? Number(0) : Number(response.data.data.per_bs)),
totalOutStand: response.data.data.total_loan, // totalOutStand: response.data.data.total_loan,
diff: response.data.data.diff // diff: response.data.data.diff
}) // })
} // }
} else { // } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false }) // this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} // }
} // }
}) // })
} // }
backToMonthlyReport(type) { backToMonthlyReport(type) {
// this.setState({ loading: true }) // this.setState({ loading: true })
...@@ -1044,241 +995,241 @@ export default class LOV extends Component { ...@@ -1044,241 +995,241 @@ export default class LOV extends Component {
} }
handleCalculate = () => { // handleCalculate = () => {
let dataTable2 = this.state.dataTable // let dataTable2 = this.state.dataTable
this.setState({ loading: true }, () => { // this.setState({ loading: true }, () => {
let bankPrev = "" // let bankPrev = ""
let idPrev = 0 // let idPrev = 0
let newData = [] // let newData = []
let dataCoba = [] // let dataCoba = []
let bankNameEmpty = false // let bankNameEmpty = false
let totalLoan = 0 // let totalLoan = 0
dataTable2.map((item, index) => { // dataTable2.map((item, index) => {
if (item[0] !== 8) { // if (item[0] !== 8) {
if (item[6] == null) { // if (item[6] == null) {
bankNameEmpty = true // bankNameEmpty = true
} else { // } else {
let groupName = String(item[6].value).split("-") // let groupName = String(item[6].value).split("-")
let indexAS = dataCoba.findIndex((val) => item[6].value.includes(val.groupName)) // let indexAS = dataCoba.findIndex((val) => item[6].value.includes(val.groupName))
if (indexAS == -1) { // if (indexAS == -1) {
dataCoba.push({ // dataCoba.push({
groupName: groupName[groupName.length - 1], // groupName: groupName[groupName.length - 1],
data: [item] // data: [item]
}) // })
} else { // } else {
let indexDD = dataCoba[indexAS].data.length - 1 == -1 ? 0 : dataCoba[indexAS].data.length - 1 // let indexDD = dataCoba[indexAS].data.length - 1 == -1 ? 0 : dataCoba[indexAS].data.length - 1
if (String(dataCoba[indexAS].data[indexDD]).includes('Total')) { // if (String(dataCoba[indexAS].data[indexDD]).includes('Total')) {
let dataAwal = [] // let dataAwal = []
let dataAkhir = [] // let dataAkhir = []
dataAwal = dataCoba[indexAS].data.splice(0, dataCoba[indexAS].data.length - 2) // dataAwal = dataCoba[indexAS].data.splice(0, dataCoba[indexAS].data.length - 2)
dataAkhir = dataCoba[indexAS].data.splice(dataCoba[indexAS].data.length - 1, 1) // dataAkhir = dataCoba[indexAS].data.splice(dataCoba[indexAS].data.length - 1, 1)
dataAwal.push(item) // dataAwal.push(item)
dataCoba[indexAS].data = dataAwal.concat(dataAkhir) // dataCoba[indexAS].data = dataAwal.concat(dataAkhir)
} else { // } else {
dataCoba[indexAS].data.push(item) // dataCoba[indexAS].data.push(item)
} // }
} // }
} // }
} // }
}) // })
console.log(dataCoba); // console.log(dataCoba);
let dataGabung = [] // let dataGabung = []
if (!bankNameEmpty) { // if (!bankNameEmpty) {
dataCoba.map((item, index) => { // dataCoba.map((item, index) => {
item.data.map((items, index) => { // item.data.map((items, index) => {
dataGabung.push(items) // dataGabung.push(items)
}) // })
}) // })
console.log(dataGabung); // console.log(dataGabung);
dataGabung.map((items, index) => { // dataGabung.map((items, index) => {
console.log(items); // console.log(items);
if (items[0] == 3) { // if (items[0] == 3) {
console.log(Number(totalLoan)); // console.log(Number(totalLoan));
this.props.defaultCurrency.id == 1 ? totalLoan += items[22] : totalLoan += items[21] // this.props.defaultCurrency.id == 1 ? totalLoan += items[22] : totalLoan += items[21]
} // }
if (bankPrev != "") { // if (bankPrev != "") {
if (items[6].value !== bankPrev) { // if (items[6].value !== bankPrev) {
bankPrev = items[6].value // bankPrev = items[6].value
if (items[6].value == 'Grand Total') { // if (items[6].value == 'Grand Total') {
// if (dataTable2.length > 2) { // // if (dataTable2.length > 2) {
// // newData.push(items)
// // } else {
// if (String(dataGabung[index - 1][6].value).includes('Total ')) {
// newData.push(items)
// } else {
// // if (String(dataGabung[index][6].value).includes('Total ')) {
// // newData.push(items)
// // } else {
// // items[46] = index + 1
// let nameTotal = String(dataGabung[index - 1][6].value).split("-")
// newData.push([
// 8,
// "",
// "",
// "",
// "",
// "",
// { value: 'Total ' + nameTotal[nameTotal.length - 1] },
// null,
// "",
// null,
// "0.00",
// "",
// "",
// "0",
// "",
// "0",
// "",
// "0",
// "",
// "",
// "0",
// "0",
// "0",
// "0",
// "0",
// "",
// "0",
// "",
// "0",
// "",
// "0",
// "",
// "0",
// "",
// "",
// "",
// "",
// "",
// "",
// "",
// "",
// "",
// "",
// "",
// "",
// "",
// index],
// items,
// )
// // }
// }
// // }
// } else {
// if (String(dataGabung[index - 1][6].value).includes('Total ')) {
// newData.push(items) // newData.push(items)
// } else { // } else {
if (String(dataGabung[index - 1][6].value).includes('Total ')) {
newData.push(items)
} else {
// if (String(dataGabung[index][6].value).includes('Total ')) { // if (String(dataGabung[index][6].value).includes('Total ')) {
// newData.push(items) // newData.push(items)
// } else { // } else {
// items[46] = index + 1 // items[46] = index + 1
let nameTotal = String(dataGabung[index - 1][6].value).split("-") // let nameTotal = String(dataGabung[index - 1][6].value).split("-")
newData.push([ // newData.push([
8, // 8,
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
{ value: 'Total ' + nameTotal[nameTotal.length - 1] }, // { value: 'Total ' + nameTotal[nameTotal.length - 1] },
null, // null,
"", // "",
null, // null,
"0.00", // "0.00",
"", // "",
"", // "",
"0", // "0",
"", // "",
"0", // "0",
"", // "",
"0", // "0",
"", // "",
"", // "",
"0", // "0",
"0", // "0",
"0", // "0",
"0", // "0",
"0", // "0",
"", // "",
"0", // "0",
"", // "",
"0", // "0",
"", // "",
"0", // "0",
"", // "",
"0", // "0",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
"", // "",
index], // index],
items, // items,
) // )
// }
}
// } // }
} else {
if (String(dataGabung[index - 1][6].value).includes('Total ')) {
newData.push(items)
} else {
if (String(dataGabung[index][6].value).includes('Total ')) {
newData.push(items)
} else {
items[46] = index + 1
let nameTotal = String(dataGabung[index - 1][6].value).split("-")
newData.push([
8,
"",
"",
"",
"",
"",
{ value: 'Total ' + nameTotal[nameTotal.length - 1] },
null,
"",
null,
"0.00",
"",
"",
"0",
"",
"0",
"",
"0",
"",
"",
"0",
"0",
"0",
"0",
"0",
"",
"0",
"",
"0",
"",
"0",
"",
"0",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
index],
items,
)
}
} // }
} // }
} // }
else { // else {
newData.push(items) // newData.push(items)
} // }
} else { // } else {
bankPrev = items[6].value // bankPrev = items[6].value
idPrev = items[0] // idPrev = items[0]
newData.push(items) // newData.push(items)
} // }
}) // })
} else { // } else {
if (this.props.get_for == 'edit') { // if (this.props.get_for == 'edit') {
this.setState({ snekbar: true, snekbarMsg: 'Bank Names Cannot be Empty' }) // this.setState({ snekbar: true, snekbarMsg: 'Bank Names Cannot be Empty' })
} // }
} // }
setTimeout(() => { // setTimeout(() => {
// console.log(dataCoba) // // console.log(dataCoba)
// console.log(dataGabung) // // console.log(dataGabung)
console.log(newData) // console.log(newData)
// console.log(dataTampungBank) // // console.log(dataTampungBank)
console.log(totalLoan); // console.log(totalLoan);
console.log(this.state.perBS) // console.log(this.state.perBS)
console.log(this.state.diff) // console.log(this.state.diff)
console.log(bankNameEmpty) // console.log(bankNameEmpty)
// dataTable: newData, totalOutStand: newData[newData.length-1][22] // // dataTable: newData, totalOutStand: newData[newData.length-1][22]
if (bankNameEmpty) { // if (bankNameEmpty) {
if (this.props.get_for == 'view') { // if (this.props.get_for == 'view') {
this.setState({ loading: false, dataTable: this.state.dataTable, diff: this.state.diff == null ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(0 - this.state.perBS), 1) : Number(0 - this.state.perBS), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand, saveDraft: false, saveComp: true }) // this.setState({ loading: false, dataTable: this.state.dataTable, diff: this.state.diff == null ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(0 - this.state.perBS), 1) : Number(0 - this.state.perBS), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand, saveDraft: false, saveComp: true })
} else { // } else {
this.setState({ loading: false, dataTable: this.state.dataTable, diff: this.props.defaultCurrency.id == 1 ? fixNumber(Number(0 - this.state.perBS), 1) : Number(0 - this.state.perBS), saveDraft: false, saveComp: true }) // this.setState({ loading: false, dataTable: this.state.dataTable, diff: this.props.defaultCurrency.id == 1 ? fixNumber(Number(0 - this.state.perBS), 1) : Number(0 - this.state.perBS), saveDraft: false, saveComp: true })
} // }
} else { // } else {
if (this.props.get_for == 'view') { // if (this.props.get_for == 'view') {
if (this.props.defaultCurrency.id == 1) { // if (this.props.defaultCurrency.id == 1) {
this.setState({ loading: false, dataTable: newData, diff: this.state.diff == null ? "0.0" : fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand }) // this.setState({ loading: false, dataTable: newData, diff: this.state.diff == null ? "0.0" : fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand })
} else { // } else {
this.setState({ loading: false, dataTable: newData, diff: this.state.diff == null ? "0.0" : fixNumber(Number(Number(totalLoan) - this.state.perBS), 1), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand }) // this.setState({ loading: false, dataTable: newData, diff: this.state.diff == null ? "0.0" : fixNumber(Number(Number(totalLoan) - this.state.perBS), 1), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand })
} // }
} else { // } else {
if (this.props.defaultCurrency.id == 1) { // if (this.props.defaultCurrency.id == 1) {
this.setState({ loading: false, dataTable: newData, diff: fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1), saveDraft: false, saveComp: Number(fixNumber(Number(totalLoan), 1) - this.state.perBS) == 0 || fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1) == "-0.0" ? false : true }) // this.setState({ loading: false, dataTable: newData, diff: fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1), saveDraft: false, saveComp: Number(fixNumber(Number(totalLoan), 1) - this.state.perBS) == 0 || fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1) == "-0.0" ? false : true })
} else { // } else {
this.setState({ loading: false, dataTable: newData, diff: fixNumber(Number(Number(totalLoan) - this.state.perBS), 1), saveDraft: false, saveComp: Number(Number(totalLoan) - this.state.perBS) == 0 || fixNumber(Number(Number(totalLoan) - this.state.perBS), 1) == "-0.0" ? false : true }) // this.setState({ loading: false, dataTable: newData, diff: fixNumber(Number(Number(totalLoan) - this.state.perBS), 1), saveDraft: false, saveComp: Number(Number(totalLoan) - this.state.perBS) == 0 || fixNumber(Number(Number(totalLoan) - this.state.perBS), 1) == "-0.0" ? false : true })
} // }
} // }
} // }
}, 100); // }, 100);
}) // })
} // }
render() { render() {
...@@ -1311,7 +1262,6 @@ export default class LOV extends Component { ...@@ -1311,7 +1262,6 @@ export default class LOV extends Component {
} }
const handleChange = (value, tableMeta, column, typeChange, typeDrop) => { const handleChange = (value, tableMeta, column, typeChange, typeDrop) => {
console.log(typeChange, value);
let val = '' let val = ''
if (typeChange == 'date') { if (typeChange == 'date') {
dataTable2[tableMeta.rowIndex][column] = format(value, 'yyyy-MM-dd') dataTable2[tableMeta.rowIndex][column] = format(value, 'yyyy-MM-dd')
...@@ -1319,6 +1269,7 @@ export default class LOV extends Component { ...@@ -1319,6 +1269,7 @@ export default class LOV extends Component {
this.setState({ loading: false }) this.setState({ loading: false })
}) })
} else { } else {
console.log(value);
dataTable2[tableMeta.rowIndex][column] = value dataTable2[tableMeta.rowIndex][column] = value
// if (column != 6 && column != 11 && column != 18 && column != 25 && column != 27 && column != 29 && column != 31 && column != 33 && column != 36 && column != 39 && column != 42 && column != 45) { // if (column != 6 && column != 11 && column != 18 && column != 25 && column != 27 && column != 29 && column != 31 && column != 33 && column != 36 && column != 39 && column != 42 && column != 45) {
// val = String(value).split(",").join("") // val = String(value).split(",").join("")
...@@ -1328,34 +1279,35 @@ export default class LOV extends Component { ...@@ -1328,34 +1279,35 @@ export default class LOV extends Component {
// } // }
// if (value.value !== undefined) { if (value.value !== undefined) {
// if (value.value == 'Investment Loan') { this.setState({ loading: true })
// dataTable2[tableMeta.rowIndex][16] = 0 if (value.value == 'Government bonds') {
// dataTable2[tableMeta.rowIndex][17] = 0 this.setState({ loading: false })
// dataTable2[tableMeta.rowIndex][18] = "" } else if (value.value == 'Stocks') {
// dataTable2[tableMeta.rowIndex][19] = 0 this.setState({ loading: false })
// dataTable2[tableMeta.rowIndex][20] = 0 } else if (value.value == 'Mutual funds') {
// } else if (value.value == 'Revolving Loan (KMK)') { this.setState({ loading: false })
// dataTable2[tableMeta.rowIndex][14] = 0 } else if (value.value == 'Investment in associate') {
// dataTable2[tableMeta.rowIndex][15] = 0 this.setState({ loading: false })
// dataTable2[tableMeta.rowIndex][18] = "" } else if (value.value == 'Investment in joint venture') {
// dataTable2[tableMeta.rowIndex][19] = 0 this.setState({ loading: false })
// dataTable2[tableMeta.rowIndex][20] = 0 } else if (value.value == 'Investment in subsidiary') {
// } else if (value.value == 'others') { this.setState({ loading: false })
// dataTable2[tableMeta.rowIndex][14] = 0 } else if (value.value == 'Time deposit') {
// dataTable2[tableMeta.rowIndex][15] = 0 this.setState({ loading: false })
// dataTable2[tableMeta.rowIndex][16] = 0 } else if (value.value == 'Corporate bonds') {
// dataTable2[tableMeta.rowIndex][17] = 0 this.setState({ loading: false })
// } } else if (value.value == 'Others') {
// dataTable2[tableMeta.rowIndex][column] = value this.setState({ loading: false })
// } else { } else if (value.value == 'N/A') {
// dataTable2[tableMeta.rowIndex][column] = val this.setState({ loading: false })
// } }
this.setState({ loading: false })
dataTable2[tableMeta.rowIndex][column] = value
} else {
dataTable2[tableMeta.rowIndex][column] = value
}
} }
console.log(value);
// console.log(dataTable2[tableMeta.rowIndex][column]);
// console.log(value)
// console.log(String(value).split(",").join(""))
} }
const handleValueDropDown = (value, type, tableMeta) => { const handleValueDropDown = (value, type, tableMeta) => {
...@@ -1408,7 +1360,6 @@ export default class LOV extends Component { ...@@ -1408,7 +1360,6 @@ export default class LOV extends Component {
let indexxx = 0 let indexxx = 0
console.log(dataTable2); console.log(dataTable2);
dataTable2.map((item, index) => { dataTable2.map((item, index) => {
console.log(item, index);
indexxx = index indexxx = index
if (item[6] == "Grand Total") { if (item[6] == "Grand Total") {
item[16] = 999999 item[16] = 999999
...@@ -1441,10 +1392,11 @@ export default class LOV extends Component { ...@@ -1441,10 +1392,11 @@ export default class LOV extends Component {
} }
}) })
dataTable2 = newData.sort((a, b) => a[16] - b[16]) dataTable2 = newData.sort((a, b) => a[16] - b[16])
let lastArray = dataTable2[dataTable2.length - 1]
this.setState({ dataTable: dataTable2 }, () => { this.setState({ dataTable: dataTable2 }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false }) this.setState({ loading: false })
console.log(dataTable2) this.props.sendToParent(dataTable2, lastArray, 'LOV', 'tambah')
}, 500) }, 500)
}) })
} }
...@@ -1463,6 +1415,7 @@ export default class LOV extends Component { ...@@ -1463,6 +1415,7 @@ export default class LOV extends Component {
let prevData = dataTable2[index - 1] == undefined ? null : dataTable2[index - 1][6] let prevData = dataTable2[index - 1] == undefined ? null : dataTable2[index - 1][6]
let currentData = dataTable2[index][6] let currentData = dataTable2[index][6]
let nextData = dataTable2[index + 1] == undefined ? null : dataTable2[index + 1][6] let nextData = dataTable2[index + 1] == undefined ? null : dataTable2[index + 1][6]
console.log(nextData);
if (nextData == null) { if (nextData == null) {
dataTable2.splice(index, 1) dataTable2.splice(index, 1)
...@@ -1584,7 +1537,7 @@ export default class LOV extends Component { ...@@ -1584,7 +1537,7 @@ export default class LOV extends Component {
} }
} }
}, { }, {
name: "(Company) Name", name: "Company",
options: { options: {
customHeadRender: (columnMeta) => ( customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}> <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
...@@ -1675,13 +1628,12 @@ export default class LOV extends Component { ...@@ -1675,13 +1628,12 @@ export default class LOV extends Component {
), ),
setCellProps: () => ({ style2 }), setCellProps: () => ({ style2 }),
customBodyRender: (val, tableMeta, updateValue) => { customBodyRender: (val, tableMeta, updateValue) => {
console.log(tableMeta);
return ( return (
<div style={{ textAlign: 'left', width: 90 }}> <div style={{ textAlign: 'left', width: 90 }}>
{tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ? {tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
null : null :
<div style={{ padding: 0, margin: 0 }}> <div style={{ padding: 0, margin: 0 }}>
<textarea disabled={this.props.get_for == 'view'} style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: tableMeta.rowData[8] == '' && this.props.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" defaultValue={tableMeta.rowData[8]} <textarea disabled={this.props.get_for == 'view'} style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.props.get_for == 'view' ? "black" : "#5198ea", backgroundColor: this.props.get_for == 'view' ? 'white' : tableMeta.rowData[8] !== '' ? 'white' : tableMeta.rowData[7] == null ? '#ffac99' : (tableMeta.rowData[8] == '' && tableMeta.rowData[7].value == 'Time deposit' || tableMeta.rowData[7].value == 'N/A') ? 'white' : '#ffac99' }} type="text" defaultValue={tableMeta.rowData[8]}
onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} /> onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} />
</div> </div>
// <Input // <Input
...@@ -2233,7 +2185,7 @@ export default class LOV extends Component { ...@@ -2233,7 +2185,7 @@ export default class LOV extends Component {
</div> </div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}> <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
<div> <div>
<Typography style={{ fontSize: '12px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.props.notes}</Typography> {/* <Typography style={{ fontSize: '12px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.props.notes}</Typography> */}
</div> </div>
<div style={{ display: 'flex', flexDirection: 'row' }}> <div style={{ display: 'flex', flexDirection: 'row' }}>
<div style={{ padding: 5 }}> <div style={{ padding: 5 }}>
...@@ -2244,7 +2196,7 @@ export default class LOV extends Component { ...@@ -2244,7 +2196,7 @@ export default class LOV extends Component {
</div> </div>
</div> </div>
</div> </div>
<div style={{ display: 'flex', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}> {/* <div style={{ display: 'flex', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, fontWeight: 'bold', textDecorationLine: 'underline' }}>Keterangan:</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5, fontWeight: 'bold', textDecorationLine: 'underline' }}>Keterangan:</Typography>
</div> </div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}> <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
...@@ -2261,7 +2213,7 @@ export default class LOV extends Component { ...@@ -2261,7 +2213,7 @@ export default class LOV extends Component {
</div> </div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}> <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 5, paddingRight: 15 }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>4. EBITDA to Interest (ISCR) = EBITDA / Interest Expenses (dimana EBITDA = Income from operations 2 (EBIT 2) + depreciation)</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 0 }}>4. EBITDA to Interest (ISCR) = EBITDA / Interest Expenses (dimana EBITDA = Income from operations 2 (EBIT 2) + depreciation)</Typography>
</div> </div> */}
{/* <div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5}}> {/* <div style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5}}>
<div style={{display: 'flex', flexDirection: 'row'}}> <div style={{display: 'flex', flexDirection: 'row'}}>
......
...@@ -105,7 +105,8 @@ export default class ListOfCreditFacilities extends Component { ...@@ -105,7 +105,8 @@ export default class ListOfCreditFacilities extends Component {
dataTable: [], dataTable: [],
dataTableLOV: [], dataTableLOV: [],
dataTableLOCF: [], dataTableLOCF: [],
lastArray: null, lastArrayLOCF: null,
lastArrayLOV: null,
bankNameList: [], bankNameList: [],
typeOfCreditList: [], typeOfCreditList: [],
loading: false, loading: false,
...@@ -152,7 +153,8 @@ export default class ListOfCreditFacilities extends Component { ...@@ -152,7 +153,8 @@ export default class ListOfCreditFacilities extends Component {
dataTableForChild(data, array, params, type) { dataTableForChild(data, array, params, type) {
switch (params) { switch (params) {
case "LOV": case "LOV":
this.setState({ dataTableLOV: data, }) console.log(data);
this.setState({ dataTableLOV: data, diff: array[16], perBS: array[18], tambahLOV: type})
break; break;
case "LOCF": case "LOCF":
this.setState({ dataTableLOCF: data, diff: array[46], perBS: array[48], tambah: type}) this.setState({ dataTableLOCF: data, diff: array[46], perBS: array[48], tambah: type})
...@@ -304,148 +306,6 @@ export default class ListOfCreditFacilities extends Component { ...@@ -304,148 +306,6 @@ export default class ListOfCreditFacilities extends Component {
}) })
} }
// getPerBS() {
// let payload = {
// "report_id": this.props.report_id,
// "revision": Number(this.props.revision),
// "periode": this.props.periode,
// "company_id": this.props.company.company_id,
// "monthly_report_id": this.props.monthlyReportId,
// "months": this.props.month.month_id,
// "currency_id": this.props.defaultCurrency.id,
// }
// api.create().getPerBSiMontlyReportLOCF(payload).then((response) => {
// console.log(response)
// // if (this.state.get_for == 'view') {
// // this.setState({perBS: "0.0"})
// // } else {
// if (response.data) {
// if (response.data.status == "success") {
// this.setState({
// perBS: this.props.defaultCurrency.id == 1 ? (response.data.data.per_bs == null || response.data.data.per_bs == '' ? fixNumber(Number(0), 1) : fixNumber(Number(response.data.data.per_bs), 1)) : (response.data.data.per_bs == null || response.data.data.per_bs == '' ? Number(0) : Number(response.data.data.per_bs)),
// totalOutStand: response.data.data.total_loan,
// diff: response.data.data.diff
// })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
// }
// // }
// })
// }
// getDataRatio() {
// let payload = {
// "report": 'ratio',
// "monthlyReportId": this.props.monthlyReportId,
// "periode": this.props.periode,
// "companyId": this.props.company.company_id,
// "months": this.props.month.month_id,
// "currency_id": this.props.defaultCurrency.id,
// }
// api.create().getRatioLOCF(payload).then(response => {
// console.log(payload);
// console.log(response);
// let dataTable = []
// if (response.data) {
// if (response.data.status === 'success') {
// let res = response.data.data
// const handlePushChild = (item) => {
// let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
// if (indexIDzz === -1) {
// dataTable.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// item.description,
// item.uom,
// item.ratio.total_actual_before === null ? "0.0" : item.ratio.total_actual_before === "" ? "0.0" : item.ratio.total_actual_before,
// // Number(item.ratio.monthly_january).toFixed(2),
// Number(item.ratio.monthly_january),
// Number(item.ratio.monthly_february),
// Number(item.ratio.monthly_march),
// Number(item.ratio.monthly_april),
// Number(item.ratio.monthly_may),
// Number(item.ratio.monthly_june),
// Number(item.ratio.monthly_july),
// Number(item.ratio.monthly_august),
// Number(item.ratio.monthly_september),
// Number(item.ratio.monthly_october),
// Number(item.ratio.monthly_november),
// Number(item.ratio.monthly_december),
// Number(item.ratio.total_next_year),
// Number(item.ratio.total_more_year),
// item.order,
// item.condition_it_should_be,
// item.condition_if_wrong
// ])
// }
// if (item.children !== null) {
// if (item.children.length > 0) {
// item.children.map((items, indexs) => {
// handlePushChild(items)
// })
// }
// }
// }
// res.map((item, index) => {
// dataTable.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// item.description,
// item.oum,
// item.ratio.total_actual_before === null ? "0.0" : item.ratio.total_actual_before === "" ? "0.0" : item.ratio.total_actual_before,
// Number(item.ratio.monthly_january),
// Number(item.ratio.monthly_february),
// Number(item.ratio.monthly_march),
// Number(item.ratio.monthly_april),
// Number(item.ratio.monthly_may),
// Number(item.ratio.monthly_june),
// Number(item.ratio.monthly_july),
// Number(item.ratio.monthly_august),
// Number(item.ratio.monthly_september),
// Number(item.ratio.monthly_october),
// Number(item.ratio.monthly_november),
// Number(item.ratio.monthly_december),
// Number(item.ratio.total_next_year),
// Number(item.ratio.total_more_year),
// item.order,
// item.condition_it_should_be,
// item.condition_if_wrong
// ])
// if (item.children !== null) {
// if (item.children.length > 0) {
// item.children.map((items, indexs) => {
// handlePushChild(items)
// })
// }
// }
// })
// console.log(dataTable)
// this.setState({ dataTableRatio: dataTable }, () => {
// this.getItemHierarki()
// })
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
// if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
// setTimeout(() => {
// localStorage.removeItem(Constant.TOKEN)
// window.location.reload();
// }, 1000);
// }
// })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
// }
// })
// }
backToMonthlyReport(type) { backToMonthlyReport(type) {
// this.setState({ loading: true }) // this.setState({ loading: true })
let data = [] let data = []
...@@ -872,8 +732,8 @@ export default class ListOfCreditFacilities extends Component { ...@@ -872,8 +732,8 @@ export default class ListOfCreditFacilities extends Component {
} }
} }
}) })
let lastArray = dataTablelocf[res.length - 1] let lastArrayLOCF = dataTablelocf[res.length - 1]
this.setState({ dataTablelocf, diff: lastArray[46], perBS: lastArray[48], loading: false, visibleLOCFMR: true }, () => { this.setState({ dataTablelocf, diff: lastArrayLOCF[46], perBS: lastArrayLOCF[48], loading: false, visibleLOCFMR: true }, () => {
this.handleCalculateLOV() this.handleCalculateLOV()
}) })
console.log(this.state.diff); console.log(this.state.diff);
...@@ -883,10 +743,278 @@ export default class ListOfCreditFacilities extends Component { ...@@ -883,10 +743,278 @@ export default class ListOfCreditFacilities extends Component {
} }
handleCalculateLOV = () => { handleCalculateLOV = () => {
let dataTable2 = this.state.dataTableLOV this.setState({ loading: true})
console.log(dataTable2); console.log(this.state.dataTablelov);
console.log(this.state.dataTableLOV);
let dataTable2 = this.state.dataTablelov == undefined || this.state.tambah == 'tambah' ? this.state.dataTableLOV : this.state.dataTablelov
let data = []
let error = false
// 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
// }
// 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])),
// "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]),
// "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])),
// "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),
// "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 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,
// "currency_id": this.props.defaultCurrency.id,
// "locf": data,
// "per_bs": this.state.perBS,
// "diff": this.state.diff,
// "total_loan": this.state.perBS
// }
// console.log(body);
// api.create().validateSaveLOCF(body).then((response) => {
// console.log(response);
// let dataTablelov = []
// if (response.data) {
// let res = response.data.data
// const handlePushChild = (item) => {
// let indexIDzz = dataTablelov.findIndex((val) => val[1] === item.id)
// let tgl = String(item.locf.loan_maturity_date).split('-')
// if (indexIDzz === -1) {
// dataTablelov.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// String(item.locf.bank_name).includes('Total') ? null : item.locf.borrower_comp_name === null || item.locf.borrower_comp_name === "" ? this.props.company.company_name : item.locf.borrower_comp_name,
// item.locf.bank_name === null ? null : item.locf.bank_name === "" ? null : { value: item.locf.bank_name },
// item.locf.type_of_credit === null ? null : item.locf.type_of_credit === "" ? null : { value: item.locf.type_of_credit },
// item.locf.remarks === null || item.locf.remarks === "" ? "" : item.locf.remarks,
// item.locf.loan_maturity_date == null || item.locf.loan_maturity_date == "" ? null : (item.locf.loan_maturity_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.locf.loan_maturity_date) : null),
// item.locf.interest === null || item.locf.interest === "" ? "0.00" : item.locf.interest,
// item.locf.currency === null || item.locf.currency === "" ? "" : item.locf.currency,
// item.locf.loan_plafond_amount_ori,
// item.locf.loan_plafond_amount_idr === null ? "0.0" : item.locf.loan_plafond_amount_idr === "" ? "0.0" : item.locf.loan_plafond_amount_idr,
// item.locf.out_loan_ki_amount_ori,
// item.locf.out_loan_ki_amount_idr === null ? "0.0" : item.locf.out_loan_ki_amount_idr === "" ? "0.0" : item.locf.out_loan_ki_amount_idr,
// item.locf.out_loan_kmk_amount_ori,
// item.locf.out_loan_kmk_amount_idr === null ? "0.0" : item.locf.out_loan_kmk_amount_idr === "" ? "0.0" : item.locf.out_loan_kmk_amount_idr,
// item.locf.out_loan_other_type,
// item.locf.out_loan_other_amount_ori,
// item.locf.out_loan_other_amount_idr === null ? "0.0" : item.locf.out_loan_other_amount_idr === "" ? "0.0" : item.locf.out_loan_other_amount_idr,
// item.locf.total_out_loan_ori === null ? "0.0" : item.locf.total_out_loan_ori === "" ? "0.0" : item.locf.total_out_loan_ori,
// item.locf.total_out_loan_idr === null ? "0.0" : item.locf.total_out_loan_idr === "" ? "0.0" : item.locf.total_out_loan_idr,
// item.locf.remaining_plafond_ori === null ? "0.0" : item.locf.remaining_plafond_ori === "" ? "0.0" : item.locf.remaining_plafond_ori,
// item.locf.remaining_plafond_idr === null ? "0.0" : item.locf.remaining_plafond_idr === "" ? "0.0" : item.locf.remaining_plafond_idr,
// item.locf.current_ratio_financial,
// item.locf.current_ratio_current === null ? "0.0" : item.locf.current_ratio_current === "" ? "0.0" : item.locf.current_ratio_current,
// item.locf.der_financial,
// item.locf.der_current === null ? "0.0" : item.locf.der_current === "" ? "0.0" : item.locf.der_current,
// item.locf.debt_to_ebitda_financial,
// item.locf.debt_to_ebitda_current === null ? "0.0" : item.locf.debt_to_ebitda_current === "" ? "0.0" : item.locf.debt_to_ebitda_current,
// item.locf.ebitda_to_interest_financial,
// item.locf.ebitda_to_interest_current === null ? "0.0" : item.locf.ebitda_to_interest_current === "" ? "0.0" : item.locf.ebitda_to_interest_current,
// item.locf.other_ratio1_ratio_name,
// item.locf.other_ratio1_financial,
// item.locf.other_ratio1_current === null ? "0.0" : item.locf.other_ratio1_current === "" ? "0.0" : item.locf.other_ratio1_current,
// item.locf.other_ratio2_ratio_name,
// item.locf.other_ratio2_financial,
// item.locf.other_ratio2_current === null ? "0.0" : item.locf.other_ratio2_current === "" ? "0.0" : item.locf.other_ratio2_current,
// item.locf.other_ratio3_ratio_name,
// item.locf.other_ratio3_financial,
// item.locf.other_ratio3_current === null ? "0.0" : item.locf.other_ratio3_current === "" ? "0.0" : item.locf.other_ratio3_current,
// item.locf.other_ratio4_ratio_name,
// item.locf.other_ratio4_financial,
// item.locf.other_ratio4_current === null ? "0.0" : item.locf.other_ratio4_current === "" ? "0.0" : item.locf.other_ratio4_current,
// item.locf.notes,
// item.diff,
// item.total_loan,
// item.per_bs
// // index
// ])
// }
// if (item.children !== null) {
// if (item.children.length > 0) {
// item.children.map((items, indexs) => {
// handlePushChild(items)
// })
// }
// }
// }
// res.map((item, index) => {
// let tgl = String(item.locf.loan_maturity_date).split('-')
// dataTablelov.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// String(item.locf.bank_name).includes('Total') ? null : item.locf.borrower_comp_name === null || item.locf.borrower_comp_name === "" ? this.props.company.company_name : item.locf.borrower_comp_name,
// item.locf.bank_name === null ? null : item.locf.bank_name === "" ? null : { value: item.locf.bank_name },
// item.locf.type_of_credit === null ? null : item.locf.type_of_credit === "" ? null : { value: item.locf.type_of_credit },
// item.locf.remarks === null || item.locf.remarks === "" ? "" : item.locf.remarks,
// item.locf.loan_maturity_date == null || item.locf.loan_maturity_date == "" ? null : (item.locf.loan_maturity_date !== "null" ? String(tgl[2]).length > 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(item.locf.loan_maturity_date) : null),
// item.locf.interest === null || item.locf.interest === "" ? "0.00" : item.locf.interest,
// item.locf.currency === null || item.locf.currency === "" ? "" : item.locf.currency,
// item.locf.loan_plafond_amount_ori,
// item.locf.loan_plafond_amount_idr === null ? "0.0" : item.locf.loan_plafond_amount_idr === "" ? "0.0" : item.locf.loan_plafond_amount_idr,
// item.locf.out_loan_ki_amount_ori,
// item.locf.out_loan_ki_amount_idr === null ? "0.0" : item.locf.out_loan_ki_amount_idr === "" ? "0.0" : item.locf.out_loan_ki_amount_idr,
// item.locf.out_loan_kmk_amount_ori,
// item.locf.out_loan_kmk_amount_idr === null ? "0.0" : item.locf.out_loan_kmk_amount_idr === "" ? "0.0" : item.locf.out_loan_kmk_amount_idr,
// item.locf.out_loan_other_type,
// item.locf.out_loan_other_amount_ori,
// item.locf.out_loan_other_amount_idr === null ? "0.0" : item.locf.out_loan_other_amount_idr === "" ? "0.0" : item.locf.out_loan_other_amount_idr,
// item.locf.total_out_loan_ori === null ? "0.0" : item.locf.total_out_loan_ori === "" ? "0.0" : item.locf.total_out_loan_ori,
// item.locf.total_out_loan_idr === null ? "0.0" : item.locf.total_out_loan_idr === "" ? "0.0" : item.locf.total_out_loan_idr,
// item.locf.remaining_plafond_ori === null ? "0.0" : item.locf.remaining_plafond_ori === "" ? "0.0" : item.locf.remaining_plafond_ori,
// item.locf.remaining_plafond_idr === null ? "0.0" : item.locf.remaining_plafond_idr === "" ? "0.0" : item.locf.remaining_plafond_idr,
// item.locf.current_ratio_financial,
// item.locf.current_ratio_current === null ? "0.0" : item.locf.current_ratio_current === "" ? "0.0" : item.locf.current_ratio_current,
// item.locf.der_financial,
// item.locf.der_current === null ? "0.0" : item.locf.der_current === "" ? "0.0" : item.locf.der_current,
// item.locf.debt_to_ebitda_financial,
// item.locf.debt_to_ebitda_current === null ? "0.0" : item.locf.debt_to_ebitda_current === "" ? "0.0" : item.locf.debt_to_ebitda_current,
// item.locf.ebitda_to_interest_financial,
// item.locf.ebitda_to_interest_current === null ? "0.0" : item.locf.ebitda_to_interest_current === "" ? "0.0" : item.locf.ebitda_to_interest_current,
// item.locf.other_ratio1_ratio_name,
// item.locf.other_ratio1_financial,
// item.locf.other_ratio1_current === null ? "0.0" : item.locf.other_ratio1_current === "" ? "0.0" : item.locf.other_ratio1_current,
// item.locf.other_ratio2_ratio_name,
// item.locf.other_ratio2_financial,
// item.locf.other_ratio2_current === null ? "0.0" : item.locf.other_ratio2_current === "" ? "0.0" : item.locf.other_ratio2_current,
// item.locf.other_ratio3_ratio_name,
// item.locf.other_ratio3_financial,
// item.locf.other_ratio3_current === null ? "0.0" : item.locf.other_ratio3_current === "" ? "0.0" : item.locf.other_ratio3_current,
// item.locf.other_ratio4_ratio_name,
// item.locf.other_ratio4_financial,
// item.locf.other_ratio4_current === null ? "0.0" : item.locf.other_ratio4_current === "" ? "0.0" : item.locf.other_ratio4_current,
// item.locf.notes,
// item.diff,
// item.total_loan,
// item.per_bs
// // index
// ])
// if (item.children !== null) {
// if (item.children.length > 0) {
// item.children.map((items, indexs) => {
// handlePushChild(items)
// })
// }
// }
// })
// let lastArrayLOCF = dataTablelov[res.length - 1]
// this.setState({ dataTablelov, diff: lastArrayLOV[46], perBS: lastArrayLOV[48], loading: false, visibleLOVFMR: true }, () => {
// // this.handleCalculateLOV()
// })
// console.log(this.state.diff);
// }
// })
} }
// handleCalculateLOV = () => {
// let dataTable2 = this.state.dataTableLOV
// console.log(dataTable2);
// }
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
let loading = this.state.loading let loading = this.state.loading
...@@ -3358,6 +3486,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -3358,6 +3486,7 @@ export default class ListOfCreditFacilities extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
sendToParent={this.dataTableForChild.bind(this)} sendToParent={this.dataTableForChild.bind(this)}
dataTablelov={this.state.dataTablelov}
/> />
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1"> <div className="col-1">
...@@ -3521,7 +3650,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -3521,7 +3650,7 @@ export default class ListOfCreditFacilities extends Component {
width={this.props.width} width={this.props.width}
sendToParent={this.dataTableForChild.bind(this)} sendToParent={this.dataTableForChild.bind(this)}
sendDataTable={this.olahDataTable.bind(this)} sendDataTable={this.olahDataTable.bind(this)}
// dataTablelov={this.state.dataTablelov} dataTablelov={this.state.dataTablelov}
/> />
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1"> <div className="col-1">
......
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