Commit e53955fd authored by Riri Novita's avatar Riri Novita

Merge branch 'ENV-DEV' into 'ENV-DEPLOYMENT'

lov

See merge request !2177
parents a44f1e79 7ad982bb
...@@ -551,6 +551,9 @@ const create = (type = "") => { ...@@ -551,6 +551,9 @@ const create = (type = "") => {
// Investment // Investment
const getTypeOfInvestment = () => api.get('setting_type/get_all_setting_type_by_investment') const getTypeOfInvestment = () => api.get('setting_type/get_all_setting_type_by_investment')
const validateSaveLOV = (body) => api.post('transaction/lov/monthly_report/validate_save', body)
const validateSaveLOCF = (body) => api.post('transaction/locf/monthly_report/validate_save', body)
// Superadmin Approve // Superadmin Approve
const getListApprover = (report, monthlyReportId) => api.get(`transaction/${report}/get_approver/${monthlyReportId}`) const getListApprover = (report, monthlyReportId) => api.get(`transaction/${report}/get_approver/${monthlyReportId}`)
...@@ -953,7 +956,9 @@ const create = (type = "") => { ...@@ -953,7 +956,9 @@ const create = (type = "") => {
uploadSimulasiOperatingInd, uploadSimulasiOperatingInd,
uploadSimulasiMROI, uploadSimulasiMROI,
uploadSimulasiROOI, uploadSimulasiROOI,
getTypeOfInvestment getTypeOfInvestment,
validateSaveLOCF,
validateSaveLOV
} }
} }
......
...@@ -106,7 +106,6 @@ export default class LOCF extends Component { ...@@ -106,7 +106,6 @@ export default class LOCF extends Component {
loading: false, loading: false,
dataTableRatio: [], dataTableRatio: [],
currentDate: format(new Date(), 'yyyy-MM-dd'), currentDate: format(new Date(), 'yyyy-MM-dd'),
totalOutStand: 0,
diff: 0, diff: 0,
perBS: 0, perBS: 0,
snekbar: false, snekbar: false,
...@@ -128,7 +127,7 @@ export default class LOCF extends Component { ...@@ -128,7 +127,7 @@ export default class LOCF extends Component {
componentDidMount() { componentDidMount() {
console.log("LOCF"); console.log("LOCF");
this.getPerBS() // this.getPerBS()
this.getBankData() this.getBankData()
this.getTypeOfCredit() this.getTypeOfCredit()
this.getSubmission() this.getSubmission()
...@@ -137,13 +136,18 @@ export default class LOCF extends Component { ...@@ -137,13 +136,18 @@ export default class LOCF 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.getBankData() this.getBankData()
this.getTypeOfCredit() this.getTypeOfCredit()
this.getSubmission() this.getSubmission()
this.getLatestUpdate() this.getLatestUpdate()
this.handleViewOnly() this.handleViewOnly()
} }
if (this.props.dataTablelocf !== prevProps.dataTablelocf) {
let array = this.props.dataTablelocf
let datas = array[array.length -1]
this.setState({ dataTable: this.props.dataTablelocf, diff: datas[46], perBS: datas[48]})
}
} }
handleGetFor(type) { handleGetFor(type) {
...@@ -201,16 +205,16 @@ export default class LOCF extends Component { ...@@ -201,16 +205,16 @@ export default class LOCF extends Component {
"currency_id": this.props.defaultCurrency.id, "currency_id": this.props.defaultCurrency.id,
"get_for": this.props.get_for "get_for": this.props.get_for
} }
console.log(payload);
api.create().getHierarkiMontlyReportLOCF(payload).then(response => { api.create().getHierarkiMontlyReportLOCF(payload).then(response => {
console.log(payload);
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
console.log(res); const handlePushChild = (item) => {
res.map((item, index) => { 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 (index == res.length - 1) { if (indexIDzz === -1) {
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -218,7 +222,7 @@ export default class LOCF extends Component { ...@@ -218,7 +222,7 @@ export default class LOCF extends Component {
item.formula, item.formula,
item.level, item.level,
// item.description, // item.description,
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,
...@@ -260,86 +264,86 @@ export default class LOCF extends Component { ...@@ -260,86 +264,86 @@ export default class LOCF extends Component {
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.per_bs === null ? "0.0" : item.locf.per_bs === "" ? "0.0" : item.locf.per_bs, item.diff,
// item.diff === null ? "0.0" : item.locf.diff === "" ? "0.0" : item.locf.diff, item.total_loan,
index item.per_bs
], // index
[9, "", "", "", "", "", { value: "Grand Total" }, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999],
)
} else {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
// item.description,
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.mtd_vs_previous_month === null ? "0.0" : item.locf.mtd_vs_previous_month === "" ? "0.0" : item.locf.mtd_vs_previous_month,
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,
index
// item.per_bs === null ? "0.0" : item.locf.per_bs === "" ? "0.0" : item.locf.per_bs,
// item.diff === null ? "0.0" : item.locf.diff === "" ? "0.0" : item.locf.diff,
]) ])
} }
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(dataTable);
if (dataTable.length == 0 && this.props.get_for == 'edit') {
dataTable.push(
[3, "", "", "", "", this.props.company.company_name, null, null, "", null, "0.00", "", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "", 0],
[9, "", "", "", "", "", { value: "Grand Total" }, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999],
)
} }
res.map((item, index) => {
let tgl = String(item.locf.loan_maturity_date).split('-')
dataTable.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)
})
}
}
})
console.log(dataTable) console.log(dataTable)
this.setState({ dataTable, loading: false, visibleLOCFMR: true }, () => { let lastArray = dataTable[res.length - 1]
this.handleCalculate() this.setState({ dataTable, diff: lastArray[46], perBS: lastArray[48], loading: false, visibleLOCFMR: true }, () => {
this.props.sendToParent(dataTable, lastArray, 'LOCF')
}) })
} }
}) })
...@@ -489,7 +493,7 @@ export default class LOCF extends Component { ...@@ -489,7 +493,7 @@ export default class LOCF extends Component {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleLOCFMR: false, totalOutStand: 0, diff: 0 }) this.setState({ visibleUpload: false, loading: true, visibleLOCFMR: false })
let dataTable = [] let dataTable = []
response.data.data.map((item, index) => { response.data.data.map((item, index) => {
if (index == response.data.data.length - 1) { if (index == response.data.data.length - 1) {
...@@ -945,36 +949,36 @@ export default class LOCF extends Component { ...@@ -945,36 +949,36 @@ export default class LOCF 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().getPerBSiMontlyReportLOCF(payload).then((response) => { // api.create().getPerBSiMontlyReportLOCF(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, // perBS: 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 })
} // }
// } // // }
}) // })
} // }
getDataRatio() { getDataRatio() {
let payload = { let payload = {
...@@ -1068,7 +1072,7 @@ export default class LOCF extends Component { ...@@ -1068,7 +1072,7 @@ export default class LOCF extends Component {
} }
} }
}) })
console.log(dataTable) // console.log(dataTable)
this.setState({ dataTableRatio: dataTable }, () => { this.setState({ dataTableRatio: dataTable }, () => {
this.getItemHierarki() this.getItemHierarki()
}) })
...@@ -1261,237 +1265,267 @@ export default class LOCF extends Component { ...@@ -1261,237 +1265,267 @@ export default class LOCF extends Component {
handleCalculate = () => { handleCalculate = () => {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
this.setState({ loading: true }, () => { let data = []
let bankPrev = "" let error = false
let idPrev = 0 dataTable2.map(i => {
let newData = [] if (i[0] == 3) {
let dataCoba = [] if (i[6] == null || i[7] == null || i[8] == "" || i[9] == "" || i[10] == "" || i[11] == "") {
let bankNameEmpty = false error = true
let totalLoan = 0
console.log(dataTable2);
dataTable2.map((item, index) => {
if (item[0] !== 8) {
if (item[6] == null) {
bankNameEmpty = true
} else {
let groupName = String(item[6].value).split("-")
let indexAS = dataCoba.findIndex((val) => item[6].value.includes(val.groupName))
if (indexAS == -1) {
dataCoba.push({
groupName: groupName[groupName.length - 1],
data: [item]
})
} else {
let indexDD = dataCoba[indexAS].data.length - 1 == -1 ? 0 : dataCoba[indexAS].data.length - 1
if (String(dataCoba[indexAS].data[indexDD]).includes('Total')) {
let dataAwal = []
let dataAkhir = []
dataAwal = dataCoba[indexAS].data.splice(0, dataCoba[indexAS].data.length - 2)
dataAkhir = dataCoba[indexAS].data.splice(dataCoba[indexAS].data.length - 1, 1)
dataAwal.push(item)
dataCoba[indexAS].data = dataAwal.concat(dataAkhir)
} else {
dataCoba[indexAS].data.push(item)
}
}
}
} }
})
console.log(dataCoba); if (i[7].value == 'Others' && i[18] == '') {
let dataGabung = [] error = true
if (!bankNameEmpty) { }
dataCoba.map((item, index) => { let tgl = String(i[9]).split('-')
item.data.map((items, index) => { let checkUndifined = tgl.findIndex((val) => val == undefined)
dataGabung.push(items) 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 {
console.log(dataGabung); data.push({
dataGabung.map((items, index) => { "item_report_id": i[1],
if (items[0] == 3) { "borrower_comp_name": i[5],
console.log(Number(totalLoan)); "bank_name": i[6] == null ? [6] : i[6].value,
this.props.defaultCurrency.id == 1 ? totalLoan += items[22] : totalLoan += items[21] "type_of_credit": i[7] == null ? i[7] : i[7].value,
} "remarks": i[8],
if (bankPrev != "") { "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])),
if (items[6].value !== bankPrev) { "interest": i[10] == "" ? "0.00" : i[10],
bankPrev = items[6].value "currency": i[11],
if (items[6].value == 'Grand Total') { "loan_plafond_amount_ori": fixNumber(Number(i[12]), 1) == "" ? "0.0" : fixNumber(Number(i[12]), 1),
// if (dataTable2.length > 2) { "loan_plafond_amount_idr": fixNumber(Number(i[13]), 1) == "" ? "0.0" : fixNumber(Number(i[13]), 1),
// newData.push(items) "out_loan_ki_amount_ori": fixNumber(Number(i[14]), 1) == "" ? "0.0" : fixNumber(Number(i[14]), 1),
// } else { "out_loan_ki_amount_idr": fixNumber(Number(i[15]), 1) == "" ? "0.0" : fixNumber(Number(i[15]), 1),
if (String(dataGabung[index - 1][6].value).includes('Total ')) { "out_loan_kmk_amount_ori": fixNumber(Number(i[16]), 1) == "" ? "0.0" : fixNumber(Number(i[16]), 1),
newData.push(items) "out_loan_kmk_amount_idr": fixNumber(Number(i[17]), 1) == "" ? "0.0" : fixNumber(Number(i[17]), 1),
} else { "out_loan_other_type": i[18],
// if (String(dataGabung[index][6].value).includes('Total ')) { "out_loan_other_amount_ori": fixNumber(Number(i[19]), 1) == "" ? "0.0" : fixNumber(Number(i[19]), 1),
// newData.push(items) "out_loan_other_amount_idr": fixNumber(Number(i[20]), 1) == "" ? "0.0" : fixNumber(Number(i[20]), 1),
// } else { "total_out_loan_ori": fixNumber(Number(i[21]), 1) == "" ? "0.0" : fixNumber(Number(i[21]), 1),
// items[46] = index + 1 "total_out_loan_idr": fixNumber(Number(i[22]), 1) == "" ? "0.0" : fixNumber(Number(i[22]), 1),
let nameTotal = String(dataGabung[index - 1][6].value).split("-") "remaining_plafond_ori": fixNumber(Number(i[23]), 1) == "" ? "0.0" : fixNumber(Number(i[23]), 1),
newData.push([ "remaining_plafond_idr": fixNumber(Number(i[24]), 1) == "" ? "0.0" : fixNumber(Number(i[24]), 1),
8, "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),
{ value: 'Total ' + nameTotal[nameTotal.length - 1] }, "ebitda_to_interest_financial": fixNumber(Number(i[31]), 2) == "" ? "0.00" : fixNumber(Number(i[31]), 2),
null, "ebitda_to_interest_current": fixNumber(Number(i[32]), 2) == "" ? "0.00" : fixNumber(Number(i[32]), 2),
"", "other_ratio1_ratio_name": i[33],
null, "other_ratio1_financial": fixNumber(Number(i[34]), 2) == "" ? "0.00" : fixNumber(Number(i[34]), 2),
"0.00", "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),
"0", "other_ratio2_current": fixNumber(Number(i[38]), 2) == "" ? "0.00" : fixNumber(Number(i[38]), 2),
"", "other_ratio3_ratio_name": i[39],
"0", "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),
"0", "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),
"0", "notes": i[45],
"0", })
"0", }
"0",
"0",
"",
"0",
"",
"0",
"",
"0",
"",
"0",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
index],
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,
)
}
} }
} })
} let body = {
else { "monthly_report_id": this.props.monthlyReportId,
newData.push(items) "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 dataTable = []
if (response.data) {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
let tgl = String(item.locf.loan_maturity_date).split('-')
if (indexIDzz === -1) {
dataTable.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)
})
} }
} else {
bankPrev = items[6].value
idPrev = items[0]
newData.push(items)
} }
})
} else {
if (this.props.get_for == 'edit') {
this.setState({ snekbar: true, snekbarMsg: 'Bank Names Cannot be Empty' })
} }
} res.map((item, index) => {
let tgl = String(item.locf.loan_maturity_date).split('-')
setTimeout(() => { dataTable.push([
// console.log(dataCoba) item.type_report_id,
// console.log(dataGabung) item.id,
console.log(newData) item.parent,
// console.log(dataTampungBank) item.formula,
console.log(totalLoan); item.level,
console.log(this.state.perBS) 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,
console.log(this.state.diff) item.locf.bank_name === null ? null : item.locf.bank_name === "" ? null : { value: item.locf.bank_name },
console.log(bankNameEmpty) item.locf.type_of_credit === null ? null : item.locf.type_of_credit === "" ? null : { value: item.locf.type_of_credit },
// dataTable: newData, totalOutStand: newData[newData.length-1][22] item.locf.remarks === null || item.locf.remarks === "" ? "" : item.locf.remarks,
if (bankNameEmpty) { 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),
if (this.props.get_for == 'view') { item.locf.interest === null || item.locf.interest === "" ? "0.00" : item.locf.interest,
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 }) item.locf.currency === null || item.locf.currency === "" ? "" : item.locf.currency,
} else { item.locf.loan_plafond_amount_ori,
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 }) 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,
} else { 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,
if (this.props.get_for == 'view') { item.locf.out_loan_kmk_amount_ori,
if (this.props.defaultCurrency.id == 1) { 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,
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 }) item.locf.out_loan_other_type,
} else { item.locf.out_loan_other_amount_ori,
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 }) 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)
})
} }
}
})
console.log(this.props.dataTablelocf)
let lastArray = dataTable[res.length - 1]
} else { this.setState({ dataTable, diff: lastArray[46], perBS: lastArray[48], loading: false, visibleLOCFMR: true }, () => {
if (this.props.defaultCurrency.id == 1) { // this.props.sendToParent(dataTable, lastArray, 'LOCF')
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 { }
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);
}) })
} }
...@@ -1542,25 +1576,33 @@ export default class LOCF extends Component { ...@@ -1542,25 +1576,33 @@ export default class LOCF extends Component {
} }
console.log(value);
console.log(value.value);
if (value.value !== undefined) { if (value.value !== undefined) {
this.setState({ loading: true})
if (value.value == 'Investment Loan') { if (value.value == 'Investment Loan') {
this.setState({ loading: false})
dataTable2[tableMeta.rowIndex][16] = 0 dataTable2[tableMeta.rowIndex][16] = 0
dataTable2[tableMeta.rowIndex][17] = 0 dataTable2[tableMeta.rowIndex][17] = 0
dataTable2[tableMeta.rowIndex][18] = "" dataTable2[tableMeta.rowIndex][18] = ""
dataTable2[tableMeta.rowIndex][19] = 0 dataTable2[tableMeta.rowIndex][19] = 0
dataTable2[tableMeta.rowIndex][20] = 0 dataTable2[tableMeta.rowIndex][20] = 0
} else if (value.value == 'Revolving Loan (KMK)') { } else if (value.value == 'Revolving Loan (KMK)') {
this.setState({ loading: false})
dataTable2[tableMeta.rowIndex][14] = 0 dataTable2[tableMeta.rowIndex][14] = 0
dataTable2[tableMeta.rowIndex][15] = 0 dataTable2[tableMeta.rowIndex][15] = 0
dataTable2[tableMeta.rowIndex][18] = "" dataTable2[tableMeta.rowIndex][18] = ""
dataTable2[tableMeta.rowIndex][19] = 0 dataTable2[tableMeta.rowIndex][19] = 0
dataTable2[tableMeta.rowIndex][20] = 0 dataTable2[tableMeta.rowIndex][20] = 0
} else if (value.value == 'others') { } else if (value.value == 'others') {
this.setState({ loading: false})
dataTable2[tableMeta.rowIndex][14] = 0 dataTable2[tableMeta.rowIndex][14] = 0
dataTable2[tableMeta.rowIndex][15] = 0 dataTable2[tableMeta.rowIndex][15] = 0
dataTable2[tableMeta.rowIndex][16] = 0 dataTable2[tableMeta.rowIndex][16] = 0
dataTable2[tableMeta.rowIndex][17] = 0 dataTable2[tableMeta.rowIndex][17] = 0
} }
this.setState({ loading: false})
dataTable2[tableMeta.rowIndex][column] = value dataTable2[tableMeta.rowIndex][column] = value
} else { } else {
dataTable2[tableMeta.rowIndex][column] = val dataTable2[tableMeta.rowIndex][column] = val
...@@ -1645,6 +1687,7 @@ export default class LOCF extends Component { ...@@ -1645,6 +1687,7 @@ export default class LOCF extends Component {
const handleTambah = (data, rowIndex) => { const handleTambah = (data, rowIndex) => {
let newData = [] let newData = []
let indexxx = 0 let indexxx = 0
console.log(dataTable2);
dataTable2.map((item, index) => { dataTable2.map((item, index) => {
indexxx = index indexxx = index
if (item[6] == "Grand Total") { if (item[6] == "Grand Total") {
...@@ -1708,10 +1751,11 @@ export default class LOCF extends Component { ...@@ -1708,10 +1751,11 @@ export default class LOCF extends Component {
} }
}) })
dataTable2 = newData.sort((a, b) => a[46] - b[46]) dataTable2 = newData.sort((a, b) => a[46] - b[46])
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, 'LOCF', 'tambah')
}, 500) }, 500)
}) })
} }
...@@ -4080,7 +4124,7 @@ export default class LOCF extends Component { ...@@ -4080,7 +4124,7 @@ export default class LOCF extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography>
</div> </div>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}> <div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.totalOutStand)}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.perBS)}</Typography>
</div> </div>
</div> </div>
</div> </div>
...@@ -4232,7 +4276,7 @@ export default class LOCF extends Component { ...@@ -4232,7 +4276,7 @@ export default class LOCF extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Total Outstanding Loan</Typography>
</div> </div>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}> <div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.totalOutStand)}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{formatSeparator(this.state.perBS)}</Typography>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -111,7 +111,7 @@ export default class LOV extends Component { ...@@ -111,7 +111,7 @@ export default class LOV extends Component {
perBS: 0, perBS: 0,
snekbar: false, snekbar: false,
snekbarMsg: '', snekbarMsg: '',
visibleLOCFMR: true, visibleLOVMR: true,
saveDraft: true, saveDraft: true,
saveComp: true, saveComp: true,
get_for: 'view', get_for: 'view',
...@@ -144,6 +144,12 @@ export default class LOV extends Component { ...@@ -144,6 +144,12 @@ export default class LOV extends Component {
this.getLatestUpdate() this.getLatestUpdate()
this.handleViewOnly() this.handleViewOnly()
} }
if (this.props.dataTablelov !== prevProps.dataTablelov) {
let array = this.props.dataTablelocf
let datas = array[array.length - 1]
console.log(datas);
this.setState({ dataTable: this.props.dataTablelov })
}
} }
handleGetFor(type) { handleGetFor(type) {
...@@ -207,39 +213,18 @@ export default class LOV extends Component { ...@@ -207,39 +213,18 @@ export default class LOV extends Component {
let dataTable = [] let dataTable = []
if (response.data) { if (response.data) {
let res = response.data.data let res = response.data.data
res.map((item, index) => { const handlePushChild = (item) => {
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('-')
let currency = item.lov.currency if (indexIDzz === -1) {
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([ 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,
item.lov.company_name === null || item.lov.company_name === "" ? this.props.company.company_name : item.lov.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.lov.institution_name === null || item.lov.institution_name === "" ? "" : item.lov.institution_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.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.remarks === null || item.lov.remarks === "" ? "" : item.lov.remarks,
...@@ -250,21 +235,113 @@ export default class LOV extends Component { ...@@ -250,21 +235,113 @@ 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,
index // index
]) ])
} }
}) if (item.children !== null) {
if (dataTable.length == 0 && this.props.get_for == 'edit') { if (item.children.length > 0) {
dataTable.push( item.children.map((items, indexs) => {
[3, "", "", "", "", this.props.company.company_name, "", null, "", null, "0.0", "0.0", "", "", "", "", 0], handlePushChild(items)
[9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999], })
) }
}
} }
res.map((item, index) => {
let tgl = String(item.lov.placement_date).split('-')
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
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,
// index
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
console.log(dataTable) console.log(dataTable)
this.setState({ dataTable, loading: false, visibleLOCFMR: true }, () => { let lastArray = dataTable[res.length - 1]
this.props.sendToParent(dataTable, 'LOV') console.log(lastArray);
this.setState({ dataTable, loading: false, visibleLOVMR: true }, () => {
this.props.sendToParent(dataTable, lastArray, 'LOCF')
}) })
} }
// 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')
// })
// }
}) })
} }
...@@ -378,7 +455,7 @@ export default class LOV extends Component { ...@@ -378,7 +455,7 @@ export default class LOV extends Component {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleLOCFMR: false, totalOutStand: 0, diff: 0 }) this.setState({ visibleUpload: false, loading: true, visibleLOVMR: false, totalOutStand: 0, diff: 0 })
let dataTable = [] let dataTable = []
let datas = response.data.data let datas = response.data.data
console.log(datas.lov); console.log(datas.lov);
...@@ -1431,7 +1508,7 @@ export default class LOV extends Component { ...@@ -1431,7 +1508,7 @@ export default class LOV extends Component {
}) })
} }
let columnsLOV = [ let columns = [
{ {
name: "", name: "",
options: { options: {
...@@ -1538,13 +1615,16 @@ export default class LOV extends Component { ...@@ -1538,13 +1615,16 @@ export default class LOV extends Component {
customBodyRender: (val, tableMeta, updateValue) => { customBodyRender: (val, tableMeta, updateValue) => {
return ( return (
<div style={{ display: 'flex', justifyContent: 'center' }}> <div style={{ display: 'flex', justifyContent: 'center' }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] == 8 || tableMeta.rowData[0] == 9 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] == 8 ?
<Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{val.value}</Typography> <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{val.value}</Typography>
: :
<div style={{ padding: 0, margin: 0 }}> tableMeta.rowData[0] == 9 ?
<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[6] == '' && this.props.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" defaultValue={tableMeta.rowData[0] == 9 ? tableMeta.rowData[6].value : tableMeta.rowData[6]} <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{val}</Typography>
onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} /> :
</div> <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[6] == '' && this.props.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" defaultValue={tableMeta.rowData[6]}
onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} />
</div>
} }
</div> </div>
) )
...@@ -1595,6 +1675,7 @@ export default class LOV extends Component { ...@@ -1595,6 +1675,7 @@ 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 ?
...@@ -1842,33 +1923,51 @@ export default class LOV extends Component { ...@@ -1842,33 +1923,51 @@ export default class LOV extends Component {
), ),
setCellProps: () => ({ style2 }), setCellProps: () => ({ style2 }),
customBodyRender: (val, tableMeta, updateValue) => { customBodyRender: (val, tableMeta, updateValue) => {
// console.log(tableMeta);
return ( return (
<div className="col-1"> <div className="col-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ? {tableMeta.rowData[0] === 4 ?
null : null :
<div style={{ flex: 1 }}> tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
<FormControlLabel <div style={{ flex: 1 }}>
style={{ margin: 0 }} <FormControlLabel
value={val} style={{ margin: 0 }}
control={ value={val}
<NumberFormat control={
thousandSeparator={true} <NumberFormat
style={{ color: this.props.get_for == 'view' ? "black" : "#5198ea", fontSize: 12, paddingBottom: 18, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} thousandSeparator={true}
type="text" style={{ color: "black", fontSize: 12, paddingBottom: 18, textAlign: 'right', fontWeight: 'bold', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
placeholder="" type="text"
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16} placeholder=""
disabled={this.props.get_for == 'view'} disabled={true}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[13]), 1) : Number(tableMeta.rowData[13]) == 0 ? "0.0" : Number(tableMeta.rowData[13])} decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
onBlur={(event) => { value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[13]), 1) : Number(tableMeta.rowData[13]) == 0 ? "0.0" : Number(tableMeta.rowData[13])}
handleChange(event.target.value, tableMeta, 13) />
}} }
/>
/> </div>
} :
/> <div style={{ flex: 1 }}>
</div> <FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: this.props.get_for == 'view' ? "black" : "#5198ea", fontSize: 12, paddingBottom: 18, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
disabled={this.props.get_for == 'view'}
value={this.props.defaultCurrency.id == 1 ? (fixNumber(Number(tableMeta.rowData[13]), 1) == 0.0 ? "0.0" : fixNumber(Number(tableMeta.rowData[13]), 1)) : (Number(tableMeta.rowData[13]) == 0.0 ? "0.0" : Number(tableMeta.rowData[13]))}
onBlur={(event) => {
handleChange(event.target.value, tableMeta, 14)
}}
/>
}
/>
</div>
} }
</div> </div>
</div> </div>
...@@ -1885,7 +1984,6 @@ export default class LOV extends Component { ...@@ -1885,7 +1984,6 @@ export default class LOV extends Component {
), ),
setCellProps: () => ({ style2 }), setCellProps: () => ({ style2 }),
customBodyRender: (val, tableMeta, updateValue) => { customBodyRender: (val, tableMeta, updateValue) => {
// console.log(tableMeta);
return ( return (
<div className="col-1"> <div className="col-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
...@@ -1905,7 +2003,7 @@ export default class LOV extends Component { ...@@ -1905,7 +2003,7 @@ export default class LOV extends Component {
disabled={true} disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16} decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14)), 1) : Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14)) == 0 ? "0.0" : Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14))} // value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14)), 1) : Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14)) == 0 ? "0.0" : Number(handleFormulaHardcode(tableMeta.rowData[14], tableMeta, 14))}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[13]), 1) : Number(tableMeta.rowData[13]) == 0 ? "0.0" : Number(tableMeta.rowData[13])} value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[14]), 1) : Number(tableMeta.rowData[14]) == 0 ? "0.0" : Number(tableMeta.rowData[14])}
/> />
} }
/> />
...@@ -2012,7 +2110,7 @@ export default class LOV extends Component { ...@@ -2012,7 +2110,7 @@ export default class LOV extends Component {
return ( return (
<div> <div>
{this.state.visibleLOCFMR ? {this.state.visibleLOVMR ?
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
<Snackbar open={this.state.snekbar} autoHideDuration={6000} onClose={handleClose}> <Snackbar open={this.state.snekbar} autoHideDuration={6000} onClose={handleClose}>
<Alert onClose={handleClose} severity="error"> <Alert onClose={handleClose} severity="error">
...@@ -2100,7 +2198,7 @@ export default class LOV extends Component { ...@@ -2100,7 +2198,7 @@ export default class LOV extends Component {
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}> {!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
columns={columnsLOV} columns={columns}
options={options} options={options}
/> />
</MuiThemeProvider>} </MuiThemeProvider>}
...@@ -2204,7 +2302,7 @@ export default class LOV extends Component { ...@@ -2204,7 +2302,7 @@ export default class LOV extends Component {
{this.state.dataLoaded && !this.state.loading && <MuiThemeProvider theme={getMuiTheme()}> {this.state.dataLoaded && !this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
columns={columnsLOV} columns={columns}
options={options} options={options}
/> />
</MuiThemeProvider>} </MuiThemeProvider>}
......
...@@ -103,6 +103,9 @@ export default class ListOfCreditFacilities extends Component { ...@@ -103,6 +103,9 @@ export default class ListOfCreditFacilities extends Component {
super(props) super(props)
this.state = { this.state = {
dataTable: [], dataTable: [],
dataTableLOV: [],
dataTableLOCF: [],
lastArray: null,
bankNameList: [], bankNameList: [],
typeOfCreditList: [], typeOfCreditList: [],
loading: false, loading: false,
...@@ -128,7 +131,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -128,7 +131,7 @@ export default class ListOfCreditFacilities extends Component {
} }
componentDidMount() { componentDidMount() {
this.getPerBS() // this.getPerBS()
// this.getBankData() // this.getBankData()
// this.getTypeOfCredit() // this.getTypeOfCredit()
this.getSubmission() this.getSubmission()
...@@ -146,13 +149,13 @@ export default class ListOfCreditFacilities extends Component { ...@@ -146,13 +149,13 @@ export default class ListOfCreditFacilities extends Component {
}) })
} }
dataTableForChild(data, params) { dataTableForChild(data, array, params, type) {
switch (params) { switch (params) {
case "LOV": case "LOV":
this.setState({ dataTableLOV: data }) this.setState({ dataTableLOV: data, })
break; break;
case "LOCF": case "LOCF":
this.setState({ dataTableLOCF: data }) this.setState({ dataTableLOCF: data, diff: array[46], perBS: array[48], tambah: type})
break break
default: default:
break; break;
...@@ -193,224 +196,6 @@ export default class ListOfCreditFacilities extends Component { ...@@ -193,224 +196,6 @@ export default class ListOfCreditFacilities extends Component {
// this.setState({viewOnly: true}) // this.setState({viewOnly: true})
} }
// getItemHierarki() {
// 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,
// "get_for": this.state.get_for
// }
// api.create().getHierarkiMontlyReportLOCF(payload).then(response => {
// console.log(payload);
// console.log(response);
// let dataTable = []
// if (response.data) {
// 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.locf.borrower_comp_name === null ? "0.0" : item.locf.borrower_comp_name === "" ? "0.0" : item.locf.borrower_comp_name,
// // item.locf.bank_name === null ? "0.0" : item.locf.bank_name === "" ? "0.0" : item.locf.bank_name,
// // item.locf.type_of_credit === null ? "0.0" : item.locf.type_of_credit === "" ? "0.0" : item.locf.type_of_credit,
// // item.locf.remarks === null ? "0.0" : item.locf.remarks === "" ? "0.0" : item.locf.remarks,
// // item.locf.loan_maturity_date === null ? "0.0" : item.locf.loan_maturity_date === "" ? "0.0" : item.locf.loan_maturity_date,
// // item.locf.interest === null ? "0.0" : item.locf.interest === "" ? "0.0" : item.locf.interest,
// // item.locf.currency === null ? "0.0" : item.locf.currency === "" ? "0.0" : item.locf.currency,
// // item.locf.loan_plafond_amount_ori === null ? "0.0" : item.locf.loan_plafond_amount_ori === "" ? "0.0" : 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 === null ? "0.0" : item.locf.out_loan_ki_amount_ori === "" ? "0.0" : 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 === null ? "0.0" : item.locf.out_loan_kmk_amount_ori === "" ? "0.0" : 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.mtd_vs_previous_month === null ? "0.0" : item.locf.mtd_vs_previous_month === "" ? "0.0" : item.locf.mtd_vs_previous_month,
// // item.locf.out_loan_other_type === null ? "0.0" : item.locf.out_loan_other_type === "" ? "0.0" : item.locf.out_loan_other_type,
// // item.locf.out_loan_other_amount_ori === null ? "0.0" : item.locf.out_loan_other_amount_ori === "" ? "0.0" : 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 === null ? "0.0" : item.locf.current_ratio_financial === "" ? "0.0" : 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 === null ? "0.0" : item.locf.der_financial === "" ? "0.0" : 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 === null ? "0.0" : item.locf.debt_to_ebitda_financial === "" ? "0.0" : 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 === null ? "0.0" : item.locf.ebitda_to_interest_financial === "" ? "0.0" : 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 === null ? "0.0" : item.locf.other_ratio1_ratio_name === "" ? "0.0" : item.locf.other_ratio1_ratio_name,
// // item.locf.other_ratio1_financial === null ? "0.0" : item.locf.other_ratio1_financial === "" ? "0.0" : 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 === null ? "0.0" : item.locf.other_ratio2_ratio_name === "" ? "0.0" : item.locf.other_ratio2_ratio_name,
// // item.locf.other_ratio2_financial === null ? "0.0" : item.locf.other_ratio2_financial === "" ? "0.0" : 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 === null ? "0.0" : item.locf.other_ratio3_ratio_name === "" ? "0.0" : item.locf.other_ratio3_ratio_name,
// // item.locf.other_ratio3_financial === null ? "0.0" : item.locf.other_ratio3_financial === "" ? "0.0" : 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 === null ? "0.0" : item.locf.other_ratio4_ratio_name === "" ? "0.0" : item.locf.other_ratio4_ratio_name,
// // item.locf.other_ratio4_financial === null ? "0.0" : item.locf.other_ratio4_financial === "" ? "0.0" : 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.notes,
// // // item.locf.per_bs === null ? "0.0" : item.locf.per_bs === "" ? "0.0" : item.locf.per_bs,
// // // item.locf.diff === null ? "0.0" : item.locf.diff === "" ? "0.0" : item.locf.diff,
// // ])
// // }
// // 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('-')
// if (index == res.length - 1) {
// dataTable.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// // item.description,
// 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.mtd_vs_previous_month === null ? "0.0" : item.locf.mtd_vs_previous_month === "" ? "0.0" : item.locf.mtd_vs_previous_month,
// 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.per_bs === null ? "0.0" : item.locf.per_bs === "" ? "0.0" : item.locf.per_bs,
// // item.diff === null ? "0.0" : item.locf.diff === "" ? "0.0" : item.locf.diff,
// index
// ],
// [9, "", "", "", "", "", { value: "Grand Total" }, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999],
// )
// } else {
// dataTable.push([
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// // item.description,
// 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.mtd_vs_previous_month === null ? "0.0" : item.locf.mtd_vs_previous_month === "" ? "0.0" : item.locf.mtd_vs_previous_month,
// 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,
// index
// // item.per_bs === null ? "0.0" : item.locf.per_bs === "" ? "0.0" : item.locf.per_bs,
// // item.diff === null ? "0.0" : item.locf.diff === "" ? "0.0" : item.locf.diff,
// ])
// }
// // if (item.children !== null) {
// // if (item.children.length > 0) {
// // item.children.map((items, indexs) => {
// // handlePushChild(items)
// // })
// // }
// // }
// })
// // console.log(dataTable);
// if (dataTable.length == 0 && this.state.get_for == 'edit') {
// dataTable.push(
// [3, "", "", "", "", this.props.company.company_name, null, null, "", null, "0.00", "", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "", 0],
// [9, "", "", "", "", "", { value: "Grand Total" }, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999],
// )
// }
// console.log(dataTable)
// this.setState({ dataTable, loading: false, visibleLOCFMR: true }, () => {
// this.handleCalculate()
// })
// }
// })
// }
getLatestUpdate() { getLatestUpdate() {
let payload = { let payload = {
"report_id": this.props.report_id, "report_id": this.props.report_id,
...@@ -445,82 +230,6 @@ export default class ListOfCreditFacilities extends Component { ...@@ -445,82 +230,6 @@ export default class ListOfCreditFacilities extends Component {
}) })
} }
// fileHandler = (event) => {
// let fileObj = event
// ExcelRenderer(fileObj, (err, resp) => {
// // console.log(resp)
// if (err) {
// console.log(err);
// }
// else {
// let isi = resp.rows.slice(3)
// console.log(isi);
// let payload = []
// let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
// isi.map((i, index) => {
// if (i.length > 0) {
// let tgl = String(i[5]).split('-')
// console.log(i[5])
// console.log(tgl)
// payload.push({
// "item_report_id": i[1],
// "borrower_comp_name": this.props.company.company_name,
// "bank_name": i[2],
// "type_of_credit": i[3],
// "remarks": i[4],
// "loan_maturity_date": i[5] !== undefined ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : null,
// "interest": i[6],
// "currency": i[7],
// "loan_plafond_amount_ori": i[8] !== undefined ? Number(i[8]) : i[8],
// "loan_plafond_amount_idr": i[9] !== undefined ? Number(i[9]) : i[9],
// "out_loan_ki_amount_ori": i[10] !== undefined ? Number(i[10]) : i[10],
// "out_loan_ki_amount_idr": i[11] !== undefined ? Number(i[11]) : i[11],
// "out_loan_kmk_amount_ori": i[12] !== undefined ? Number(i[12]) : i[12],
// "out_loan_kmk_amount_idr": i[13] !== undefined ? Number(i[13]) : i[13],
// "out_loan_other_type": i[14],
// "out_loan_other_amount_ori": i[15] !== undefined ? Number(i[15]) : i[15],
// "out_loan_other_amount_idr": i[16] !== undefined ? Number(i[16]) : i[16],
// // "total_out_loan_ori": i[18],
// // "total_out_loan_idr": i[19],
// // "remaining_plafond_ori": i[20],
// // "remaining_plafond_idr": i[21],
// "current_ratio_financial": i[17],
// "der_financial": i[18],
// "debt_to_ebitda_financial": i[19],
// "ebitda_to_interest_financial": i[20],
// "other_ratio1_ratio_name": i[21],
// "other_ratio1_financial": i[22],
// "other_ratio1_current": i[23],
// "other_ratio2_ratio_name": i[24],
// "other_ratio2_financial": i[25],
// "other_ratio2_current": i[26],
// "other_ratio3_ratio_name": i[27],
// "other_ratio3_financial": i[28],
// "other_ratio3_current": i[29],
// "other_ratio4_ratio_name": i[30],
// "other_ratio4_financial": i[31],
// "other_ratio4_current": i[32],
// "notes": i[33],
// })
// }
// })
// 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,
// "locf": payload,
// "per_bs": this.state.perBS,
// "diff": this.state.diff,
// "total_loan": this.state.perBS
// }
// console.log(body)
// this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
// }
// });
// }
deleteReport() { deleteReport() {
...@@ -533,427 +242,6 @@ export default class ListOfCreditFacilities extends Component { ...@@ -533,427 +242,6 @@ export default class ListOfCreditFacilities extends Component {
} }
} }
// checkUpload() {
// let payload = {
// ...this.state.payload,
// currency_id: this.state.defaultCurrencyUpload?.id
// }
// let dataDelete = []
// api.create().getIdDeleteFromExcelLOCF(payload).then((response) => {
// console.log(response)
// // if (response.data) {
// // // // // // // console.log(response.data)
// // let idDelete = response.data.data.item_report_id
// // if (idDelete.length > 0) {
// // idDelete.map((item, index) => {
// // dataDelete.push(item)
// // })
// // this.setState({ dataDelete })
// // }
// // }
// })
// api.create().checkUploadMonthlyReportLOCF(payload).then(response => {
// // console.log(JSON.stringify(this.state.payload));
// console.log(response)
// if (response.data) {
// if (response.data.status === 'success') {
// this.setState({ visibleUpload: false, loading: true, visibleLOCFMR: false, totalOutStand: 0, diff: 0 })
// let dataTable = []
// response.data.data.map((item, index) => {
// if (index == response.data.data.length - 1) {
// dataTable.push([
// 3,
// item.item_report_id,
// item.parent,
// item.formula,
// item.level,
// item.borrower_comp_name === null ? this.props.company.company_name : item.borrower_comp_name === "" ? this.props.company.company_name : item.borrower_comp_name,
// item.bank_name === null ? null : item.bank_name === "" ? null : { value: item.bank_name },
// item.type_of_credit === null ? null : item.type_of_credit === "" ? null : { value: item.type_of_credit },
// item.remarks === null ? "" : item.remarks === "" ? "" : item.remarks,
// item.loan_maturity_date === null || item.loan_maturity_date === "" ? null : item.loan_maturity_date,
// item.interest === null || item.interest === "" ? "0.00" : item.interest,
// item.currency === null || item.currency === "" ? "" : item.currency,
// item.loan_plafond_amount_ori == null ? "" : item.loan_plafond_amount_ori,
// item.loan_plafond_amount_idr === null ? "0.0" : item.loan_plafond_amount_idr === "" ? "0.0" : item.loan_plafond_amount_idr,
// item.type_of_credit == "Investment Loan" ? item.out_loan_ki_amount_ori : "0.0",
// item.type_of_credit == "Investment Loan" ? (item.out_loan_ki_amount_idr === null ? "0.0" : item.out_loan_ki_amount_idr === "" ? "0.0" : item.out_loan_ki_amount_idr) : "0.0",
// item.type_of_credit == "Revolving Loan (KMK)" ? item.out_loan_kmk_amount_ori : "0.0",
// item.type_of_credit == "Revolving Loan (KMK)" ? (item.out_loan_kmk_amount_idr === null ? "0.0" : item.out_loan_kmk_amount_idr === "" ? "0.0" : item.out_loan_kmk_amount_idr) : "0.0",
// item.type_of_credit == "Others" ? item.out_loan_other_type : "",
// item.type_of_credit == "Others" ? item.out_loan_other_amount_ori : "0.0",
// item.type_of_credit == "Others" ? (item.out_loan_other_amount_idr === null ? "0.0" : item.out_loan_other_amount_idr === "" ? "0.0" : item.out_loan_other_amount_idr) : "0.0",
// item.total_out_loan_ori === null ? "0.0" : item.total_out_loan_ori === "" ? "0.0" : item.total_out_loan_ori === 0 ? "0.0" : item.total_out_loan_ori,
// item.total_out_loan_idr === null ? "0.0" : item.total_out_loan_idr === "" ? "0.0" : item.total_out_loan_idr,
// item.remaining_plafond_ori === null ? "0.0" : item.remaining_plafond_ori === "" ? "0.0" : item.remaining_plafond_ori,
// item.remaining_plafond_idr === null ? "0.0" : item.remaining_plafond_idr === "" ? "0.0" : item.remaining_plafond_idr,
// item.current_ratio_financial == null ? "" : item.current_ratio_financial,
// item.current_ratio_current === null ? "0.0" : item.current_ratio_current === "" ? "0.0" : item.current_ratio_current,
// item.der_financial == null ? "" : item.der_financial,
// item.der_current === null ? "0.0" : item.der_current === "" ? "0.0" : item.der_current,
// item.debt_to_ebitda_financial == null ? "" : item.debt_to_ebitda_financial,
// item.debt_to_ebitda_current === null ? "0.0" : item.debt_to_ebitda_current === "" ? "0.0" : item.debt_to_ebitda_current,
// item.ebitda_to_interest_financial == null ? "" : item.ebitda_to_interest_financial,
// item.ebitda_to_interest_current === null ? "0.0" : item.ebitda_to_interest_current === "" ? "0.0" : item.ebitda_to_interest_current,
// item.other_ratio1_ratio_name == null ? "" : item.other_ratio1_ratio_name,
// item.other_ratio1_financial === null ? "0.0" : item.other_ratio1_financial === "" ? "0.0" : item.other_ratio1_financial,
// item.other_ratio1_current === null ? "0.0" : item.other_ratio1_current === "" ? "0.0" : item.other_ratio1_current,
// item.other_ratio2_ratio_name == null ? "" : item.other_ratio2_ratio_name,
// item.other_ratio2_financial === null ? "0.0" : item.other_ratio2_financial === "" ? "0.0" : item.other_ratio2_financial,
// item.other_ratio2_current === null ? "0.0" : item.other_ratio2_current === "" ? "0.0" : item.other_ratio2_current,
// item.other_ratio3_ratio_name == null ? "" : item.other_ratio3_ratio_name,
// item.other_ratio3_financial === null ? "0.0" : item.other_ratio3_financial === "" ? "0.0" : item.other_ratio3_financial,
// item.other_ratio3_current === null ? "0.0" : item.other_ratio3_current === "" ? "0.0" : item.other_ratio3_current,
// item.other_ratio4_ratio_name == null ? "" : item.other_ratio4_ratio_name,
// item.other_ratio4_financial === null ? "0.0" : item.other_ratio4_financial === "" ? "0.0" : item.other_ratio4_financial,
// item.other_ratio4_current === null ? "0.0" : item.other_ratio4_current === "" ? "0.0" : item.other_ratio4_current,
// item.notes,
// ],
// [9, "", "", "", "", "", { value: "Grand Total" }, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999],
// )
// } else {
// dataTable.push([
// 3,
// item.item_report_id,
// item.parent,
// item.formula,
// item.level,
// item.borrower_comp_name === null ? this.props.company.company_name : item.borrower_comp_name === "" ? this.props.company.company_name : item.borrower_comp_name,
// item.bank_name === null ? null : item.bank_name === "" ? null : { value: item.bank_name },
// item.type_of_credit === null ? null : item.type_of_credit === "" ? null : { value: item.type_of_credit },
// item.remarks === null ? "" : item.remarks === "" ? "" : item.remarks,
// item.loan_maturity_date === null || item.loan_maturity_date === "" ? null : item.loan_maturity_date,
// item.interest === null || item.interest === "" ? "0.00" : item.interest,
// item.currency === null || item.currency === "" ? "" : item.currency,
// item.loan_plafond_amount_ori == null ? "" : item.loan_plafond_amount_ori,
// item.loan_plafond_amount_idr === null ? "0.0" : item.loan_plafond_amount_idr === "" ? "0.0" : item.loan_plafond_amount_idr,
// item.type_of_credit == "Investment Loan" ? item.out_loan_ki_amount_ori : "0.0",
// item.type_of_credit == "Investment Loan" ? (item.out_loan_ki_amount_idr === null ? "0.0" : item.out_loan_ki_amount_idr === "" ? "0.0" : item.out_loan_ki_amount_idr) : "0.0",
// item.type_of_credit == "Revolving Loan (KMK)" ? item.out_loan_kmk_amount_ori : "0.0",
// item.type_of_credit == "Revolving Loan (KMK)" ? (item.out_loan_kmk_amount_idr === null ? "0.0" : item.out_loan_kmk_amount_idr === "" ? "0.0" : item.out_loan_kmk_amount_idr) : "0.0",
// item.type_of_credit == "Others" ? item.out_loan_other_type : "",
// item.type_of_credit == "Others" ? item.out_loan_other_amount_ori : "0.0",
// item.type_of_credit == "Others" ? (item.out_loan_other_amount_idr === null ? "0.0" : item.out_loan_other_amount_idr === "" ? "0.0" : item.out_loan_other_amount_idr) : "0.0",
// item.total_out_loan_ori === null ? "0.0" : item.total_out_loan_ori === "" ? "0.0" : item.total_out_loan_ori,
// item.total_out_loan_idr === null ? "0.0" : item.total_out_loan_idr === "" ? "0.0" : item.total_out_loan_idr,
// item.remaining_plafond_ori === null ? "0.0" : item.remaining_plafond_ori === "" ? "0.0" : item.remaining_plafond_ori,
// item.remaining_plafond_idr === null ? "0.0" : item.remaining_plafond_idr === "" ? "0.0" : item.remaining_plafond_idr,
// item.current_ratio_financial == null ? "" : item.current_ratio_financial,
// item.current_ratio_current === null ? "0.0" : item.current_ratio_current === "" ? "0.0" : item.current_ratio_current,
// item.der_financial == null ? "" : item.der_financial,
// item.der_current === null ? "0.0" : item.der_current === "" ? "0.0" : item.der_current,
// item.debt_to_ebitda_financial == null ? "" : item.debt_to_ebitda_financial,
// item.debt_to_ebitda_current === null ? "0.0" : item.debt_to_ebitda_current === "" ? "0.0" : item.debt_to_ebitda_current,
// item.ebitda_to_interest_financial == null ? "" : item.ebitda_to_interest_financial,
// item.ebitda_to_interest_current === null ? "0.0" : item.ebitda_to_interest_current === "" ? "0.0" : item.ebitda_to_interest_current,
// item.other_ratio1_ratio_name == null ? "" : item.other_ratio1_ratio_name,
// item.other_ratio1_financial === null ? "0.0" : item.other_ratio1_financial === "" ? "0.0" : item.other_ratio1_financial,
// item.other_ratio1_current === null ? "0.0" : item.other_ratio1_current === "" ? "0.0" : item.other_ratio1_current,
// item.other_ratio2_ratio_name == null ? "" : item.other_ratio2_ratio_name,
// item.other_ratio2_financial === null ? "0.0" : item.other_ratio2_financial === "" ? "0.0" : item.other_ratio2_financial,
// item.other_ratio2_current === null ? "0.0" : item.other_ratio2_current === "" ? "0.0" : item.other_ratio2_current,
// item.other_ratio3_ratio_name == null ? "" : item.other_ratio3_ratio_name,
// item.other_ratio3_financial === null ? "0.0" : item.other_ratio3_financial === "" ? "0.0" : item.other_ratio3_financial,
// item.other_ratio3_current === null ? "0.0" : item.other_ratio3_current === "" ? "0.0" : item.other_ratio3_current,
// item.other_ratio4_ratio_name == null ? "" : item.other_ratio4_ratio_name,
// item.other_ratio4_financial === null ? "0.0" : item.other_ratio4_financial === "" ? "0.0" : item.other_ratio4_financial,
// item.other_ratio4_current === null ? "0.0" : item.other_ratio4_current === "" ? "0.0" : item.other_ratio4_current,
// item.notes,
// ])
// }
// // if (item.children !== null) {
// // if (item.children.length > 0) {
// // item.children.map((items, indexs) => {
// // handlePushChild(items)
// // })
// // }
// // }
// })
// console.log(dataTable);
// if (dataTable.length == 0) {
// dataTable.push(
// [3, "", "", "", "", this.props.company.company_name, null, null, "", null, "0.00", "", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "", 0],
// [9, "", "", "", "", "", { value: "Grand Total" }, null, "", "", "", "0", "", "0", "", "0", "", "0", "", "", "0", "0", "0", "0", "0", "", "0", "", "0", "", "0", "", "0", "", "", "", "", "", "", "", "", "", "", "", "", "notes", 999999],
// )
// }
// this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => {
// this.handleCalculate()
// this.state.dataTable.map(item => {
// if (item[23].length > 0) {
// // console.log('masuk')
// this.setState({ buttonError: true, errorPreview: true })
// }
// })
// // console.log(this.state.buttonError)
// })
// // console.log(dataTable);
// }
// }
// })
// }
// uploadLOCF(type) {
// let data = []
// let error = false
// this.deleteReport()
// this.state.dataTable.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],
// "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],
// "currency": i[11],
// "loan_plafond_amount_ori": Number(i[12]) == "" ? "0.0" : Number(i[12]),
// "loan_plafond_amount_idr": Number(i[13]) == "" ? "0.0" : Number(i[13]),
// "out_loan_ki_amount_ori": Number(i[14]) == "" ? "0.0" : Number(i[14]),
// "out_loan_ki_amount_idr": Number(i[15]) == "" ? "0.0" : Number(i[15]),
// "out_loan_kmk_amount_ori": Number(i[16]) == "" ? "0.0" : Number(i[16]),
// "out_loan_kmk_amount_idr": Number(i[17]) == "" ? "0.0" : Number(i[17]),
// // "mtd_vs_previous_month": i[18],
// "out_loan_other_type": i[18],
// "out_loan_other_amount_ori": Number(i[19]) == "" ? "0.0" : Number(i[19]),
// "out_loan_other_amount_idr": Number(i[20]) == "" ? "0.0" : Number(i[20]),
// "total_out_loan_ori": Number(i[21]) == "" ? "0.0" : Number(i[21]),
// "total_out_loan_idr": Number(i[22]) == "" ? "0.0" : Number(i[22]),
// "remaining_plafond_ori": Number(i[23]) == "" ? "0.0" : Number(i[23]),
// "remaining_plafond_idr": Number(i[24]) == "" ? "0.0" : Number(i[24]),
// "current_ratio_financial": Number(i[25]) == "" ? "0.00" : Number(i[25]),
// "current_ratio_current": Number(i[26]) == "" ? "0.00" : Number(i[26]),
// "der_financial": Number(i[27]) == "" ? "0.00" : Number(i[27]),
// "der_current": Number(i[28]) == "" ? "0.00" : Number(i[28]),
// "debt_to_ebitda_financial": Number(i[29]) == "" ? "0.00" : Number(i[29]),
// "debt_to_ebitda_current": Number(i[30]) == "" ? "0.00" : Number(i[30]),
// "ebitda_to_interest_financial": Number(i[31]) == "" ? "0.00" : Number(i[31]),
// "ebitda_to_interest_current": Number(i[32]) == "" ? "0.00" : Number(i[32]),
// "other_ratio1_ratio_name": i[33],
// "other_ratio1_financial": Number(i[34]) == "" ? "0.00" : Number(i[34]),
// "other_ratio1_current": Number(i[35]) == "" ? "0.00" : Number(i[35]),
// "other_ratio2_ratio_name": i[36],
// "other_ratio2_financial": Number(i[37]) == "" ? "0.00" : Number(i[37]),
// "other_ratio2_current": Number(i[38]) == "" ? "0.00" : Number(i[38]),
// "other_ratio3_ratio_name": i[39],
// "other_ratio3_financial": Number(i[40]) == "" ? "0.00" : Number(i[40]),
// "other_ratio3_current": Number(i[41]) == "" ? "0.00" : Number(i[41]),
// "other_ratio4_ratio_name": i[42],
// "other_ratio4_financial": Number(i[43]) == "" ? "0.00" : Number(i[43]),
// "other_ratio4_current": Number(i[44]) == "" ? "0.00" : Number(i[44]),
// "notes": i[45],
// })
// } else {
// data.push({
// "item_report_id": i[1],
// "borrower_comp_name": i[5],
// "bank_name": i[6] == null ? [6] : i[6].value,
// "type_of_credit": i[7] == null ? i[7] : i[7].value,
// "remarks": i[8],
// // "loan_maturity_date": i[9],
// "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],
// "currency": i[11],
// "loan_plafond_amount_ori": fixNumber(Number(i[12]), 1) == "" ? "0.0" : fixNumber(Number(i[12]), 1),
// "loan_plafond_amount_idr": fixNumber(Number(i[13]), 1) == "" ? "0.0" : fixNumber(Number(i[13]), 1),
// "out_loan_ki_amount_ori": fixNumber(Number(i[14]), 1) == "" ? "0.0" : fixNumber(Number(i[14]), 1),
// "out_loan_ki_amount_idr": fixNumber(Number(i[15]), 1) == "" ? "0.0" : fixNumber(Number(i[15]), 1),
// "out_loan_kmk_amount_ori": fixNumber(Number(i[16]), 1) == "" ? "0.0" : fixNumber(Number(i[16]), 1),
// "out_loan_kmk_amount_idr": fixNumber(Number(i[17]), 1) == "" ? "0.0" : fixNumber(Number(i[17]), 1),
// // "mtd_vs_previous_month": i[18],
// "out_loan_other_type": i[18],
// "out_loan_other_amount_ori": fixNumber(Number(i[19]), 1) == "" ? "0.0" : fixNumber(Number(i[19]), 1),
// "out_loan_other_amount_idr": fixNumber(Number(i[20]), 1) == "" ? "0.0" : fixNumber(Number(i[20]), 1),
// "total_out_loan_ori": fixNumber(Number(i[21]), 1) == "" ? "0.0" : fixNumber(Number(i[21]), 1),
// "total_out_loan_idr": fixNumber(Number(i[22]), 1) == "" ? "0.0" : fixNumber(Number(i[22]), 1),
// "remaining_plafond_ori": fixNumber(Number(i[23]), 1) == "" ? "0.0" : fixNumber(Number(i[23]), 1),
// "remaining_plafond_idr": fixNumber(Number(i[24]), 1) == "" ? "0.0" : fixNumber(Number(i[24]), 1),
// "current_ratio_financial": fixNumber(Number(i[25]), 2) == "" ? "0.00" : fixNumber(Number(i[25]), 2),
// "current_ratio_current": fixNumber(Number(i[26]), 2) == "" ? "0.00" : fixNumber(Number(i[26]), 2),
// "der_financial": fixNumber(Number(i[27]), 2) == "" ? "0.00" : fixNumber(Number(i[27]), 2),
// "der_current": fixNumber(Number(i[28]), 2) == "" ? "0.00" : fixNumber(Number(i[28]), 2),
// "debt_to_ebitda_financial": fixNumber(Number(i[29]), 2) == "" ? "0.00" : fixNumber(Number(i[29]), 2),
// "debt_to_ebitda_current": fixNumber(Number(i[30]), 2) == "" ? "0.00" : fixNumber(Number(i[30]), 2),
// "ebitda_to_interest_financial": fixNumber(Number(i[31]), 2) == "" ? "0.00" : fixNumber(Number(i[31]), 2),
// "ebitda_to_interest_current": fixNumber(Number(i[32]), 2) == "" ? "0.00" : fixNumber(Number(i[32]), 2),
// "other_ratio1_ratio_name": i[33],
// "other_ratio1_financial": fixNumber(Number(i[34]), 2) == "" ? "0.00" : fixNumber(Number(i[34]), 2),
// "other_ratio1_current": fixNumber(Number(i[35]), 2) == "" ? "0.00" : fixNumber(Number(i[35]), 2),
// "other_ratio2_ratio_name": i[36],
// "other_ratio2_financial": fixNumber(Number(i[37]), 2) == "" ? "0.00" : fixNumber(Number(i[37]), 2),
// "other_ratio2_current": fixNumber(Number(i[38]), 2) == "" ? "0.00" : fixNumber(Number(i[38]), 2),
// "other_ratio3_ratio_name": i[39],
// "other_ratio3_financial": fixNumber(Number(i[40]), 2) == "" ? "0.00" : fixNumber(Number(i[40]), 2),
// "other_ratio3_current": fixNumber(Number(i[41]), 2) == "" ? "0.00" : fixNumber(Number(i[41]), 2),
// "other_ratio4_ratio_name": i[42],
// "other_ratio4_financial": fixNumber(Number(i[43]), 2) == "" ? "0.00" : fixNumber(Number(i[43]), 2),
// "other_ratio4_current": fixNumber(Number(i[44]), 2) == "" ? "0.00" : fixNumber(Number(i[44]), 2),
// "notes": i[45],
// })
// }
// }
// })
// let body = {
// "monthly_report_id": this.props.monthlyReportId,
// "company_id": this.props.company.company_id,
// "periode": this.props.periode,
// "report_id": this.props.report_id,
// "status": type,
// "months": this.props.month.month_id,
// "currency_id": this.props.defaultCurrency.id,
// "locf": data,
// "per_bs": this.state.perBS,
// "diff": this.state.diff,
// "total_loan": this.state.perBS
// }
// console.log(JSON.stringify(body));
// if (error && type == 'submitted') {
// this.setState({ handleDoubleClick: 0, saveDraft: false, saveComp: true, loading: false, snekbar: true, snekbarMsg: 'Data Incomplete', handleDoubleClick: 0 })
// } else {
// api.create('UPLOAD').uploadMonthlyReportLOCF(body).then(response => {
// console.log(response);
// if (response.data) {
// if (response.ok) {
// if (response.data.status === "success") {
// this.props.saveToMonthlyReport('LOCF')
// // this.props.onClickClose()
// // this.props.getReport()
// } else {
// if (response.data?.message == "Please Set Up Rate Currency First") {
// this.setState({ visibleAlertSave: true })
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
// if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
// setTimeout(() => {
// localStorage.removeItem(Constant.TOKEN)
// window.location.reload();
// }, 1000);
// }
// })
// }
// // alert(response.data.status)
// }
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
// }
// this.setState({ handleDoubleClick: 0 })
// })
// }
// }
// getBankData() {
// let body = {
// group: 'BANK',
// company_id: this.props.company.company_id,
// type: 'BANK_NAME',
// currency_id: this.props.defaultCurrency.id,
// }
// this.setState({ dataLoaded: false })
// api.create().getAllSettingByType(body).then(response => {
// console.log(response)
// if (response.data) {
// if (response.ok) {
// if (response.data.status === 'success') {
// let data = response.data.data
// // // // console.log(data)
// let inputBank = []
// data.map((item) => {
// inputBank.push({
// value: `${item.value}`
// })
// })
// let defaultProps = {
// options: inputBank,
// getOptionLabel: (option) => titleCase(option.value),
// };
// // // // console.log(defaultProps)
// this.setState({ bankNameList: defaultProps })
// } 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.data.message, tipeAlert: 'error' })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
// }
// })
// }
// getTypeOfCredit() {
// let body = {
// group: 'BANK',
// company_id: this.props.company.company_id,
// type: 'TYPE_OF_CREDIT',
// currency_id: this.props.defaultCurrency.id,
// }
// api.create().getAllSettingByType(body).then(response => {
// console.log(response)
// if (response.data) {
// if (response.ok) {
// if (response.data.status === 'success') {
// let data = response.data.data
// // // // console.log(data)
// let inputTypeOfCredit = []
// data.map((item) => {
// inputTypeOfCredit.push({
// value: item.value
// })
// })
// let defaultProps = {
// options: inputTypeOfCredit,
// getOptionLabel: (option) => titleCase(option.value),
// };
// // // // console.log(defaultProps)
// this.setState({ typeOfCreditList: defaultProps })
// } 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.data.message, tipeAlert: 'error' })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
// }
// })
// }
downloadTemplate = async () => { downloadTemplate = async () => {
let res = await fetch( let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}&&currency_id=${this.props.defaultCurrency.id}` `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}&&currency_id=${this.props.defaultCurrency.id}`
...@@ -1007,7 +295,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1007,7 +295,7 @@ export default class ListOfCreditFacilities extends Component {
lastRevision: response.data.data.last_revision, lastRevision: response.data.data.last_revision,
}, () => { }, () => {
// this.getDataRatio() // this.getDataRatio()
}) })
} else { } else {
this.setState({ submissionID: null, loading: false, visibleLOCFMR: true }) this.setState({ submissionID: null, loading: false, visibleLOCFMR: true })
...@@ -1016,35 +304,35 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1016,35 +304,35 @@ export default class ListOfCreditFacilities 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,
} // }
api.create().getPerBSiMontlyReportLOCF(payload).then((response) => { // api.create().getPerBSiMontlyReportLOCF(payload).then((response) => {
console.log(response) // console.log(response)
// if (this.state.get_for == 'view') { // // if (this.state.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 })
} // }
// } // // }
}) // })
} // }
// getDataRatio() { // getDataRatio() {
// let payload = { // let payload = {
...@@ -1328,241 +616,269 @@ export default class ListOfCreditFacilities extends Component { ...@@ -1328,241 +616,269 @@ export default class ListOfCreditFacilities extends Component {
} }
} }
handleCalculateLOCF = () => {
this.setState({ loading: true})
let dataTable2 = this.state.dataTablelocf == undefined || this.state.tambah == 'tambah' ? this.state.dataTableLOCF : this.state.dataTablelocf
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
}
handleCalculate = () => { if (i[7].value == 'Others' && i[18] == '') {
let dataTable2 = this.state.dataTable error = true
this.setState({ loading: true }, () => {
let bankPrev = ""
let idPrev = 0
let newData = []
let dataCoba = []
let bankNameEmpty = false
let totalLoan = 0
console.log(dataTable2);
dataTable2.map((item, index) => {
if (item[0] !== 8) {
if (item[6] == null) {
bankNameEmpty = true
} else {
let groupName = String(item[6].value).split("-")
let indexAS = dataCoba.findIndex((val) => item[6].value.includes(val.groupName))
if (indexAS == -1) {
dataCoba.push({
groupName: groupName[groupName.length - 1],
data: [item]
})
} else {
let indexDD = dataCoba[indexAS].data.length - 1 == -1 ? 0 : dataCoba[indexAS].data.length - 1
if (String(dataCoba[indexAS].data[indexDD]).includes('Total')) {
let dataAwal = []
let dataAkhir = []
dataAwal = dataCoba[indexAS].data.splice(0, dataCoba[indexAS].data.length - 2)
dataAkhir = dataCoba[indexAS].data.splice(dataCoba[indexAS].data.length - 1, 1)
dataAwal.push(item)
dataCoba[indexAS].data = dataAwal.concat(dataAkhir)
} else {
dataCoba[indexAS].data.push(item)
}
}
}
} }
}) let tgl = String(i[9]).split('-')
console.log(dataCoba); let checkUndifined = tgl.findIndex((val) => val == undefined)
let dataGabung = [] if (this.props.defaultCurrency.id == 2) {
if (!bankNameEmpty) { data.push({
dataCoba.map((item, index) => { "item_report_id": i[1],
item.data.map((items, index) => { "borrower_comp_name": i[5],
dataGabung.push(items) "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 {
console.log(dataGabung); data.push({
dataGabung.map((items, index) => { "item_report_id": i[1],
console.log(items); "borrower_comp_name": i[5],
if (items[0] == 3) { "bank_name": i[6] == null ? [6] : i[6].value,
console.log(Number(totalLoan)); "type_of_credit": i[7] == null ? i[7] : i[7].value,
this.props.defaultCurrency.id == 1 ? totalLoan += items[22] : totalLoan += items[21] "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])),
if (bankPrev != "") { "interest": i[10] == "" ? "0.00" : i[10],
if (items[6].value !== bankPrev) { "currency": i[11],
bankPrev = items[6].value "loan_plafond_amount_ori": fixNumber(Number(i[12]), 1) == "" ? "0.0" : fixNumber(Number(i[12]), 1),
if (items[6].value == 'Grand Total') { "loan_plafond_amount_idr": fixNumber(Number(i[13]), 1) == "" ? "0.0" : fixNumber(Number(i[13]), 1),
// if (dataTable2.length > 2) { "out_loan_ki_amount_ori": fixNumber(Number(i[14]), 1) == "" ? "0.0" : fixNumber(Number(i[14]), 1),
// newData.push(items) "out_loan_ki_amount_idr": fixNumber(Number(i[15]), 1) == "" ? "0.0" : fixNumber(Number(i[15]), 1),
// } else { "out_loan_kmk_amount_ori": fixNumber(Number(i[16]), 1) == "" ? "0.0" : fixNumber(Number(i[16]), 1),
if (String(dataGabung[index - 1][6].value).includes('Total ')) { "out_loan_kmk_amount_idr": fixNumber(Number(i[17]), 1) == "" ? "0.0" : fixNumber(Number(i[17]), 1),
newData.push(items) "out_loan_other_type": i[18],
} else { "out_loan_other_amount_ori": fixNumber(Number(i[19]), 1) == "" ? "0.0" : fixNumber(Number(i[19]), 1),
// if (String(dataGabung[index][6].value).includes('Total ')) { "out_loan_other_amount_idr": fixNumber(Number(i[20]), 1) == "" ? "0.0" : fixNumber(Number(i[20]), 1),
// newData.push(items) "total_out_loan_ori": fixNumber(Number(i[21]), 1) == "" ? "0.0" : fixNumber(Number(i[21]), 1),
// } else { "total_out_loan_idr": fixNumber(Number(i[22]), 1) == "" ? "0.0" : fixNumber(Number(i[22]), 1),
// items[46] = index + 1 "remaining_plafond_ori": fixNumber(Number(i[23]), 1) == "" ? "0.0" : fixNumber(Number(i[23]), 1),
let nameTotal = String(dataGabung[index - 1][6].value).split("-") "remaining_plafond_idr": fixNumber(Number(i[24]), 1) == "" ? "0.0" : fixNumber(Number(i[24]), 1),
newData.push([ "current_ratio_financial": fixNumber(Number(i[25]), 2) == "" ? "0.00" : fixNumber(Number(i[25]), 2),
8, "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),
{ value: 'Total ' + nameTotal[nameTotal.length - 1] }, "ebitda_to_interest_current": fixNumber(Number(i[32]), 2) == "" ? "0.00" : fixNumber(Number(i[32]), 2),
null, "other_ratio1_ratio_name": i[33],
"", "other_ratio1_financial": fixNumber(Number(i[34]), 2) == "" ? "0.00" : fixNumber(Number(i[34]), 2),
null, "other_ratio1_current": fixNumber(Number(i[35]), 2) == "" ? "0.00" : fixNumber(Number(i[35]), 2),
"0.00", "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),
"0", "other_ratio3_ratio_name": i[39],
"", "other_ratio3_financial": fixNumber(Number(i[40]), 2) == "" ? "0.00" : fixNumber(Number(i[40]), 2),
"0", "other_ratio3_current": fixNumber(Number(i[41]), 2) == "" ? "0.00" : fixNumber(Number(i[41]), 2),
"", "other_ratio4_ratio_name": i[42],
"0", "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],
"0", })
"0", }
"0",
"0",
"0",
"",
"0",
"",
"0",
"",
"0",
"",
"0",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
index],
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,
)
}
} }
} })
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 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) {
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.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)
})
} }
else { }
newData.push(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.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)
})
} }
} else {
bankPrev = items[6].value
idPrev = items[0]
newData.push(items)
} }
}) })
} else { let lastArray = dataTablelocf[res.length - 1]
if (this.state.get_for == 'edit') { this.setState({ dataTablelocf, diff: lastArray[46], perBS: lastArray[48], loading: false, visibleLOCFMR: true }, () => {
this.setState({ snekbar: true, snekbarMsg: 'Bank Names Cannot be Empty' }) this.handleCalculateLOV()
} })
console.log(this.state.diff);
} }
setTimeout(() => {
// console.log(dataCoba)
// console.log(dataGabung)
console.log(newData)
// console.log(dataTampungBank)
console.log(totalLoan);
console.log(this.state.perBS)
console.log(this.state.diff)
console.log(bankNameEmpty)
// dataTable: newData, totalOutStand: newData[newData.length-1][22]
if (bankNameEmpty) {
if (this.state.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 })
} 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 })
}
} else {
if (this.state.get_for == 'view') {
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 })
} 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 })
}
} else {
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 })
} 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 })
}
}
}
}, 100);
}) })
} }
...@@ -4024,6 +3340,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -4024,6 +3340,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)}
dataTablelocf={this.state.dataTablelocf}
/> />
<hr /> <hr />
<LOV <LOV
...@@ -4098,7 +3415,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -4098,7 +3415,7 @@ export default class ListOfCreditFacilities extends Component {
marginRight: 20 marginRight: 20
}} }}
onClick={() => this.setState({ totalOutStand: totalLoan, saveTambahan: false }, () => { onClick={() => this.setState({ totalOutStand: totalLoan, saveTambahan: false }, () => {
this.handleCalculateLOV() this.handleCalculateLOCF()
})} })}
> >
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}> <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
...@@ -4185,6 +3502,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -4185,6 +3502,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)}
dataTablelocf={this.state.dataTablelocf}
/> />
<hr /> <hr />
<LOV <LOV
...@@ -4202,6 +3520,8 @@ export default class ListOfCreditFacilities extends Component { ...@@ -4202,6 +3520,8 @@ 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)}
sendDataTable={this.olahDataTable.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">
...@@ -4239,7 +3559,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -4239,7 +3559,7 @@ export default class ListOfCreditFacilities extends Component {
marginRight: 20 marginRight: 20
}} }}
onClick={() => this.setState({ totalOutStand: totalLoan, saveTambahan: false }, () => { onClick={() => this.setState({ totalOutStand: totalLoan, saveTambahan: false }, () => {
this.handleCalculate() this.handleCalculateLOCF()
})} })}
> >
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}> <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
......
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