Commit a7e016d9 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'riri' into 'master'

apdet issue

See merge request !370
parents 10d4bf81 d84c78d7
...@@ -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, type } 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';
...@@ -46,7 +44,8 @@ export default class ProfitLoss extends Component { ...@@ -46,7 +44,8 @@ export default class ProfitLoss extends Component {
disabledSave: true, disabledSave: true,
editable: false, editable: false,
buttonError: false, buttonError: false,
judulColumn: null judulColumn: null,
updateBy: '-'
} }
this.handleValue = this.handleValue.bind(this) this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -54,9 +53,29 @@ export default class ProfitLoss extends Component { ...@@ -54,9 +53,29 @@ export default class ProfitLoss extends Component {
componentDidMount() { componentDidMount() {
this.getItemHierarki() this.getItemHierarki()
this.getLatestUpdate()
console.log(this.props); console.log(this.props);
} }
getLatestUpdate() {
let payload = {
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID
}
api.create().getLastestUpdateMB(payload).then(response => {
if (response.data) {
if (response.data.status === "success") {
this.setState({
updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update
})
}
}
})
}
getItemHierarki() { getItemHierarki() {
this.setState({ loading: true, judulColumn: null }) this.setState({ loading: true, judulColumn: null })
let payload = { let payload = {
...@@ -71,7 +90,6 @@ export default class ProfitLoss extends Component { ...@@ -71,7 +90,6 @@ export default class ProfitLoss extends Component {
let dataTable = [] let dataTable = []
if (response.data) { if (response.data) {
let res = response.data.data let res = response.data.data
console.log(res)
const handlePushChild = (item) => { const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) { if (indexIDzz === -1) {
...@@ -184,22 +202,22 @@ export default class ProfitLoss extends Component { ...@@ -184,22 +202,22 @@ export default class ProfitLoss extends Component {
data.push({ data.push({
item_report_id: i[1], item_report_id: i[1],
notes: i[6] == null || i[6] == "" ? "" : String(i[6]), notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
total_actual_before: String(i[7]), total_actual_before: String(Number(i[7]).toFixed(1)),
january: String(i[8]), january: String(Number(i[8]).toFixed(1)),
february: String(i[9]), february: String(Number(i[9]).toFixed(1)),
march: String(i[10]), march: String(Number(i[10]).toFixed(1)),
april: String(i[11]), april: String(Number(i[11]).toFixed(1)),
may: String(i[12]), may: String(Number(i[12]).toFixed(1)),
june: String(i[13]), june: String(Number(i[13]).toFixed(1)),
july: String(i[14]), july: String(Number(i[14]).toFixed(1)),
august: String(i[15]), august: String(Number(i[15]).toFixed(1)),
september: String(i[16]), september: String(Number(i[16]).toFixed(1)),
october: String(i[17]), october: String(Number(i[17]).toFixed(1)),
november: String(i[18]), november: String(Number(i[18]).toFixed(1)),
december: String(i[19]), december: String(Number(i[19]).toFixed(1)),
total_current_year: String(i[20]), total_current_year: String(Number(i[20]).toFixed(1)),
total_next_year: String(i[21]), total_next_year: String(Number(i[21]).toFixed(1)),
total_more_year: String(i[22]) total_more_year: String(Number(i[22]).toFixed(1))
}) })
}) })
let payload = { let payload = {
...@@ -210,7 +228,7 @@ export default class ProfitLoss extends Component { ...@@ -210,7 +228,7 @@ export default class ProfitLoss extends Component {
"status": type, "status": type,
"profit_loss": data "profit_loss": data
} }
console.log(data); // console.log(data);
this.props.saveToMasterBudget(payload) this.props.saveToMasterBudget(payload)
this.props.onClickClose() this.props.onClickClose()
} }
...@@ -225,7 +243,7 @@ export default class ProfitLoss extends Component { ...@@ -225,7 +243,7 @@ export default class ProfitLoss extends Component {
let url = window.URL.createObjectURL(res); let url = window.URL.createObjectURL(res);
let a = document.createElement('a'); let a = document.createElement('a');
a.href = url; a.href = url;
a.download = 'Template Profit Loss.xlsx'; a.download = 'Template Master Budget Profit & Loss.xlsx';
a.click(); a.click();
} }
} }
...@@ -321,35 +339,35 @@ export default class ProfitLoss extends Component { ...@@ -321,35 +339,35 @@ export default class ProfitLoss extends Component {
this.setState({ buttonError: true, errorPreview: true }) this.setState({ buttonError: true, errorPreview: true })
} }
}) })
// console.log(dataTable) // console.log(this.state.buttonError)
}) })
} }
} }
}) })
} }
uploadProfitLoss() { uploadProfitLoss(type) {
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
item_report_id: i[1], item_report_id: i[1],
notes: String(i[6]), notes: String(i[6]),
total_actual_before: String(i[7]), total_actual_before: String(Number(i[7]).toFixed(1)),
january: String(i[8]), january: String(Number(i[8]).toFixed(1)),
february: String(i[9]), february: String(Number(i[9]).toFixed(1)),
march: String(i[10]), march: String(Number(i[10]).toFixed(1)),
april: String(i[11]), april: String(Number(i[11]).toFixed(1)),
may: String(i[12]), may: String(Number(i[12]).toFixed(1)),
june: String(i[13]), june: String(Number(i[13]).toFixed(1)),
july: String(i[14]), july: String(Number(i[14]).toFixed(1)),
august: String(i[15]), august: String(Number(i[15]).toFixed(1)),
september: String(i[16]), september: String(Number(i[16]).toFixed(1)),
october: String(i[17]), october: String(Number(i[17]).toFixed(1)),
november: String(i[18]), november: String(Number(i[18]).toFixed(1)),
december: String(i[19]), december: String(Number(i[19]).toFixed(1)),
total_current_year: String(i[20]), total_current_year: String(Number(i[20]).toFixed(1)),
total_next_year: String(i[21]), total_next_year: String(Number(i[21]).toFixed(1)),
total_more_year: String(i[22]) total_more_year: String(Number(i[22]).toFixed(1)),
}) })
}) })
let body = { let body = {
...@@ -357,10 +375,10 @@ export default class ProfitLoss extends Component { ...@@ -357,10 +375,10 @@ export default class ProfitLoss extends Component {
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,
profit_loss: data profit_loss: data,
status: type
} }
console.log(data); console.log(data);
// console.log(JSON.stringify(body));
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) {
...@@ -371,15 +389,17 @@ export default class ProfitLoss extends Component { ...@@ -371,15 +389,17 @@ export default class ProfitLoss extends Component {
alert(response.data.status) alert(response.data.status)
} }
} else { } else {
alert(response.problem)
this.setState({loading: false}) this.setState({loading: false})
this.props.onClickClose() alert(response.problem)
this.props.getReport() // this.props.onClickClose()
// this.props.getReport()
} }
}) })
} }
async downloadAllData() { async downloadAllData() {
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
console.log(url);
let res = await fetch( let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}` `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
) )
...@@ -389,33 +409,34 @@ export default class ProfitLoss extends Component { ...@@ -389,33 +409,34 @@ export default class ProfitLoss extends Component {
let url = window.URL.createObjectURL(res); let url = window.URL.createObjectURL(res);
let a = document.createElement('a'); let a = document.createElement('a');
a.href = url; a.href = url;
a.download = 'Profit Loss.xlsx'; a.download = 'Master Budget Profit & Loss.xlsx';
a.click(); a.click();
} }
} }
handleValidate() { handleValidate() {
let data = [] let data = []
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],
notes: i[6] == null || i[6] == "" ? "" : String(i[6]), notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
total_actual_before: String(i[7]), total_actual_before: String(i[7]),
january: String(i[8]), january: i[0] === 3 && i[8] === "" ? "0" : String(i[8]),
february: String(i[9]), february: i[0] === 3 && i[9] === "" ? "0" : String(i[9]),
march: String(i[10]), march: i[0] === 3 && i[10] === "" ? "0" : String(i[10]),
april: String(i[11]), april: i[0] === 3 && i[11] === "" ? "0" : String(i[11]),
may: String(i[12]), may: i[0] === 3 && i[12] === "" ? "0" : String(i[12]),
june: String(i[13]), june: i[0] === 3 && i[13] === "" ? "0" : String(i[13]),
july: String(i[14]), july: i[0] === 3 && i[14] === "" ? "0" : String(i[14]),
august: String(i[15]), august: i[0] === 3 && i[15] === "" ? "0" : String(i[15]),
september: String(i[16]), september: i[0] === 3 && i[16] === "" ? "0" : String(i[16]),
october: String(i[17]), october: i[0] === 3 && i[17] === "" ? "0" : String(i[17]),
november: String(i[18]), november: i[0] === 3 && i[18] === "" ? "0" : String(i[18]),
december: String(i[19]), december: i[0] === 3 && i[19] === "" ? "0" : String(i[19]),
total_current_year: String(i[20]), total_current_year: i[0] === 3 && i[20] === "" ? "0" : String(i[20]),
total_next_year: String(i[21]), total_next_year: i[0] === 3 && i[21] === "" ? "0" : String(i[21]),
total_more_year: String(i[22]) total_more_year: i[0] === 3 && i[22] === "" ? "0" : String(i[22])
}) })
}) })
let payload = { let payload = {
...@@ -423,9 +444,10 @@ export default class ProfitLoss extends Component { ...@@ -423,9 +444,10 @@ export default class ProfitLoss extends Component {
"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,
"status": type, "profit_loss": data,
"profit_loss": data "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) {
...@@ -436,11 +458,14 @@ export default class ProfitLoss extends Component { ...@@ -436,11 +458,14 @@ export default class ProfitLoss extends Component {
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
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 {
...@@ -464,8 +489,15 @@ export default class ProfitLoss extends Component { ...@@ -464,8 +489,15 @@ export default class ProfitLoss extends Component {
total += Number(valItem) total += Number(valItem)
} }
}) })
dataTable2[tableMeta.rowIndex][20] = total if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "sales price" ) {
return total dataTable2[tableMeta.rowIndex][20] = Number(dataTable2[tableMeta.rowIndex - 2][20]) / Number(dataTable2[tableMeta.rowIndex - 1][20])
let value = Number(dataTable2[tableMeta.rowIndex - 2][20]) / Number(dataTable2[tableMeta.rowIndex - 1][20])
return value
} else {
dataTable2[tableMeta.rowIndex][20] = total
return total
}
// console.log(total); // console.log(total);
} }
const handleNotes = (value, tableMeta) => { const handleNotes = (value, tableMeta) => {
...@@ -656,7 +688,7 @@ export default class ProfitLoss extends Component { ...@@ -656,7 +688,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={value} value={Number(value).toFixed(1)}
/> />
} }
/> />
...@@ -689,7 +721,7 @@ export default class ProfitLoss extends Component { ...@@ -689,7 +721,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
console.log(dataTable2) console.log(dataTable2)
...@@ -706,7 +738,7 @@ export default class ProfitLoss extends Component { ...@@ -706,7 +738,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -777,7 +809,7 @@ export default class ProfitLoss extends Component { ...@@ -777,7 +809,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -795,7 +827,7 @@ export default class ProfitLoss extends Component { ...@@ -795,7 +827,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -866,7 +898,7 @@ export default class ProfitLoss extends Component { ...@@ -866,7 +898,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -884,7 +916,7 @@ export default class ProfitLoss extends Component { ...@@ -884,7 +916,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -955,7 +987,7 @@ export default class ProfitLoss extends Component { ...@@ -955,7 +987,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -973,7 +1005,7 @@ export default class ProfitLoss extends Component { ...@@ -973,7 +1005,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1044,7 +1076,7 @@ export default class ProfitLoss extends Component { ...@@ -1044,7 +1076,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1062,7 +1094,7 @@ export default class ProfitLoss extends Component { ...@@ -1062,7 +1094,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1133,7 +1165,7 @@ export default class ProfitLoss extends Component { ...@@ -1133,7 +1165,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1151,7 +1183,7 @@ export default class ProfitLoss extends Component { ...@@ -1151,7 +1183,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1222,7 +1254,7 @@ export default class ProfitLoss extends Component { ...@@ -1222,7 +1254,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1240,7 +1272,7 @@ export default class ProfitLoss extends Component { ...@@ -1240,7 +1272,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1311,7 +1343,7 @@ export default class ProfitLoss extends Component { ...@@ -1311,7 +1343,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1329,7 +1361,7 @@ export default class ProfitLoss extends Component { ...@@ -1329,7 +1361,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1400,7 +1432,7 @@ export default class ProfitLoss extends Component { ...@@ -1400,7 +1432,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1418,7 +1450,7 @@ export default class ProfitLoss extends Component { ...@@ -1418,7 +1450,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1489,7 +1521,7 @@ export default class ProfitLoss extends Component { ...@@ -1489,7 +1521,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1507,7 +1539,7 @@ export default class ProfitLoss extends Component { ...@@ -1507,7 +1539,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1578,7 +1610,7 @@ export default class ProfitLoss extends Component { ...@@ -1578,7 +1610,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1596,7 +1628,7 @@ export default class ProfitLoss extends Component { ...@@ -1596,7 +1628,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1667,7 +1699,7 @@ export default class ProfitLoss extends Component { ...@@ -1667,7 +1699,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1685,7 +1717,7 @@ export default class ProfitLoss extends Component { ...@@ -1685,7 +1717,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1754,7 +1786,7 @@ export default class ProfitLoss extends Component { ...@@ -1754,7 +1786,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> : </span> :
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
...@@ -1764,7 +1796,7 @@ export default class ProfitLoss extends Component { ...@@ -1764,7 +1796,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleTotal(tableMeta)} value={Number(handleTotal(tableMeta)).toFixed(1)}
/> />
</span>} </span>}
</div> </div>
...@@ -1794,7 +1826,7 @@ export default class ProfitLoss extends Component { ...@@ -1794,7 +1826,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1812,7 +1844,7 @@ export default class ProfitLoss extends Component { ...@@ -1812,7 +1844,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1883,7 +1915,7 @@ export default class ProfitLoss extends Component { ...@@ -1883,7 +1915,7 @@ export default class ProfitLoss extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} value={Number(value).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1901,7 +1933,7 @@ export default class ProfitLoss extends Component { ...@@ -1901,7 +1933,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={Number(handleValue(tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1971,25 +2003,25 @@ export default class ProfitLoss extends Component { ...@@ -1971,25 +2003,25 @@ export default class ProfitLoss extends Component {
return ( return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}> <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Pengajuan Budget Tahunan</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
</div> </div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}> <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}> <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert} {this.state.messageAlert}
</Alert> </Alert>
</Snackbar> </Snackbar>
{this.state.loading && loadingComponent} {/* {this.state.loading && loadingComponent} */}
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleProfitLoss === true ? {this.state.visibleProfitLoss === true ?
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}> <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Budget Tahunan - Profit & Loss </Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Profit & Loss </Typography>
</div> </div>
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div> <div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode} (rev.{this.props.revision})</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
...@@ -2046,30 +2078,26 @@ export default class ProfitLoss extends Component { ...@@ -2046,30 +2078,26 @@ export default class ProfitLoss extends Component {
</div> </div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}> {this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
columns={columns} columns={columns}
options={options} options={options}
/> />
</MuiThemeProvider>} </MuiThemeProvider>
</div> </div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
</div> </div>
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1"> <div className="col-1">
<button <button
type="button" type="button"
onClick={() => this.state.editable === true ? onClick={() => this.setState({ loading: true }, () => {
this.setState({ loading: true }, () => { setTimeout(() => {
setTimeout(() => { this.props.onClickClose()
this.backToMasterBudget('draft') }, 100);
}, 100); })}
}) :
this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
...@@ -2078,7 +2106,7 @@ export default class ProfitLoss extends Component { ...@@ -2078,7 +2106,7 @@ export default class ProfitLoss extends Component {
}} }}
> >
<div style={{ backgroundColor: '#019ce5', 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: '#fff', textAlign: 'center' }}>Back</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
</div> </div>
...@@ -2093,14 +2121,16 @@ export default class ProfitLoss extends Component { ...@@ -2093,14 +2121,16 @@ export default class ProfitLoss extends Component {
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
}} }}
onClick={() => this.setState({ loading: true }, () => { onClick={() => {
setTimeout(() => { this.setState({ loading: true }, () => {
this.props.onClickClose() setTimeout(() => {
}, 100); this.handleValidate()
})} }, 100);
})
}}
> >
<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', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div> </div>
</button> </button>
<button <button
...@@ -2113,24 +2143,34 @@ export default class ProfitLoss extends Component { ...@@ -2113,24 +2143,34 @@ export default class ProfitLoss extends Component {
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
}} }}
onClick={() => { onClick={() => this.state.editable === true ?
this.setState({ loading: true}, () => { this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.handleValidate() this.backToMasterBudget('draft')
}, 100); }, 100);
}) }) :
}} this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
> >
<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' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
</div> </div>
</button> </button>
<button <button
type="button" type="button"
// disabled={this.state.buttonError} disabled={this.state.buttonError}
onClick={() => this.state.buttonError? onClick={() => {
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) this.state.buttonError ?
: this.backToMasterBudget('submitted')} this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning', loading: false })
}, 100);
})
: this.backToMasterBudget('submitted')
}}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer', cursor: this.state.buttonError === true ? 'default' : 'pointer',
...@@ -2139,7 +2179,7 @@ export default class ProfitLoss extends Component { ...@@ -2139,7 +2179,7 @@ export default class ProfitLoss extends Component {
}} }}
> >
<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 & Complate</Typography>
</div> </div>
</button> </button>
</div> </div>
...@@ -2151,71 +2191,91 @@ export default class ProfitLoss extends Component { ...@@ -2151,71 +2191,91 @@ export default class ProfitLoss extends Component {
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
<div> <div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div> </div>
{this.state.dataLoaded && ( {this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}> {this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
columns={columns} columns={columns}
options={options} options={options}
/> />
</MuiThemeProvider>} </MuiThemeProvider>
</div> </div>
)} )}
</div> </div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button <div className="grid grid-2x" style={{ marginTop: 20 }}>
type="button" <div className="col-1">
onClick={() => this.setState({ loading: true, visibleProfitLoss: true }, () => { <button
setTimeout(() => { type="button"
this.getItemHierarki() onClick={() => this.setState({ loading: true, visibleProfitLoss: true }, () => {
}, 100);
})}
style={{ marginRight: 20 }}
>
<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' }}>Cancel</Typography>
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.buttonError}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false }) this.getItemHierarki()
}, 100); }, 100);
}) })}
}} style={{ marginRight: 20 }}
> >
<div style={{ backgroundColor: '#354960', 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: '#fff', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
<button </div>
type="button" <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
disabled={this.state.buttonError} <button
onClick={() => this.setState({ loading: true }, () => { className="button"
setTimeout(() => { type="button"
this.uploadProfitLoss() // disabled={this.state.buttonError}
}, 100); style={{
})} backgroundColor: 'transparent',
> cursor: this.state.buttonError === true ? 'default' : 'pointer',
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> borderColor: 'transparent',
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography> outline: 'none',
</div> marginRight: 20
</button> }}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
}, 100);
})
}}
>
<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>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadProfitLoss('draft')
}, 100);
})}
style={{ marginRight: 20}}
>
<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 as Draft</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadProfitLoss('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