Commit da7849e8 authored by d.arizona's avatar d.arizona

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into didam

parents b3e9df33 cf0e1edd
...@@ -669,6 +669,8 @@ export default class BudgetTahunan extends Component { ...@@ -669,6 +669,8 @@ export default class BudgetTahunan extends Component {
submissionID={this.state.submissionID} submissionID={this.state.submissionID}
saveToMasterBudget={this.saveToMasterBudget.bind(this)} saveToMasterBudget={this.saveToMasterBudget.bind(this)}
onClickClose={() => this.setState({ visiblePL: false, visibleBudgetTahunan: true })} onClickClose={() => this.setState({ visiblePL: false, visibleBudgetTahunan: true })}
getReport={this.getReport.bind(this)}
getReportAttachment={this.getReportAttachment.bind(this)}
/> />
)} )}
......
...@@ -31,18 +31,7 @@ export default class ProfitLoss extends Component { ...@@ -31,18 +31,7 @@ export default class ProfitLoss extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
dataTable: [ dataTable: [],
// ["TOTAL ASSETS", "11,247,249", "10,702,196"],
// ["TOTAL CURRENT ASSETS", "2,647,647", "2,058,898"],
// ["Cash & Cash Equivalent", "1,464,571", "729,743"],
// ["Cash & Bank Balance", "938,707", "265,584"],
// ["Time & Call Deposit", "525,864", "464,159"],
// ["BI Deposit", "", ""],
// ["Marketable Securities", "150,250", "154,500"],
// ["Notes Receivable", "", ""],
// ["Accounts Receivable", "172,031", "97,112"],
// ["Trade Receivables - Third Party", "142,668", "77,480"],
],
visibleProfitLoss: true, visibleProfitLoss: true,
disabledSave: true disabledSave: true
} }
...@@ -66,12 +55,12 @@ export default class ProfitLoss extends Component { ...@@ -66,12 +55,12 @@ export default class ProfitLoss extends Component {
} }
api.create().getDetailReportMB(payload).then(response => { api.create().getDetailReportMB(payload).then(response => {
console.log(response); console.log(response);
if (response.data) {
if (response.data.status === "success") {
let dataTable = [] let dataTable = []
response.data.data.map((item, index) => { let res = response.data.data
console.log(res)
if (item.children && item.children.length > 0) { const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -97,585 +86,16 @@ export default class ProfitLoss extends Component { ...@@ -97,585 +86,16 @@ export default class ProfitLoss extends Component {
item.profit_loss.total_next_year, item.profit_loss.total_next_year,
item.profit_loss.total_more_year item.profit_loss.total_more_year
]) ])
item.children.map(i => {
if (i.children) {
if (i.children.length > 0) {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.formula,
i.level,
i.description,
i.profit_loss.notes === "" ? null : item.profit_loss.notes,
i.profit_loss.total_actual_before,
i.profit_loss.january,
i.profit_loss.february,
i.profit_loss.march,
i.profit_loss.april,
i.profit_loss.may,
i.profit_loss.june,
i.profit_loss.july,
i.profit_loss.august,
i.profit_loss.september,
i.profit_loss.october,
i.profit_loss.november,
i.profit_loss.december,
i.profit_loss.total_current_year,
i.profit_loss.total_next_year,
i.profit_loss.total_more_year
])
i.children.map(val => {
if (val.children && val.children.length > 0) {
dataTable.push([
val.type_report_id,
val.id,
val.parent,
val.formula,
val.level,
val.description,
val.profit_loss.notes === "" ? null : item.profit_loss.notes,
val.profit_loss.total_actual_before,
val.profit_loss.january,
val.profit_loss.february,
val.profit_loss.march,
val.profit_loss.april,
val.profit_loss.may,
val.profit_loss.june,
val.profit_loss.july,
val.profit_loss.august,
val.profit_loss.september,
val.profit_loss.october,
val.profit_loss.november,
val.profit_loss.december,
val.profit_loss.total_current_year,
val.profit_loss.total_next_year,
val.profit_loss.total_more_year
])
val.children.map(items => {
if (items.children && items.children.length > 0) {
dataTable.push([
items.type_report_id,
items.id,
items.parent,
items.formula,
items.level,
items.description,
items.profit_loss.notes === "" ? null : item.profit_loss.notes,
items.profit_loss.total_actual_before,
items.profit_loss.january,
items.profit_loss.february,
items.profit_loss.march,
items.profit_loss.april,
items.profit_loss.may,
items.profit_loss.june,
items.profit_loss.july,
items.profit_loss.august,
items.profit_loss.september,
items.profit_loss.october,
items.profit_loss.november,
items.profit_loss.december,
items.profit_loss.total_current_year,
items.profit_loss.total_next_year,
items.profit_loss.total_more_year
])
items.children.map(itemss => {
if (itemss.children && itemss.children.length > 0) {
dataTable.push([
itemss.type_report_id,
itemss.id,
itemss.parent,
itemss.formula,
itemss.level,
itemss.description,
itemss.profit_loss.notes === "" ? null : item.profit_loss.notes,
itemss.profit_loss.total_actual_before,
itemss.profit_loss.january,
itemss.profit_loss.february,
itemss.profit_loss.march,
itemss.profit_loss.april,
itemss.profit_loss.may,
itemss.profit_loss.june,
itemss.profit_loss.july,
itemss.profit_loss.august,
itemss.profit_loss.september,
itemss.profit_loss.october,
itemss.profit_loss.november,
itemss.profit_loss.december,
itemss.profit_loss.total_current_year,
itemss.profit_loss.total_next_year,
itemss.profit_loss.total_more_year
])
itemss.children.map(item1 => {
if (item1.children && item1.children.length > 0) {
dataTable.push([
item1.type_report_id,
item1.id,
item1.parent,
item1.formula,
item1.level,
item1.description,
item1.profit_loss.notes === "" ? null : item.profit_loss.notes,
item1.profit_loss.total_actual_before,
item1.profit_loss.january,
item1.profit_loss.february,
item1.profit_loss.march,
item1.profit_loss.april,
item1.profit_loss.may,
item1.profit_loss.june,
item1.profit_loss.july,
item1.profit_loss.august,
item1.profit_loss.september,
item1.profit_loss.october,
item1.profit_loss.november,
item1.profit_loss.december,
item1.profit_loss.total_current_year,
item1.profit_loss.total_next_year,
item1.profit_loss.total_more_year
])
item1.children.map(item2 => {
if (item2.children && item2.children.length > 0) {
dataTable.push([
item2.type_report_id,
item2.id,
item2.parent,
item2.formula,
item2.level,
item2.description,
item2.profit_loss.notes === "" ? null : item.profit_loss.notes,
item2.profit_loss.total_actual_before,
item2.profit_loss.january,
item2.profit_loss.february,
item2.profit_loss.march,
item2.profit_loss.april,
item2.profit_loss.may,
item2.profit_loss.june,
item2.profit_loss.july,
item2.profit_loss.august,
item2.profit_loss.september,
item2.profit_loss.october,
item2.profit_loss.november,
item2.profit_loss.december,
item2.profit_loss.total_current_year,
item2.profit_loss.total_next_year,
item2.profit_loss.total_more_year
])
item2.children.map(item3 => {
if (item3.children && item3.children.length > 0) {
dataTable.push([
item3.type_report_id,
item3.id,
item3.parent,
item3.formula,
item3.level,
item3.description,
item3.profit_loss.notes === "" ? null : item.profit_loss.notes,
item3.profit_loss.total_actual_before,
item3.profit_loss.january,
item3.profit_loss.february,
item3.profit_loss.march,
item3.profit_loss.april,
item3.profit_loss.may,
item3.profit_loss.june,
item3.profit_loss.july,
item3.profit_loss.august,
item3.profit_loss.september,
item3.profit_loss.october,
item3.profit_loss.november,
item3.profit_loss.december,
item3.profit_loss.total_current_year,
item3.profit_loss.total_next_year,
item3.profit_loss.total_more_year
])
item3.children.map(item4 => {
if (item4.children && item4.children.length > 0) {
dataTable.push([
item4.type_report_id,
item4.id,
item4.parent,
item4.formula,
item4.level,
item4.description,
item4.profit_loss.notes === "" ? null : item.profit_loss.notes,
item4.profit_loss.total_actual_before,
item4.profit_loss.january,
item4.profit_loss.february,
item4.profit_loss.march,
item4.profit_loss.april,
item4.profit_loss.may,
item4.profit_loss.june,
item4.profit_loss.july,
item4.profit_loss.august,
item4.profit_loss.september,
item4.profit_loss.october,
item4.profit_loss.november,
item4.profit_loss.december,
item4.profit_loss.total_current_year,
item4.profit_loss.total_next_year,
item4.profit_loss.total_more_year
])
item4.children.map(item5 => {
if (item5.children && item5.children.length > 0) {
dataTable.push([
item5.type_report_id,
item5.id,
item5.parent,
item5.formula,
item5.level,
item5.description,
item5.profit_loss.notes === "" ? null : item.profit_loss.notes,
item5.profit_loss.total_actual_before,
item5.profit_loss.january,
item5.profit_loss.february,
item5.profit_loss.march,
item5.profit_loss.april,
item5.profit_loss.may,
item5.profit_loss.june,
item5.profit_loss.july,
item5.profit_loss.august,
item5.profit_loss.september,
item5.profit_loss.october,
item5.profit_loss.november,
item5.profit_loss.december,
item5.profit_loss.total_current_year,
item5.profit_loss.total_next_year,
item5.profit_loss.total_more_year
])
item5.children.map(item6 => {
if (item6.children && item.children.length > 0) {
dataTable.push([
item6.type_report_id,
item6.id,
item6.parent,
item6.formula,
item6.level,
item6.description,
item6.profit_loss.notes === "" ? null : item.profit_loss.notes,
item6.profit_loss.total_actual_before,
item6.profit_loss.january,
item6.profit_loss.february,
item6.profit_loss.march,
item6.profit_loss.april,
item6.profit_loss.may,
item6.profit_loss.june,
item6.profit_loss.july,
item6.profit_loss.august,
item6.profit_loss.september,
item6.profit_loss.october,
item6.profit_loss.november,
item6.profit_loss.december,
item6.profit_loss.total_current_year,
item6.profit_loss.total_next_year,
item6.profit_loss.total_more_year
])
} else {
dataTable.push([
item6.type_report_id,
item6.id,
item6.parent,
item6.formula,
item6.level,
item6.description,
item6.profit_loss.notes === "" ? null : item.profit_loss.notes,
item6.profit_loss.total_actual_before,
item6.profit_loss.january,
item6.profit_loss.february,
item6.profit_loss.march,
item6.profit_loss.april,
item6.profit_loss.may,
item6.profit_loss.june,
item6.profit_loss.july,
item6.profit_loss.august,
item6.profit_loss.september,
item6.profit_loss.october,
item6.profit_loss.november,
item6.profit_loss.december,
item6.profit_loss.total_current_year,
item6.profit_loss.total_next_year,
item6.profit_loss.total_more_year
])
}
})
} else {
dataTable.push([
item5.type_report_id,
item5.id,
item5.parent,
item5.formula,
item5.level,
item5.description,
item5.profit_loss.notes === "" ? null : item.profit_loss.notes,
item5.profit_loss.total_actual_before,
item5.profit_loss.january,
item5.profit_loss.february,
item5.profit_loss.march,
item5.profit_loss.april,
item5.profit_loss.may,
item5.profit_loss.june,
item5.profit_loss.july,
item5.profit_loss.august,
item5.profit_loss.september,
item5.profit_loss.october,
item5.profit_loss.november,
item5.profit_loss.december,
item5.profit_loss.total_current_year,
item5.profit_loss.total_next_year,
item5.profit_loss.total_more_year
])
}
})
} else {
dataTable.push([
item4.type_report_id,
item4.id,
item4.parent,
item4.formula,
item4.level,
item4.description,
item4.profit_loss.notes === "" ? null : item.profit_loss.notes,
item4.profit_loss.total_actual_before,
item4.profit_loss.january,
item4.profit_loss.february,
item4.profit_loss.march,
item4.profit_loss.april,
item4.profit_loss.may,
item4.profit_loss.june,
item4.profit_loss.july,
item4.profit_loss.august,
item4.profit_loss.september,
item4.profit_loss.october,
item4.profit_loss.november,
item4.profit_loss.december,
item4.profit_loss.total_current_year,
item4.profit_loss.total_next_year,
item4.profit_loss.total_more_year
])
}
})
} else {
dataTable.push([
item3.type_report_id,
item3.id,
item3.parent,
item3.formula,
item3.level,
item3.description,
item3.profit_loss.notes === "" ? null : item.profit_loss.notes,
item3.profit_loss.total_actual_before,
item3.profit_loss.january,
item3.profit_loss.february,
item3.profit_loss.march,
item3.profit_loss.april,
item3.profit_loss.may,
item3.profit_loss.june,
item3.profit_loss.july,
item3.profit_loss.august,
item3.profit_loss.september,
item3.profit_loss.october,
item3.profit_loss.november,
item3.profit_loss.december,
item3.profit_loss.total_current_year,
item3.profit_loss.total_next_year,
item3.profit_loss.total_more_year
])
}
})
} else {
dataTable.push([
item2.type_report_id,
item2.id,
item2.parent,
item2.formula,
item2.level,
item2.description,
item2.profit_loss.notes === "" ? null : item.profit_loss.notes,
item2.profit_loss.total_actual_before,
item2.profit_loss.january,
item2.profit_loss.february,
item2.profit_loss.march,
item2.profit_loss.april,
item2.profit_loss.may,
item2.profit_loss.june,
item2.profit_loss.july,
item2.profit_loss.august,
item2.profit_loss.september,
item2.profit_loss.october,
item2.profit_loss.november,
item2.profit_loss.december,
item2.profit_loss.total_current_year,
item2.profit_loss.total_next_year,
item2.profit_loss.total_more_year
])
}
})
} else {
dataTable.push([
item1.type_report_id,
item1.id,
item1.parent,
item1.formula,
item1.level,
item1.description,
item1.profit_loss.notes === "" ? null : item.profit_loss.notes,
item1.profit_loss.total_actual_before,
item1.profit_loss.january,
item1.profit_loss.february,
item1.profit_loss.march,
item1.profit_loss.april,
item1.profit_loss.may,
item1.profit_loss.june,
item1.profit_loss.july,
item1.profit_loss.august,
item1.profit_loss.september,
item1.profit_loss.october,
item1.profit_loss.november,
item1.profit_loss.december,
item1.profit_loss.total_current_year,
item1.profit_loss.total_next_year,
item1.profit_loss.total_more_year
])
}
})
} else {
dataTable.push([
itemss.type_report_id,
itemss.id,
itemss.parent,
itemss.formula,
itemss.level,
itemss.description,
itemss.profit_loss.notes === "" ? null : item.profit_loss.notes,
itemss.profit_loss.total_actual_before,
itemss.profit_loss.january,
itemss.profit_loss.february,
itemss.profit_loss.march,
itemss.profit_loss.april,
itemss.profit_loss.may,
itemss.profit_loss.june,
itemss.profit_loss.july,
itemss.profit_loss.august,
itemss.profit_loss.september,
itemss.profit_loss.october,
itemss.profit_loss.november,
itemss.profit_loss.december,
itemss.profit_loss.total_current_year,
itemss.profit_loss.total_next_year,
itemss.profit_loss.total_more_year
])
} }
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
}) })
} else {
dataTable.push([
items.type_report_id,
items.id,
items.parent,
items.formula,
items.level,
items.description,
items.profit_loss.notes === "" ? null : item.profit_loss.notes,
items.profit_loss.total_actual_before,
items.profit_loss.january,
items.profit_loss.february,
items.profit_loss.march,
items.profit_loss.april,
items.profit_loss.may,
items.profit_loss.june,
items.profit_loss.july,
items.profit_loss.august,
items.profit_loss.september,
items.profit_loss.october,
items.profit_loss.november,
items.profit_loss.december,
items.profit_loss.total_current_year,
items.profit_loss.total_next_year,
items.profit_loss.total_more_year
])
} }
})
} else {
dataTable.push([
val.type_report_id,
val.id,
val.parent,
val.formula,
val.level,
val.description,
val.profit_loss.notes === "" ? null : item.profit_loss.notes,
val.profit_loss.total_actual_before,
val.profit_loss.january,
val.profit_loss.february,
val.profit_loss.march,
val.profit_loss.april,
val.profit_loss.may,
val.profit_loss.june,
val.profit_loss.july,
val.profit_loss.august,
val.profit_loss.september,
val.profit_loss.october,
val.profit_loss.november,
val.profit_loss.december,
val.profit_loss.total_current_year,
val.profit_loss.total_next_year,
val.profit_loss.total_more_year
])
} }
})
} else {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.formula,
i.level,
i.description,
i.profit_loss.notes === "" ? null : item.profit_loss.notes,
i.profit_loss.total_actual_before,
i.profit_loss.january,
i.profit_loss.february,
i.profit_loss.march,
i.profit_loss.april,
i.profit_loss.may,
i.profit_loss.june,
i.profit_loss.july,
i.profit_loss.august,
i.profit_loss.september,
i.profit_loss.october,
i.profit_loss.november,
i.profit_loss.december,
i.profit_loss.total_current_year,
i.profit_loss.total_next_year,
i.profit_loss.total_more_year
])
} }
} else { res.map((item, index) => {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.formula,
i.level,
i.description,
i.profit_loss.notes === "" ? null : item.profit_loss.notes,
i.profit_loss.total_actual_before,
i.profit_loss.january,
i.profit_loss.february,
i.profit_loss.march,
i.profit_loss.april,
i.profit_loss.may,
i.profit_loss.june,
i.profit_loss.july,
i.profit_loss.august,
i.profit_loss.september,
i.profit_loss.october,
i.profit_loss.november,
i.profit_loss.december,
i.profit_loss.total_current_year,
i.profit_loss.total_next_year,
i.profit_loss.total_more_year
])
}
})
} else {
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -701,15 +121,17 @@ export default class ProfitLoss extends Component { ...@@ -701,15 +121,17 @@ export default class ProfitLoss extends Component {
item.profit_loss.total_next_year, item.profit_loss.total_next_year,
item.profit_loss.total_more_year item.profit_loss.total_more_year
]) ])
} if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
}) })
console.log(dataTable);
this.setState({ loading: false, dataTable })
} }
} else {
this.setState({ loading: false })
} }
}) })
this.setState({ dataTable, loading: false })
})
} }
handleValue(data) { handleValue(data) {
...@@ -737,16 +159,10 @@ export default class ProfitLoss extends Component { ...@@ -737,16 +159,10 @@ export default class ProfitLoss extends Component {
} else { } else {
data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
} }
// this.forceUpdate()
// console.log(this.state.dataTable)
// this.setState({
// data: a,
// }, () => console.log(this.state.dataTable))
} }
backToMasterBudget(type) { backToMasterBudget(type) {
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],
...@@ -768,7 +184,6 @@ export default class ProfitLoss extends Component { ...@@ -768,7 +184,6 @@ export default class ProfitLoss extends Component {
total_next_year: String(i[21]), total_next_year: String(i[21]),
total_more_year: String(i[22]) total_more_year: String(i[22])
}) })
}) })
let payload = { let payload = {
"submission_id": this.props.submissionID, "submission_id": this.props.submissionID,
...@@ -778,7 +193,7 @@ export default class ProfitLoss extends Component { ...@@ -778,7 +193,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()
} }
...@@ -801,6 +216,7 @@ export default class ProfitLoss extends Component { ...@@ -801,6 +216,7 @@ export default class ProfitLoss extends Component {
fileHandler = (event) => { fileHandler = (event) => {
let fileObj = event let fileObj = event
ExcelRenderer(fileObj, (err, resp) => { ExcelRenderer(fileObj, (err, resp) => {
// console.log(resp)
if (err) { if (err) {
console.log(err); console.log(err);
} }
...@@ -829,37 +245,10 @@ export default class ProfitLoss extends Component { ...@@ -829,37 +245,10 @@ export default class ProfitLoss extends Component {
december: i[15] === undefined ? "" : String(i[15]).trim(), december: i[15] === undefined ? "" : String(i[15]).trim(),
total_current_year: i[16] === undefined ? "" : String(i[16]).trim(), total_current_year: i[16] === undefined ? "" : String(i[16]).trim(),
total_next_year: i[17] === undefined ? "" : String(i[17]).trim(), total_next_year: i[17] === undefined ? "" : String(i[17]).trim(),
total_more_year: i[18] === undefined ? "" : String(i[18]).trim() total_more_year: i[17] === undefined ? "" : String(i[18]).trim()
}) })
} }
}) })
let rows = isi.map((i, index) => {
return [
String(i[0]) === '-' ? 4 : 3,
0,
0,
"",
1,
i[0] === undefined ? "" : String(i[0]),
i[1] === undefined ? "" : String(i[1]),
i[2] === undefined ? "" : String(i[2]),
i[3] === undefined ? "" : String(i[3]),
i[4] === undefined ? "" : String(i[4]),
i[5] === undefined ? "" : String(i[5]),
i[6] === undefined ? "" : String(i[6]),
i[7] === undefined ? "" : String(i[7]),
i[8] === undefined ? "" : String(i[8]),
i[9] === undefined ? "" : String(i[9]),
i[10] === undefined ? "" : String(i[10]),
i[11] === undefined ? "" : String(i[11]),
i[12] === undefined ? "" : String(i[12]),
i[13] === undefined ? "" : String(i[13]),
i[14] === undefined ? "" : String(i[14]),
i[15] === undefined ? "" : String(i[15]),
i[16] === undefined ? "" : String(i[16]),
i[17] === undefined ? "" : String(i[17])
]
})
let body = { let body = {
company_id: this.props.company.company_id, company_id: this.props.company.company_id,
periode: this.props.periode, periode: this.props.periode,
...@@ -907,12 +296,82 @@ export default class ProfitLoss extends Component { ...@@ -907,12 +296,82 @@ export default class ProfitLoss extends Component {
item.error item.error
] ]
}) })
this.setState({ dataTable, dataLoaded: true, loading: false }) this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false })
} }
} }
}) })
} }
checkError(tableMeta) {
if (tableMeta.rowData[23]) {
if (tableMeta.rowData[23][0] === 'item') {
this.setState({ buttonError: true })
}
}
}
uploadProfitLoss() {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
notes: i[6],
total_actual_before: String(i[7]),
january: String(i[8]),
february: String(i[9]),
march: String(i[10]),
april: String(i[11]),
may: String(i[12]),
june: String(i[13]),
july: String(i[14]),
august: String(i[15]),
september: String(i[16]),
october: String(i[17]),
november: String(i[18]),
december: String(i[19]),
total_current_year: String(i[20]),
total_next_year: String(i[21]),
total_more_year: String(i[22])
})
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
profit_loss: data
}
console.log(data);
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
this.props.getReportAttachment()
} else {
alert(response.data.status)
}
} else {
alert(response.problem)
}
})
}
async downloadAllData() {
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}`
)
res = await res.blob()
this.setState({ loading: false })
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Profit Loss.xlsx';
a.click();
}
}
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => { const handleChange = (value, tableMeta) => {
...@@ -928,13 +387,11 @@ export default class ProfitLoss extends Component { ...@@ -928,13 +387,11 @@ export default class ProfitLoss extends Component {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
} }
} }
const handleNotes = (value, tableMeta) => { const handleNotes = (value, tableMeta) => {
console.log(value) console.log(value)
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
console.log(dataTable2[tableMeta.rowIndex]); console.log(dataTable2[tableMeta.rowIndex]);
} }
const handleValue = (data) => { const handleValue = (data) => {
let total = 0 let total = 0
dataTable2.map((item, index) => { dataTable2.map((item, index) => {
...@@ -991,6 +448,7 @@ export default class ProfitLoss extends Component { ...@@ -991,6 +448,7 @@ export default class ProfitLoss extends Component {
return a return a
} }
const columns = [{ const columns = [{
name: "", name: "",
options: { options: {
...@@ -1034,11 +492,13 @@ export default class ProfitLoss extends Component { ...@@ -1034,11 +492,13 @@ export default class ProfitLoss extends Component {
tableMeta.rowData[4] == 0 ? tableMeta.rowData[4] == 0 ?
<a data-tip={tableMeta.rowData[23][0].message} data-for="account"> <a data-tip={tableMeta.rowData[23][0].message} data-for="account">
<span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span> <span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
{this.checkError(tableMeta)}
</a> </a>
: :
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}> <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<a data-tip={tableMeta.rowData[23][0].message} data-for="account"> <a data-tip={tableMeta.rowData[23][0].message} data-for="account">
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span> <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
{this.checkError(tableMeta)}
</a> </a>
</div> </div>
: :
...@@ -2557,7 +2017,12 @@ export default class ProfitLoss extends Component { ...@@ -2557,7 +2017,12 @@ export default class ProfitLoss extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => null} onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
}, 100);
})}
> >
<img src={Images.download} /> <img src={Images.download} />
</button> </button>
...@@ -2680,14 +2145,18 @@ export default class ProfitLoss extends Component { ...@@ -2680,14 +2145,18 @@ export default class ProfitLoss extends Component {
onClick={() => this.setState({ visibleProfitLoss: true }, () => this.getItemHierarki())} onClick={() => this.setState({ visibleProfitLoss: true }, () => this.getItemHierarki())}
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', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
<button <button
type="button" type="button"
disabled={this.state.buttonError == true ? true : false} disabled={this.state.buttonError == true ? true : false}
onClick={() => null} onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadProfitLoss()
}, 100);
})}
style={{ marginRight: 20 }} 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' }}>
...@@ -2706,7 +2175,7 @@ export default class ProfitLoss extends Component { ...@@ -2706,7 +2175,7 @@ export default class ProfitLoss extends Component {
onClick={() => { onClick={() => {
this.setState({ loading: true }, () => { this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false, buttonError: false }) this.setState({ loading: false })
}, 100); }, 100);
}) })
}} }}
...@@ -2717,8 +2186,7 @@ export default class ProfitLoss extends Component { ...@@ -2717,8 +2186,7 @@ export default class ProfitLoss extends Component {
</button> </button>
</div> </div>
</div> </div>
</Paper> </Paper>}
}
</div> </div>
{this.state.visibleUpload && ( {this.state.visibleUpload && (
...@@ -2758,8 +2226,7 @@ export default class ProfitLoss extends Component { ...@@ -2758,8 +2226,7 @@ export default class ProfitLoss extends Component {
</div> </div>
</div> </div>
)} )}
</div>
</div >
); );
} }
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
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