Commit b66bbe9b authored by Riri Novita's avatar Riri Novita

Update Monthly Currency

parent 2cde66a3
...@@ -51,7 +51,7 @@ export default class EditApprovalMatrix extends Component { ...@@ -51,7 +51,7 @@ export default class EditApprovalMatrix extends Component {
getDetailAM() { getDetailAM() {
api.create().getDetailAM(this.props.data[1]).then(response => { api.create().getDetailAM(this.props.data[1]).then(response => {
// console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
...@@ -89,6 +89,8 @@ export default class EditApprovalMatrix extends Component { ...@@ -89,6 +89,8 @@ export default class EditApprovalMatrix extends Component {
getUserData() { getUserData() {
api.create().getApprovedByAM().then((response) => { api.create().getApprovedByAM().then((response) => {
console.log(response);
console.log(this.state.getUserId);
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
......
...@@ -95,7 +95,21 @@ export default class MonthlyReport extends Component { ...@@ -95,7 +95,21 @@ export default class MonthlyReport extends Component {
isCheckAll: false, isCheckAll: false,
downloadedFileReportId: null, downloadedFileReportId: null,
arrayReport: [], arrayReport: [],
popupDownload: false popupDownload: false,
defaultCurrency: null,
dataCurrency: [],
currency: [],
visibleAlertSave: false,
dataCurrency: [
{
"id": 1,
"value": "IDR"
},
{
"id": 2,
"value": "USD",
}
]
} }
this.myRef = React.createRef() this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -237,6 +251,7 @@ export default class MonthlyReport extends Component { ...@@ -237,6 +251,7 @@ export default class MonthlyReport extends Component {
"periode": this.state.periode.periode, "periode": this.state.periode.periode,
"report_type": "Monthly Report", "report_type": "Monthly Report",
"months": this.state.month.month_id, "months": this.state.month.month_id,
"currency_id": this.state.defaultCurrency.id
} }
api.create().getMonthlyReport(payload).then(response => { api.create().getMonthlyReport(payload).then(response => {
console.log(response); console.log(response);
...@@ -308,6 +323,7 @@ export default class MonthlyReport extends Component { ...@@ -308,6 +323,7 @@ export default class MonthlyReport extends Component {
}; };
this.setState({ listCompany: defaultProps, company: companyData[0], company_active: defaultProps }, () => { this.setState({ listCompany: defaultProps, company: companyData[0], company_active: defaultProps }, () => {
this.getMonth() this.getMonth()
this.getCurrency(this.state.company.company_id)
// console.log(this.state.company_active) // console.log(this.state.company_active)
}) })
} else { } else {
...@@ -459,6 +475,51 @@ export default class MonthlyReport extends Component { ...@@ -459,6 +475,51 @@ export default class MonthlyReport extends Component {
}) })
} }
getCurrency(companyID) {
console.log(companyID);
api.create().getDetailPerusahaan(companyID).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
let datas = []
if (response.data.data.currency.length > 0) {
response.data.data.currency.map((item) => {
// console.log(item);
datas.push({
id: item.currencyId,
value: item.currencyName
})
})
}
let index = datas.findIndex((val) => val.id == response.data.data.default_currency)
this.setState({
defaultCurrencyID: response.data.data.default_currency,
currency: datas,
defaultCurrency: index == -1 ? null : datas[index]
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
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' })
}
})
}
getDetailUser() { getDetailUser() {
let userId = localStorage.getItem(Constant.USER) let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => { api.create().getDetailUser(userId).then((response) => {
...@@ -548,9 +609,10 @@ export default class MonthlyReport extends Component { ...@@ -548,9 +609,10 @@ export default class MonthlyReport extends Component {
} }
// console.log(response.data.data.length) // console.log(response.data.data.length)
this.setState({ listCompany: defaultProps, company: indexID == null ? arrayBaru[0] : arrayBaru[indexID], company_submit: defaultProps }, () => { this.setState({ listCompany: defaultProps, company: indexID == null ? arrayBaru[0] : arrayBaru[indexID], company_submit: defaultProps }, () => {
// console.log(response.data.data.length) console.log(this.state.company)
if (response.data.data.length > 0) { if (response.data.data.length > 0) {
this.getRevision() this.getRevision()
this.getCurrency(this.state.company.company_id)
} else { } else {
// console.log(this.state.listCompany) // console.log(this.state.listCompany)
// console.log(this.state.company_submit) // console.log(this.state.company_submit)
...@@ -1817,13 +1879,13 @@ export default class MonthlyReport extends Component { ...@@ -1817,13 +1879,13 @@ export default class MonthlyReport extends Component {
} }
}) })
if (tableMeta[5] == "Direct Material" && typeRO != undefined) { // if (tableMeta[5] == "Direct Material" && typeRO != undefined) {
console.log(splitFormula) // console.log(splitFormula)
console.log(baru) // console.log(baru)
console.log(anjay) // console.log(anjay)
console.log(anjay2) // console.log(anjay2)
console.log(total) // console.log(total)
} // }
total = R.equals(total, NaN) ? "0.0" : total total = R.equals(total, NaN) ? "0.0" : total
return total return total
...@@ -2266,7 +2328,7 @@ export default class MonthlyReport extends Component { ...@@ -2266,7 +2328,7 @@ export default class MonthlyReport extends Component {
// } // }
async handleGenerateReport(data) { async handleGenerateReport(data) {
let { selectReport, monthlyReportId, company, periode, revisionTable, month, downloadedFileReportId } = this.state let { selectReport, monthlyReportId, company, periode, revisionTable, month, downloadedFileReportId, defaultCurrency } = this.state
if (selectReport.length > 0) { if (selectReport.length > 0) {
let result = [] let result = []
console.log('mulai hit') console.log('mulai hit')
...@@ -2274,9 +2336,9 @@ export default class MonthlyReport extends Component { ...@@ -2274,9 +2336,9 @@ export default class MonthlyReport extends Component {
let urlReport = items === 8 ? "profit_loss" : items === 12 ? "tax_planning" : items === 7 ? "balance_sheet" : items === 9 ? "fam" : items === 13 ? "cash_flow" : items === 11 ? "locf" : items === 10 ? "cat" : null let urlReport = items === 8 ? "profit_loss" : items === 12 ? "tax_planning" : items === 7 ? "balance_sheet" : items === 9 ? "fam" : items === 13 ? "cash_flow" : items === 11 ? "locf" : items === 10 ? "cat" : null
let datas = data.findIndex((val) => val[4] == items) let datas = data.findIndex((val) => val[4] == items)
let report = data[datas] let report = data[datas]
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/${urlReport}/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}` let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/${urlReport}/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
let res = await fetch( let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/${urlReport}/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}` `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/${urlReport}/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
) )
if (res.status === 200) { if (res.status === 200) {
result = [...result, res]; result = [...result, res];
...@@ -2843,7 +2905,7 @@ export default class MonthlyReport extends Component { ...@@ -2843,7 +2905,7 @@ export default class MonthlyReport extends Component {
</div> </div>
<div style={{ marginTop: 20 }}> <div style={{ display: 'flex', marginTop: 20 }}>
<Autocomplete <Autocomplete
multiple multiple
id="tags-standard" id="tags-standard"
...@@ -2859,6 +2921,32 @@ export default class MonthlyReport extends Component { ...@@ -2859,6 +2921,32 @@ export default class MonthlyReport extends Component {
value={this.state.selectedStatus} value={this.state.selectedStatus}
renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />} renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />}
/> />
<Autocomplete
id="tipe"
disableClearable
options={this.state.currency}
getOptionLabel={(option) => option.value}
value={this.state.defaultCurrency}
// onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue })}
onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue }, () => {
this.getRevision()
})}
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Currency" margin="normal" style={{ marginTop: 7, marginLeft: 20 }} />}
// renderInput={(params) =>
// <TextField
// {...params}
// variant="standard"
// label="Currency"
// margin="normal"
// style={{ marginTop: 6 }}
// // InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
// // InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
// />
// }
/>
{/* <Autocomplete {/* <Autocomplete
{...this.state.listCompany} {...this.state.listCompany}
multiple multiple
...@@ -2879,6 +2967,7 @@ export default class MonthlyReport extends Component { ...@@ -2879,6 +2967,7 @@ export default class MonthlyReport extends Component {
disabled={this.state.listCompany === null ? true : false} disabled={this.state.listCompany === null ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => { onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => {
this.getMonthlyReportID() this.getMonthlyReportID()
this.getCurrency(newInputValue.company_id)
})} })}
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
...@@ -3257,6 +3346,8 @@ export default class MonthlyReport extends Component { ...@@ -3257,6 +3346,8 @@ export default class MonthlyReport extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
...@@ -3278,6 +3369,8 @@ export default class MonthlyReport extends Component { ...@@ -3278,6 +3369,8 @@ export default class MonthlyReport extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
...@@ -3300,6 +3393,8 @@ export default class MonthlyReport extends Component { ...@@ -3300,6 +3393,8 @@ export default class MonthlyReport extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
...@@ -3322,6 +3417,8 @@ export default class MonthlyReport extends Component { ...@@ -3322,6 +3417,8 @@ export default class MonthlyReport extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
...@@ -3342,6 +3439,8 @@ export default class MonthlyReport extends Component { ...@@ -3342,6 +3439,8 @@ export default class MonthlyReport extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
...@@ -3363,6 +3462,8 @@ export default class MonthlyReport extends Component { ...@@ -3363,6 +3462,8 @@ export default class MonthlyReport extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
...@@ -3383,6 +3484,8 @@ export default class MonthlyReport extends Component { ...@@ -3383,6 +3484,8 @@ export default class MonthlyReport extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
...@@ -3401,6 +3504,8 @@ export default class MonthlyReport extends Component { ...@@ -3401,6 +3504,8 @@ export default class MonthlyReport extends Component {
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
......
...@@ -93,7 +93,9 @@ export default class ProfitLossMR extends Component { ...@@ -93,7 +93,9 @@ export default class ProfitLossMR extends Component {
saveDraft: true, saveDraft: true,
buttonError: true, buttonError: true,
viewOnly: true, viewOnly: true,
get_for: 'view' get_for: 'view',
defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -223,6 +225,7 @@ export default class ProfitLossMR extends Component { ...@@ -223,6 +225,7 @@ export default class ProfitLossMR extends Component {
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
"monthly_report_id": this.props.monthlyReportId, "monthly_report_id": this.props.monthlyReportId,
"months": this.props.month.month_id, "months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id,
"get_for": this.state.get_for "get_for": this.state.get_for
} }
console.log(payload); console.log(payload);
...@@ -402,6 +405,7 @@ export default class ProfitLossMR extends Component { ...@@ -402,6 +405,7 @@ export default class ProfitLossMR extends Component {
"report_id": this.props.report_id, "report_id": this.props.report_id,
"status": type, "status": type,
"months": this.props.month.month_id, "months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id,
"profit_loss": data "profit_loss": data
} }
console.log(payload); console.log(payload);
...@@ -474,7 +478,11 @@ export default class ProfitLossMR extends Component { ...@@ -474,7 +478,11 @@ export default class ProfitLossMR extends Component {
} }
checkUpload() { checkUpload() {
api.create().checkUploadMonthlyReportPL(this.state.payload).then(response => { let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
api.create().checkUploadMonthlyReportPL(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) {
...@@ -568,6 +576,7 @@ export default class ProfitLossMR extends Component { ...@@ -568,6 +576,7 @@ export default class ProfitLossMR extends Component {
"periode": this.props.periode, "periode": this.props.periode,
"report_id": this.props.report_id, "report_id": this.props.report_id,
"months": this.props.month.month_id, "months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id,
"status": type, "status": type,
"profit_loss": data "profit_loss": data
} }
...@@ -653,6 +662,7 @@ export default class ProfitLossMR extends Component { ...@@ -653,6 +662,7 @@ export default class ProfitLossMR extends Component {
"report_id": this.props.report_id, "report_id": this.props.report_id,
"status": "submitted", "status": "submitted",
"months": this.props.month.month_id, "months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id,
"profit_loss": data "profit_loss": data
} }
// console.log(JSON.stringify(payload)); // console.log(JSON.stringify(payload));
......
...@@ -14,6 +14,21 @@ import { format } from 'date-fns'; ...@@ -14,6 +14,21 @@ import { format } from 'date-fns';
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
const defaultReport = [
{ value: 2, label: 'DB Balance Sheet', report: 1 },
{ value: 3, label: 'DB Profit & Loss', report: 2 },
{ value: 1, label: 'DB Profit & Loss Detail', report: 2 },
{ value: 4, label: 'DB Ratio', report: 1 },
{ value: 5, label: 'DB Tax Planning', report: 1 },
{ value: 21, label: 'DB Operating Indicator', report: 1 },
{ value: 6, label: 'Cash Flow - Summary', report: 1 },
{ value: 7, label: 'Balance Sheet - Summary', report: 1 },
{ value: 8, label: 'Profit Loss - Summary', report: 2 },
{ value: 9, label: 'Financial Ratio - Summary', report: 1 },
{ value: 11, label: 'CAT Performance Quarterly', report: 1 },
{ value: 10, label: 'CAT Performance Appraisal', report: 1 },
]
export default class SubHolding extends Component { export default class SubHolding extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -26,19 +41,11 @@ export default class SubHolding extends Component { ...@@ -26,19 +41,11 @@ export default class SubHolding extends Component {
company: null, company: null,
listPeriode: null, listPeriode: null,
periode: null, periode: null,
reportType: [ reportType: defaultReport,
{ value: 2, label: 'DB Balance Sheet' }, reportType2: [
{ value: 3, label: 'DB Profit & Loss' }, { value: 3, label: 'DB Profit & Loss' },
{ value: 1, label: 'DB Profit & Loss Detail' }, { value: 1, label: 'DB Profit & Loss Detail' },
{ value: 4, label: 'DB Ratio' },
{ value: 5, label: 'DB Tax Planning' },
{ value: 21, label: 'DB Operating Indicator' },
{ value: 6, label: 'Cash Flow - Summary' },
{ value: 7, label: 'Balance Sheet - Summary' },
{ value: 8, label: 'Profit Loss - Summary' }, { value: 8, label: 'Profit Loss - Summary' },
{ value: 9, label: 'Financial Ratio - Summary' },
{ value: 11, label: 'CAT Performance Quarterly' },
{ value: 10, label: 'CAT Performance Appraisal' },
], ],
report: null, report: null,
loading: false, loading: false,
...@@ -51,7 +58,22 @@ export default class SubHolding extends Component { ...@@ -51,7 +58,22 @@ export default class SubHolding extends Component {
quarter: null, quarter: null,
uom: null, uom: null,
approveMB: false, approveMB: false,
approveMonthly: false approveMonthly: false,
defaultCurrency: null,
defaultCurrencyID: null,
dataCurrency: [],
currency: [],
visibleAlertSave: false,
dataCurrency: [
{
"id": 1,
"value": "IDR"
},
{
"id": 2,
"value": "USD",
}
]
} }
} }
...@@ -183,6 +205,7 @@ export default class SubHolding extends Component { ...@@ -183,6 +205,7 @@ export default class SubHolding 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.getLastPeriod() this.getLastPeriod()
this.getCurrency(this.state.company.company_id)
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -200,6 +223,60 @@ export default class SubHolding extends Component { ...@@ -200,6 +223,60 @@ export default class SubHolding extends Component {
}) })
} }
getCurrency(companyID) {
// console.log(companyID);
api.create().getDetailPerusahaan(companyID).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
let datas = []
if (response.data.data.currency.length > 0) {
response.data.data.currency.map((item) => {
// console.log(item);
datas.push({
id: item.currencyId,
value: item.currencyName
})
})
}
let index = datas.findIndex((val) => val.id == response.data.data.default_currency)
this.setState({
defaultCurrencyID: response.data.data.default_currency,
currency: datas,
// report: response.data.data.default_currency == 2 && this.state.defaultCurrency == 1 ? this.state.reportType2[0] : this.state.reportType[0],
defaultCurrency: index == -1 ? null : datas[index]
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
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' })
}
})
}
changeCurrency(idCurrency) {
if (this.state.defaultCurrencyID == 2 && idCurrency == 1) {
this.setState({ reportType: this.state.reportType2, report: this.state.reportType2[0] })
} else {
this.setState({ reportType: this.state.reportType, report: this.state.reportType[0] })
}
}
getLastPeriod() { getLastPeriod() {
api.create().getLastPeriod(this.state.company.company_id).then(response => { api.create().getLastPeriod(this.state.company.company_id).then(response => {
console.log(response); console.log(response);
...@@ -354,6 +431,7 @@ export default class SubHolding extends Component { ...@@ -354,6 +431,7 @@ export default class SubHolding extends Component {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
"periode": this.state.periode.periode, "periode": this.state.periode.periode,
"report_type": "Master Budget", "report_type": "Master Budget",
"currency_id": this.state.defaultCurrency.id
} }
this.getApproveMB() this.getApproveMB()
this.getApproveMonthly() this.getApproveMonthly()
...@@ -445,7 +523,9 @@ export default class SubHolding extends Component { ...@@ -445,7 +523,9 @@ export default class SubHolding extends Component {
"revision": this.state.revisionType, "revision": this.state.revisionType,
"periode": this.state.periode.periode, "periode": this.state.periode.periode,
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
"submission_id": this.state.submissionID "submission_id": this.state.submissionID,
"currency_id": this.state.defaultCurrency.id
} }
if (this.state.report.value === 1) { if (this.state.report.value === 1) {
api.create().getAllReportPLDetail(payload).then(response => { api.create().getAllReportPLDetail(payload).then(response => {
...@@ -4174,6 +4254,7 @@ export default class SubHolding extends Component { ...@@ -4174,6 +4254,7 @@ export default class SubHolding extends Component {
} }
render() { render() {
let { defaultCurrencyID, report } = this.state
const loadingComponent = ( const loadingComponent = (
<div style={{ position: 'fixed', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}> <div style={{ position: 'fixed', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader <PropagateLoader
...@@ -4254,6 +4335,7 @@ export default class SubHolding extends Component { ...@@ -4254,6 +4335,7 @@ export default class SubHolding extends Component {
disabled={this.state.intent === 'Home' ? true : false} disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true, previewTable: false }, () => { onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true, previewTable: false }, () => {
this.getReportType() this.getReportType()
this.getCurrency(newInputValue.company_id)
})} })}
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
...@@ -4273,6 +4355,35 @@ export default class SubHolding extends Component { ...@@ -4273,6 +4355,35 @@ export default class SubHolding extends Component {
renderInput={(params) => <TextField {...params} label="Months" margin="normal" style={{ marginTop: 7 }} />} renderInput={(params) => <TextField {...params} label="Months" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.month} value={this.state.month}
/> : null : null} /> : null : null}
<Autocomplete
id="tipe"
disabled={this.state.intent === 'Home' ? true : false}
options={this.state.currency}
getOptionLabel={(option) => option.value}
onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue, loading: true, previewTable: false }, () => {
// console.log(defaultCurrencyID);
// console.log(newInputValue.id);
// if (defaultCurrencyID == 2 && newInputValue.id == 1) {
// this.setState({ report: this.state.reportType2[0], reportType: this.state.reportType2 })
// console.log("report 1");
// } else if (defaultCurrencyID == 2 && newInputValue.id == 2) {
// console.log(this.state.reportType)
// this.setState({ report: defaultReport[0], reportType: defaultReport }, () => {
// console.log(this.state.reportType)
// })
// console.log("report 2");
// }
let bizpar = defaultCurrencyID == 2 && newInputValue.id == 1 ? defaultReport.filter(e => e.report === 2) : defaultReport
this.setState({ report: bizpar[0], reportType: bizpar })
this.getReportType()
})}
disableClearable
style={{ width: 250, marginLeft: 20 }}
renderInput={(params) => <TextField {...params} label="Currency" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.defaultCurrency}
/>
{/* {this.state.report != null ? String(this.state.report.label).toLocaleLowerCase().includes('summary') ? <Autocomplete {/* {this.state.report != null ? String(this.state.report.label).toLocaleLowerCase().includes('summary') ? <Autocomplete
{...this.state.listUom} {...this.state.listUom}
// getOptionLabel={(option) => titleCase(option.label)} // getOptionLabel={(option) => titleCase(option.label)}
......
...@@ -94,7 +94,21 @@ export default class RollingOutlook extends Component { ...@@ -94,7 +94,21 @@ export default class RollingOutlook extends Component {
isCheckAll: false, isCheckAll: false,
downloadedFileReportId: null, downloadedFileReportId: null,
arrayReport: [], arrayReport: [],
popupDownload: false popupDownload: false,
defaultCurrency: null,
dataCurrency: [],
currency: [],
visibleAlertSave: false,
dataCurrency: [
{
"id": 1,
"value": "IDR"
},
{
"id": 2,
"value": "USD",
}
]
} }
this.myRef = React.createRef() this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -221,6 +235,7 @@ export default class RollingOutlook extends Component { ...@@ -221,6 +235,7 @@ export default class RollingOutlook extends Component {
// console.log(response.data.data.length) // console.log(response.data.data.length)
if (response.data.data.length > 0) { if (response.data.data.length > 0) {
this.getRevision() this.getRevision()
this.getCurrency(this.state.company.company_id)
} else { } else {
// console.log(this.state.listCompany) // console.log(this.state.listCompany)
// console.log(this.state.company_submit) // console.log(this.state.company_submit)
...@@ -249,6 +264,50 @@ export default class RollingOutlook extends Component { ...@@ -249,6 +264,50 @@ export default class RollingOutlook extends Component {
}) })
} }
getCurrency(companyID) {
// console.log(companyID);
api.create().getDetailPerusahaan(companyID).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
let datas = []
if (response.data.data.currency.length > 0) {
response.data.data.currency.map((item) => {
// console.log(item);
datas.push({
id: item.currencyId,
value: item.currencyName
})
})
}
let index = datas.findIndex((val) => val.id == response.data.data.default_currency)
this.setState({
defaultCurrencyID: response.data.data.default_currency,
currency: datas,
defaultCurrency: index == -1 ? null : datas[index]
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
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' })
}
})
}
getReportAttachment() { getReportAttachment() {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
...@@ -1881,7 +1940,7 @@ export default class RollingOutlook extends Component { ...@@ -1881,7 +1940,7 @@ export default class RollingOutlook extends Component {
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Rolling Outlook & CAT</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Rolling Outlook & CAT</Typography>
</div> </div>
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
<div> <div style={{ display: 'flex' }}>
<Autocomplete <Autocomplete
{...this.state.listPeriode} {...this.state.listPeriode}
id="periode" id="periode"
...@@ -1901,6 +1960,27 @@ export default class RollingOutlook extends Component { ...@@ -1901,6 +1960,27 @@ export default class RollingOutlook extends Component {
/>} />}
value={this.state.periode} value={this.state.periode}
/> />
<Autocomplete
id="tipe"
disableClearable
style={{ width: 250 }}
options={this.state.currency}
getOptionLabel={(option) => option.value}
value={this.state.defaultCurrency}
onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue }, () => {
this.getRevision()
})}
renderInput={(params) =>
<TextField
{...params}
variant="standard"
label="Currency"
margin="normal"
style={{ marginLeft: 25, marginTop: 7 }}
/>
}
/>
</div> </div>
<div style={{ marginTop: 20 }}> <div style={{ marginTop: 20 }}>
<Autocomplete <Autocomplete
...@@ -1946,6 +2026,7 @@ export default class RollingOutlook extends Component { ...@@ -1946,6 +2026,7 @@ export default class RollingOutlook extends Component {
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.setState({ visibleTableHistory: false }) this.setState({ visibleTableHistory: false })
this.getRevision() this.getRevision()
this.getCurrency(newInputValue.company_id)
})} })}
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
...@@ -2328,6 +2409,8 @@ export default class RollingOutlook extends Component { ...@@ -2328,6 +2409,8 @@ export default class RollingOutlook extends Component {
open={this.props.open} open={this.props.open}
report_id={this.state.report_id} report_id={this.state.report_id}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
rollingOutlookID={this.state.rollingOutlookID} rollingOutlookID={this.state.rollingOutlookID}
...@@ -2348,6 +2431,8 @@ export default class RollingOutlook extends Component { ...@@ -2348,6 +2431,8 @@ export default class RollingOutlook extends Component {
open={this.props.open} open={this.props.open}
report_id={this.state.report_id} report_id={this.state.report_id}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
rollingOutlookID={this.state.rollingOutlookID} rollingOutlookID={this.state.rollingOutlookID}
...@@ -2368,6 +2453,8 @@ export default class RollingOutlook extends Component { ...@@ -2368,6 +2453,8 @@ export default class RollingOutlook extends Component {
open={this.props.open} open={this.props.open}
report_id={this.state.report_id} report_id={this.state.report_id}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
rollingOutlookID={this.state.rollingOutlookID} rollingOutlookID={this.state.rollingOutlookID}
...@@ -2388,6 +2475,8 @@ export default class RollingOutlook extends Component { ...@@ -2388,6 +2475,8 @@ export default class RollingOutlook extends Component {
open={this.props.open} open={this.props.open}
report_id={this.state.report_id} report_id={this.state.report_id}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
rollingOutlookID={this.state.rollingOutlookID} rollingOutlookID={this.state.rollingOutlookID}
...@@ -2409,6 +2498,8 @@ export default class RollingOutlook extends Component { ...@@ -2409,6 +2498,8 @@ export default class RollingOutlook extends Component {
open={this.props.open} open={this.props.open}
report_id={this.state.report_id} report_id={this.state.report_id}
company={this.state.company} company={this.state.company}
defaultCurrency={this.state.defaultCurrency}
currency={this.state.currency}
revision={this.state.revisionTable} revision={this.state.revisionTable}
periode={this.state.periode.periode} periode={this.state.periode.periode}
rollingOutlookID={this.state.rollingOutlookID} rollingOutlookID={this.state.rollingOutlookID}
......
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