Commit 933c822d authored by Riri Novita's avatar Riri Novita

lov

parent fbf6454e
......@@ -111,7 +111,7 @@ export default class LOV extends Component {
perBS: 0,
snekbar: false,
snekbarMsg: '',
visibleLOCFMR: true,
visibleLOVMR: true,
saveDraft: true,
saveComp: true,
get_for: 'view',
......@@ -144,9 +144,12 @@ export default class LOV extends Component {
this.getLatestUpdate()
this.handleViewOnly()
}
// if (this.props.dataTablelov !== prevProps.dataTablelov) {
// this.setState({ dataTable: this.props.dataTablelov})
// }
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) {
......@@ -210,17 +213,18 @@ export default class LOV extends Component {
let dataTable = []
if (response.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 currency = item.lov.currency
if (index == res.length - 1) {
if (indexIDzz === -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,
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,
......@@ -231,43 +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_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
// 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],
)
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
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)
this.setState({ dataTable, loading: false, visibleLOCFMR: true }, () => {
this.props.sendToParent(dataTable, 'LOV')
let lastArray = dataTable[res.length - 1]
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')
// })
// }
})
}
......@@ -381,7 +455,7 @@ export default class LOV extends Component {
console.log(response)
if (response.data) {
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 datas = response.data.data
console.log(datas.lov);
......@@ -1434,7 +1508,7 @@ export default class LOV extends Component {
})
}
let columnsLOV = [
let columns = [
{
name: "",
options: {
......@@ -1541,13 +1615,16 @@ export default class LOV extends Component {
customBodyRender: (val, tableMeta, updateValue) => {
return (
<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>
:
<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[0] == 9 ? tableMeta.rowData[6].value : tableMeta.rowData[6]}
onBlur={(event) => handleChange(event.target.value, tableMeta, tableMeta.columnIndex)} />
</div>
tableMeta.rowData[0] == 9 ?
<Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{val}</Typography>
:
<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>
)
......@@ -1598,6 +1675,7 @@ export default class LOV extends Component {
),
setCellProps: () => ({ style2 }),
customBodyRender: (val, tableMeta, updateValue) => {
console.log(tableMeta);
return (
<div style={{ textAlign: 'left', width: 90 }}>
{tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
......@@ -1845,33 +1923,51 @@ export default class LOV extends Component {
),
setCellProps: () => ({ style2 }),
customBodyRender: (val, tableMeta, updateValue) => {
// console.log(tableMeta);
return (
<div className="col-1">
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
{tableMeta.rowData[0] === 4 ?
null :
<div style={{ flex: 1 }}>
<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) : Number(tableMeta.rowData[13]) == 0 ? "0.0" : Number(tableMeta.rowData[13])}
onBlur={(event) => {
handleChange(event.target.value, tableMeta, 13)
}}
/>
}
/>
</div>
tableMeta.rowData[0] === 8 || tableMeta.rowData[0] === 9 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, paddingBottom: 18, textAlign: 'right', fontWeight: 'bold', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[13]), 1) : Number(tableMeta.rowData[13]) == 0 ? "0.0" : Number(tableMeta.rowData[13])}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}>
<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>
......@@ -1888,7 +1984,6 @@ export default class LOV extends Component {
),
setCellProps: () => ({ style2 }),
customBodyRender: (val, tableMeta, updateValue) => {
// console.log(tableMeta);
return (
<div className="col-1">
<div style={{ textAlign: 'right', width: 90 }}>
......@@ -1908,7 +2003,7 @@ export default class LOV extends Component {
disabled={true}
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(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])}
/>
}
/>
......@@ -2015,7 +2110,7 @@ export default class LOV extends Component {
return (
<div>
{this.state.visibleLOCFMR ?
{this.state.visibleLOVMR ?
<div style={{ padding: 20 }}>
<Snackbar open={this.state.snekbar} autoHideDuration={6000} onClose={handleClose}>
<Alert onClose={handleClose} severity="error">
......@@ -2103,7 +2198,7 @@ export default class LOV extends Component {
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columnsLOV}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
......@@ -2207,7 +2302,7 @@ export default class LOV extends Component {
{this.state.dataLoaded && !this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columnsLOV}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
......
......@@ -152,7 +152,7 @@ export default class ListOfCreditFacilities extends Component {
dataTableForChild(data, array, params, type) {
switch (params) {
case "LOV":
this.setState({ dataTableLOV: data,})
this.setState({ dataTableLOV: data, })
break;
case "LOCF":
this.setState({ dataTableLOCF: data, diff: array[46], perBS: array[48], tambah: type})
......
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