Commit 5c922371 authored by EKSAD's avatar EKSAD

nyicil

parent 35ed8ee7
...@@ -69,7 +69,6 @@ export default class ProfitLoss extends Component { ...@@ -69,7 +69,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) {
...@@ -327,6 +326,7 @@ export default class ProfitLoss extends Component { ...@@ -327,6 +326,7 @@ export default class ProfitLoss extends Component {
} }
uploadProfitLoss() { uploadProfitLoss() {
// console.log('tes');
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
...@@ -377,6 +377,8 @@ export default class ProfitLoss extends Component { ...@@ -377,6 +377,8 @@ export default class ProfitLoss extends Component {
} }
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}`
) )
...@@ -386,13 +388,14 @@ export default class ProfitLoss extends Component { ...@@ -386,13 +388,14 @@ 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 = 'Master Budget Profit & Loss.xlsx'; a.download = 'Balance Sheet.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],
...@@ -420,9 +423,10 @@ export default class ProfitLoss extends Component { ...@@ -420,9 +423,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": "submitted", "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) {
...@@ -433,11 +437,14 @@ export default class ProfitLoss extends Component { ...@@ -433,11 +437,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 {
...@@ -690,6 +697,7 @@ export default class ProfitLoss extends Component { ...@@ -690,6 +697,7 @@ export default class ProfitLoss extends Component {
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
decimalSeparator={"."}
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=""
...@@ -1982,7 +1990,7 @@ export default class ProfitLoss extends Component { ...@@ -1982,7 +1990,7 @@ export default class ProfitLoss extends Component {
{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 }}>
...@@ -2050,13 +2058,14 @@ export default class ProfitLoss extends Component { ...@@ -2050,13 +2058,14 @@ 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>
</div> </div>
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
...@@ -2131,10 +2140,16 @@ export default class ProfitLoss extends Component { ...@@ -2131,10 +2140,16 @@ export default class ProfitLoss extends Component {
</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',
...@@ -2160,13 +2175,14 @@ export default class ProfitLoss extends Component { ...@@ -2160,13 +2175,14 @@ export default class ProfitLoss extends Component {
</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>
...@@ -2187,7 +2203,7 @@ export default class ProfitLoss extends Component { ...@@ -2187,7 +2203,7 @@ export default class ProfitLoss extends Component {
<button <button
className="button" className="button"
type="button" type="button"
disabled={this.state.buttonError} // disabled={this.state.buttonError}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer', cursor: this.state.buttonError === true ? 'default' : 'pointer',
...@@ -2209,7 +2225,7 @@ export default class ProfitLoss extends Component { ...@@ -2209,7 +2225,7 @@ export default class ProfitLoss extends Component {
</button> </button>
<button <button
type="button" type="button"
disabled={this.state.buttonError} // disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => { onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.uploadProfitLoss() this.uploadProfitLoss()
......
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