Commit f6d03117 authored by Riri Novita's avatar Riri Novita

Merge branch 'ENV-PROD' into 'ENV-DEPLOYMENT-PROD'

fix(handleCalculate) : undefined value

See merge request !2336
parents 6c89b23a e3327301
......@@ -356,7 +356,7 @@ export default class LOV extends Component {
isi.map((i, index) => {
if (i.length > 0) {
let tgl = String(i[6]).split('-')
console.log(tgl);
// console.log(tgl);
payload.push({
"item_report_id": i[1],
"company_name": this.props.company.company_name,
......
......@@ -721,11 +721,77 @@ export default class ListOfCreditFacilities extends Component {
console.log(response);
let dataTablelocf = []
if (response.data) {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTablelocf.findIndex((val) => val[1] === item.id)
let tgl = String(item.locf.loan_maturity_date).split('-')
if (indexIDzz === -1) {
if (response.data.status == 'success') {
let res = response.data.data
const handlePushChild = (item) => {
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([
item.type_report_id,
item.id,
......@@ -779,100 +845,37 @@ export default class ListOfCreditFacilities extends Component {
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([
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)
})
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
})
})
let lastArrayLOCF = dataTablelocf[res.length - 1]
let roundDataDiff = fixNumber(Number(lastArrayLOCF[47]), 1)
let roundDataLoan = fixNumber(Number(lastArrayLOCF[48]), 1)
let roundDataPerBS = fixNumber(Number(lastArrayLOCF[49]), 1)
console.log(dataTablelocf);
if (bankNameEmpty) {
if (this.state.get_for == 'view') {
this.setState({ saveDraft: false, saveComp: true })
} else {
this.setState({ saveDraft: false, saveComp: true })
}
} else {
if (this.state.get_for == 'view') {
console.log("view");
let lastArrayLOCF = dataTablelocf[res.length - 1]
let roundDataDiff = fixNumber(Number(lastArrayLOCF[47]), 1)
let roundDataLoan = fixNumber(Number(lastArrayLOCF[48]), 1)
let roundDataPerBS = fixNumber(Number(lastArrayLOCF[49]), 1)
console.log(dataTablelocf);
if (bankNameEmpty) {
if (this.state.get_for == 'view') {
this.setState({ saveDraft: false, saveComp: true })
} else {
this.setState({ saveDraft: false, saveComp: true })
}
} 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 {
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
} else {
error = false
......@@ -962,7 +965,7 @@ export default class ListOfCreditFacilities extends Component {
"item_report_id": i[1],
"company_name": i[5],
"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],
"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],
......@@ -978,7 +981,7 @@ export default class ListOfCreditFacilities extends Component {
"item_report_id": i[1],
"company_name": i[5],
"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],
"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],
......
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