Commit cc68ef05 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'faisal' into 'master'

update fam preview upload

See merge request !390
parents bc515672 f0e9a94f
...@@ -3,8 +3,6 @@ import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormCon ...@@ -3,8 +3,6 @@ import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormCon
import MUIDataTable from 'mui-datatables'; import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import api from '../../api'; import api from '../../api';
import AddIcon from '@material-ui/icons/Add';
import { values } from 'ramda';
import PropagateLoader from "react-spinners/PropagateLoader" import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images'; import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
...@@ -87,9 +85,8 @@ export default class FixedAssetsMovement extends Component { ...@@ -87,9 +85,8 @@ export default class FixedAssetsMovement extends Component {
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
"submission_id": this.props.submissionID "submission_id": this.props.submissionID
} }
// 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
...@@ -220,7 +217,6 @@ export default class FixedAssetsMovement extends Component { ...@@ -220,7 +217,6 @@ export default class FixedAssetsMovement extends Component {
total_next_year: String(Number(i[20]).toFixed(1)), total_next_year: String(Number(i[20]).toFixed(1)),
total_more_year: String(Number(i[21]).toFixed(1)) total_more_year: String(Number(i[21]).toFixed(1))
}) })
}) })
let payload = { let payload = {
"submission_id": this.props.submissionID, "submission_id": this.props.submissionID,
...@@ -287,12 +283,10 @@ export default class FixedAssetsMovement extends Component { ...@@ -287,12 +283,10 @@ export default class FixedAssetsMovement extends Component {
} }
}) })
let body = { let body = {
submission_id: this.props.submissionID,
company_id: this.props.company.company_id, company_id: this.props.company.company_id,
periode: this.props.periode, periode: this.props.periode,
report_id: this.props.report_id, report_id: this.props.report_id,
fixed_asset_movement: payload fixed_asset_movement: payload
} }
console.log(body) console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] }) this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
...@@ -337,7 +331,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -337,7 +331,7 @@ export default class FixedAssetsMovement extends Component {
}) })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[22].length > 0) { if (item[23].length > 0) {
console.log('masuk') console.log('masuk')
this.setState({ buttonError: true, errorPreview: true }) this.setState({ buttonError: true, errorPreview: true })
} }
...@@ -354,22 +348,22 @@ export default class FixedAssetsMovement extends Component { ...@@ -354,22 +348,22 @@ export default class FixedAssetsMovement extends Component {
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
item_report_id: i[1], item_report_id: i[1],
total_actual_before: String(i[6]), total_actual_before: String(Number(i[6]).toFixed(1)),
january: String(i[7]), january: String(Number(i[7]).toFixed(1)),
february: String(i[8]), february: String(Number(i[8]).toFixed(1)),
march: String(i[9]), march: String(Number(i[9]).toFixed(1)),
april: String(i[10]), april: String(Number(i[10]).toFixed(1)),
may: String(i[11]), may: String(Number(i[11]).toFixed(1)),
june: String(i[12]), june: String(Number(i[12]).toFixed(1)),
july: String(i[13]), july: String(Number(i[13]).toFixed(1)),
august: String(i[14]), august: String(Number(i[14]).toFixed(1)),
september: String(i[15]), september: String(Number(i[15]).toFixed(1)),
october: String(i[16]), october: String(Number(i[16]).toFixed(1)),
november: String(i[17]), november: String(Number(i[17]).toFixed(1)),
december: String(i[18]), december: String(Number(i[18]).toFixed(1)),
total_current_year: String(i[19]), total_current_year: String(Number(i[19]).toFixed(1)),
total_next_year: String(i[20]), total_next_year: String(Number(i[20]).toFixed(1)),
total_more_year: String(i[21]) total_more_year: String(Number(i[21]).toFixed(1))
}) })
}) })
let body = { let body = {
...@@ -380,7 +374,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -380,7 +374,7 @@ export default class FixedAssetsMovement extends Component {
fixed_asset_movement: data, fixed_asset_movement: data,
status: type status: type
} }
console.log(data); // console.log(data);
api.create('UPLOAD').uploadMasterBudget(body).then(response => { api.create('UPLOAD').uploadMasterBudget(body).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
...@@ -391,6 +385,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -391,6 +385,7 @@ export default class FixedAssetsMovement extends Component {
alert(response.data.status) alert(response.data.status)
} }
} else { } else {
this.setState({ loading: false })
alert(response.problem) alert(response.problem)
} }
}) })
...@@ -415,7 +410,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -415,7 +410,7 @@ export default class FixedAssetsMovement extends Component {
handleValidate() { handleValidate() {
let data = [] let data = []
console.log(this.state.dataTable) // console.log(this.state.dataTable)
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
item_report_id: i[1], item_report_id: i[1],
...@@ -446,7 +441,6 @@ export default class FixedAssetsMovement extends Component { ...@@ -446,7 +441,6 @@ export default class FixedAssetsMovement extends Component {
"fixed_asset_movement": data, "fixed_asset_movement": data,
"status": "submitted" "status": "submitted"
} }
// console.log(payload)
api.create().validateSubmitReport(payload).then((response) => { api.create().validateSubmitReport(payload).then((response) => {
console.log(response) console.log(response)
if (response.data.data.result) { if (response.data.data.result) {
...@@ -465,7 +459,6 @@ export default class FixedAssetsMovement extends Component { ...@@ -465,7 +459,6 @@ export default class FixedAssetsMovement extends Component {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta, type) => { const handleChange = (value, tableMeta, type) => {
let val = String(value).split(",").join("") let val = String(value).split(",").join("")
// let data = this.state.dataTable2
if (type === "actual") { if (type === "actual") {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
} else { } else {
...@@ -556,7 +549,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -556,7 +549,7 @@ export default class FixedAssetsMovement extends Component {
"formula": rilFormula "formula": rilFormula
} }
api.create().countingFormula(body).then(response => { api.create().countingFormula(body).then(response => {
// console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
setTimeout(() => { setTimeout(() => {
...@@ -647,9 +640,8 @@ export default class FixedAssetsMovement extends Component { ...@@ -647,9 +640,8 @@ 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[23] ?
{tableMeta.rowData[22] ? tableMeta.rowData[23].length > 0 ?
tableMeta.rowData[22].length > 0 ?
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}> <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<LightTooltip title={"Report Items Not Registered"} arrow> <LightTooltip title={"Report Items Not Registered"} arrow>
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span> <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
...@@ -2202,20 +2194,24 @@ export default class FixedAssetsMovement extends Component { ...@@ -2202,20 +2194,24 @@ export default class FixedAssetsMovement extends Component {
</div> </div>
)} )}
</div> </div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button <button
type="button" type="button"
onClick={() => this.setState({ visibleFixedAssetsMovement: true }, () => { onClick={() => this.setState({ loading: true, visibleFixedAssetsMovement: true }, () => {
setTimeout(() => { setTimeout(() => {
this.getItemHierarki() this.getItemHierarki()
}, 100); }, 100);
})} })}
style={{ marginRight: 20 }} style={{ marginRight: 20 }}
> >
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#019ce5', 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: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button <button
className="button" className="button"
type="button" type="button"
...@@ -2235,7 +2231,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -2235,7 +2231,7 @@ export default class FixedAssetsMovement extends Component {
}) })
}} }}
> >
<div style={{ backgroundColor: '#fff', 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: '#354960', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div> </div>
</button> </button>
...@@ -2244,14 +2240,29 @@ export default class FixedAssetsMovement extends Component { ...@@ -2244,14 +2240,29 @@ export default class FixedAssetsMovement extends Component {
disabled={this.state.buttonError} disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => { onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.uploadFAM() this.uploadFAM('draft')
}, 100); }, 100);
})} })}
style={{ marginRight: 20 }}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
</div> </div>
</button> </button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadFAM('submitted')
}, 100);
})}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
</div>
</button>
</div>
</div> </div>
</div> </div>
</Paper>} </Paper>}
......
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