Commit d51a53e0 authored by Riri Novita's avatar Riri Novita

locf

parent 889f3b5a
......@@ -104,7 +104,9 @@ export default class ListOfCreditFacilities extends Component {
dataTableInvest: [],
bankNameList: [],
typeOfCreditList: [],
typeOfInvesmentList: [],
typeOfInvestmentList: [],
currencyList: [],
loading: false,
dataTableRatio: [],
currentDate: format(new Date(), 'yyyy-MM-dd'),
......@@ -135,26 +137,34 @@ export default class ListOfCreditFacilities extends Component {
this.getSubmission()
this.getLatestUpdate()
this.handleViewOnly()
this.getType()
this.getTypeOfInvesment()
this.getListCurrency()
}
getType() {
api.create().getTypeOfInvestment().then(response => {
console.log(response);
getTypeOfInvesment() {
let body = {
group: 'INVESTMENT',
company_id: this.props.company.company_id,
type: 'TYPE_OF_INVESTEMENT',
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 inputTypeOfInvesment = []
let inpuTypeOfInvestment = []
data.investment.map((item) => {
inputTypeOfInvesment.push({
value: item.value
data.map((item) => {
inpuTypeOfInvestment.push({
value: `${item.value}`
})
})
let defaultProps = {
options: inputTypeOfInvesment,
options: inpuTypeOfInvestment,
getOptionLabel: (option) => titleCase(option.value),
};
// // // console.log(defaultProps)
......@@ -178,6 +188,46 @@ export default class ListOfCreditFacilities extends Component {
})
}
getListCurrency() {
this.setState({ dataLoaded: false })
api.create().getDataCurrency().then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inpuCurrency = []
data.map((item) => {
inpuCurrency.push({
currency_name: `${item.currency_name}`
})
})
console.log(data);
let defaultProps = {
options: inpuCurrency,
getOptionLabel: (option) => titleCase(option.currency_name),
};
// // // console.log(defaultProps)
this.setState({ currencyList: 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' })
}
})
}
handleGetFor(type) {
this.setState({ get_for: type }, () => {
this.getPerBS()
......@@ -452,13 +502,14 @@ export default class ListOfCreditFacilities extends Component {
"get_for": this.state.get_for
}
api.create().getHierarkiMontlyReportInvesment(payload).then(response => {
console.log(payload);
// console.log(payload);
console.log(response);
let dataTableInvest = []
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) {
dataTableInvest.push([
item.type_report_id,
......@@ -479,7 +530,7 @@ export default class ListOfCreditFacilities extends Component {
item.lov.notes,
index
],
[9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "notes", 999999],
[9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999],
)
} else {
dataTableInvest.push([
......@@ -505,8 +556,8 @@ export default class ListOfCreditFacilities extends Component {
})
if (dataTableInvest.length == 0 && this.state.get_for == 'edit') {
dataTableInvest.push(
[3, "", "", "", "", this.props.company.company_name, "", null, "", null, "0.0", "0.0", "", "", "", 0],
[9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "notes", 999999],
[3, "", "", "", "", this.props.company.company_name, "", null, "", null, "0.0", "0.0", "", "", "", "", 0],
[9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999],
)
}
console.log(dataTableInvest)
......@@ -528,7 +579,6 @@ export default class ListOfCreditFacilities extends Component {
}
// console.log(payload)
api.create().getLastestUpdateMR(payload).then(response => {
console.log(JSON.stringify(response))
if (response.data) {
if (response.data.status === "success") {
this.setState({
......@@ -1705,6 +1755,22 @@ export default class ListOfCreditFacilities extends Component {
}
}
const handleActionInvesment = (typeReport, tableMeta, typeButton) => {
if (typeReport == 3) {
if (dataTableInvestment.length == 2) {
if (typeButton == 'addLov') {
return true
} else {
return false
}
} else {
return true
}
} else {
return false
}
}
const handleChange = (value, tableMeta, column, typeChange, typeDrop) => {
let val = ''
if (typeChange == 'date') {
......@@ -1752,15 +1818,15 @@ export default class ListOfCreditFacilities extends Component {
}
const handleChangeInves = (value, tableMeta, column, typeChange, typeDrop) => {
console.log(typeChange, value);
let val = ''
if (typeChange == 'date') {
dataTable2[tableMeta.rowIndex][column] = format(value, 'yyyy-MM-dd')
dataTableInvestment[tableMeta.rowIndex][column] = format(value, 'yyyy-MM-dd')
this.setState({ loading: true }, () => {
this.setState({ loading: false })
})
} else {
console.log(column, value);
dataTable2[tableMeta.rowIndex][column] = value
dataTableInvestment[tableMeta.rowIndex][column] = value
// if (column != 6 && column != 11 && column != 18 && column != 25 && column != 27 && column != 29 && column != 31 && column != 33 && column != 36 && column != 39 && column != 42 && column != 45) {
// val = String(value).split(",").join("")
// val = this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 2) : Number(val)
......@@ -1819,23 +1885,23 @@ export default class ListOfCreditFacilities extends Component {
}
const handleValueDropDownInves = (value, type, tableMeta) => {
// let data = type == 'bankName' ? this.state.bankNameList.options : this.state.typeOfCreditList.options
// let index = 0
// if (type == 'bankName' && dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] != null && dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] != "") {
// indexNyasar = true
// }
// if (value == null) {
// index = -1
// } else {
// index = data.findIndex((val) => String(val.value) == String(value.value))
// }
// if (index == -1) {
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = null
// return null
// } else {
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
// return value
// }
let data = type == 'typeOfInvestmentList' ? this.state.typeOfInvestmentList.options : this.state.currencyList.options
let index = 0
if (type == 'typeOfInvestmentList' && dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] != null && dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] != "") {
indexNyasar = true
}
if (value == null) {
index = -1
} else {
index = data.findIndex((val) => String(val.value) == String(value.value))
}
if (index == -1) {
dataTableInvestment[tableMeta.rowIndex][tableMeta.columnIndex] = null
return null
} else {
dataTableInvestment[tableMeta.rowIndex][tableMeta.columnIndex] = value
return value
}
}
const handleTableRatio = (value, tableMeta, column, reportName) => {
......@@ -1890,43 +1956,26 @@ export default class ListOfCreditFacilities extends Component {
}
const handleFormulaHardcodeInves = (value, tableMeta, column) => {
// console.log("------------coba------------------");
// console.log(tableMeta);
// console.log(tableMeta.rowData[0]);
// let valuez = 0
// if (tableMeta.rowData[0] == 8) {
// dataTable2.map((item, index) => {
// if (item[6].value.includes(String(tableMeta.rowData[6].value).substr(6, tableMeta.rowData[6].length)) && item[0] != 8) {
// valuez += Number(item[column])
// }
// })
// } else if (tableMeta.rowData[0] == 9) {
// dataTable2.map((item, index) => {
// if (item[0] == 8) {
// valuez += Number(item[column])
// }
// })
// if (column == 22) {
// totalLoan = valuez
// }
// } else {
// if (column == 21) {
// valuez = Number(tableMeta.rowData[14]) + Number(tableMeta.rowData[16]) + Number(tableMeta.rowData[19])
// } else if (column == 22) {
// valuez = Number(tableMeta.rowData[15]) + Number(tableMeta.rowData[17]) + Number(tableMeta.rowData[20])
// } else if (column == 23) {
// valuez = Number(tableMeta.rowData[12]) - Number(tableMeta.rowData[21])
// } else if (column == 24) {
// valuez = Number(tableMeta.rowData[13]) - Number(tableMeta.rowData[22])
// }
// }
// dataTable2[tableMeta.rowIndex][column] = valuez
// return valuez
console.log(value);
let valuez = 0
if (tableMeta.rowData[0] == 8) {
dataTableInvestment.map((item, index) => {
if (item[6].value.includes(String(tableMeta.rowData[6].value).substr(6, tableMeta.rowData[6].length)) && item[0] != 8) {
valuez += Number(item[column])
}
})
} else {
dataTableInvestment.map((item, index) => {
if (item[0] == 8) {
valuez += Number(item[column])
}
})
}
dataTableInvestment[tableMeta.rowIndex][column] = valuez
return valuez
}
const handleTambah = (data, rowIndex) => {
console.log(dataTable2)
let newData = []
let indexxx = 0
dataTable2.map((item, index) => {
......@@ -2004,12 +2053,14 @@ export default class ListOfCreditFacilities extends Component {
// // console.log(dataTable2)
let newData = []
let indexxx = 0
dataTable2.map((item, index) => {
console.log(dataTableInvestment);
dataTableInvestment.map((item, index) => {
console.log(item, index);
indexxx = index
if (item[6] == "Grand Total") {
item[46] = 999999
item[16] = 999999
} else {
item[46] = indexxx
item[16] = indexxx
}
newData.push(item)
if (index == rowIndex) {
......@@ -2031,17 +2082,16 @@ export default class ListOfCreditFacilities extends Component {
"0",
"",
"",
"",
indexxx],
)
}
})
dataTable2 = newData.sort((a, b) => a[46] - b[46])
this.setState({ dataTable: dataTable2 }, () => {
dataTableInvestment = newData.sort((a, b) => a[16] - b[16])
this.setState({ dataTable: dataTableInvestment }, () => {
setTimeout(() => {
this.setState({ loading: false })
console.log(dataTable2)
console.log(dataTableInvestment)
}, 500)
})
}
......@@ -2105,6 +2155,65 @@ export default class ListOfCreditFacilities extends Component {
})
}
const handleDeleteInvesment = (index) => {
let dataDelete = this.state.dataDelete
let berapaInput = 0
dataTableInvestment.map((items, indexs) => {
if (items[0] == 3) {
berapaInput += 1
}
})
dataDelete.push(dataTableInvestment[index][1])
let prevData = dataTableInvestment[index - 1] == undefined ? null : dataTableInvestment[index - 1][6]
let currentData = dataTableInvestment[index][6]
let nextData = dataTableInvestment[index + 1] == undefined ? null : dataTableInvestment[index + 1][6]
if (nextData == null) {
dataTableInvestment.splice(index, 1)
} else if (nextData.value.includes('Total')) {
if (prevData !== null && currentData == null) {
dataTableInvestment.splice(index, 1)
} else if (prevData !== null && prevData.value == currentData.value) {
dataTableInvestment.splice(index, 1)
} else if (dataTableInvestment.length > 3) {
if (prevData == null) {
if (nextData.value.includes('Grand')) {
dataTableInvestment.splice(index, 1)
} else {
dataTableInvestment.splice(index, 2)
}
} else {
dataTableInvestment.splice(index, 2)
}
} else if (dataTableInvestment.length == 3) {
if (prevData == null) {
if (nextData.value.includes('Grand')) {
dataTableInvestment.splice(index, 1)
} else {
dataTableInvestment.splice(index, 3)
dataTableInvestment.push(
[3, "", "", "", "", this.props.company.company_name, "", null, "", null, "0.0", "0.0", "", "", "", "", 0],
[9, "", "", "", "", "", { value: "Grand Total" }, "", "", "", "", "", "", "", "", "notes", 999999],
)
}
} else {
dataTableInvestment.splice(index, 1)
}
}
} else {
dataTableInvestment.splice(index, 1)
}
this.setState({ dataTable: dataTableInvestment, dataDelete }, () => {
setTimeout(() => {
console.log(this.state.dataDelete)
this.setState({ loading: false })
}, 100)
})
}
let columnsLOCF = [
{
name: "",
......@@ -4260,10 +4369,8 @@ export default class ListOfCreditFacilities extends Component {
setCellProps: () => ({ style2 }),
customBodyRender: (val, tableMeta) => {
return (
// handleAction(tableMeta.rowData[2]) &&
<div style={{ display: 'flex' }}>
{/* {tableMeta.rowData[6] === "Active" ? */}
{handleAction(tableMeta.rowData[0], tableMeta, 'add') && <span>
{handleActionInvesment(tableMeta.rowData[0], tableMeta, 'addLov') && <span>
<LightTooltip title={'Add'} arrow>
<button
style={{
......@@ -4281,7 +4388,7 @@ export default class ListOfCreditFacilities extends Component {
</button>
</LightTooltip>
</span>}
{handleAction(tableMeta.rowData[0], tableMeta, 'delete') && <span>
{handleActionInvesment(tableMeta.rowData[0], tableMeta, 'delete') && <span>
<LightTooltip title={'Delete'} arrow>
<button
style={{
......@@ -4292,7 +4399,7 @@ export default class ListOfCreditFacilities extends Component {
}}
onClick={() => {
this.setState({ loading: true })
handleDelete(tableMeta.rowIndex)
handleDeleteInvesment(tableMeta.rowIndex)
}}
>
<img src={Images.delete} style={{ width: 37, height: 37 }} />
......@@ -4361,11 +4468,11 @@ export default class ListOfCreditFacilities extends Component {
{tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 || tableMeta.rowData[0] === 4 ?
null :
<Autocomplete
{...this.state.typeOfCreditList}
id="typeOfCreditList"
{...this.state.typeOfInvestmentList}
id="typeOfInvestmentList"
onChange={(event, newInputValue) => handleChangeInves(newInputValue, tableMeta, tableMeta.columnIndex)}
debug
value={handleValueDropDownInves(val, 'typeOfCreditList', tableMeta)}
value={handleValueDropDownInves(val, 'typeOfInvestmentList', tableMeta)}
disableClearable
disabled={this.state.get_for == 'view'}
// disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
......@@ -4602,30 +4709,26 @@ export default class ListOfCreditFacilities extends Component {
),
setCellProps: () => ({ style2 }),
customBodyRender: (val, tableMeta, updateValue) => {
// console.log(tableMeta);
return (
<div style={{ display: 'flex' }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] == 8 || tableMeta.rowData[0] == 9 ?
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 || tableMeta.rowData[0] === 4 ?
null :
<div style={{ padding: 0, margin: 0 }}>
<textarea disabled={this.state.get_for == 'view'} style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.state.get_for == 'view' ? "black" : "#5198ea", backgroundColor: tableMeta.rowData[12] == '' && this.state.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" defaultValue={tableMeta.rowData[12]}
onBlur={(event) => handleChangeInves(event.target.value, tableMeta, tableMeta.columnIndex)} />
<Autocomplete
{...this.state.currencyList}
id="currencyList"
onChange={(event, newInputValue) => handleChangeInves(newInputValue, tableMeta, tableMeta.columnIndex)}
debug
value={handleValueDropDownInves(val, 'currencyList', tableMeta)}
disableClearable
disabled={this.state.get_for == 'view'}
style={{ padding: 0, margin: 0 }}
renderInput={(params) =>
<div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
<textarea style={{ borderColor: 'white', width: 96, textAlign: 'center', justifyContent: 'center', padding: 0, margin: 0, color: this.state.get_for == 'view' ? "black" : "#5198ea", backgroundColor: tableMeta.rowData[12] == null && this.state.get_for == 'edit' ? '#ffac99' : 'white' }} type="text" {...params.inputProps} />
</div>
// <ThemeProvider theme={this.state.get_for == 'view'? theme3 : theme2}>
// <Input
// disableUnderline={true}
// style={{ width: 96, color: this.state.get_for == 'view'? "black" : "#5198ea", fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, backgroundColor: 'transparent', backgroundColor: tableMeta.rowData[11] == '' && this.state.get_for == 'edit'? '#ffac99' : 'white' }}
// type="text"
// placeholder=""
// disabled={this.state.get_for == 'view'}
// defaultValue={tableMeta.rowData[11]}
// onBlur={(event) => {
// // // // console.log(event.target.value)
// // updateValue(event.target.value)
// handleChange(event.target.value, tableMeta, tableMeta.columnIndex)
// // // // console.log(dataTable2)
// }}
// />
// </ThemeProvider>
}
/>
}
</div>
)
......@@ -4802,107 +4905,7 @@ export default class ListOfCreditFacilities extends Component {
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
},
]
const loadingComponent = (
......
......@@ -301,7 +301,7 @@ export default class MonthlyReport extends Component {
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......
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