Commit 55cb53a9 authored by Riri Novita's avatar Riri Novita

Update Banyak

parent ab9fa1c1
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -165,7 +165,6 @@ export default class FixedAssetsMovement extends Component { ...@@ -165,7 +165,6 @@ export default class FixedAssetsMovement extends Component {
} }
} }
res.map((item, index) => { res.map((item, index) => {
console.log(item);
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -911,24 +910,26 @@ export default class FixedAssetsMovement extends Component { ...@@ -911,24 +910,26 @@ export default class FixedAssetsMovement extends Component {
const handleForecast = (tableMeta, periode) => { const handleForecast = (tableMeta, periode) => {
let total = 0 let total = 0
if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'gain/ (loss) on fixed assets' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'ending balance' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') { if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'gain/ (loss) on fixed assets' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'ending balance' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') {
console.log('cek forcast 1');
if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') { if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') {
console.log('cek forcast 2');
let indexID = dataTable2.findIndex((val, index) => String(val[5]).toLocaleLowerCase() == 'ending balance' && dataTable2[index - 1][2] == tableMeta.rowData[2]) let indexID = dataTable2.findIndex((val, index) => String(val[5]).toLocaleLowerCase() == 'ending balance' && dataTable2[index - 1][2] == tableMeta.rowData[2])
if (indexID !== -1) { if (indexID !== -1) {
console.log('cek forcast 3');
// console.log(dataTable2) // console.log(dataTable2)
total = tableMeta.columnIndex == 21 ? dataTable2[indexID][20] : dataTable2[indexID][18].value total = tableMeta.columnIndex == 21 ? dataTable2[indexID][20] : dataTable2[indexID][18].value
} }
} else { } else {
let indexID = dataTable2[tableMeta.rowIndex][23].findIndex((val) => val.periode == periode) // simulasi
let indexID = dataTable2[tableMeta.rowIndex][25].findIndex((val) => val.periode == periode)
// Asli
// let indexID = dataTable2[tableMeta.rowIndex][23].findIndex((val) => val.periode == periode)
if (indexID !== -1) { if (indexID !== -1) {
total = dataTable2[tableMeta.rowIndex][23][indexID].value // simulasi
total = dataTable2[tableMeta.rowIndex][25][indexID].value
// Asli
// total = dataTable2[tableMeta.rowIndex][23][indexID].value
} }
} }
} else { } else {
total = handleValueFormula(tableMeta.columnIndex, tableMeta) total = handleValueFormula(tableMeta.columnIndex, tableMeta)
console.log('cek forcast 4');
} }
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
return total return total
...@@ -2608,44 +2609,44 @@ export default class FixedAssetsMovement extends Component { ...@@ -2608,44 +2609,44 @@ export default class FixedAssetsMovement extends Component {
return ( return (
<div style={{ textAlign: 'right' }}> <div style={{ textAlign: 'right' }}>
{ {
this.props.status === 'CLOSED' ? // this.props.status === 'CLOSED' ?
tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? // tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null // null
: // :
tableMeta.rowData[0] === 3 ? // tableMeta.rowData[0] === 3 ?
<div style={{ flex: 1 }}> // <div style={{ flex: 1 }}>
<FormControlLabel // <FormControlLabel
style={{ margin: 0 }} // style={{ margin: 0 }}
value={value} // value={value}
control={ // control={
<NumberFormat // <NumberFormat
thousandSeparator={true} // thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} // style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" // type="text"
placeholder="" // placeholder=""
disabled={true} // disabled={true}
value={Number(value).toFixed(1)} // value={Number(value).toFixed(1)}
/> // />
} // }
/> // />
</div> : // </div> :
<div style={{ flex: 1 }}> // <div style={{ flex: 1 }}>
<FormControlLabel // <FormControlLabel
style={{ margin: 0 }} // style={{ margin: 0 }}
value={value} // value={value}
control={ // control={
<NumberFormat // <NumberFormat
thousandSeparator={true} // thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} // style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" // type="text"
placeholder="" // placeholder=""
disabled={true} // disabled={true}
value={Number(value).toFixed(1)} // value={Number(value).toFixed(1)}
/> // />
} // }
/> // />
</div> // </div>
: // :
tableMeta.rowData[0] === 3 ? tableMeta.rowData[0] === 3 ?
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
...@@ -2715,44 +2716,44 @@ export default class FixedAssetsMovement extends Component { ...@@ -2715,44 +2716,44 @@ export default class FixedAssetsMovement extends Component {
return ( return (
<div style={{ textAlign: 'right' }}> <div style={{ textAlign: 'right' }}>
{ {
this.props.status === 'CLOSED' ? // this.props.status === 'CLOSED' ?
tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? // tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null // null
: // :
tableMeta.rowData[0] === 3 ? // tableMeta.rowData[0] === 3 ?
<div style={{ flex: 1 }}> // <div style={{ flex: 1 }}>
<FormControlLabel // <FormControlLabel
style={{ margin: 0 }} // style={{ margin: 0 }}
value={value} // value={value}
control={ // control={
<NumberFormat // <NumberFormat
thousandSeparator={true} // thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} // style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" // type="text"
placeholder="" // placeholder=""
disabled={true} // disabled={true}
value={Number(value).toFixed(1)} // value={Number(value).toFixed(1)}
/> // />
} // }
/> // />
</div> : // </div> :
<div style={{ flex: 1 }}> // <div style={{ flex: 1 }}>
<FormControlLabel // <FormControlLabel
style={{ margin: 0 }} // style={{ margin: 0 }}
value={value} // value={value}
control={ // control={
<NumberFormat // <NumberFormat
thousandSeparator={true} // thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} // style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" // type="text"
placeholder="" // placeholder=""
disabled={true} // disabled={true}
value={Number(value).toFixed(1)} // value={Number(value).toFixed(1)}
/> // />
} // }
/> // />
</div> // </div>
: // :
tableMeta.rowData[0] === 3 ? tableMeta.rowData[0] === 3 ?
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
......
...@@ -496,7 +496,7 @@ export default class BalanceSheetMR extends Component { ...@@ -496,7 +496,7 @@ export default class BalanceSheetMR extends Component {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleBSMR: false, loading: true, visibleButtonUpload: true }) this.setState({ visibleUploadSimulasi: false, visibleBSMR: false, loading: true, visibleButtonUpload: true })
let err = false let err = false
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
if (item.type_report_id === 3) { if (item.type_report_id === 3) {
...@@ -885,6 +885,129 @@ export default class BalanceSheetMR extends Component { ...@@ -885,6 +885,129 @@ export default class BalanceSheetMR extends Component {
}) })
} }
handleValidateSimulasi() {
let data = []
let err = false
let errorContrl = false
let editAble = this.state.editAble
let dataTable = this.state.dataTable
let kansas = this.state.kansas
console.log(dataTable[dataTable.length - 1])
dataTable.map((i, index) => {
if (i[0] === 3) {
// console.log(i);
// if ( i[17] === "" && (Number(i[12]) < this.state.minValue || Number(i[12]) > this.state.maxValue)) {
// console.log('msk 1');
// // console.log(i);
// err = true
// } else
if (i[18] === "" && (Number(i[14]).toFixed(1) < this.state.minValue || Number(i[14]).toFixed(1) > this.state.maxValue)) {
console.log('msk 2');
err = true
}
}
if (String(i[5]) == "Control (should be nil)") {
if (Number(i[9]).toFixed(1) < this.state.minValue || Number(i[9]).toFixed(1) > this.state.maxValue) {
errorContrl = true
editAble = true
}
}
data.push({
"item_report_id": i[1],
"rolling_outlook": i[6],
"master_budget": i[7],
"rolling_budget": i[8],
"actual": i[9],
"actual_previous_month": i[10],
"amount_act_vs_previous_month": i[11],
"percent_act_vs_previous_month": i[12],
"amount_act_vs_mb": i[13],
"percent_act_vs_mb": i[14],
"amount_act_vs_rb": i[15],
"percent_act_vs_rb": i[16],
"mtd_vs_previous_month": i[17],
"mtd_vs_mb": i[18],
"mtd_vs_rb": i[19]
})
})
// console.log(JSON.stringify(data));
// data.map(i => {
// if (i.mtd_vs_previous_month === "" && (Number(i.percent_act_vs_previous_month) < this.state.minValue || Number(i.percent_act_vs_previous_month) > this.state.maxValue)) {
// console.log('msk 1');
// console.log(i);
// err = true
// } else if (i.mtd_vs_mb === "" && (Number(i.percent_act_vs_mb) < this.state.minValue || Number(i.percent_act_vs_mb) > this.state.maxValue)) {
// console.log('msk 2');
// err = true
// } else if (i.mtd_vs_rb === "" && (Number(i.percent_act_vs_rb) < this.state.minValue || Number(i.percent_act_vs_rb) > this.state.maxValue)) {
// console.log('msk 3');
// err = true
// }
// })
// if (err === true) {
// console.log('error');
// this.setState({ loading: false, buttonError: true, saveDraft: false })
// } else {
// console.log('g error');
// this.setState({ loading: false, buttonError: false, saveDraft: false })
// }
// console.log(JSON.stringify(data))
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"currency_id": this.props.defaultCurrency.id,
"status": "submitted",
"months": this.props.month.month_id,
"balance_sheet": data
}
// console.log(JSON.stringify(payload));
// console.log(this.state.dataTable)
api.create().validateSubmitReportBS(payload).then((response) => {
console.log(response.data.data.result)
console.log(err);
console.log(errorContrl);
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result && err === false && errorContrl === false) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
if (kansas == 0) {
this.setState({ kansas: 1, loading: true }, () => {
this.handleValidate()
})
} else {
this.setState({ kansas: 0 })
}
} else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
if (kansas == 0) {
this.setState({ kansas: 1, loading: true }, () => {
this.handleValidate()
})
} else {
this.setState({ kansas: 0 })
}
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
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.problem, tipeAlert: 'error', loading: false })
}
})
}
closeAlert() { closeAlert() {
this.setState({ alert: false }) this.setState({ alert: false })
} }
...@@ -2778,7 +2901,8 @@ export default class BalanceSheetMR extends Component { ...@@ -2778,7 +2901,8 @@ export default class BalanceSheetMR extends Component {
</Alert> </Alert>
</Snackbar> </Snackbar>
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleBSMR ? <Paper style={{ paddingTop: 10 }}> {this.state.visibleBSMR ?
<Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
</div> </div>
...@@ -3053,7 +3177,102 @@ export default class BalanceSheetMR extends Component { ...@@ -3053,7 +3177,102 @@ export default class BalanceSheetMR extends Component {
</div> </div>
{/* : null {/* : null
} */} } */}
</Paper> : </Paper>
:
this.state.visibleButtonUpload ?
<Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
</div>
<div style={{ padding: 20 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
{this.props.defaultCurrency.id === 1 ?
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
:
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
}
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.dataLoaded && !this.state.loading && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
)}
</div>
</div>
<div className="grid grid-2x" style={{ marginTop: 10, padding: 20 }}>
<div className="col-1" style={{ paddingLeft: 0 }}>
<button
type="button"
onClick={() => this.setState({ loading: true, visibleBSMR: true }, () => {
setTimeout(() => {
this.getItemHierarki()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true, dataTable: dataTable2 }, () => {
setTimeout(() => {
this.handleValidateSimulasi()
}, 100);
})
}}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.uploadSimulasi('submitted')
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data</Typography>
</div>
</button>
</div>
</div>
</Paper>
:
<Paper style={{ paddingTop: 10 }}> <Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
...@@ -3252,7 +3471,7 @@ export default class BalanceSheetMR extends Component { ...@@ -3252,7 +3471,7 @@ export default class BalanceSheetMR extends Component {
}} }}
/> />
</div> </div>
{this.state.visibleButtonUpload && {/* {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}> <div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div> <div>
<button <button
...@@ -3276,7 +3495,7 @@ export default class BalanceSheetMR extends Component { ...@@ -3276,7 +3495,7 @@ export default class BalanceSheetMR extends Component {
</button> </button>
</div> </div>
</div> </div>
} } */}
{/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */} {/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */}
</div> </div>
</div> </div>
......
...@@ -1074,6 +1074,236 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1074,6 +1074,236 @@ export default class CorporateAnnualTargetMR extends Component {
} }
handleCalculateSimulasi(datatable2) {
// console.log(datatable2)
this.setState({ loading: true }, () => {
let total = 0
let perfomanceScore = ''
let totalWeight = 0
// console.log(datatable2)
let datatable3 = datatable2.map((item, index) => {
// console.log(item[6])
//total weight
if (item[0] !== 1 && item[0] !== 4) {
if (item[12] == '' || String(item[12]) == '0' || String(item[12]) == '0.0') {
totalWeight += Number(0)
} else {
totalWeight += Number(item[6])
}
}
//ach
let totalAch = 0
if (item[8] == 'HIB') {
let actual = item[11] == "" ? 0 : Number(item[11])
let target = item[12] == "" ? 0 : Number(item[12])
// if (item[5] == "Striping Ratio (SR) YTD") {
// console.log(actual)
// console.log(target)
// console.log(actual/target)
// }
if (target < 0) {
if (actual > target) {
totalAch = (actual / target) - 1
} else {
totalAch = (actual / target)
}
} else if (target == 0) {
if (target >= actual) {
totalAch = 1.26
} else {
totalAch = 0
}
} else {
if (actual == target) {
totalAch = (actual / target)
} else {
totalAch = 2 - (actual / target)
}
}
// if (item[5] == "Striping Ratio (SR) YTD") {
// console.log(actual)
// console.log(target)
// console.log(actual/target)
// }
} else {
let actual = item[11] == "" ? 0 : Number(item[11])
let target = item[12] == "" ? 0 : Number(item[12])
if (target < 0) {
if (actual >= target) {
totalAch = ((target - actual) / target) + 1
} else {
totalAch = (target - actual) / target
}
} else if (target == 0) {
if (target <= actual) {
totalAch = 1.26
} else {
totalAch = 0
}
} else {
// if (actual <= target) {
totalAch = (actual / target)
// } else {
// totalAch = 1 - (actual / target)
// }
}
}
totalAch = String(totalAch) == 'NaN' || String(totalAch) == 'Infinity' || String(totalAch) == '-Infinity' ? 0 : totalAch
totalAch = this.props.lastStatus == 'APPROVED' ? item[13] : Number(totalAch) * 100
//score
let listParameter = this.state.parameterScore
let parameterKpi = item[8]
let parameterAch = String(item[9]).includes('%') ? `MAX${String(item[9]).substr(0, String(item[9]).length - 1)}` : String(item[9])
let parameterMix = `${parameterKpi}_${parameterAch}`
let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase())
let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id)
let totalScore = 0
let achx100 = item[9] == '100%' && (item[8] == 'HIB' || item[8] == 'HIG') ? (Number(totalAch) / 100 > 1 ? 1 : Number(totalAch) / 100) : Number(totalAch) / 100
// if (item[5] == "Max Quality drop from Bor-Barge") {
// console.log(listParameterFilter)
// console.log(listParameterFilterCompany)
// // console.log(Number(item.min_value))
// console.log(Number(item.max_value))
// }
if (listParameterFilterCompany.length == 0) {
listParameterFilter.map((items, index) => {
if (Number(achx100) >= Number(items.min_value) && Number(achx100) <= Number(items.max_value)) {
totalScore = Number(items.value)
}
})
} else {
listParameterFilterCompany.map((items, index) => {
if (Number(achx100) >= Number(items.min_value) && Number(achx100) <= Number(items.max_value)) {
totalScore = Number(items.value)
}
})
}
let totalScorez = this.props.lastStatus == 'APPROVED' ? item[14] : Number(totalScore).toFixed(0)
// if (item[5] == "Max Quality drop from Bor-Barge") {
// console.log(totalScorez)
// }
//Score X Weight
let totalSW = 0
let handlePercent = ''
if (String(item[6]).includes('%')) {
handlePercent = String(item[6]).substr(0, String(item[6]).length - 1)
} else {
handlePercent = String(item[6])
}
if (item[12] == '' || String(item[12]) == '0' || String(item[12]) == '0.0') {
totalSW = 0
} else {
totalSW = (Number(totalScorez) * Number(handlePercent) / 100)
}
totalSW = this.props.lastStatus == 'APPROVED' ? item[15] : Number(totalSW).toFixed(2)
if (item[0] !== 1 && item[0] !== 4) {
total += Number(totalSW)
}
// console.log(item[5])
// console.log(totalAch);
// console.log(achx100);
// console.log(listParameterFilter);
// console.log(listParameterFilterCompany);
// console.log(totalScorez)
// console.log(totalSW)
// console.log(item[12])
// console.log(item[5])
// console.log(total)
return [
item[0],
item[1],
item[2],
item[3],
item[4],
item[5],
item[6],
item[7],
item[8],
item[9],
item[10],
item[11],
item[12],
totalAch,
totalScorez,
totalSW,
item[16],
item[17],
item[18],
// item[19],
// ]
]
})
// console.log(totalWeight)
// console.log(total)
// console.log(datatable3);
let totalWeightz = Number(totalWeight) / 100
let totalz = Number(Number(total).toFixed(2) / Number(totalWeightz)).toFixed(2)
console.log(totalz)
let lastTotal = R.equals(totalz, NaN) ? 0.0 : totalz
if (R.equals(totalz, NaN) || R.equals(totalz, "NaN")) {
lastTotal = 0.0
} else {
lastTotal = totalz
}
console.log(Number(Number(total).toFixed(2) / Number(totalWeightz)).toFixed(2))
let indexPerform = this.state.parameterPerfom.findIndex((val) => val.company_id == this.props.company.company_id)
let listPerfomanceDefault = []
if (indexPerform == -1) {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
} else {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => val.company_id == this.props.company.company_id)
}
let performanceScore = ''
let perfomanceScoreColor = '#fff'
if (listPerfomanceDefault.length > 0) {
listPerfomanceDefault.map((item, index) => {
console.log(Number(lastTotal))
console.log(Number(item.min_value))
console.log(Number(item.max_value))
if (Number(lastTotal) >= Number(item.min_value) && Number(lastTotal) <= Number(item.max_value)) {
console.log('masuk')
perfomanceScore = item.description
perfomanceScoreColor = item.value
}
})
}
// console.log(Number(lastTotal))
console.log(this.state.parameterPerfom)
console.log(listPerfomanceDefault)
console.log(perfomanceScore)
console.log(perfomanceScoreColor)
console.log(datatable3)
// if (lastTotal >= 1.00 && lastTotal <= 2.00) {
// perfomanceScore = 'K'
// } else if (lastTotal >= 2.01 && lastTotal <= 2.75) {
// perfomanceScore = 'C'
// } else if (lastTotal >= 2.76 && lastTotal <= 3.00) {
// perfomanceScore = 'B-'
// } else if (lastTotal >= 3.01 && lastTotal <= 3.75) {
// perfomanceScore = 'B'
// } else if (lastTotal >= 3.76 && lastTotal <= 4.00) {
// perfomanceScore = 'B+'
// } else if (lastTotal >= 4.01 && lastTotal <= 4.75) {
// perfomanceScore = 'BS'
// } else if (lastTotal >= 4.76 && lastTotal <= 5.00) {
// perfomanceScore = 'IST'
// }
setTimeout(() => {
this.setState({ totalScore: lastTotal, perfomanceScore, loading: false, perfomanceScoreColor }, () => {
this.setState({ loading: true })
setTimeout(() => {
this.setState({ loading: false })
}, 500);
})
}, 500);
})
}
handleBackgroundPerf(total) { handleBackgroundPerf(total) {
// console.log(total) // console.log(total)
let color = 'white' let color = 'white'
...@@ -2484,7 +2714,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -2484,7 +2714,7 @@ export default class CorporateAnnualTargetMR extends Component {
this.setState({ loading: true, dataTable: dataTable2, saveDraft: false, buttonError: false }, () => { this.setState({ loading: true, dataTable: dataTable2, saveDraft: false, buttonError: false }, () => {
setTimeout(() => { setTimeout(() => {
// this.handleValidate() // this.handleValidate()
this.handleCalculate(dataTable2) this.handleCalculateSimulasi(dataTable2)
}, 100); }, 100);
}) })
}} }}
......
...@@ -405,7 +405,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -405,7 +405,7 @@ export default class FixedAssetsMovementMR extends Component {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleFAMMR: false, refresh: true, visibleButtonUpload: true }) this.setState({ visibleUploadSimulasi: false, loading: true, visibleFAMMR: false, refresh: true, visibleButtonUpload: true })
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
return [ return [
item.type_report_id, item.type_report_id,
...@@ -670,6 +670,62 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -670,6 +670,62 @@ export default class FixedAssetsMovementMR extends Component {
}) })
} }
handleValidateSimulasi() {
let data = []
let err = false
this.state.dataTable.map((i, index) => {
data.push({
"item_report_id": i[1],
"mtd_mb": i[6],
"mtd_rb": i[7],
"mtd_actual": i[8],
"act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(i[9]),
"act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(i[10]),
"act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(i[11]),
"act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(i[12])
})
})
// console.log(JSON.stringify(data))
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"currency_id": this.props.defaultCurrency.id,
"status": "submitted",
"months": this.props.month.month_id,
"fixed_asset_movement": data
}
// console.log(JSON.stringify(payload));
api.create().validateSubmitReportFAM(payload).then((response) => {
console.log(response.data.data.result)
console.log(err);
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result && err === false) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
} else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
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.problem, tipeAlert: 'error', loading: false })
}
})
}
closeAlert() { closeAlert() {
this.setState({ alert: false }) this.setState({ alert: false })
} }
...@@ -1738,7 +1794,105 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1738,7 +1794,105 @@ export default class FixedAssetsMovementMR extends Component {
</div> </div>
} }
</div> </div>
</Paper> : </Paper>
:
this.state.visibleButtonUpload ?
<Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Fixed Assets Movement</Typography>
</div>
<div style={{ padding: 20 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
{this.props.defaultCurrency.id === 1 ?
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
:
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
}
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.refresh && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
)}
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1" style={{ paddingLeft: 0 }}>
<button
type="button"
onClick={() => this.setState({ loading: true, visibleFAMMR: true }, () => {
setTimeout(() => {
this.getItemHierarki()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
{/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
(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%', paddingRight: 5 }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
// this.setState({ loading: false })
this.handleValidateSimulasi()
}, 100);
})
}}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.uploadSimulasi('submitted')
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data</Typography>
</div>
</button>
</div>
</div>
</div>
</Paper>
:
<Paper style={{ paddingTop: 10 }}> <Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Fixed Assets Movement</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Fixed Assets Movement</Typography>
...@@ -1940,7 +2094,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1940,7 +2094,7 @@ export default class FixedAssetsMovementMR extends Component {
}} }}
/> />
</div> </div>
{this.state.visibleButtonUpload && {/* {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}> <div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div> <div>
<button <button
...@@ -1964,7 +2118,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1964,7 +2118,7 @@ export default class FixedAssetsMovementMR extends Component {
</button> </button>
</div> </div>
</div> </div>
} } */}
{/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */} {/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */}
</div> </div>
</div> </div>
......
...@@ -605,7 +605,7 @@ export default class ProfitLossMR extends Component { ...@@ -605,7 +605,7 @@ export default class ProfitLossMR extends Component {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visiblePLMR: false, loading: true, visibleButtonUpload: true }) this.setState({ visibleUploadSimulasi: false, visiblePLMR: false, loading: true, visibleButtonUpload: true })
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
return [ return [
item.type_report_id, item.type_report_id,
...@@ -868,6 +868,86 @@ export default class ProfitLossMR extends Component { ...@@ -868,6 +868,86 @@ export default class ProfitLossMR extends Component {
}) })
} }
handleValidateSimulasi() {
let data = []
let err = false
this.state.dataTable.map((i, index) => {
if (i[0] === 3) {
// console.log(i);
if (i[19] === "" && (Number(i[16]).toFixed(1) < this.state.minValue || Number(i[16]).toFixed(1) > this.state.maxValue)) {
console.log('msk 1');
// console.log(i);
err = true
}
// else if ( i[20] === "" && (Number(i[16]) < this.state.minValue || Number(i[16]) > this.state.maxValue)) {
// console.log('msk 2');
// err = true
// } else if ( i[21] === "" && (Number(i[18]) < this.state.minValue || Number(i[18]) > this.state.maxValue)) {
// console.log('msk 3');
// err = true
// }
}
data.push({
"item_report_id": i[1],
"notes": i[6],
"rolling_outlook": i[7],
"master_budget": i[8],
"rolling_budget": i[9],
"actual": i[10],
"ytd_actual": i[11],
"actual_previous_month": i[12],
"amount_act_vs_previous_month": i[13],
"percent_act_vs_previous_month": i[14],
"amount_act_vs_mb": i[15],
"percent_act_vs_mb": i[16],
"amount_act_vs_rb": i[17],
"percent_act_vs_rb": i[18],
"mtd_vs_mb": i[19],
"mtd_vs_rb": i[20],
"mtd_vs_previous_month": i[21],
})
})
console.log(this.state.dataTable);
// console.log(JSON.stringify(data))
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": "submitted",
"months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id,
"profit_loss": data
}
console.log(JSON.stringify(payload));
api.create().validateSubmitReportPL(payload).then((response) => {
console.log(response)
console.log(err);
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result && err === false) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
} else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
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.problem, tipeAlert: 'error', loading: false })
}
})
}
closeAlert() { closeAlert() {
this.setState({ alert: false }) this.setState({ alert: false })
} }
...@@ -2482,6 +2562,101 @@ export default class ProfitLossMR extends Component { ...@@ -2482,6 +2562,101 @@ export default class ProfitLossMR extends Component {
} */} } */}
</Paper> </Paper>
: :
this.state.visibleButtonUpload ?
<Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Profit Loss</Typography>
</div>
<div style={{ padding: 20 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.month.month_value} {this.props.periode} (rev.{this.props.revision})</Typography>
{this.props.defaultCurrency.id === 1 ?
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
:
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
}
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
)}
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1" style={{ paddingLeft: 0 }}>
<button
type="button"
onClick={() => this.setState({ loading: true, visiblePLMR: true }, () => {
setTimeout(() => {
this.getItemHierarki()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
// this.setState({ loading: false })
this.handleValidateSimulasi()
}, 100);
})
}}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.uploadSimulasi('submitted')
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data</Typography>
</div>
</button>
</div>
</div>
</div>
</Paper>
:
<Paper style={{ paddingTop: 10 }}> <Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Profit Loss</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Profit Loss</Typography>
...@@ -2681,7 +2856,7 @@ export default class ProfitLossMR extends Component { ...@@ -2681,7 +2856,7 @@ export default class ProfitLossMR extends Component {
}} }}
/> />
</div> </div>
{this.state.visibleButtonUpload && {/* {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}> <div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div> <div>
<button <button
...@@ -2705,7 +2880,7 @@ export default class ProfitLossMR extends Component { ...@@ -2705,7 +2880,7 @@ export default class ProfitLossMR extends Component {
</button> </button>
</div> </div>
</div> </div>
} } */}
{/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */} {/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */}
</div> </div>
</div> </div>
......
...@@ -504,7 +504,7 @@ export default class TaxPlanningMR extends Component { ...@@ -504,7 +504,7 @@ export default class TaxPlanningMR extends Component {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleTP: false, loading: true, visibleButtonUpload: true }) this.setState({ visibleUploadSimulasi: false, visibleTP: false, loading: true, visibleButtonUpload: true })
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
return [ return [
0, 0,
...@@ -714,6 +714,77 @@ export default class TaxPlanningMR extends Component { ...@@ -714,6 +714,77 @@ export default class TaxPlanningMR extends Component {
}) })
} }
handleValidateSimulasi(dataTable2) {
let data = []
let errorContrl = this.state.buttonError
let editAble = this.state.editAble
console.log(this.state.dataTable)
console.log(dataTable2)
dataTable2.map(i => {
console.log(i)
// this.setState({ loading: false })
console.log(i[9].tbf)
if (String(i[8]) === "Control (should be nil)") {
console.log(i[9].tbf)
console.log(this.state.minValue)
console.log(this.state.maxValue)
if (Number(i[9].tbf) < Number(this.state.minValue) || Number(i[9].tbf) > Number(this.state.maxValue)) {
errorContrl = true
editAble = true
} else {
errorContrl = false
editAble = false
}
}
data.push({
item_report_id: i[4],
trial_balance_commercial: String(Number(i[9].tbc).toFixed(1)),
fiscal_correction: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].fcp).toFixed(2)) : String(Number(i[9].fcp).toFixed(1)),
trial_balance_fiscal: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[9].tbf).toFixed(2)) : String(Number(i[9].tbf).toFixed(1)),
trial_balance_fiscal_actual: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[10]).toFixed(2)) : String(Number(i[10]).toFixed(1)),
trial_balance_fiscal_mb: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[11]).toFixed(2)) : String(Number(i[11]).toFixed(1))
})
})
// this.setState({ loading: false, buttonError: errorContrl, editable: editAble, saveDraft: false })
console.log(errorContrl)
let i = this.state.dataTable
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": "submitted",
"months": this.props.month.month_id,
"currency_id": this.props.defaultCurrency.id,
"tax_planning": data
}
api.create().validateSubmitReportMRTP(payload).then((response) => {
console.log(payload)
console.log(response)
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.result && errorContrl === false && editAble === false) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
} else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
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.problem, tipeAlert: 'error', loading: false })
}
})
}
downloadTemplate = async () => { downloadTemplate = async () => {
let res = await fetch( let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/tax_planning/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&currency_id=${this.props.defaultCurrency.id}` `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/tax_planning/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&currency_id=${this.props.defaultCurrency.id}`
...@@ -1911,6 +1982,97 @@ export default class TaxPlanningMR extends Component { ...@@ -1911,6 +1982,97 @@ export default class TaxPlanningMR extends Component {
</div> </div>
</Paper> </Paper>
: :
this.state.visibleButtonUpload === true ?
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div>
<div style={{ padding: 25 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()}, {this.props.periode} (rev.{this.props.revision})</Typography>
{this.props.defaultCurrency.id === 1 ?
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
:
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
}
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent}
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
</div>
)}
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button
type="button"
onClick={() => this.setState({ loading: true, visibleTP: true }, () => {
setTimeout(() => {
this.getItemHierarki()
}, 100);
})}
style={{ marginRight: 20, marginLeft: 10 }}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
// this.forceUpdate()
this.setState({ loading: true, buttonDraft: false }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: false, editable: true })
this.handleValidateSimulasi(dataTable2)
}, 100);
})
}}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.uploadSimulasi('submitted')
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data</Typography>
</div>
</button>
</div>
</div>
</div>
</Paper>
:
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}> <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div> <div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
...@@ -2107,7 +2269,7 @@ export default class TaxPlanningMR extends Component { ...@@ -2107,7 +2269,7 @@ export default class TaxPlanningMR extends Component {
}} }}
/> />
</div> </div>
{this.state.visibleButtonUpload && {/* {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}> <div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div> <div>
<button <button
...@@ -2131,7 +2293,7 @@ export default class TaxPlanningMR extends Component { ...@@ -2131,7 +2293,7 @@ export default class TaxPlanningMR extends Component {
</button> </button>
</div> </div>
</div> </div>
} } */}
{/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */} {/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */}
</div> </div>
</div> </div>
......
...@@ -602,7 +602,7 @@ export default class ProfitLossROO extends Component { ...@@ -602,7 +602,7 @@ export default class ProfitLossROO extends Component {
console.log("checkUpload Response", response) console.log("checkUpload Response", response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visiblePLRO: false, loading: true, visibleButtonUpload: true }) this.setState({ visibleUploadSimulasi: false, visiblePLRO: false, loading: true, visibleButtonUpload: true })
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
return [ return [
item.type_report_id, item.type_report_id,
...@@ -850,6 +850,10 @@ export default class ProfitLossROO extends Component { ...@@ -850,6 +850,10 @@ export default class ProfitLossROO extends Component {
// }) // })
} }
handleValidateSimulasi() {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false, handleDoubleClick: 0 })
}
closeAlert() { closeAlert() {
this.setState({ alert: false }) this.setState({ alert: false })
} }
...@@ -2742,6 +2746,101 @@ export default class ProfitLossROO extends Component { ...@@ -2742,6 +2746,101 @@ export default class ProfitLossROO extends Component {
} */} } */}
</Paper> </Paper>
: :
this.state.visibleButtonUpload ?
<Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Rolling Outlook - Profit Loss</Typography>
</div>
<div style={{ padding: 20 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} {String(this.props.quarter).toLocaleUpperCase()} (rev.{this.props.revision}) </Typography>
{this.props.defaultCurrency.id === 1 ?
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
:
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
}
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
)}
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1" style={{ paddingLeft: 0 }}>
<button
type="button"
onClick={() => this.setState({ loading: true, visiblePLRO: true }, () => {
setTimeout(() => {
this.getItemHierarki()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
// this.setState({ loading: false })
this.handleValidateSimulasi()
}, 100);
})
}}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.uploadSimulasi('submitted')
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data</Typography>
</div>
</button>
</div>
</div>
</div>
</Paper>
:
<Paper style={{ paddingTop: 10 }}> <Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Rolling Outlook - Profit Loss</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Rolling Outlook - Profit Loss</Typography>
...@@ -2944,7 +3043,7 @@ export default class ProfitLossROO extends Component { ...@@ -2944,7 +3043,7 @@ export default class ProfitLossROO extends Component {
}} }}
/> />
</div> </div>
{this.state.visibleButtonUpload && {/* {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}> <div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div> <div>
<button <button
...@@ -2968,7 +3067,7 @@ export default class ProfitLossROO extends Component { ...@@ -2968,7 +3067,7 @@ export default class ProfitLossROO extends Component {
</button> </button>
</div> </div>
</div> </div>
} } */}
{/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */} {/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */}
</div> </div>
</div> </div>
......
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