Commit 137d6338 authored by Riri Novita's avatar Riri Novita

push

parent eb45c224
......@@ -289,6 +289,8 @@ const create = (type = "") => {
const validateSubmitReportBS = (body) => api.post('transaction/monthly_report_bs/validate_save', body)
const validateSubmitReportMR = (body) => api.post('transaction/monthly_report/validate_save', body)
const validateSubmitReportMRTP = (body) => api.post('transaction/monthly_report_tp/validate_save', body)
const validateSubmitReportOI = (body) => api.post('transaction/monthly_report_oi/validate_save', body)
// MonthlyPL
const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body)
......@@ -522,7 +524,8 @@ const create = (type = "") => {
validateSubmitReportMR,
validateSubmitReportMRTP,
validateSubmitReportBS,
validateSubmitReportPL
validateSubmitReportPL,
validateSubmitReportOI
}
}
......
......@@ -21,6 +21,15 @@ const LightTooltip = withStyles((theme) => ({
},
}))(Tooltip);
const LightTooltipError = withStyles((theme) => ({
tooltip: {
backgroundColor: theme.palette.common.white,
color: 'rgba(255, 0, 0, 0.87)',
boxShadow: theme.shadows[1],
fontSize: 11,
},
}))(Tooltip);
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());
......@@ -47,8 +56,19 @@ export default class OperatingIndicatorMR extends Component {
loading: true,
visibleOI: true,
minValue: 0,
maxValue: 0
maxValue: 0,
updateBy: '-',
notesUpdate: '-',
templateNull: true
}
this.fileHandler = this.fileHandler.bind(this);
}
componentDidMount() {
// this.getItemHierarki()
this.getSettingControl()
this.getLatestUpdate()
// console.log(this.props.permission.create);
}
getLatestUpdate() {
......@@ -57,6 +77,7 @@ export default class OperatingIndicatorMR extends Component {
"report_id": this.props.data.report_id,
"company_id": this.props.data.company.company_id,
"periode": this.props.data.periode,
"months": this.props.data.report_id === 22 ? 1 : 23 ? 2 : 24 ? 3 : 25 ? 4 : 27 ? 5 : 28 ? 6 : 29 ? 7 : 31 ? 8 : 32 ? 9 : 33 ? 10 : 35 ? 11 : 36 ? 12 : null
}
api.create().getLastestUpdateMROI(payload).then(response => {
// console.log(response.data)
......@@ -65,16 +86,20 @@ export default class OperatingIndicatorMR extends Component {
this.setState({
updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update
})
}
} 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);
}
})
}
componentDidMount() {
// this.getItemHierarki()
this.getSettingControl()
this.getLatestUpdate()
console.log(this.props.permission.create);
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
getSettingControl() {
......@@ -89,8 +114,8 @@ export default class OperatingIndicatorMR extends Component {
if (response.data) {
if (response.data.status === 'success') {
this.setState({
minValue: response.data.data[0] ? response.data.data[0].min_value : -5,
maxValue: response.data.data[0] ? response.data.data[0].max_value : 5,
minValue: response.data.data[0] ? Number(response.data.data[0].min_value) : -5,
maxValue: response.data.data[0] ? Number(response.data.data[0].max_value) : 5,
}, () => {
this.getItemHierarki()
})
......@@ -137,15 +162,15 @@ export default class OperatingIndicatorMR extends Component {
item.description,
item.uom === "" ? null : item.uom,
item.monthly_report.rolling_outlook === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_outlook,
item.monthly_report.master_budget === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.master_budget,
item.monthly_report.master_budget === null ? "10.0" : item.monthly_report.rolling_outlook === "" ? "10.0" : item.monthly_report.master_budget,
item.monthly_report.rolling_budget === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_budget,
item.monthly_report.actual === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.actual,
item.monthly_report.amount_act_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.amount_act_vs_mb,
item.monthly_report.percent_act_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.percent_act_vs_mb,
item.monthly_report.amount_act_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.amount_act_vs_rb,
item.monthly_report.percent_act_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.percent_act_vs_rb,
item.monthly_report.mtd_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.mtd_vs_mb,
item.monthly_report.mtd_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.mtd_vs_rb,
item.monthly_report.mtd_vs_mb === null ? "" : item.monthly_report.mtd_vs_mb,
item.monthly_report.mtd_vs_rb === null ? "" : item.monthly_report.mtd_vs_rb,
item.order,
])
}
......@@ -167,15 +192,15 @@ export default class OperatingIndicatorMR extends Component {
item.description,
item.uom === "" ? null : item.uom,
item.monthly_report.rolling_outlook === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_outlook,
item.monthly_report.master_budget === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.master_budget,
item.monthly_report.master_budget === null ? "10.0" : item.monthly_report.rolling_outlook === "" ? "10.0" : item.monthly_report.master_budget,
item.monthly_report.rolling_budget === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_budget,
item.monthly_report.actual === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.actual,
item.monthly_report.amount_act_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.amount_act_vs_mb,
item.monthly_report.percent_act_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.percent_act_vs_mb,
item.monthly_report.amount_act_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.amount_act_vs_rb,
item.monthly_report.percent_act_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.percent_act_vs_rb,
item.monthly_report.mtd_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.mtd_vs_mb,
item.monthly_report.mtd_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.mtd_vs_rb,
item.monthly_report.mtd_vs_mb === null ? "" : item.monthly_report.mtd_vs_mb,
item.monthly_report.mtd_vs_rb === null ? "" : item.monthly_report.mtd_vs_rb,
item.order,
])
if (item.children !== null) {
......@@ -187,7 +212,7 @@ export default class OperatingIndicatorMR extends Component {
}
})
console.log(dataTable);
this.setState({ dataTable, loading: false })
this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
}
})
}
......@@ -278,8 +303,8 @@ export default class OperatingIndicatorMR extends Component {
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
uom: i[3] === undefined ? "" : String(i[3]).trim(),
actual: 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(),
mtd_vs_rb: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
mtd_vs_mb: i[5] === undefined ? "" : String(i[5]).trim(),
mtd_vs_rb: i[6] === undefined ? "" : String(i[6]).trim(),
})
}
})
......@@ -321,10 +346,14 @@ export default class OperatingIndicatorMR extends Component {
item.master_budget,
item.rolling_budget,
item.actual,
item.amount_act_vs_mb,
item.percent_act_vs_mb,
item.amount_act_vs_rb,
item.percent_act_vs_rb,
0,
0,
0,
0,
// item.amount_act_vs_mb,
// item.percent_act_vs_mb,
// item.amount_act_vs_rb,
// item.percent_act_vs_rb,
item.mtd_vs_mb,
item.mtd_vs_rb,
item.order,
......@@ -339,7 +368,7 @@ export default class OperatingIndicatorMR extends Component {
uploadOI(type) {
let data = []
console.log(this.state.dataTable)
// console.log(this.state.dataTable)
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
......@@ -352,8 +381,8 @@ export default class OperatingIndicatorMR extends Component {
percent_act_vs_mb: String(Number(i[12]).toFixed(1)),
amount_act_vs_rb: String(Number(i[13]).toFixed(1)),
percent_act_vs_rb: String(Number(i[14]).toFixed(1)),
mtd_vs_mb: String(Number(i[15]).toFixed(1)),
mtd_vs_rb: String(Number(i[16]).toFixed(1)),
mtd_vs_mb: String(i[15]),
mtd_vs_rb: String(i[16]),
})
})
let body = {
......
......@@ -342,7 +342,7 @@ export default class ProfitLossMR extends Component {
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
// console.log(resp)
console.log(resp)
if (err) {
console.log(err);
}
......@@ -359,9 +359,9 @@ export default class ProfitLossMR extends Component {
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
notes: i[3] === undefined ? "" : String(i[3]).trim(),
actual: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
mtd_vs_previous_month: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
mtd_vs_mb: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
mtd_vs_rb: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
mtd_vs_previous_month: i[5] === undefined ? "" : String(i[5]).trim(),
mtd_vs_mb: i[6] === undefined ? "" : String(i[6]).trim(),
mtd_vs_rb: i[7] === undefined ? "" : String(i[7]).trim(),
})
}
})
......@@ -393,7 +393,7 @@ export default class ProfitLossMR extends Component {
item.formula,
item.level,
item.item_report,
item.notes === null ? "" : item.notes === "" ? "" : item.notes,
item.notes,
item.rolling_outlook === null ? "" : item.rolling_outlook === "" ? "" : item.rolling_outlook,
item.master_budget === "" ? "" : item.master_budget,
item.rolling_budget === "" ? "" : item.rolling_budget,
......@@ -412,9 +412,9 @@ export default class ProfitLossMR extends Component {
// item.percent_act_vs_mb,
// item.amount_act_vs_rb,
// item.percent_act_vs_rb,
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 ? '' : item.mtd_vs_rb,
item.mtd_vs_previous_month ,
item.mtd_vs_mb ,
item.mtd_vs_rb ,
item.orders,
item.error
]
......@@ -533,13 +533,6 @@ export default class ProfitLossMR extends Component {
err = true
}
})
// if (err === true) {
// console.log('error');
// this.setState({ loading: false, buttonError: true, saveDraft: false })
// } else {
// console.log('g error');
// this.setState({ loading: false, buttonError: false, saveDraft: false })
// }
// console.log(JSON.stringify(data))
let payload = {
......@@ -551,7 +544,7 @@ export default class ProfitLossMR extends Component {
"months": this.props.month.month_id,
"profit_loss": data
}
console.log(JSON.stringify(payload));
// console.log(JSON.stringify(payload));
api.create().validateSubmitReportPL(payload).then((response) => {
console.log(response)
if (response.data) {
......@@ -608,8 +601,8 @@ export default class ProfitLossMR extends Component {
// }
const handleText = (value, tableMeta, type) => {
dataTable2[tableMeta.rowIndex][type] = value
// let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = value
// dataTable2[tableMeta.rowIndex][type] = value
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = value
// console.log(dataTable2[tableMeta.rowIndex]);
}
const handleChange = (value, tableMeta, type) => {
......@@ -846,11 +839,12 @@ export default class ProfitLossMR extends Component {
color: "#5198ea"
}}}
placeholder=""
value={tableMeta.rowData[6]}
// disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
defaultValue={value}
defaultValue={tableMeta.rowData[6]}
onBlur={(event) => {
// updateValue(event.target.value)
handleText(event.target.value, tableMeta, 6)
handleText(event.target.value, tableMeta, 0)
// console.log(dataTable2)
}}
/>
......@@ -1570,16 +1564,17 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 ? null : tableMeta.rowData[0] === 1 ? null :
<FormControlLabel
style={{ margin: 0 }}
// value={value}
// value={tableMeta.rowData[19]}
control={
tableMeta.rowData[19] === "" && (Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue) ?
<LightTooltipError title={"MTD Explanation vs Prev. Month is Reqiured"} arrow>
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
// value={tableMeta.rowData[19]}
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
......@@ -1589,7 +1584,7 @@ export default class ProfitLossMR extends Component {
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 19)
handleText(event.target.value, tableMeta, 0)
}}
/>
</LightTooltipError>
......@@ -1599,16 +1594,17 @@ export default class ProfitLossMR extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? false : true}
// disabled={Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? false : true}
// value={tableMeta.rowData[19]}
defaultValue={tableMeta.rowData[19]}
inputProps={{
style: {
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : 'black',
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'right'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 19)
handleText(event.target.value, tableMeta, 0)
}}
/>
}
......@@ -1632,6 +1628,7 @@ export default class ProfitLossMR extends Component {
type="text"
placeholder=""
disabled={false}
// value={tableMeta.rowData[20]}
defaultValue={tableMeta.rowData[20]}
inputProps={{
style: {
......@@ -1641,7 +1638,7 @@ export default class ProfitLossMR extends Component {
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 20)
handleText(event.target.value, tableMeta, 1)
}}
/>
</LightTooltipError> :
......@@ -1650,16 +1647,17 @@ export default class ProfitLossMR extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? false : true}
// disabled={Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? false : true}
// value={tableMeta.rowData[20]}
defaultValue={tableMeta.rowData[20]}
inputProps={{
style: {
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : 'black',
color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'right'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 20)
handleText(event.target.value, tableMeta, 1)
}}
/>
}
......@@ -1683,6 +1681,7 @@ export default class ProfitLossMR extends Component {
type="text"
placeholder=""
disabled={false}
// value={tableMeta.rowData[21]}
defaultValue={tableMeta.rowData[21]}
inputProps={{
style: {
......@@ -1692,7 +1691,7 @@ export default class ProfitLossMR extends Component {
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 21)
handleText(event.target.value, tableMeta, 2)
}}
/>
</LightTooltipError> :
......@@ -1701,16 +1700,17 @@ export default class ProfitLossMR extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={Number(tableMeta.rowData[18]) < this.state.minValue || Number(tableMeta.rowData[18]) > this.state.maxValue ? false : true}
// disabled={Number(tableMeta.rowData[18]) < this.state.minValue || Number(tableMeta.rowData[18]) > this.state.maxValue ? false : true}
// value={tableMeta.rowData[21]}
defaultValue={tableMeta.rowData[21]}
inputProps={{
style: {
color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? "#5198ea" : 'black',
color: Number(tableMeta.rowData[16]) < this.state.minValue || Number(tableMeta.rowData[16]) > this.state.maxValue ? "#5198ea" : '#5198ea',
textAlign: 'right'
}
}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 21)
handleText(event.target.value, tableMeta, 2)
}}
/>
}
......
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