Commit 9d48658f authored by Riri Novita's avatar Riri Novita

Issue save pl

parent e70bba9a
......@@ -339,12 +339,12 @@ export default class ProfitLoss extends Component {
}
console.log(payload);
this.setState({ loading: false })
// if (type == 'submitted') {
// this.props.saveToMasterBudget(payload, 'PL')
// } else {
// this.props.saveToMasterBudget(payload, 'DraftPL')
// }
// this.props.onClickClose()
if (type == 'submitted') {
this.props.saveToMasterBudget(payload, 'PL')
} else {
this.props.saveToMasterBudget(payload, 'DraftPL')
}
this.props.onClickClose()
}
downloadTemplate = async () => {
......@@ -435,22 +435,22 @@ export default class ProfitLoss extends Component {
item.level,
item.item_report,
item.notes,
Number(item.total_actual_before),
Number(item.january),
Number(item.february),
Number(item.march),
Number(item.april),
Number(item.may),
Number(item.june),
Number(item.july),
Number(item.august),
Number(item.september),
Number(item.october),
Number(item.november),
Number(item.december),
Number(item.total_current_year),
Number(item.total_next_year),
Number(item.total_more_year),
item.total_actual_before == 0 ? "0.0" : item.total_actual_before,
item.january == 0 ? "0.0" : item.january,
item.february == 0 ? "0.0" : item.february,
item.march == 0 ? "0.0" : item.march,
item.april == 0 ? "0.0" : item.april,
item.may == 0 ? "0.0" : item.may,
item.june == 0 ? "0.0" : item.june,
item.july == 0 ? "0.0" : item.july,
item.august == 0 ? "0.0" : item.august,
item.september == 0 ? "0.0" : item.september,
item.october == 0 ? "0.0" : item.october,
item.november == 0 ? "0.0" : item.november,
item.december == 0 ? "0.0" : item.december,
item.total_current_year == 0 ? "0.0" : item.total_current_year,
item.total_next_year == 0 ? "0.0" : item.total_next_year,
item.total_more_year == 0 ? "0.0" : item.total_more_year,
item.orders,
item.error
]
......@@ -574,39 +574,39 @@ export default class ProfitLoss extends Component {
console.log(body);
// console.log(this.state.dataTable);
// console.log(JSON.stringify(body));
// api.create('UPLOAD').uploadMasterBudget(body).then(response => {
// console.log(response);
// if (response.data) {
// if (response.ok) {
// if (response.data.status === "success") {
// this.props.onClickClose()
// if (type == 'submitted') {
// this.props.getReport('PL')
// } else {
// this.props.getReport()
// }
// } else {
// if (response.data.message == "Please Set Up Rate Currency First") {
// this.setState({ visibleAlertSave: true })
// } 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);
// }
// })
// }
// // alert(response.data.status)
// }
// } 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 })
// }
// })
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.onClickClose()
if (type == 'submitted') {
this.props.getReport('PL')
} else {
this.props.getReport()
}
} else {
if (response.data.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} 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);
}
})
}
// alert(response.data.status)
}
} 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 })
}
})
}
async downloadAllData() {
......@@ -1053,7 +1053,7 @@ export default class ProfitLoss extends Component {
type="text"
placeholder=""
disabled={true}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
/>
......@@ -1186,7 +1186,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -1327,7 +1327,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -1468,7 +1468,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -1609,7 +1609,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -1750,7 +1750,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -1891,7 +1891,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -2032,7 +2032,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -2173,7 +2173,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -2314,7 +2314,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -2455,7 +2455,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -2596,7 +2596,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -2832,7 +2832,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......@@ -2973,7 +2973,7 @@ export default class ProfitLoss extends Component {
disabled={true}
decimalScale={this.props.defaultCurrency.id == 1 ? 1 : 16}
// decimalScale={this.props.defaultCurrency.id == 1 ? 1 : (String(value).includes(".") && this.state.previewUpload == true ? String(value).split(".")[1].length : 16)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
value={handleValue(value, tableMeta) == 0 ? "0.0" : this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(value, tableMeta)), 1) : handleValue(value, tableMeta)}
/>
</span>
:
......
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