Commit 05a0c2a1 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

Deni dev(pc)

See merge request !429
parents 39b813fa 64a6d12d
...@@ -204,6 +204,7 @@ const create = (type = "") => { ...@@ -204,6 +204,7 @@ const create = (type = "") => {
const checkApprover = () => api.get('transaction/master_budget/is_approver') const checkApprover = () => api.get('transaction/master_budget/is_approver')
const approvalSubmission = (body) => api.post('transaction/master_budget/approval_submission', body) const approvalSubmission = (body) => api.post('transaction/master_budget/approval_submission', body)
const getCompanySubmitted = (body) => api.post('transaction/get_company_submitted', body) const getCompanySubmitted = (body) => api.post('transaction/get_company_submitted', body)
const getLastPeriod = (idCompany) => api.get(`transaction/get_last_periode/${idCompany}`)
const getIdDeleteFromExcel = (body) => api.post('transaction/master_budget/delete_from_excel', body) const getIdDeleteFromExcel = (body) => api.post('transaction/master_budget/delete_from_excel', body)
const getOpetratingIndID = (body) => api.post('transaction/get_operating_indicator_id', body) const getOpetratingIndID = (body) => api.post('transaction/get_operating_indicator_id', body)
...@@ -367,7 +368,8 @@ const create = (type = "") => { ...@@ -367,7 +368,8 @@ const create = (type = "") => {
historyApproval, historyApproval,
checkApprover, checkApprover,
approvalSubmission, approvalSubmission,
getCompanySubmitted getCompanySubmitted,
getLastPeriod
} }
} }
......
...@@ -70,7 +70,7 @@ export default class BudgetTahunan extends Component { ...@@ -70,7 +70,7 @@ export default class BudgetTahunan extends Component {
this.props.selectIndex('Master Budget & CAT') this.props.selectIndex('Master Budget & CAT')
if (this.props.location.state !== undefined) { if (this.props.location.state !== undefined) {
console.log(this.props); console.log(this.props);
this.setState({ userType: this.props.location.state.userType, intent: 'Home', rawData: this.props.location.state.rawData }, () => { this.setState({ userType: this.props.location.state.userType, intent: 'Home', lastPeriod: this.props.location.state.rawData }, () => {
this.checkApprover() this.checkApprover()
}) })
} else { } else {
...@@ -232,7 +232,7 @@ export default class BudgetTahunan extends Component { ...@@ -232,7 +232,7 @@ export default class BudgetTahunan extends Component {
}; };
let index = arrayBaru.findIndex((val) => val.company_id == comID) let index = arrayBaru.findIndex((val) => val.company_id == comID)
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => { this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
this.getPeriode() this.getLastPeriod()
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -250,10 +250,21 @@ export default class BudgetTahunan extends Component { ...@@ -250,10 +250,21 @@ export default class BudgetTahunan extends Component {
}) })
} }
getLastPeriod(){
api.create().getLastPeriod(this.state.company.company_id).then(response => {
console.log(response);
if (response.data.status === "success") {
this.setState({ lastPeriod : response.data.data.last_periode}, ()=> {
this.getPeriode()
})
}
})
}
getPeriode() { getPeriode() {
api.create().getPeriodeTransaction().then(response => { api.create().getPeriodeTransaction().then(response => {
let dateNow = new Date // let dateNow = new Date
let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy') // let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy')
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
let data = response.data.data let data = response.data.data
...@@ -266,7 +277,7 @@ export default class BudgetTahunan extends Component { ...@@ -266,7 +277,7 @@ export default class BudgetTahunan extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, getOptionLabel: (option) => option.periode,
}; };
let index = data.sort((a, b) => a - b).findIndex((val) => val === year) let index = data.sort((a, b) => a - b).findIndex((val) => val === this.state.lastPeriod)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => { this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
if (this.state.isApprover === true) { if (this.state.isApprover === true) {
this.getCompanySubmitted() this.getCompanySubmitted()
......
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