Commit 74c9bbee authored by Riri Novita's avatar Riri Novita

Merge branch 'riri' into 'master'

pusing

See merge request !844
parents 199e4c90 66de34a7
...@@ -61,20 +61,20 @@ const styleNotesEmpty = { ...@@ -61,20 +61,20 @@ const styleNotesEmpty = {
zIndex: 99, zIndex: 99,
left: 0 left: 0
} }
const StyledButton = withStyles({ // const StyledButton = withStyles({
root: { // root: {
background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)', // background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
borderRadius: 3, // borderRadius: 3,
border: 0, // border: 0,
color: 'white', // color: 'white',
height: 48, // height: 48,
padding: '0 30px', // padding: '0 30px',
boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)', // boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
}, // },
label: { // label: {
textTransform: 'capitalize', // textTransform: 'capitalize',
}, // },
})(Input); // })(Input);
export default class ProfitLossMR extends Component { export default class ProfitLossMR extends Component {
constructor(props) { constructor(props) {
...@@ -88,7 +88,11 @@ export default class ProfitLossMR extends Component { ...@@ -88,7 +88,11 @@ export default class ProfitLossMR extends Component {
updateBy: '-', updateBy: '-',
notesUpdate: '-', notesUpdate: '-',
bebas: false, bebas: false,
judulColumn: null judulColumn: null,
handleTekTekTek: 0,
saveDraft: true,
buttonError: true
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -174,17 +178,81 @@ export default class ProfitLossMR extends Component { ...@@ -174,17 +178,81 @@ export default class ProfitLossMR extends Component {
"periode": this.props.periode, "periode": this.props.periode,
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
"monthly_report_id": this.props.monthlyReportId, "monthly_report_id": this.props.monthlyReportId,
"months": this.props.month.month_id "months": this.props.month.month_id,
"get_for": "edit"
} }
console.log(payload); console.log(payload);
api.create().getHierarkiMontlyReportPL(payload).then(response => { api.create().getHierarkiMontlyReportPL(payload).then(response => {
console.log(response); console.log(response);
let dataTable = [] let dataTable = []
let err = false
if (response.data) { if (response.data) {
let res = response.data.data if (response.data.status === 'success') {
const handlePushChild = (item) => { let res = response.data.data
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) const handlePushChild = (item) => {
if (indexIDzz === -1) { let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (item.type_report_id === 3) {
if (item.profit_loss.mtd_vs_previous_month == "" && Number(item.profit_loss.percent_act_vs_previous_month) < this.state.minValue || Number(item.profit_loss.percent_act_vs_previous_month) > this.state.maxValue) {
err = true
}
if (item.profit_loss.mtd_vs_mb == "" && Number(item.profit_loss.percent_act_vs_mb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_mb) > this.state.maxValue) {
err = true
}
if (item.profit_loss.mtd_vs_rb == "" && Number(item.profit_loss.percent_act_vs_rb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_rb) > this.state.maxValue) {
err = true
}
}
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.rolling_outlook === null ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook === "0" ? "0.0" : item.profit_loss.rolling_outlook,
item.profit_loss.master_budget === null ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget,
item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual,
0,
item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
item.profit_loss.percent_act_vs_mb === null ? "0.0" : item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_act_vs_mb,
item.profit_loss.amount_act_vs_rb === null ? "0.0" : item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb,
item.profit_loss.percent_act_vs_rb === null ? "0.0" : item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_act_vs_rb,
item.profit_loss.mtd_vs_previous_month === null ? "" : item.profit_loss.mtd_vs_previous_month,
item.profit_loss.mtd_vs_mb === null ? "" : item.profit_loss.mtd_vs_mb,
item.profit_loss.mtd_vs_rb === null ? "" : item.profit_loss.mtd_vs_rb,
item.order,
item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
])
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
res.map((item, index) => {
if (item.type_report_id === 3) {
if (item.profit_loss.mtd_vs_previous_month == "" && Number(item.profit_loss.percent_act_vs_previous_month) < this.state.minValue || Number(item.profit_loss.percent_act_vs_previous_month) > this.state.maxValue) {
err = true
}
if (item.profit_loss.mtd_vs_mb == "" && Number(item.profit_loss.percent_act_vs_mb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_mb) > this.state.maxValue) {
err = true
}
if (item.profit_loss.mtd_vs_rb == "" && Number(item.profit_loss.percent_act_vs_rb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_rb) > this.state.maxValue) {
err = true
}
}
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -193,7 +261,7 @@ export default class ProfitLossMR extends Component { ...@@ -193,7 +261,7 @@ export default class ProfitLossMR extends Component {
item.level, item.level,
item.description, item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes, item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.rolling_outlook === null ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook === "0" ? "0.0" : item.profit_loss.rolling_outlook, item.profit_loss.rolling_outlook === null ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook,
item.profit_loss.master_budget === null ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget, item.profit_loss.master_budget === null ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget,
item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget, item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual, item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual,
...@@ -211,71 +279,32 @@ export default class ProfitLossMR extends Component { ...@@ -211,71 +279,32 @@ export default class ProfitLossMR extends Component {
item.order, item.order,
item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual, item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
]) ])
} 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) => { handlePushChild(items)
handlePushChild(items) })
}) }
} }
})
if (err === true) {
this.setState({ bebas: true })
} }
} this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
res.map((item, index) => { } else {
dataTable.push([ this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
item.type_report_id, if (response.data.message.includes("Someone Logged In")) {
item.id, setTimeout(() => {
item.parent, localStorage.removeItem(Constant.TOKEN)
item.formula, window.location.reload();
item.level, }, 1000);
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.rolling_outlook === null ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook,
item.profit_loss.master_budget === null ? "0.0" : item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget,
item.profit_loss.rolling_budget === null ? "0.0" : item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
item.profit_loss.actual === null ? "0.0" : item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual,
0,
item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
item.profit_loss.amount_act_vs_previous_month === null ? "0.0" : item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
item.profit_loss.percent_act_vs_previous_month === null ? "0.0" : item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
item.profit_loss.amount_act_vs_mb === null ? "0.0" : item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
item.profit_loss.percent_act_vs_mb === null ? "0.0" : item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_act_vs_mb,
item.profit_loss.amount_act_vs_rb === null ? "0.0" : item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb,
item.profit_loss.percent_act_vs_rb === null ? "0.0" : item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_act_vs_rb,
item.profit_loss.mtd_vs_previous_month === null ? "" : item.profit_loss.mtd_vs_previous_month,
item.profit_loss.mtd_vs_mb === null ? "" : item.profit_loss.mtd_vs_mb,
item.profit_loss.mtd_vs_rb === null ? "" : item.profit_loss.mtd_vs_rb,
item.order,
item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
} }
} })
})
this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true, bebas: true })
}
console.log(dataTable);
let err = false
dataTable.map((item, index) => {
if (item[19] == "" && Number(item[14]) < this.state.minValue || Number(item[14]) > this.state.maxValue) {
err = true
}
if (item[20] == "" && Number(item[16]) < this.state.minValue || Number(item[16]) > this.state.maxValue) {
err = true
}
if (item[21] == "" && Number(item[18]) < this.state.minValue || Number(item[18]) > this.state.maxValue) {
err = true
} }
}) } else {
if (err === true) { this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
this.setState({ bebas: true })
} }
console.log(dataTable);
}) })
} }
...@@ -522,6 +551,20 @@ export default class ProfitLossMR extends Component { ...@@ -522,6 +551,20 @@ export default class ProfitLossMR extends Component {
let data = [] let data = []
let err = false let err = false
this.state.dataTable.map((i, index) => { this.state.dataTable.map((i, index) => {
if(i[0] === 3) {
// console.log(i);
if ( i[19] === "" && (Number(i[14]) < this.state.minValue || Number(i[14]) > this.state.maxValue)) {
console.log('msk 1');
// console.log(i);
err = true
} else if ( i[20] === "" && (Number(i[16]) < this.state.minValue || Number(i[16]) > this.state.maxValue)) {
console.log('msk 2');
err = true
} else if ( i[21] === "" && (Number(i[18]) < this.state.minValue || Number(i[18]) > this.state.maxValue)) {
console.log('msk 3');
err = true
}
}
data.push({ data.push({
"item_report_id": i[1], "item_report_id": i[1],
"notes": i[6], "notes": i[6],
...@@ -542,20 +585,7 @@ export default class ProfitLossMR extends Component { ...@@ -542,20 +585,7 @@ export default class ProfitLossMR extends Component {
"mtd_vs_rb": i[21] "mtd_vs_rb": i[21]
}) })
}) })
console.log(data);
data.map(i => {
if (i.mtd_vs_previous_month === "" && (Number(i.percent_act_vs_previous_month) < this.state.minValue || Number(i.percent_act_vs_previous_month) > this.state.maxValue)) {
// console.log('msk 1');
// console.log(i);
err = true
} else if (i.mtd_vs_mb === "" && (Number(i.percent_act_vs_mb) < this.state.minValue || Number(i.percent_act_vs_mb) > this.state.maxValue)) {
// console.log('msk 2');
err = true
} else if (i.mtd_vs_rb === "" && (Number(i.percent_act_vs_rb) < this.state.minValue || Number(i.percent_act_vs_rb) > this.state.maxValue)) {
// console.log('msk 3');
err = true
}
})
// console.log(JSON.stringify(data)) // console.log(JSON.stringify(data))
let payload = { let payload = {
...@@ -569,10 +599,12 @@ export default class ProfitLossMR extends Component { ...@@ -569,10 +599,12 @@ export default class ProfitLossMR extends Component {
} }
// console.log(JSON.stringify(payload)); // console.log(JSON.stringify(payload));
api.create().validateSubmitReportPL(payload).then((response) => { api.create().validateSubmitReportPL(payload).then((response) => {
console.log(response) console.log(response.data.data.result)
console.log(err);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
if (response.data.data.result && err === false) { if (response.data.data.result && err === false) {
this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false }) this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
} else { } else {
this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false }) this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
...@@ -599,29 +631,6 @@ export default class ProfitLossMR extends Component { ...@@ -599,29 +631,6 @@ export default class ProfitLossMR extends Component {
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
// const handleCalculate = () => {
// let error = false
// let messageError = ""
// dataTable2.map((item, index) => {
// if (item[19] == "" && Number(item[14]) <= this.state.minValue || Number(item[14]) >= this.state.maxValue) {
// error = true
// messageError = "MTD Explanation vs Prev. Month is Reqiured"
// }
// if (item[20] == "" && Number(item[16]) <= this.state.minValue || Number(item[16]) >= this.state.maxValue) {
// error = true
// messageError = "MTD Explanation vs MB is Reqiured"
// }
// if (item[21] == "" && Number(item[18]) <= this.state.minValue || Number(item[18]) >= this.state.maxValue) {
// error = true
// messageError = "MTD Explanation vs RB is Reqiured"
// }
// })
// if (error === true) {
// this.setState({ alert: true, messageAlert: messageError, tipeAlert: 'error', loading: false, bebas: true })
// }
// }
const handleText = (value, tableMeta, type) => { const handleText = (value, tableMeta, type) => {
// dataTable2[tableMeta.rowIndex][type] = value // dataTable2[tableMeta.rowIndex][type] = value
...@@ -1831,7 +1840,7 @@ export default class ProfitLossMR extends Component { ...@@ -1831,7 +1840,7 @@ export default class ProfitLossMR extends Component {
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div> <div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.month.month_value} {this.props.periode} (rev.{this.props.revision})</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase} {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
...@@ -1963,7 +1972,7 @@ export default class ProfitLossMR extends Component { ...@@ -1963,7 +1972,7 @@ export default class ProfitLossMR extends Component {
marginRight: 20 marginRight: 20
}} }}
onClick={() => { onClick={() => {
this.setState({ loading: true, bebas: false }, () => { this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.handleValidate() this.handleValidate()
}, 100); }, 100);
...@@ -2005,7 +2014,7 @@ export default class ProfitLossMR extends Component { ...@@ -2005,7 +2014,7 @@ export default class ProfitLossMR extends Component {
</button> </button>
<button <button
type="button" type="button"
disabled={this.state.buttonError} // disabled={this.state.butto nError}
onClick={() => onClick={() =>
this.state.buttonError ? this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment