Commit bc6454b9 authored by Riri Novita's avatar Riri Novita

bikin pusing

parent 4db09279
...@@ -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,7 +178,8 @@ export default class ProfitLossMR extends Component { ...@@ -174,7 +178,8 @@ 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 => {
...@@ -187,6 +192,8 @@ export default class ProfitLossMR extends Component { ...@@ -187,6 +192,8 @@ export default class ProfitLossMR extends Component {
let res = response.data.data let res = response.data.data
const handlePushChild = (item) => { const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) 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) { 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 err = true
} }
...@@ -196,6 +203,7 @@ export default class ProfitLossMR extends Component { ...@@ -196,6 +203,7 @@ export default class ProfitLossMR extends Component {
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) { 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 err = true
} }
}
if (indexIDzz === -1) { if (indexIDzz === -1) {
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
...@@ -233,6 +241,8 @@ export default class ProfitLossMR extends Component { ...@@ -233,6 +241,8 @@ export default class ProfitLossMR extends Component {
} }
} }
res.map((item, index) => { 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) { 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 err = true
} }
...@@ -242,6 +252,7 @@ export default class ProfitLossMR extends Component { ...@@ -242,6 +252,7 @@ export default class ProfitLossMR extends Component {
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) { 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 err = true
} }
}
dataTable.push([ dataTable.push([
item.type_report_id, item.type_report_id,
item.id, item.id,
...@@ -540,6 +551,20 @@ export default class ProfitLossMR extends Component { ...@@ -540,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],
...@@ -560,20 +585,7 @@ export default class ProfitLossMR extends Component { ...@@ -560,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 = {
...@@ -587,10 +599,12 @@ export default class ProfitLossMR extends Component { ...@@ -587,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 })
...@@ -617,29 +631,6 @@ export default class ProfitLossMR extends Component { ...@@ -617,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
...@@ -1849,7 +1840,7 @@ export default class ProfitLossMR extends Component { ...@@ -1849,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%' }}>
...@@ -1981,7 +1972,7 @@ export default class ProfitLossMR extends Component { ...@@ -1981,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);
...@@ -2023,7 +2014,7 @@ export default class ProfitLossMR extends Component { ...@@ -2023,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