Commit f629a31f authored by Deni Rinaldi's avatar Deni Rinaldi

test

parent 575df2c7
......@@ -259,6 +259,7 @@ const create = (type = "") => {
const getHierarkiMontlyReportTP = (body) => api.post('transaction/monthly_report_tp/get_report_hierarki', body)
const getHierarkiMontlyReportLOCF = (body) => api.post('transaction/monthly_report_locf/get_report_hierarki', body)
const getHierarkiMontlyReportFAM = (body) => api.post('transaction/monthly_report/fam/get_report_hierarki', body)
const getHierarkiMontlyReportCF = (body) => api.post('transaction/monthly_report_cf/get_report_hierarki', body)
const getHierarkiMontlyReportCAT = (body) => api.post('/transaction/monthly_report/cat/get_report_hierarki', body)
const getLastPeriodMonthly = (idCompany) => api.get(`transaction/monthly_report/get_last_periode/${idCompany}`)
const checkApproverMonthly = () => api.get('transaction/monthly_report/is_approver')
......@@ -496,7 +497,8 @@ const create = (type = "") => {
checkUploadMonthlyReportBS,
uploadMonthlyReportBS,
uploadMonthlyReportFAM,
uploadMonthlyReportTP
uploadMonthlyReportTP,
getHierarkiMontlyReportCF
}
}
......
......@@ -51,11 +51,227 @@ export default class CashFlowMR extends Component {
}
}
componentDidMount() {
this.getItemHierarki()
// this.getSettingControl()
}
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
}
api.create().getHierarkiMontlyReportCF(payload).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)
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
{ value: item.cash_flow.actual, formula: item.cash_flow.actual_formula },
item.order,
])
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
{ value: item.cash_flow.actual, formula: item.cash_flow.actual_formula },
item.order,
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
this.setState({ dataTable, loading: false })
}
})
}
render() {
let dataTable = [
["1", "2", "2", "2", "2", "2", "3"],
["1", "2", "2", "2", "2", "2", "3"],
]
let dataTable2 = this.state.dataTable
const handleValueFormula = (value, tableMeta, column, periode, forecast) => {
let splitFormula = String(tableMeta.rowData[3]).split('@')
let baru = []
let anjay = []
splitFormula.map((item, index) => {
let items = String(item).substr(Number(String(item).length) - 1, 1)
let re = /^[a-zA-Z0-9]+$/;
let asd = ''
if (item !== "") {
if (!re.test(items)) {
if (String(item).substr(Number(String(item).length) - 1, 1) === ']') {
baru.push(String(item))
} else {
baru.push(String(item).substr(0, Number(String(item).length) - 1))
baru.push(String(item).substr(Number(String(item).length) - 1, 1))
}
} else {
baru.push(String(item))
}
}
})
// if (tableMeta.columnIndex == 7) {
// console.log(splitFormula)
// console.log(baru)
// }
// console.log(baru)
baru.map((item, index) => {
if (item == '-' || item == '+' || item == '/' || item == '*') {
anjay.push(item)
} else {
if (String(item).includes('#')) {
if (forecast !== undefined) {
let forecastt = 0
forecast.map((items, index) => {
if (items.periode == periode) {
forecastt += Number(items.value)
}
})
anjay.push(forecastt)
} else if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
let data = tableMeta.columnIndex == 7 ? 18 : tableMeta.columnIndex - 1
let period = data == 18 ? Number(this.props.periode) - 1 : this.props.periode
// console.log(tableMeta.columnIndex)
let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
// console.log(indexID)
if (indexID !== -1) {
let valuezz = tableMeta.rowData[data].formula[indexID].value
// baru.push(valuezz)
anjay.push(valuezz == "" ? 0 : valuezz)
// console.log(valuezz)
}
} else {
// console.log(baru);
// console.log(value);
let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
// console.log(indexID)
if (indexID !== -1) {
// console.log(value.formula[indexID].value)
let valuezz = value.formula[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
} else if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
if (tableMeta.columnIndex === 7 || tableMeta.columnIndex === 19) {
let indexID = dataTable2.findIndex((val) => val[22] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][6]
anjay.push(valuezz == "" ? 0 : valuezz)
}
// } else if (tableMeta.columnIndex === 19) {
// let indexID = dataTable2.findIndex((val) => val[22] == tst)
// if (indexID !== -1) {
// let valuezz = dataTable2[indexID][7].value !== undefined ? dataTable2[indexID][7].value : dataTable2[indexID][7]
// anjay.push(valuezz == "" ? 0 : valuezz)
// }
} else {
let data = tableMeta.columnIndex - 1
let indexID = dataTable2.findIndex((val) => val[7] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][data].value !== undefined ? dataTable2[indexID][data].value : dataTable2[indexID][data]
anjay.push(valuezz == "" ? 0 : valuezz)
}
// console.log(tst, data, tableMeta.rowData[data]);
}
} else {
let indexID = dataTable2.findIndex((val) => val[7] == item)
// console.log(dataTable2[indexID])
if (indexID !== -1) {
let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
anjay.push(valuezz == "" ? 0 : valuezz)
} else {
if (item === '(-1)') {
anjay.push(-1)
}
// console.log(item);
}
}
}
})
// console.log(baru)
// console.log(anjay)
let total = 0
let opt = ""
anjay.map((item, index) => {
if (item == "+") {
opt = "tambah"
} else if (item == "-") {
opt = "kurang"
} else if (item == "*") {
opt = "kali"
} else if (item == "/") {
opt = "bagi"
} else {
item = item == "" ? 0 : item
if (opt == "tambah") {
total = Number(total) + Number(item)
} else if (opt == "kurang") {
total = Number(total) - Number(item)
} else if (opt == "kali") {
total = Number(total) * Number(item)
} else if (opt == "bagi") {
total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
} else {
total += Number(item)
}
}
})
total = R.equals(total, NaN) ? "0.0" : total
// console.log(dataTable2[tableMeta.rowIndex][22])
// console.log(tableMeta.rowData[5])
// if (tableMeta.rowData[5] == 'Beginning Balance') {
// console.log(baru)
// console.log(anjay)
// console.log(total)
// }
// if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
// // console.log([tableMeta.rowIndex][tableMeta.columnIndex])
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
// } else {
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
// }
return total
}
let columns = [
{
name: "",
......@@ -129,9 +345,9 @@ export default class CashFlowMR extends Component {
// <TableCell style={{ ...style2, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 96 }}>
// <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
// </TableCell> :
<TableCell style={{ ...style2, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 96 }}>
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell>
<TableCell style={{ ...style2, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 96 }}>
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell>
),
setCellProps: () => ({
style: {
......@@ -142,14 +358,21 @@ export default class CashFlowMR extends Component {
}
}),
customBodyRender: (value, tableMeta, updateValue) => {
console.log(tableMeta);
return (
<div style={{ textAlign: 'right' }}>
{value}
{null}
</div>
)
}
}
}
},
{
name: "",
options: {
display: false
}
},
]
const loadingComponent = (
......@@ -210,7 +433,7 @@ export default class CashFlowMR extends Component {
{!this.state.loading && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable}
data={dataTable2}
columns={columns}
options={options}
/>
......
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