Commit 1ecbe43f authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'GGMAC' into 'master'

Ggmac

See merge request !1393
parents 4f78f7ab 305be65c
...@@ -358,6 +358,8 @@ const create = (type = "") => { ...@@ -358,6 +358,8 @@ const create = (type = "") => {
const approvalSubmissionOLPA = (body) => api.post('transaction/outlook_pa/approval_outlook', body) const approvalSubmissionOLPA = (body) => api.post('transaction/outlook_pa/approval_outlook', body)
const checkApproverOLPA = () => api.get('transaction/outlook_pa/is_approver') const checkApproverOLPA = () => api.get('transaction/outlook_pa/is_approver')
const createPeriodeRevisionOLPA = (body) => api.post('transaction/outlook_pa/create_periode_revision', body) 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 // Monthly
const getMonthlyReport = (body) => api.post('transaction/monthly_report/get_all_report', body) const getMonthlyReport = (body) => api.post('transaction/monthly_report/get_all_report', body)
...@@ -786,7 +788,9 @@ const create = (type = "") => { ...@@ -786,7 +788,9 @@ const create = (type = "") => {
createPeriodeRevisionRO, createPeriodeRevisionRO,
historyApprovalRO, historyApprovalRO,
getRollingOutlookCF, getRollingOutlookCF,
createRollingOutlookCF createRollingOutlookCF,
getHierarkiCFOLPA,
createCFOLPA
} }
} }
......
...@@ -8,6 +8,7 @@ import MuiAlert from '@material-ui/lab/Alert'; ...@@ -8,6 +8,7 @@ import MuiAlert from '@material-ui/lab/Alert';
import { titleCase } from '../library/Utils'; import { titleCase } from '../library/Utils';
import ProfitLossOLPA from './OutlookPA/ProfitLossOLPA'; import ProfitLossOLPA from './OutlookPA/ProfitLossOLPA';
import TaxPlanning from './OutlookPA/TaxPlanningOLPA'; import TaxPlanning from './OutlookPA/TaxPlanningOLPA';
import CashFlow from './OutlookPA/CashFlowOLPA';
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../library/Upload"; import UploadFile from "../library/Upload";
import { format } from 'date-fns'; import { format } from 'date-fns';
...@@ -38,6 +39,7 @@ export default class OutlookPA extends Component { ...@@ -38,6 +39,7 @@ export default class OutlookPA extends Component {
report_id: null, report_id: null,
visibleBS: false, visibleBS: false,
visiblePL: false, visiblePL: false,
visibleCF: false,
listAttachment: [], listAttachment: [],
visibleUpload: false, visibleUpload: false,
revisionTable: null, revisionTable: null,
...@@ -60,7 +62,9 @@ export default class OutlookPA extends Component { ...@@ -60,7 +62,9 @@ export default class OutlookPA extends Component {
latestPeriode: '', latestPeriode: '',
minDateRevision: new Date(), minDateRevision: new Date(),
maxDateRevision: new Date(), maxDateRevision: new Date(),
btnApprove: false btnApprove: false,
listStatus: [],
selectedStatus: [],
} }
this.myRef = React.createRef() this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -82,26 +86,43 @@ export default class OutlookPA extends Component { ...@@ -82,26 +86,43 @@ export default class OutlookPA extends Component {
} }
checkApprover() { 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 => { api.create().checkApproverOLPA().then(response => {
// console.log(response); // console.log(response);
if (response.data.data.is_approver === true) { 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()) this.getPeriode())
} else { } else {
this.setState({ isApprover: false, checkApprover: false }, () => this.setState({ isApprover: false, checkApprover: false, listStatus: listStatus2, selectedStatus: listStatus2 }, () =>
this.getDetailUser()) this.getPeriode())
} }
}) })
} }
getCompanySubmitted() { getCompanySubmitted() {
let selectedStatus = this.state.selectedStatus.map((item) => {
return item.value
})
let body = { let body = {
"periode": this.state.periode.periode "periode": this.state.periode.periode,
"status": selectedStatus
} }
api.create().getCompanySubmittedOLPA(body).then(response => { api.create().getCompanySubmittedOLPA(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') {
if (response.data.data.length > 0) {
let data = response.data.data let data = response.data.data
let companyData = data.map((item) => { let companyData = data.map((item) => {
return { return {
...@@ -111,7 +132,7 @@ export default class OutlookPA extends Component { ...@@ -111,7 +132,7 @@ export default class OutlookPA extends Component {
}) })
if (companyData.length > 0) { 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 defaultProps = { let defaultProps = {
...@@ -123,7 +144,7 @@ export default class OutlookPA extends Component { ...@@ -123,7 +144,7 @@ export default class OutlookPA extends Component {
indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id) indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id)
} }
this.setState({ listCompany: defaultProps, company: indexID == null ? companyData[0] : companyData[indexID] }, () => { this.setState({ listCompany: defaultProps, company: indexID == null ? companyData[0] : companyData[indexID] }, () => {
// // console.log(response.data.data); console.log(response.data.data);
if (response.data.data.length > 0) { if (response.data.data.length > 0) {
this.getRevision() this.getRevision()
} else { } else {
...@@ -131,6 +152,11 @@ export default class OutlookPA extends Component { ...@@ -131,6 +152,11 @@ export default class OutlookPA extends Component {
} }
// //
}) })
} else {
this.setState({ listRevision: null, revision: null, listCompany: null, company: null, dataTable: [], lastRevision: "", visibleTableHistory: false, loading: false }, () => {
document.body.style.overflow = 'unset';
})
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -244,8 +270,9 @@ export default class OutlookPA extends Component { ...@@ -244,8 +270,9 @@ export default class OutlookPA extends Component {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.getRole(response.data.data.role_id)
this.setState({ userCompany: response.data.data.company }, () => { this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive() this.getCompanySubmitted()
}) })
} }
} }
...@@ -253,6 +280,35 @@ export default class OutlookPA extends Component { ...@@ -253,6 +280,35 @@ export default class OutlookPA extends Component {
}) })
} }
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' })
}
})
}
getCompanyActive() { getCompanyActive() {
api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
console.log(response); console.log(response);
...@@ -268,7 +324,7 @@ export default class OutlookPA extends Component { ...@@ -268,7 +324,7 @@ export default class OutlookPA extends Component {
}) })
if (companyData.length > 0) { 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 = [] let arrayBaru = []
...@@ -280,7 +336,7 @@ export default class OutlookPA extends Component { ...@@ -280,7 +336,7 @@ export default class OutlookPA extends Component {
}) })
if (arrayBaru.length > 0) { 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(companyData)
...@@ -315,7 +371,7 @@ export default class OutlookPA extends Component { ...@@ -315,7 +371,7 @@ export default class OutlookPA extends Component {
// console.log(response); // console.log(response);
let currentYear = new Date().getFullYear() let currentYear = new Date().getFullYear()
if (response.data.status === "success") { 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() this.getPeriode()
}) })
} }
...@@ -333,11 +389,11 @@ export default class OutlookPA extends Component { ...@@ -333,11 +389,11 @@ export default class OutlookPA extends Component {
let data = [] let data = []
response.data.data.map((item) => { response.data.data.map((item) => {
if (this.state.isApprover) { if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) { if (item >= 2000 && item <= (Number(currentYear))) {
data.push(item) data.push(item)
} }
} else { } else {
if ((item >= 2000) && (item == Number(this.state.lastPeriod) || item < Number(this.state.lastPeriod))) { if ((item >= 2000) && (item == currentYear || item <= currentYear)) {
data.push(item) data.push(item)
} }
} }
...@@ -351,18 +407,19 @@ export default class OutlookPA extends Component { ...@@ -351,18 +407,19 @@ export default class OutlookPA extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, 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) let index = data.sort((a, b) => a - b).findIndex((val) => val == periode)
// console.log(data) // console.log(data)
// console.log(this.state.lastPeriod) // console.log(this.state.lastPeriod)
// console.log(periode) // console.log(periode)
// console.log(index) // console.log(index)
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()
} else { // } else {
this.getRevision() // this.getRevision()
} // }
this.getDetailUser()
}) })
} }
} }
...@@ -514,31 +571,40 @@ export default class OutlookPA extends Component { ...@@ -514,31 +571,40 @@ export default class OutlookPA extends Component {
visibleBS: true, visibleBS: true,
visiblePL: false, visiblePL: false,
visibleTP: false, visibleTP: false,
visibleCF: false
}) })
} else } else if (item === 'Profit Loss') {
if (item === 'Profit Loss') {
this.setState({ this.setState({
visibleOutlookPA: false, visibleOutlookPA: false,
visibleBS: false, visibleBS: false,
visiblePL: true, visiblePL: true,
visibleTP: false, visibleTP: false,
visibleCF: false
}) })
} } else if (item === 'Tax Planning') {
else if (item === 'Tax Planning') {
this.setState({ this.setState({
visibleOutlookPA: false, visibleOutlookPA: false,
visibleBS: false, visibleBS: false,
visiblePL: false, visiblePL: false,
visibleTP: true, 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 arrayRevisi = this.state.detailRevisiCheck
let remarksKosong = 0 let remarksKosong = 0
arrayRevisi.map((item,index) => { arrayRevisi.map((item, index) => {
if (item.remarks == "") { if (item.remarks == "") {
remarksKosong += 1 remarksKosong += 1
} }
...@@ -792,9 +858,9 @@ export default class OutlookPA extends Component { ...@@ -792,9 +858,9 @@ export default class OutlookPA extends Component {
borderColor: 'transparent' borderColor: 'transparent'
}} }}
onClick={() => onClick={() =>
tableMeta.rowData[5] == true ? // tableMeta.rowData[5] == true ?
this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3]) this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
: null // : null
} }
> >
{/* {this.state.isApprover == true ? {/* {this.state.isApprover == true ?
...@@ -974,11 +1040,12 @@ export default class OutlookPA extends Component { ...@@ -974,11 +1040,12 @@ export default class OutlookPA extends Component {
{...this.state.listPeriode} {...this.state.listPeriode}
id="periode" id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
// console.log(this.state.isApprover, this.state.company); this.setState({ visibleTableHistory: false })
if (this.state.isApprover === true) { if (this.state.listCompany == null) {
console.log('yak')
this.getCompanySubmitted() this.getCompanySubmitted()
} else { } else {
this.setState({ visibleTableHistory: false }) console.log('zz')
this.getRevision() this.getRevision()
} }
})} })}
...@@ -991,6 +1058,23 @@ export default class OutlookPA extends Component { ...@@ -991,6 +1058,23 @@ export default class OutlookPA extends Component {
value={this.state.periode} value={this.state.periode}
/> />
</div> </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 }}> <div style={{ marginTop: 20 }}>
<Autocomplete <Autocomplete
{...this.state.listCompany} {...this.state.listCompany}
...@@ -1334,6 +1418,25 @@ export default class OutlookPA extends Component { ...@@ -1334,6 +1418,25 @@ export default class OutlookPA extends Component {
prevRevision={this.state.isSubmit ? this.state.prevRevision : true} 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 && ( {this.state.visibleRevision && (
<div className="test app-popup-show"> <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