Commit 1f133840 authored by Riri Novita's avatar Riri Novita

Merge branch 'dev/riri' into 'ENV-DEV'

Setting Full Amount

See merge request !1980
parents fda5146b 645a35f0
......@@ -189,6 +189,7 @@ const create = (type = "") => {
const searchParameter = (body) => api.post('setting/search_setting', body)
const deleteParameter = (id) => api.post(`setting/delete_setting/${id}`)
const getDataReport = () => api.get('setting_type/get_all_setting_type_by_report_submit_period_group')
const getFormatValue = () => api.get('setting_type/get_all_setting_type_by_money_format_group')
// MASTER DATA - CAT
const getAllMasterDataCat = () => api.get('item_report_company/get_all_item_report_company')
......@@ -649,6 +650,7 @@ const create = (type = "") => {
deleteUnitBisnis,
deleteParameter,
getDataReport,
getFormatValue,
deletePerusahaan,
getDataCurrency,
deleteReportItems,
......
......@@ -14,6 +14,7 @@ export default class CreateParameter extends Component {
this.state = {
enableParameter: false,
enableReportName: false,
enableFormat: false,
id: '',
description: '',
value: '',
......@@ -29,7 +30,9 @@ export default class CreateParameter extends Component {
getTypes: null,
perusahaan: null,
reportName: null,
formatCurrency: null,
getReportName: null,
getFormatData: null,
getPerusahaan: null,
parameter: null,
getParameter: null,
......@@ -40,6 +43,7 @@ export default class CreateParameter extends Component {
errorParameter: false,
errorDeskripsi: false,
errorReportName: false,
errorFormatValue: false,
errorValue: false,
errorMinValue: false,
errorOrder: false,
......@@ -53,6 +57,7 @@ export default class CreateParameter extends Component {
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorValue: '',
msgErrorMinValue: '',
msgErrorOrder: '',
......@@ -74,6 +79,7 @@ export default class CreateParameter extends Component {
this.getDataGroup()
this.getDataPerusahaan()
this.getDataReportName()
this.getDataFormat()
}
}
......@@ -93,12 +99,14 @@ export default class CreateParameter extends Component {
typeReport: data.setting_type_name,
getTypeReportID: data.setting_type_id,
enableReportName: data.setting_group === "CURRENCY" ? true : false,
tesValue: response.data.data.setting_group === "CURRENCY" ? Number(response.data.data.value)*1000 : response.data.data.value
enableFormat: data.setting_group === "CURRENCY_MONEY_FORMAT" ? true : false,
tesValue: response.data.data.setting_group === "CURRENCY" ? Number(response.data.data.value) * 1000 : response.data.data.value
}, () => {
this.getAllGroup()
this.getPerusahaan()
this.getReport()
this.getFormat()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -236,6 +244,44 @@ export default class CreateParameter extends Component {
})
}
getFormat() {
api.create().getFormatValue().then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let formatData = data.map((item) => {
return {
setting_type_id: item.setting_type_id,
setting_type_name: item.setting_type_name
}
})
let index = formatData.findIndex((val) => val.setting_type_id == this.state.tempData.reference_id)
let formatProps = {
options: formatData,
getOptionLabel: (option) => option.setting_type_name,
};
this.setState({ formatCurrency: formatProps, formatData: response.data.data, getFormatData: index == -1 ? formatData[0] : formatData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getDataGroup() {
api.create().getAllGroup().then((response) => {
if (response.data) {
......@@ -314,9 +360,11 @@ export default class CreateParameter extends Component {
getParameterByGroup(id, name) {
if (name === "CURRENCY") {
this.setState({ enableReportName: true })
this.setState({ enableReportName: true, enableFormat : false})
} else if (name === "CURRENCY_MONEY_FORMAT") {
this.setState({ enableFormat: true, enableReportName : false })
} else {
this.setState({ enableReportName: false })
this.setState({ enableReportName: false, enableFormat: false })
}
api.create().getParameterByGroup(id).then(response => {
// console.log(id, response);
......@@ -420,6 +468,43 @@ export default class CreateParameter extends Component {
// this.setState({ reportName: reportProps })
}
getDataFormat() {
api.create().getFormatValue().then((response) => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let formatData = data.map((item) => {
return {
setting_type_id: item.setting_type_id,
setting_type_name: item.setting_type_name
}
})
let formatProps = {
options: formatData,
getOptionLabel: (option) => option.setting_type_name,
};
this.setState({ formatCurrency: formatProps, formatData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
handleChange(e, type) {
let data = this.state
let isDate = type !== '' ? true : false
......@@ -429,6 +514,7 @@ export default class CreateParameter extends Component {
errorParameter: false,
errorDeskripsi: false,
errorReportName: false,
errorFormatValue: false,
errorValue: false,
errorMinValue: false,
errorOrder: false,
......@@ -442,6 +528,7 @@ export default class CreateParameter extends Component {
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorValue: '',
msgErrorMinValue: '',
msgErrorOrder: '',
......@@ -455,6 +542,7 @@ export default class CreateParameter extends Component {
errorParameter: false,
errorDeskripsi: false,
errorReportName: false,
errorFormatValue: false,
errorValue: false,
errorMinValue: false,
errorOrder: false,
......@@ -468,6 +556,7 @@ export default class CreateParameter extends Component {
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorValue: '',
msgErrorMinValue: '',
msgErrorOrder: '',
......@@ -482,6 +571,7 @@ export default class CreateParameter extends Component {
errorParameter: false,
errorDeskripsi: false,
errorReportName: false,
errorFormatValue: false,
errorValue: false,
errorMinValue: false,
errorOrder: false,
......@@ -495,6 +585,7 @@ export default class CreateParameter extends Component {
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorValue: '',
msgErrorMinValue: '',
msgErrorOrder: '',
......@@ -513,6 +604,7 @@ export default class CreateParameter extends Component {
errorMinValue: false,
errorOrder: false,
errorReportName: false,
errorFormatValue: false,
errorMaxValue: false,
errorStartDate: false,
errorEndDate: false,
......@@ -528,7 +620,8 @@ export default class CreateParameter extends Component {
msgErrorMaxValue: '',
msgErrorStartDate: '',
msgErrorEndDate: '',
msgErrorReportName: ''
msgErrorReportName: '',
msgErrorFormatValue: '',
})
}
......@@ -558,7 +651,9 @@ export default class CreateParameter extends Component {
// } else if (R.isEmpty(this.state.tempData.description)) {
// this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
} else if (this.state.getTypes.setting_group_name === "CURRENCY" && R.isNil(this.state.getReportName)) {
this.setState({ errorReportName: true, msgErrorReportName: 'Report Cannot be Empty' })
this.setState({ errorReportName: true, msgErrorReportName: 'Type Report Cannot be Empty' })
} else if (this.state.getTypes.setting_group_name === "CURRENCY_MONEY_FORMAT" && R.isNil(this.state.getFormatData)) {
this.setState({ errorFormatValue: true, msgErrorFormatValue: 'Format Cannot be Empty' })
} else if (R.isEmpty(this.state.tempData.value) && R.isEmpty(this.state.tempData.min_value) && R.isEmpty(this.state.tempData.max_value)) {
this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' })
} else if ((!R.isEmpty(this.state.tempData.max_value) && R.isEmpty(this.state.tempData.min_value))) {
......@@ -587,7 +682,9 @@ export default class CreateParameter extends Component {
// } else if (R.isEmpty(this.state.description)) {
// this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
} else if (this.state.getTypes.setting_group_name === "CURRENCY" && R.isNil(this.state.getReportName)) {
this.setState({ errorReportName: true, msgErrorReportName: 'Report Cannot be Empty' })
this.setState({ errorReportName: true, msgErrorReportName: 'Type Report Cannot be Empty' })
} else if (this.state.getTypes.setting_group_name === "CURRENCY_MONEY_FORMAT" && R.isNil(this.state.getFormatData)) {
this.setState({ errorFormatValue: true, msgErrorFormatValue: 'Format Cannot be Empty' })
} else if ((R.isEmpty(this.state.value) && R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' })
} else if ((!R.isEmpty(this.state.maxValue) && R.isEmpty(this.state.minValue))) {
......@@ -640,7 +737,7 @@ export default class CreateParameter extends Component {
"orders": this.state.order,
"value": this.state.value,
// convert IDR to IDR mn
"value": this.state.enableReportName ? this.state.value.includes(".") || arrayChar.length == 2 ? this.state.value : this.state.value/1000 : this.state.value ,
"value": this.state.enableReportName ? this.state.value.includes(".") || arrayChar.length == 2 ? this.state.value : this.state.value / 1000 : this.state.value,
"max_value": this.state.maxValue,
"min_value": this.state.minValue,
"start_date": this.state.startDate,
......@@ -706,7 +803,7 @@ export default class CreateParameter extends Component {
{...this.state.types}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, enableReportName: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())}
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, enableReportName: false, enableFormat: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
......@@ -832,9 +929,9 @@ export default class CreateParameter extends Component {
<TextField
style={{ width: '100%' }}
id="value"
label= {"Value"}
label={"Value"}
// get data IDR by IDR mn
value={this.state.tempData === null ? '' : this.state.tempData.setting_group === "CURRENCY" ? Number(this.state.tempData.value )*1000 : this.state.tempData.value}
value={this.state.tempData === null ? '' : this.state.tempData.setting_group === "CURRENCY" ? Number(this.state.tempData.value) * 1000 : this.state.tempData.value}
inputProps={{
min: 0,
style: {
......@@ -852,7 +949,7 @@ export default class CreateParameter extends Component {
this.setState({
tempData: {
...this.state.tempData,
value: this.state.tempData.setting_group === "CURRENCY" ? e.target.value/1000 : e.target.value
value: this.state.tempData.setting_group === "CURRENCY" ? e.target.value / 1000 : e.target.value
}
})
this.clearMessage()
......@@ -884,8 +981,50 @@ export default class CreateParameter extends Component {
/>}
value={this.state.getReportName}
/>
</div> : null
</div>
:
this.state.enableFormat == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.formatCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getFormatData: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Format"
error={this.state.errorFormatValue}
helperText={this.state.msgErrorFormatValue}
/>}
value={this.state.getFormatData}
/>
</div>
:
null
}
{/* {this.state.enableFormat == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.formatCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getFormatData: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Format"
error={this.state.errorFormatValue}
helperText={this.state.msgErrorFormatValue}
/>}
value={this.state.getFormatData}
/>
</div> : null
} */}
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ padding: '5px 20px' }}>
......@@ -1145,7 +1284,7 @@ export default class CreateParameter extends Component {
{...this.state.types}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, enableReportName: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())}
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, enableReportName: false, enableFormat: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
......@@ -1162,7 +1301,7 @@ export default class CreateParameter extends Component {
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ padding: '5px 20px' }}>
<div className="column-1">
<div style={{ padding: 10, borderRadius: 5 }}>
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.parameter}
debug
......@@ -1270,7 +1409,7 @@ export default class CreateParameter extends Component {
<TextField
style={{ width: '100%' }}
id="value"
label= {"Value"}
label={"Value"}
value={this.state.value}
inputProps={{
min: 0,
......@@ -1301,7 +1440,7 @@ export default class CreateParameter extends Component {
</div>
</div>
<div className="column-2">
{this.state.enableReportName &&
{this.state.enableReportName == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.reportName}
......@@ -1320,7 +1459,30 @@ export default class CreateParameter extends Component {
value={this.state.getReportName}
/>
</div>
:
this.state.enableFormat == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.formatCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getFormatData: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Format"
error={this.state.errorFormatValue}
helperText={this.state.msgErrorFormatValue}
/>}
value={this.state.getFormatData}
/>
</div>
:
null
}
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ padding: '5px 20px' }}>
......
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