Commit 160e34be authored by Riri Novita's avatar Riri Novita

update PL TP

parent 2c2b0d05
...@@ -56,7 +56,8 @@ export default class BalanceSheetOLPA extends Component { ...@@ -56,7 +56,8 @@ export default class BalanceSheetOLPA extends Component {
maxValue: "0", maxValue: "0",
kansas: 0, kansas: 0,
defaultCurrencyUpload: this.props.defaultCurrency, defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false visibleAlertSave: false,
visibleButtonUpload: false
} }
this.handleValue = this.handleValue.bind(this) this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -65,7 +66,7 @@ export default class BalanceSheetOLPA extends Component { ...@@ -65,7 +66,7 @@ export default class BalanceSheetOLPA extends Component {
componentDidMount() { componentDidMount() {
this.getLatestUpdate() this.getLatestUpdate()
this.handleViewOnly() // this.handleViewOnly()
this.getSettingControl() this.getSettingControl()
} }
...@@ -203,19 +204,19 @@ export default class BalanceSheetOLPA extends Component { ...@@ -203,19 +204,19 @@ export default class BalanceSheetOLPA extends Component {
item.level, item.level,
item.description, item.description,
item.balance_sheet.total_actual_before === null ? "0" : item.balance_sheet.total_actual_before === "" ? "0" : item.balance_sheet.total_actual_before, item.balance_sheet.total_actual_before === null ? "0" : item.balance_sheet.total_actual_before === "" ? "0" : item.balance_sheet.total_actual_before,
Number(item.balance_sheet.january).toFixed(1), Number(item.balance_sheet.january),
Number(item.balance_sheet.february).toFixed(1), Number(item.balance_sheet.february),
Number(item.balance_sheet.march).toFixed(1), Number(item.balance_sheet.march),
Number(item.balance_sheet.april).toFixed(1), Number(item.balance_sheet.april),
Number(item.balance_sheet.may).toFixed(1), Number(item.balance_sheet.may),
Number(item.balance_sheet.june).toFixed(1), Number(item.balance_sheet.june),
Number(item.balance_sheet.july).toFixed(1), Number(item.balance_sheet.july),
Number(item.balance_sheet.august).toFixed(1), Number(item.balance_sheet.august),
Number(item.balance_sheet.september).toFixed(1), Number(item.balance_sheet.september),
Number(item.balance_sheet.october).toFixed(1), Number(item.balance_sheet.october),
this.props.status === 'CLOSED' ? Number(item.balance_sheet.november).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.november).toFixed(1), formula: item.balance_sheet.november_formula } : Number(item.balance_sheet.november).toFixed(1), this.props.status === 'CLOSED' ? Number(item.balance_sheet.november) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.november), formula: item.balance_sheet.november_formula } : Number(item.balance_sheet.november),
this.props.status === 'CLOSED' ? Number(item.balance_sheet.december).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.december).toFixed(1), formula: item.balance_sheet.december_formula } : Number(item.balance_sheet.december).toFixed(1), this.props.status === 'CLOSED' ? Number(item.balance_sheet.december) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.december), formula: item.balance_sheet.december_formula } : Number(item.balance_sheet.december),
Number(item.balance_sheet.total_current_year).toFixed(1), Number(item.balance_sheet.total_current_year),
item.order, item.order,
item.condition_it_should_be, item.condition_it_should_be,
item.condition_if_wrong, item.condition_if_wrong,
...@@ -239,19 +240,19 @@ export default class BalanceSheetOLPA extends Component { ...@@ -239,19 +240,19 @@ export default class BalanceSheetOLPA extends Component {
item.level, item.level,
item.description, item.description,
item.balance_sheet.total_actual_before === null ? "0" : item.balance_sheet.total_actual_before === "" ? "0" : item.balance_sheet.total_actual_before, item.balance_sheet.total_actual_before === null ? "0" : item.balance_sheet.total_actual_before === "" ? "0" : item.balance_sheet.total_actual_before,
Number(item.balance_sheet.january).toFixed(1), Number(item.balance_sheet.january),
Number(item.balance_sheet.february).toFixed(1), Number(item.balance_sheet.february),
Number(item.balance_sheet.march).toFixed(1), Number(item.balance_sheet.march),
Number(item.balance_sheet.april).toFixed(1), Number(item.balance_sheet.april),
Number(item.balance_sheet.may).toFixed(1), Number(item.balance_sheet.may),
Number(item.balance_sheet.june).toFixed(1), Number(item.balance_sheet.june),
Number(item.balance_sheet.july).toFixed(1), Number(item.balance_sheet.july),
Number(item.balance_sheet.august).toFixed(1), Number(item.balance_sheet.august),
Number(item.balance_sheet.september).toFixed(1), Number(item.balance_sheet.september),
Number(item.balance_sheet.october).toFixed(1), Number(item.balance_sheet.october),
this.props.status === 'CLOSED' ? Number(item.balance_sheet.november).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.november).toFixed(1), formula: item.balance_sheet.november_formula } : Number(item.balance_sheet.november).toFixed(1), this.props.status === 'CLOSED' ? Number(item.balance_sheet.november) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.november), formula: item.balance_sheet.november_formula } : Number(item.balance_sheet.november),
this.props.status === 'CLOSED' ? Number(item.balance_sheet.december).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.december).toFixed(1), formula: item.balance_sheet.december_formula } : Number(item.balance_sheet.december).toFixed(1), this.props.status === 'CLOSED' ? Number(item.balance_sheet.december) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.december), formula: item.balance_sheet.december_formula } : Number(item.balance_sheet.december),
Number(item.balance_sheet.total_current_year).toFixed(1), Number(item.balance_sheet.total_current_year),
item.order, item.order,
item.condition_it_should_be, item.condition_it_should_be,
item.condition_if_wrong, item.condition_if_wrong,
...@@ -304,20 +305,20 @@ export default class BalanceSheetOLPA extends Component { ...@@ -304,20 +305,20 @@ export default class BalanceSheetOLPA extends Component {
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
item_report_id: i[1], item_report_id: i[1],
total_actual_before: String(Number(i[6]).toFixed(1)), total_actual_before: String(Number(i[6])),
january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)), january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7])),
february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)), february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8])),
march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)), march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9])),
april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)), april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10])),
may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)), may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11])),
june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)), june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12])),
july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)), july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13])),
august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)), august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14])),
september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)), september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15])),
october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)), october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16])),
november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1))), november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[17].value)) : String(Number(i[17]))),
december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1))), december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[18].value)) : String(Number(i[18]))),
total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19]).toFixed(1)), total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19])),
}) })
}) })
let payload = { let payload = {
...@@ -478,19 +479,19 @@ export default class BalanceSheetOLPA extends Component { ...@@ -478,19 +479,19 @@ export default class BalanceSheetOLPA extends Component {
item.level, item.level,
item.item_report, item.item_report,
item.total_actual_before, item.total_actual_before,
Number(item.january).toFixed(1), Number(item.january),
Number(item.february).toFixed(1), Number(item.february),
Number(item.march).toFixed(1), Number(item.march),
Number(item.april).toFixed(1), Number(item.april),
Number(item.may).toFixed(1), Number(item.may),
Number(item.june).toFixed(1), Number(item.june),
Number(item.july).toFixed(1), Number(item.july),
Number(item.august).toFixed(1), Number(item.august),
Number(item.september).toFixed(1), Number(item.september),
Number(item.october).toFixed(1), Number(item.october),
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.november).toFixed(1), formula: item.november_formula } : Number(item.november).toFixed(1), item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.november), formula: item.november_formula } : Number(item.november),
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.december).toFixed(1), formula: item.december_formula } : Number(item.december).toFixed(1), item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.december), formula: item.december_formula } : Number(item.december),
Number(item.total_current_year).toFixed(1), Number(item.total_current_year),
item.orders, item.orders,
item.condition_it_should_be, item.condition_it_should_be,
item.condition_if_wrong, item.condition_if_wrong,
...@@ -522,14 +523,103 @@ export default class BalanceSheetOLPA extends Component { ...@@ -522,14 +523,103 @@ export default class BalanceSheetOLPA extends Component {
}) })
} }
uploadSimulasi() { checkUploadSimulasi() {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id currency_id: this.state.defaultCurrencyUpload?.id
} }
api.create().checkUploadOLPA(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUploadSimulasi: false, visibleBalanceSheet: false, loading: true, visibleButtonUpload: true })
let dataTable = response.data.data.map((item, index) => {
return [
item.type_report_id,
item.item_report_id,
item.parent,
item.formula,
item.level,
item.item_report,
item.total_actual_before,
Number(item.january),
Number(item.february),
Number(item.march),
Number(item.april),
Number(item.may),
Number(item.june),
Number(item.july),
Number(item.august),
Number(item.september),
Number(item.october),
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.november), formula: item.november_formula } : Number(item.november),
item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.december), formula: item.december_formula } : Number(item.december),
Number(item.total_current_year),
item.orders,
item.condition_it_should_be,
item.condition_if_wrong,
item.forecast_formula == null ? [] : item.forecast_formula,
item.error
]
})
console.log(this.state.dataTable);
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.state.dataTable.map(item => {
if (item[24].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
})
console.log(this.state.dataTable);
})
} 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);
}
})
}
}
})
}
uploadSimulasi(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
total_actual_before: String(Number(i[6]).toFixed(1)),
january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)),
november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1))),
december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1))),
total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19]).toFixed(1)),
})
})
let body = {
outlook_pa_id: this.props.outlook_pa_id,
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
currency_id: this.props.defaultCurrency.id,
balance_sheet: data,
status: type
}
this.setState({ loading: true, dataTable: [] }) this.setState({ loading: true, dataTable: [] })
console.log(payload) console.log(body)
api.create().uploadSimulasiOLPA(payload).then(response => { api.create().uploadSimulasiOLPA(body).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -859,7 +949,6 @@ export default class BalanceSheetOLPA extends Component { ...@@ -859,7 +949,6 @@ export default class BalanceSheetOLPA extends Component {
} }
} else { } else {
// console.log(baru); // console.log(baru);
// console.log(value);
let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode)) let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
// console.log(indexID) // console.log(indexID)
if (indexID !== -1) { if (indexID !== -1) {
...@@ -1962,21 +2051,6 @@ export default class BalanceSheetOLPA extends Component { ...@@ -1962,21 +2051,6 @@ export default class BalanceSheetOLPA extends Component {
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}> <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload Simulasi'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })}
>
<img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
{/* {this.props.isApprover == true || this.state.dataTable.length == 0 ? null : */} {/* {this.props.isApprover == true || this.state.dataTable.length == 0 ? null : */}
{this.props.isApprover == true || this.state.get_for == 'view' ? {this.props.isApprover == true || this.state.get_for == 'view' ?
null null
...@@ -2003,6 +2077,20 @@ export default class BalanceSheetOLPA extends Component { ...@@ -2003,6 +2077,20 @@ export default class BalanceSheetOLPA extends Component {
// </div> // </div>
: :
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Upload Simulasi'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })}
>
<img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download Template'} data-for="template"> <a data-tip={'Download Template'} data-for="template">
<button <button
style={{ style={{
...@@ -2199,6 +2287,95 @@ export default class BalanceSheetOLPA extends Component { ...@@ -2199,6 +2287,95 @@ export default class BalanceSheetOLPA 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 : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent}
<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, visibleBalanceSheet: true }, () => {
setTimeout(() => {
this.getItemHierarki()
}, 100);
})}
style={{ marginRight: 20 }}
>
<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%' }}>
{this.state.get_for == 'edit' && <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.handleValidate()
}, 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>}
{this.state.get_for == 'edit' &&
<button
type="button"
// disabled={this.state.buttonError}
onClick={() => this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
:
this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1 }, () => {
this.uploadSimulasi('submitted')
})}
style={{
backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : '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 }}>
...@@ -2384,7 +2561,7 @@ export default class BalanceSheetOLPA extends Component { ...@@ -2384,7 +2561,7 @@ export default class BalanceSheetOLPA extends Component {
}} }}
onUpload={() => { onUpload={() => {
String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PA") && String(this.state.judul).includes("BALANCE") && String(this.state.judul).includes("SHEET") ? String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PA") && String(this.state.judul).includes("BALANCE") && String(this.state.judul).includes("SHEET") ?
this.uploadSimulasi() : this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}} }}
/> />
......
...@@ -67,7 +67,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -67,7 +67,7 @@ export default class TaxPlanningOLPA extends Component {
// this.getItemHierarki() // this.getItemHierarki()
this.getSettingControl() this.getSettingControl()
this.lastUpdate() this.lastUpdate()
this.handleViewOnly() // this.handleViewOnly()
console.log(this.props) console.log(this.props)
} }
...@@ -856,14 +856,198 @@ export default class TaxPlanningOLPA extends Component { ...@@ -856,14 +856,198 @@ export default class TaxPlanningOLPA extends Component {
}) })
} }
uploadSimulasi() { checkUploadSimulasi() {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id currency_id: this.state.defaultCurrencyUpload?.id
} }
this.setState({ loading: true, dataTable: [] }) api.create().checkUploadOLPA(payload).then(response => {
console.log(payload) // console.log(JSON.stringify(this.state.payload));
api.create().uploadSimulasiROPL(payload).then(response => { console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUploadSimulasi: false, visibleTP: false, loading: true })
let dataTable = response.data.data.map((item, index) => {
return [
// item.type_report_id,
0,
Number(item.type_report_id.tbc),
Number(item.type_report_id.fcp),
Number(item.type_report_id.tbf),
item.item_report_id,
item.parent,
item.formula,
// {tbc: item.formula.tbc, fcp: item.formula.fcp, tbf: item.formula.tbf},
item.level,
item.item_report,
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.january.tbf === "" ? "0" : item.january.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.february.tbf === "" ? "0" : item.february.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.march.tbf === "" ? "0" : item.march.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.april.tbf === "" ? "0" : item.april.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.may.tbf === "" ? "0" : item.may.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.june.tbf === "" ? "0" : item.june.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.july.tbf === "" ? "0" : item.july.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.august.tbf === "" ? "0" : item.august.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.september.tbf === "" ? "0" : item.september.tbf
},
{
tbc: 0,
fcp: 0,
tbf: Number(item.type_report_id.tbf) === 3 && item.october.tbf === "" ? "0" : item.october.tbf
},
{
tbc: Number(item.type_report_id.tbc) === 3 && item.november.tbc === "" ? "0" : (Number(item.type_report_id.tbc) === 5 || Number(item.type_report_id.tbc) === 6 || Number(item.type_report_id.tbc) === 7 ? { value: item.november.tbc, formula: item.november_formula } : item.november.tbc),
fcp: Number(item.type_report_id.fcp) === 3 && item.november.fcp === "" ? "0" : (Number(item.type_report_id.fcp) === 5 || Number(item.type_report_id.fcp) === 6 || Number(item.type_report_id.fcp) === 7 ? { value: item.november.fcp, formula: item.november_formula } : item.november.fcp),
tbf: Number(item.type_report_id.tbf) === 3 && item.november.tbf === "" ? "0" : (Number(item.type_report_id.tbf) === 5 || Number(item.type_report_id.tbf) === 6 || Number(item.type_report_id.tbf) === 7 ? { value: item.november.tbf, formula: item.november_formula } : item.november.tbf)
},
{
tbc: Number(item.type_report_id.tbc) === 3 && item.december.tbc === "" ? "0" : (Number(item.type_report_id.tbc) === 5 || Number(item.type_report_id.tbc) === 6 || Number(item.type_report_id.tbc) === 7 ? { value: item.december.tbc, formula: item.december_formula } : item.december.tbc),
fcp: Number(item.type_report_id.fcp) === 3 && item.december.fcp === "" ? "0" : (Number(item.type_report_id.fcp) === 5 || Number(item.type_report_id.fcp) === 6 || Number(item.type_report_id.fcp) === 7 ? { value: item.december.fcp, formula: item.december_formula } : item.december.fcp),
tbf: Number(item.type_report_id.tbf) === 3 && item.december.tbf === "" ? "0" : (Number(item.type_report_id.tbf) === 5 || Number(item.type_report_id.tbf) === 6 || Number(item.type_report_id.tbf) === 7 ? { value: item.december.tbf, formula: item.december_formula } : item.december.tbf)
},
item.total_current_year,
0,
0,
item.orders,
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.state.dataTable.map(item => {
if (item[25].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
})
console.log(this.state.dataTable);
})
} 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);
}
})
}
}
})
}
uploadSimulasi(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[4],
january: {
// tbc: String(Number(i[9].tbc).toFixed(1)),
// fcp: String(Number(i[9].fcp).toFixed(1)),
tbf: String(Number(i[9].tbf).toFixed(1))
},
february: {
// tbc: String(Number(i[10].tbc).toFixed(1)),
// fcp: String(Number(i[10].fcp).toFixed(1)),
tbf: String(Number(i[10].tbf).toFixed(1))
},
march: {
// tbc: String(Number(i[11].tbc).toFixed(1)),
// fcp: String(Number(i[11].fcp).toFixed(1)),
tbf: String(Number(i[11].tbf).toFixed(1))
},
april: {
// tbc: String(Number(i[12].tbc).toFixed(1)),
// fcp: String(Number(i[12].fcp).toFixed(1)),
tbf: String(Number(i[12].tbf).toFixed(1))
},
may: {
// tbc: String(Number(i[13].tbc).toFixed(1)),
// fcp: String(Number(i[13].fcp).toFixed(1)),
tbf: String(Number(i[13].tbf).toFixed(1))
},
june: {
// tbc: String(Number(i[14].tbc).toFixed(1)),
// fcp: String(Number(i[14].fcp).toFixed(1)),
tbf: String(Number(i[14].tbf).toFixed(1))
},
july: {
// tbc: String(Number(i[15].tbc).toFixed(1)),
// fcp: String(Number(i[15].fcp).toFixed(1)),
tbf: String(Number(i[15].tbf).toFixed(1))
},
august: {
// tbc: String(Number(i[16].tbc).toFixed(1)),
// fcp: String(Number(i[16].fcp).toFixed(1)),
tbf: String(Number(i[16].tbf).toFixed(1))
},
september: {
// tbc: String(Number(i[17].tbc).toFixed(1)),
// fcp: String(Number(i[17].fcp).toFixed(1)),
tbf: String(Number(i[17].tbf).toFixed(1))
},
october: {
// tbc: String(Number(i[18].tbc).toFixed(1)),
// fcp: String(Number(i[18].fcp).toFixed(1)),
tbf: String(Number(i[18].tbf).toFixed(1))
},
november: {
tbc: String(Number(i[19].tbc).toFixed(1)),
fcp: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[19].fcp).toFixed(2)) : String(Number(i[19].fcp).toFixed(1)),
tbf: String(Number(i[19].tbf).toFixed(1))
},
december: {
tbc: String(Number(i[20].tbc).toFixed(1)),
fcp: String(i[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? String(Number(i[20].fcp).toFixed(2)) : String(Number(i[20].fcp).toFixed(1)),
tbf: String(Number(i[20].tbf).toFixed(1))
},
total_current_year: String(Number(i[21]).toFixed(1))
})
})
let body = {
outlook_pa_id: this.props.outlook_pa_id,
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
currency_id: this.state.defaultCurrencyUpload?.id,
tax_planning: data,
status: type
}
api.create().uploadSimulasiROPL(body).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -1245,7 +1429,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -1245,7 +1429,7 @@ export default class TaxPlanningOLPA extends Component {
// console.log(tableMeta); // console.log(tableMeta);
// } // }
let data = dex == 1 ? value.tbc : dex == 2 ? value.fcp : value.tbf let data = dex == 1 ? value.tbc : dex == 2 ? value.fcp : value.tbf
console.log(data); // console.log(data);
if (data.formula) { if (data.formula) {
let indexID = data.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode)) let indexID = data.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
if (indexID !== -1) { if (indexID !== -1) {
...@@ -2436,7 +2620,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2436,7 +2620,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp.value).toFixed(2) : Number(value.fcp.value).toFixed(1)} value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp.value) : Number(value.fcp.value)}
/> />
} }
/> />
...@@ -2471,7 +2655,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2471,7 +2655,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
// placeholder="input" // placeholder="input"
// disabled={this.props.isApprover == true ? true : false} // disabled={this.props.isApprover == true ? true : false}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp).toFixed(2) : Number(value.fcp).toFixed(1)} value={value.fcp == 0 ? "0.0" : String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp) : Number(value.fcp)}
onBlur={(event) => { onBlur={(event) => {
handleChange(event.target.value, tableMeta, 1) handleChange(event.target.value, tableMeta, 1)
// console.log(dataTable2) // console.log(dataTable2)
...@@ -2488,7 +2672,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2488,7 +2672,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleParent(tableMeta, 2)).toFixed(1)} value={Number(handleParent(tableMeta, 2)) == 0 ? "0.0" : Number(handleParent(tableMeta, 2))}
/> />
</span> </span>
: :
...@@ -2499,7 +2683,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2499,7 +2683,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)} value={Number(handleValueFormula(value, tableMeta, 2)) == 0 ? "0.0" : Number(handleValueFormula(value, tableMeta, 2))}
/> />
: :
tableMeta.rowData[2] === 5 ? tableMeta.rowData[2] === 5 ?
...@@ -2509,7 +2693,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2509,7 +2693,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)} value={Number(handleValueFormula(value, tableMeta, 2)) == 0 ? "0.0" : Number(handleValueFormula(value, tableMeta, 2))}
/> />
: :
tableMeta.rowData[2] === 7 ? tableMeta.rowData[2] === 7 ?
...@@ -2912,7 +3096,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2912,7 +3096,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
// placeholder="input" // placeholder="input"
// disabled={this.props.isApprover == true ? true : false} // disabled={this.props.isApprover == true ? true : false}
value={String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp).toFixed(2) : Number(value.fcp).toFixed(1)} value={value.fcp == 0 ? "0.0" : String(tableMeta.rowData[8]).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(value.fcp) : Number(value.fcp)}
onBlur={(event) => { onBlur={(event) => {
handleChange(event.target.value, tableMeta, 1) handleChange(event.target.value, tableMeta, 1)
// console.log(dataTable2) // console.log(dataTable2)
...@@ -2929,7 +3113,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2929,7 +3113,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleParent(tableMeta, 2)).toFixed(1)} value={Number(handleParent(tableMeta, 2)) == 0 ? "0.0" : Number(handleParent(tableMeta, 2))}
/> />
</span> </span>
: :
...@@ -2940,7 +3124,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2940,7 +3124,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)} value={Number(handleValueFormula(value, tableMeta, 2)) == 0 ? "0.0" : Number(handleValueFormula(value, tableMeta, 2))}
/> />
: :
tableMeta.rowData[2] === 5 ? tableMeta.rowData[2] === 5 ?
...@@ -2950,7 +3134,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -2950,7 +3134,7 @@ export default class TaxPlanningOLPA extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)} value={Number(handleValueFormula(value, tableMeta, 2))}
/> />
: :
tableMeta.rowData[2] === 7 ? tableMeta.rowData[2] === 7 ?
...@@ -3352,21 +3536,6 @@ export default class TaxPlanningOLPA extends Component { ...@@ -3352,21 +3536,6 @@ export default class TaxPlanningOLPA extends Component {
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}> <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload Simulasi'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })}
>
<img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
{this.props.isApprover === true || this.state.get_for == 'view' ? {this.props.isApprover === true || this.state.get_for == 'view' ?
null null
// <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
...@@ -3392,6 +3561,20 @@ export default class TaxPlanningOLPA extends Component { ...@@ -3392,6 +3561,20 @@ export default class TaxPlanningOLPA extends Component {
// </div> // </div>
: :
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Upload Simulasi'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })}
>
<img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download Template'} data-for="template"> <a data-tip={'Download Template'} data-for="template">
<button <button
style={{ style={{
...@@ -3599,6 +3782,98 @@ export default class TaxPlanningOLPA extends Component { ...@@ -3599,6 +3782,98 @@ export default class TaxPlanningOLPA 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 : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent}
<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 }}
>
<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"
// disabled={this.state.buttonError}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true, buttonDraft: false }, () => {
setTimeout(() => {
// this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false, editable: false })
this.handleValidate()
}, 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}
style={{
backgroundColor: 'transparent',
cursor: this.state.editable !== true ? 'pointer' : 'default',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() =>
this.state.editable === true ?
this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
:
this.state.handleDoubleClick == 1 ? null :
this.setState({ handleDoubleClick: 1, loading: true }, () => {
setTimeout(() => {
this.uploadSimulasi('submitted')
}, 100);
})}
>
<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 }}>
...@@ -3787,7 +4062,7 @@ export default class TaxPlanningOLPA extends Component { ...@@ -3787,7 +4062,7 @@ export default class TaxPlanningOLPA extends Component {
}} }}
onUpload={() => { onUpload={() => {
String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PA") && String(this.state.judul).includes("TAX") && String(this.state.judul).includes("PLANNING") ? String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PA") && String(this.state.judul).includes("TAX") && String(this.state.judul).includes("PLANNING") ?
this.uploadSimulasi() : this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}} }}
/> />
......
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