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

update

parent e4e3fd1b
......@@ -358,6 +358,8 @@ const create = (type = "") => {
const approvalSubmissionOLPA = (body) => api.post('transaction/outlook_pa/approval_outlook', body)
const checkApproverOLPA = () => api.get('transaction/outlook_pa/is_approver')
const createPeriodeRevisionOLPA = (body) => api.post('transaction/outlook_pa/create_periode_revision', body)
const getHierarkiCFOLPA = (body) => api.post('transaction/cash_flow/outlook_pa/get_report_hierarki', body)
const createCFOLPA = (body) => api.post ('transaction/cash_flow/outlook_pa/create_outlook_report', body)
// Monthly
const getMonthlyReport = (body) => api.post('transaction/monthly_report/get_all_report', body)
......@@ -786,7 +788,9 @@ const create = (type = "") => {
createPeriodeRevisionRO,
historyApprovalRO,
getRollingOutlookCF,
createRollingOutlookCF
createRollingOutlookCF,
getHierarkiCFOLPA,
createCFOLPA
}
}
......
......@@ -8,6 +8,7 @@ import MuiAlert from '@material-ui/lab/Alert';
import { titleCase } from '../library/Utils';
import ProfitLossOLPA from './OutlookPA/ProfitLossOLPA';
import TaxPlanning from './OutlookPA/TaxPlanningOLPA';
import CashFlow from './OutlookPA/CashFlowOLPA';
import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../library/Upload";
import { format } from 'date-fns';
......@@ -38,6 +39,7 @@ export default class OutlookPA extends Component {
report_id: null,
visibleBS: false,
visiblePL: false,
visibleCF: false,
listAttachment: [],
visibleUpload: false,
revisionTable: null,
......@@ -60,7 +62,9 @@ export default class OutlookPA extends Component {
latestPeriode: '',
minDateRevision: new Date(),
maxDateRevision: new Date(),
btnApprove: false
btnApprove: false,
listStatus: [],
selectedStatus: [],
}
this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this);
......@@ -82,55 +86,77 @@ export default class OutlookPA extends Component {
}
checkApprover() {
let listStatus1 = [
{ name: 'Open', value: 'not-yet' },
{ name: 'Submitted', value: 'approval_review' },
{ name: 'Waiting for Review / Approval', value: 'approval_proccess' },
{ name: 'Approved', value: 'approved' },
]
let listStatus2 = [
{ name: 'Open', value: 'not-yet' },
{ name: 'Submitted', value: 'approval_review' },
{ name: 'Approved', value: 'approved' },
]
api.create().checkApproverOLPA().then(response => {
// console.log(response);
if (response.data.data.is_approver === true) {
this.setState({ isApprover: true, checkApprover: true }, () =>
this.setState({ isApprover: true, checkApprover: true, listStatus: listStatus1, selectedStatus: listStatus1 }, () =>
this.getPeriode())
} else {
this.setState({ isApprover: false, checkApprover: false }, () =>
this.getDetailUser())
this.setState({ isApprover: false, checkApprover: false, listStatus: listStatus2, selectedStatus: listStatus2 }, () =>
this.getPeriode())
}
})
}
getCompanySubmitted() {
let selectedStatus = this.state.selectedStatus.map((item) => {
return item.value
})
let body = {
"periode": this.state.periode.periode
"periode": this.state.periode.periode,
"status": selectedStatus
}
api.create().getCompanySubmittedOLPA(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let companyData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name,
}
})
if (response.data.data.length > 0) {
let data = response.data.data
let companyData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name,
}
})
if (companyData.length > 0) {
companyData = companyData.sort((a,b) => a.company_name.localeCompare(b.company_name))
}
if (companyData.length > 0) {
companyData = companyData.sort((a, b) => a.company_name.localeCompare(b.company_name))
}
let defaultProps = {
options: companyData,
getOptionLabel: (option) => titleCase(option.company_name),
};
let indexID = null
if (this.state.rawData !== undefined) {
indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id)
}
this.setState({ listCompany: defaultProps, company: indexID == null ? companyData[0] : companyData[indexID] }, () => {
// // console.log(response.data.data);
if (response.data.data.length > 0) {
this.getRevision()
} else {
this.setState({ listRevision: null, revision: null, dataTable: [], checkApprover: false, lastRevision: "", visibleTableHistory: false, loading: false })
let defaultProps = {
options: companyData,
getOptionLabel: (option) => titleCase(option.company_name),
};
let indexID = null
if (this.state.rawData !== undefined) {
indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id)
}
//
})
this.setState({ listCompany: defaultProps, company: indexID == null ? companyData[0] : companyData[indexID] }, () => {
console.log(response.data.data);
if (response.data.data.length > 0) {
this.getRevision()
} else {
this.setState({ listRevision: null, revision: null, dataTable: [], checkApprover: false, lastRevision: "", visibleTableHistory: false, loading: false })
}
//
})
} else {
this.setState({ listRevision: null, revision: null, listCompany: null, company: null, dataTable: [], lastRevision: "", visibleTableHistory: false, loading: false }, () => {
document.body.style.overflow = 'unset';
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
......@@ -244,11 +270,41 @@ export default class OutlookPA extends Component {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.getRole(response.data.data.role_id)
this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive()
this.getCompanySubmitted()
})
}
}
}
})
}
getRole(id) {
api.create().getDetailRole(id).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
// this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
// // // console.log(response.data.data)
if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') {
this.setState({ isAdmin: true })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -268,7 +324,7 @@ export default class OutlookPA extends Component {
})
if (companyData.length > 0) {
companyData = companyData.sort((a,b) => a.company_name.localeCompare(b.company_name))
companyData = companyData.sort((a, b) => a.company_name.localeCompare(b.company_name))
}
let arrayBaru = []
......@@ -280,12 +336,12 @@ export default class OutlookPA extends Component {
})
if (arrayBaru.length > 0) {
arrayBaru = arrayBaru.sort((a,b) => a.company_name.localeCompare(b.company_name))
arrayBaru = arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name))
}
console.log(companyData)
console.log(arrayBaru)
let defaultProps = {
options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name),
......@@ -315,7 +371,7 @@ export default class OutlookPA extends Component {
// console.log(response);
let currentYear = new Date().getFullYear()
if (response.data.status === "success") {
this.setState({ lastPeriod: Number(response.data.data.last_periode) < Number(currentYear)? String(currentYear) : response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => {
this.setState({ lastPeriod: Number(response.data.data.last_periode) < Number(currentYear) ? String(currentYear) : response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => {
this.getPeriode()
})
}
......@@ -333,11 +389,11 @@ export default class OutlookPA extends Component {
let data = []
response.data.data.map((item) => {
if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
if (item >= 2000 && item <= (Number(currentYear))) {
data.push(item)
}
} else {
if ((item >= 2000) && (item == Number(this.state.lastPeriod) || item < Number(this.state.lastPeriod))) {
if ((item >= 2000) && (item == currentYear || item <= currentYear)) {
data.push(item)
}
}
......@@ -351,18 +407,19 @@ export default class OutlookPA extends Component {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriodProps == undefined ? Number(this.state.lastPeriod) : this.state.lastPeriodProps )
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriodProps == undefined ? Number(this.state.lastPeriod) : this.state.lastPeriodProps)
let index = data.sort((a, b) => a - b).findIndex((val) => val == periode)
// console.log(data)
// console.log(this.state.lastPeriod)
// console.log(periode)
// console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
if (this.state.isApprover === true) {
this.getCompanySubmitted()
} else {
this.getRevision()
}
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.getRevision()
// }
this.getDetailUser()
})
}
}
......@@ -437,7 +494,7 @@ export default class OutlookPA extends Component {
}, 1000);
}
})
}
}
} else {
this.setState({ outlook_pa_id: null, loading: false })
}
......@@ -481,7 +538,7 @@ export default class OutlookPA extends Component {
"max_periode": moment(this.state.maxDateRevision).format('YYYY-MM-DD')
}
// console.log(payload)
api.create().approvalSubmissionOLPA(body).then((res) => {
api.create().approvalSubmissionOLPA(body).then((res) => {
console.log(res)
this.setState({ loading: false }, () => {
this.getOutlookPAID()
......@@ -514,31 +571,40 @@ export default class OutlookPA extends Component {
visibleBS: true,
visiblePL: false,
visibleTP: false,
visibleCF: false
})
} else
if (item === 'Profit Loss') {
this.setState({
visibleOutlookPA: false,
visibleBS: false,
visiblePL: true,
visibleTP: false,
})
}
else if (item === 'Tax Planning') {
this.setState({
visibleOutlookPA: false,
visibleBS: false,
visiblePL: false,
visibleTP: true,
})
}
} else if (item === 'Profit Loss') {
this.setState({
visibleOutlookPA: false,
visibleBS: false,
visiblePL: true,
visibleTP: false,
visibleCF: false
})
} else if (item === 'Tax Planning') {
this.setState({
visibleOutlookPA: false,
visibleBS: false,
visiblePL: false,
visibleTP: true,
visibleCF: false
})
} else if (item === 'Cash Flow') {
this.setState({
visibleOutlookPA: false,
visibleBS: false,
visiblePL: false,
visibleTP: false,
visibleCF: true
})
}
})
}
validateRevision(){
validateRevision() {
let arrayRevisi = this.state.detailRevisiCheck
let remarksKosong = 0
arrayRevisi.map((item,index) => {
arrayRevisi.map((item, index) => {
if (item.remarks == "") {
remarksKosong += 1
}
......@@ -589,7 +655,7 @@ export default class OutlookPA extends Component {
}, 1000);
}
})
}
}
}
})
}
......@@ -608,7 +674,7 @@ export default class OutlookPA extends Component {
}, 1000);
}
})
}
}
}
})
}
......@@ -792,9 +858,9 @@ export default class OutlookPA extends Component {
borderColor: 'transparent'
}}
onClick={() =>
tableMeta.rowData[5] == true ?
// tableMeta.rowData[5] == true ?
this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
: null
// : null
}
>
{/* {this.state.isApprover == true ?
......@@ -974,11 +1040,12 @@ export default class OutlookPA extends Component {
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
// console.log(this.state.isApprover, this.state.company);
if (this.state.isApprover === true) {
this.setState({ visibleTableHistory: false })
if (this.state.listCompany == null) {
console.log('yak')
this.getCompanySubmitted()
} else {
this.setState({ visibleTableHistory: false })
console.log('zz')
this.getRevision()
}
})}
......@@ -991,6 +1058,23 @@ export default class OutlookPA extends Component {
value={this.state.periode}
/>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
multiple
id="tags-standard"
options={this.state.listStatus}
getOptionLabel={(option) => option.name}
style={{ width: 250 }}
onChange={(event, newInputValue) => {
this.setState({ selectedStatus: newInputValue, loading: true }, () => {
console.log(newInputValue);
this.getCompanySubmitted()
})
}}
value={this.state.selectedStatus}
renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />}
/>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listCompany}
......@@ -1334,6 +1418,25 @@ export default class OutlookPA extends Component {
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)}
{this.state.visibleCF && (
<CashFlow
open={this.props.open}
report_id={this.state.report_id}
height={this.props.height}
width={this.props.width}
company={this.state.company}
revision={this.state.revisionTable}
periode={this.state.periode.periode}
outlook_pa_id={this.state.outlook_pa_id}
saveToOLPA={this.saveToOLPA.bind(this)}
onClickClose={() => this.setState({ visibleCF: false, visibleOutlookPA: true })}
getReport={this.getOutlookPAID.bind(this)}
status={this.state.status}
isApprover={this.state.isApprover}
lastStatus={this.state.lastStatus}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)}
{this.state.visibleRevision && (
<div className="test app-popup-show">
......
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