Commit 93cac74f authored by Faisal Hamdi's avatar Faisal Hamdi

Merge branch 'faisal' into 'master'

update string includes

See merge request !703
parents 4cc07854 b4007660
...@@ -206,6 +206,43 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -206,6 +206,43 @@ export default class FixedAssetsMovementMR extends Component {
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta, type) => {
let val = String(value).split(",").join("")
if (type === "actual") {
dataTable2[tableMeta.rowIndex][8] = Number(val).toFixed(1)
} else {
let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
if (indexParent > 0) {
// console.log(indexParent)
dataTable2[tableMeta.rowIndex][9] = Number(val).toFixed(1)
let jagain = Number(dataTable2[indexParent][8]).toFixed(1)
dataTable2[indexParent][9] = jagain === undefined ? (0 + Number(val)).toFixed(1) : Number(Number(jagain) + Number(val)).toFixed(1)
// if (tableMeta.rowData[5] === 'Cash & Bank Balance') {
// console.log(value);
// console.log(a);
// console.log(jagain);
// console.log(dataTable2[indexParent]);
// }
} else {
dataTable2[tableMeta.rowIndex][8] = Number(val).toFixed(1)
}
}
}
const handleValue = (data, type) => {
let total = 0
dataTable2.map((item, index) => {
if (data.rowData[1] === item[2]) {
let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type])
total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal
}
})
let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
// console.log(indexParent);
return total
}
const handleValueFormula = (data, type) => { const handleValueFormula = (data, type) => {
let total = 0 let total = 0
dataTable2.map((item, index) => { dataTable2.map((item, index) => {
...@@ -263,7 +300,6 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -263,7 +300,6 @@ export default class FixedAssetsMovementMR extends Component {
customBodyRender: (value, tableMeta) => { customBodyRender: (value, tableMeta) => {
return ( return (
<div style={{ width: 300 }}> <div style={{ width: 300 }}>
{console.log(tableMeta)}
{tableMeta.rowData[24] ? {tableMeta.rowData[24] ?
tableMeta.rowData[24].length > 0 ? tableMeta.rowData[24].length > 0 ?
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}> <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
...@@ -322,35 +358,46 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -322,35 +358,46 @@ export default class FixedAssetsMovementMR extends Component {
{ {
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 3 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <div style={{ flex: 1 }}>
<NumberFormat <FormControlLabel
thousandSeparator={true} style={{ margin: 0 }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} value={value}
type="text" control={
placeholder="" <NumberFormat
disabled={true} thousandSeparator={true}
value={Number(handleValueFormula(tableMeta, 0)).toFixed(1)} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[6]).toFixed(1)}
/>
}
/> />
</span> : </div> :
tableMeta.rowData[0] === 3 ? tableMeta.rowData[0] === 5 ?
<div style={{ flex: 1 }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<FormControlLabel <NumberFormat
style={{ margin: 0 }} thousandSeparator={true}
value={value} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
control={ type="text"
<NumberFormat placeholder=""
thousandSeparator={true} disabled={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} value={Number(handleValue(tableMeta, 0)).toFixed(1)}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[6]).toFixed(1)}
/>
}
/> />
</div> : </span> :
null tableMeta.rowData[0] === 6 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 0)).toFixed(1)}
/>
</span> :
null
} }
</div> </div>
</div> </div>
...@@ -367,7 +414,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -367,7 +414,7 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValueFormula(tableMeta, 0)).toFixed(1)} value={Number(handleValueFormula(tableMeta, 1)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 3 ? tableMeta.rowData[0] === 3 ?
...@@ -395,18 +442,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -395,18 +442,7 @@ export default class FixedAssetsMovementMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{ {
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(tableMeta, 0)).toFixed(1)}
/>
</span> :
tableMeta.rowData[0] === 3 ? tableMeta.rowData[0] === 3 ?
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
...@@ -415,16 +451,41 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -415,16 +451,41 @@ export default class FixedAssetsMovementMR extends Component {
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={false}
value={Number(tableMeta.rowData[8]).toFixed(1)} value={Number(tableMeta.rowData[8]).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
/> />
} }
/> />
</div> : </div> :
null tableMeta.rowData[0] === 5 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 2)).toFixed(1)}
/>
</span> :
tableMeta.rowData[0] === 6 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValue(tableMeta, 2)).toFixed(1)}
/>
</span> :
null
} }
</div> </div>
</div> </div>
......
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