Commit aa9e3d12 authored by Riri Novita's avatar Riri Novita

Update Simulasi MB

parent 62587f66
...@@ -48,7 +48,6 @@ class Login extends Component { ...@@ -48,7 +48,6 @@ class Login extends Component {
componentDidMount() { componentDidMount() {
this.getUser() this.getUser()
var email = localStorage.getItem(Constant.EMAIL) var email = localStorage.getItem(Constant.EMAIL)
console.log(email)
} }
getWindowDimensions() { getWindowDimensions() {
...@@ -112,6 +111,7 @@ class Login extends Component { ...@@ -112,6 +111,7 @@ class Login extends Component {
} else { } else {
localStorage.setItem(Constant.TOKEN, datas.token) localStorage.setItem(Constant.TOKEN, datas.token)
localStorage.setItem(Constant.USER, datas.user_id) localStorage.setItem(Constant.USER, datas.user_id)
localStorage.setItem(Constant.ROLE, datas.role_id)
if (this.state.rememberMe) { if (this.state.rememberMe) {
localStorage.setItem(Constant.EMAIL, this.state.email) localStorage.setItem(Constant.EMAIL, this.state.email)
localStorage.setItem(Constant.PASSWORD, this.state.password) localStorage.setItem(Constant.PASSWORD, this.state.password)
......
...@@ -60,7 +60,8 @@ export default class BalanceSheet extends Component { ...@@ -60,7 +60,8 @@ export default class BalanceSheet extends Component {
tipeAlert: '', tipeAlert: '',
messageAlert: '', messageAlert: '',
defaultCurrencyUpload: this.props.defaultCurrency, defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false visibleAlertSave: false,
visibleButtonUpload: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this); this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
...@@ -489,27 +490,106 @@ export default class BalanceSheet extends Component { ...@@ -489,27 +490,106 @@ export default class BalanceSheet 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().checkUploadMB(payload).then(response => {
// let dataDelete = this.state.dataDelete // console.log(response)
// api.create().getIdDeleteFromExcel(payload).then((response) => { if (response.data) {
// if (response.data) { if (response.data.status === 'success') {
// // // // // // console.log(response.data) this.setState({ visibleUpload: false, visibleBalanceSheet: false, loading: true, visibleButtonUpload: true })
// let idDelete = response.data.data.item_report_id let dataTable = response.data.data.map((item, index) => {
// if (idDelete.length > 0) { return [
// idDelete.map((item, index) => { item.type_report_id,
// dataDelete.push(item) item.item_report_id,
// }) item.parent,
// this.setState({ dataDelete }) item.formula,
// } item.level,
// } item.item_report,
// }) item.total_actual_before,
console.log(payload) item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.january, formula: item.january_formula } : Number(item.january).toFixed(1),
api.create().uploadSimulasiMB(payload).then(response => { item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.february, formula: item.february_formula } : Number(item.february).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.march, formula: item.march_formula } : Number(item.march).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.april, formula: item.april_formula } : Number(item.april).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.may, formula: item.may_formula } : Number(item.may).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.june, formula: item.june_formula } : Number(item.june).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.july, formula: item.july_formula } : Number(item.july).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.august, formula: item.august_formula } : Number(item.august).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.september, formula: item.september_formula } : Number(item.september).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.october, formula: item.october_formula } : Number(item.october).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.november, formula: item.november_formula } : Number(item.november).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.december, formula: item.december_formula } : Number(item.december).toFixed(1),
Number(item.total_current_year).toFixed(1),
Number(item.total_next_year).toFixed(1),
Number(item.total_more_year).toFixed(1),
item.orders,
item.condition_it_should_be,
item.condition_if_wrong,
item.forecast_formula == null ? [] : item.forecast_formula,
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, errorPreview: false, saveDraft: true }, () => {
this.state.dataTable.map(item => {
if (item[26].length > 0) {
// console.log('error')
this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: 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);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
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] === 5 || i[0] === 6 ? String(Number(i[7].value).toFixed(1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
february: i[0] === 5 || i[0] === 6 ? String(Number(i[8].value).toFixed(1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
march: i[0] === 5 || i[0] === 6 ? String(Number(i[9].value).toFixed(1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
april: i[0] === 5 || i[0] === 6 ? String(Number(i[10].value).toFixed(1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
may: i[0] === 5 || i[0] === 6 ? String(Number(i[11].value).toFixed(1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
june: i[0] === 5 || i[0] === 6 ? String(Number(i[12].value).toFixed(1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
july: i[0] === 5 || i[0] === 6 ? String(Number(i[13].value).toFixed(1)) : i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
august: i[0] === 5 || i[0] === 6 ? String(Number(i[14].value).toFixed(1)) : i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
september: i[0] === 5 || i[0] === 6 ? String(Number(i[15].value).toFixed(1)) : i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
october: i[0] === 5 || i[0] === 6 ? String(Number(i[16].value).toFixed(1)) : i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)),
november: i[0] === 5 || i[0] === 6 ? String(Number(i[17].value).toFixed(1)) : i[0] === 3 && i[17] === "" ? "0.0" : String(Number(i[17]).toFixed(1)),
december: i[0] === 5 || i[0] === 6 ? String(Number(i[18].value).toFixed(1)) : i[0] === 3 && i[18] === "" ? "0.0" : String(Number(i[18]).toFixed(1)),
total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19]).toFixed(1)),
total_next_year: i[0] === 3 && i[20] === "" ? "0.0" : String(Number(i[20]).toFixed(1)),
total_more_year: i[0] === 3 && i[21] === "" ? "0.0" : String(Number(i[21]).toFixed(1)),
})
})
let body = {
submission_id: this.props.submissionID,
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
currency_id: this.state.defaultCurrencyUpload?.id,
balance_sheet: data,
status: type
}
console.log(body)
api.create().uploadSimulasiMB(body).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -3981,12 +4061,37 @@ export default class BalanceSheet extends Component { ...@@ -3981,12 +4061,37 @@ export default class BalanceSheet extends Component {
}} }}
onUpload={() => { onUpload={() => {
String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("BALANCE") && String(this.state.judul).includes("SHEET") ? String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && 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' })
}} }}
/> />
</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> {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div>
<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 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>
......
...@@ -86,7 +86,8 @@ export default class CorporateAnnualTarget extends Component { ...@@ -86,7 +86,8 @@ export default class CorporateAnnualTarget extends Component {
dataLearn: [], dataLearn: [],
handleDataSalah: false, handleDataSalah: false,
defaultCurrencyUpload: this.props.defaultCurrency, defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false visibleAlertSave: false,
visibleButtonUpload: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this); this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
...@@ -708,7 +709,156 @@ export default class CorporateAnnualTarget extends Component { ...@@ -708,7 +709,156 @@ export default class CorporateAnnualTarget extends Component {
}) })
} }
uploadSimulasi() { checkUploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
this.setState({ loading: true, dataTable: [] })
let dataDelete = this.state.dataDelete
api.create().getIdDeleteFromExcel(payload).then((response) => {
if (response.data) {
// // // // // console.log(response.data)
let idDelete = response.data.data.item_report_id
if (idDelete.length > 0) {
idDelete.map((item, index) => {
dataDelete.push(item)
})
this.setState({ dataDelete })
}
}
})
console.log(payload)
api.create().checkUploadMB(payload).then(response => {
// // console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
// this.setState({ visibleUpload: false, visibleCAT: false })
this.setState({ visibleUpload: false, visibleCAT: false, visibleButtonUpload: true })
let dataTable = []
let custoId = 0
let bisnsId = 0
let dataDelete = this.state.dataDelete
let dataFin = this.state.dataFin
let dataLearn = this.state.dataLearn
let newValidate = false
response.data.data.map((item, index) => {
if (item.item_report == 'CUSTOMER PERSPECTIVE') {
custoId = item.item_report_id
}
if (item.item_report == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
bisnsId = item.item_report_id
}
if (String(item.item_report).trim().toLocaleUpperCase() == "CUSTOMER PERSPECTIVE") {
newValidate = true
}
if (String(item.item_report).trim().toLocaleUpperCase() == "LEARNING & GROWTH PERSPECTIVE") {
newValidate = false
}
if (item.type_report_id !== 4 && item.parent !== null && (item.parent == custoId || item.parent == bisnsId)) {
let indexCust = this.state.dataCustomerPrs.findIndex((val) => val.name == item.item_report)
let indexBisn = this.state.dataInternalBsn.findIndex((val) => val.name == item.item_report)
if (indexCust !== -1 && item.item_report_id == 0) {
dataDelete.push(this.state.dataCustomerPrs[indexCust].id)
}
if (indexBisn !== -1 && item.item_report_id == 0) {
dataDelete.push(this.state.dataInternalBsn[indexBisn].id)
}
}
if (newValidate == false) {
let indexIDx = dataFin.findIndex((val) => String(val.name).toLocaleLowerCase() == String(item.item_report).toLocaleLowerCase())
let indexIDz = dataLearn.findIndex((val) => String(val.name).toLocaleLowerCase() == String(item.item_report).toLocaleLowerCase())
if (indexIDx != -1) {
dataFin[indexIDx].check = true
}
if (indexIDz != -1) {
dataLearn[indexIDz].check = true
}
}
dataTable.push([
item.type_report_id,
item.item_report_id,
item.parent,
item.formula,
item.level == null ? 1 : item.level,
"",
item.item_report,
item.type_report_id == 1 ? (`${String(item.weight).includes('%') ? String(item.weight) : String((Number(item.weight) * 100) + '% ')}`) : (String(item.weight)),
item.uom,
item.kpi_type == "" || item.kpi_type == null ? null : { value: item.kpi_type },
item.max_ach == "" || item.max_ach == null ? null : { value: titleCase(item.max_ach) },
item.formula_ytd == "" || item.formula_ytd == null ? null : { value: item.formula_ytd },
item.total_actual_before == "" ? item.total_actual_before : String(item.total_actual_before).indexOf(".") == -1 ? Number(item.total_actual_before) : Number(item.total_actual_before).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.january).toFixed(1) : { value: item.january, formula: item.january_formula } : item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.february).toFixed(1) : { value: item.february, formula: item.february_formula } : item.february == "" ? item.february : String(item.february).indexOf(".") == -1 ? Number(item.february) : Number(item.february).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.march).toFixed(1) : { value: item.march, formula: item.march_formula } : item.march == "" ? item.march : String(item.march).indexOf(".") == -1 ? Number(item.march) : Number(item.march).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.april).toFixed(1) : { value: item.april, formula: item.april_formula } : item.april == "" ? item.april : String(item.april).indexOf(".") == -1 ? Number(item.april) : Number(item.april).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.may).toFixed(1) : { value: item.may, formula: item.may_formula } : item.may == "" ? item.may : String(item.may).indexOf(".") == -1 ? Number(item.may) : Number(item.may).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.june).toFixed(1) : { value: item.june, formula: item.june_formula } : item.june == "" ? item.june : String(item.june).indexOf(".") == -1 ? Number(item.june) : Number(item.june).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.july).toFixed(1) : { value: item.july, formula: item.july_formula } : item.july == "" ? item.july : String(item.july).indexOf(".") == -1 ? Number(item.july) : Number(item.july).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.august).toFixed(1) : { value: item.august, formula: item.august_formula } : item.august == "" ? item.august : String(item.august).indexOf(".") == -1 ? Number(item.august) : Number(item.august).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.september).toFixed(1) : { value: item.september, formula: item.september_formula } : item.september == "" ? item.september : String(item.september).indexOf(".") == -1 ? Number(item.september) : Number(item.september).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.october).toFixed(1) : { value: item.october, formula: item.october_formula } : item.october == "" ? item.october : String(item.october).indexOf(".") == -1 ? Number(item.october) : Number(item.october).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.november).toFixed(1) : { value: item.november, formula: item.november_formula } : item.november == "" ? item.november : String(item.november).indexOf(".") == -1 ? Number(item.november) : Number(item.november).toFixed(1),
item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.december).toFixed(1) : { value: item.december, formula: item.december_formula } : item.december == "" ? item.december : String(item.december).indexOf(".") == -1 ? Number(item.december) : Number(item.december).toFixed(1),
item.total_current_year === "NaN" ? "0.0" : item.total_current_year == "" ? item.total_current_year : String(item.total_current_year).indexOf(".") == -1 ? Number(item.total_current_year) : Number(item.total_current_year).toFixed(1),
item.total_next_year == "" ? item.total_next_year : String(item.total_next_year).indexOf(".") == -1 ? Number(item.total_next_year) : Number(item.total_next_year).toFixed(1),
item.total_more_year == "" ? item.total_more_year : String(item.total_more_year).indexOf(".") == -1 ? Number(item.total_more_year) : Number(item.total_more_year).toFixed(1),
item.strategic,
item.pic,
item.forecast_formula,
item.orders,
item.error
])
})
let checkDataFin = dataFin.filter((val) => val.check == false)
let checkDataLearn = dataLearn.filter((val) => val.check == false)
let handleDataSalah = this.state.handleDataSalah
if (checkDataFin.length > 0 || checkDataLearn.length > 0) {
handleDataSalah = true
}
// // console.log(indexCheck)
// // // // console.log(this.state.buttonError)
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, dataDelete, handleDataSalah }, () => {
this.state.dataTable.map(item => {
if (item[30].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);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
uploadSimulasi(type) {
let payload = { let payload = {
...this.state.payload, ...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id currency_id: this.state.defaultCurrencyUpload?.id
...@@ -762,6 +912,99 @@ export default class CorporateAnnualTarget extends Component { ...@@ -762,6 +912,99 @@ export default class CorporateAnnualTarget extends Component {
} }
uploadSimulasi(type) {
// let dataDelete = this.state.dataDelete
// // // // console.log(dataDelete)
let payload = { "item_report_id": this.state.dataDelete }
if (this.state.dataDelete.length > 0) {
api.create().deleteAllItemReport(payload).then((response) => {
this.functionUploadSimulasi(type)
})
} else {
this.functionUploadSimulasi(type)
}
}
functionUploadSimulasi(type) {
let data = []
let stateFR = false
// // // console.log(this.state.dataTable)
this.state.dataTable.map(i => {
if (i[2] !== null) {
let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
if (indexID !== -1) {
if (this.state.dataTable[indexID][6] === 'FINANCIAL PERSPECTIVE') {
stateFR = true
} else {
stateFR = false
}
}
} else {
stateFR = false
}
data.push({
"item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
"item_report": String(i[6]),
"weight": String(i[7]),
"uom": String(i[8]),
"kpi_type": i[9] == null ? "" : i[9].value,
"max_ach": i[10] == null ? "" : i[10].value,
"formula": i[11] == null ? "" : i[11].value,
"total_actual_before": String(i[12]) == "" ? "0.0" : String(i[12]),
"january": i[13].value != undefined ? String(Number(i[13].value).toFixed(1)) : String(i[13]),
"february": i[14].value != undefined ? String(Number(i[14].value).toFixed(1)) : String(i[14]),
"march": i[15].value != undefined ? String(Number(i[15].value).toFixed(1)) : String(i[15]),
"april": i[16].value != undefined ? String(Number(i[16].value).toFixed(1)) : String(i[16]),
"may": i[17].value != undefined ? String(Number(i[17].value).toFixed(1)) : String(i[17]),
"june": i[18].value != undefined ? String(Number(i[18].value).toFixed(1)) : String(i[18]),
"july": i[19].value != undefined ? String(Number(i[19].value).toFixed(1)) : String(i[19]),
"august": i[20].value != undefined ? String(Number(i[20].value).toFixed(1)) : String(i[20]),
"september": i[21].value != undefined ? String(Number(i[21].value).toFixed(1)) : String(i[21]),
"october": i[22].value != undefined ? String(Number(i[22].value).toFixed(1)) : String(i[22]),
"november": i[23].value != undefined ? String(Number(i[23].value).toFixed(1)) : String(i[23]),
"december": i[24].value != undefined ? String(Number(i[24].value).toFixed(1)) : String(i[24]),
"total_current_year": String(Number(i[25]).toFixed(1)) == "" ? "0.0" : String(Number(i[25]).toFixed(1)),
"total_next_year": String(Number(i[26]).toFixed(1)) == "" ? "0.0" : String(Number(i[26]).toFixed(1)),
"total_more_year": String(Number(i[27]).toFixed(1)) == "" ? "0.0" : String(Number(i[27]).toFixed(1)),
"strategic": String(i[28]),
"pic": String(i[29])
})
})
let body = {
"report_id": this.props.report_id,
// "revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID,
"currency_id": this.state.defaultCurrencyUpload?.id,
"status": type,
"cat": data
}
// // console.log(data);
// // console.log(JSON.stringify(body))
api.create('UPLOAD').uploadSimulasiMB(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.getReport(body, 'CAT')
this.setState({ loading: false })
this.props.onClickClose()
// this.props.getReport()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false })
}
})
}
functionUpload(type) { functionUpload(type) {
let data = [] let data = []
let stateFR = false let stateFR = false
...@@ -4354,12 +4597,38 @@ export default class CorporateAnnualTarget extends Component { ...@@ -4354,12 +4597,38 @@ export default class CorporateAnnualTarget extends Component {
}} }}
onUpload={() => { onUpload={() => {
String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("CAT") ? String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("CAT") ?
this.uploadSimulasi() : this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}} }}
/> />
</div> </div>
<div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> (Simulasi) Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div>
<button
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() =>
this.setState({ handleDoubleClick: 1 }, () => {
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 & Complete</Typography>
</div>
</button>
</div>
</div>
}
{/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> (Simulasi) Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */}
</div> </div>
</div> </div>
......
...@@ -50,7 +50,8 @@ export default class FixedAssetsMovement extends Component { ...@@ -50,7 +50,8 @@ export default class FixedAssetsMovement extends Component {
updateBy: [], updateBy: [],
handleDoubleClick: 0, handleDoubleClick: 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);
...@@ -458,27 +459,110 @@ export default class FixedAssetsMovement extends Component { ...@@ -458,27 +459,110 @@ export default class FixedAssetsMovement 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().checkUploadMB(payload).then(response => {
// let dataDelete = this.state.dataDelete // // console.log(JSON.stringify(this.state.payload));
// api.create().getIdDeleteFromExcel(payload).then((response) => { // // console.log(response)
// if (response.data) { if (response.data) {
// // // // // // console.log(response.data) if (response.ok) {
// let idDelete = response.data.data.item_report_id if (response.data.status === 'success') {
// if (idDelete.length > 0) { this.setState({ visibleUpload: false, visibleFixedAssetsMovement: false, loading: true, visibleButtonUpload: true })
// idDelete.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
// dataDelete.push(item) return [
// }) item.type_report_id,
// this.setState({ dataDelete }) item.item_report_id,
// } item.parent,
// } item.formula,
// }) item.level,
console.log(payload) item.item_report,
api.create().uploadSimulasiMB(payload).then(response => { item.total_actual_before,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.january, formula: item.january_formula } : Number(item.january).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.february, formula: item.february_formula } : Number(item.february).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.march, formula: item.march_formula } : Number(item.march).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.april, formula: item.april_formula } : Number(item.april).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.may, formula: item.may_formula } : Number(item.may).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.june, formula: item.june_formula } : Number(item.june).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.july, formula: item.july_formula } : Number(item.july).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.august, formula: item.august_formula } : Number(item.august).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.september, formula: item.september_formula } : Number(item.september).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.october, formula: item.october_formula } : Number(item.october).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.november, formula: item.november_formula } : Number(item.november).toFixed(1),
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.december, formula: item.december_formula } : Number(item.december).toFixed(1),
Number(item.total_current_year).toFixed(1),
Number(item.total_next_year).toFixed(1),
Number(item.total_more_year).toFixed(1),
item.orders,
item.forecast_formula,
item.before_formula,
item.error
]
})
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' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
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] === 5 || i[0] === 6 ? String(Number(i[7].value).toFixed(1)) : String(Number(i[7]).toFixed(1)),
february: i[0] === 5 || i[0] === 6 ? String(Number(i[8].value).toFixed(1)) : String(Number(i[8]).toFixed(1)),
march: i[0] === 5 || i[0] === 6 ? String(Number(i[9].value).toFixed(1)) : String(Number(i[9]).toFixed(1)),
april: i[0] === 5 || i[0] === 6 ? String(Number(i[10].value).toFixed(1)) : String(Number(i[10]).toFixed(1)),
may: i[0] === 5 || i[0] === 6 ? String(Number(i[11].value).toFixed(1)) : String(Number(i[11]).toFixed(1)),
june: i[0] === 5 || i[0] === 6 ? String(Number(i[12].value).toFixed(1)) : String(Number(i[12]).toFixed(1)),
july: i[0] === 5 || i[0] === 6 ? String(Number(i[13].value).toFixed(1)) : String(Number(i[13]).toFixed(1)),
august: i[0] === 5 || i[0] === 6 ? String(Number(i[14].value).toFixed(1)) : String(Number(i[14]).toFixed(1)),
september: i[0] === 5 || i[0] === 6 ? String(Number(i[15].value).toFixed(1)) : String(Number(i[15]).toFixed(1)),
october: i[0] === 5 || i[0] === 6 ? String(Number(i[16].value).toFixed(1)) : String(Number(i[16]).toFixed(1)),
november: i[0] === 5 || i[0] === 6 ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1)),
december: i[0] === 5 || i[0] === 6 ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1)),
total_current_year: String(Number(i[19]).toFixed(1)),
total_next_year: String(Number(i[20]).toFixed(1)),
total_more_year: String(Number(i[21]).toFixed(1))
})
})
let body = {
submission_id: this.props.submissionID,
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
currency_id: this.state.defaultCurrencyUpload?.id,
fixed_asset_movement: data,
status: type
}
console.log(body)
api.create().uploadSimulasiMB(body).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -3153,12 +3237,37 @@ export default class FixedAssetsMovement extends Component { ...@@ -3153,12 +3237,37 @@ export default class FixedAssetsMovement extends Component {
}} }}
onUpload={() => { onUpload={() => {
String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("FIXED") && String(this.state.judul).includes("ASSETS") && String(this.state.judul).includes("MOVEMENT") ? String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("FIXED") && String(this.state.judul).includes("ASSETS") && String(this.state.judul).includes("MOVEMENT") ?
this.uploadSimulasi() : this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}} }}
/> />
</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> {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div>
<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 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>
......
...@@ -65,7 +65,8 @@ export default class ProfitLoss extends Component { ...@@ -65,7 +65,8 @@ export default class ProfitLoss extends Component {
handleDoubleClick: 0, handleDoubleClick: 0,
fromUpload: false, fromUpload: false,
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);
...@@ -475,27 +476,105 @@ export default class ProfitLoss extends Component { ...@@ -475,27 +476,105 @@ export default class ProfitLoss 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().checkUploadMB(payload).then(response => {
// let dataDelete = this.state.dataDelete // console.log(JSON.stringify(this.state.payload));
// api.create().getIdDeleteFromExcel(payload).then((response) => { console.log(response)
// if (response.data) { if (response.data) {
// // // // // // console.log(response.data) if (response.data.status === 'success') {
// let idDelete = response.data.data.item_report_id this.setState({ visibleUpload: false, visibleProfitLoss: false, loading: true, visibleButtonUpload: true })
// if (idDelete.length > 0) { let dataTable = response.data.data.map((item, index) => {
// idDelete.map((item, index) => { return [
// dataDelete.push(item) item.type_report_id,
// }) item.item_report_id,
// this.setState({ dataDelete }) item.parent,
// } item.formula,
// } item.level,
// }) item.item_report,
console.log(payload) item.notes,
api.create().uploadSimulasiMB(payload).then(response => { Number(item.total_actual_before).toFixed(1),
Number(item.january).toFixed(1),
Number(item.february).toFixed(1),
Number(item.march).toFixed(1),
Number(item.april).toFixed(1),
Number(item.may).toFixed(1),
Number(item.june).toFixed(1),
Number(item.july).toFixed(1),
Number(item.august).toFixed(1),
Number(item.september).toFixed(1),
Number(item.october).toFixed(1),
Number(item.november).toFixed(1),
Number(item.december).toFixed(1),
Number(item.total_current_year).toFixed(1),
Number(item.total_next_year).toFixed(1),
Number(item.total_more_year).toFixed(1),
item.orders,
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, fromUpload: 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.buttonError)
})
} 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],
notes: String(i[6]),
total_actual_before: String(Number(i[7]).toFixed(1)),
january: String(Number(i[8]).toFixed(1)),
february: String(Number(i[9]).toFixed(1)),
march: String(Number(i[10]).toFixed(1)),
april: String(Number(i[11]).toFixed(1)),
may: String(Number(i[12]).toFixed(1)),
june: String(Number(i[13]).toFixed(1)),
july: String(Number(i[14]).toFixed(1)),
august: String(Number(i[15]).toFixed(1)),
september: String(Number(i[16]).toFixed(1)),
october: String(Number(i[17]).toFixed(1)),
november: String(Number(i[18]).toFixed(1)),
december: String(Number(i[19]).toFixed(1)),
total_current_year: String(Number(i[20]).toFixed(1)),
total_next_year: String(Number(i[21]).toFixed(1)),
total_more_year: String(Number(i[22]).toFixed(1)),
})
})
let body = {
submission_id: this.props.submissionID,
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
currency_id: this.state.defaultCurrencyUpload?.id,
profit_loss: data,
status: type
}
console.log(body)
api.create().uploadSimulasiMB(body).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -3419,13 +3498,37 @@ export default class ProfitLoss extends Component { ...@@ -3419,13 +3498,37 @@ export default class ProfitLoss extends Component {
}} }}
onUpload={() => { onUpload={() => {
String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("PROFIT") && String(this.state.judul).includes("LOSS") ? String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("PROFIT") && String(this.state.judul).includes("LOSS") ?
this.uploadSimulasi() : this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}} }}
/> />
</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> {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div>
<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 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>
)} )}
......
...@@ -58,7 +58,8 @@ export default class TaxPlanning extends Component { ...@@ -58,7 +58,8 @@ export default class TaxPlanning extends Component {
minValue: "0", minValue: "0",
maxValue: "0", maxValue: "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)
...@@ -770,7 +771,86 @@ export default class TaxPlanning extends Component { ...@@ -770,7 +771,86 @@ export default class TaxPlanning extends Component {
}) })
} }
uploadSimulasi() { checkUploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
console.log(payload);
api.create().checkUploadMB(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleTP: false, loading: true, visibleButtonUpload: 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: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.january.tbc, formula: item.january_formula } : Number(item.january.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 || item.type_report_id.fcp == 7 ? { value: item.january.fcp, formula: item.january_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.january.fcp).toFixed(2) : Number(item.january.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 || item.type_report_id.tbf == 7 ? { value: item.january.tbf, formula: item.january_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.january.tbf).toFixed(2) : Number(item.january.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.february.tbc, formula: item.february_formula } : Number(item.february.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.february.fcp, formula: item.february_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.february.fcp).toFixed(2) : Number(item.february.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.february.tbf, formula: item.february_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.february.tbf).toFixed(2) : Number(item.february.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.march.tbc, formula: item.march_formula } : Number(item.march.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.march.fcp, formula: item.march_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.march.fcp).toFixed(2) : Number(item.march.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.march.tbf, formula: item.march_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.march.tbf).toFixed(2) : Number(item.march.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.april.tbc, formula: item.april_formula } : Number(item.april.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.april.fcp, formula: item.april_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.april.fcp).toFixed(2) : Number(item.april.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.april.tbf, formula: item.april_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.april.tbf).toFixed(2) : Number(item.april.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.may.tbc, formula: item.may_formula } : Number(item.may.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.may.fcp, formula: item.may_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.may.fcp).toFixed(2) : Number(item.may.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.may.tbf, formula: item.may_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.may.tbf).toFixed(2) : Number(item.may.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.june.tbc, formula: item.june_formula } : Number(item.june.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.june.fcp, formula: item.june_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.june.fcp).toFixed(2) : Number(item.june.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.june.tbf, formula: item.june_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.june.tbf).toFixed(2) : Number(item.june.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.july.tbc, formula: item.july_formula } : Number(item.july.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.july.fcp, formula: item.july_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.july.fcp).toFixed(2) : Number(item.july.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.july.tbf, formula: item.july_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.july.tbf).toFixed(2) : Number(item.july.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.august.tbc, formula: item.august_formula } : item.august.tbc === null ? "0" : item.august.tbc === "" ? "0" : Number(item.august.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.august.fcp, formula: item.august_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.august.fcp).toFixed(2) : Number(item.august.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.august.tbf, formula: item.august_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.august.tbf).toFixed(2) : Number(item.august.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.september.tbc, formula: item.september_formula } : Number(item.september.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.september.fcp, formula: item.september_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.september.fcp).toFixed(2) : Number(item.september.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.september.tbf, formula: item.september_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.september.tbf).toFixed(2) : Number(item.september.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.october.tbc, formula: item.october_formula } : Number(item.october.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.october.fcp, formula: item.october_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.october.fcp).toFixed(2) : Number(item.october.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.october.tbf, formula: item.october_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.october.tbf).toFixed(2) : Number(item.october.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.november.tbc, formula: item.november_formula } : Number(item.november.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.november.fcp, formula: item.november_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.november.fcp).toFixed(2) : Number(item.november.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.november.tbf, formula: item.november_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.november.tbf).toFixed(2) : Number(item.november.tbf).toFixed(1) },
{ tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.december.tbc, formula: item.december_formula } : Number(item.december.tbc).toFixed(1), fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.december.fcp, formula: item.december_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.december.fcp).toFixed(2) : Number(item.december.fcp).toFixed(1), tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.december.tbf, formula: item.december_formula } : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.december.tbf).toFixed(2) : Number(item.december.tbf).toFixed(1) },
String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.total_current_year).toFixed(2) : Number(item.total_current_year).toFixed(1),
{
tbc: Number(item.type_report_id.tbc) === 3 && item.total_next_year.tbc === "" ? "0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.total_next_year.tbc).toFixed(2) : Number(item.total_next_year.tbc).toFixed(1),
fcp: Number(item.type_report_id.fcp) === 3 && item.total_next_year.fcp === "" ? "0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.total_next_year.fcp).toFixed(2) : Number(item.total_next_year.fcp).toFixed(1),
tbf: Number(item.type_report_id.tbf) === 3 && item.total_next_year.tbf === "" ? "0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.total_next_year.tbf).toFixed(2) : Number(item.total_next_year.tbf).toFixed(1)
},
{
tbc: Number(item.type_report_id.tbc) === 3 && item.total_more_year.tbc === "" ? "0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.total_more_year.tbc).toFixed(2) : Number(item.total_more_year.tbc).toFixed(1),
fcp: Number(item.type_report_id.fcp) === 3 && item.total_more_year.fcp === "" ? "0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.total_more_year.fcp).toFixed(2) : Number(item.total_more_year.fcp).toFixed(1),
tbf: Number(item.type_report_id.tbf) === 3 && item.total_more_year.tbf === "" ? "0" : String(item.item_report).toLocaleUpperCase() == "CORPORATE INCOME TAX" ? Number(item.total_more_year.tbf).toFixed(2) : Number(item.total_more_year.tbf).toFixed(1)
},
item.orders,
{ tbc: item.condition_it_should_be.tbc, fcp: item.condition_it_should_be.fcp, tbf: item.condition_it_should_be.tbf },
{ tbc: item.condition_if_wrong.tbc, fcp: item.condition_if_wrong.fcp, tbf: item.condition_if_wrong.tbf },
item.forecast_tbc_formula,
item.forecast_fcp_formula,
item.forecast_tbf_formula,
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, saveDraft: true }, () => {
this.state.dataTable.map(item => {
if (item[27].length > 0) {
// console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: 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 payload = { let payload = {
...this.state.payload, ...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id currency_id: this.state.defaultCurrencyUpload?.id
...@@ -9651,12 +9731,37 @@ export default class TaxPlanning extends Component { ...@@ -9651,12 +9731,37 @@ export default class TaxPlanning extends Component {
}} }}
onUpload={() => { onUpload={() => {
String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("TAX") && String(this.state.judul).includes("PLANNING") ? String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && 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' })
}} }}
/> />
</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> {this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div>
<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 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>
......
const Constant = { const Constant = {
TOKEN: null, TOKEN: null,
USER: 0, USER: 0,
ROLE: 'role_id',
EMAIL: 'TOKEN', EMAIL: 'TOKEN',
PASSWORD: 'PASSWORD', PASSWORD: 'PASSWORD',
URL_BE_DEV: '${process.env.REACT_APP_URL_MAIN_BE}', URL_BE_DEV: '${process.env.REACT_APP_URL_MAIN_BE}',
......
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