Commit e3327301 authored by Riri Novita's avatar Riri Novita

fix(handleCalculate) : undefined value

parent 4eede6e4
...@@ -356,7 +356,7 @@ export default class LOV extends Component { ...@@ -356,7 +356,7 @@ export default class LOV extends Component {
isi.map((i, index) => { isi.map((i, index) => {
if (i.length > 0) { if (i.length > 0) {
let tgl = String(i[6]).split('-') let tgl = String(i[6]).split('-')
console.log(tgl); // console.log(tgl);
payload.push({ payload.push({
"item_report_id": i[1], "item_report_id": i[1],
"company_name": this.props.company.company_name, "company_name": this.props.company.company_name,
......
...@@ -721,11 +721,77 @@ export default class ListOfCreditFacilities extends Component { ...@@ -721,11 +721,77 @@ export default class ListOfCreditFacilities extends Component {
console.log(response); console.log(response);
let dataTablelocf = [] let dataTablelocf = []
if (response.data) { if (response.data) {
let res = response.data.data if (response.data.status == 'success') {
const handlePushChild = (item) => {
let indexIDzz = dataTablelocf.findIndex((val) => val[1] === item.id) let res = response.data.data
let tgl = String(item.locf.loan_maturity_date).split('-') const handlePushChild = (item) => {
if (indexIDzz === -1) { let indexIDzz = dataTablelocf.findIndex((val) => val[1] === item.id)
let tgl = String(item.locf.loan_maturity_date).split('-')
if (indexIDzz === -1) {
dataTablelocf.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.remarks2 === null ? null : item.locf.remarks2 === "" ? null : { value: item.locf.remarks2 },
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('-')
dataTablelocf.push([ dataTablelocf.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -779,100 +845,37 @@ export default class ListOfCreditFacilities extends Component { ...@@ -779,100 +845,37 @@ export default class ListOfCreditFacilities extends Component {
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) => {
let tgl = String(item.locf.loan_maturity_date).split('-')
dataTablelocf.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.remarks2 === null ? null : item.locf.remarks2 === "" ? null : { value: item.locf.remarks2 },
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 = dataTablelocf[res.length - 1] let lastArrayLOCF = dataTablelocf[res.length - 1]
let roundDataDiff = fixNumber(Number(lastArrayLOCF[47]), 1) let roundDataDiff = fixNumber(Number(lastArrayLOCF[47]), 1)
let roundDataLoan = fixNumber(Number(lastArrayLOCF[48]), 1) let roundDataLoan = fixNumber(Number(lastArrayLOCF[48]), 1)
let roundDataPerBS = fixNumber(Number(lastArrayLOCF[49]), 1) let roundDataPerBS = fixNumber(Number(lastArrayLOCF[49]), 1)
console.log(dataTablelocf); console.log(dataTablelocf);
if (bankNameEmpty) { if (bankNameEmpty) {
if (this.state.get_for == 'view') { if (this.state.get_for == 'view') {
this.setState({ saveDraft: false, saveComp: true }) this.setState({ saveDraft: false, saveComp: true })
} else { } else {
this.setState({ saveDraft: false, saveComp: true }) this.setState({ saveDraft: false, saveComp: true })
} }
} else {
if (this.state.get_for == 'view') {
console.log("view");
} else { } else {
this.setState({ saveDraft: false, saveComp: roundDataDiff == 0 || roundDataDiff == '0.0' || roundDataDiff == "-0.0" ? false : true }) if (this.state.get_for == 'view') {
console.log("view");
} else {
this.setState({ saveDraft: false, saveComp: roundDataDiff == 0 || roundDataDiff == '0.0' || roundDataDiff == "-0.0" ? false : true })
}
} }
this.setState({ dataTablelocf, diffLOCF: roundDataDiff, totalLoanLOCF: roundDataLoan, perBSLOCF: roundDataPerBS, loading: false }, () => {
this.handleCalculateLOV()
})
} }
this.setState({ dataTablelocf, diffLOCF: roundDataDiff, totalLoanLOCF: roundDataLoan, perBSLOCF: roundDataPerBS, loading: false }, () => {
this.handleCalculateLOV()
})
} }
}) })
...@@ -946,7 +949,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -946,7 +949,7 @@ export default class ListOfCreditFacilities extends Component {
error = true error = true
} }
if ((i[7].value == 'Government bonds' && i[8] == '') || (i[7].value == 'Stocks' && i[8] == '') || (i[7].value == 'Mutual funds' && i[8] == '') || (i[7].value == 'Investment in associate' && i[8] == '') || (i[7].value == 'Investment in joint venture' && i[8] == '') || (i[7].value == 'Investment in subsidiary' && i[8] == '') || (i[7].value == 'Corporate bonds' && i[8] == '') || (i[7].value == 'Others' && i[8] == '')) { if ((i[7]?.value == 'Government bonds' && i[8] == '') || (i[7]?.value == 'Stocks' && i[8] == '') || (i[7]?.value == 'Mutual funds' && i[8] == '') || (i[7]?.value == 'Investment in associate' && i[8] == '') || (i[7]?.value == 'Investment in joint venture' && i[8] == '') || (i[7]?.value == 'Investment in subsidiary' && i[8] == '') || (i[7]?.value == 'Corporate bonds' && i[8] == '') || (i[7]?.value == 'Others' && i[8] == '')) {
error = true error = true
} else { } else {
error = false error = false
...@@ -962,7 +965,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -962,7 +965,7 @@ export default class ListOfCreditFacilities extends Component {
"item_report_id": i[1], "item_report_id": i[1],
"company_name": i[5], "company_name": i[5],
"institution_name": i[6], "institution_name": i[6],
"type_of_investment": i[7] == null ? i[7] : i[7].value, "type_of_investment": i[7] == null ? i[7] : i[7]?.value,
"remarks": i[8], "remarks": i[8],
"placement_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])), "placement_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
"tenor": i[10], "tenor": i[10],
...@@ -978,7 +981,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -978,7 +981,7 @@ export default class ListOfCreditFacilities extends Component {
"item_report_id": i[1], "item_report_id": i[1],
"company_name": i[5], "company_name": i[5],
"institution_name": i[6], "institution_name": i[6],
"type_of_investment": i[7] == null ? i[7] : i[7].value, "type_of_investment": i[7] == null ? i[7] : i[7]?.value,
"remarks": i[8], "remarks": i[8],
"placement_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])), "placement_date": i[9] == undefined || i[9] == "null" || i[9] == null ? "" : (String(tgl[2]).length <= 2 ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : String(i[9])),
"tenor": i[10], "tenor": i[10],
......
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