Commit e54317d2 authored by faisalhamdi's avatar faisalhamdi

olpa pl

parent da5dc009
...@@ -66,7 +66,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -66,7 +66,7 @@ export default class ProfitLossOLPA extends Component {
"revision": Number(this.props.revision), "revision": Number(this.props.revision),
"periode": this.props.periode, "periode": this.props.periode,
"company_id": this.props.company.company_id, "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 => { api.create().getLastestUpdateMB(payload).then(response => {
if (response.data) { if (response.data) {
...@@ -79,60 +79,24 @@ export default class ProfitLossOLPA extends Component { ...@@ -79,60 +79,24 @@ export default class ProfitLossOLPA extends Component {
}) })
} }
getItemHierarki() { async getItemHierarki() {
this.setState({ loading: true, judulColumn: null }) this.setState({ loading: true, judulColumn: null })
let payload = { let payload = {
"outlook_pa_id": this.props.outlook_pa_id,
"report_id": this.props.report_id, "report_id": this.props.report_id,
"revision": Number(this.props.revision), "revision": this.props.revision,
"periode": this.props.periode, "periode": this.props.periode,
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id
"submission_id": this.props.submissionID
} }
api.create().getDetailReportMB(payload).then(response => { console.log(payload)
console.log(response); let response = await api.create().getDetailReportOLPA(payload)
let dataTable = [] console.log(response);
this.setState({visibleProfitLoss: true}) let dataTable = []
if (response.data) { if (response.data) {
let res = response.data.data let res = response.data.data
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) {
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) => {
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -159,21 +123,55 @@ export default class ProfitLossOLPA extends Component { ...@@ -159,21 +123,55 @@ export default class ProfitLossOLPA extends Component {
item.profit_loss.total_more_year, item.profit_loss.total_more_year,
item.order item.order
]) ])
if (item.children !== null) { }
if (item.children.length > 0) { if (item.children !== null) {
item.children.map((items, indexs) => { if (item.children.length > 0) {
handlePushChild(items) 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) { handleValue(data) {
...@@ -203,7 +201,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -203,7 +201,7 @@ export default class ProfitLossOLPA extends Component {
} }
} }
backToMasterBudget(type) { backToOLPA(type) {
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
...@@ -228,7 +226,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -228,7 +226,7 @@ export default class ProfitLossOLPA extends Component {
}) })
}) })
let payload = { let payload = {
"submission_id": this.props.submissionID, "outlook_pa_id": this.props.outlook_pa_id,
"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,
...@@ -237,13 +235,13 @@ export default class ProfitLossOLPA extends Component { ...@@ -237,13 +235,13 @@ export default class ProfitLossOLPA extends Component {
} }
console.log(data); console.log(data);
this.setState({ loading: false }) this.setState({ loading: false })
this.props.saveToMasterBudget(payload) this.props.saveToOLPA(payload)
this.props.onClickClose() this.props.onClickClose()
} }
downloadTemplate = async () => { downloadTemplate = async () => {
let res = await fetch( 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() res = await res.blob()
console.log(res) console.log(res)
...@@ -306,7 +304,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -306,7 +304,7 @@ export default class ProfitLossOLPA extends Component {
} }
checkUpload() { 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(JSON.stringify(this.state.payload));
console.log(response) console.log(response)
if (response.data) { if (response.data) {
...@@ -380,15 +378,15 @@ export default class ProfitLossOLPA extends Component { ...@@ -380,15 +378,15 @@ export default class ProfitLossOLPA extends Component {
}) })
}) })
let body = { let body = {
submission_id: this.props.submissionID, outlook_pa_id: this.props.outlook_pa_id,
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 status: type
} }
console.log(data); console.log(JSON.stringify(body));
api.create('UPLOAD').uploadMasterBudget(body).then(response => { api.create('UPLOAD').uploadOLPA(body).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
...@@ -400,18 +398,16 @@ export default class ProfitLossOLPA extends Component { ...@@ -400,18 +398,16 @@ export default class ProfitLossOLPA extends Component {
} else { } else {
this.setState({ loading: false }) this.setState({ loading: false })
alert(response.problem) alert(response.problem)
// 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}` 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/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 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); console.log(url);
let res = await fetch( let res = await fetch(
this.props.submissionID == null ? sub_null : url this.props.outlook_pa_id == null ? sub_null : url
) )
res = await res.blob() res = await res.blob()
this.setState({ loading: false }) this.setState({ loading: false })
...@@ -450,15 +446,15 @@ export default class ProfitLossOLPA extends Component { ...@@ -450,15 +446,15 @@ export default class ProfitLossOLPA extends Component {
}) })
}) })
let payload = { let payload = {
"submission_id": this.props.submissionID, "outlook_pa_id": this.props.outlook_pa_id,
"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": "submitted" "status": "submitted"
} }
console.log(payload) // console.log(payload)
api.create().validateSubmitReport(payload).then((response) => { api.create().validateSubmitReportOLPA(payload).then((response) => {
console.log(response) console.log(response)
if (response.data.data.result) { if (response.data.data.result) {
this.setState({ loading: false, buttonError: false, editable: false }) this.setState({ loading: false, buttonError: false, editable: false })
...@@ -2158,7 +2154,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -2158,7 +2154,7 @@ export default class ProfitLossOLPA extends Component {
</button> </button>
</div> </div>
{this.props.isApprover === true || this.state.dataTable.length == 0 ? null : {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%' }}> <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button <button
className="button" className="button"
...@@ -2196,7 +2192,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -2196,7 +2192,7 @@ export default class ProfitLossOLPA extends Component {
onClick={() => onClick={() =>
this.state.handleTekTekTek == 1? null : this.state.handleTekTekTek == 1? null :
this.setState({handleTekTekTek: 1}, () => { this.setState({handleTekTekTek: 1}, () => {
this.backToMasterBudget('draft') this.backToOLPA('draft')
}) })
} }
> >
...@@ -2212,7 +2208,7 @@ export default class ProfitLossOLPA extends Component { ...@@ -2212,7 +2208,7 @@ export default class ProfitLossOLPA extends Component {
: :
this.state.handleTekTekTek == 1? null : this.state.handleTekTekTek == 1? null :
this.setState({handleTekTekTek: 1}, () => { this.setState({handleTekTekTek: 1}, () => {
this.backToMasterBudget('submitted') this.backToOLPA('submitted')
})} })}
style={{ style={{
backgroundColor: 'transparent', 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