Commit c87d4e0a authored by faisalhamdi's avatar faisalhamdi

fixed formula

parent fde3083b
...@@ -89,7 +89,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -89,7 +89,7 @@ export default class FixedAssetsMovement extends Component {
} }
// console.log(payload); // console.log(payload);
api.create().getDetailReportMB(payload).then(response => { api.create().getDetailReportMB(payload).then(response => {
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
...@@ -500,7 +500,60 @@ export default class FixedAssetsMovement extends Component { ...@@ -500,7 +500,60 @@ export default class FixedAssetsMovement extends Component {
// console.log(indexParent); // console.log(indexParent);
return a return a
} }
const handleFormula = (data, tableMeta) => { const handleFormula = (data, tableMeta, month) => {
let rilFormula = String(tableMeta.rowData[3])
if (rilFormula.includes("#")) {
if (this.props.status === "not-yet") {
let splitOrder = String(tableMeta.rowData[3]).split('@')
for (let index = 0; index < splitOrder.length; index++) {
if (splitOrder[index] === "") {
} else {
if (splitOrder[index].includes('#')) {
} else {
let splitOperator = splitOrder[index].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let reg = /^\d+$/
splitOperator.map((item) => {
if (reg.test(item) === true) {
let i = dataTable2.findIndex((val) => val[23] == item)
if (i > 0) {
rilFormula = rilFormula.replace(item, dataTable2[i][tableMeta.columnIndex] === "" ? "0" : dataTable2[i][tableMeta.columnIndex])
}
}
})
}
}
}
let body = {
"submission_id": null,
"company_id": this.props.company.company_id,
"report_id": this.props.report_id,
"year": this.props.periode,
"month": month,
"formula": rilFormula
}
api.create().countingFormula(body).then(response => {
console.log(response);
})
} else {
let body = {
"submission_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"report_id": this.props.report_id,
"year": this.props.periode,
"month": month,
"formula": rilFormula
}
api.create().countingFormula(body).then(response => {
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
return response.data.data.result
}
}
})
}
} else {
let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g) let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let arrayJumlah = [] let arrayJumlah = []
arrayFormula.map((item, indexs) => { arrayFormula.map((item, indexs) => {
...@@ -542,7 +595,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -542,7 +595,7 @@ export default class FixedAssetsMovement extends Component {
}) })
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
return a return a
}
} }
const columns = [{ const columns = [{
name: "", name: "",
...@@ -581,6 +634,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -581,6 +634,7 @@ export default class FixedAssetsMovement extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ width: 300 }}> <div style={{ width: 300 }}>
{/* {console.log(tableMeta.rowData)} */}
{tableMeta.rowData[22] ? {tableMeta.rowData[22] ?
tableMeta.rowData[22].length > 0 ? tableMeta.rowData[22].length > 0 ?
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}> <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
...@@ -691,15 +745,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -691,15 +745,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 1)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -780,15 +833,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -780,15 +833,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 2)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -869,15 +921,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -869,15 +921,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 3)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -958,15 +1009,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -958,15 +1009,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 4)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1047,15 +1097,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1047,15 +1097,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 5)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1136,15 +1185,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1136,15 +1185,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 6)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1225,15 +1273,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1225,15 +1273,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 7)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1314,15 +1361,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1314,15 +1361,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 8)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1403,15 +1449,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1403,15 +1449,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 9)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1492,15 +1537,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1492,15 +1537,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 10)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1581,15 +1625,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1581,15 +1625,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 11)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1670,15 +1713,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1670,15 +1713,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 12)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1797,15 +1839,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1797,15 +1839,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 12)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -1886,15 +1927,14 @@ export default class FixedAssetsMovement extends Component { ...@@ -1886,15 +1927,14 @@ export default class FixedAssetsMovement extends Component {
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={handleFormula(value, tableMeta)} value={Number(handleFormula(value, tableMeta, 12)).toFixed(1)}
// /> />
null
: :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 ?
// <NumberFormat // <NumberFormat
...@@ -2046,7 +2086,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -2046,7 +2086,7 @@ export default class FixedAssetsMovement extends Component {
}, 100); }, 100);
})} })}
> >
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}> <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
...@@ -2071,8 +2111,8 @@ export default class FixedAssetsMovement extends Component { ...@@ -2071,8 +2111,8 @@ export default class FixedAssetsMovement extends Component {
}) })
}} }}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div> </div>
</button> </button>
<button <button
...@@ -2159,7 +2199,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -2159,7 +2199,7 @@ export default class FixedAssetsMovement extends Component {
})} })}
style={{ marginRight: 20 }} style={{ marginRight: 20 }}
> >
<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' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
...@@ -2182,8 +2222,8 @@ export default class FixedAssetsMovement extends Component { ...@@ -2182,8 +2222,8 @@ export default class FixedAssetsMovement extends Component {
}) })
}} }}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div> </div>
</button> </button>
<button <button
......
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