Commit 953bb3e8 authored by Riri Novita's avatar Riri Novita

Merge branch 'ENV-STAGING' of http://103.44.149.204/d.arizona/tia-dev into ENV-STAGING

parents cb9491df 66c49bdc
......@@ -190,6 +190,7 @@ const create = (type = "") => {
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')
const getThreshold = () => api.get('/setting_type/get_all_setting_type_by_threshold_control')
// MASTER DATA - CAT
const getAllMasterDataCat = () => api.get('item_report_company/get_all_item_report_company')
......@@ -651,6 +652,7 @@ const create = (type = "") => {
deleteParameter,
getDataReport,
getFormatValue,
getThreshold,
deletePerusahaan,
getDataCurrency,
deleteReportItems,
......
......@@ -2513,14 +2513,15 @@ export default class BudgetTahunan extends Component {
}
handleDownloadReport(tableMeta) {
let { selectReport, company, periode, month } = this.state
let { selectReport, company, periode, month, defaultCurrency } = this.state
let payload = {
"company_id": company.company_id,
"year": periode.periode,
"report_id": selectReport,
"month": "",
"quartal": "",
"type_report_name": "Master Budget"
"type_report_name": "Master Budget",
"currency_id" : defaultCurrency.id
}
// console.log(payload);
api.create().createDownloadFile(payload).then((response) => {
......
......@@ -16,6 +16,7 @@ export default class CreateParameter extends Component {
enableParameter: false,
enableReportName: false,
enableFormat: false,
enableThreshold: false,
id: '',
description: '',
value: '',
......@@ -32,8 +33,10 @@ export default class CreateParameter extends Component {
perusahaan: null,
reportName: null,
formatCurrency: null,
thresholdCurrency: null,
getReportName: null,
getFormatData: null,
getThresholdCurrency: null,
getPerusahaan: null,
parameter: null,
getParameter: null,
......@@ -45,6 +48,7 @@ export default class CreateParameter extends Component {
errorDeskripsi: false,
errorReportName: false,
errorFormatValue: false,
errorThresholdCurrency: false,
errorValue: false,
errorMinValue: false,
errorOrder: false,
......@@ -59,6 +63,7 @@ export default class CreateParameter extends Component {
msgErrorDeskripsi: '',
msgErrorReportName: '',
msgErrorFormatValue: '',
msgErrorThresholdCurrency: '',
msgErrorValue: '',
msgErrorMinValue: '',
msgErrorOrder: '',
......@@ -87,6 +92,7 @@ export default class CreateParameter extends Component {
this.getDataPerusahaan()
this.getDataReportName()
this.getDataFormat()
this.getDataCurrencyThreshold()
}
}
......@@ -107,6 +113,7 @@ export default class CreateParameter extends Component {
getTypeReportID: data.setting_type_id,
enableReportName: data.setting_group === "CURRENCY" ? true : false,
enableFormat: data.setting_group === "CURRENCY_MONEY_FORMAT" ? true : false,
enableThreshold: data.setting_group === "THRESHOLD_CONTROL" ? true : false,
tesValue: response.data.data.setting_group === "CURRENCY" ? Number(response.data.data.value) * 1000 : response.data.data.value
}, () => {
......@@ -114,6 +121,7 @@ export default class CreateParameter extends Component {
this.getPerusahaan()
this.getReport()
this.getFormat()
this.getCurrencyByThreshold()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -289,6 +297,44 @@ export default class CreateParameter extends Component {
})
}
getCurrencyByThreshold() {
api.create().getThreshold().then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let currencyData = data.map((item) => {
return {
setting_type_id: item.setting_type_id,
setting_type_name: item.setting_type_name
}
})
let index = currencyData.findIndex((val) => val.setting_type_id == this.state.tempData.reference_id)
let currencyProps = {
options: currencyData,
getOptionLabel: (option) => option.setting_type_name,
};
this.setState({ thresholdCurrency: currencyProps, currencyData: response.data.data, getThresholdCurrency: index == -1 ? currencyData[0] : currencyData[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) {
......@@ -367,11 +413,13 @@ export default class CreateParameter extends Component {
getParameterByGroup(id, name) {
if (name === "CURRENCY") {
this.setState({ enableReportName: true, enableFormat: false })
this.setState({ enableReportName: true, enableFormat: false, enableThreshold: false })
} else if (name === "CURRENCY_MONEY_FORMAT") {
this.setState({ enableFormat: true, enableReportName: false })
this.setState({ enableFormat: true, enableReportName: false, enableThreshold: false })
} else if (name === "THRESHOLD_CONTROL") {
this.setState({ enableThreshold: true, enableFormat: false, enableReportName: false })
} else {
this.setState({ enableReportName: false, enableFormat: false })
this.setState({ enableReportName: false, enableFormat: false, enableThreshold: false })
}
api.create().getParameterByGroup(id).then(response => {
// console.log(id, response);
......@@ -512,6 +560,43 @@ export default class CreateParameter extends Component {
})
}
getDataCurrencyThreshold() {
api.create().getThreshold().then((response) => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let currencyData = data.map((item) => {
return {
setting_type_id: item.setting_type_id,
setting_type_name: item.setting_type_name
}
})
let currencyProps = {
options: currencyData,
getOptionLabel: (option) => option.setting_type_name,
};
this.setState({ thresholdCurrency: currencyProps, currencyData: 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
......@@ -530,6 +615,8 @@ export default class CreateParameter extends Component {
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
errorThresholdCurrency: false,
msgErrorThresholdCurrency: '',
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
......@@ -558,6 +645,8 @@ export default class CreateParameter extends Component {
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
errorThresholdCurrency: false,
msgErrorThresholdCurrency: '',
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
......@@ -587,6 +676,8 @@ export default class CreateParameter extends Component {
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
errorThresholdCurrency: false,
msgErrorThresholdCurrency: '',
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
......@@ -617,6 +708,8 @@ export default class CreateParameter extends Component {
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
errorThresholdCurrency: false,
msgErrorThresholdCurrency: '',
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
......@@ -683,18 +776,17 @@ export default class CreateParameter extends Component {
// }
// }
async validasiValueResponse() {
let data = await this.validasiValueData()
if (R.isNil(this.state.getTypes)) {
}else {
} else {
if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") {
if (R.isEmpty(data.value)) {
if (R.isNil(this.state.getPerusahaan)){
}else {
if (this.state.getPerusahaan.company_name == "Default"){
}else {
this.setState({errorValue: true, msgErrorValue: 'Value Cannot be Empty'})
if (R.isNil(this.state.getPerusahaan)) {
} else {
if (this.state.getPerusahaan.company_name == "Default") {
} else {
this.setState({ errorValue: true, msgErrorValue: 'Value Cannot be Empty' })
}
}
} else {
......@@ -702,7 +794,7 @@ export default class CreateParameter extends Component {
} else {
switch (this.state.getParameter.setting_type_name) {
case "MASTER_BUDGET":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023'})
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023' })
break
case "MONTHLY_REPORT":
this.setState({
......@@ -711,43 +803,43 @@ export default class CreateParameter extends Component {
})
break
case "OUTLOOK_Q1":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : Q1 2023'})
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : Q1 2023' })
break
case "OUTLOOK_Q2":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : Q2 2023'})
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : Q2 2023' })
break
case "OUTLOOK_Q3":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : Q3 2023'})
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : Q3 2023' })
break
case "OUTLOOK_PA":
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023'})
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023' })
break
default:
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023'})
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023' })
}
}
}
} else if (this.state.getTypes.setting_group_name == "CURRENCY") {
this.setState({errorValue: true, msgErrorValue: 'Incorrect value format, example : 15000'})
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 15000' })
}
}
}
async validasiCreateEdit(){
async validasiCreateEdit() {
let data = await this.validasiValueData()
let response = await this.validasiRegexValue()
let minMaxValidasi = await this.validasiMinMaxValue()
console.log("Masuk ke menu creat : " + R.isNil(this.state.getFormatData))
if (this.props.type === "edit"){
if (this.props.type === "edit") {
if (R.isNil(this.state.getTypes)) {
} else {
if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT") {
if (R.isNil(this.state.getParameter)){
}else {
if (R.isNil(this.state.getPerusahaan)){
}else {
if (R.isNil(this.state.getFormatData)){
}else {
if (R.isNil(this.state.getParameter)) {
} else {
if (R.isNil(this.state.getPerusahaan)) {
} else {
if (R.isNil(this.state.getFormatData)) {
} else {
this.updateParameterCurrebcyMoneyFormat()
}
}
......@@ -760,7 +852,7 @@ export default class CreateParameter extends Component {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) {
} else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
......@@ -772,24 +864,24 @@ export default class CreateParameter extends Component {
}
}
}
} else if (this.state.getTypes.setting_group_name == "THRESHOLD_VARIANCE" || this.state.getTypes.setting_group_name == "THRESHOLD_CONTROL" ) {
} else if (this.state.getTypes.setting_group_name == "THRESHOLD_VARIANCE" || this.state.getTypes.setting_group_name == "THRESHOLD_CONTROL") {
if (R.isEmpty(data.minValue)) {
} else {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.minValue.substring(0,1) != "0" : true ) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.minValue.length <= minMaxValidasi.minLength : true )) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
this.updateParameter()
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.maxValue.substring(0,1) != "0" : true ) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.maxValue.length <= minMaxValidasi.maxLength : true )) {
this.updateParameterThreshold()
}
}
}
}
} else if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") {
if (R.isEmpty(data.value)) {
if (this.state.getPerusahaan.company_name == "Default"){
if (this.state.getPerusahaan.company_name == "Default") {
if (R.isEmpty(data.minValue)) {
} else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength){
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
......@@ -803,7 +895,7 @@ export default class CreateParameter extends Component {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) {
} else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength){
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
......@@ -814,27 +906,27 @@ export default class CreateParameter extends Component {
}
}
}
}else {
if (R.isNil(this.state.getParameter)){
}else {
if (R.isNil(this.state.getPerusahaan)){
}else {
} else {
if (R.isNil(this.state.getParameter)) {
} else {
if (R.isNil(this.state.getPerusahaan)) {
} else {
this.updateParameter()
}
}
}
}
}else {
} else {
if (R.isNil(this.state.getTypes)) {
} else {
if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT") {
if (R.isNil(this.state.getParameter)){
}else {
if (R.isNil(this.state.getPerusahaan)){
}else {
if (R.isNil(this.state.getParameter)) {
} else {
if (R.isNil(this.state.getPerusahaan)) {
} else {
console.log()
if (R.isNil(this.state.getFormatData)){
}else {
if (R.isNil(this.state.getFormatData)) {
} else {
this.createParameterCurrebcyMoneyFormat()
}
}
......@@ -859,27 +951,27 @@ export default class CreateParameter extends Component {
}
}
}
} else if (this.state.getTypes.setting_group_name == "THRESHOLD_VARIANCE" || this.state.getTypes.setting_group_name == "THRESHOLD_CONTROL" ) {
} else if (this.state.getTypes.setting_group_name == "THRESHOLD_VARIANCE" || this.state.getTypes.setting_group_name == "THRESHOLD_CONTROL") {
if (R.isEmpty(data.minValue)) {
} else {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.minValue.substring(0,1) != "0" : true ) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.minValue.length <= minMaxValidasi.minLength : true )) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
this.createParameter()
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.maxValue.substring(0,1) != "0" : true ) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.maxValue.length <= minMaxValidasi.maxLength : true )) {
this.createParameterThreshold()
}
}
}
}
} else if (this.state.getTypes.setting_group_name == "REPORT_SUBMIT_PERIOD") {
if (R.isEmpty(data.value)) {
if (this.state.getPerusahaan.company_name == "Default"){
if (this.state.getPerusahaan.company_name == "Default") {
if (R.isEmpty(data.minValue)) {
} else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0,1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
this.createParameter()
}
}
......@@ -890,10 +982,10 @@ export default class CreateParameter extends Component {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) {
} else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0,1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
this.createParameter()
}
}
......@@ -901,11 +993,11 @@ export default class CreateParameter extends Component {
}
}
}
}else {
if (R.isNil(this.state.getParameter)){
}else {
if (R.isNil(this.state.getPerusahaan)){
}else {
} else {
if (R.isNil(this.state.getParameter)) {
} else {
if (R.isNil(this.state.getPerusahaan)) {
} else {
this.createParameter()
}
}
......@@ -914,11 +1006,11 @@ export default class CreateParameter extends Component {
}
}
validasiFormatResponse(){
if (R.isNil(this.state.getTypes)){
}else {
if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT"){
if (R.isNil(this.state.getFormatData)){
validasiFormatResponse() {
if (R.isNil(this.state.getTypes)) {
} else {
if (this.state.getTypes.setting_group_name == "CURRENCY_MONEY_FORMAT") {
if (R.isNil(this.state.getFormatData)) {
this.setState({ errorFormatValue: true, msgErrorFormatValue: 'Format Cannot be Empty' })
}
}
......@@ -927,12 +1019,12 @@ export default class CreateParameter extends Component {
validasiRegexValue() {
let obj = null
if (R.isNil(this.state.getTypes)){
if (R.isNil(this.state.getTypes)) {
obj = { regexValue: "", valueLength: "" }
}else {
if (this.state.getTypes.setting_group_name === "CURRENCY"){
} else {
if (this.state.getTypes.setting_group_name === "CURRENCY") {
obj = { regexValue: (/\d+(\.\d+)?/), valueLength: 20 }
} else if (this.state.getTypes.setting_group_name === "REPORT_SUBMIT_PERIOD"){
} else if (this.state.getTypes.setting_group_name === "REPORT_SUBMIT_PERIOD") {
if (R.isNil(this.state.getParameter)) {
obj = { regexValue: (/\b\d{4}\b/), valueLength: 4 }
} else {
......@@ -1012,10 +1104,10 @@ export default class CreateParameter extends Component {
})
break
case "THRESHOLD_CONTROL":
this.setState({ errorMinValue: true, msgErrorMinValue: 'Incorrect min value format, example : 99999999' })
this.setState({ errorMinValue: true, msgErrorMinValue: 'Incorrect min value format, example : -99999999' })
break
case "THRESHOLD_VARIANCE":
this.setState({ errorMinValue: true, msgErrorMinValue: 'Incorrect min value format, example : 99999999' })
this.setState({ errorMinValue: true, msgErrorMinValue: 'Incorrect min value format, example : -99999999' })
break
default:
this.setState({ errorMinValue: false, msgErrorMinValue: '' })
......@@ -1030,16 +1122,76 @@ export default class CreateParameter extends Component {
} else {
switch (this.state.getTypes.setting_group_name) {
case "CURRENCY":
obj = { minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/), minLength: 11, maxLength: 11, regexValue: (/^\d+$/)}
obj = { minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/), minLength: 11, maxLength: 11, regexValue: (/^\d+$/) }
break
case "REPORT_SUBMIT_PERIOD":
if (R.isNil(this.state.getPerusahaan)) {
obj = {
minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/),
minLength: 11, maxLength: 11
}
} else {
if (this.state.getPerusahaan.company_name == "Default") {
if (R.isNil(this.state.getParameter)) {
obj = {
minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/),
minLength: 11, maxLength: 11
}
} else {
switch (this.state.getParameter.setting_type_name) {
case "MASTER_BUDGET":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
case "MONTHLY_REPORT":
obj = {
minMaxRegex: (/^(?:\d{1,2}|(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}))$/),
minLength: 11, maxLength: 11
}
break
case "OUTLOOK_Q1":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
case "OUTLOOK_Q2":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
case "OUTLOOK_Q3":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
case "OUTLOOK_PA":
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
break
default:
obj = {
minMaxRegex: (/^(\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(?:\s\d{4})?$/),
minLength: 11, maxLength: 11
}
}
}
} else {
obj = {
minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/),
minLength: 11, maxLength: 11
}
}
}
break
case "THRESHOLD_CONTROL":
obj = { minMaxRegex: (/^-?\d+\.?\d+$/), minLength: this.state.minValue.length, maxLength: this.state.maxValue.length }
obj = { minMaxRegex: (/^-?\d+(\.\d+)?$/), minLength: this.state.minValue.length, maxLength: this.state.maxValue.length }
break
default:
obj = { regexValue: null, minLength: 11, maxLength: 11 }
......@@ -1048,31 +1200,49 @@ export default class CreateParameter extends Component {
return obj;
}
validasiValueData(){
validasiValueData() {
let obj = null
if (this.props.type === "edit"){
obj = {value: this.state.tempData.value.toString(), minValue: this.state.tempData.min_value, maxValue: this.state.tempData.max_value, endDate: this.state.tempData.end_date, startDate: this.state.tempData.start_date}
}else {
obj = {value: this.state.value, minValue: this.state.minValue, maxValue: this.state.maxValue, endDate: this.state.endDate, startDate: this.state.startDate}
if (this.props.type === "edit") {
obj = { value: this.state.tempData.value.toString(), minValue: this.state.tempData.min_value, maxValue: this.state.tempData.max_value, endDate: this.state.tempData.end_date, startDate: this.state.tempData.start_date }
} else {
obj = { value: this.state.value, minValue: this.state.minValue, maxValue: this.state.maxValue, endDate: this.state.endDate, startDate: this.state.startDate }
}
return obj;
}
validasiCurrencyTC(){
if (R.isNil(this.state.getThresholdCurrency)){
this.setState({ errorThresholdCurrency: true, msgErrorThresholdCurrency: 'Currency Cannot be Empty' })
}
}
async validasiMaxValue() {
let data = await this.validasiValueData()
let minMaxValidasi = await this.validasiMinMaxValue()
if (R.isEmpty(data.maxValue)) {
this.validasiMaxResponse()
this.validasiCurrencyTC()
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
if (R.isNil(this.state.getTypes)){
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0,1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
this.validasiCurrencyTC()
} else {
this.validasiMaxResponse()
this.validasiCurrencyTC()
}
}else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.maxValue.substring(0,1) != "0" : true ) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.maxValue.length <= minMaxValidasi.maxLength : true ) ) {
this.validasiCurrencyTC()
} else {
this.validasiMaxResponse()
this.validasiCurrencyTC()
}
}
}
}
validasiFormatData() {
if (R.isNil(this.state.getFormatData)){
if (R.isNil(this.state.getFormatData)) {
this.validasiFormatResponse()
this.validasiMaxValue()
} else {
......@@ -1087,64 +1257,73 @@ export default class CreateParameter extends Component {
this.validasiMinResponse()
this.validasiFormatData()
} else {
if (R.isNil(this.state.getTypes)){
if(data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0,1) != "0" && data.minValue.length <= minMaxValidasi.minLength){
this.validasiFormatData()
} else {
this.validasiMinResponse()
this.validasiFormatData()
}
}else {
if(data.minValue.match(minMaxValidasi.minMaxRegex) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.minValue.substring(0,1) != "0" : true ) && (this.state.getTypes.setting_group_name != "THRESHOLD_CONTROL" ? data.minValue.length <= minMaxValidasi.minLength : true )){
this.validasiFormatData()
} else {
this.validasiMinResponse()
this.validasiFormatData()
}
}
}
}
async validasiValue (){
async validasiValue() {
let data = await this.validasiValueData()
let response = await this.validasiRegexValue()
if (R.isEmpty(data.value)){
if (R.isEmpty(data.value)) {
this.validasiValueResponse()
this.validsiMinValue()
}else {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength){
} else {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
this.validsiMinValue()
}else {
} else {
this.validasiValueResponse()
this.validsiMinValue()
}
}
}
validasiReportName(){
if (R.isNil(this.state.getReportName)){
validasiReportName() {
if (R.isNil(this.state.getReportName)) {
this.setState({ errorReportName: true, msgErrorReportName: 'Report Cannot be Empty' })
this.validasiValue()
}else {
} else {
this.validasiValue()
}
}
validasiPerusahaan(){
if (R.isNil(this.state.getPerusahaan)){
validasiPerusahaan() {
if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
this.validasiReportName()
}else {
} else {
this.validasiReportName()
this.validasiCreateEdit()
}
}
validasiParameter(){
if(R.isNil(this.state.getParameter)){
validasiParameter() {
if (R.isNil(this.state.getParameter)) {
this.setState({ errorParameter: true, msgErrorParameter: 'Parameter Cannot be Empty' })
this.validasiPerusahaan()
}else {
} else {
this.validasiPerusahaan()
}
}
validasiGroup(){
validasiGroup() {
if (R.isNil(this.state.getTypes)) {
this.setState({ errorGroup: true, msgErrorGroup: 'Group Cannot be Empty' })
this.validasiParameter()
}else {
} else {
this.validasiParameter()
}
}
......@@ -1179,6 +1358,28 @@ export default class CreateParameter extends Component {
this.props.updateParameter(body)
}
updateParameterThreshold() {
// let char = this.state.value
// let arrayChar = char.split('');
// console.log(char);
let body = {
"setting_id": this.state.tempData.setting_id,
"setting_group_id": this.state.getTypes.setting_group_id,
"setting_type_id": this.state.getParameter.setting_type_id,
"company_id": this.state.getPerusahaan.company_id,
"reference_id": this.state.getThresholdCurrency == null ? null : this.state.getThresholdCurrency.setting_type_id,
"description": this.state.tempData.description,
"orders": this.state.tempData.order,
"value": this.state.tempData.value,
"max_value": this.state.tempData.max_value,
"min_value": this.state.tempData.min_value,
"start_date": this.state.tempData.start_date,
"end_date": this.state.tempData.end_date
}
console.log(body);
this.props.updateParameter(body)
}
updateParameterCurrebcyMoneyFormat() {
// let char = this.state.value
// let arrayChar = char.split('');
......@@ -1224,6 +1425,29 @@ export default class CreateParameter extends Component {
this.props.createParameter(body)
}
createParameterThreshold() {
let char = this.state.value
let arrayChar = char.split('');
console.log(char);
let body = {
"setting_group_id": this.state.getTypes.setting_group_id,
"setting_type_id": this.state.getParameter.setting_type_id,
"company_id": this.state.getPerusahaan.company_id,
"reference_id": this.state.getThresholdCurrency == null ? null : this.state.getThresholdCurrency.setting_type_id,
"description": this.state.description,
"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,
"max_value": this.state.maxValue,
"min_value": this.state.minValue,
"start_date": this.state.startDate,
"end_date": this.state.endDate
}
console.log(body);
this.props.createParameter(body)
}
createParameterCurrebcyMoneyFormat() {
let char = this.state.value
let arrayChar = char.split('');
......@@ -1248,9 +1472,9 @@ export default class CreateParameter extends Component {
}
openPopUp() {
if (!R.isNil(this.state.getTypes)){
if (this.state.getTypes.setting_group_name == "CURRENCY"){
if (!R.isNil(this.state.getReportName)){
if (!R.isNil(this.state.getTypes)) {
if (this.state.getTypes.setting_group_name == "CURRENCY") {
if (!R.isNil(this.state.getReportName)) {
this.setState({
visiblePopupInformation: true
})
......@@ -1315,7 +1539,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, enableFormat: 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, enableThreshold: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
......@@ -1519,6 +1743,27 @@ export default class CreateParameter extends Component {
/>
</div>
:
this.state.enableThreshold == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.thresholdCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getThresholdCurrency: newInputValue }, () =>
this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Currency"
error={this.state.errorThresholdCurrency}
helperText={this.state.msgErrorThresholdCurrency}
/>}
value={this.state.getThresholdCurrency}
/>
</div>
:
null
}
{/* {this.state.enableFormat == true ?
......@@ -1804,7 +2049,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, enableFormat: 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, enableThreshold: false, getParameter: null, getReportName: null }, () => this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id, newInputValue.setting_group_name), this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
......@@ -1967,7 +2212,8 @@ export default class CreateParameter extends Component {
id="report"
onChange={(event, newInputValue) => this.setState({ getReportName: newInputValue }, () => {
this.clearMessage()
this.openPopUp()})}
this.openPopUp()
})}
renderInput={(params) =>
<TextField
{...params}
......@@ -2001,6 +2247,26 @@ export default class CreateParameter extends Component {
/>
</div>
:
this.state.enableThreshold == true ?
<div className="" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.thresholdCurrency}
debug
id="report"
onChange={(event, newInputValue) => this.setState({ getThresholdCurrency: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Currency"
error={this.state.errorThresholdCurrency}
helperText={this.state.msgErrorThresholdCurrency}
/>}
value={this.state.getThresholdCurrency}
/>
</div>
:
null
}
......
......@@ -665,14 +665,14 @@ export default class BalanceSheetMR extends Component {
// // console.log(i);
// err = true
// } else
if (i[18] === "" && (this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[14]), 1) : Number(i[14]) < this.state.minValue || this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[14]), 1) : Number(i[14]) > this.state.maxValue)) {
if (i[18] === "" && (fixNumber(Number(i[14]), 1) < this.state.minValue || fixNumber(Number(i[14]), 1) > this.state.maxValue)) {
console.log('msk 2');
err = true
}
}
if (String(i[5]) == "Control (should be nil)") {
if (this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[9]), 1) : Number(i[9]) < this.state.minValue || this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[9]), 1) : Number(i[9]) > this.state.maxValue) {
if (fixNumber(Number(i[9]), 1) < this.state.minValue || fixNumber(Number(i[9]), 1) > this.state.maxValue) {
errorContrl = true
editAble = true
}
......@@ -1307,7 +1307,15 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
null :
// this.state.get_for == 'view'?
this.state.get_for == 'view'?
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[7]), 1) : Number(tableMeta.rowData[7]) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[7]))}
/>:
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
......@@ -1404,7 +1412,15 @@ export default class BalanceSheetMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 7 ?
null :
// this.state.get_for == 'view'?
this.state.get_for == 'view'?
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(tableMeta.rowData[8]), 1) : Number(tableMeta.rowData[8]) == 0 ? "0.0" : fixNumber(Number(tableMeta.rowData[8]))}
/>:
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
......
......@@ -1536,14 +1536,14 @@ export default class ListOfCreditFacilities extends Component {
if (this.props.defaultCurrency.id == 1) {
this.setState({ loading: false, dataTable: newData, diff: this.state.diff == null ? "0.0" : fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand })
} else {
this.setState({ loading: false, dataTable: newData, diff: this.state.diff == null ? "0.0" : Number(Number(totalLoan) - this.state.perBS), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand })
this.setState({ loading: false, dataTable: newData, diff: this.state.diff == null ? "0.0" : fixNumber(Number(Number(totalLoan) - this.state.perBS),1), perBS: this.state.totalOutStand == null ? "0.0" : this.state.totalOutStand })
}
} else {
if (this.props.defaultCurrency.id == 1) {
this.setState({ loading: false, dataTable: newData, diff: fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1), saveDraft: false, saveComp: Number(fixNumber(Number(totalLoan), 1) - this.state.perBS) == 0 || Number(fixNumber(Number(totalLoan), 1) - this.state.perBS) == "-0.0" ? false : true })
this.setState({ loading: false, dataTable: newData, diff: fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS), 1), saveDraft: false, saveComp: Number(fixNumber(Number(totalLoan), 1) - this.state.perBS) == 0 || fixNumber(Number(fixNumber(Number(totalLoan), 1) - this.state.perBS),1) == "-0.0" ? false : true })
} else {
this.setState({ loading: false, dataTable: newData, diff: Number(Number(totalLoan) - this.state.perBS), saveDraft: false, saveComp: Number(Number(totalLoan) - this.state.perBS) == 0 || Number(Number(totalLoan) - this.state.perBS) == "-0.0" ? false : true })
this.setState({ loading: false, dataTable: newData, diff: fixNumber(Number(Number(totalLoan) - this.state.perBS),1), saveDraft: false, saveComp: Number(Number(totalLoan) - this.state.perBS) == 0 || fixNumber(Number(Number(totalLoan) - this.state.perBS),1) == "-0.0" ? false : true })
}
}
......
......@@ -2304,14 +2304,15 @@ export default class MonthlyReport extends Component {
}
handleDownloadReport(tableMeta) {
let { selectReport, company, periode, month } = this.state
let { selectReport, company, periode, month, defaultCurrency } = this.state
let payload = {
"company_id": company.company_id,
"year": periode.periode,
"report_id": selectReport,
"month": month ? String(month.month_id).toString() : "",
"quartal": "",
"type_report_name": "Monthly Report"
"type_report_name": "Monthly Report",
"currency_id" : defaultCurrency.id
}
console.log(payload);
api.create().createDownloadFile(payload).then((response) => {
......
......@@ -651,14 +651,15 @@ export default class OperatingIndicator extends Component {
}
handleDownloadReport(tableMeta) {
let { selectReport, company, periode, month } = this.state
let { selectReport, company, periode, month, defaultCurrency } = this.state
let payload = {
"company_id": company.company_id,
"year": periode.periode,
"report_id": selectReport,
"month": "",
"quartal": "",
"type_report_name": "Operating Indicator"
"type_report_name": "Operating Indicator",
"currency_id" : defaultCurrency.id
}
console.log(payload);
api.create().createDownloadFile(payload).then((response) => {
......
......@@ -1538,14 +1538,15 @@ export default class OutlookPA extends Component {
}
handleDownloadReport(tableMeta) {
let { selectReport, company, periode, month } = this.state
let { selectReport, company, periode, month, defaultCurrency } = this.state
let payload = {
"company_id": company.company_id,
"year": periode.periode,
"report_id": selectReport,
"month": "",
"quartal": "",
"type_report_name": "Outlook PA"
"type_report_name": "Outlook PA",
"currency_id" : defaultCurrency.id
}
console.log(payload);
api.create().createDownloadFile(payload).then((response) => {
......
......@@ -1231,7 +1231,8 @@ export default class BalanceSheetRO extends Component {
placeholder=""
// disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
disabled={this.props.quarter == 'q1' ? false : true}
value={this.props.defaultCurrency.id == 1 ? (this.props.quarter == 'q2' || this.props.quarter == 'q3' ? (val == "" ? "" : fixNumber(Number(val), 1)) : fixNumber(Number(val), 1)) : (this.props.quarter == 'q2' || this.props.quarter == 'q3' ? (val == "" ? "" : Number(val) == 0 ? "0.0" : Number(val)) : Number(val) == 0 ? "0.0" : Number(val))}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 1) : Number(val) == 0 ? "0.0" : Number(val)}
// value={this.props.defaultCurrency.id == 1 ? (this.props.quarter == 'q2' || this.props.quarter == 'q3' ? (val == "" ? "" : fixNumber(Number(val), 1)) : fixNumber(Number(val), 1)) : (this.props.quarter == 'q2' || this.props.quarter == 'q3' ? (val == "" ? "" : Number(val) == 0 ? "0.0" : Number(val)) : Number(val) == 0 ? "0.0" : Number(val))}
onBlur={(event) => {
handleChange(event.target.value, tableMeta)
}}
......@@ -2720,7 +2721,7 @@ export default class BalanceSheetRO extends Component {
type="text"
placeholder=""
disabled={true}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 1) : Number(val) == 0 ? "0.0" : Number(val)}
value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(val), 1) : Number(val) == 0 ? "0.0" : fixNumber(Number(val),1)}
/>
:
tableMeta.rowData[0] === 2 ?
......
......@@ -1553,14 +1553,15 @@ export default class RollingOutlook extends Component {
}
handleDownloadReport(tableMeta) {
let { selectReport, company, periode, quarter } = this.state
let { selectReport, company, periode, quarter, defaultCurrency } = this.state
let payload = {
"company_id": company.company_id,
"year": periode.periode,
"report_id": selectReport,
"month": "",
"quartal": quarter ? quarter.value : "",
"type_report_name": "Rolling Outlook"
"type_report_name": "Rolling Outlook",
"currency_id" : defaultCurrency.id
}
console.log(payload);
api.create().createDownloadFile(payload).then((response) => {
......
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