Commit 9384300e authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'faisal' into 'master'

OLPA PL

See merge request !474
parents 54217f96 d9c23444
......@@ -66,7 +66,7 @@ export default class ProfitLossOLPA extends Component {
"revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID
"outlook_pa_id": this.props.outlook_pa_id
}
api.create().getLastestUpdateMB(payload).then(response => {
if (response.data) {
......@@ -79,60 +79,24 @@ export default class ProfitLossOLPA extends Component {
})
}
getItemHierarki() {
async getItemHierarki() {
this.setState({ loading: true, judulColumn: null })
let payload = {
"outlook_pa_id": this.props.outlook_pa_id,
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
"revision": this.props.revision,
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID
"company_id": this.props.company.company_id
}
api.create().getDetailReportMB(payload).then(response => {
console.log(response);
let dataTable = []
this.setState({visibleProfitLoss: true})
if (response.data) {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
item.order
])
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
res.map((item, index) => {
console.log(payload)
let response = await api.create().getDetailReportOLPA(payload)
console.log(response);
let dataTable = []
if (response.data) {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
......@@ -159,21 +123,55 @@ export default class ProfitLossOLPA extends Component {
item.profit_loss.total_more_year,
item.order
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
})
console.log(dataTable)
this.setState({ dataTable, loading: false, buttonError: true, editable: true })
} else {
this.setState({ dataTable, loading: false, buttonError: true, editable: true })
}
}
})
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
item.order
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
console.log(dataTable)
this.setState({ dataTable, loading: false, buttonError: true, editable: true })
} else {
this.setState({ dataTable, loading: false, buttonError: true, editable: true })
}
}
handleValue(data) {
......@@ -203,7 +201,7 @@ export default class ProfitLossOLPA extends Component {
}
}
backToMasterBudget(type) {
backToOLPA(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
......@@ -228,7 +226,7 @@ export default class ProfitLossOLPA extends Component {
})
})
let payload = {
"submission_id": this.props.submissionID,
"outlook_pa_id": this.props.outlook_pa_id,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
......@@ -237,13 +235,13 @@ export default class ProfitLossOLPA extends Component {
}
console.log(data);
this.setState({ loading: false })
this.props.saveToMasterBudget(payload)
this.props.saveToOLPA(payload)
this.props.onClickClose()
}
downloadTemplate = async () => {
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
`https://tia.eksad.com/tia-reporting-dev/public/transaction/outlook_pa/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
)
res = await res.blob()
console.log(res)
......@@ -306,7 +304,7 @@ export default class ProfitLossOLPA extends Component {
}
checkUpload() {
api.create().checkUploadMB(this.state.payload).then(response => {
api.create().checkUploadOLPA(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
......@@ -380,15 +378,15 @@ export default class ProfitLossOLPA extends Component {
})
})
let body = {
submission_id: this.props.submissionID,
outlook_pa_id: this.props.outlook_pa_id,
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
profit_loss: data,
status: type
}
console.log(data);
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
console.log(JSON.stringify(body));
api.create('UPLOAD').uploadOLPA(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
......@@ -400,18 +398,16 @@ export default class ProfitLossOLPA extends Component {
} else {
this.setState({ loading: false })
alert(response.problem)
// this.props.onClickClose()
// this.props.getReport()
}
})
}
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}`
let sub_null = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/outlook_pa/export_outlook_pa?outlook_pa_id=${this.props.outlook_pa_id}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
let sub_null = `https://tia.eksad.com/tia-reporting-dev/public/transaction/outlook_pa/export_outlook_pa?outlook_pa_id=&&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(
this.props.submissionID == null ? sub_null : url
this.props.outlook_pa_id == null ? sub_null : url
)
res = await res.blob()
this.setState({ loading: false })
......@@ -450,15 +446,15 @@ export default class ProfitLossOLPA extends Component {
})
})
let payload = {
"submission_id": this.props.submissionID,
"outlook_pa_id": this.props.outlook_pa_id,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"profit_loss": data,
"status": "submitted"
}
console.log(payload)
api.create().validateSubmitReport(payload).then((response) => {
// console.log(payload)
api.create().validateSubmitReportOLPA(payload).then((response) => {
console.log(response)
if (response.data.data.result) {
this.setState({ loading: false, buttonError: false, editable: false })
......@@ -2158,7 +2154,7 @@ export default class ProfitLossOLPA extends Component {
</button>
</div>
{this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
(this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ?
(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ?
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
className="button"
......@@ -2196,7 +2192,7 @@ export default class ProfitLossOLPA extends Component {
onClick={() =>
this.state.handleTekTekTek == 1? null :
this.setState({handleTekTekTek: 1}, () => {
this.backToMasterBudget('draft')
this.backToOLPA('draft')
})
}
>
......@@ -2212,7 +2208,7 @@ export default class ProfitLossOLPA extends Component {
:
this.state.handleTekTekTek == 1? null :
this.setState({handleTekTekTek: 1}, () => {
this.backToMasterBudget('submitted')
this.backToOLPA('submitted')
})}
style={{
backgroundColor: 'transparent',
......
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