Commit 29fbe4f4 authored by r.kurnia's avatar r.kurnia

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into rifka

parents 21304aaf 8aed1c07
...@@ -278,7 +278,7 @@ const create = (type = "") => { ...@@ -278,7 +278,7 @@ const create = (type = "") => {
const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body) const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body)
const createMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/create_monthly_report', body) const createMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/create_monthly_report', body)
const checkUploadMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/check_import', body) const checkUploadMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/check_import', body)
const uploadMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/import_monthly_report', body)
//Template //Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`) const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
...@@ -486,6 +486,7 @@ const create = (type = "") => { ...@@ -486,6 +486,7 @@ const create = (type = "") => {
getHierarkiMontlyReportFAM, getHierarkiMontlyReportFAM,
checkUploadMonthlyReportTP, checkUploadMonthlyReportTP,
checkUploadMonthlyReportFAM, checkUploadMonthlyReportFAM,
uploadMonthlyReportPL,
getMonthlyReport getMonthlyReport
} }
} }
......
...@@ -663,10 +663,17 @@ export default class FixedAssetsMovement extends Component { ...@@ -663,10 +663,17 @@ export default class FixedAssetsMovement extends Component {
const handleForecast = (tableMeta, periode) => { const handleForecast = (tableMeta, periode) => {
let total = 0 let total = 0
if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'gain/ (loss) on fixed assets' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'ending balance' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') { if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'gain/ (loss) on fixed assets' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'ending balance' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') {
if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') {
let indexID = dataTable2.findIndex((val, index) => String(val[5]).toLocaleLowerCase() == 'ending balance' && dataTable2[index-1][2] == tableMeta.rowData[2])
if (indexID !== -1) {
total = dataTable2[indexID][18].value
}
} else {
let indexID = dataTable2[tableMeta.rowIndex][23].findIndex((val) => val.periode == periode) let indexID = dataTable2[tableMeta.rowIndex][23].findIndex((val) => val.periode == periode)
if (indexID !== -1) { if (indexID !== -1) {
total = dataTable2[tableMeta.rowIndex][23][indexID].value total = dataTable2[tableMeta.rowIndex][23][indexID].value
} }
}
} else { } else {
total = handleValueFormula(tableMeta.columnIndex, tableMeta) total = handleValueFormula(tableMeta.columnIndex, tableMeta)
} }
......
...@@ -104,7 +104,7 @@ export default class ProfitLoss extends Component { ...@@ -104,7 +104,7 @@ export default class ProfitLoss extends Component {
"submission_id": this.props.submissionID "submission_id": this.props.submissionID
} }
api.create().getDetailReportMB(payload).then(response => { api.create().getDetailReportMB(payload).then(response => {
console.log(response); // console.log(response);
let dataTable = [] let dataTable = []
this.setState({ visibleProfitLoss: true }) this.setState({ visibleProfitLoss: true })
if (response.data) { if (response.data) {
...@@ -141,10 +141,10 @@ export default class ProfitLoss extends Component { ...@@ -141,10 +141,10 @@ export default class ProfitLoss extends Component {
item.order item.order
]) ])
} }
if (item.id === 20092) { // if (item.id === 20092) {
console.log(item); // console.log(item);
console.log(dataTable); // console.log(dataTable);
} // }
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items, indexs) => { item.children.map((items, indexs) => {
...@@ -188,7 +188,7 @@ export default class ProfitLoss extends Component { ...@@ -188,7 +188,7 @@ export default class ProfitLoss extends Component {
} }
} }
}) })
console.log(dataTable) // console.log(dataTable)
this.setState({ dataTable, loading: false, buttonError: true, editable: true }, () => { this.setState({ dataTable, loading: false, buttonError: true, editable: true }, () => {
}) })
} else { } else {
...@@ -422,8 +422,8 @@ export default class ProfitLoss extends Component { ...@@ -422,8 +422,8 @@ export default class ProfitLoss extends Component {
profit_loss: data, profit_loss: data,
status: type status: type
} }
console.log(this.state.dataTable); // console.log(this.state.dataTable);
console.log(JSON.stringify(body)); // console.log(JSON.stringify(body));
api.create('UPLOAD').uploadMasterBudget(body).then(response => { api.create('UPLOAD').uploadMasterBudget(body).then(response => {
// console.log(response); // console.log(response);
if (response.data) { if (response.data) {
...@@ -635,10 +635,10 @@ export default class ProfitLoss extends Component { ...@@ -635,10 +635,10 @@ export default class ProfitLoss extends Component {
} }
}) })
if (tableMeta.rowData[1] === 20092) { // if (tableMeta.rowData[1] === 20092) {
console.log(total); // console.log(total);
console.log(arrayJumlah); // console.log(arrayJumlah);
} // }
// if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === "" || dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === undefined || dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === null) { // if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === "" || dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === undefined || dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === null) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
// } // }
......
...@@ -9,6 +9,7 @@ import { type } from 'ramda'; ...@@ -9,6 +9,7 @@ import { type } from 'ramda';
import { PropagateLoader } from 'react-spinners'; import { PropagateLoader } from 'react-spinners';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import Constant from '../../library/Constant';
const LightTooltip = withStyles((theme) => ({ const LightTooltip = withStyles((theme) => ({
tooltip: { tooltip: {
...@@ -42,7 +43,8 @@ export default class BalanceSheetMR extends Component { ...@@ -42,7 +43,8 @@ export default class BalanceSheetMR extends Component {
super(props) super(props)
this.state = { this.state = {
dataTable: [], dataTable: [],
loading: true loading: true,
visibleBSMR: true
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -183,11 +185,12 @@ export default class BalanceSheetMR extends Component { ...@@ -183,11 +185,12 @@ export default class BalanceSheetMR extends Component {
isi.map((i, index) => { isi.map((i, index) => {
if (i.length > 0) { if (i.length > 0) {
payload.push({ payload.push({
orders: i[0] === undefined ? "" : String(i[0]).trim(),
item_report_id: i[1] === undefined ? "" : String(i[1]).trim(), item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(), item_report: i[2] === undefined ? "" : String(i[2]).trim(),
total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(), actual: i[3] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[3]).trim(),
january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(), mtd_vs_previous_month: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(), mtd_vs_mb: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
}) })
} }
}) })
...@@ -198,12 +201,120 @@ export default class BalanceSheetMR extends Component { ...@@ -198,12 +201,120 @@ export default class BalanceSheetMR extends Component {
balance_sheet: payload, balance_sheet: payload,
months: this.props.month.month_id months: this.props.month.month_id
} }
// console.log(body) console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] }) this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
} }
}); });
} }
checkUpload() {
api.create().checkUploadMonthlyReportBS(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleBSMR: false, loading: 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.rolling_outlook === null ? "" : item.rolling_outlook === "" ? "" : item.rolling_outlook,
item.master_budget === "" ? "" : item.master_budget,
item.rolling_budget === "" ? "" : item.rolling_budget,
item.actual === "" ? "" : item.actual,
item.actual_previous_month === null ? "" : item.actual_previous_month === "" ? "" : item.actual_previous_month,
// item.amount_act_vs_previous_month === "" ? "" : item.amount_act_vs_previous_month,
// item.percent_act_vs_previous_month === "" ? "" : item.percent_act_vs_previous_month,
// item.amount_act_vs_mb === "" ? "" : item.amount_act_vs_mb,
// item.percent_act_vs_mb === "" ? "9.0" : item.percent_act_vs_mb,
// item.amount_act_vs_rb === "" ? "1" : item.amount_act_vs_rb,
// item.percent_act_vs_rb === "" ? "" : item.percent_act_vs_rb,
0,
0,
0,
0,
0,
0,
item.mtd_vs_previous_month === "" ? "" : item.mtd_vs_previous_month,
item.mtd_vs_mb === "" ? "" : item.mtd_vs_mb,
item.mtd_vs_rb === "" ? "" : item.mtd_vs_rb === null ? 0 : item.mtd_vs_rb,
item.error
]
})
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.state.dataTable.map(item => {
if (item[20].length > 0) {
// console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
})
// console.log(this.state.buttonError)
})
}
}
})
}
uploadBalanceSheet(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
item_report: String(i[5]).trim(),
rolling_outlook: i[0] === 5 || i[0] === 6 ? String(Number(i[6].value).toFixed(1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6]).toFixed(1)),
master_budget: 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)),
rolling_budget: 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)),
actual: 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)),
actual_previous_month: 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)),
amount_act_vs_previous_month: 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)),
percent_act_vs_previous_month: 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)),
amount_act_vs_mb: 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)),
percent_act_vs_mb: 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)),
amount_act_vs_rb: 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)),
percent_act_vs_rb: 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)),
mtd_vs_previous_month: 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)),
mtd_vs_mb: 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)),
mtd_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[19].value).toFixed(1)) : i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19]).toFixed(1))
})
})
let body = {
"monthly_report_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"months": this.props.month.month_id,
"balance_sheet": data
}
// console.log(data);
api.create('UPLOAD').uploadMonthlyReportBS(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
backToMonthlyReport(type) { backToMonthlyReport(type) {
this.setState({ loading: true }) this.setState({ loading: true })
let data = [] let data = []
...@@ -282,10 +393,14 @@ export default class BalanceSheetMR extends Component { ...@@ -282,10 +393,14 @@ export default class BalanceSheetMR extends Component {
const handleValue = (data, type) => { const handleValue = (data, type) => {
let total = 0 let total = 0
dataTable2.map((item, index) => { dataTable2.map((item, index) => {
// if (item[2] !== null) {
if (data.rowData[1] === item[2]) { if (data.rowData[1] === item[2]) {
// console.log(item[data.columnIndex + type])
let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type]) let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type])
total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal
} }
// }
}) })
let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2]) let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1) dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
...@@ -1052,7 +1167,7 @@ export default class BalanceSheetMR extends Component { ...@@ -1052,7 +1167,7 @@ export default class BalanceSheetMR extends Component {
<Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
</div> </div>
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ paddingTop: 10 }}> {this.state.visibleBSMR? <Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
</div> </div>
...@@ -1120,7 +1235,7 @@ export default class BalanceSheetMR extends Component { ...@@ -1120,7 +1235,7 @@ export default class BalanceSheetMR extends Component {
{!this.state.loading && ( {!this.state.loading && (
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={this.state.dataTable} data={dataTable2}
columns={columns} columns={columns}
options={options} options={options}
/> />
...@@ -1224,7 +1339,123 @@ export default class BalanceSheetMR extends Component { ...@@ -1224,7 +1339,123 @@ export default class BalanceSheetMR extends Component {
{/* : null {/* : null
} */} } */}
</div> </div>
</Paper> :
<Paper style={{ paddingTop: 10 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
</div>
<div style={{ padding: 20 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
)}
</div>
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button
type="button"
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false })
// this.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
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: this.state.saveDraft !== true ? 'pointer' : 'default',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() =>
this.state.saveDraft === true ?
null :
this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => {
this.uploadBalanceSheet('draft')
})
}
>
<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 as Draft</Typography>
</div>
</button>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
:
this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => {
this.uploadBalanceSheet('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 & Complete</Typography>
</div>
</button>
</div>
</div>
</div>
</Paper> </Paper>
}
</div> </div>
{this.state.visibleUpload && ( {this.state.visibleUpload && (
<div className="test app-popup-show"> <div className="test app-popup-show">
......
...@@ -55,12 +55,46 @@ export default class ProfitLossMR extends Component { ...@@ -55,12 +55,46 @@ export default class ProfitLossMR extends Component {
super(props) super(props)
this.state = { this.state = {
dataTable: [], dataTable: [],
loading: true loading: true,
valueThreshold: 0
} }
} }
componentDidMount() { componentDidMount() {
// this.getItemHierarki()
this.getSettingControl()
}
getSettingControl() {
let body = {
group: 'THRESHOLD_VARIANCE',
company_id: this.props.company.company_id,
type: 'PNL'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
this.setState({
valueThreshold: response.data.data[0] ? response.data.data[0].value : null
}, () => {
this.getItemHierarki() this.getItemHierarki()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
} }
getItemHierarki() { getItemHierarki() {
...@@ -104,7 +138,7 @@ export default class ProfitLossMR extends Component { ...@@ -104,7 +138,7 @@ export default class ProfitLossMR extends Component {
item.profit_loss.mtd_vs_previous_month === null ? "0.0" : item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month, item.profit_loss.mtd_vs_previous_month === null ? "0.0" : item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month,
item.profit_loss.mtd_vs_mb === null ? "0.0" : item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb, item.profit_loss.mtd_vs_mb === null ? "0.0" : item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb,
item.profit_loss.mtd_vs_rb === null ? "0.0" : item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb, item.profit_loss.mtd_vs_rb === null ? "0.0" : item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb,
item.order item.order,
]) ])
} }
if (item.children !== null) { if (item.children !== null) {
...@@ -286,12 +320,12 @@ export default class ProfitLossMR extends Component { ...@@ -286,12 +320,12 @@ export default class ProfitLossMR extends Component {
this.setState({ visibleUpload: false, visibleProfitLoss: false, loading: true }) this.setState({ visibleUpload: false, visibleProfitLoss: false, loading: true })
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
return [ return [
item.item_report_id,
item.item_report,
item.type_report_id, item.type_report_id,
item.item_report_id,
item.parent,
item.formula, item.formula,
item.level, item.level,
item.parent, item.item_report,
item.notes, item.notes,
item.rolling_outlook, item.rolling_outlook,
item.master_budget, item.master_budget,
...@@ -299,15 +333,22 @@ export default class ProfitLossMR extends Component { ...@@ -299,15 +333,22 @@ export default class ProfitLossMR extends Component {
item.actual, item.actual,
item.ytd_actual, item.ytd_actual,
item.actual_previous_month, item.actual_previous_month,
item.amount_act_vs_previous_month,
item.percent_act_vs_previous_month,
item.amount_act_vs_mb,
item.percent_act_vs_mb,
item.amount_act_vs_rb,
item.percent_act_vs_rb,
item.mtd_vs_previous_month,
item.mtd_vs_mb, item.mtd_vs_mb,
item.mtd_vs_rb, item.mtd_vs_rb,
item.orders, item.order,
item.error item.error
] ]
}) })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[16].length > 0) { if (item[23].length > 0) {
// console.log('masuk') // console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true }) this.setState({ buttonError: true, errorPreview: true, editable: true })
} }
...@@ -324,35 +365,35 @@ export default class ProfitLossMR extends Component { ...@@ -324,35 +365,35 @@ export default class ProfitLossMR 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],
notes: String(i[6]), notes: i[6],
total_actual_before: String(Number(i[7]).toFixed(1)), rolling_outlook: String(Number(i[7]).toFixed(1)),
january: String(Number(i[8]).toFixed(1)), master_budget: String(Number(i[8]).toFixed(1)),
february: String(Number(i[9]).toFixed(1)), rolling_budget: String(Number(i[9]).toFixed(1)),
march: String(Number(i[10]).toFixed(1)), actual: String(Number(i[10]).toFixed(1)),
april: String(Number(i[11]).toFixed(1)), ytd_actual: String(Number(i[11]).toFixed(1)),
may: String(Number(i[12]).toFixed(1)), actual_previous_month: String(Number(i[12]).toFixed(1)),
june: String(Number(i[13]).toFixed(1)), amount_act_vs_previous_month: String(Number(i[13]).toFixed(1)),
july: String(Number(i[14]).toFixed(1)), percent_act_vs_previous_month: String(Number(i[14]).toFixed(1)),
august: String(Number(i[15]).toFixed(1)), amount_act_vs_mb: String(Number(i[15]).toFixed(1)),
september: String(Number(i[16]).toFixed(1)), percent_act_vs_mb: String(Number(i[16]).toFixed(1)),
october: String(Number(i[17]).toFixed(1)), amount_act_vs_rb: String(Number(i[17]).toFixed(1)),
november: String(Number(i[18]).toFixed(1)), percent_act_vs_rb: String(Number(i[18]).toFixed(1)),
december: String(Number(i[19]).toFixed(1)), mtd_vs_previous_month: String(Number(i[19]).toFixed(1)),
total_current_year: String(Number(i[20]).toFixed(1)), mtd_vs_mb: String(Number(i[20]).toFixed(1)),
total_next_year: String(Number(i[21]).toFixed(1)), mtd_vs_rb: String(Number(i[21]).toFixed(1)),
total_more_year: String(Number(i[22]).toFixed(1)),
}) })
}) })
let body = { let body = {
submission_id: this.props.submissionID, // submission_id: this.props.submissionID,
company_id: this.props.company.company_id, company_id: this.props.company.company_id,
periode: this.props.periode, periode: this.props.periode,
report_id: this.props.report_id, report_id: this.props.report_id,
months: this.props.month.month_id,
profit_loss: data, profit_loss: data,
status: type status: type
} }
// console.log(data); // console.log(data);
api.create('UPLOAD').uploadMasterBudget(body).then(response => { api.create('UPLOAD').uploadMonthlyReportPL(body).then(response => {
// console.log(response); // console.log(response);
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -764,7 +805,7 @@ export default class ProfitLossMR extends Component { ...@@ -764,7 +805,7 @@ export default class ProfitLossMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={tableMeta.rowData[8]} value={Number(tableMeta.rowData[8]).toFixed(1)}
/> />
} }
/> />
...@@ -1337,6 +1378,26 @@ export default class ProfitLossMR extends Component { ...@@ -1337,6 +1378,26 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null null
: :
Number(tableMeta.rowData[19]).toFixed(1) < Number(this.state.valueThreshold).toFixed(1) ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[19]}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
value={Number(tableMeta.rowData[19]).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1372,6 +1433,26 @@ export default class ProfitLossMR extends Component { ...@@ -1372,6 +1433,26 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null null
: :
Number(tableMeta.rowData[20]).toFixed(1) < Number(this.state.valueThreshold).toFixed(1) ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[20]}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
value={Number(tableMeta.rowData[20]).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
...@@ -1407,6 +1488,26 @@ export default class ProfitLossMR extends Component { ...@@ -1407,6 +1488,26 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null null
: :
Number(tableMeta.rowData[21]).toFixed(1) < Number(this.state.valueThreshold).toFixed(1) ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[21]}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
value={Number(tableMeta.rowData[21]).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 2 ? tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
......
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